				/*function trim(sValue)
				{
					
					var myRegExp=/ /g;
					if (sValue==undefined)
					{
						return ""
					}
					else
					{
						var newStr=sValue.replace(myRegExp,"");
						return newStr;
					}
					
				}*/

				function calculateAmount()
				{
					var totAmount=0;
					// Hiddens containing count of checkboxes to be looped for
					var hiddenA=document.forms[0].hidACount;
					var hiddenB=document.forms[0].hidBCount;
					var hiddenC=document.forms[0].hidCCount;
					var hiddenD=document.forms[0].hidDCount;
					var hiddenE=document.forms[0].hidECount;
					var hiddenF=document.forms[0].hidFCount;
					var hiddenG=document.forms[0].hidGCount;
					// Hiddens containing count of checkboxes to be looped for

					var object; // Obj of checkboxes
					var hidobject; //Obj of hiddens for storing value 1 as multiplicant (Rooms, Teachers, Children counts).

					//hid___Base are used for storing Rs. taken as base for 2 multiplicator.

					var iTemp; //For stroing current calculated value

					var iCtr; // Loop Variable

/////////////////////////////////////////////////  Block A ///////////////////////////////////////////
					for (iCtr=1; iCtr <= hiddenA.value; iCtr++)
					{
						var objName = "cb1_" + iCtr;
						var hidName = "hid" + objName;
						object = eval("document.forms[0]." + objName);
						hidobject = eval("document.forms[0]." + hidName);
						if (object.checked==true)
						{
							if (iCtr!=4)
							{
								iTemp = parseInt((hidobject.value * document.forms[0].hidABase.value), 10);
								totAmount += iTemp;
							}
							else
							{
								
								if (document.forms[0].txtcb1_4.value != "" && document.forms[0].txtcb1_41.value != "" &&
								!isNaN(document.forms[0].txtcb1_4.value) &&
								!isNaN(document.forms[0].txtcb1_41.value))
								{
									iTemp = parseInt((document.forms[0].txtcb1_4.value * document.forms[0].txtcb1_41.value), 10);
									totAmount += iTemp;
								}
								else
								{
									alert("Please enter proper values in field a.");
									document.forms[0].txtcb1_4.focus();
									return false;
								}
							}
						}
					}
/////////////////////////////////////////////////  Block A ///////////////////////////////////////////


/////////////////////////////////////////////////  Block C ///////////////////////////////////////////
					for (iCtr=1; iCtr <= hiddenC.value; iCtr++)
					{
						var objName = "cb3_" + iCtr;
						var hidName = "hid" + objName;
						object = eval("document.forms[0]." + objName);
						hidobject = eval("document.forms[0]." + hidName);
						if (object.checked==true)
						{
							iTemp = parseInt((hidobject.value * document.forms[0].hidCBase.value), 10);
							totAmount += iTemp;
						}
					}

					if (document.forms[0].txtChildren.value != "" && !isNaN(document.forms[0].txtChildren.value))
					{
						iTemp = parseInt((document.forms[0].txtChildren.value * document.forms[0].hidCBase.value), 10);
						totAmount += iTemp;
					}
					if (document.forms[0].txtChildren.value != "" && isNaN(document.forms[0].txtChildren.value))
					{
						alert("Please enter proper values in field c.");
						document.forms[0].txtChildren.focus();
						return false;
					}
/////////////////////////////////////////////////  Block C ///////////////////////////////////////////

/////////////////////////////////////////////////  Block D ///////////////////////////////////////////
					for (iCtr=1; iCtr <= hiddenD.value; iCtr++)
					{
						var objName = "cb4_" + iCtr;
						var hidName = "hid" + objName;
						object = eval("document.forms[0]." + objName);
						hidobject = eval("document.forms[0]." + hidName);
						if (object.checked==true)
						{
							iTemp = parseInt((hidobject.value * document.forms[0].hidDBase.value), 10);
							totAmount += iTemp;
						}
					}

					if (document.forms[0].txtChildren1.value != "" && !isNaN(document.forms[0].txtChildren1.value))
					{
						iTemp = parseInt((document.forms[0].txtChildren1.value * document.forms[0].hidDBase.value), 10);
						totAmount += iTemp;
					}
					if (document.forms[0].txtChildren1.value != "" && isNaN(document.forms[0].txtChildren1.value))
					{
						alert("Please enter proper values in field d.");
						document.forms[0].txtChildren1.focus();
						return false;
					}
/////////////////////////////////////////////////  Block D ///////////////////////////////////////////


/////////////////////////////////////////////////  Block E ///////////////////////////////////////////
					for (iCtr=1; iCtr <= hiddenE.value; iCtr++)
					{
						var objName = "cb5_" + iCtr;
						var hidName = "hid" + objName;
						object = eval("document.forms[0]." + objName);
						hidobject = eval("document.forms[0]." + hidName);
						if (object.checked==true)
						{
							iTemp = parseInt((hidobject.value * document.forms[0].hidEBase.value), 10);
							totAmount += iTemp;
						}
					}

					if (document.forms[0].txtTeachers.value != "" && !isNaN(document.forms[0].txtTeachers.value))
					{
						iTemp = parseInt((document.forms[0].txtTeachers.value * document.forms[0].hidEBase.value), 10);
						totAmount += iTemp;
					}
					if (document.forms[0].txtTeachers.value != "" && isNaN(document.forms[0].txtTeachers.value))
					{
						alert("Please enter proper values in field e.");
						document.forms[0].txtTeachers.focus();
						return false;
					}
/////////////////////////////////////////////////  Block E ///////////////////////////////////////////

/////////////////////////////////////////////////  Block F ///////////////////////////////////////////
					for (iCtr=1; iCtr <= hiddenF.value; iCtr++)
					{
						var objName = "cb6_" + iCtr;
						var hidName = "hid" + objName;
						object = eval("document.forms[0]." + objName);
						hidobject = eval("document.forms[0]." + hidName);
						if (object.checked==true)
						{
							iTemp = parseInt((hidobject.value * document.forms[0].hidFBase.value), 10);
							totAmount += iTemp;
						}
					}

					if (document.forms[0].txtRooms.value != "" && !isNaN(document.forms[0].txtRooms.value))
					{
						iTemp = parseInt((document.forms[0].txtRooms.value * document.forms[0].hidFBase.value), 10);
						totAmount += iTemp;
					}
					if (document.forms[0].txtRooms.value != "" && isNaN(document.forms[0].txtRooms.value))
					{
						alert("Please enter proper values in field f.");
						document.forms[0].txtRooms.focus();
						return false;
					}
/////////////////////////////////////////////////  Block F ///////////////////////////////////////////

/////////////////////////////////////////////////  Block G ///////////////////////////////////////////
					if (document.forms[0].cb7_1.checked==true)
					{
						totAmount += 2500;
					}
					if (document.forms[0].cb7_2.checked==true)
					{
						totAmount += 5000;
					}
					if (document.forms[0].txtRs.value!="" && !isNaN(document.forms[0].txtRs.value))
					{
						totAmount += parseInt(document.forms[0].txtRs.value, 10);
					}
/////////////////////////////////////////////////  Block G ///////////////////////////////////////////

					document.forms[0].amount.value=totAmount;
					if (totAmount == 0)
					{
						if (document.forms[0].cb2_1.checked==false &&
							document.forms[0].cb2_2.checked==false &&
							document.forms[0].cb2_3.checked==false &&
							document.forms[0].cb2_4.checked==false &&
							document.forms[0].cb2_5.checked==false &&
							document.forms[0].cb2_6.checked==false &&
							document.forms[0].cb2_7.checked==false &&
							document.forms[0].cb2_8.checked==false)
							{
								alert("Cannot proceed, please select something to donate.")
								return false;
							}
							else
							{
								document.forms[0].hidGoByGateway.value=0;
								return true;
							}
					}
					if (confirm("Total cost is : " + totAmount))
						return true;
					else
						return false;
				}
				
				function trim(sValue)
				{
					var myRegExp=/ /g;
					try{
						var newStr=sValue.replace(myRegExp,"");
						return newStr;
					}catch(e){return "";}
					
				}
				
				function test(src)
				 {
					var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
					var regex = new RegExp(emailReg);
					return regex.test(src);
				 }
				function ValidateControl()
				{
					if(trim(document.forms[0].txtTitle.value)=='')
					{
						alert("Title can not be empty")
						document.forms[0].txtTitle.focus();
						return false;
					}
					if(trim(document.forms[0].txtFirst.value)=='')
					{
						alert("First name can not be empty")
						document.forms[0].txtFirst.focus();
						return false;
					}
					if(trim(document.forms[0].txtLast.value)=='')
					{
						alert("Last name can not be empty")
						document.forms[0].txtLast.focus();
						return false;
					}
					if(trim(document.forms[0].txttel.value)=='')
					{
						alert("Telephone No. can not be empty")
						document.forms[0].txttel.focus();
						return false;
					}
					
					
					if(trim(document.forms[0].txtemail.value)=='')
					{
						alert("Email can not be empty")
						document.forms[0].txtemail.focus();
						return false;
					}
					//var bool=test(document.forms[0].txtemail.value)
					//alert(bool)
					if(!test(document.forms[0].txtemail.value))
					{
						alert("Please enter proper email address")
						document.forms[0].txtemail.focus();
						return false;
					}
					if(trim(document.forms[0].txtaddress.value)=='')
					{
						alert("Address can not be empty")
						document.forms[0].txtaddress.focus();
						return false;
					}
					if(document.forms[0].txtaddress.value.length>100)
					{
						alert("Address Should not be more then 100 character")
						document.forms[0].txtaddress.focus();
						return false;
					}
					if(trim(document.forms[0].txtcountry.value)=='')
					{
						alert("Country can not be empty")
						document.forms[0].txtcountry.focus();
						return false;
					}
					if(trim(document.forms[0].txtpin.value)=='')
					{
						alert("PinCode can not be empty")
						document.forms[0].txtpin.focus();
						return false;
					}
					if(trim(document.forms[0].txtdate.value)=='')
					{
						alert("Date of Birth can not be empty")
						document.forms[0].txtdate.focus();
						return false;
					}
					if(document.forms[0].txtcompanyAddress.value.length>100)
					{
						alert("Company Address Should not be more then 100 character")
						document.forms[0].txtcompanyAddress.focus();
						return false;
					}
					if(document.forms[0].txtfriendEmail1.value !='')
					{
						if(!test(document.forms[0].txtfriendEmail1.value))
						{
							alert("Please enter proper email address")
							document.forms[0].txtfriendEmail1.focus();
							return false;
						}
					}
					if(document.forms[0].txtfriendEmail2.value != '')
					{
						if(!test(document.forms[0].txtfriendEmail2.value))
						{
							alert("Please enter proper email address")
							document.forms[0].txtfriendEmail2.focus();
							return false;
						}
					}
					if(document.forms[0].txtfriendEmail3.value !='')
					{
						if(!test(document.forms[0].txtfriendEmail3.value))
						{
							alert("Please enter proper email address")
							document.forms[0].txtfriendEmail3.focus();
							return false;
						}
					}

					if (calculateAmount())
						return true;
					else
						return false;
				}

