// JavaScript Document

function donateValid()
{
	var doc=document.dnt;
	if(doc.name.value=="" || doc.name.value==null)
	{
		alert("Please fill name");
		doc.name.focus();
		return false;
	}
	if(doc.addr.value=="" || doc.addr.value==null)
	{
		alert("Please fill address");
		doc.addr.focus();
		return false;
	}
	if(doc.email.value=="" || doc.email.value==null)
	{
		alert("Please fill email");
		doc.email.focus();
		return false;
	}
	if(echeck(doc.email.value)==false)
	{
		doc.email.value="";
		doc.email.focus();
		return false;
	}
	if(doc.vpc_Amount.value=="" || doc.vpc_Amount.value==null)
	{
		alert("Please fill amount");
		doc.vpc_Amount.focus();
		return false;
	}
	if(isNaN(doc.vpc_Amount.value)==true)
	{
		alert("Please fill valid amount");
		doc.vpc_Amount.value="";
		doc.vpc_Amount.focus();
		return false;
	}
	if(doc.vrcode.value=="" || doc.vrcode.value==null)
	{
		alert("Please enter verification code");
		doc.vrcode.focus();
		return false;
	}
	return true;

}

function valid_orderonline()
{
	if(!checkRadio('orderonline','ptype'))
	{
		alert("Please select amount");
		return false;
	}
	else
	{
		return true;
	}
				   
}

function checkRadio (frmName, rbGroupName) {
 var radios = document[frmName].elements[rbGroupName];
 for (var i=0; i <radios.length; i++) {
  if (radios[i].checked) {
   return true;
  }
 }
 return false;
} 

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true
	}

