/* Google Analytics Start */ _uacct = "UA-2519041-2";urchinTracker();


$(document).ready(function () {

	// Alterando la maqueta.
	$("#pestanas/li/a").append('<span class="left"></span><span class="right"></span>');
	$("#lateral").prepend('<li class="top"></li>');
	$("#lateral").append('<li class="bottom"></li>');

	$("#anadirFavoritos").click(function(){
		if ($.browser.msie)
			window.external.AddFavorite("http://www.sportinca.com","Club Deportivo SportInca");
		else
			alert("Las protecciones de su navegador no nos permiten añadir la página a sus favoritos. \n Presione Ctrl+D para hacerlo manualmente.");
		return false;
	});

	
	// Ayudas de raton.

	$.mouseConfig.maxWidth = 180;
	$.mouseConfig.format = '<p><span class="T"></span><span>%title%</span><span class="B"></span></p>';
	$("#pestanas/li/a,img").toMouse();
	$(".evento").toMouse();

	// Links Externos.
	var link = $("a");
	for (var i=0;i<link.length;i++){
		if ( !link[i].href.split("ttp://www.sportinca.co")[1] )
		$(link[i]).click (function(){ return !window.open(this.href); });
	}

	// Alerta antes de borrar nada.
	$(".borrar").click(function(){
		if (confirm("Hey! Seguro que quieres borrarlo?")) return true;
		else return false;
	})

	// Horarios

	var D=$("#horario/.dias/li")
	for (i=0;i<D.length;i++){
		$(D[i]).css({
			left : i*100/D.length - 1 + "%",
			width :  100/D.length - 1 + "%"
		})

	}

	var P=$("#horario/#contDias/.dia/.pista")
	for (i=0;i<P.length;i++){
		$(P[i]).css({
			width :  Math.floor(440/$(P[i]).parent().find(".pista").length)

		})

	}

	var E=$("#horario/#contDias/.dia/.pista/.evento")
	for (i=0;i<E.length;i++){
		H = String( $(E[i]).find("span").html() ).split("/")
		if ( H[1].split(":")[0] == "00" ) { $(E[i]).remove() } else {
			H[0] = (H[0].charAt(0)=="0") ? H[0].substring(1) : H[0];
			H[1] = (H[1].charAt(0)=="0") ? H[1].substring(1) : H[1];
			Etop = ( (H[0].split(":")[0] - 8) * 36 ) + ( H[0].split(":")[1] / 15 * 9 ) + 30 ;
			Eheight = ( ( parseInt(H[1].split(":")[0]) - 8 ) * 36 ) + ( parseInt(H[1].split(":")[1]) / 15 * 9 ) + 30 - Etop -1 ;
			if (Eheight > 0)
			$(E[i]).css({
				height :  Eheight + "px",
				lineHeight : Eheight + "px",
				top : Etop + "px" 
			})
		}
	}

	selectDia($("#horario/.dias/li:first"));

	$("#horario/.dias/li").click(function(){selectDia(this);})
});

selectDia = function(el){
	$("#horario/.dias/li").removeAttr("class");
	$("#horario/#contDias/.dia").css("display","none");
	$("#b" + $(el).attr("id") ).fadeIn("slow");
	$(el).attr("class","selected")
}

