// JavaScript Document


jQuery(document).ready(function() {	


	
jQuery('input[type="text"], input[type="email"], input[type="number"], input[type="password"], textarea[name="comment"], textarea[name="Message"]').addClass("idleField");
   		jQuery('input[type="text"], input[type="email"], input[type="number"], input[type="password"], textarea[name="comment"], textarea[name="Message"]').focus(function() {
   			jQuery(this).removeClass("idleField").addClass("focusField");
		    if (this.value == this.defaultValue){ 
		    	this.value = '';
			}
			if(this.value != this.defaultValue){
    			this.select();
    		}
		});
		jQuery('input[type="text"], input[type="email"], input[type="number"], input[type="password"], textarea[name="comment"], textarea[name="Message"]').blur(function() {
			jQuery(this).removeClass("focusField").addClass("idleField");
		    if (jQuery.trim(this.value) == ''){
		    	this.value = (this.defaultValue ? this.defaultValue : '');
			}
		});

				   



jQuery('#confirmation').hide();

jQuery("#subForm #sub-btn").click(function() { 
  
  jQuery('form#subForm').submit(function() { return false; });

  var formAction = jQuery("form#subForm").attr("action");
  
  var id = "trdrdi";
  var emailId = id + "-" + id;
  
  if (!checkEmail(emailId)) {
	alert("Please enter a valid email address");
	return;
  }
  
  var str = jQuery("form#subForm").serialize();
  
  // Add form action to end of serialized data
  // CDATA is used to avoid validation errors
  //<![CDATA[
  var serialized = str + "&action=" + formAction;
  // ]]>
  
  jQuery.ajax({
	url: "proxy.php",
	type: "POST",
	data: serialized,
	success: function(data){
	  if (data.search(/invalid/i) != -1) {
		alert('The email address you supplied is invalid and needs to be fixed before you can subscribe to this list.');
	  }	  else	  {
		jQuery("#subscribe-form").slideUp("fast"); 
		
		jQuery("#confirmation").slideDown("fast");  
		jQuery("#confirmation").tabIndex = -1;
		jQuery("#confirmation").focus();

	  }
	}

  });
  
  
});

});
