anchor = {
	init : function() {
		jQuery("a.comentar").click(function () {
		  	jQuery("#form_comment").fadeIn("slow");	
			elementClick = jQuery(this).attr("href")
			destination = jQuery(elementClick).offset().top;
			jQuery("html ,body").animate({ scrollTop: destination}, 800 );
			/*$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 1100 );*/
			return false;
		})
	}
}

function oscurece_pantalla(mensaje)
{
	var mensaje 	= jQuery('<div id="TB_load"><p style="text-align:center;">'+mensaje+'<br><img src="images/loader_login.gif" alt="loading..." /></p></div>');
	mensaje.appendTo("body").hide();
	try {										 
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
			jQuery("body","html").css({height: "100%", width: "100%"});
			jQuery("html").css("overflow","hidden");
		}else{//all others
			if(document.getElementById("TB_overlay") === null)	{
				jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
			}
		}	
		if(tb_detectMacXFF()){
			jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
			}else{
			jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
		}
		jQuery().ajaxStart(function() {mensaje.fadeIn();}).ajaxStop(function() {mensaje.fadeOut();	});	
		jQuery('#TB_load').show();//show loader
	}
	catch(e){alert(e);}	
}

function tb_remove() 
{
 	jQuery("#TB_imageOff").unbind("click");
  	jQuery("#TB_closeWindowButton").unbind("click");
  	jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
  	jQuery("#TB_load").remove();
  	if (typeof document.body.style.maxHeight == "undefined")
	{//if IE 6
    	jQuery("body","html").css({height: "auto", width: "auto"});
    	jQuery("html").css("overflow","");
 	}
 	document.onkeydown 	= "";
  	document.onkeyup 	= "";
  return false;
}

function tb_detectMacXFF() 
{
	var userAgent = navigator.userAgent.toLowerCase();
  	if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) 
	{
    	return true;
  	}
}

function mainmenu(){
	jQuery(" #nav ul ").css({display: "none"}); // Opera Fix
	jQuery(" #nav li").hover(function()
	{
		jQuery(this).find('ul:first').css({visibility: "visible",display: "none"}).show(0);
	},function()
	{
		jQuery(this).find('ul:first').css({visibility: "hidden"});
	});
}

function calendario(mo,yr)
{	
	var loader = jQuery('<div id="loading"><img src="images/loading.gif"></div>');
	loader.appendTo( jQuery("#fecha_calendar")).hide();
	
	jQuery().ajaxStart(function() {
			loader.show();
		}).ajaxStop(function() {
			loader.hide();	
			jQuery("#loading").remove();
		});	
	
	jQuery("#muestra_calendario").fadeOut('slow', function() {
		jQuery("#muestra_calendario").load("libs_php/calendario.php?mes="+mo+"&anho="+yr);
		jQuery("#muestra_calendario").fadeIn('slow');
	});
}


function contador_click(id,tipo)
{
	jQuery.ajax({
   		url: "libs_php/contador_clicks.php?id="+id+"&tipo="+tipo,
   		dataType: "json",
   		success: function(data){
			window.open(data.links);
		}
 	});
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function cargarListado(pag) {
		var	cat	=	jQuery("#spot_deporte").val();
		var	opc	=	jQuery("#pais_spot").val();
		(pag=="" || pag == undefined)?pag="pag="+1:pag="pag="+pag;
		(cat != undefined)?cate="&cat="+cat:cate="";	
		(opc != undefined)?opc="&opc="+Url.encode(opc):opc="";	
		
		jQuery("#listar ul").empty()
			.load("libs_php/functions.spots.php?"+pag+cate+opc+" #listar ul")
			.hide()
			.show();	
}
function cargarPaginado() {
		var	cat	=	jQuery("#spot_deporte").val();
		var	opc	=	jQuery("#pais_spot").val();
		(cat != undefined)?cate="cat="+cat:cate="";	
		(opc != undefined)?opc="&opc="+Url.encode(opc):opc="";	

		jQuery("#paginado").empty()
			 .load("libs_php/functions.spots.php?"+cate+opc+" .paginador")
			.hide()
			.show();	
		setTimeout("jQuery.getScript('js/functions.paginador.js')",2500);

}