function change(formRef, id, newClass) {
	var el = formRef && formRef.elements[id];
	el.className = newClass;
}

function checkField(formRef, id) {
	var el = formRef && formRef.elements[id];
	return !el || Boolean(el.value);
}

function validateForm(formRef) {
		var alertMsg = "The following REQUIRED fields\nhave been left empty:\n";

		if (!checkField(formRef,"postcode"))
			{
			alertMsg += "\nPlease enter your postcode details";
			change(formRef,'postcode','error') + formRef.postcode.focus();
			}
		else { change(formRef,'postcode','normal'); }
		
		if (document.form1.ImageSrc.value == "")
		{
		return false;
		}


		if (alertMsg != "The following REQUIRED fields\nhave been left empty:\n")
			{
			alert(alertMsg);
			return false;
			}
		else {
			return true;
			}
}

function submitForm()
{
if (document.form1.onsubmit())
{document.form1.submit();}
}

function SetField(Source)
{
document.form1.ImageSrc.value=Source;
if (document.form1.onsubmit())
{document.form1.submit();}
}

function newwin(url, winname, parameters)
{
window.open(url, winname, parameters);
}

function GoBrokerbank()
{
		var alertMsg = "The following REQUIRED fields\nhave been left empty:\n";


		if (document.form1.postcode.value !="")
			{
			SetField('Brokerbank')
			window.open('http://www.brokerbank.co.uk/consumer.php', 'Brokerbank','top=100,left=100, toolbar=no,titlebar=no,location=no,directories=no,status=no,scrollbars=yes,width=800,height=700%,resizable=yes');
			}

		else
			{
			alertMsg += "\nYou must enter your postcode details";
			}


		if (alertMsg != "The following REQUIRED fields\nhave been left empty:\n")
			{
			alert(alertMsg);
			}
}

function ShowMessage(id)
{
	if(id=="Halifax")
	{
	alert('This Button will forward the customer to the Halifax Consumer MicroSite. \n \n Providing the customer has linked to this site using the link provided to you by Broker Support \n \n your specific id will be recorded against the application so that the commission can be paid through to yourselves. ')
	}
	else
	{
	alert('This functionality is currently under construction.')
	}
}
