/*==============================================================================

This function checks the value of the parameter for a email address. Also
checks for missing information in general forms.
            
------------------------------------------------------------------------------*/
function offerFocus() {
	var field = document.offerform.email;
	if (field.value == 'Your Email Address') { field.value = ''; }
	else if (field.value == '') { field.value = 'Your Email Address'; }	
	return;
}
function nameFocus() {
	var field = document.offerform.name;
	if (field.value == 'Your Name') { field.value = ''; }
	else if (field.value == '') { field.value = 'Your Name'; }	
	return;
}
function telFocus() {
	var field = document.offerform.tel;
	if (field.value == 'Your Contact Number') { field.value = ''; }
	else if (field.value == '') { field.value = 'Your Contact Number'; }	
	return;
}
function checkForm() {
	var missinginfo = "";
	var errorcolor = 'Pink';
    var okcolor = 'White';
	var field1 = document.offerform.name; 
	var field2 = document.offerform.tel; 
    var field3 = document.offerform.email;
    var noName = field1.value == "";
    var badName = field1.value == "Your Name";
    var goodTel = field2.value.match(/^[(]?[0]{1}[0-9]{2,4}[) -]{0,4}.[0-9]{3}[- ]?[0-9]{3}[ ]?$/);
	var goodEmail = field3.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

	if (badName || noName) {
		missinginfo += "\n- Name";
		field1.style.background = errorcolor;
	}
	else {
		field1.style.background = okcolor;
	}
	if (!goodTel) {
		missinginfo += "\n- Valid Contact Number, e.g. 01522 510310";
		field2.style.background = errorcolor;
	}
	else {
		field2.style.background = okcolor;
	}
	if (!goodEmail) {
		missinginfo += "\n- Valid Email Address, e.g. name@domain.com";
		field3.style.background = errorcolor;
	}
	else {
		field3.style.background = okcolor;
	}
	if (missinginfo != "") {
	   missinginfo ="===============================\n" +
	   "The following details are required:\n" +
	   missinginfo + "\n===============================" +
	   "\nPlease re-enter and submit again!";
	   alert(missinginfo);
	   return false;
	}
	else
	{
	   document.offerform.submit();
	}
}

var domain="mailto:"
function contact_me()
	{
		var end="info"
		var relend="@eyerent2own.co.uk"
		window.location=domain+end+relend;
	}


function show(x)
	{

	y = document.getElementById(x)
	if ( y.style.zIndex != '17' ){
		y.style.display = 'inline'; y.style.zIndex = '17'; }
	else {
		y.style.display = 'none'; y.style.zIndex = '1'; }

	}


