	function openpopup(popurl){
		var winpops=window.open(popurl,"","width=450px,height=320px,scrollbars")
		}
function validateField(value,name,validChar)
{
 	
	digits_field_val = value;
	digits_field_val_len = digits_field_val.length;

	lastword_digits_field_val_len = digits_field_val.length;
	
	var valid;
	
	for(u=0; u<digits_field_val_len; u++)
	{
		if (validChar.indexOf(digits_field_val.charAt(u)) < 0)
		{
			if(name == "Amount")
			{
				valid = "Your amount should be in round number.";
			}
			else
			{
				valid = "Special characters are not allowed.";
			}
			/*for(i=0; i<digits_field_val_len - 1; i++)
			{
				if(validChar.indexOf(digits_field_val.charAt(i)) < 0)
				{}
				else
				{						
					lastword = lastword + digits_field_val.charAt(i);
				}
			}
			document.getElementById(name).value = lastword;*/
			//alert(valid);
			document.getElementById('name').focus();
			lastword = '';
		return false;
		}
	}	
	return true;
}
function donatetype_old(id)
{

   //alert(id);
	if(id=="become-patron")
    {
     document.getElementById("amount").value=5000;
	 //document.frm_donation.quantity.value=0;
	 //document.frm_donation.total.value=0;
	 document.frm_donation.Amount.readOnly=true;
    }
	if(id=="become-benefactor")
    {
     document.getElementById("amount").value=2500;
	 //document.frm_donation.quantity.value=0;
	 //document.frm_donation.total.value=0;
	 document.frm_donation.Amount.readOnly=true;
    }
	if((id=="renew-pledge")||(id=="become-curranfoundation"))
    {
     document.getElementById("amount").value=0;
	 //document.frm_donation.quantity.value=0;
	 //document.frm_donation.total.value=0;
	 document.frm_donation.Amount.readOnly=false;
    }
}

function donateTypeCheck(id)
{
	for (var i=0; i < document.frm_donation.Donation.length; i++)
	{
		if (i == id && id == 0)
		{
			document.getElementById("amount").value = 5000;
			//document.getElementById("Donation").value = 5000;
			document.frm_donation.Amount.readOnly=true;
			break;

		}
		if (i == id && id == 1)
		{
			document.getElementById("amount").value = 2500;
			//document.getElementById("Donation").value = 2500;
			document.frm_donation.Amount.readOnly=true;
			break;
		}
		if (i == 2 && id == 2)
		{
			document.getElementById("amount").value = 0;
			//document.getElementById("Donation").value = 0;
			document.frm_donation.Amount.readOnly=false;
			break;
		}
		if (i == 3 && id == 3)
		{
			document.getElementById("amount").value = 0;
			//document.getElementById("Donation").value = 0;
			document.frm_donation.Amount.readOnly=false;
			break;
		}
	}
}
function resetDonationField()
{
	//document.getElementById("Donation").value = document.getElementById("amount").value;
}
function calculation()
{
   var db_amt = document.getElementById("db_amt").value;
   var quantity=document.getElementById("Quantity").value;
   var total=(db_amt*quantity);
   //alert(db_amt);
   //document.frm_donation.amount.value=total;
   document.getElementById("amount").value=total;


}
function check_radio_box()
{
	var pass = "no";
	if(document.frm_donation.Donation)
	{
		//var donation_type=document.getElementById("Donation").value;
		for(var i = 0; i < document.frm_donation.Donation.length; i++)
		{
			if(document.frm_donation.Donation[i].checked == true)
			{
				pass = "yes";
				break;
			}
		}
	}
	else
	{
		pass = "yes";
	}
	//alert(document.getElementById.amount.value);
	if(pass == "no")
	{
		return false;
	}
	if(pass == "yes")
	{
		return true;
	}
}

function checkEventValidation(what)
{
	var chkpass = "yes";
	if(document.frm_donation.Quantity)
	{
	    for (var i=0, j=what.elements.length; i<j; i++)
	    {
		myType = what.elements[i].type;
		myName = what.elements[i].name;
		if (myType == 'text' && document.frm_donation.Quantity)
		{
			if(document.getElementById('Quantity').value == 0 || document.getElementById('Quantity').value == "")
			{
				chkpass = "no";
				//break;
				
			}

			
		}
		if(myType == 'hidden' && myName == "Quantity")
		{
			
			//what.elements[i].value = document.frm_donation.amount.value;
			//alert(what.elements[i].value);
		}
	    }
	    if(chkpass == "no")
	    {
	    	return false
	    	
	    }
	    if(chkpass == "yes")
	    {
	    	return true;
	    }
	}
	else
	{
		return true;
	}
}
function validate()
{
	var checked_pass = "y";
	var what = document.frm_donation;
	if(!checkEventValidation(what))
	{
		alert("Please enter the number of tickets.");
		document.getElementById('Quantity').focus();
		checked_pass = "n";
		return false;
	
	}
	if(!check_radio_box())
	{
		alert("Please select a donation option");
		document.frm_donation.Amount.focus();
		checked_pass = "n";
		return false;
	}
	if(document.frm_donation.Amount.value == "" || document.frm_donation.Amount.value == 0)
	{
		alert("Please Enter Amount");
		document.frm_donation.Amount.focus();
		checked_pass = "n";
		return false;
	}
	else
	{
		if(validateField(document.frm_donation.Amount.value,"Amount","0123456789")==false)
		{
		
			document.getElementById("amount").focus();
			return false;
		}
	}
	if(document.frm_donation.Firstname.value == "")
	{
		alert("Please Enter First Name");
		document.frm_donation.Firstname.focus();
		checked_pass = "n";
		return false;
	}
	if(document.frm_donation.Surname.value == "")
	{
		alert("Please Enter Last Name");
		document.frm_donation.Surname.focus();
		checked_pass = "n";
		return false;
	}
	if(document.frm_donation.Email.value == "")
	{
		alert("Please Enter Email");
		document.frm_donation.Email.focus();
		checked_pass = "n";
		return false;
	}
   	
	if(!(document.frm_donation.Email.value.match(/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-z]{2,3})$/)))
	{
		alert("Please Enter Valid Email");
	 	document.frm_donation.Email.focus();
	 	checked_pass = "n";
	 	return false;
	}
 	if (document.frm_donation.Phonenumber.value=='')
	{
		alert("Please Enter Phone Number");
		document.frm_donation.Phonenumber.focus();
		checked_pass = "n";
		return false;
	}
	if(!(document.frm_donation.Phonenumber.value.match(/(\+)?([-\._\(\) ]?[\d]{3,20}[-\._\(\) ]?){2,10}/)))
	{
	    alert("Please enter valid Phone Number ");
		document.frm_donation.Phonenumber.focus();
		checked_pass = "n";
		return false;
	}
	if(checked_pass == "y")
	{
		if(document.frm_donation.Donation)
		{
			//var donation_type=document.getElementById("Donation").value;
			for(var i = 0; i < document.frm_donation.Donation.length; i++)
			{
				if(document.frm_donation.Donation[i].checked == true)
				{
					var donation_type = document.frm_donation.Donation[i].value;
					break;
				}
			}
		}
		var amount=document.getElementById("amount").value;
		if(document.getElementById('Event'))
		{
			var eventname=document.getElementById("Event").value;
			var Quantity= document.getElementById("Quantity").value;
			var totalnew=document.getElementById("amount").value;
			var guestname = document.getElementById("guestname").value;
			//var name = document.getElementById("name").value;
			//var company = document.getElementById("company").value;

		}
		else
		{
			var eventname="undefined";
			var Quantity= 0;
			var totalnew= 0;
			var guestname = "";
			//var name = "";
			//var company = "";			
		}
		
		
		var title = document.getElementById("title").value;
		var firstname = document.getElementById("firstname").value;
		var lastname = document.getElementById("surname").value;
		var address1 = document.getElementById("address1").value;
		var address2 = document.getElementById("address2").value;
		var address3 = document.getElementById("address3").value;
		var suburb = document.getElementById("suburb").value;
		var postcode = document.getElementById("postcode").value;
		var state = document.getElementById("state").value;
		var email = document.getElementById("email").value;
		var phonenumber = document.getElementById("phonenumber").value;
		var donation_hash = document.getElementById("donation_hash").value;
		var name = document.getElementById("name").value;
		var company = document.getElementById("company").value;
        /*alert(name);
		alert(company);
		alert(address3);*/
		
 
		//var agegroup = document.getElementById("agegroup").value;
		
		if(document.getElementById("subscribed").checked == true)
		{
			document.getElementById("subscribed").value = "Y";
		}
		if(document.getElementById("subscribed").checked == false)
		{
			document.getElementById("subscribed").value = "N";
		}		
		var subscribed = document.getElementById("subscribed").value;
				
		<!--var query_str =donation_type+"="+amount+"="+title+"="+firstname+"="+lastname+"="+address1+"="+address2+"="+suburb+"="+postcode+"="+state+"="+email+"="+phonenumber+"="+guestname+"="+donation_hash+"="+eventname+"="+Quantity+"="+totalnew+"="+subscribed+"="+name+"="+company;-->
		
		var query_str =donation_type+"="+amount+"="+title+"="+firstname+"="+lastname+"="+address1+"="+address2+"="+suburb+"="+postcode+"="+state+"="+email+"="+phonenumber+"="+guestname+"="+donation_hash+"="+eventname+"="+Quantity+"="+totalnew+"="+subscribed+"="+name+"="+company+"="+address3;
		
		//alert(query_str);
		
		if(!addValueInDatabase(query_str))
		{
			return false;
		}

	 }

}
function entryInDatabase(temp_url)						//paging function.
{
		loadXMLDocApiModuleForm(temp_url);
		//return true;


}
function loadXMLDocApiModuleForm(url)
{
	if (window.XMLHttpRequest)
	{
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChangePhotoModuleForm;
		req.open("GET", url, true);
		req.send(null);
		// branch for IE/Windows ActiveX version
	}
	else if (window.ActiveXObject)
	{
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req)
		{
			req.onreadystatechange = processReqChangePhotoModuleForm;
			req.open("GET", url, true);
			req.send();
		}
	}
}

function processReqChangePhotoModuleForm()
{
	// only if req shows "complete"
	if (req.readyState == 4)
	{

		// only if "OK"
		if (req.status == 200)
		{
			response = req.responseXML.documentElement;
			var urlpath='';
			for(var x = 0; response.getElementsByTagName('urlpath')[0].childNodes[x]; x++ )
			urlpath = urlpath.concat(response.getElementsByTagName('urlpath')[0].childNodes[x].data);
			//alert(urlpath);
			document.getElementById("ajax_call").innerHTML = urlpath;

		}
		else
		{

			alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}
}

