
function IsNumeric(obj,msg)//validate phone no.
{
   var ValidChars = "0123456789.-";
   var IsNumber=true;
   var Char;
   var sText=obj.value;
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
		 alert(msg);
		 obj.focus();
         IsNumber = false;
         }
      }
   return IsNumber;
   
}

	function checkempty(obj,msg)
	{
	 if(obj.value=="")
	 {
	  alert(msg);
	  obj.focus();
	  return false;
	 }
	}
	
	function test(obj,msg) {
	  var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	  if (regex.test(obj.value))
	  {
		return true;
	  }
	  else{
		alert(msg);
		obj.focus();
		return false;
	  }
	}
	
function checkForm()
{
	if (checkempty(document.frmEmail.F_Name,"Contact Information - Enter Your Name")==false) return false;
	if (checkempty(document.frmEmail.L_Name,"Contact Information - Enter Last Name")==false) return false;
	if (test(document.frmEmail.Email,"Contact Information - Email Address Is Invalid")==false) return false;
	if (checkempty(document.frmEmail.Phone,"Contact Information - Enter Phone No.")==false) return false;
	if (IsNumeric(document.frmEmail.Phone,"Contact Information - Phone No. Is Invalid")==false) return false;

	window.document.frmEmail.submit()
}


function Right(str, n)
{
	if (n <= 0)     // Invalid bound, return blank string
	   return "";
	else if (n > String(str).length)   // Invalid bound, return
	   return str;                     // entire string
	else { // Valid bound, return appropriate substring
	   var iLen = String(str).length;
	   return String(str).substring(iLen, iLen - n);
	}
}

function setFile()
{
	window.document.frmEmail.File_Name.value=window.document.frmEmail.Attach_File.value;
	str=window.document.frmEmail.File_Name.value;
	
	var counter=0;
	var lastIndex=0;
	while (counter<str.length-1)
	{
		if (str.indexOf("\\",(counter+1)) != (-1))	lastIndex=str.indexOf("\\",(counter+1));
		counter++;
	}
		str1=window.document.frmEmail.File_Name.value;
		strLen=str1.length;
		window.document.frmEmail.File_Name.value = Right(window.document.frmEmail.File_Name.value,(strLen-lastIndex-1));
		//alert("file set");

}

function EnableOthersContact()
{

	if (window.document.frmEmail.Intersted_in.selectedIndex == 7)
		window.document.frmEmail.Other_Interst.style.visibility='visible';
	else
	{
		window.document.frmEmail.Other_Interst.style.visibility='hidden';
		window.document.frmEmail.Other_Interst.value="";
	}
	
	if (window.document.frmEmail.Industry.selectedIndex == 6)
		window.document.frmEmail.Other_Industry.style.visibility='visible';
	else
	{
		window.document.frmEmail.Other_Industry.style.visibility='hidden';
		window.document.frmEmail.Other_Industry.value="";
	}

	
}

function EnableOthersCareers()
{
	if (window.document.frmEmail.about_us.selectedIndex == 7)
		window.document.frmEmail.about_us_other.style.visibility='visible';
	else
	{
		window.document.frmEmail.about_us_other.style.visibility='hidden';
		window.document.frmEmail.about_us_other.value="";
	}
}
