
function Buton_onclick() 
{
	if (document.frmpromodetail.txtname.value=='')
		{
			alert('Enter your name');
			document.frmpromodetail.txtname.focus();
			return false;
		}
	if(document.frmpromodetail.txtEmail.value=='')
	{
		alert('Please enter Email');
		document.frmpromodetail.txtEmail.value='';
		document.frmpromodetail.txtEmail.focus();
		return false;
	}
	
	if (checkEmail(document.frmpromodetail.txtEmail)==false) 
	{
		alert('Enter correct Email');
		document.frmpromodetail.txtEmail.focus();
		return false;
	}
	if (isNumeric(document.frmpromodetail.txtphone.value)==false)
		{
			alert('Telephone Number Should contain only numbers');
			document.frmpromodetail.txtphone.value='';
			document.frmpromodetail.txtphone.focus();
			return false;
		}
	//document.frmCustomerDetails.action='ContactSubFinal.asp';
	//document.frmCustomerDetails.submit();
	return true;

}
function checkEmail(email)
{		
	aflag=false;
	emailStr = email.value;
	if(emailStr=="") return true;
	var err=-1,cntAt=0,mailAt=0,cntDot=0,cntDotNum=-1; 
	var Atpos, Dotpos
	
	for (i=0;i<emailStr.length;i++)
					
	{
	val=emailStr.charAt(i);
	if (val=='.')
	{
	if (i==emailStr.length-1)
	{
	return false;
	break;
	}
	}
	 }
	for (i=0;i<emailStr.length;i++)    // Splitting the string with '@'
	{
	val=emailStr.charAt(i);    // val: to get each character from string
	if (val=='.')
	{
	 Dotpos=i;
	}
	if (val=='@')
	{	
	cntAt=1;mailAt=i;    // mailAt: to find the position of @
	aflag=true;
	break;
	}
	}
	if(!aflag)
	return false;
		
	if (mailAt!=0)
	{
	befAtStr = emailStr.substring(0,mailAt);    // befAtStr: to store string before '@'
	aftAtStr = emailStr.substring(mailAt+1,emailStr.length); // aftfAtStr: to store string before '@'
	if ((befAtStr.length!=0) && (cntAt!=0) && (aftAtStr.length!=0))
	{
	for (j=0;j<befAtStr.length;j++)	   // Checking the characters in befAtStr
	{
	val1 = befAtStr.charAt(j);
	if ( (((val1>='a' && val1<='z')) || ((val1>='0' && val1<='9')) || ((val1>='A' && val1<='Z')) || (val1!=' ') && val1!='#') )                                   
	{
													  
	}
	else
	{					
	err=4;
	break;
	}
									
	}	
	for (k=0;k<aftAtStr.length;k++)    // Checking the characters in aftAtStr
	{
	val2 = aftAtStr.charAt(k);
	if((!(val2>='a' && val2<='z')) && (!(val2>='0' && val2<='9')) && (!(val2>='A' && val2<='Z')) && (val2==' ') )
	{					
	err=4;
	break;
	}
										
	if (val2=='.' && k!=0)
	{
	cntDot++;   // setting cntDot=1 when dot encountered in aftAtStr
										     
	}
	if (cntDot==1) 
	cntDotNum++;   // numbers after dot in aftAtStr
	}
	}
	else
	err=4;   // setting error if befAtStr and befAtStr are empty and if atleast one period doesn't present
	}
	else
	err=4;   // setting error if '@' is not present in the string
		
	if ( (cntDot<1) || (err==4) || (cntDotNum<0) )
		return false; // Calling errDisplay function with the error code
	else
	{
	return true;    // temporary: transfering the focus 
	}
								
								
	return flag;
	}


function isNumeric(str)
// returns true if str is numeric
// that is it contains only the digits 0-9
// returns false otherwise
// returns false if empty
{
  var len= str.length;
  if (len==0)
    return false;
  //else
  var p=0;
  var ok= true;
  var ch= "";
  while (ok && p<len)
  {
    ch= str.charAt(p);
    if ('0'<=ch && ch<='9')
      p++;
    else
      ok= false;
  }
  return ok;
}

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}