/* Google analytics */
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
try {
	var pageTracker = _gat._getTracker("UA-9059953-1");
	pageTracker._trackPageview();
} catch(err) {}

/* Hack para evitar flicker de rollover en IE6 */
if($.browser.msie){	try { document.execCommand('BackgroundImageCache', false, true);} catch(e) {}; };

function valores(){
	//$("#valores #contenido dl.valoresen dt#val1, #valores #contenido dt.valoresde h1#val1").append("<span class='b'> </span>");
	//$("#valores #contenido dl").hide().fadeIn(2000);
	//$("#valores #contenido dl dt").find("span").fadeTo(0,0);
//	$("#valores #contenido dl dt").hover(
//		function() { 
//			$(this).parents("dl").find("dt").not(this).find("span").fadeTo(200, .7);
//			$(this).next().fadeIn(500);
//		},
//		function() { 
//			$(this).parents("dl").find("dt span").fadeTo(200, 0);
//			$(this).next().fadeOut(500);
//		}
//	);
	$("#valores #contenido dl").hide().fadeIn(2000);
	$("#valores #contenido dl div").hide();
	$("#valores #contenido dl h1").hover(
		function() { 
			//$(this).parents("dl").find("h1").not(this).fadeTo(500, .2);
			$(this).next().fadeIn(500);
			
		},
		function() { 
		//	$(this).parents("dl").find("h1").not(this).fadeTo(500, 1);
			$(this).next().fadeOut(500);
		}
	);
};



function localizador(){
		$("body#contacto #plano span#sl1").after("<img src='img/localizador.gif' id='localizador'>");
		$("img#localizador").hide();
		$("body#contacto #plano span#sl1").hover(
			function(){	$("img#localizador").fadeIn(1000);},
			function(){ $("img#localizador").fadeOut(1000);}
		);
};

function localizador2(){
		$("body#contacto #plano span#sl").after("<img src='img/localizador2.gif' id='localizador2'>");
		$("img#localizador2").hide();
		$("body#contacto #plano span#sl").hover(
			function(){	$("img#localizador2").fadeIn(1000);},
			function(){ $("img#localizador2").fadeOut(1000);}
		);
};


function antispam(){
	q = "ndp"; s = "ana"; o = "ulj"; w = "inf";  u = "o@b"; i = "art"; v = "ners"; j = ".com";
	return  w+u+o+s+q+i+v+j;
};

function antispam2(){
	q = "ndp"; s = "ana"; o = "ulj"; w = "inf";  u = "o@b"; i = "art"; v = "ners"; j = ".de";
	return  w+u+o+s+q+i+v+j;
};

function tableformat(){
	$("#tabcontenido tr:even").addClass("even");
	$("#tabcontenido a").hover(
		function() { $(this).parents("tr").addClass("activo"); },
		function() { $(this).parents("tr").removeClass("activo");}
	);
};

function cuadclientes(){
	$("#cuadclientes li:first-child").addClass("primera");
	$("#cuadclientes li:last-child").addClass("ultima");
	$("#cuadclientes #listado span:odd").addClass("even");
};

function miportal(){
	$("#miportal").hide();
	$("#pie #items li.pliportal").hover(
		function(){
			$(this).addClass("activo");
			$("#pie #items li.pliportal span").addClass("hover");
			$("#miportal").fadeIn(200);
		},
		function(){
			$(this).removeClass("activo");
			$("#pie #items li.pliportal span").removeClass("hover");
			$("#miportal").fadeOut(200);
		}
	);
};

function slider(){
	$("#slider").fadeTo(0,0).fadeTo(500, 1);
	$("#slider li").hide();
	$("#slider li:first-child").show().addClass("current");
	
	function resize(){
		var altura = $(".current").height();
		//alert (altura);
		$(".current").parents("ul").animate({height: [altura+40] + "px"}, 500);
	};
	
	function fader(){
		var ultimo = $("#slider li:last-child").hasClass("current");
			if (ultimo) {
				$("#slider li:last-child").removeClass("current").fadeOut(500, function(){
					$("#slider li:first-child").fadeIn(500).addClass("current");
					resize();
				});
			}
			else {
				$("#slider li:visible").removeClass("current").fadeOut(1000, function(){
					var siguiente = $(this).next();
					$(siguiente).fadeIn(500).addClass("current");
					resize();
				});
			}
	};
	
	$("#slider").next().find("span").hover(
			function() { $(this).addClass("hover");},
			function() { $(this).removeClass("hover");})
		.bind("click", function(){ resize(); })
		.click( function(){
			fader();	
			return false;
		});
};


$(document).ready(function(e) {

	valores();	
	localizador();
	localizador2();
	tableformat();
	cuadclientes();
	slider();
	miportal();
	
	$("#servgraf").hide().fadeIn(2000)
	$("#servgraf #servc2").hover(
		function() { $("#servgraf").addClass("hover");},
		function() { $("#servgraf").removeClass("hover");}
	);
	
	$("#direcciones").hide().fadeIn(2000)
	$("#planoale").hide()
	$("#direcciones #dirale").hover(
		function() {
			$("#direcciones").addClass("hover");
			$("#planoesp").fadeOut(500);
			$("#planoale").fadeIn(500);
		}
	);
	$("#direcciones #diresp").hover(
		function() {
			$("#direcciones").removeClass("hover");
			$("#planoale").fadeOut(500);
			$("#planoesp").fadeIn(500);
			}
	);
	
	if (location.pathname == '/contacto/de') {
			$("#direcciones").addClass("hover");
			$("#planoesp").hide();
			$("#planoale").fadeIn(2000);
	}
	
	$("a[rel='external']").click(function(){ this.target = "_blank"; });
	$("a[rel='contacto']").html(antispam()).click(function(){ this.href = "mailto:"+antispam(); });	
	$("a[rel='contactoaleman']").html(antispam2()).click(function(){ this.href = "mailto:"+antispam2(); });	
	//$("a[rel='candidatos']").click(function(){ this.href = "mailto:rrhh@smartworxx.es" });	
	
	$('#tabpublicaciones div.scroll').jScrollPane().css("padding-right","0px").css("width", "899px");
	if($.browser.msie){	$("#tabpublicaciones").css("background-position", "541px"); };
	
});
