Date.prototype.getDiff = function(date, interval){
  if (typeof date == "string"){
     date = new Date(date);
  }
  if (isNaN(date) || !(date instanceof Date)){
     return NaN; 
  }
  if (typeof interval == "undefined") interval = "ms"; 
  var diff = this - date; 
  switch(interval.toLowerCase()){
    case "s": 
        diff = diff/1000; break;
    case "n": 
        diff = diff/(1000*60); break;
       case "h": 
        diff = diff/(1000*60*60); break;
       case "d": 
        diff = diff/(1000*60*60*24); break;
    case "m": 
        diff = diff/(1000*60*60*24*30); break;
    case "y": 
        diff = diff/(1000*60*60*24*365); break;
    default:
      ; 
  }
  return Math.floor(diff);
}


function reg_valid()
  {
	  	  	
//	  var flag_phone = 0;	
	
	 	  
	  if(isEmpty(document.registration_step1.firstname.value))
	  {
		   alert ("Please Enter First Name.");
		   document.registration_step1.firstname.value="";
		   document.registration_step1.firstname.focus();
		   return false;
	  }	 
	  
	   if(chkWhitespace(document.registration_step1.firstname.value))
	  {
		   alert ("Please Enter First Name.");
		   document.registration_step1.firstname.value="";
		   document.registration_step1.firstname.focus();
		   return false;
	  }	 
	  
     if(isEmpty(document.registration_step1.lastname.value))
	  {
		   alert ("Please Enter Last Name.");
		   document.registration_step1.lastname.value="";
		   document.registration_step1.lastname.focus();
		   return false;
	  }	 
	   if(chkWhitespace(document.registration_step1.lastname.value))
	  {
		   alert ("Please Enter Last Name.");
		   document.registration_step1.lastname.value="";
		   document.registration_step1.lastname.focus();
		   return false;
	  }	
	   if(isEmpty(document.registration_step1.companyname.value)==false)
	  {
		   if(chkWhitespace(document.registration_step1.companyname.value))
		  {
			   alert ("Do not enter spaces.");
			   document.registration_step1.companyname.value="";
			   document.registration_step1.companyname.focus();
			   return false;
		  }	
	   
	  }

	 /* if(isEmpty(document.registration_step1.address1.value))
	  {
		   alert ("Please Enter Your Address.");
		   document.registration_step1.address1.value="";
		   document.registration_step1.address1.focus();
		   return false;
	  }	
	  if(chkWhitespace(document.registration_step1.address1.value))
	  {
		   alert ("Please Enter Your Address.");
		   document.registration_step1.address1.value="";
		   document.registration_step1.address1.focus();
		   return false;
	  }	

	 if(isEmpty(document.registration_step1.city.value))
	  {
		   alert ("Please Enter  Your City.");
		   document.registration_step1.city.value="";
		   document.registration_step1.city.focus();
		   return false;
	  }	
	   if(chkWhitespace(document.registration_step1.city.value))
	  {
		   alert ("Please Enter  Your City.");
		   document.registration_step1.city.value="";
		   document.registration_step1.city.focus();
		   return false;
	  }		  
	   
	   if(isAllCharacters(document.registration_step1.city.value)==false)
	  {
		   alert ("Please Use Letters Only.");
		   document.registration_step1.city.value="";
		   document.registration_step1.city.focus();
		   return false;
	  }
	  
	   if(isEmpty(document.registration_step1.zip.value))
	  {
		   alert ("Please Enter Zip Code.");
		   document.registration_step1.zip.value="";
		   document.registration_step1.zip.focus();
		   return false;
	  }	
	   if(isAllCharacters(document.registration_step1.zip.value))
	  {
		   alert ("Please Enter Zip Code.");
		   document.registration_step1.zip.value="";
		   document.registration_step1.zip.focus();
		   return false;
	  }	
	 
		  if(isAllNumerics(document.registration_step1.zip.value)==false)
		  {
			   alert ("Please Enter Only Numbers for Zip Code.");
			   document.registration_step1.zip.value="";
			   document.registration_step1.zip.focus();
			   return false;
		  }*/
	 
	   if(isEmpty(document.registration_step1.emailaddress.value))
	  {
		   alert ("Please Enter a  Valid Email Address.");
		   document.registration_step1.emailaddress.value="";
		   document.registration_step1.emailaddress.focus();
		    return false;
	  }
	  
	  if(isEmpty(document.registration_step1.emailaddress.value)==false)
	  {		
	   if(isValidEmail(document.registration_step1.emailaddress.value)==false)
	     {
		   alert ("Please Enter a  Valid Email Address.");
		   document.registration_step1.emailaddress.value="";
		   document.registration_step1.emailaddress.focus();
		   return false;
	     }
	  }
	/*  if(isEmpty(document.registration_step1.backup_emailaddress.value)==false)
	  {
		  if(isValidEmail(document.registration_step1.backup_emailaddress.value)==false)
		  {
			   alert ("Please Enter a  Valid Email Address.");
			   document.registration_step1.backup_emailaddress.value="";
			   document.registration_step1.backup_emailaddress.focus();
			   return false;
		  }
	  }       	   
	 */
	 if(isEmpty(document.registration_step1.username.value))
	  {
		   alert ("Please Enter Your Username.");
		   document.registration_step1.username.value="";
		   document.registration_step1.username.focus();
		   return false;
	  }
	   if(chkWhitespace(document.registration_step1.username.value))
	  {
		   alert ("Please Enter Your Username.");
		   document.registration_step1.username.value="";
		   document.registration_step1.username.focus();
		   return false;
	  }	
	  if(isAlphaNumericwithspecialchars(document.registration_step1.username.value)==false)
	  {
		   alert ("Please Enter Your Username.");
		   document.registration_step1.username.value="";
		   document.registration_step1.username.focus();
		   return false;
	  }
	   if(isValidUsername(document.registration_step1.username.value)==false)
	  {
		   alert ("Username Must be Minimum 6 Characters.");
		   document.registration_step1.username.value="";
		   document.registration_step1.username.focus();
		   return false;
	  }
	/*   if(isEmpty(document.registration_step1.username.value)==false)
	  {
		   check_username1();			 
		    
	  }*/
	  
	
	  
	   if(isEmpty(document.registration_step1.password.value))
	  {
		   alert ("Please Enter Your Password.");
		   document.registration_step1.password.value="";
		   document.registration_step1.password.focus();
		   return false;
	  }
	    if(chkWhitespace(document.registration_step1.password.value))
	  {
		   alert ("Please Enter Your Password.");
		   document.registration_step1.password.value="";
		   document.registration_step1.password.focus();
		   return false;
	  }
	   if(isValidPassword(document.registration_step1.password.value)==false)
	  {
		   alert ("Password Must be Minimum 6/Maximum 16 Characters.");
		   document.registration_step1.password.value="";
		   document.registration_step1.password.focus();
		   return false;
	  }
	   if(chkWhitespace(document.registration_step1.retype_password.value))
	  {
		   alert ("Please Re-Enter Your Password.");
		   document.registration_step1.retype_password.value="";
		   document.registration_step1.retype_password.focus();
		   return false;
	  }
	   if(isEmpty(document.registration_step1.retype_password.value))
	  {
		   alert ("Please Re-Enter Your Password.");
		   document.registration_step1.retype_password.value="";
		   document.registration_step1.retype_password.focus();
		   return false;
	  }
	   if(MatchPasswords(document.registration_step1.password.value,document.registration_step1.retype_password.value)==false)
	  {
		   alert ("Please Verify Your Password.");
		   document.registration_step1.retype_password.value="";
		   document.registration_step1.retype_password.focus();
		   return false;
	  }
	  
		 
					
	  if(isEmpty(document.registration_step1.webaddress.value))
	  {
		   alert ("Please Choose Your crewnewmexico.com Web Address.");
		   document.registration_step1.webaddress.value="";
		   document.registration_step1.webaddress.focus();
		   return false;
	  }	  
	     if(chkWhitespace(document.registration_step1.webaddress.value))
	  {
		   alert ("Please Choose Your crewnewmexico.com Web Address.");
		   document.registration_step1.webaddress.value="";
		   document.registration_step1.webaddress.focus();
		   return false;
	  }
	   if(isAlphaNumericwithspecialchars(document.registration_step1.webaddress.value)==false)
	  {
		   alert ("Please Choose Your crewnewmexico.com Web Address.");
		   document.registration_step1.webaddress.value="";
		   document.registration_step1.webaddress.focus();
		   return false;
	  }
	 /*  if(isEmpty(document.registration_step1.webaddress.value)==false)
	  {
		   check_url(); 
		   
	  }	*/
	
	 
	 

	  return true;	 
  }
  
/* var xmlHttp

function check_username1()
{
	 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	  {
		  alert ("Browser does not support HTTP Request")
		  return
	  } 	
	var username = document.getElementById("username").value 
	var url = "chk_username.php"
	url=url+"?username="+username
	xmlHttp.onreadystatechange=stateChanged_username 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

function stateChanged_username() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		   if(xmlHttp.responseText!="")
		  {
			alert(xmlHttp.responseText );
			document.registration_step1.username.value="";
			document.registration_step1.username.focus();
			return false;
		  }
		  
	 } 
	 
}

function check_url()
{
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	  {
		  alert ("Browser does not support HTTP Request")
		  return
	  } 
	
	var webaddress = document.getElementById("webaddress").value 
	var url = "chk_url.php"
	
	url = url+"?webaddress="+webaddress	
	xmlHttp.onreadystatechange=stateChanged_url
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	} 
	
	function stateChanged_url() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
		   if(xmlHttp.responseText!="")
		   {
			alert(xmlHttp.responseText);
		    document.registration_step1.webaddress.value="";
		    document.registration_step1.webaddress.focus();
			return false;
		   }
		 } 
	}

	
	function GetXmlHttpObject()
	{
		var xmlHttp=null;
		try
		 {
			 // Firefox, Opera 8.0+, Safari
			 xmlHttp=new XMLHttpRequest();
		 }
		catch (e)
		 {
			 // Internet Explorer
			 try
			  {
				  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			  }
			 catch (e)
			  {
				  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
		 }
		return xmlHttp;
}*/