// JavaScript Document
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("Please enter a valid Email Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter a valid Email Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please enter a valid Email Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please enter a valid Email Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please enter a valid Email Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please enter a valid Email Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please enter a valid Email Address")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	
	var emailID=document.finalform.email
	var fname=document.finalform.fname
	var lname=document.finalform.lname
	var adress1=document.finalform.ad1
	var adress2=document.finalform.ad2
	var city=document.finalform.city
	var doarri=document.finalform.doarri
	var timeofarr=document.finalform.timeofarr
	var credit=document.finalform.credit
	var typecc=document.finalform.typecc
	var ccday=document.finalform.ccday
	var ccyear=document.finalform.ccyear
	var terms=document.finalform.terms
	var tel=document.finalform.tel
	var mob=document.finalform.mob
	

	
	
	if ((emailID.value==null)||(emailID.value==""))
	{
		alert("Please Enter the Email Address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	
	if ((fname.value==null)||(fname.value==""))
	{
		alert("Please Enter the First Name")
		fname.focus()
		return false
	}
	
	if ((lname.value==null)||(lname.value==""))
	{
		alert("Please Enter the Last Name")
		lname.focus()
		return false
	}
	
	if ((adress1.value==null)||(adress1.value==""))
	{
		alert("Please Enter the Address Line 1")
		adress1.focus()
		return false
	}
	
	if ((adress2.value==null)||(adress2.value==""))
	{
		alert("Please Enter the Address Line 2")
		adress2.focus()
		return false
	}
	
	if ((city.value==null)||(city.value==""))
	{
		alert("Please Enter the City")
		city.focus()
		return false
	}
	
	if ((doarri.value==null)||(doarri.value==""))
	{
		alert("Please Enter the Date of arrival:")
		doarri.focus()
		return false
	}
	
	if ((timeofarr.value==null)||(timeofarr.value==""))
	{
		alert("Please Enter the Time of arrival:")
		timeofarr.focus()
		return false
	}
	
		if ((tel.value==null)||(tel.value==""))
	{
		alert("Please Enter the Telephone number")
		tel.focus()
		return false
	}
	
		if ((mob.value==null)||(mob.value==""))
	{
		alert("Please Enter the Mobile number")
		mob.focus()
		return false
	}
	
	/*
	
	if ((terms.value=="1"))
	{
		alert("Please agree with the Terms of Service")
		terms.focus()
		return false
	}



	if((document.donation.s1.checked) || (document.donation.s2.checked) || (document.donation.s3.checked) || (document.donation.s4.checked))
	{
		
	}else
	{
	alert("Please Enter the Salutation")
	    s1.focus()
		return false
	}
	
	 if ((fname.value==null)||(fname.value==""))
	{
		alert("Please Enter the First Name")
		fname.focus()
		return false
	}
		 if ((lname.value==null)||(lname.value==""))
	{
		alert("Please Enter the Last Name")
		lname.focus()
		return false
	}
	
		 if ((address.value==null)||(address.value==""))
	{
		alert("Please Enter the Address")
		address.focus()
		return false
	}
	
	if ((city.value==null)||(city.value==""))
	{
		alert("Please Enter the City")
		city.focus()
		return false
	}
	
		if ((state.value==null)||(state.value==""))
	{
		alert("Please Enter the State/Province/ Region")
		state.focus()
		return false
	}
	
		if ((country.value==null)||(country.value==""))
	{
		alert("Please Enter the Country")
		country.focus()
		return false
	}
		if ((tel.value==null)||(tel.value==""))
	{
		alert("Please Enter the Phone Number")
		tel.focus()
		return false
	}
	
	if((document.donation.checking1.checked) || (document.donation.checking2.checked) || (document.donation.checking3.checked))
	{
		
	}else
	{
	alert("Please Enter your Contributions Method")
	    checking1.focus()
		return false
	}
	
		if((document.donation.checking1.checked) || (document.donation.checking2.checked))
	{
		if((document.donation.rno.value==null)|| (document.donation.rno.value=="")){
			
			alert("Please Enter the Routing Number")
	    	rno.focus()
			return false
			}else if ((document.donation.ano.value==null)|| (document.donation.ano.value=="")){
				
				alert("Please Enter the Account Number")
	    		ano.focus()
				return false
				
				}
	}
	
	if((document.donation.checking3.checked))
	{
		if((document.donation.ccno.value==null)|| (document.donation.ccno.value=="")){
			
			alert("Please Enter the Credit Card Number")
	    	ccno.focus()
			return false
			} else if ((document.donation.exday.value==null)|| (document.donation.exday.value=="")){
				
				alert("Please Enter the day of the Credit card Expiration date")
	    		exday.focus()
				return false
				
				} else if ((document.donation.exdate.value==null)|| (document.donation.exdate.value=="")){
				
				alert("Please Enter the Year of the Credit card Expiration date")
	    		exdate.focus()
				return false
				
				}
	}

		
		if ((money.value==null)||(money.value==""))
	{
		alert("Please Enter the Amount of Gift")
		money.focus()
		return false
	}
	
		if (money.value<5)
	{
		alert("Minimum donation you can make is 5 dollers")
		money.focus()
		return false
	}

        if ((dbegin.value==null)||(dbegin.value==""))
	{
		alert("Please Enter the Donation Start Date")
		dbegin.focus()
		return false
	}
	
	*/
	
	return true
 
}
	

function enableField(x){



if (x=='Checking' || x=='Savings')
{

document.donation.rno.readOnly=false;
document.donation.ano.readOnly=false;
document.donation.rno.style.backgroundColor='#FFFFFF';
document.donation.ano.style.backgroundColor='#FFFFFF';
document.getElementById('ccno').readOnly=true;
document.getElementById('exdate').readOnly=true;
document.getElementById('exday').readOnly=true;
document.donation.ccno.style.backgroundColor='#DFDFDF';
document.donation.exdate.style.backgroundColor='#DFDFDF';
document.donation.exday.style.backgroundColor='#DFDFDF';
}
else if (x=="credit")
{
document.getElementById('ccno').readOnly=false;
document.getElementById('exdate').readOnly=false;	
document.getElementById('exday').readOnly=false;
document.donation.ccno.style.backgroundColor='#FFFFFF';
document.donation.exdate.style.backgroundColor='#FFFFFF';
document.donation.exday.style.backgroundColor='#FFFFFF';
document.donation.rno.readOnly=true;
document.donation.ano.readOnly=true;
document.donation.rno.style.backgroundColor='#DFDFDF';
document.donation.ano.style.backgroundColor='#DFDFDF';
}

}
