

//ZOOM TO STREET
function LoadStreetSearch(URL)
{

//window.opener.getElementById("processing").style.display="block"; //shows processing window
//window.opener.location=URL + "&planned=" + window.opener.document.getElementById("Planned3G").value;
}

//ZOOM TO SUBURB
function LoadSuburb()
{
var i=0;
var subid=0;
var arr;
var lat,lon,coord;

i=document.getElementById("cbxSuburb").options.selectedIndex;
coord=document.getElementById("lstSubCoord").options[i].text;
arr = coord.split('#@#')
lat = arr[0]
lon=arr[1]
if (i==0)
	{	}
else
	{
	       var obj=parent.frames["Map"];
		    //obj.location="mappage.aspx?x=" + lon + "&y=" + lat + "&zoom=5";
		    obj.document.getElementById("SSZoom").value=lon + "?" + lat + "?2";
		    obj.document.getElementById("processing").style.display="block";//shows processing window
	        obj.document.getElementById("EMVodamap_Command2").value=obj.document.getElementById("EMVodamap_Command").value;
	        obj.document.getElementById("EMVodamap_Command").value="TEMP";		       
	        var formToSend = obj.document.getElementById("Form1");	        
            formToSend.submit();
	        
		    
		    
		
	}
}

//ZOOM TO INTERSECTION
function LoadStreet()
{

var i=0;
var subid=0;
var arr;
var lat,lon,coord;

i=document.getElementById("cbxResults").options.selectedIndex;
coord=document.getElementById("lstIntCoord").options[i].text;
arr = coord.split('#@#')
lat = arr[0]
lon=arr[1]
if (i==0)
	{	}
else
	{
	var obj=parent.frames["Map"];
	 obj.document.getElementById("SSZoom").value=lon + "?" + lat + "?1";
     obj.document.getElementById("processing").style.display="block";//shows processing window
     obj.document.getElementById("EMVodamap_Command2").value=obj.document.getElementById("EMVodamap_Command").value;
     obj.document.getElementById("EMVodamap_Command").value="TEMP";
    
     var formToSend = obj.document.getElementById("Form1");	        
     formToSend.submit();	
		
		
	}
}


function ClearPoint() 
{
    var obj = parent.frames["Map"];
    obj.document.getElementById('btnClearPoint').value = "1";
    obj.document.getElementById('processing').style.display = 'block';
    obj.document.getElementById("EMVodamap_Command2").value = obj.document.getElementById("EMVodamap_Command").value;
    obj.document.getElementById("EMVodamap_Command").value = "TEMP";
    var formToSend = obj.document.getElementById("Form1");
    formToSend.submit();

}


//#########################################################################################
//#########################  AJAX FUNCTIONS ###############################################
//#########################################################################################
function ProvinceChanged(id){
document.body.style.cursor = 'wait';
document.getElementById("SearchProcess").style.display="block";
setTimeout("ProvinceChanged2(" + id +")",100);
}

function ProvinceChanged2(id){
HtmlControlUpdate('StreetSearch.GetTowns', 'TownSpan', id);
HtmlControlUpdate('StreetSearch.GetSuburbsFromProvince', 'SuburbSpan', id);
HtmlControlUpdate('StreetSearch.GetSuburbsCFromProvince', 'SuburbCSpan', id);

if (document.getElementById("cbxTown").style.display=="none")
	{
		document.getElementById("lblTown").style.display="none";
		document.getElementById("lblSuburb").style.display="none";
		document.getElementById("cbxTown").style.display="none";
		document.getElementById("txtStreet").style.display="none";
		document.getElementById("lblStreet").style.display="none";
		document.getElementById("cbxResults").style.display="none";
		document.getElementById("lblResults").style.display="none";
		document.getElementById("lblNoMatches").style.display="none";
		document.getElementById("cmdSearch").style.display = "none"
		document.getElementById("cmdClearPoint").style.display = "none"
		document.getElementById("cmdReset").style.display="none";
	}
else
	{
		document.getElementById("lblTown").style.display="block";
		document.getElementById("lblSuburb").style.display="block";
		document.getElementById("cbxTown").style.display="block";
		document.getElementById("cbxSuburb").style.display="block";
		document.getElementById("txtStreet").style.display="none";
		document.getElementById("lblStreet").style.display="none";
		document.getElementById("cbxResults").style.display="none";
		document.getElementById("lblResults").style.display="none";
		document.getElementById("lblNoMatches").style.display="none";
		document.getElementById("cmdSearch").style.display="none"
		document.getElementById("cmdReset").style.display = "none";
		document.getElementById("cmdClearPoint").style.display = "none"
	}
document.getElementById("SearchProcess").style.display="none";
document.body.style.cursor = 'default';
}
//############################################################################################
//############################################################################################

function TownChanged(id){
document.body.style.cursor = 'wait';
document.getElementById("SearchProcess").style.display="block";
setTimeout("TownChanged2(" + id +")",100);
}

function TownChanged2(id){

HtmlControlUpdate('StreetSearch.GetSuburbs', 'SuburbSpan', id);
HtmlControlUpdate('StreetSearch.GetSuburbsC', 'SuburbCSpan', id);

if (document.getElementById("cbxTown").value==0)
	{
		document.getElementById("txtStreet").style.display="none";
		document.getElementById("lblStreet").style.display="none";
		document.getElementById("cmdSearch").style.display="none"
		document.getElementById("cmdReset").style.display="none";
		document.getElementById("cbxResults").style.display="none";
		document.getElementById("lblResults").style.display="none";
		document.getElementById("lblNoMatches").style.display="none";
	}
else
	{
		document.getElementById("txtStreet").style.display="block";
		document.getElementById("lblStreet").style.display="block";
		document.getElementById("cmdSearch").style.display = "block"
		document.getElementById("cmdClearPoint").style.display = "block"
		document.getElementById("cmdReset").style.display="block";
		document.getElementById("lblNoMatches").style.display="none";
		document.getElementById("cbxResults").style.display="none";
		//document.getElementById("cbxResults").style.display="none";
	}

document.getElementById("SearchProcess").style.display="none";
document.body.style.cursor = 'default';
}

//############################################################################################
//############################################################################################

function SuburbChanged(){
if (document.getElementById("cbxSuburb").value==0)
	{
		if(document.getElementById("cbxTown").value==0)
			{
				document.getElementById("txtStreet").style.display="none";
				document.getElementById("lblStreet").style.display="none";
				document.getElementById("cmdSearch").style.display="none"
				document.getElementById("cmdReset").style.display = "none";
				document.getElementById("cmdClearPoint").style.display = "none"
				document.getElementById("cbxResults").style.display="none";
				document.getElementById("lblResults").style.display="none";
				document.getElementById("lblNoMatches").style.display="none";
			}
		else
			{
				document.getElementById("txtStreet").style.display="block";
				document.getElementById("lblStreet").style.display="block";
				document.getElementById("cmdSearch").style.display="block"
				document.getElementById("cmdReset").style.display = "block";
				document.getElementById("cmdClearPoint").style.display = "block"
			}
	}
else
	{
				document.getElementById("txtStreet").style.display="block";
				document.getElementById("lblStreet").style.display="block";
				document.getElementById("cmdSearch").style.display="block"
				document.getElementById("cmdReset").style.display = "block";
				document.getElementById("cmdClearPoint").style.display = "block"
	}
}

//############################################################################################
//############################################################################################

function SearchMatches(town,suburb,street){
document.getElementById("SearchProcess").style.display="block";
document.body.style.cursor = 'wait';
setTimeout("SearchMatches2()",100);

}

function SearchMatches2(){
		//VALIDATE FIRST !!!!!!!
		
		var town=document.getElementById("cbxTown").value;
		var suburb=document.getElementById("cbxSuburb").value;
		var street=document.getElementById("txtStreet").value;
		
		if(town==0){
			if(suburb==0){
			alert("Please select a Town First");
			document.getElementById("SearchProcess").style.display="none";
			return;
			}
		}
		if(street==""){
			alert("Please enter a street or partial street to search on\n\nExample: \nIf you were searching for 'church' street you could type 'chu'  \nto return all street matching the letters 'chu'");
			document.getElementById("SearchProcess").style.display="none";
			return;
		}
		document.getElementById("lblResults").style.display="block"
		HtmlControlUpdate('StreetSearch.MatchSearch', 'ResultsSpan', town,suburb,street);
		HtmlControlUpdate('StreetSearch.MatchSearchC', 'ResultsCSpan',  town,suburb,street);
		if(document.getElementById("cbxResults").style.display=="none")
			{document.getElementById("lblNoMatches").style.display="block"}
		else
			{document.getElementById("lblNoMatches").style.display="none"}
	
		document.getElementById("SearchProcess").style.display="none";
		document.body.style.cursor = 'default';
}
