 
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 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 validate()
{

  var alpha_phone = document.frm.txtPhone.value.search(/[a-z]|[A-Z]/);

  if(document.frm.txtName.value=="")
  {
    alert("Please Enter Your Name");
    document.frm.txtName.focus();
    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.txtTitle.value=="")
  {
    alert("Please enter your Job Title.");
    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 Email.")
    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(document.frm.txtCountry.value==""){
    alert("Please enter your Country Name.");
    document.frm.txtCountry.focus();
    document.frm.txtCountry.select();
    return false;
  }

  if(document.frm.txtState && document.frm.txtState.value=="")
  {
    alert("Please select your State.");
    document.frm.txtState.focus();
    document.frm.txtState.select();
    return false;
  }

  if(document.frm.txtReason.value=="")
  {
    alert("Please enter the reason for visiting the MetricStream site");
    document.frm.txtReason.focus();
    document.frm.txtReason.select();
    return false;
  }

  if((!spaceCheck(document.frm.txtReason.value)))
  {
    alert("Please remove the blank space from Reason's Box");
    document.frm.txtReason.focus();
    document.frm.txtReason.select();
    return false;
  }
  else{
     return true;
  }
}

var states = new Array (
 " US State/Canadian Province ",
 "AB","AK","AL","AR","AS","AZ","BC","CA","CO","CT","DC","DE","FL","FM","GA"
 ,"GU","HI","IA","ID","IL","IN","KS","KY","LA","MA","MB","MD","ME","MH","MI"
,"MN","MO","MP","MS","MT","NB","NC","ND","NE","NH","NJ","NL","NM","NS","NT"
,"NU","NV","NY","OH","OK","OR","PA","PE","PR","PW","QC","RI","SC","SD","SK"
,"TN","TX","UT","VA","VI","VT","WA","WI","WV","WY","YT");



function changeState()
{

  nav = navigator.appName;
  t = document.getElementById("selectState");
  e = t.childNodes;

  if (nav == "Netscape") {
    if (document.frm.txtCountry.value != "USA/Canada")
    {
       for (i=e.length-1;i>0;i--) {
         t.removeChild(e[i]);
       }
       e[0].value = "Not Applicable";
       e[0].text = "Not Applicable";
    }
    else {
      e[0].value = "";
      e[0].text = states[0];
      for (i=1;i<states.length-1;i++) {
         o = new Option(states[i],states[i],false,false);
         t.appendChild(o);
         e[i].text = states[i];
      }
    }
  }
  else {
    if (nav == "Microsoft Internet Explorer") {
      if (document.frm.txtCountry.value != "USA/Canada")
      {
         for (i=e.length-1;i>1;i--) {
           t.removeChild(e[i]);
         }
         e[1].value = "Not Applicable";
         e[1].text = "Not Applicable";
      }
      else {
        e[1].value = "";
        e[1].text = states[0];
        for (i=1;i<states.length;i++) {
           t.appendChild(document.createTextNode(""));
           o = new Option(states[i],states[i],false,false);
           t.appendChild(o);
           e[i*2+1].text = states[i];
        }
      }
    }
    else {

    }
  }


  return false;
}
function skip_registration(url)
{
  if(document.frm.no_thanks.checked==true)
  {
  document.location.href=url;
  return false;
  }
  else
  {
  alert("Please tick the checkbox")
  return false;
  }
}
var image;


function changeState2()
{
  if (!document.frm.txtState) {
     return;
  }

  if(document.frm.txtCountry.options[document.frm.txtCountry.selectedIndex].value=="USA/Canada")
  {

    document.frm.txtState.disabled = false;
    document.frm.txtState.selectedIndex = [0];
  }
  else
  {

    document.frm.txtState.selectedIndex = [0];
    document.frm.txtCountry.options[document.frm.txtCountry.selectedIndex].value = "n/a";
    document.frm.txtState.disabled = 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((!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.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(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.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(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;
  }
  if(document.frm.txtComments.value=="")
  {
    alert("Please enter the Comments");
      document.frm.txtComments.focus();
    return false;
  }

  if (document.frm.txtState) {
    document.frm.txtState.disabled = false;
  }

  return true;

}

function validatethankyou()
{

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

  if(document.frm_thanku.drpPrimaryInds.options[document.frm_thanku.drpPrimaryInds.selectedIndex].value=="n/a")
  {
    alert("Please select the Primary Industry of Company");
    document.frm_thanku.drpPrimaryInds.selectedIndex = [0];
    document.frm_thanku.drpPrimaryInds.focus();
    return false;
  }

  if(document.frm_thanku.drpInvolvement.options[document.frm_thanku.drpInvolvement.selectedIndex].value=="n/a")
  {
    alert("Please select your level of involvement");
    document.frm_thanku.drpInvolvement.selectedIndex = [0];
    document.frm_thanku.drpInvolvement.focus();
    return false;
  }
     
   if(document.frm_thanku.txtCity.value=="")
  {
    alert("Please Enter your City");
    document.frm_thanku.txtCity.focus();
    return false;
  }

  exitType = "submit";
  return true;
}

function validate3()
 {
  
 	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((!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(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(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;
 
 }
 
 
 
//Added by Sahitya
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;
for(i=0; i<nonCorpEmail.length; i++)
	{
		if(email.indexOf(nonCorpEmail[i])>-1)
			{
			return false;
			}
	}
return true;
}



function validate_new4()
{


  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.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(document.frm.txtTitle.value=="")
  {
    alert("Please enter your Job Title.");
    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.txtState.options[document.frm.txtState.selectedIndex].value=="")
    {
      alert("Please select the State");
      document.frm.txtState.focus();
      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;
  }  
  return true;

}