
function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
      
     
      
   return IsNumber;
   
   }


   
function updateAmount()
{
	var radioAmount = document.getElementById("radioAmount");
	var textAmount = document.getElementById("textAmount");
	var a3 = document.getElementById("a3");
	
	if (textAmount.value.length==0)
	{
		
			if (isRadioChecked()==false)
			{
				alert("Please choose an amount you wish to donate.");
				return false;
			}
			else
			{
				
				
				
			    for (var i = 0; i < document.main.radioAmount.length; i++) {
			         
				    if (document.main.radioAmount[i].checked == true)
				    {
					    a3.value = document.main.radioAmount[i].value;
				    }
			    }
			    
				
			}
			
	}
	else
	{
		if (IsNumeric(textAmount.value))
		{
			var intValue = parseInt(textAmount.value);
			
			if (intValue<1)
			{
				alert("You must donate at least €1.00");
				return false;
			}
			else
			{
				a3.value = textAmount.value;
			}
		}
		else
		{
			alert("Please enter a numeric value for the amount you with to donate.");
			return false;
		}
	}
	
	document.main.target = "paypal";
	document.main.cmd.value = "_xclick-subscriptions";
	document.main.action = "https://www.paypal.com/cgi-bin/webscr";
	document.main.submit();
	
}

function isRadioChecked()
{
	var or = document.getElementById("radioAmount");
	
	
      for (var i = 0; i < document.main.radioAmount.length; i++) {
         if (document.main.radioAmount[i].checked == true)
         	return true;
     }
     return false;
     
}
function uncheckRadio() {
	  

	var or = document.getElementById("radioAmount");
	
	
      for (var i = 0; i < document.main.radioAmount.length; i++) {
         document.main.radioAmount[i].checked = false;
     }
}



function blankAmount()
{
	var textAmount = document.getElementById("textAmount");
	textAmount.value="";
		
}
function activateRadio(obj)
{
	var radioAmount = document.getElementById("radioAmount");
	//alert(obj.value);
	
	//radioAmount.value = obj.value;
	blankAmount();
	
}

function donate()
{
	document.main.action = "https://www.paypal.com/cgi-bin/webscr";
	document.main.submit();
	
}

function addNameToMailingList()
{
	var name = document.getElementById("name");
	
	if (name.value.length==0)
	{
		alert("Please enter your name.");
		name.focus();
		return false;
	}
	
	var email = document.getElementById("email");
	
	if (email.value.length==0)
	{
		alert("Please enter your email address.");
		email.focus();
		return false;
	}
	
	if (!echeck(email.value))
	{
		alert("Please enter a valid email address.");
		email.focus();
		return false;
	}
	
	document.main.action="addNameToMailingList.php";
	document.main.submit();
	
}

function checkKey(id,type)
{
	if (id==13)
	{
		doSearch(type);
		
	}
	
}

function MM_openBrWindow(theURL,winName,features) {
			window.open(theURL,winName,features);
			return false;
		
		}

function showSiteMap()
{
	
	MM_openBrWindow('siteMap.php','','resizable=no,scrollbars=yes,width=750,height=800');
}



function printablePage()
{
	
	
	var address = location.href;
	
	
	var searchTerms = document.main.searchTerms;
	
	if (searchTerms==null)
		searchTerms = "";
	else
		searchTerms = searchTerms.value;
	
	
	if (address.indexOf("?")==-1)
		address = address+"?PRINT=1&amp;search="+searchTerms;
	else
		address = address+"&amp;PRINT=1&amp;search="+searchTerms;
		
	window.open(address);
	
}
function doSearch(mainSearchFlag)
{
	if (mainSearchFlag==1)
		document.main.searchBox.value = document.main.mainSearch.value;
	
	document.main.action="showPage.php";
	document.main.submit();
}



function checkChange()
{
	//Placeholder for equivalent maintain function - needed to make menu.xsl work.
	return 1;
}