function checkwebsite (input) {
			http = input.substring(0,7);
			if (http != "http://") {
				return ("http://" + input);
			} else {
				return input;
			}
}

function checkform()
{
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	var result=true;
	
	if(document.getElementById("contact").name.value=="")
	{	
		result=false;
		document.getElementById("contact").name.style.backgroundColor='#FFDDDD';
	}
	else
	{
		document.getElementById("contact").name.style.backgroundColor='#FFFFFF';
	}
	
	if(document.getElementById("contact").address.value=="")
	{	
		result=false;
		document.getElementById("contact").address.style.backgroundColor='#FFDDDD';
	}
	else
	{
		document.getElementById("contact").address.style.backgroundColor='#FFFFFF';
	}
	
	if(document.getElementById("contact").phone.value=="")
	{
		document.getElementById("contact").phone.style.backgroundColor='#FFDDDD';
		result= false;
	}
	else
	{
		document.getElementById("contact").phone.style.backgroundColor='#FFFFFF';
	}

	if(!filter.test(document.getElementById("contact").email.value))
	{
		document.getElementById("contact").email.style.backgroundColor='#FFDDDD';
		result= false;
	}
	else
	{
		document.getElementById("contact").email.style.backgroundColor='#FFFFFF';
	}
	
	if(result==false)
	{
		alert("The highlighted fields are mandatory and have not been completed correctly.  Please check and try again.");
	}
	
	return result;
}

function validate()
{
return checkform() && alert('If you have attached a large file, it may take a couple of minutes to send so please be patient and wait for the transfer to be complete.');
}

function checkpost()
{
	document.getElementById("post").send.disabled = true;
	document.getElementById("post").site.value = checkwebsite(document.getElementById("post").site.value);
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	var result=true;
	
	if(document.getElementById("post").name.value=="")
	{	
		result=false;
		document.getElementById("post").name.style.backgroundColor='#FFDDDD';
	}
	else
	{
		document.getElementById("post").name.style.backgroundColor='#FFFFFF';
	}
	
	if(document.getElementById("post").town.value=="")
	{	
		result=false;
		document.getElementById("post").town.style.backgroundColor='#FFDDDD';
	}
	else
	{
		document.getElementById("post").town.style.backgroundColor='#FFFFFF';
	}

	if(!filter.test(document.getElementById("post").email.value))
	{
		document.getElementById("post").email.style.backgroundColor='#FFDDDD';
		result= false;
	}
	else
	{
		document.getElementById("post").email.style.backgroundColor='#FFFFFF';
	}
	
	if(result==false)
	{
		alert("The highlighted fields are mandatory and have not been completed correctly.  Please check and try again.");
		document.getElementById("post").send.disabled = false;
	}
	
	return result;
}

var height = "";
var width = "";

function EnlargeImage(imgSrc)
{
	var newImg = new Image();
	newImg.src = imgSrc;
	
	if(newImg.width>newImg.height)
	{
		if(newImg.width>800)
		{
			var scale = 800/newImg.width;
			width = "800";
			height = newImg.height*scale;
		}
		else
		{
			width = newImg.width;
			height = newImg.height;
		}
	}
	else
	{
		if(newImg.height>600)
		{
			var scale = 600/newImg.height;
			height = "600";
			width = newImg.width*scale;
		}
		else
		{
			width = newImg.width;
			height = newImg.height;
		}
	}
	
	newWindow = window.open("", "Enlarged", "width="+width+", height="+(height+30)+", scrollbars=no, status=yes, toolbar=no, location=no, resizable=no");
	newWindow.document.write("<html><head><title>Enlarged Image</title></head><body onblur='this.close();' style='margin:0px'><img src='"+imgSrc+"' alt='Enlarged Image' title='Enlarged Image' width='"+width+"' height='"+height+"' />");
	newWindow.document.write("<p style='text-align:center; padding-top:5px; margin:0px'><a href='javascript:this.close()'>Close Window</a></p></body></html>");
	newWindow.document.close();
}