// JavaScript Document


function menuSup(){
  //$('#sitio #contenedor #cabecera #menu div.fade').hover(function() {	    		 
	$('div.fade').hover(function() {	    		   
		var fade = $('.capa', this);
		//var but=$(this);						    
		if (fade.is(':animated')) {
		  fade.stop(true, true).fadeIn(100);
		} else {
		  fade.fadeIn(100);
		}			
  }, function () {
		var fade = $('.capa', this);
		if (fade.is(':animated')) {
		  fade.stop(true, true).fadeOut(450);
		} else {
		  fade.fadeOut(450);
		}
  });
  /*
  $('#sitio #contenedor #cabecera #idiomas div.fade').hover(function() {	    		 
		var fade = $('.capa', this);
		//var but=$(this);						    
		if (fade.is(':animated')) {
		  fade.stop(true, true).fadeIn(100);
		} else {
		  fade.fadeIn(100);
		}			
  }, function () {
		var fade = $('.capa', this);
		if (fade.is(':animated')) {
		  fade.stop(true, true).fadeOut(450);
		} else {
		  fade.fadeOut(450);
		}
  });  */
  
}





function menuLat(){
   //menu lateral
  $('#menulateral div.fadelateral').hover(function() {   		 
   
	var fade = $('.anim' , this);
		if (fade.is(':animated')) {
		  fade.stop(true, true).fadeIn(100);
		} else {
		  fade.fadeIn(100);  
		}			
		  }, function () {
				var fade = $('.anim', this);
				if (fade.is(':animated')) {
				  fade.stop(true, true).fadeOut(200);
				} else {
				  fade.fadeOut(200);
		}
  });
  
  //$('#menulateral div.fadelateral').click(function() {     
  // $('.submenu' , this).slideToggle(450);
  //});
  
 //submenu lateral
  $('#menulateral div.subfadelateral').hover(function() {   		 
	var fade = $('.subanim' , this);
		if (fade.is(':animated')) {
		  fade.stop(true, true).fadeIn(100);
		} else {
		  fade.fadeIn(100);
		}			
		  }, function () {

			if ($("#subirimagen").length == 0){	
					var fade = $('.subanim', this);
					if (fade.is(':animated')) {
					  fade.stop(true, true).fadeOut(450);
					} else {
					  fade.fadeOut(450);
					}
			}
  });
  
}

function leermas(){	 
			if ($(".leermas a,img").length > 0){		 
		 		$('.leermas a,img').hover(function() {   
					$('img',this).stop(true, true).animate({marginLeft: '+=5'},'fast').fadeTo('fast', 0.7);
				 }, function () {
					$('img',this).stop(true, true).animate({marginLeft: '-=5'},'fast').fadeTo('fast', 1);
				 });				 
	 		}		
}

function paginarhover(){	 
			if ($(".botonpaginar").length > 0){		 
		 		$('.botonpaginar').hover(function() {   
					$(this).stop(true, true).fadeTo(300, 0.5);
				 }, function () {
					$(this).stop(true, true).fadeTo('slow', 1);
				 });
				  $('.botonpaginar').click(function() {     
				   $(this).fadeTo('fast', 0.3);
				  });				 
				 
				 				 
	 		}		
}







function validaemail(str) {
		var error=0;
		var at="@";
		var dot=".";
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
			error=1;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			error=1;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			error=1;

		}

		 if (str.indexOf(at,(lat+1))!=-1){
			error=1;

		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			error=1;

		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			error=1;

		 }
		
		 if (str.indexOf(" ")!=-1){
		    error=1;
		 }
		 
		if (error==1){
		   return false		 
		}else{
 		 return true					
		}
	}







//notícies 
function noticiaspie(pag){

valorpag=pag;	
     $.ajaxSetup ({  
         cache: false,
		 contentType: "application/x-www-form-urlencoded;charset=ISO-8859-15"
		 //contentType: "application/x-www-form-urlencoded;charset=utf-8"
     });  
	 
$.post("includes/AjaxNoticiasPie.php", { pagpie: valorpag},
   function(data){
     $('.actualidadcontainer').delay(1000).html(data);
 });
}


//notícies 
function galeria(pag){
valorpag=pag;	
     $.ajaxSetup ({  
         cache: false,
		 contentType: "application/x-www-form-urlencoded;charset=ISO-8859-15"
		 //contentType: "application/x-www-form-urlencoded;charset=utf-8"
     }); 

$('#galeria .titulo').hide();	  
$('#galeria #contenidoimagen img').attr('src','images/anim.gif').css('marginTop','185px').delay(800);
//$('#galeria').load('includes/AjaxGaleria.php',{pag: valorpag} );	


$('#galeria #contenidoimagen img').animate({opacity:0}, 'fast', function() {    
		$('#galeria').hide()//ocultar galeria
		.load('includes/AjaxGaleria.php',{pag: valorpag}).show();
  });
$('#galeria #contenidoimagen ').hide().fadeIn(1000);
$('#galeria .titulo').slideDown(3000);	
	
	//$('#galeria #contenidoimagen img').animate({'margin-left':'+=200px',opacity:1}, 0);  

		$('#galeria .titulo').hide();	

//.animate({'margin-right':'+=400px',opacity:0},0)
//.animate({'margin-right':'-=200px',opacity:1},300);	

}

