/*
 *	eduardoleon-webcard.js
 *	Autor: Eduardo León Pavón
 *	http://www.eduardoleon.net
 *	Creado el 10 de Noviembre de 2009
 */

$(document).ready(function() {
						   
	/*
	Inicializar variables y mostrar la primera pestagna.
	*/	
	$('#tabs-container ul:first').show();
	$('.nav li a:first').addClass('current');


	/*
	Establece los bordes redondeados para cada navegador.
	*/
	function PropiedadesEspecificasCSS() {		
		if ($.browser.safari) {
			$('#tabs-container .tab LI A').css({ WebkitBorderRadius: 5 });
			$("#descripcion").css({ WebkitBorderRadius: 5 });
			$("#descripcion A").css({ WebkitBorderRadius: 0 });
		}
		else if ($.browser.mozilla) {
			$('#tabs-container .tab LI A').css({ MozBorderRadius: 5 });
			$("#descripcion").css({ MozBorderRadius: 5 });
			$("#descripcion A").css({ MozBorderRadius: 0 });
		}
	}
	
	PropiedadesEspecificasCSS();

	/*
	Mostrar los créditos
	*/
	function Creditos() {
		var lucesoff = $('<div>').attr({ className: 'lucesoff', id: 'lucesoff' });
		$('body').append(lucesoff);
		lucesoff = $('#lucesoff');
		if ($.browser.msie) lucesoff.css('filter', 'alpha(opacity=70)');
		lucesoff
			.css('width', $(window).width())
			.css('height', $(window).height())
			.die('click')
			.live('click', function() { $(this).fadeOut(500, function() { $(this).remove(); }); })
			.load('creditos.html').fadeIn(500);
	}
	
	/*
	Gestión de las pestagnas
	*/	
	$('.nav li a').click(function() {
		if (!($(this).hasClass('current'))) {		
			var module = $($(this).attr('href'));
			var container = $('#tabs-container');
			
			container.children(':visible').fadeOut(500, function() {
				module.fadeIn(600);
				//container.animate({ 'height': module.height() }, 500);
			});
			
			$('.nav a.current').toggleClass('current');
			$(this).toggleClass('current');
		}
		
		return false;
	});
		

	
	$('#info').click(Creditos);
	
	function MostrarVcard() {
		$("#avatar span").show();
		$("#avatar span").animate({
			top: "43px",
			opacity: 1
		}, 250 );
	}

	function OcultarVcard() {
		$("#avatar span").animate({ 
			top: "35px",
			opacity: 0
		}, 250 );
		setTimeout("$('#avatar span').hide();", 250);
		$("#avatar span").animate({ 
			top: "30px",
		}, 250 );
	}
		
	$("#avatar").hover(MostrarVcard, OcultarVcard);
	
	/*
	 * Establece el idioma en inglés si el navegador
	 * tiene un idioma distinto del castellano.
	 */
	function ConfigurarIdioma(){		
		var lang = new String;
		if (navigator.language){
		   lang = navigator.language;
		} else {
		   lang = navigator.browserLanguage;
		}
		lang=lang.split("-");
		lang=lang[0];
		if(lang != "es"){
			$("#author p").html("<strong>Computer engineer,<br /> eAdministration</strong> in Valdepeñas. ");
			$("#wblog a strong").html("My blog");
			$("#wemail a strong").html("Mail");
			$("#navquiensoy").html("Who I am");
			$("#navcontacto").html("Contact");
			$("#avatar span").html("DOWNLOAD VCARD");
			$("#email a strong").html("Mail");
			$("#piehoja p span").html("Under Creative Commons 3.0 license ");
			$("#descripcion p").html("I am a <strong>software engineer,</strong> born in Puertollano (Ciudad Real, Spain). " 
                    +"I´m lucky to have had the chance to learn from notable masters in the <a target=\"_blank\""
                    +"href=\"http://www.esi.uclm.es\">ESI</a> of Ciudad Real (<a target=\"_blank\" href=\"http://www.uclm.es\">UCLM</a>).<br />"
                    +"Nowadays I am performing in the IT industry using leading technologies like <strong>.Net, J2EE or PHP.</strong>");
		}
	}
	
	ConfigurarIdioma();
	
	
});

