function checkFastStartFields(form){
  
  if (form.sf_gender.options[form.sf_gender.options.selectedIndex].value == "none" ) {
    window.alert("Please enter your Gender.");
    form.sf_gender.focus();
    return false;
  }
  
  if(form.sf_gender.options[form.sf_gender.options.selectedIndex].value == "M")
  {
    form.sf_title.value = "Mr.";
  }
  else
  {
    form.sf_title.value = "Ms.";
  }

  if ( isBlank(form.sf_first_nme.value) ) {
    window.alert("Please enter your First Name.");
    form.sf_first_nme.focus();
    return false;
  }
  
  if ( isBlank(form.sf_last_nme.value) ) {
    window.alert("Please enter your Last Name.");
    form.sf_last_nme.focus();
    return false;
  }
  
  if ( isBlank(form.sf_address1.value) ) {
    window.alert("Please enter your Street Address.");
    form.sf_address1.focus();
    return false;
  }
  
  if ( isBlank(form.sf_city.value) ) {
    window.alert("Please enter your City.");
    form.sf_city.focus();
    return false;
  }
  
  if (form.sf_state_cd.options[form.sf_state_cd.options.selectedIndex].value == "none") {
    window.alert("Please choose your State.");
    form.sf_state_cd.focus();
    return false;
  }
  
  if ( isBlank(form.sf_postal_cd.value) ) {
    alert("Please enter your Zip code.");
    form.sf_postal_cd.focus();
    return false;
  }
  if ( !isInteger(form.sf_postal_cd.value) || (form.sf_postal_cd.value.length != 5)) {
	form.sf_postal_cd.value = "";
    alert("Please enter a valid Zip code.");
    form.sf_postal_cd.focus();
    return false;
  }  
  
  if ( isBlank(form.sf_email_addr.value) ) {
    alert("Please enter your email address.");
    form.sf_email_addr.focus();
    return false;
  }
  if ( isBlank(form.email_addr_confirm.value) ) {
    alert("Please verify your email address.");
    form.email_addr_confirm.focus();
    return false;
  }
  if ( form.sf_email_addr.value != form.email_addr_confirm.value ) {
    alert("Your email address does not match. Please verify your email.");
    form.sf_email_addr.focus();
    return false;
  }
  if ( !checkEmailAddress(form.sf_email_addr.value) ) {
    form.email_addr_confirm.value = "";
    window.alert("Please enter a valid email address.");
    form.sf_email_addr.focus();
    return false;
  }
  if (form.sf_birth_month.options[form.sf_birth_month.options.selectedIndex].value == "none" ) {
    alert("Please enter your Birthdate.");
    form.sf_birth_month.focus();
    return false;
  }
  if ( form.sf_birth_date.options[form.sf_birth_date.options.selectedIndex].value == "none" ) {
    alert("Please enter your Birthdate.");
    form.sf_birth_date.focus();
    return false;
  }
  if ( form.sf_birth_year.options[form.sf_birth_year.options.selectedIndex].value == "none" ) {
    alert("Please enter your Birthdate.");
    form.sf_birth_year.focus();
    return false;
  }
  
  //check if user is under 13 years
  var userYear = form.sf_birth_year.options[form.sf_birth_year.options.selectedIndex].value;
  var userMonth = form.sf_birth_month.options[form.sf_birth_month.options.selectedIndex].value;
  var userDate = form.sf_birth_date.options[form.sf_birth_date.options.selectedIndex].value;    
  
  if ( !isDate(userDate, userMonth, userYear, form) ) {    
    return false;
  }
  
  if(under13(userMonth, userDate, userYear)){	  
	  setAgeCookie();
	  window.location ='/app/Colgate/US/OC/SpecialOffers/FastStart/Under13.cvsp';
	  return false;
  }  
  
  return true;  
}

function isBlank(s) {
	if (s == "") {
		return true;
	}
	// loop checks for instance of any non-eol character
	for(var i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t'))
			return false;
	}
	return true;
}

function checkEmailAddress( emailStr ) {

	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

	var matchArray=emailStr.match(emailPat)

	if (matchArray==null) {
		return false
	}

	var user=matchArray[1]
	var domain=matchArray[2]

	if (user.match(userPat)==null) {
	    return false
	}

	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
			return false
		    }
	    }
	    return true
	}

	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
	    return false
	}


	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
	    domArr[domArr.length-1].length>3) {
	   return false
	}

	// Make sure there's a host name preceding the domain.
	if (len<2) {
	   return false
	}
	return true;
}

function under13(birthMonth, birthDay, birthYear)
{
  var now = new Date();
  var thisMonth = now.getMonth() + 1;
  var thisDay = now.getDate();
  var thisYear = now.getFullYear();  
  var user_age = thisYear - birthYear;
  var minimum_year = 13;

  if (user_age < minimum_year) {
    return true;
  }
  if (user_age > minimum_year) {
    return false;
  }
  if (thisMonth < birthMonth) {
    return true;
  }
  if (thisMonth > birthMonth) {
    return false;
  }
  if (thisDay < birthDay) {
    return true;
  }
  return false;
}

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(strDay, strMonth, strYear, form){
	var daysInMonth = DaysArray(12)	
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)	
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month.")
		form.sf_birth_month.focus();
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){		
		alert("Please enter a valid day.")
		form.sf_birth_date.focus();
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid year.")
		form.sf_birth_year.focus();
		return false
	}
	return true
}

function ValidateForm(){
	var dt=document.frmSample.txtDate
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}
    return true
}