image1 = new Image();
image1.src = "/images/convertover.png";
image2 = new Image();
image2.src = "/images/ajax-loader.gif";

function moveX00(x){
	$("#MySplitter").trigger("resize", [x]);
	}

function closereg(){
	moveX00(217);
	document.getElementById("contact").style.display = 'none';
	document.getElementById("disclaimer").style.display = 'none';
	document.getElementById("legend").style.display = 'none';
	document.getElementById("legend250").style.display = 'none';
	document.getElementById("closebutton").style.display = 'none'; 
}
	
function showreg(y){
	if(y == 'legend'){
	document.getElementById("leg50").src = '/images/topo50-legend.png';
	document.getElementById("leg250").src = '/images/topo250-legend.png';
	}
	closereg();
	moveX00(800);
	document.getElementById(y).style.display = 'block';
	document.getElementById("closebutton").style.display = 'block'; 
}

function closemsg(){
	document.getElementById("playmid").style.display = 'none';	
}

function swapbox(){
	document.getElementById("idbox").style.display = 'none';
	document.getElementById("idboxh").style.display = 'inline';
}
function swapboxh(){
	document.getElementById("idboxh").style.display = 'none';
	document.getElementById("idbox").style.display = 'inline';
}



function CheckValidCoords(theForm) {
  if ((theForm.C01.value == "")||(theForm.C11.value == ""))
  {
    alert("Please click on the map to enter coordinates values.");
    return (false);
  }
    if ((theForm.C11.value < -180)||(theForm.C11.value > 180))
  {
    alert("Invalid Longitude");
    return (false);
  }
    if ((theForm.C01.value < -90)||(theForm.C01.value > 90))
  {
    alert("Invalid Latitude");
    return (false);
  }
if(theForm.convertto.value == 'WGS84_H'){
	theForm.OS.value = 'WGS84';
	theForm.OC.value = 'H';
} else if (theForm.convertto.value == 'WGS84_M') {
	theForm.OS.value = 'WGS84';
	theForm.OC.value = 'M';
} else {
  theForm.OS.value = theForm.convertto.value;
}
window.open('http://www.linz.govt.nz/geodetic/conversion-coordinates/online-conversion-service/converter/index.aspx', 'convo','resizable=1')
}

function scfocus(){
	if(document.getElementById("scloc").value == 'Search Placenames'){
		document.getElementById("scloc").style.color = '#333';
		document.getElementById("scloc").value = '';
	}
}

function clearsearch(){
	document.getElementById("scres").innerHTML='';
	document.getElementById("rndclear").innerHTML='<p style="text-align:center;"><span class="hyper" onclick="showrandom();">Go somewhere random</span></p>';
	document.getElementById("scloc").value = 'Search Placenames';
	document.getElementById("scloc").style.color = '#999';
}

function showSearch(str, region){
	document.getElementById("scres").innerHTML="<img src='/images/ajax-loader.gif' width='16' height='16' alt='Loading' />";
if(str=="random"){
	str = document.searchplace;
	str.scloc.value="random";
	document.getElementById("scloc").style.color = '#333';
	}
	
if ((str.scloc.value=="")||(str.scloc.value=="Search Placenames")||(str.scloc.value.length < 3))
  {
  document.getElementById("scres").innerHTML="<p>Empty Search</p>";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("scres").innerHTML=xmlhttp.responseText;
	document.getElementById("rndclear").innerHTML='<p style="text-align:right;"><span class="hyper" onclick="clearsearch()">clear search</span></p>';
		if(str.scloc.value=="random"){
		eval(document.getElementById('runsc').innerHTML);
		}
    }
  }
se = str.scloc.value;
dda = new Date().getTime();
if(region==100){
	xmlhttp.open("GET","/getsearch.php?q="+se+"&z="+dda,true);
} else {
	xmlhttp.open("GET","/getsearch.php?q="+se+"&k="+region+"&z="+dda,true);
}
xmlhttp.send();
}

function filteregion(region){
	str = document.searchplace;
	showSearch(str, region);
}

function showrandom(){
	showSearch('random', 100);
}

function showip(){
	$.popup.show("iPhone nztopomaps.com example", "<img src='/images/iPhone-preview_Topo.jpg' width='537' height='400' alt='nztopomaps.com iPhone example' />");
}

function showyt(){
	$.popup.show("Introduction to nztopomaps.com", "<object width='622' height='473'><param name='movie' value='http//www.youtube.com/v/yPK6AYWD1Ao?hl=en&fs=1'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='http://www.youtube.com/v/yPK6AYWD1Ao?hl=en&fs=1' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='622' height='473'></embed></object>");
}

function select_all_link() {  
document.getElementById('LL03').select();  
}  

