// JavaScript Document



/* Form javascript start  */

function checkEmail()
	{
	var strEmail, strError, countAtRate, countDot, i;
	var checkAtRate, checkDot;
	var ValidChars,CountValidChars;
	ValidChars="abcdefghijklmnopqrstuvwxyz0123456789_.@ABCDEFGHIJKLMNOPQRSTUVWXYZ-";
	strEmail = checkEmail.arguments[0];

	countAtRate=0;
	countDot=0;
	CountValidChars=0;
	if (strEmail.length >= 7)
		{
		for(i=0;i<strEmail.length;i++)
			{
			if(strEmail.charAt(i)=="@")
				countAtRate++;
			if(strEmail.charAt(i)==".")
				countDot++;
			CountValidChars=0;
			for(j=0;j<ValidChars.length;j++)
				{
				if(strEmail.charAt(i)==ValidChars.charAt(j))
					{
					CountValidChars++;
					}
				}
			if(CountValidChars==0)
				{
				strError=0;
				break;
				}
			}
		}
	checkAtRate=strEmail.indexOf("@",1);
	checkDot=strEmail.indexOf(".",1);
	for(i=1;i<countDot;i++)
		checkDot=strEmail.indexOf(".",checkDot+1);
	if(countAtRate==1 && countDot > 0 && strEmail.length >=7 && strError != 0)
		strError=1;
	else
		strError=0;
	if(checkDot>=strEmail.length-2)
		strError=0;
	if(strEmail.charAt(0)=="@" || strEmail.charAt(strEmail.length-1)=="@")
		strError=0;
	if(strEmail.charAt(0)=="." || strEmail.charAt(strEmail.length-1)==".")
		strError=0;
	if(checkDot < checkAtRate)
		strError=0;

	return strError;
}


function isBlank(C) {
	for (i=0;i<C.length;i++) {if (C.charAt(i) != " ") return false}
	return true;
}

function validate_app(dm) {
	var strError="";		
	if(isBlank(dm.printname.value))
	strError += "Print Name\n";		
	if(isBlank(dm.youremail.value)||checkEmail(dm.email.value)==0)
    strError += " Enter Your Email Address\n";	
	if(strError!=""){		
		alert("Check these Invalid Fields\n------------------------------------\n"+strError);
		return false;
	}	
	return true;

  }

function validate_mail(dm) {
	var strError="";				
	if(isBlank(dm.email.value))
	  {
		alert("Email Address is Empty\n");
		return false;
		  }
		  else if(checkEmail(dm.email.value)==0){	
		  alert("Invalid Email Address\n");
		  return false;
			  }
			  else{
				  return true;
				  }

     }
/* Form javascript End */




