
$(function(){

// Efecto ocultar y mostrar googlemaps
    $('.showMap').click(function(){
        $('.maps').slideToggle(500);
        return false;
    });
	
	tooltip();

	if($('.slideIn').length>0){pBar(790);}else{
		$("#menuPrincipal").css('background-position','0px 0px').find('ul').show();
	}
});
	
// Efecto carga de  pagina
function pBar(ig){
	r=Math.floor(Math.random()*ig);
	c=Math.floor(Math.random()*300);
	if(r>10){
		$("#menuPrincipal").animate({backgroundPosition:(r*-1)+'px 0px'},100,function(){setTimeout('pBar('+r+')',c);});
	}else{
		$("#menuPrincipal").animate({backgroundPosition:'0px 0px'},100,function(){
			$('#menuPrincipal ul').fadeIn(100,function(){
				$('.slideIn').slideDown(200);
			});
	
		});
	}
} 
/*

// Efecto paso de input a password    
$('.password-clear').show();
$('.pass').hide();
$('.password-clear').focus(function() {
  $('.password-clear').hide();
  $('.pass').show();
  $('.pass').focus();
  });
$('.pass').blur(function() {
  if($('.pass')   .val() == '') {
  $('.password-clear').show();
  $('.pass').hide();
  }
});

$("input").live('click',function(){if($(this).attr("title")==$(this).val())$(this).val("");});
$("input").live('blur',function(){if(!$(this).val())$(this).val($(this).attr("title"));});
*/


// Efecto flash en menu principal
$(document).ready(function() {
	$("#topnav li").prepend("<span></span>");  
	//Crear un espacio vacío antes de la etiqueta  
	$("#topnav li").each(function() {  
		//Por cada item  
		var linkText = $(this).find("a").html();  
		//Encontrar el texto denteo de la etiqueta <a>  
		$(this).find("span").show().html(linkText);  
		//Agregar el texto a la etiqueta span  
	});  
	$("#topnav li").hover(function() {  
		//En el hover (cuando el puntero del mouse se posiciona por encima)...  
		$(this).find("span").stop().animate({  
			marginTop: "-40" //Encontrar la etiqueta<span> y moverla 40 px hacia arriba.  
		}, 250);  
	} , function() { //Cuando se quita (retira o mueve) el puntero del mouse...  
		$(this).find("span").stop().animate({  
			marginTop: "0"  //Mover la etiqueta <span> devuelta a la posición original (0px)  
		}, 250);  
	});  
});


/*
 * Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */

this.tooltip = function(){
	/* CONFIG */
		xOffset = -20;
		yOffset = 20;
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */
	$("a.tooltip").hover(function(e){
		this.t = this.title;
		this.title = "";
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");
    },

	function(){
		this.title = this.t;
		$("#tooltip").remove();
    });
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});
};


