function validateForm()
{
	today = new Date() ;
	diff  = new Date();
	var Name = new RegExp("^[0-9a-zA-Z\\s\\.]{3,100}$");
   	var Add = new RegExp("^[A-Za-z0-9\\/\\#\\-\\_\\()\\s\\.\\,\\:\\&]{3,120}$");
   	var TN = new RegExp("^[0-9]{6,20}$");
	var amount = new RegExp("^([1-9]{1}[0-9]{0,7}|[1-9]{1}[0-9]{0,7}\\.[0-9]{2})$");
	var date = new RegExp("^(((0[1-9]|[12][0-9]|3[01])([/])(0[13578]|10|12)([/])([1-2][0,9][0-9][0-9]))|(([0][1-9]|[12][0-9]|30)([/])(0[469]|11)([/])([1-2][0,9][0-9][0-9]))|((0[1-9]|1[0-9]|2[0-8])([/])(02)([/])([1-2][0,9][0-9][0-9]))|((29)(\.|-|\/)(02)([/])([02468][048]00))|((29)([/])(02)([/])([13579][26]00))|((29)([/])(02)([/])([0-9][0-9][0][48]))|((29)([/])(02)([/])([0-9][0-9][2468][048]))|((29)([/])(02)([/])([0-9][0-9][13579][26])))$");	
	if (!document.form1.txtCustomerID.value.match(Name))
	{
		alert("Please enter a valid Name of the Donor (eg Sachin Sharma)");
		document.form1.txtCustomerID.focus();
		return false;
	}
	if (!document.form1.txtAdditionalInfo1.value.match(Add))
	{
		alert("Please enter a valid Address (eg 7/7 I Flr, Old Rajinder Nagar,N D-60)");
		document.form1.txtAdditionalInfo1.focus();
		return false;
	}
	if (!document.form1.txtAdditionalInfo3.value.match(TN))
	{
		alert("Please enter a valid Telephone Numbar (eg 23485872)");
		document.form1.txtAdditionalInfo3.focus();
		return false;
	}
	if(document.form1.txtDonationType.value == 0)
	{
		alert("Please select a valid Type of Donation");
		document.form1.txtDonationType.focus();
		return false;
	}
		if (document.form1.txtPoojaType.value == 0 && document.form1.txtDonationType.value != "Others")
		{
			alert("Please select a Pooja Type.");
			document.form1.txtPoojaType.focus();
			return false;
		}
	if(document.form1.txtDonationType.value == "Regular Pooja")
	{
		var str_DonationType=document.form1.txtDonationType.value;
		var str_PoojaType=document.form1.txtPoojaType.value;
		var conv_info2= str_DonationType + "~" + str_PoojaType + "~" + "NA" + "~" + "NA";
		document.form1.txtAdditionalInfo2.value = conv_info2;
//		alert("txtAdditionalInfo2 =" + document.form1.txtAdditionalInfo2.value);
		document.form1.txtAdditionalInfo4.value = "00000000";

	}
	if(document.form1.txtDonationType.value == "Endowment Schemes")
	{
    	
		if (document.form1.txtPoojaDate.value.length == 0)
		{
			alert("Please enter a valid Date on which he/she intends to offer the Pooja (eg 02/08/2006)");
			document.form1.txtPoojaDate.focus();
			return false;
		}

		if (checkDate())		
		{
			alert("Please enter a valid Date on which he/she intends to offer the Pooja (eg 02/08/2006)");
			document.form1.txtPoojaDate.focus();
			return false;
		}
		if (!document.form1.txtNamePooja.value.match(Name))
		{
			alert("Please enter a valid Name of the person in whose name the pooja to be conducted.");
			document.form1.txtNamePooja.focus();
			return false;
		}
		if (document.form1.txtNameGothram.value.length > 0) {
		if (!document.form1.txtNameGothram.value.match(Name))
		{
			alert("Please enter a valid Name of gothram.");
			document.form1.txtNameGothram.focus();
			return false;
		}

		}
		document.form1.txtAdditionalInfo4.value = document.form1.txtPoojaDate.value;
		var str_DonationType=document.form1.txtDonationType.value;
		var str_PoojaType=document.form1.txtPoojaType.value;
		var str_NamePooja=document.form1.txtNamePooja.value;
		var str_NameGothram=document.form1.txtNameGothram.value;
		var conv_info2a= str_DonationType + "~" + str_PoojaType + "~" + str_NamePooja + "~" + str_NameGothram;
		document.form1.txtAdditionalInfo2.value = conv_info2a;
//		alert("txtAdditionalInfo2 =" + document.form1.txtAdditionalInfo2.value);
//		alert("txtAdditionalInfo4 =" + document.form1.txtAdditionalInfo4.value);
	}

	
		if(document.form1.txtDonationType.value == "Others")
	{
		if (document.form1.txtDonationPurpose.value.length == 0)
		{
			alert("Please enter a valid Purpose of Daonation.");
			document.form1.txtDonationPurpose.focus();
			return false;
		}
		var str_DonationType=document.form1.txtDonationType.value;
		var str_PoojaType=document.form1.txtPoojaType.value;
		var str_DonationPurpose=document.form1.txtDonationPurpose.value;
		var conv_info2b= str_DonationType + "~" + "NA" + "~" + str_DonationPurpose + "~" + "NA";
		document.form1.txtAdditionalInfo2.value = conv_info2b;
		document.form1.txtAdditionalInfo4.value = "00000000";
//		alert("txtAdditionalInfo2 =" + document.form1.txtAdditionalInfo2.value);
	}

	
	if (! document.form1.txtTxnAmount.value.match(amount))
	{
		alert("Please enter a valid Donation Amount (eg 3022.26)");
		document.form1.txtTxnAmount.focus();
		return false;
	}

	ls_date2 = document.form1.txtPoojaDate.value;
	sub_date12 = ls_date2.substring(0,2);
	sub_date22 = ls_date2.substring(3,5);
	sub_date32 = ls_date2.substring(6,10);
	if (! check_bhogdate())
	{
		return false;
	}
		var conv_Date2 = sub_date32 + sub_date22 + sub_date12;
		document.form1.txtAdditionalInfo4.value = conv_Date2;
		var str=document.form1.txtTxnAmount.value;
		if (str.indexOf(".")== -1)
		{
			str=str+".00";
		}
		document.form1.txtTxnAmount.value=str;

		//alert("HUI"+document.form1.txtAdditionalInfo4.value);
		if (document.form1.txtAdditionalInfo4.value=="")
		{
			document.form1.txtAdditionalInfo4.value="00000000";
		}

		document.all.item("form1").action="https://www.billdesk.com/pgidsk/servlet/com.pgidsk.controller.PGIBillerRequestHandler"
		document.form1.submit();


}

function checkDate()
{
if (document.form1.txtPoojaDate.value.length > 0)
{
		var date = new RegExp("^(((0[1-9]|[12][0-9]|3[01])([/])(0[13578]|10|12)([/])([1-2][0,9][0-9][0-9]))|(([0][1-9]|[12][0-9]|30)([/])(0[469]|11)([/])([1-2][0,9][0-9][0-9]))|((0[1-9]|1[0-9]|2[0-8])([/])(02)([/])([1-2][0,9][0-9][0-9]))|((29)(\.|-|\/)(02)([/])([02468][048]00))|((29)([/])(02)([/])([13579][26]00))|((29)([/])(02)([/])([0-9][0-9][0][48]))|((29)([/])(02)([/])([0-9][0-9][2468][048]))|((29)([/])(02)([/])([0-9][0-9][13579][26])))$");	

	if (! document.form1.txtPoojaDate.value.match(date))		
	{
		
		return true;
	}
	else
	{
		return false;
	}
}	
else
	{
	document.form1.txtPoojaDate.value="00/00/2009";
	}		
}

function  check_bhogdate()
{
	var due_mmddyyyy =  new Date(sub_date22 +"/"+ sub_date12 +"/"+ sub_date32);
	diff.setTime(Math.abs(due_mmddyyyy.getTime() - today.getTime()));
	timediff = diff.getTime();
	var days = Math.floor(timediff / (1000 * 60 * 60 * 24));
	days = days + 2 ;
	//alert("days = "+days)
	if (due_mmddyyyy > today)
	{
		if(days >= 2000)
		{
			alert("Bhog Date:  should not be less than Today ");
			return false;
		}
		return true;
	}
	days = - days ;
	//alert("days ="+days);
	if(days <= -3)
	{
		alert("Bhog Date:  should not be less than Today ");
		return false;
	}
	return true;

}	

function DonationType()
{

		if (document.form1.txtDonationType.value=="init")
		{
			return true;
		}
		else
		{
			return false;
		}
}


function setOptions(chosen) {
	var poojaType = document.form1.txtPoojaType;


	poojaType.options.length = 0;

if (chosen == "0") {
	poojaType.options[poojaType.options.length] = new Option('==Select Pooja Type==', 0);
  }
  
if (chosen == "Regular Pooja") {
	poojaType.options[poojaType.options.length] = new Option('==Select Pooja Type==','0');
	poojaType.options[poojaType.options.length] = new Option('Panchamrita Abhishek','Panchamrita Abhishek');
	poojaType.options[poojaType.options.length] = new Option('Kumkumarchana','Kumkumarchana');
	poojaType.options[poojaType.options.length] = new Option('Padya Puja','Padya Puja');
	poojaType.options[poojaType.options.length] = new Option('Saree and blouse piece (Rs. 250.00)','Saree and blouse piece (Rs. 250.00)');
	poojaType.options[poojaType.options.length] = new Option('Saree and blouse piece (Rs. 401.00)','Saree and blouse piece (Rs. 401.00)');
	document.getElementById("EndowmentSchemes").style.visibility = "hidden";
	document.getElementById("Others").style.visibility = "hidden";
	
	document.form1.txtPoojaDate.value='';
	document.form1.txtNamePooja.value='';
	document.form1.txtNameGothram.value='';
	document.form1.txtDonationPurpose.value='';
	document.form1.txtTxnAmount.value='';
 	document.form1.txtTxnAmount.readOnly=true;
	}

if (chosen == "Endowment Schemes") {
	poojaType.options[poojaType.options.length] = new Option('==Select Pooja Type==','0');
	poojaType.options[poojaType.options.length] = new Option('Abhisheka','Abhisheka');
	poojaType.options[poojaType.options.length] = new Option('Kumkumarchana ','Kumkumarchana ');
	poojaType.options[poojaType.options.length] = new Option('Padya Puja ','Padya Puja ');
	document.getElementById("EndowmentSchemes").style.visibility = "visible";
	document.getElementById("Others").style.visibility = "hidden";
	
	document.form1.txtPoojaDate.value='';
	document.form1.txtNamePooja.value='';
	document.form1.txtNameGothram.value='';
	document.form1.txtDonationPurpose.value='';
	document.form1.txtTxnAmount.value='';
 	document.form1.txtTxnAmount.readOnly=true;

	}
if (chosen == "Others") {
	poojaType.options[poojaType.options.length] = new Option('==Select Pooja Type==','0');
	document.getElementById("EndowmentSchemes").style.visibility = "hidden";
	document.getElementById("Others").style.visibility = "visible";
	document.form1.txtPoojaDate.value='';
	document.form1.txtNamePooja.value='';
	document.form1.txtNameGothram.value='';
	document.form1.txtDonationPurpose.value='';
	document.form1.txtTxnAmount.value='';
 	document.form1.txtTxnAmount.readOnly=false;


}

}


function setOptions2(chosen) {
	var donationAmount = document.form1.txtTxnAmount;

if (chosen == "Panchamrita Abhishek") {
  		donationAmount.value='151.00';
 		donationAmount.readOnly=true;
}
	if (chosen == "Kumkumarchana") {
  		donationAmount.value='101.00';
 		donationAmount.readOnly=true;
}
	if (chosen == "Padya Puja") {
  		donationAmount.value='51.00';
 		donationAmount.readOnly=true;
}
	if (chosen == "Saree and blouse piece (Rs. 250.00)") {
  		donationAmount.value='250.00';
 		donationAmount.readOnly=true;
}
	if (chosen == "Saree and blouse piece (Rs. 401.00)") {
  		donationAmount.value='401.00';
 		donationAmount.readOnly=true;
}

	if (chosen == "Abhisheka") {
  		donationAmount.value='10000.00';
 		donationAmount.readOnly=true;
}
	if (chosen == "Kumkumarchana ") {
  		donationAmount.value='7000.00';
 		donationAmount.readOnly=true;
}
	if (chosen == "Padya Puja ") {
  		donationAmount.value='5000.00';
 		donationAmount.readOnly=true;
}
	if (chosen == "==Select Pooja Type==") {
//		if (document.form1.txtDonationType.value == "Others"){
//	alert("Hui");
donationAmount.value='';
 		donationAmount.readOnly=false;

}

}