function isAllowedChar1(ch)
{	var notAllowedChars = "0123456789~`!@#$%^&*()+=;:|?<>[]{}";
	if (notAllowedChars.indexOf(ch)>=0)
	{return false;}
	return true;
}
function validate()
{
	if (document.contact.first_name.value == "")
		{	
			alert("Please enter your First Name");
			document.contact.first_name.focus();
			return false;
		}
	else
		{
				tempStr = document.contact.first_name.value;
				for(i=0;i<tempStr.length;i++)
			{	
				if(isAllowedChar1(tempStr.charAt(i))=="0")
				{
					alert("The Name can only contain Letters");
					document.contact.first_name.focus();
					document.contact.first_name.select();
					i = tempStr.length;
					return false;
				}
			}
		}
	
	if (document.contact.last_name.value == "")
		{	
			alert("Please enter your Last Name");
			document.contact.last_name.focus();
			return false;
		}
	else
		{
				tempStr = document.contact.last_name.value;
				for(i=0;i<tempStr.length;i++)
			{	
				if(isAllowedChar1(tempStr.charAt(i))=="0")
				{
					alert("The Name can only contain Letters");
					document.contact.last_name.focus();
					document.contact.last_name.select();
					i = tempStr.length;
					return false;
				}
			}
		}
	
	if (document.contact.email.value == "" )
		{	alert("Please enter your Email.");
			document.contact.email.focus();
			document.contact.email.select();
			return false;
		}
	else
	{
		if(emailCheck(document.contact.email.value,document.contact.email)=="0")
		return false;
	}

	if (document.contact.phone.value == "")
		{
			alert("Please enter your Mobile Number");
			document.contact.phone.focus();
			document.contact.phone.select();
			return false;
		}
	else  
		{
			if (isNaN(document.contact.phone.value))
				{	alert("Please enter a valid Mobile Number");
					document.contact.phone.focus();
					document.contact.phone.select();
					return false;
				}
		}
	if (document.contact.phone.value.length < 10)
		{
			alert("The Mobile no. should be at least of 10 characters");
			document.contact.phone.focus();
			document.contact.phone.select();
			return false;
		}
	
	if (document.getElementById('designation').value == "")
		{	
			alert("Please enter your Designation");
			document.getElementById('designation').focus();
			return false;
		}
	else
		{
				tempStr = document.getElementById('designation').value;
				for(i=0;i<tempStr.length;i++)
			{	
				if(isAllowedChar1(tempStr.charAt(i))=="0")
				{
					alert("The Designation can only contain Letters");
					document.getElementById('designation').focus();
					document.getElementById('designation').select();
					i = tempStr.length;
					return false;
				}
			}
		}	
	
	if (document.getElementById('program').value == "")
		{	
			alert("Please select one Program Name you are interested in");
			document.getElementById('program').focus();
			return false;
		}
		
	if (document.contact.city.value == "")
		{	
			alert("Please fill your City Name");
			document.contact.city.focus();
			return false;
		}		

return true;
}
function ValidateList(that,TextMsg)
{	if (that.selectedIndex == "0"){alert("Please tell us " + TextMsg);that.focus();return false;}}
function  emailCheck(emailStr,that)
{
if(that.value == "")
{return 1;}
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)
	{alert("Email address seems incorrect (check @ and .'s)");that.focus();return 0;}
var user=matchArray[1]
var domain=matchArray[2]
	if (user.match(userPat)==null)
	{alert("The username doesn't seem to be valid.");that.focus();return 0;}
var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null)
	{ for (var i=1;i<=4;i++)
	  {if (IPArray[i]>255)
		{alert("Destination IP address is invalid!");that.focus();return 0;}
	  }
	    return 1;
	}
var domainArray=domain.match(domainPat)
	if (domainArray==null)
	{alert("The domain name doesn't seem to be valid.");that.focus();return 0;}
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)
	{alert("The address must end in a three-letter domain, or two letter country.");that.focus();return 0;}
	if (len<2) 
	{  var errStr="This address is missing a hostname!"
	   alert(errStr);that.focus();return 0;}
	return 1;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
