function popup(url,ancho,alto,id,extras){
	if(navigator.userAgent.indexOf("Mac")>0){ancho=parseInt(ancho)+15;alto=parseInt(alto)+15;}
	var left = (screen.availWidth-ancho)/2;
	var top = (screen.availHeight-alto)/2;
	if(extras!=""){extras=","+extras;};
	var ventana = window.open(url,id,'width='+ancho+',height='+alto+',left='+left+',top='+top+',screenX='+left+',screenY='+top+extras);
	var bloqueado = "AVISO:\n\nPara ver este contenido es necesario que desactive\nel Bloqueo de Ventanas para este Sitio."
	//var bloqueado = "WARNING:\n\nIn order to use this functionality, you need\nto deactivate Popup Blocking for this site."
	if(ventana==null || typeof(ventana.document)=="undefined"){ alert(bloqueado) }else{ return ventana; };
}

function setPageTitle(title){
	document.title = title;
}

function sendSocialBookmark(site){
	switch(site){
		case 'facebook':
			window.open('http://www.facebook.com/share.php?u='+encodeURIComponent(location.href)+'&t='+encodeURIComponent(document.title));
		break;
		case 'digg':
			window.open('http://digg.com/submit?phase=2&amp;url='+encodeURIComponent(location.href)+'&amp;bodytext=&amp;tags=&amp;title='+encodeURIComponent(document.title));
		break;
		case 'delicious':
			window.open('http://del.icio.us/post?v=2&amp;url='+encodeURIComponent(location.href)+'&amp;notes=&amp;tags=&amp;title='+encodeURIComponent(document.title))
		break;
		case 'stumbleupon':
			window.open('http://www.stumbleupon.com/submit?url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title))
		break;
		case 'yahoo':
			window.open('http://myweb2.search.yahoo.com/myresults/bookmarklet?t='+encodeURIComponent(document.title)+'&amp;d=&amp;tag=&amp;u='+encodeURIComponent(location.href))
		break;
		case 'google':
			window.open('http://www.google.com/bookmarks/mark?op=add&amp;hl=es&amp;bkmk='+encodeURIComponent(location.href)+'&amp;annotation=&amp;labels=&amp;title='+encodeURIComponent(document.title))
		break;
		case 'live':
			window.open('https://favorites.live.com/quickadd.aspx?marklet=1&url='+encodeURIComponent(location.href)+'&top=1&title='+encodeURIComponent(document.title))
		break;
		case 'myspace':
			window.open('http://www.myspace.com/Modules/PostTo/Pages/?u='+encodeURIComponent(location.href)+'&t='+encodeURIComponent(document.title))
		break;
	}
}

function writeCookie(name, value, hours, path){
	var domain = document.domain;
	var expire = "";
	if(hours != null){
		expire = new Date((new Date()).getTime() + hours * 3600000);
		expire = "; expires=" + expire.toGMTString();
	}
	document.cookie = name + "=" + escape(value) + expire + "; path=" + path + "; domain=" + domain;
}

function readCookie(name){
	var cookieValue = "";
	var search = name + "=";
	if(document.cookie.length > 0){ 
		offset = document.cookie.indexOf(search);
		if (offset != -1){ 
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
			cookieValue = unescape(document.cookie.substring(offset, end));
		}
	}
	return cookieValue;
}

function randomNumber(){
	return Math.floor(Math.random()*99999999);
}

function ad_tracking(url){
	$('#tracking_tag').remove();
	$('body').append('<a href="http://ad.doubleclick.net/jump/dla.es.tudis/telmex_logotimeline;sz=1x1;ord=123456789?" target="_blank" id="tracking_tag"><img src="'+ url + '#'+ randomNumber() +'" width="1" height="1" border="0" alt=""></a>');	
}