var server = "unvrso.ec";

function url_change()
{
	var urlchange;
	urlchange=location.href;
	if (location.href.indexOf('/Caricatura/') != -1)
	{
		var a = document.getElementsByName("lknews");
		if(a){if(PosPagBonil){urlchange=a.item(PosPagBonil-1);}}
	}	
	if (location.href.indexOf('/foto_galeria_') != -1){urlchange = urlchange + '#FG' + PosPag;}	
	return urlchange;
}

function fbs_click()
{
    u=location.href;
    t=document.title;
    u=url_change();
    //window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	//u="http://www.eluniverso.com/2011/05/19/1/1422/encuentran-dos-cadaveres-calcinados-un-auto.html?p=1354&m=1835";
    window.open('http://' + server + '/sharer.php?tipo=F&width=626&height=436&url=' + u + '&title=' + encode(t),'sharer','toolbar=0,status=0,width=626,height=436');
    return false;
}

function twiter_click()
{
    var u=location.href;
    var urlLength = 24;
    var documentLength = document.title.length;
	var finaltext = "...";
	//debugger;
    var tamanio = documentLength +  finaltext.length +  urlLength + 3;
    var MaxTamanio = 140 - tamanio;
    var t = document.title;
    if (MaxTamanio < 0)
    {
		MaxTamanio = 140 -  (finaltext.length +  urlLength + 3);
        t = '';
        var TitlePalabras  = document.title.split (" ");
        for (var ind = 0 ; ind < TitlePalabras.length ; ind++)
        {
            if (TitlePalabras[ind] != '')
            {
                if ( (t + TitlePalabras[ind] + ' ').length < MaxTamanio)
                {
                   t += TitlePalabras[ind] + ' ';
                }
            }
        }
    }
    u=url_change();
	//u="http://www.eluniverso.com/2011/05/19/1/1422/encuentran-dos-cadaveres-calcinados-un-auto.html?p=1354&m=1835";
	window.open('http://' + server + '/sharer.php?tipo=T&width=626&height=436&url=' + u + '&title=' + encode(t) ,'sharer','toolbar=0,status=0,width=626,height=436');
    //window.open('http://twitter.com/home?status=' + t  + ' ' + u ,'sharer','toolbar=0,status=0,width=626,height=436');
    return false;
}
function  encode(t)
{
	return encodeURIComponent( t ).replace( /\%20/g, '+' ).replace( /!/g, '%21' ).replace( /\'/g, '%27' ).replace( /\(/g, '%28' ).replace( /\)/g, '%29' ).replace( /\*/g, '%2A' ).replace( /\~/g, '%7E' );
}

function GetThisDelicious()
{                            
    var T = document.title;
    var U = location.href;
	//var targetUrl = 'http://del.icio.us/post?url=' + encodeURIComponent(U) + '&title=' + encodeURIComponent(T);
	U=url_change();
	window.open('http://' + server + '/sharer.php?tipo=D&width=626&height=436&url=' + U+ '&title=' + T,'sharer','toolbar=0,status=0,width=626,height=436');
	//window.open(targetUrl,'sharer','toolbar=0,status=0,width=626,height=436');
    return false;
}
function GetThis()
{                            
    var T = document.title;
    var C = ' ';
    var U = location.href;
    var L = ' ';
    U=url_change();
//    var targetUrl = 'http://www.myspace.com/index.cfm?fuseaction=postto&' + 't=' + encodeURIComponent(T) + '&c=' + encodeURIComponent(C) + '&u=' + encodeURIComponent(U) + '&l=' + L;
	window.open('http://' + server + '/sharer.php?tipo=M&width=626&height=436&url=' + U+ '&title=' + T,'sharer','toolbar=0,status=0,width=626,height=436');
//    window.open(targetUrl,'sharer','toolbar=0,status=0,width=626,height=436');
    return false;
}   


document.getElementById('botonescompartir').innerHTML = "<span >Compartir: </span> <a style='cursor:pointer;padding: 0pt 5px 0pt 4px' onclick='return fbs_click()' target='_blank' title = 'Facebook'  ><img class='imgComp' src='/versiones/v1/img/Global/FaceBook.png' alt='Facebook' /></a> "
+ " <a style='cursor:pointer;padding: 0pt 5px 0pt 4pt' onclick='return twiter_click()' target='_blank' title = 'Twitter'><img src='/versiones/v1/img/Global/twiter.png' alt='Twitter'  class='imgComp'/></a> "
+ " <a style='cursor:pointer;padding: 0pt 5px 0pt 0pt' onclick='return GetThis();' target='_blank' title = 'MySpace'><img src='/versiones/v1/img/Global/post_myspace_icon.gif' border='0' alt='MySpace' class='imgComp'/></a> "
+ " <a style='cursor:pointer;padding: 0pt 5px 0pt 0pt' onclick='return GetThisDelicious()' target='_blank' title = 'Delicious'><img src='/versiones/v1/img/Global/delicious_icon.png' alt='Delicious' class='imgComp'/></a> " ;


