function trimSpace(x)
{
  var emptySpace = / /g;
  var trimAfter = x.replace(emptySpace,"");
  return(trimAfter);
}

function textValidate(incomingString)
{
  if(trimSpace(incomingString).length == 0 || incomingString.search(/[^a-zA-Z ]/g) != -1)
  {
    return false;
  }
  else
    return true;
}

function spaceCheck(incomingString)
{
  if(trimSpace(incomingString).length == 0)
  {
    return false;
  }
  else
    return true;
}

function numberValidate(incomingString)
{
  if(trimSpace(incomingString).length == 0 || incomingString.search(/[^0-9\.]/g) != -1 || parseInt(incomingString, 10) <= 0 )
  {
    return false;
  }
  else
    return true;
}
function CorpEmailCheck(email)
{
var nonCorpEmail = new Array("@yahoo.","@gmail.","@rediff.","@rediffmail.","@aol.","@abc.","@xyz.","@mail.","@aim.","@gmx.","@inbox.","@hotmail.","@bluebottle.","@bluestring.","@zapak.","@mywaymail.","@hotpop.","@lavabit.","@topmail.","@yousendit.","@mail2web.","@netaddress.","@lycos.","@postmaster.","@zzn.","@walla.","@fastmail.","@thatweb.","@mailinator.","@30gigs.","@e-mailanywhere.","@xasamail.","@excitemail.","@myrealbox.","@flashmail","@nameplanet.","@dodgeit.","@hushmail.","@mailandnews.","@caramail.lycos.","@icqmail.","@thedoghousemail.","@webmail.earthlink.","@eo.yifan.","@prontomail.","@gurlmail.","@wowmail.","@indiatimes.","@msn.","@sbc.");
var i;
email = email.toLowerCase();
for(i=0; i<nonCorpEmail.length; i++)
	{
		if(email.indexOf(nonCorpEmail[i])>-1)
			{
			return false;
			}
	}
return true;
}
function emailValidate(incomingString)
{
  if(trimSpace(incomingString).length == 0 || incomingString.search(/[\_\-\d]*[A-Za-z]+[\w\_\-]*[\@][\d]*[A-Za-z]+[\w\-]*[\.][A-Za-z]+/g) == -1)
  {
    return false;
  }
  else
    return true;
}

function alphanumeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
			 return false;
		  }
		}
 return true;
}

function validate2()
{
//  var alpha_phone = window.document.frm.txtPhone.value.search(/[a-z]|[A-Z]/);
  if(window.document.frm.txtName.value=="")
  {
    alert("Please Enter Your First Name");
    window.document.frm.txtName.focus();
    window.document.frm.txtName.select();
    return false;
  }

  if((!textValidate(document.frm.txtName.value)))
  {
    alert("Please Enter Alphabets Only");
    document.frm.txtName.focus();
    document.frm.txtName.select();
    return false;
  }

  if(document.frm.txtLastName.value=="")
  {
    alert("Please Enter Your Last Name");
    document.frm.txtLastName.focus();
    document.frm.txtLastName.select();
    return false;
  }

  if(!textValidate(document.frm.txtLastName.value))
  {
    alert("Please Enter Alphabets Only");
    document.frm.txtLastName.focus();
    document.frm.txtLastName.select();
    return false;
  }

  if(document.frm.txtTitle.value=="")
  {
    alert("Please enter your Job Title.");
    document.frm.txtTitle.focus();
    document.frm.txtTitle.select();
    return false;
  }
   if((!textValidate(document.frm.txtTitle.value)))
  {
    alert("Please Enter Alphabets Only");
    document.frm.txtTitle.focus();
    document.frm.txtTitle.select();
    return false;
  }

  if((!spaceCheck(document.frm.txtTitle.value)))
  {
    alert("Please remove the blank space from Job Title");
    document.frm.txtTitle.focus();
    document.frm.txtTitle.select();
    return false;
  }

  if(document.frm.txtEmail.value=="")
  {
    alert("Please enter your Business email address")
    document.frm.txtEmail.focus();
    document.frm.txtEmail.select();
    return false;
  }
  if(!emailValidate(document.frm.txtEmail.value))
  {
    alert("Please Enter the Correct Email Id");
    document.frm.txtEmail.focus();
    document.frm.txtEmail.select();
    return false;
  }
  if(!CorpEmailCheck(document.frm.txtEmail.value))
  {
    alert("Please Enter Your Corporate Email Id");
    document.frm.txtEmail.focus();
    document.frm.txtEmail.select();
    return false;
  } 
  	if(document.frm.txtCompanyURL.value=="")
	  {
		alert("Please enter your Company Name.");
		document.frm.txtCompanyURL.focus();
		document.frm.txtCompanyURL.select();
		return false;
	  }
  if((!spaceCheck(document.frm.txtCompanyURL.value)))
  {
    alert("Please remove the blank space from Company Name");
    document.frm.txtCompanyURL.focus();
    document.frm.txtCompanyURL.select();
    return false;
  }
  if(document.frm.txtPhone.value=="")
  {
    alert("Please enter your Phone Number.");
    document.frm.txtPhone.focus();
    document.frm.txtPhone.select();
    return false;
  }

  if(!numberValidate(document.frm.txtPhone.value))
  {
    alert("Please Enter Numbers Only");
    document.frm.txtPhone.focus();
    document.frm.txtPhone.select();
    return false;
  }
  
  if(trimSpace(document.frm.txtExt.value).length > 0)
  {
      
	  if(!numberValidate(document.frm.txtExt.value))
	  {
		alert("Please Enter Numbers Only");
		document.frm.txtExt.focus();
		document.frm.txtExt.select();
		return false;
	  }
  }
  if(document.frm.txtCity && document.frm.txtCity.value=="")
  {
    alert("Please enter City Name.");
    document.frm.txtCity.focus();
    document.frm.txtCity.select();
    return false;
  }

  if(document.frm.txtCity && (!textValidate(document.frm.txtCity.value)))
  {
    alert("Please Enter Alphabets Only");
    document.frm.txtCity.focus();
    document.frm.txtCity.select();
    return false;
  }

  if(document.frm.txtCountry.options[document.frm.txtCountry.selectedIndex].value=="USA/Canada")
  {
    if(document.frm.txtState && document.frm.txtState.options[document.frm.txtState.selectedIndex].value=="n/a")
    {
      alert("Please select the State");
      document.frm.txtState.selectedIndex = [0];
      document.frm.txtState.focus();
      return false;
    }
  }

/*  else
  {
          document.frm.txtState.selectedIndex.value="Not Applicable";
      alert("State : " + document.frm.txtState.selectedIndex.value);
  }
*/
/*  else
  {
    if(document.frm.txtCountry.options[document.frm.txtCountry.selectedIndex].value=="CA")
    {
      if(document.frm.txtState && document.frm.txtState.options[document.frm.txtState.selectedIndex].value=="PleaseSelect")
      {
        alert("Please select the Province");
        document.frm.txtState.selectedIndex = [0];
        document.frm.txtState.focus();
        return false;
      }
    }
  }*/

  if(document.frm.txtPostalCode.value=="")
  {
    alert("Please enter Zip Code.");
    document.frm.txtPostalCode.focus();
    document.frm.txtPostalCode.select();
    return false;
  }

  if(trimSpace(document.frm.txtPostalCode.value).length == 0)
  {
    alert("Please enter Zip Code.");
    document.frm.txtPostalCode.focus();
    document.frm.txtPostalCode.select();
    return false;
  }
  
   if(!numberValidate(document.frm.txtPostalCode.value))
  {
    alert("Please Enter Numbers Only");
    document.frm.txtPostalCode.focus();
    document.frm.txtPostalCode.select();
    return false;
  }

  if(document.frm.txtReason.options[document.frm.txtReason.selectedIndex].value=="PleaseSelect")
  {
    alert("Please select the reason for visiting the site");
    document.frm.txtReason.selectedIndex = [0];
    document.frm.txtReason.focus();
    return false;
  } 
  return true; 
}

function validate3()
{
//  var alpha_phone = window.document.frm.txtPhone.value.search(/[a-z]|[A-Z]/);
  if(window.document.frm.txtName.value=="")
  {
    alert("Please Enter Your First Name");
    window.document.frm.txtName.focus();
    window.document.frm.txtName.select();
    return false;
  }

  if((!textValidate(document.frm.txtName.value)))
  {
    alert("Please Enter Alphabets Only");
    document.frm.txtName.focus();
    document.frm.txtName.select();
    return false;
  }

  if(document.frm.txtLastName.value=="")
  {
    alert("Please Enter Your Last Name");
    document.frm.txtLastName.focus();
    document.frm.txtLastName.select();
    return false;
  }

  if(!textValidate(document.frm.txtLastName.value))
  {
    alert("Please Enter Alphabets Only");
    document.frm.txtLastName.focus();
    document.frm.txtLastName.select();
    return false;
  }

  if(document.frm.txtTitle.value=="")
  {
    alert("Please enter your Job Title.");
    document.frm.txtTitle.focus();
    document.frm.txtTitle.select();
    return false;
  }
   if((!textValidate(document.frm.txtTitle.value)))
  {
    alert("Please Enter Alphabets Only");
    document.frm.txtTitle.focus();
    document.frm.txtTitle.select();
    return false;
  }

  if((!spaceCheck(document.frm.txtTitle.value)))
  {
    alert("Please remove the blank space from Job Title");
    document.frm.txtTitle.focus();
    document.frm.txtTitle.select();
    return false;
  }

  if(document.frm.txtEmail.value=="")
  {
    alert("Please enter your Business email address")
    document.frm.txtEmail.focus();
    document.frm.txtEmail.select();
    return false;
  }
 
  if(!emailValidate(document.frm.txtEmail.value))
  {
    alert("Please Enter the Correct Email Id");
    document.frm.txtEmail.focus();
    document.frm.txtEmail.select();
    return false;
  }
  if(!CorpEmailCheck(document.frm.txtEmail.value))
  {
    alert("Please Enter Your Corporate Email Id");
    document.frm.txtEmail.focus();
    document.frm.txtEmail.select();
    return false;
  } 
  	if(document.frm.txtCompanyURL.value=="")
	  {
		alert("Please enter your Company Name.");
		document.frm.txtCompanyURL.focus();
		document.frm.txtCompanyURL.select();
		return false;
	  }

//	if(!alphanumeric(document.frm.txtCompanyURL.value))
	if(alphanumeric(document.frm.txtCompanyURL.value))	
	{
		alert("Please enter only AlphaNumeric");
		document.frm.txtCompanyURL.focus();
		document.frm.txtCompanyURL.select();
		return false;
	}

	//if(!numberValidate(document.frm.txtCompanyURL.value, ''))
	 if(numberValidate(document.frm.txtCompanyURL.value))
	{
		alert("Please enter only AlphaNumeric");
		document.frm.txtCompanyURL.focus();
		document.frm.txtCompanyURL.select();
		return false;
	}	  
	  
  if((!spaceCheck(document.frm.txtCompanyURL.value)))
  {
    alert("Please remove the blank space from Company Name");
    document.frm.txtCompanyURL.focus();
    document.frm.txtCompanyURL.select();
    return false;
  }

  if(document.frm.txtPhone.value=="")
  {
    alert("Please enter your Phone Number.");
    document.frm.txtPhone.focus();
    document.frm.txtPhone.select();
    return false;
  }

  if(!numberValidate(document.frm.txtPhone.value))
  {
    alert("Please Enter Numbers Only");
    document.frm.txtPhone.focus();
    document.frm.txtPhone.select();
    return false;
  }
  
  if(trimSpace(document.frm.txtExt.value).length > 0)
  {
      
	  if(!numberValidate(document.frm.txtExt.value))
	  {
		alert("Please Enter Numbers Only");
		document.frm.txtExt.focus();
		document.frm.txtExt.select();
		return false;
	  }
  }
  if(document.frm.txtCity && document.frm.txtCity.value=="")
  {
    alert("Please enter City Name.");
    document.frm.txtCity.focus();
    document.frm.txtCity.select();
    return false;
  }

  if(document.frm.txtCity && (!textValidate(document.frm.txtCity.value)))
  {
    alert("Please Enter Alphabets Only");
    document.frm.txtCity.focus();
    document.frm.txtCity.select();
    return false;
  }

  if(document.frm.txtCountry.options[document.frm.txtCountry.selectedIndex].value=="USA/Canada")
  {
    if(document.frm.txtState && document.frm.txtState.options[document.frm.txtState.selectedIndex].value=="n/a")
    {
      alert("Please select the State");
      document.frm.txtState.selectedIndex = [0];
      document.frm.txtState.focus();
      return false;
    }
  }

/*  else
  {
          document.frm.txtState.selectedIndex.value="Not Applicable";
      alert("State : " + document.frm.txtState.selectedIndex.value);
  }
*/
/*  else
  {
    if(document.frm.txtCountry.options[document.frm.txtCountry.selectedIndex].value=="CA")
    {
      if(document.frm.txtState && document.frm.txtState.options[document.frm.txtState.selectedIndex].value=="PleaseSelect")
      {
        alert("Please select the Province");
        document.frm.txtState.selectedIndex = [0];
        document.frm.txtState.focus();
        return false;
      }
    }
  }*/

  
  return true; 

}


function validatethankyou()
{

  if (window.document.frm_thanku.skip != undefined) {
      if (window.document.frm_thanku.skip.value == "true") {
         return true;
    }
  }

  exitType = "submit";
  return true;
}

function checkBoxInfoRequest()
{ 
 document.getElementById('InfoRequest').value="";

 var InfoRequestCount = document.getElementById('InfoRequestCount').value;
 InfoRequestCount++;
 //alert(InfoRequestCount);
 
 for(var i=0;i<InfoRequestCount;i++)
 { 
  var chBxName = document.getElementById('InfoRequest_'+i);
//  var chBxName = 'document.InfoRequest_'+i;
//  var chBxName = "document.getElementById('InfoRequest_1')";
    if(chBxName.checked == true)
  //if(document.getElementById('InfoRequest_1').checked == true)
  {
   document.getElementById('InfoRequest').value=document.getElementById('InfoRequest').value+chBxName.value+";";
   //alert("inside chBxName check");
  }  
 // alert(chBxName);
 } 
 //alert(document.getElementById('InfoRequest').value); 
 return true;
}