// JavaScript Document

function validarEmail(valor) {

  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){

   return (true)

  } else {

   return (false);

  }

}
function abrirPopup(url,ancho,alto) {
	if(!ancho){ancho=500}
	if(!alto){alto=500}
var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, width="+ancho+", height="+alto+", top=150, left=250";
window.open(url,"",opciones);
return false;
}
function ani_boletin(){
	var obj = $('#tec');
	var obj2 = $('#eve');
	var obj3 = $('#inv');
	obj.animate({"left":"-=115px"},2500,function(){
		obj.animate({"opacity":0},1000,function(){
			obj.animate({'left':'145px'},500,function(){
				obj.css({'opacity':1});
				obj2.animate({"left":"-=115px"},2500,function(){
					obj2.animate({"opacity":0},1000,function(){
						obj2.animate({'left':'145px'},500,function(){
						obj2.css({'opacity':1});
							obj3.animate({"left":"+=115px"},2500,function(){
							obj3.animate({"opacity":0},1000,function(){
							obj3.animate({'left':'-102px'},500,function(){
							obj3.css({'opacity':1});
									});
								});
							});
						});
					});
				});
			});
		});
		
	});

}
function ani_caso(){
	var obj = $('#lamex');

	obj.animate({"left":"-=115px"},2500,function(){
		obj.animate({"opacity":0},1000,function(){
			obj.animate({'left':'145px'},500,function(){
				obj.css({'opacity':1});
				
			});
		});
		
	});

}
function slideShow() {

	//Set the opacity of all images to 0
	$('#gallery a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	$('#gallery .caption').css({opacity: 0.8});

	//Resize the width of the caption according to the image width
	$('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	$('#gallery .content').html($('#gallery a:first').find('.dato').html())
	.animate({opacity: 0.6}, 50);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery()',6000);
	
}

function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));	
	
	//Get next image caption
	//var caption = next.find('img').attr('rel');	
	var caption = next.find('.dato').html();	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	$('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#gallery .caption').animate({opacity: 0.8},100 ).animate({height: '36px'},500 );
	
	//Display the content
	$('#gallery .content').html(caption);
	
	
}
function promocion(){
	$('#acceso_promo img.img_1').fadeOut(4000,function(){
			if($('#acceso_promo img').is('.img_2')){
			$('#acceso_promo img.img_2').fadeIn(50,function(){
				$('#acceso_promo img.img_2').fadeOut(3000,function(){
					$('#acceso_promo img.img_1').fadeIn(50,promocion);			   
				});
			});
			}else{
				//alert('ok');
				$('#acceso_promo img.img_1').fadeIn(50,promocion);
			}
	});
	
}
$(document).ready(function(){	
		$('#acceso_sof ul li').hover(function(){
				$(this).find("img:first").css({"width":"39px"});
				  $(this).find("img:first").animate({"width":"+=10px"},{queue:false,duration:200 });
			  },function(){
				 //$(this).find("img:first").animate({"width":"-=10px"},{ duration:0 });
				 $(this).find("img:first").css({"width":"39px"});
		});
		
		setInterval('ani_boletin()',12000);
			ani_boletin();
			setInterval('ani_caso()',6000);
			ani_caso();
			promocion();
})
$(document).ready(function() {		
	
	//Execute the slideShow
	slideShow();

});


