function ValidateData(form) {

 var strErrMsg = "";

  //====== Validation rules BEGIN ======. 
  
  if (isWhitespace(form.Domain.value) && form.PurchaseDomain[1].checked==true) {
    strErrMsg = strErrMsg + "Please enter your desired new domain name.\n";
  }
  if (isWhitespace(form.Domain.value) && form.PurchaseDomain[0].checked==true) {
    strErrMsg = strErrMsg + "Please enter your existing domain name.\n";
  }  
   if (!isEmail(form.Email.value)) {
   strErrMsg = strErrMsg + "Please enter a valid Invoice Email.\n";
  }
  
  if (isWhitespace(form.DomainYears.value) && form.PurchaseDomain[1].checked==true) {
    strErrMsg = strErrMsg + "Please enter the number of years to purchase the domain name.\n";
  }
    
  if (isWhitespace(form.Phone.value)) {
    strErrMsg = strErrMsg + "Please enter your phone number.\n";
  }
  
  if (isWhitespace(form.Registrar.value) && form.PurchaseDomain[0].checked==true) {
    strErrMsg = strErrMsg + "Please enter from where you purchased your domain name.\n";
  }
  if (form.HostingPlan.options[0].selected==true) {
    strErrMsg = strErrMsg + "Please select a hosting plan.\n";
  }  
   
  if (isWhitespace(form.CCName.value)) {
    strErrMsg = strErrMsg + "Please enter Name on Credit Card.\n";
  }
  if (isWhitespace(form.CCAddress.value)) {
    strErrMsg = strErrMsg + "Please enter your billing address.\n";
  }
  if (isWhitespace(form.CCCity.value)) {
    strErrMsg = strErrMsg + "Please enter your billing city.\n";
  }
  if (isWhitespace(form.CCState.value)) {
    strErrMsg = strErrMsg + "Please enter your billing state.\n";
  }
  
   if (isWhitespace(form.CCZip.value)) {
    strErrMsg = strErrMsg + "Please enter your billing postal code.\n";
  }
  
   if (isWhitespace(form.CCNum.value)) {
   strErrMsg = strErrMsg + "Please enter a valid credit card number.\n";
  }
  
   if (isWhitespace(form.CCCVV2.value)) {
   strErrMsg = strErrMsg + "Please enter your credit card security code.\n";
  }
  
   //====== Validation rules End ======.

  if (strErrMsg != "") {
  	alert(strErrMsg);
  	return (false);
  }
  else {
  	return(true);
  }
}

// Email address must be of form a@b.c
function isEmail (s) {

    if (isEmpty(s)){return false;}

    // is s whitespace?
    if (isEmpty(s)){return false;}

    // there must be >= 1 character before @, so we
    // start looking at character position 1
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@")) {
    	i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != ".")) {
    	i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

// Returns true if string s is empty or
// whitespace characters only.
function isWhitespace (s)
{
    var whitespace = " \t\n\r";
    var i;

    // Is s empty?
    if (isEmpty(s)){return true;}

    // Search through characters one by one
    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

// Check whether string s is empty.
function isEmpty(s) {
    return ((s == null) || (s.length == 0) || (s == ""))
}
// beta
//function IsValidCC(strObj) {
	//var CCRegExp = strObj.match(^(\d{4}[- ]){3}\d{4}|\d{16}$);
	//if (CCRegExp) {
		//return false;
   // }
  // // return true;
//}


	
	
	

