//$Id: common.js,v 1.1 2005/02/25 21:36:53 www Exp $

//Catches the clicks and filters only the radio buttons clicks. 
//Then it takes their value attribute and is getting the url 
//for the "next" parameter from the next_url array that is generated at signup.php 
function processClicks(event)
{
    var e;
	var next;
	    
    e=navigator.appName=="Netscape"?event.target:window.event.srcElement;
	if (e.type == 'radio' && e.name=='next_url')
	{
		next = e.form.elements.next;
		next.value = next_url[e.value];
	}
	 

	if (e.getAttribute('value') == 'change_country') 
	{
		var form = document.forms[0];
		form.action = "eusignup.php";
		form.show_all_countries.value  = "1";
		form.submit();
	}
	
	//If it is the select country option - check if the country has it's 
	//own customized page and redirect there.
	if (e.type == 'select-one' && e.name=='country')
	{
		e.onchange = function (){
			if (custom_countries[e.value] == e.value){
				e.form.change_country.value = e.value;
				e.form.action = "eusignup.php";
				e.form.submit();
				//window.location.href = change_country_url+e.value;
			}
		}
	}

}

function initializeCountrySelect()
{
	//this functon provides default selection for the "country" select option in the form.
	
	change_country_pattern = /change_country=([^&]+)/i;
	if (window.location.search.match(change_country_pattern))
	{
		//select the country drop down box
		country_select = document.getElementById('country');
		if (country_select.type == 'select-one')
		{
			select_options = country_select.options;
			//loop through the elements of the select
			for (var i=0; i<country_select.options.length; i++) 
			{
				if (country_select.options[i].value==RegExp.$1) 
				{
					country_select.selectedIndex=i;
				}
			}
		}
	}
}

    
document.onclick = processClicks;
//window.onload = initializeCountrySelect;

