function updateform()
{
		document.getElementById('amount').value = document.getElementById('newamount').value;
		var amount1 = document.getElementById('amount').value;
		if(amount1 < "0.99")
		{
			alert("Please enter an amount of at least 1.00");
		}
}

function updateform1()
{
	document.getElementById('a3').value = document.getElementById('newamount').value;

}

function closearea(close1)
{
	document.getElementById(close1).innerHTML = '';	
}

function formcreate(dtype1)
{
	if(dtype1 == 'onetime')
	{
		document.getElementById('formarea').innerHTML = '<input type="hidden" name="cmd" value="_s-xclick"><input type="hidden" name="hosted_button_id" value="7572739"><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"><img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">';
	}
	else if(dtype1 == 'reocurring')
	{
		document.getElementById('formarea').innerHTML = 'Amount:<br /><input id="newamount" onblur="updateform1();" type="text" name="newamount" />&nbsp;<select name="duration" id="duration" onchange="buttonupdate(this)"><option value="1">Select Monthly Cycles</option><option value="3">3 Months</option><option value="6">6 Months</option><option value="9">9 Months</option><option value="12">12 Months</option></select><br /><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"><img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"><input type="hidden" name="cmd" value="_xclick-subscriptions"><input type="hidden" name="business" value="kingdomfaith@kingdomfaithchurch.org"><input type="hidden" name="item_name" value="ReOcurring Donations"><input type="hidden" name="page_style" value="Primary"><input type="hidden" name="no_shipping" value="1"><input type="hidden" name="return" value="http://www.kingdomfaithchurch.org/test.php?func=successful"><input type="hidden" name="no_note" value="1"><input type="hidden" name="currency_code" value="USD"><input type="hidden" name="lc" value="US"><input type="hidden" name="bn" value="PP-SubscriptionsBF"><input type="hidden" name="a3" value="0.00"><input type="hidden" name="p3" value="1"><input type="hidden" name="t3" value="M"><input type="hidden" name="src" value="1"><input type="hidden" name="sra" value="1"><input type="hidden" name="srt" value="0"></form>';
	}
	else if(dtype1 == 'cds')
	{
		document.getElementById('reveal').innerHTML = 'Amount:<input id="newamount" onblur="updateform1();" type="text" name="newamount" />&nbsp;<input type="submit" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" value="Get CD Now">';
	}
}

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					
	}

function scavengerhunt(){
	var emailID=document.getElementById('emailaddress');
	var formsubmit = document.getElementById('prayeremail');
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	else if (echeck(emailID.value)==true){
		formsubmit.submit();
	}
}

function submitform(var1)
{
	formsend = document.getElementById('donation3');
	formsend.submit();
}

function ValidateForm(){
	var emailID=document.prayeremail.emailaddress
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	else if (echeck(emailID.value)==true){
		document.prayeremail.submit();
	}
 }
 
function redirecthunt()
{
	var today = new Date();
	var month = today.getMonth()+1;
	var date = today.getDate();
	var page = 'scavengerhunt.php';
	if((month >= 8) && (date <= 16))
	{	page = 'scavengerhunt.php'; }
	else if((month >= 8) && (date >= 17))
	{	page = 'scavengerhuntnew.php'; }
	window.location.href = page;
}

function buttonupdate(currentform)
{
	if(currentform.value == "")
	{
		alert("Please Select Monthly Committment.");
	}
	else
	{
		document.getElementById('srt').value = currentform.value;
	}
	
}

function checknumber(){
var x=document.checknum.pnum.value
var anum=/(^\d+$)|(^\d+\.\d+$)/
if (anum.test(x))
testresult=true
else{
alert("Please input a valid number!")
testresult=false
}
return (testresult)
}

function checkban(){
if (document.layers||document.all||document.getElementById)
return checknumber()
else
return true
}

function overlay(overlay,cdname) {
	e2 = document.getElementById('placeholder');
	e2.innerHTML = "<div id=\"" + overlay + "\"><div><form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\">Amount:<input id=\"newamount\" onblur=\"updateform();\" type=\"text\" name=\"newamount\" /><input type=\"hidden\" name=\"cmd\" value=\"_donations\"><input type=\"hidden\" name=\"business\" value=\"kingdomfaith@kingdomfaithchurch.org\"><input type=\"hidden\" name=\"item_name\" value=\"" + cdname + " - " + overlay + "\"><input id=\"amount\" type=\"hidden\" name=\"amount\" value=\"0.00\"><input type=\"hidden\" name=\"no_shipping\" value=\"0\"><input type=\"hidden\" name=\"no_note\" value=\"1\"><input type=\"hidden\" name=\"currency_code\" value=\"USD\"><input type=\"hidden\" name=\"tax\" value=\"0\"><input type=\"hidden\" name=\"lc\" value=\"US\"><input type=\"hidden\" name=\"bn\" value=\"PP-DonationsBF\"><br /><input style=\"left:-5px;\" type=\"image\" src=\"https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal - The safer, easier way to pay online!\"><img alt=\"\" border=\"0\" src=\"https://www.paypal.com/en_US/i/scr/pixel.gif\" width=\"1\" height=\"1\"></form><br><a href=\"#\" onclick=\"closeoverlay();\">Close</a></div></div>";
	el = document.getElementById(overlay);
	el.style.visibility = "visible";
}

function overlay2(overlay,cdname) {
	e2 = document.getElementById('placeholder');
	e2.innerHTML = "<div id=\"" + overlay + "\"><div><table><tr><td>" + cdname + "</td><td>$5.50</td></tr><tr><td colspan=\"2\"><form style=\"margin-top:5px; margin-bottom:0px; margin:0px;\" action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\"><input type=\"hidden\" name=\"cmd\" value=\"_xclick\"><input type=\"hidden\" name=\"business\" value=\"kingdomfaith@kingdomfaithchurch.org\"><input type=\"hidden\" name=\"undefined_quantity\" value=\"1\"><input type=\"hidden\" name=\"item_name\" value=\"" + cdname + "\"><input type=\"hidden\" name=\"item_number\" value=\"" + overlay + "\"><input type=\"hidden\" name=\"amount\" value=\"5.50\"><input type=\"hidden\" name=\"page_style\" value=\"Primary\"><input type=\"hidden\" name=\"no_shipping\" value=\"2\"><input type=\"hidden\" name=\"return\" value=\"http://www.kingdomfaithchurch.org/test.php?func=successful\"><input type=\"hidden\" name=\"logo_custom\" value=\"http://www.kingdomfaithchurch.org/images/buynow.bmp\"><input type=\"hidden\" name=\"no_note\" value=\"1\"><input type=\"hidden\" name=\"currency_code\" value=\"USD\"><input type=\"hidden\" name=\"lc\" value=\"US\"><input type=\"hidden\" name=\"bn\" value=\"PP-BuyNowBF\"><input type=\"image\" src=\"http://www.kingdomfaithchurch.org/images/buynow.bmp\" border=\"0\" name=\"submit\" alt=\"PayPal - The safer, easier way to pay online!\"><img alt=\"\" border=\"0\" src=\"https://www.paypal.com/en_US/i/scr/pixel.gif\" width=\"1\" height=\"1\"></form><br><a href=\"#\" onclick=\"closeoverlay();\">Close</a></td></tr></table></div></div>";
	el = document.getElementById(overlay);
	el.style.visibility = "visible";
}


function closeoverlay() {
	e2 = document.getElementById('placeholder');
	e2.innerHTML = " ";
}

function reveal()
{
	var theAd = document.getElementById('showbox');
	theAd.style.display = 'block';
}

function closeit()
{
	var theAd = document.getElementById('showbox');
	theAd.style.display = 'none';
}

function donate(cdnum)
{
	e1 = document.getElementById(cdnum,cdname);
	e1.innerHTML = "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\"><input type=\"hidden\" name=\"cmd\" value=\"_donations\"><input type=\"hidden\" name=\"business\" value=\"kingdomfaith@kingdomfaithchurch.org\"><input type=\"hidden\" name=\"item_name\" value=\"CD Love Gift\"><input type=\"hidden\" name=\"item_number\" value=\"CDID\"><input type=\"hidden\" name=\"amount\" value=\"2.00\"><input type=\"hidden\" name=\"no_shipping\" value=\"0\"><input type=\"hidden\" name=\"no_note\" value=\"1\"><input type=\"hidden\" name=\"currency_code\" value=\"USD\"><input type=\"hidden\" name=\"tax\" value=\"0\"><input type=\"hidden\" name=\"lc\" value=\"US\"><input type=\"hidden\" name=\"bn\" value=\"PP-DonationsBF\"><input type=\"image\" src=\"https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal - The safer, easier way to pay online!\"><img alt=\"\" border=\"0\" src=\"https://www.paypal.com/en_US/i/scr/pixel.gif\" width=\"1\" height=\"1\"></form>";
	
}