/*
	Used to dynamically change images on the site.
*/
function tronmedia_changeimage(image, url)
{
	image.src = url;
}


/*
	Creates an "are you sure?" dialogue.
*/
function tronmedia_areyousure_link(message, link)
{
	if (confirm(message))
	{
		document.location = link;
	}
	
	return false;
}


/*
	Updates the page location.
*/
function tronmedia_location(new_location)
{
	document.location = new_location;
	
	return false;
}


/*
	Supports client side checking of form details.
*/
function tronmedia_checkform(command, form_ref)
{
	var error_message = '';
	var areyousure_message = '';

	if (command == 'cardmonthly')
	{
		if 
		(
			form_ref.customer_address_1.value == '' || form_ref.customer_town.value == '' || form_ref.customer_county.value == '' || form_ref.customer_postcode.value == '' ||
			form_ref.card_name.value == "" || form_ref.card_number.value == "" || form_ref.card_cvv.value == ""
		)
		{
			error_message = 'Please fill in all required fields.';
		}
	}
	else if (command == 'cardsingle')
	{
		if 
		(
			form_ref.reference.value == '' || form_ref.initial_amount.value == '' || 
			form_ref.customer_address_1.value == '' || form_ref.customer_town.value == '' || form_ref.customer_county.value == '' || form_ref.customer_postcode.value == '' ||
			form_ref.card_name.value == "" || form_ref.card_number.value == "" || form_ref.card_cvv.value == ""
		)
		{
			error_message = 'Please fill in all required fields.';
		}
	}
	
	if (error_message != '')
	{
		alert(error_message);
		return false;
	}
	else
	{
		if (areyousure_message != '')
		{
			return confirm(areyousure_message);
		}
		else
		{
			return true;
		}
	}
}
