jQuery(function() {
	
	jQuery('#nav ul ul').hide();
	
	jQuery('#nav ul li').hover(
	function () {
		jQuery(this).find('ul').show();
	}, 
	function () {
		jQuery(this).find('ul').hide();
	}
	);
	
	jQuery(".home #nav li:first").addClass('active');
	jQuery("#nav").find('.current_page_item').find('a').addClass('active');
	
	jQuery("#loading").bind("ajaxSend", function(){
		jQuery(this).show();
		}).bind("ajaxComplete", function(){
		jQuery(this).hide();
	});

	jQuery(".button").click(function() {
		// validate and process form
		// first hide any error messages
	jQuery('.error').hide();
		
	 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 comments = jQuery("#comments").val();
		if (comments == "") {
      jQuery("#comments_error").show();
      jQuery("#comments").focus();
      return false;
    }
		
		var dataString = 'name='+ name + '&email=' + email + '&comments=' + comments;
		//alert (dataString);return false;
		
		jQuery.ajax({
		type: "POST",
		url: "http://psd-2-css.com/portafolio-bruno/wp-content/themes/wp_template/form/bin/process.php",
		data: dataString,
		success: function() {
			jQuery('#form-contact').html("<div id='message'></div>");
			jQuery('#message').html("<p>Su mensaje fue enviado exitosamente</p>")
			.append("<p>Muy pronto nos pondremos en contacto con Usted.</p>")
			.hide()
			.fadeIn(1500, function() {
			  jQuery('#message').append("<img id='checkmark' src='images/check.png' />");
			});
      }
     });
    return false;
	});
  
});
