jQuery(function() {
	
	jQuery('#show_languages').click(function () {
      jQuery('#select li').toggleClass('show');
	  return false;
    });
	
	/*jQuery(".home #nav li:first").addClass('active');
	jQuery('.current_page_item').find('a').addClass('active');*/
	jQuery('.target').attr('target','_blank');
	
	jQuery("#loading").bind("ajaxSend", function(){
		jQuery(this).show();
		jQuery('.contact_form fieldset').addClass('layer');
		}).bind("ajaxComplete", function(){
		jQuery(this).hide();
		jQuery('.contact_form fieldset').removeClass('layer');
	});
	
	var action_val = jQuery('.contact_form').attr('action'); 

	jQuery(".submit").click(function() {
		
	 var name = jQuery("#name").val();
		if (name == "") {
      jQuery("#name_error").show();
      jQuery("#name").focus();
      return false;
    }
	
	var email = jQuery("#email").val();
		if (email == "") {
      jQuery("#email_error").show();
      jQuery("#email").focus();
      return false;
    }
	
	var email = jQuery("#email").val();
	if( !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) ){
	jQuery("#email_error").show();
	jQuery("#email").focus();
	return (false);
	} 
	
	var comment = jQuery("#comment").val();
		if (comment == "") {
      jQuery("#comment_error").show();
      jQuery("#comment").focus();
      return false;
    }
		
		var dataString = 'name='+ name + '&email=' + email + '&comment=' + comment;
		//alert (dataString);return false;
		jQuery.ajax({
		type: "POST",
		url: action_val,
		data: dataString,
		success: function() {
			jQuery('.contact_form').html("<div id='message'></div>");
			jQuery('#message').html("<p>Formulario de contacto enviado!</p>")
			.append("<p>Pronto nos pondremos en contacto con Ud.</p>");
      }
     });
    return false;
	});
	
  
});
