﻿//**********************************************************************
//main.js includes all functions of page "main.aspx" mainly functions here 
//control the map
//**********************************************************************
var map;
var marqueeTip="";


function Load()
{ 

	
	//document.getElementById("mapframe").src="Map.aspx?extent="+ document.frmMain.extent.value;	


}
//**********************************************************************
//function sets the map according to browser type
function SetMap()
{
	var checked=CheckMapForm();
	if (checked)
	{
		if (isIE)//case of IE
		{
		
		    document.getElementById("imgmapIE").style.display='block';
			map= document.getElementById("imgDiv");	
		}
		else//case netscae,mozilla, firefox, opera..
		{
		    document.getElementById("imgmapFF").style.display='block';
			map= document.getElementById("imgmapFF");	
		}
		
		
	}
}
//**********************************************************************

//function SetCursor()
//{	
//	if (document.getElementById("hid_action").value =='zoomin')
//	{	
//		map.style.cursor= 'url("http://www.elections.gov.lb/KenticoCMS/CMSTemplates/elections09/LPHU/Images/Cursor/Pan.cur")';
//	}
//	if (document.getElementById("hid_action").value =='zoomout')
//	{	
//		map.style.cursor= "url(../Images/Cursor/zoom_out.cur)";
//	}
//	if (document.getElementById("hid_action").value =='pan')
//	{	
//		map.style.cursor= "url(../Images/Cursor/Pan.cur)";
//	}
//	if (document.getElementById("hid_action").value =='measure')
//	{	
//		map.style.cursor= "crosshair";
//	}
//	if (document.getElementById("hid_action").value=='move')
//	{
//		map.style.cursor= "url(../Images/Cursor/Pan.cur)";
//	}
//	if (document.getElementById("hid_action").value=='identify')
//	{
//		//document.getElementById("hid_subaction").value = "" ;
//		map.style.cursor="help";
//	}
//	if (document.getElementById("hid_action").value=='clickmap')
//	{
//		//document.getElementById("hid_subaction").value = "" ;
//		map.style.cursor="arrow";
//	}	
//}

//sets the action chosen by the user
 function SetAction(action,value)
{			
	//check if map form is loaded or not
	var checked;
	checked= CheckMapForm();
	if (checked == false) return;

	//define the map object
	SetMap();
	
	
	
	if (action=='zoomin')
	{        
	    marqueeTip="حرك الفارة فوق الخريطة لتحديد مكان التكبير ثم اترك الفأرة";
	    document.getElementById("hid_action").value=action;	
		HideDiv();
		ClearZoomLevels();		
	}
	if (action=='zoomout')
	{
        marqueeTip="حرك الفارة فوق الخريطة لتحديد مكان التصغير ثم اترك الفأرة";
		document.getElementById("hid_action").value=action;
		HideDiv();
		ClearZoomLevels();
	}
	if (action=='previousextent')
	{
		document.getElementById("hid_action").value=action;
		HideDiv();
		ClearZoomLevels();
		document.forms["frmMap"].submit();
	}
	if (action=='pan')
	{
		document.frmMap.hid_panDirection.value= value;
		document.getElementById("hid_action").value=action;
		document.forms["frmMap"].submit();
	}
	if (action=='move')
	{
                marqueeTip="انقر على الخريطة ثم حرك الفأرة بالاتجاه الذي تريد ومن ثم قم بترك الفأرة";
		document.getElementById("hid_action").value=action;
		HideDiv();
	}


	if (action=='identify')
	{
                marqueeTip="انقر علي اي موقع لتحصل على معلومات اكثر عن هذا الموقع";
		document.getElementById("hid_action").value=action;
		HideDiv();
	}
	
	if (action=='clickmap')
	{
		document.getElementById("hid_action").value=action;
		HideDiv();
	}
	
	if (action=='reset')
	{		
	
	
		document.getElementById("hid_action").value=action;
		document.getElementById("hid_ilevel").value="";	
		HideDiv();
		ClearZoomLevels();
		document.forms["frmMap"].submit();
		
	}
	if (action=='clearmap')
	{		
	
		//<!-- Inmaa Demo ------------------------------>
		//document.frmMap.hid_subaction.value="";
		document.getElementById("hid_action").value=action;			
		//document.frmMap.hid_showsymbol.value="";
		//document.frmMap.hid_showroute.value="";
		//<!--End ------------------------------------------>
		
		document.forms["frmMap"].submit();
	
	}
	
	if (action=='upzoomlevel')
	{
		if (parseInt(document.getElementById("hid_ilevel").value.length) == 0)
			document.getElementById("hid_ilevel").value=1;


		if (document.getElementById("hid_ilevel").value < 11)
		{	
			document.getElementById("hid_ilevel").value = parseInt(document.getElementById("hid_ilevel").value) + 1;		
		}
		else
			document.getElementById("hid_ilevel").value = 11;


		document.getElementById("hid_action").value="zoomlevel";
		HideDiv();
		SetZoomLevels(document.getElementById("hid_ilevel").value);
		document.forms["frmMap"].submit();
	}
	
	if (action=='downzoomlevel')
	{
		if (parseInt(document.getElementById("hid_ilevel").value.length) == 0)
			document.getElementById("hid_ilevel").value=1;

		if (document.getElementById("hid_ilevel").value >= 2)
		{	
			document.getElementById("hid_ilevel").value = parseInt(document.getElementById("hid_ilevel").value) - 1;		
		}
		else
			document.getElementById("hid_ilevel").value = 1;			
			
		
		document.getElementById("hid_action").value="zoomlevel";
		HideDiv();
		SetZoomLevels(document.getElementById("hid_ilevel").value);
		document.forms["frmMap"].submit();
	}
	
	if (action=='zoomlevel')
	{	
		document.getElementById("hid_action").value=action;
		document.getElementById("hid_ilevel").value=value;
		//document.getElementById("imgframeDiv")style.cursor="url(pan.cur)";

		HideDiv();
		//document.getElementById("tooltipdiv").style.visibility= "hidden";
		SetZoomLevels(value);
		document.forms["frmMap"].submit();
	}
	
	if (action == 'addannotation')
	{
		document.getElementById("hid_action").value="addannotation";
	}
	
	if (action=='print')
	{
		window.open("../MapTools/print.aspx?mapurl=" + document.getElementById("hid_mapurl").value ,"Print",'width=600; height=500; left=20; top=20;','True');
	}
	if (action=='printguide')
	{
		window.open("printguide.aspx?minx=" + document.getElementById("hid_minx").value + "&miny=" + document.getElementById("hid_miny").value + "&maxx=" + document.getElementById("hid_maxx").value + "&maxy=" + document.getElementById("hid_maxy").value  ,"PrintGuide",'width=660; height=660; left=20; top=20;','True');
	}
	if (action=='printlocation')
	{
		document.getElementById("hid_action").value=action;		
		HideDiv();
	}
	if (action=='email')
	{
	
	window.open("../MapTools/SendEmail.aspx?mapurl=" + document.getElementById("hid_mapurl").value + "&mapfile=" + document.getElementById("hid_mapfile").value,"SendMail","left=0, top=0, scrollbars=0, resizable=yes, width=590, height=700");
		//window.open("mailto:?subject=mapo medco itinerary map&body="+ document.frmMap.hid_Member.value + " has sent you a link. Click on the link  to visit our website. http://209.120.245.180/mapomedco");
	}
	
   if (action=='customizemap')
	{
	
	//document.location.href = '../MapTools/CustomizeMap.aspx'
	    newWindow=window.open("../MapTools/CustomizeMap.aspx","CustomizeMap","left=0, top=0, scrollbars=1, resizable=yes, width=300, height=580");
		newWindow.focus();
	}
	
	if (action=='locate')
	{
		window.open("locator.aspx?tabindex=" + value,"Locator",'width=360; height=300; left=50; top=50;','True');
	}
	if (action=='openarabic')
	{
		//window.open("arabic.html","Arabic",'width=300; height=100; left=50; top=50;','True');
		window.location="http://localhost/ld/locatordubai/main.aspx?pass=" + document.frmMain.hid_pass.value;	
	}
	
	if (action=='ViewControl')
	{
	
	   if (document.getElementById("PnlMapViewControl").style.display=='none')
	     {
	        document.getElementById("PnlMapViewControl").style.display='block'
	        document.getElementById("PnlShowControl").style.display='none'
	     }
	     else
	     {
	       document.getElementById("PnlMapViewControl").style.display='none'
	       document.getElementById("PnlShowControl").style.display='block'
	     }
		
	}
										 			
    //alert(document.getElementById('lblMarquee').innerText);

	SetCursor();
	//ClearImages();
     //document.getElementById('Marqueecnl').innerHTML=marqueeTip;	
	document.getElementById('hid_Marquee').value=marqueeTip;
	
}
//**********************************************************************

//Shows or Hides Municipality LandBase Layer
function SetLayerVisibility() {

	//check if map form is loaded or not
	var checked;
	checked= CheckMapForm();
	if (checked == false) return;

document.getElementById("hid_action").value="";
if (document.frmMap.hid_layervisibility.value== "false")
{

	document.frmMap.hid_layervisibility.value= "true";
}
else
{
	document.frmMap.hid_layervisibility.value= "false";
}

document.forms["frmMap"].submit();


}
//**********************************************************************

//Shows help for user on tool selected
function ShowToolTip(action)
{
	var inhtml;
	
	if (action=='zoomin')
	{
		inhtml =" <table background='images/rbg.jpg' width=100%><tr><td><table width=100%><tr><td align=left><b> Zoom In </td><td align=right><img src='images/zoom_off.gif'></td></tr></table></td></tr>"
		inhtml = inhtml + "<tr height='2'><td bgcolor='#006dad' width='100%'></td></tr>"
		inhtml = inhtml + "<tr><td >Click on the Map <br>and drag the cursor</td></tr>"
		//inhtml = inhtml + "<tr><td align=center><img src='images/zinhint.png'></td></tr>"
		inhtml = inhtml + "<tr height='2'><td bgcolor='#006dad' width='100%'></td></tr>"
		inhtml = inhtml + "</table>";
	}
	if (action=='zoomout')
	{
		inhtml =" <table background='images/rbg.jpg' width=100%><tr><td><table width=100%><tr><td align=left><b> Zoom Out </td><td align=right><img src='images/zoomout_off.gif'></td></tr></table></td></tr>"
		inhtml = inhtml + "<tr height='2'><td bgcolor='#006dad' width='100%'></td></tr>"
		inhtml = inhtml + "<tr><td >Click on the Map <br>and drag the cursor</td></tr>"
		//inhtml = inhtml + "<tr><td align=center><img src='images/zouthint.png'></td></tr>"
		inhtml = inhtml + "<tr height='2'><td bgcolor='#006dad' width='100%'></td></tr>"
		inhtml = inhtml + "</table>";
	}
	if (action=='pan')
	{
	}
	if (action=='measure')
	{
				inhtml =" <table background='images/rbg.jpg' width=100%><tr><td><table width=100%><tr><td align=left><b> Measure </td><td align=right><img src='images/measure.gif'></td></tr></table></td></tr>"
				inhtml = inhtml + "<tr height='2'><td bgcolor='#006dad' width='100%'></td></tr>"
				inhtml = inhtml + "<tr><td >Click on the Map, move the cursor then click agian.<br> To finish measuring double click the same point on the map</td></tr>"
				//inhtml = inhtml + "<tr><td align=center><img src='images/mhint.png'></td></tr>"
				inhtml = inhtml + "<tr height='2'><td bgcolor='#006dad' width='100%'></td></tr>"
				inhtml = inhtml + "</table>";
	}
	if (action=='buffer')
	{
				inhtml =" <table background='images/rbg.jpg' width=100%><tr><td><table width=100%><tr><td align=left><b> Buffer </td><td align=right><img src='images/buffer.gif'></td></tr></table></td></tr>"
				inhtml = inhtml + "<tr height='2'><td bgcolor='#006dad' width='100%'></td></tr>"
				inhtml = inhtml + "<tr><td >Click on the Map</td></tr>"
				//inhtml = inhtml + "<tr><td align=center><img src='images/bhint.png'></td></tr>"
				inhtml = inhtml + "<tr height='2'><td bgcolor='#006dad' width='100%'></td></tr>"
				inhtml = inhtml + "</table>";
	}
	if (action=='identify')
	{
				inhtml =" <table background='images/rbg.jpg' width=100%><tr><td><table width=100%><tr><td align=left><b> Identify </td><td align=right><img src='images/identify_off.gif'></td></tr></table></td></tr>"
				inhtml = inhtml + "<tr height='2'><td bgcolor='#006dad' width='100%'></td></tr>"
				inhtml = inhtml + "<tr><td >Click on the Map</td></tr>"
				//inhtml = inhtml + "<tr><td align=center><img src='images/identifyhint.png'></td></tr>"
				inhtml = inhtml + "<tr height='2'><td bgcolor='#006dad' width='100%'></td></tr>"
				inhtml = inhtml + "</table>";
	}
	if (action=='move')
	{
		inhtml =" <table background='images/rbg.jpg' width=100%><tr><td><table width=100%><tr><td align=left><b> Move Map </td><td align=right><img src='images/pan.gif'></td></tr></table></td></tr>"
		inhtml = inhtml + "<tr height='2'><td bgcolor='#006dad' width='100%'></td></tr>"
		inhtml = inhtml + "<tr><td >Click on the Map <br>and move the cursor in any direction</td></tr>"
		inhtml = inhtml + "<tr height='2'><td bgcolor='#006dad' width='100%'></td></tr>"
		inhtml = inhtml + "</table>";
	}
	showLayer("tooltipdiv");
	//document.getElementById("tooltipdiv").style.visibility="Visible";
	document.getElementById("tooltipdiv").innerHTML=inhtml;
}
//**********************************************************************


//**********************************************************************

//ClearImages() resets all images in map toolbar to their original form
function ClearImages()
{
	switch (document.getElementById("hid_action").value)
	{
		case "zoomin":			
			//if (document.getElementById("imgzoomin")) document.getElementById("imgzoomin").src="images/zoomin_o.jpg";
			if (document.getElementById("imgzoomout")) document.getElementById("imgzoomout").src="images/zoomout_n.jpg";
			if (document.getElementById("imgpan")) document.getElementById("imgpan").src="images/pan_n.jpg";
			if (document.getElementById("imgbuffer")) document.getElementById("imgbuffer").src="images/buffer_n.jpg";
			if (document.getElementById("imgidentify")) document.getElementById("imgidentify").src="images/identify_n.jpg";
			if (document.getElementById("imgprintr"))document.getElementById("imgprint").src="images/print_n.jpg";
			if (document.getElementById("imgmeasure")) document.getElementById("imgmeasure").src="images/measure_n.jpg";
			if (document.getElementById("imgprev")) document.getElementById("imgprev").src="images/prev_n.jpg";
			if (document.getElementById("imgannotation")) document.getElementById("imgannotation").src="images/addtext_n.jpg";
			if (document.getElementById("imgprintlocation")) document.getElementById("imgprintlocation").src="images/printlocation_n.jpg";
			break;
			
		case  "zoomout": 
			if (document.getElementById("imgzoomin")) document.getElementById("imgzoomin").src="images/zoomin_n.jpg";
			//if (document.getElementById("imgzoomout")) document.getElementById("imgzoomout").src="images/zoomout_o.jpg";
			if (document.getElementById("imgpan")) document.getElementById("imgpan").src="images/pan_n.jpg";
			if (document.getElementById("imgbuffer")) document.getElementById("imgbuffer").src="images/buffer_n.jpg";
			if (document.getElementById("imgidentify")) document.getElementById("imgidentify").src="images/identify_n.jpg";
			if (document.getElementById("imgprintr"))document.getElementById("imgprint").src="images/print_n.jpg";
			if (document.getElementById("imgmeasure")) document.getElementById("imgmeasure").src="images/measure_n.jpg";
			if (document.getElementById("imgprev")) document.getElementById("imgprev").src="images/prev_n.jpg";
			if (document.getElementById("imgannotation")) document.getElementById("imgannotation").src="images/addtext_n.jpg";
			if (document.getElementById("imgprintlocation")) document.getElementById("imgprintlocation").src="images/printlocation_n.jpg";
			break;
			
		case  "move": 
			if (document.getElementById("imgzoomin")) document.getElementById("imgzoomin").src="images/zoomin_n.jpg";
			if (document.getElementById("imgzoomout")) document.getElementById("imgzoomout").src="images/zoomout_n.jpg";
			if (document.getElementById("imgpan")) document.getElementById("imgpan").src="images/pan_o.jpg";
			if (document.getElementById("imgbuffer")) document.getElementById("imgbuffer").src="images/buffer_n.jpg";
			if (document.getElementById("imgidentify")) document.getElementById("imgidentify").src="images/identify_n.jpg";
			if (document.getElementById("imgprintr"))document.getElementById("imgprint").src="images/print_n.jpg";
			if (document.getElementById("imgmeasure")) document.getElementById("imgmeasure").src="images/measure_n.jpg";
			if (document.getElementById("imgprev")) document.getElementById("imgprev").src="images/prev_n.jpg";
			if (document.getElementById("imgannotation")) document.getElementById("imgannotation").src="images/addtext_n.jpg";
			if (document.getElementById("imgprintlocation")) document.getElementById("imgprintlocation").src="images/printlocation_n.jpg";
			break;
			
		case  "openbuffer": 
			if (document.getElementById("imgzoomin")) document.getElementById("imgzoomin").src="images/zoomin_n.jpg";
			if (document.getElementById("imgzoomout")) document.getElementById("imgzoomout").src="images/zoomout_n.jpg";
			if (document.getElementById("imgpan")) document.getElementById("imgpan").src="images/pan_n.jpg";
			if (document.getElementById("imgbuffer")) document.getElementById("imgbuffer").src="images/buffer_o.jpg";
			if (document.getElementById("imgidentify")) document.getElementById("imgidentify").src="images/identify_n.jpg";
			if (document.getElementById("imgprintr"))document.getElementById("imgprint").src="images/print_n.jpg";
			if (document.getElementById("imgmeasure")) document.getElementById("imgmeasure").src="images/measure_n.jpg";
			if (document.getElementById("imgprev")) document.getElementById("imgprev").src="images/prev_n.jpg";
			if (document.getElementById("imgannotation")) document.getElementById("imgannotation").src="images/addtext_n.jpg";
			if (document.getElementById("imgprintlocation")) document.getElementById("imgprintlocation").src="images/printlocation_n.jpg";
			break;
			
		case  "identify": 
			if (document.getElementById("imgzoomin")) document.getElementById("imgzoomin").src="images/zoomin_n.jpg";
			if (document.getElementById("imgzoomout")) document.getElementById("imgzoomout").src="images/zoomout_n.jpg";
			if (document.getElementById("imgpan")) document.getElementById("imgpan").src="images/pan_n.jpg";
			if (document.getElementById("imgbuffer")) document.getElementById("imgbuffer").src="images/buffer_n.jpg";
			if (document.getElementById("imgidentify")) document.getElementById("imgidentify").src="images/identify_o.jpg";
			if (document.getElementById("imgprintr"))document.getElementById("imgprint").src="images/print_n.jpg";
			if (document.getElementById("imgmeasure")) document.getElementById("imgmeasure").src="images/measure_n.jpg";
			if (document.getElementById("imgprev")) document.getElementById("imgprev").src="images/prev_n.jpg";
			if (document.getElementById("imgannotation")) document.getElementById("imgannotation").src="images/addtext_n.jpg";
			if (document.getElementById("imgprintlocation")) document.getElementById("imgprintlocation").src="images/printlocation_n.jpg";
			break;		

		case "measure":
			if (document.getElementById("imgzoomin")) document.getElementById("imgzoomin").src="images/zoomin_n.jpg";
			if (document.getElementById("imgzoomout")) document.getElementById("imgzoomout").src="images/zoomout_n.jpg";
			if (document.getElementById("imgpan")) document.getElementById("imgpan").src="images/pan_n.jpg";
			if (document.getElementById("imgbuffer")) document.getElementById("imgbuffer").src="images/buffer_n.jpg";
			if (document.getElementById("imgidentify")) document.getElementById("imgidentify").src="images/identify_n.jpg";
			if (document.getElementById("imgprintr"))document.getElementById("imgprint").src="images/print_n.jpg";
			if (document.getElementById("imgmeasure")) document.getElementById("imgmeasure").src="images/measure_o.jpg";
			if (document.getElementById("imgprev")) document.getElementById("imgprev").src="images/prev_n.jpg";
			if (document.getElementById("imgannotation")) document.getElementById("imgannotation").src="images/addtext_n.jpg";
			if (document.getElementById("imgprintlocation")) document.getElementById("imgprintlocation").src="images/printlocation_n.jpg";
			break;	
								
		case "locatelandmarks":
			if (document.getElementById("imgzoomin")) document.getElementById("imgzoomin").src="images/zoomin_n.jpg";
			if (document.getElementById("imgzoomout")) document.getElementById("imgzoomout").src="images/zoomout_n.jpg";
			if (document.getElementById("imgpan")) document.getElementById("imgpan").src="images/pan_n.jpg";
			if (document.getElementById("imgbuffer")) document.getElementById("imgbuffer").src="images/buffer_n.jpg";
			if (document.getElementById("imgidentify")) document.getElementById("imgidentify").src="images/identify_n.jpg";
			if (document.getElementById("imgprintr"))document.getElementById("imgprint").src="images/print_n.jpg";
			if (document.getElementById("imgmeasure")) document.getElementById("imgmeasure").src="images/measure_n.jpg";
			if (document.getElementById("imgprev")) document.getElementById("imgprev").src="images/prev_n.jpg";
			if (document.getElementById("imgannotation")) document.getElementById("imgannotation").src="images/addtext_n.jpg";
			if (document.getElementById("imgprintlocation")) document.getElementById("imgprintlocation").src="images/printlocation_n.jpg";
			break;
			
		case "locateroads":
			if (document.getElementById("imgzoomin")) document.getElementById("imgzoomin").src="images/zoomin_n.jpg";
			if (document.getElementById("imgzoomout")) document.getElementById("imgzoomout").src="images/zoomout_n.jpg";
			if (document.getElementById("imgpan")) document.getElementById("imgpan").src="images/pan_n.jpg";
			if (document.getElementById("imgbuffer")) document.getElementById("imgbuffer").src="images/buffer_n.jpg";
			if (document.getElementById("imgidentify")) document.getElementById("imgidentify").src="images/identify_n.jpg";
			if (document.getElementById("imgprintr"))document.getElementById("imgprint").src="images/print_n.jpg";
			if (document.getElementById("imgmeasure")) document.getElementById("imgmeasure").src="images/measure_n.jpg";
			if (document.getElementById("imgprev")) document.getElementById("imgprev").src="images/prev_n.jpg";
			if (document.getElementById("imgannotation")) document.getElementById("imgannotation").src="images/addtext_n.jpg";
			if (document.getElementById("imgprintlocation")) document.getElementById("imgprintlocation").src="images/printlocation_n.jpg";
			break;
			
		case "zoomlevel":
			if (document.getElementById("imgzoomin")) document.getElementById("imgzoomin").src="images/tick_selected.gif";
			if (document.getElementById("imgzoomout")) document.getElementById("imgzoomout").src="images/tick.gif";
			if (document.getElementById("imgpan")) document.getElementById("imgpan").src="images/pan_n.jpg";
			if (document.getElementById("imgbuffer")) document.getElementById("imgbuffer").src="images/buffer_n.jpg";
			if (document.getElementById("imgidentify")) document.getElementById("imgidentify").src="images/identify_n.jpg";
			if (document.getElementById("imgprintr"))document.getElementById("imgprint").src="images/print_n.jpg";
			if (document.getElementById("imgmeasure")) document.getElementById("imgmeasure").src="images/measure_n.jpg";
			if (document.getElementById("imgprev")) document.getElementById("imgprev").src="images/prev_n.jpg";
			if (document.getElementById("imgannotation")) document.getElementById("imgannotation").src="images/addtext_n.jpg";
			if (document.getElementById("imgprintlocation")) document.getElementById("imgprintlocation").src="images/printlocation_n.jpg";
			break;
		
		case "reset":
			if (document.getElementById("imgzoomin")) document.getElementById("imgzoomin").src="images/zoomin_n.jpg";
			if (document.getElementById("imgzoomout")) document.getElementById("imgzoomout").src="images/zoomout_n.jpg";
			if (document.getElementById("imgpan")) document.getElementById("imgpan").src="images/pan_n.jpg";
			if (document.getElementById("imgbuffer")) document.getElementById("imgbuffer").src="images/buffer_n.jpg";
			if (document.getElementById("imgidentify")) document.getElementById("imgidentify").src="images/identify_n.jpg";
			if (document.getElementById("imgprintr"))document.getElementById("imgprint").src="images/print_n.jpg";
			if (document.getElementById("imgmeasure")) document.getElementById("imgmeasure").src="images/measure_n.jpg";
			if (document.getElementById("imgprev")) document.getElementById("imgprev").src="images/prev_n.jpg";
			if (document.getElementById("imgannotation")) document.getElementById("imgannotation").src="images/addtext_n.jpg";
			if (document.getElementById("imgprintlocation")) document.getElementById("imgprintlocation").src="images/printlocation_n.jpg";
			break;
			
		case "pan":
			if (document.getElementById("imgzoomin")) document.getElementById("imgzoomin").src="images/zoomin_n.jpg";
			if (document.getElementById("imgzoomout")) document.getElementById("imgzoomout").src="images/zoomout_n.jpg";
			if (document.getElementById("imgpan")) document.getElementById("imgpan").src="images/pan_n.jpg";
			if (document.getElementById("imgbuffer")) document.getElementById("imgbuffer").src="images/buffer_n.jpg";
			if (document.getElementById("imgidentify")) document.getElementById("imgidentify").src="images/identify_n.jpg";
			if (document.getElementById("imgprintr"))document.getElementById("imgprint").src="images/print_n.jpg";
			if (document.getElementById("imgmeasure")) document.getElementById("imgmeasure").src="images/measure_n.jpg";
			if (document.getElementById("imgprev")) document.getElementById("imgprev").src="images/prev_n.jpg";
			if (document.getElementById("imgannotation")) document.getElementById("imgannotation").src="images/addtext_n.jpg";
			if (document.getElementById("imgprintlocation")) document.getElementById("imgprintlocation").src="images/printlocation_n.jpg";
			
			break;
		
		case "previousextent":
			if (document.getElementById("imgzoomin")) document.getElementById("imgzoomin").src="images/zoomin_n.jpg";
			if (document.getElementById("imgzoomout")) document.getElementById("imgzoomout").src="images/zoomout_n.jpg";
			if (document.getElementById("imgpan")) document.getElementById("imgpan").src="images/pan_n.jpg";
			if (document.getElementById("imgbuffer")) document.getElementById("imgbuffer").src="images/buffer_n.jpg";
			if (document.getElementById("imgidentify")) document.getElementById("imgidentify").src="images/identify_n.jpg";
			if (document.getElementById("imgprintr"))document.getElementById("imgprint").src="images/print_n.jpg";
			if (document.getElementById("imgmeasure")) document.getElementById("imgmeasure").src="images/measure_n.jpg";
			if (document.getElementById("imgprev")) document.getElementById("imgprev").src="images/prev_o.jpg";
			if (document.getElementById("imgannotation")) document.getElementById("imgannotation").src="images/addtext_n.jpg";
			break;

		case "addannotation":
			if (document.getElementById("imgzoomin")) document.getElementById("imgzoomin").src="images/zoomin_n.jpg";
			if (document.getElementById("imgzoomout")) document.getElementById("imgzoomout").src="images/zoomout_n.jpg";
			if (document.getElementById("imgpan")) document.getElementById("imgpan").src="images/pan_n.jpg";
			if (document.getElementById("imgbuffer")) document.getElementById("imgbuffer").src="images/buffer_n.jpg";
			if (document.getElementById("imgidentify")) document.getElementById("imgidentify").src="images/identify_n.jpg";
			if (document.getElementById("imgprintr"))document.getElementById("imgprint").src="images/print_n.jpg";
			if (document.getElementById("imgmeasure")) document.getElementById("imgmeasure").src="images/measure_n.jpg";
			if (document.getElementById("imgprev")) document.getElementById("imgprev").src="images/prev_n.jpg";
			if (document.getElementById("imgannotation")) document.getElementById("imgannotation").src="images/addtext_o.jpg";
			if (document.getElementById("imgprintlocation")) document.getElementById("imgprintlocation").src="images/printlocation_n.jpg";
			
			break;
			
		case "printlocation":
			if (document.getElementById("imgzoomin")) document.getElementById("imgzoomin").src="images/zoomin_n.jpg";
			if (document.getElementById("imgzoomout")) document.getElementById("imgzoomout").src="images/zoomout_n.jpg";
			if (document.getElementById("imgpan")) document.getElementById("imgpan").src="images/pan_n.jpg";
			if (document.getElementById("imgbuffer")) document.getElementById("imgbuffer").src="images/buffer_n.jpg";
			if (document.getElementById("imgidentify")) document.getElementById("imgidentify").src="images/identify_n.jpg";
			if (document.getElementById("imgprintr"))document.getElementById("imgprint").src="images/print_n.jpg";
			if (document.getElementById("imgmeasure")) document.getElementById("imgmeasure").src="images/measure_n.jpg";
			if (document.getElementById("imgprev")) document.getElementById("imgprev").src="images/prev_n.jpg";
			if (document.getElementById("imgannotation")) document.getElementById("imgannotation").src="images/addtext_n.jpg";
			if (document.getElementById("imgprintlocation")) document.getElementById("imgprintlocation").src="images/printlocation_o.jpg";						
				
			break;	
	}
}

// zoom to center of fullextent at set scale
function ZoomToScale()
{
	//check if map form is loaded or not
	var checked;
	checked= CheckMapForm();
	if (checked == false) return;
	
	var str=document.frmMain.txtscale.value;
	if (parseInt(str) && parseInt(str)> 0 )
	{
		ClearZoomLevels();
		//SetZoomValue(-1,document.frmMain.txtscale.value);
		document.getElementById("hid_action").value="zoomtoscale";
		document.frmMap.hid_scale.value=document.frmMain.txtscale.value;
		document.forms["frmMap"].submit();		
	}
	else
	{
		alert("Number must be a positive Integer.");
	}
}
//**********************************************************************


//Opens the email form to send map as attachment
function EmailMap()
{   
	window.open('emailmap.asp','popwindow','titlebar=no,scrollbars=yes,titlebar=no,dependent=yes,width=600,height=380,top=100,left=10' );
}
//**********************************************************************

//Opens the legend of the map in a new form
function PopLegend()
{
	//check if map form is loaded or not
	var checked;
	checked= CheckMapForm();
	if (checked == false) return;
	
	window.open("../MapTools/legend.aspx?legendurl=" + document.getElementById("hid_legendurl").value,"Legend",'width=250, height=350,resizable=yes, scrollbars=yes','True');
	
}
//**********************************************************************


//Hide measure Table from the map
function HideDiv()
{
	//hideLayer("measurediv");
	//document.getElementById("imgtrp").style.visibility="hidden";
	//document.getElementById("measurediv").style.visibility="hidden";
	//document.frmMap.hid_measurediv.value = "hidden";
}
//**********************************************************************


  //function hides measure box from the top left of the map
  function HideMeasure()
  {
	HideDiv();
  }
  //**********************************************************************
  

//DoNothing is a function that does nothing
function DoNothing()
{
}
//**********************************************************************

//CheckMapForm is a function that checks if map frame is loaded if yes it returns true else it returns false
function CheckMapForm()
{
	if (parent.window.mapframe.document.forms["frmMap"]!= null)
		return true;
	else 
		return false;		
}
//**********************************************************************

//CheckEnter checks if enter key is pressed and do the action if it is pressed
function CheckEnter(searchtype)
{
	var check = IsEnterPressed();
	if (check==true)
	{	
		if (searchtype==1) Search('dm');
		if (searchtype==2) Search('ld');
		if (searchtype==3) ZoomToScale();
	
	}
}

function ZoomLevelOnMouseOut(id,index)
{

if (index != document.getElementById("hid_ilevel").value )
    {
    
      document.getElementById(id).src ='../images/ToolBar/ZoomBar.gif';
    }
}

//new function used to identify the clicked feature

function DoIdentify2(id,Xcoord,Ycoord,lang)
{
if(document.getElementById("hid_action").value == "identify")
{
		{           
           newwindow=window.open("http://212.28.242.51/lphu/MapTools/DescriptionReport_MOI.aspx?ln="+ lang + "&action=Identify&Id=" + id + "&xCoord=" + Xcoord+"&yCoord="+Ycoord+"&scale="+document.getElementById("hid_scale").value,"Identify","scrollbars=1, resizable=yes, width=800, height=550");
		   if (window.focus) {newwindow.focus()}
	        return false;
	        
	        }

}
}
//**********************************************************************


