$(document).ready(function(){
	
	/*Cufon.replace('#myslidemenu, .titular, #sidebar h2, .cat-item, .eti, .entry-title, .entry-meta, .page-title, .recientes, .corporativa-title, .contacto-titulo, #contact-wrapper h4, .logintitulo');*/
	



	$("#contactformen").validate({
	
 	
   		messages: {
     		contactname: "<span class='error'>* Please specify your name</span>",
     		email: {
       		required: "<span class='error'>* We need your email address to contact you</span>",
       		email: "<span class='error'>* Your email address must be in the format of name@domain.com</span>"
     		},
	 		subject: "<span class='error'>*Please specify your subject</span>",
	 		message: "<span class='error'>* Please specify your message</span>",
	 
   		},    

	
		submitHandler: function() { 
			
			var name = $("#contactname").val();
			var mail = $("#email").val();
			var asunto = $("#subject").val();
			var text = $("#message").val();
			
			var datastr ='name=' + name + '&mail=' + mail + '&asunto=' + asunto + '&text=' + text;
			
			$("#response").css("display", "block");
			$("#response").html("Sending message .... ");
			$("#response").fadeIn("slow");
			setTimeout("send('"+datastr+"')",2000);
			$("#contactname").val("");
			$("#email").val("");
			$("#subject").val("");
			$("#message").val("");
		
		
		}
							   }); 
	
	$("#contactform").validate({
	
 	
   		messages: {
     		contactname: "<span class='error'>* Por favor, indique su nombre</span>",
     		email: {
       		required: "<span class='error'>* Por favor, indique su e-mail</span>",
       		email: "<span class='error'>* Su e-mail no es correcto, ej.:(nombre@dominio.com)</span>"
     		},
	 		subject: "<span class='error'>* Por favor, indique el asunto</span>",
	 		message: "<span class='error'>* Por favor, escriba el mensaje</span>",
	 
   		},    

	
		submitHandler: function() { 
			
			var name = $("#contactname").val();
			var mail = $("#email").val();
			var asunto = $("#subject").val();
			var text = $("#message").val();
			
			var datastr ='name=' + name + '&mail=' + mail + '&asunto=' + asunto + '&text=' + text;
			
			$("#response").css("display", "block");
			$("#response").html("Enviando mensaje .... ");
			$("#response").fadeIn("slow");
			setTimeout("send('"+datastr+"')",2000);
			$("#contactname").val("");
			$("#email").val("");
			$("#subject").val("");
			$("#message").val("");
		
		
		}
							   }); 

});

function privada(){
	$("#area").slideToggle("slow");
	
}

function send(datastr){
	
	$.ajax({	
		type: "POST",
		url: "http://www.josevidal.com/wp-content/themes/josevidal/mail.php",
		data: datastr,
		cache: false,
		success: function(html){
		
		$("#response").fadeIn("slow");
		$("#response").html(html);
		setTimeout('$("#response").fadeOut("slow")',2000);
		
	}
	});
	
}

function cambio(abrir){

	if (timer_is_on)
  {
	clearTimeout(t);
	timer_is_on=0;
  }		
	cerrar(abrir);
	
	/* $("#slide"+abrir).fadeIn("slow");/*LO QUIERO CON EL FADE IN PERO AL PASAR RÁPIDO DE UNO A OTRO ME DESCOLOCA*/
	$("#slide"+abrir).show();
	
}

function tiempo(abrir){

  if (!timer_is_on)
  {
  	timer_is_on=1;
  } else {
  		cerrar(abrir);		
  }			
	
	/* $("#slide"+abrir).fadeIn("slow");/*LO QUIERO CON EL FADE IN PERO AL PASAR RÁPIDO DE UNO A OTRO ME DESCOLOCA*/
	$("#flash").show();
	$("#flash").fadeOut();
	$("#slide"+abrir).show();
		
	if (abrir==4) abrir= 0;
	t=setTimeout("tiempo("+(abrir+1)+")",5000);	
		
}

function cerrar(capa){
	
	for (i=1;i<=4;i++){
	 	if (i!=cerrar) { 
		$("#slide"+i).hide();
		}
	}	
	
}




