if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) //test for MSIE x.x;
{ 
	var ieversion=new Number(RegExp.$1)

	if (ieversion==6)
	{
		document.write("<link rel='stylesheet' type='text/css' href='css/skennyIE6.css'>")
	}
}

function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	} else {
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

function addUnLoadEvent(func)
{
	var oldonunload = window.onunload;
	if (typeof window.onunload != 'function')
	{
		window.onunload = func;
	} else {
		window.onunload = function()
		{
			oldonunload();
			func();
		}
	}
}

function frmWrite(method, name, onsubmit, action, id)
{
	document.write("<form method='"+method+"' name='"+name+"' id='"+id+"' onsubmit='"+onsubmit+";' action='"+action+".php'>");
}

function input_write(type, value, id)
{
	document.write("<input type='"+type+"' value='"+value+"' id='"+id+"'>");
}

function validate_required(field,alerttxt)
{
	with (field)
	{
		if (value==null || value=="")
  		{
			alert(alerttxt);
			return false
		}
		else
		{
			return true
		}
	}
}

function validate_search(thisform)
{
	with (thisform)
	{
		if (validate_required(minRent,"Please select a minimum amount of rent per calendar month")==false)
		{
			minRent.focus();
			return false
		}
		if (validate_required(maxRent,"Please select a maximum amount of rent per calendar month")==false)
		{
			maxRent.focus();
			return false
		}
		if (validate_required(beds,"Please select a minimum number of bedrooms")==false)
		{
			beds.focus();
			return false
		}
	}
}

function validate_email(field,alerttxt)
{
	with (field)
	{
		atPos=value.indexOf("@")
		dotPos=value.lastIndexOf(".")
		if (atPos<1 || dotPos-atPos<2) 
		{
			alert(alerttxt);
			return false
		}
		else
		{
			return true
		}
	}
}

function validate_enquiry(thisform)
{
	with (thisform)
	{
		if (Name2.value!="")
		{
			return false
		}
		if (validate_required(Name,"You are required to give your Name")==false)
		{
			Name.focus();
			return false
		}
		if (validate_email(E_mail,"It appears that your e-mail address is invalid. Please check your details and re-submit")==false)
		{
			E_mail.focus();
			return false
		}
		if (validate_required(Telephone,"You are required to provide a contact telephone number")==false)
		{
			Telephone.focus();
			return false
		}
	}
}

function validate_requestInfo(thisform)
{
	with (thisform)
	{
		if (Name2.value!="")
		{
			return false
		}

		var chk1 = document.getElementById('chkbox1').checked;
		var chk2 = document.getElementById('chkbox2').checked;

		if(chk1 == false && chk2 == false)
		{
			alert("Please select an option");
			chkbox1.focus();
			return false
		}
		if (validate_required(Name,"You are required to give your Name")==false)
		{
			Name.focus();
			return false
		}
		if (validate_email(E_mail,"It appears that your e-mail address is invalid. Please check your details and re-submit")==false)
		{
			E_mail.focus();
			return false
		}
		if (validate_required(Telephone,"You are required to provide a contact telephone number")==false)
		{
			Telephone.focus();
			return false
		}
	}
}


function validate_signUp(thisform)
{
	with (thisform)
	{
		if (Name2.value!="")
		{
			return false
		}

		if (validate_required(Name,"You are required to give your Name")==false)
		{
			Name.focus();
			return false
		}
		if (validate_email(E_mail,"It appears that your e-mail address is invalid. Please check your details and re-submit")==false)
		{
			E_mail.focus();
			return false
		}
		if (validate_required(Telephone,"You are required to provide a contact telephone number")==false)
		{
			Telephone.focus();
			return false
		}
	}
}

function extensionAllowed(fld, exts)
{
	ext=fld.value.substr(fld.value.lastIndexOf("."));
	for (x in exts)
	{
 		if (ext.toLowerCase()== exts[x])
		{
			return true;
		}
	}
	flag = true
	fld.select();
	fld.focus();
	return false;
}

function KeyUpNumeric(f)
{
	var keycode;
	if (window.event){
		keycode = window.event.keyCode;
	}
	else if (f){
		keycode = f.which;
	}

	if (keycode != 37 && keycode != 39){
		var re = /^[0-9]*$/;
		if (!re.test(f.value)) {
			alert("Only numbers allowed!");
			f.value = f.value.replace(/[^0-9]/g,"");
		}
	}
}

function KeyUpNoChars(f){

	var keycode;
	if (window.event){
		keycode = window.event.keyCode;
	}
	else if (f){
		keycode = f.which;
	}

	if (keycode != 37 && keycode != 39){
		var re = /['\''&'\"'&';']/g;

		if (re.test(f.value)){
			alert("Character not allowed.");
		}
  		f.value = f.value.replace(re,'');
	}
}

function printEAdd(em1, em2)
{
	if (em1 && em2)
	{
		if(!atxt)
		{
			var atxt = "E-Mail";
		}
		document.write('<a href=\"mailto:' + em1 + '@' + em2 +'\">' + em1 + '@' + em2 + '</a>');
	}
	else
	{
		document.write(' -- No email address supplied -- ');
	}
}


function swapMsg()
{
	var t=setTimeout("document.getElementById('reqInfoSubmit').style.display='none'; document.getElementById('reqInfoHide').style.display='block'",5000);
}

function loadStreetView(Lat, Long, divId)
{
	document.getElementById(divId).src='streetView.php?'+Lat+','+Long;
}

function loadGoogleMaps(Lat, Long, divId)
{
	document.getElementById(divId).src='googleMaps.php?'+Lat+','+Long;
}

function loadEPCdata(eneRatC, eneRatP, envRatC, envRatP, divId)
{
	document.getElementById(divId).src='epcData.php?eneRatC='+eneRatC+'&eneRatP='+eneRatP+'&envRatC='+envRatC+'&envRatP='+envRatP;
}

function requestInfo(propId, propRef, divId)
{
	document.getElementById(divId).src='requestInfo.php?propId='+propId+'&propRef='+propRef;
}

function loadFloorplan(propId, propRef, divId)
{
	document.getElementById(divId).src='loadFloorplan.php?PropId='+propId+'&PropRef='+propRef;
}