
function page_select(formname)
{
	document.getElementById(formname).submit();
}

function category_click(category)
{
	var country = document.getElementById('country').value;
	window.location = 'directory.php?category=' + category + '&country=' + country;
}


function countrySelect(country)
{
	if (country > 0)
	{
		window.location = 'directory.php?country=' + country;
	}
}

function validateSearch()
{
	if (document.getElementById('query').value.length < 2)
	{
		alert("Please enter a keyword with at least 2 characters");
		return false;
	}

	return true;
}

function change_currency(code)
{
	var amount = 0;
	switch (code)
	{
		case 'GBP':
			amount = 99;
		break;
		case 'AUD':
			amount = 249;
		break;
		case 'EUR':
			amount = 149;
		break;
		case 'USD':
			amount = 199;
		break;
		case 'CAD':
			amount = 229;
		break;
		case 'NZD':
			amount = 279;
		break;	
		default:
			amount = 99;
		break;
	}

	document.getElementById('amount').value = amount;
}

function selectCategory()
{
	var category = document.getElementById('category');
	var parentID = category.options[category.selectedIndex].getAttribute('parent');
	
	var childName = category.options[category.selectedIndex].text;

	if (parentID > 0)
	{
		var theText = document.getElementById('category_group_' + parentID).label + childName;
	}
	else
	{
		var theText = childName;
	}

	document.getElementById('selectedCategory').innerHTML = theText;	
}

function selectCountry()
{
	var country = document.getElementById('country');
	var parentID = country.options[country.selectedIndex].getAttribute('parent');
	
	var childName = country.options[country.selectedIndex].text;

	if (parentID > 0)
	{
		var theText = document.getElementById('country_group_' + parentID).label + childName;
	}
	else
	{
		var theText = childName;
	}

	document.getElementById('selectedCountry').innerHTML = theText;	
}
