// Captcha
var captchaurl;
function captchareload() {
	var tmp=new Date();
	$("img#captcha").attr("src",captchaurl+"?time="+tmp.getTime());
	return false;
}

$(function(){
	captchaurl=$("img#captcha").attr("src");
	$("a#captchareload").click(captchareload);
});

$(document).ready(function(){
	
	 $('#submenu').hide();     
     $('a#slick-show').click(function() {
       $('#submenu').show('slow');
       return false;
     });
  
     $('a#slick-hide').click(function() {
       $('#submenu').hide('fast');
       return false;
     });
  
     $('a#slick-toggle').click(function() {
       $('#submenu').toggle(400);
       return false;
     });
	
      $('#mapa_google').hide(); 
      $('a#mapa-show').click(function() {
        $('#mapa_google').show('slow');
        return false;
      });  
      $('a#mapa-hide').click(function() {
        $('#mapa_google').hide('fast');
        return false;
      });  
      $('a#mapa-toggle').click(function() {
        $('#mapa_google').toggle(400);
        return false;
      });
	
	// Formularios
	$(".dato:first input").focus();
	var span_error = $(".dato .requerido").length;
	for(i=0;i< span_error; i++){
		if($(".dato .error").text()){
			$(".dato .error").siblings(".requerido").addClass("borde-error");			
		}
	}
	$(".dato .requerido").live({
		  keypress:function(){
			  $(this).siblings(".error").hide();  
			  $(this).removeClass("borde-error");
		  },
		  focus:function(){
			  $(this).siblings(".error").hide(); 
			  $(this).removeClass("borde-error");
		  },		 
		  focusout: function(){
			  if($(this).attr("value")){
				  $(this).siblings(".error").hide();
			  }
			  else{
				  $(this).siblings(".error").show();
				  $(this).addClass("borde-error");
			  }
		  }
	});
	$(".dato .error").live({
		click:function(){
	
		  $(this).hide(); 
		  $(this).siblings(".requerido").removeClass("borde-error").focus();
		}
	});
	  		
	$(".tejas .listado li").hover(			
	function(){$(this).addClass("hover");},
	function(){$(this).removeClass("hover");}
	);
	
	$(".eep span").hide();
	$(".eep").hover(
		function() {
			$("span",this).show();
		},
		function() {
			$("span",this).hide();
		}
	);
});
