
var loadingHTML = '<div align="center" style="height:100%; width:100%; vertical-align:middle;"><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><img align="middle" alt="loading" src="images/loading.gif" /></div>';

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

<!--
	function change(id, newClass) {
		identity=document.getElementById(id);
		identity.className=newClass;
	}
	
	function openWin(file, size1, size2, scroll) {
		popupbox = window.open( file,
"new","toolbar=no,location=no,status=no,menubar=no,scrollbars="+scroll+",width="+size1+",height="+size2+",resizable=no");
	}
	
	function openReport(field,value) {
		if (value == "") {
			alert("Please make a selection before printing a report");
		} else {		
			reportbox = window.open("report.php?field="+field+"&value="+value,
"new","toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,width=760,height=520,resizable=no");
		}
	}
	
	function openfilter()
	{
		Element.toggle('searchfilter');
	}
	
	function CheckAll(fmobj, check) {
		var TotalBoxes = 0;
	  	var TotalOn = 0;
		  for (var i=0;i<fmobj.elements.length;i++) {
			var e = fmobj.elements[i];
			if ((e.type=='checkbox')) {
			  e.checked = check;
			}
		  }
	}
	
	function submitSearch(e, btnid)
	{
		var characterCode;
		var btn = document.getElementById(btnid);

		if(e && e.which){ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which; //character code is contained in NN4's which property
		}
		else{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
		}
		
		//alert(characterCode);
		
		if(characterCode == 13){ 
			btn.click();
			return false;
		}else
		{
			return false;
		}
	}
	
	
	function addlot2(e)
	{
		var characterCode;

		if(e && e.which){ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which; //character code is contained in NN4's which property
		}
		else{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
		}
		
		//alert(characterCode);
		
		if(characterCode == 13){ 
			addlot();
			return false;
		}else
		{
			return false;
		}
	}
	
	function clearLots()
	{
		var clear = '';
		Element.update('lotlist', clear);
		checkContact(document.getElementById('email').value);	
	}
	
	function addlot()
	{
		var name = document.getElementById('lotname');
		var list = document.getElementById('lotlist');
		current = list.innerHTML;
		if(current != '')
		{
			current += ','+name.value+'\n';
		}else
		{
			current += name.value+'\n';
		}
		
		Element.update('lotlist', current);
		name.value = '';
		checkContact(document.getElementById('email').value);		
	}
	
	function checkContact(value)
	{
		var list = document.getElementById('lotlist');
		var fname = document.getElementById('first_name').value;
		var lname = document.getElementById('last_name').value;
		new Ajax.Updater('messageBox', 'contactcheck.php?email='+value+'&lotlist='+list.innerHTML+'&first_name='+fname+'&last_name='+lname, {method: 'get'});		
		Element.show('messageBox');
	}
	
	function addlot2edit(e)
	{
		var characterCode;

		if(e && e.which){ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which; //character code is contained in NN4's which property
		}
		else{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
		}
		
		//alert(characterCode);
		
		if(characterCode == 13){ 
			addlotedit();
			return false;
		}else
		{
			return false;
		}
	}
	
	function clearLotsedit(value)
	{
		Element.update('lotlist', value);
		checkContact(document.getElementById('email').value);	
	}
	
	function addlotedit()
	{
		var name = document.getElementById('lotname');
		var list = document.getElementById('lotlist');
		current = list.innerHTML;
		if(current != '')
		{
			current += ','+name.value+'\n';
		}else
		{
			current += name.value+'\n';
		}
		
		Element.update('lotlist', current);
		name.value = '';
		checkContactedit(document.getElementById('email').value);		
	}
	
	function checkContactedit(value)
	{
		var list = document.getElementById('lotlist');
		var iam = document.getElementById('contactid').value;
		var fname = document.getElementById('first_name').value;
		var lname = document.getElementById('last_name').value;
		new Ajax.Updater('messageBox', 'contactcheckedit.php?email='+value+'&iam='+iam+'&lotlist='+list.innerHTML+'&first_name='+fname+'&last_name='+lname, {method: 'get'});		
		Element.show('messageBox');
	}

function ShowHideLayer(id, todo)
{
	if(todo == 'show')
	{
		Element.show(id);
	}else
	{
		Element.hide(id);
	}
}

function showpopup(id)
{	
	setOpacity("PopupOverlay");
	Element.show('PopupOverlay');
	Element.show(id);
}

function closePopup(name, inner)
{
	Element.hide('PopupOverlay');
	Element.hide(name);
	if(inner != "")
	{
		Element.update(inner,loadingHTML);	
	}
	//resetWindow('enquirePnl');
}

function setOpacity(name)
{
	if (navigator.appVersion.indexOf("MSIE")!=-1)
	{
		Element.setFilter(name,'alpha(opacity=80)');
	}
	else
	{
		Element.setOpacity(name,'0.8');
	}
}

function loadBox(value)
{
	page = document.getElementById('wrapper');
	
	width = f_clientWidth();
	scrollh = f_scrollTop();	
	height = page.offsetHeight;
	
	Element.setTop('enquirePnl',scrollh+150);
	Element.setLeft('enquirePnl',width/2 -250);	
	Element.setHeight('PopupOverlay',height+20);
		
	showpopup('enquirePnl');
	//resizeWindow('enquirePnl', 500, 485);
	new Ajax.Updater('enquirePnlInner', 'lib/map_entry.php?entry='+value, {method: 'get'});
}

function showdetails()
{
	Element.show('detailsDisplay');
	Element.show('contentToggle');
	Element.hide('contentDisplay');
	Element.hide('detailToggle');
	
}

function showcontent()
{
	Element.hide('detailsDisplay');
	Element.hide('contentToggle');
	Element.show('detailToggle');
	Element.show('contentDisplay');
	
}

function updateFilename(value)
{
	value = value.replace(/ /g,"-");
	value = value.replace(/'/g,"");
	value = value.replace(/"/g,"");
	value = value.replace(/&/g,"");
	value = value.replace(/\//g,"");
	value = value.toLowerCase();
	var newvalue = value+'.php';
	Element.setValue('filename',newvalue);
}

// Map ajax functions

function loadarea(value)
{
	Element.show('areaList');
	new Ajax.Updater('areaListInner', 'lib/arealist.php?area='+value, {method: 'get'});
	new Ajax.Updater('AreaTitleDiv', 'lib/areatitle.php?area='+value, {method: 'get'});	
}

function loadcenter(value)
{
	Element.show('areaDetail');
	new Ajax.Updater('areaDetailtInner', 'lib/areadetail.php?entry='+value, {method: 'get'});
}

function deleteEntry(value, area)
{	
	if(confirm('Are you sure you want to delete this?'))
	{
		new Ajax.Updater('areaMsg', 'lib/deleteArea.php?entry='+value, {method: 'get'});
		new Ajax.Updater('areaListInner', 'lib/arealist.php?area='+area, {method: 'get'});
		new Ajax.Updater('AreaTitleDiv', 'lib/areatitle.php?area='+area, {method: 'get'});
	}else{
		return false;
	}
}

function showRegion(region)
{
	switch(region)
	{
		case '1':
			Element.show('region1Inner');
			Element.hide('region2Inner');
			Element.hide('region3Inner');
			break;
		case '2':
			Element.hide('region1Inner');
			Element.show('region2Inner');
			Element.hide('region3Inner');
			break;
		case '3':
			Element.hide('region1Inner');
			Element.hide('region2Inner');
			Element.show('region3Inner');
			break;
	}
}


// JavaScript Document


