// JavaScript Document

$(document).ready(function()
	{
		$('#slideshow').cycle({ 
		fx:     'fade', 
		speed:   900, 
		timeout: 3000, 
		pause:   1 
	});
		
		
	//Tabs	
	$(".tab_content").hide();
	$("ul.tabs li:first").addClass("active").show();
	$(".tab_content:first").show();

	$("ul.tabs li").click(function()
       {
		$("ul.tabs li").removeClass("active");
		$(this).addClass("active");
		$(".tab_content").hide();

		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn();
		return false;
	});
	
	
	//Forms
	$(".error").hide();
	$("#submit").click(function(){
		
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		
		var nameVal = $("#nombre").val();
		if(nameVal == '') {
			$("#name_error").show();
			$("#nombre").addClass("ierror");
			hasError = true;
		}

		var emailVal = $("#email").val();
		if(emailVal == '') {
			$("#email_error").show();
			$("#email").addClass("ierror");
			hasError = true;
		} else if(!emailReg.test(emailVal)) {
			$("#emailval_error").show();
			$("#email").addClass("ierror");
			hasError = true;
		}

		if(hasError == true) {		
			return false;
		}
		if(hasError == false) {
			return true;
		}

	});
//Segundo form
	$(".error").hide();
	$("#submit2").click(function(){
		
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		
		var nameVal = $("#nombre2").val();
		if(nameVal == '') {
			$("#name_error2").show();
			$("#nombre2").addClass("ierror");
			hasError = true;
		}

		var emailVal = $("#email2").val();
		if(emailVal == '') {
			$("#email_error2").show();
			$("#email2").addClass("ierror");
			hasError = true;
		} else if(!emailReg.test(emailVal)) {
			$("#emailval_error2").show();
			$("#email2").addClass("ierror");
			hasError = true;
		}

		if(hasError == true) {		
			return false;
		}
		if(hasError == false) {
			return true;
		}

	});


});
