﻿//**********************************************************************
//main.js includes all functions of page "main.aspx" mainly functions here 
//control the map
//**********************************************************************
var prefixName;

//Set the map in the map iframe
function Load(frameName,pageId)
{ 
	//document.getElementById("chkAuto").checked=true;	
	//CheckLayers(); //function is in explorer.js	
	prefixName=frameName.substring(0,frameName.lastIndexOf("_")+1);
	document.getElementById(frameName).src="map.aspx?ln=" + document.getElementById(prefixName + "hid_lang").value + "&prefixName=" + prefixName + "&pageId=" + pageId; //?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
		{
			map= window.mapframe.document.getElementById("imgDiv");	
		}
		else//case netscae,mozilla, firefox, opera..
		{
			map= window.mapframe.document.getElementById("imgmap");	
		}
	}
}
//**********************************************************************/

//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();
	
	//Hide popUp DIV that is used to popup data
	//window.mapframe.document.getElementById("popupDIV").style.visibility="hidden";
	
	if (action=='zoomin')
	{
		//if (document.getElementById("imgzoomin")) document.getElementById("imgzoomin").src = "images/zoomin_o.jpg";
		window.mapframe.document.forms["frmMap"].hid_action.value=action;
		map.style.cursor="crosshair";
		HideDiv();
		//ShowToolTip("zoomin");
		ClearZoomLevels();
	}
	if (action=='zoomout')
	{
		window.mapframe.document.forms["frmMap"].hid_action.value=action;
		map.style.cursor="crosshair";
		HideDiv();
		//ShowToolTip("zoomout");
		ClearZoomLevels();
	}
	if (action=='previousextent')
	{
		window.mapframe.document.forms["frmMap"].hid_action.value=action;
		map.style.cursor="normal";
		HideDiv();
		//ShowToolTip("zoomout");
		ClearZoomLevels();
		window.mapframe.document.forms["frmMap"].submit();
	}
	if (action=='pan')
	{
		window.mapframe.document.forms["frmMap"].hid_panDirection.value= value;
		window.mapframe.document.forms["frmMap"].hid_action.value=action;
		window.mapframe.document.forms["frmMap"].submit();
	}
	if (action=='move')
	{
		window.mapframe.document.forms["frmMap"].hid_action.value=action;
		map.style.cursor="move";
		HideDiv();
		//ShowToolTip("move");
	}
	if (action=='measure')
	{
		window.mapframe.document.forms["frmMap"].hid_action.value=action;
		window.mapframe.document.forms["frmMap"].hid_startmeasure.value="end";
		window.mapframe.document.forms["frmMap"].hid_drawxstrmeas.value="";
		window.mapframe.document.forms["frmMap"].hid_drawystrmeas.value="";
		window.mapframe.document.forms["frmMap"].hid_meastexts.value="";
		window.mapframe.document.forms["frmMap"].hid_meastext1.value="0";
		window.mapframe.document.forms["frmMap"].hid_meastext2.value="0";
		window.mapframe.document.getElementById("measurediv").style.visibility="Visible";
		window.mapframe.document.forms["frmMap"].hid_measurediv.value = "Visible";
		map.style.cursor="crosshair";
		window.mapframe.document.forms["frmMap"].meastext1.value="";
		if (document.getElementById("hid_lang").value=="en")
			alert("Click on the map to define the start point");
		else
			alert("انقر على الخريطة لتعريف نقطة بداية");
		//ShowToolTip("measure");
	}
	if (action=='openbuffer')
	{
		window.mapframe.document.forms["frmMap"].hid_action.value=action;
		map.style.cursor="hand";	
		HideDiv();
		//ShowToolTip("buffer");
		window.open("buffer.aspx",'popwindow','titlebar=no,scrollbars=no,titlebar=no,dependent=yes,width=430,height=355,top=100,left=10' );
	}
	if (action=='identify')
	{
		window.mapframe.document.forms["frmMap"].hid_action.value=action;
		map.style.cursor="help";
		HideDiv();
		//ShowToolTip("identify");
	}
	if (action=='reset')
	{		
		//if clear is included in reset
			window.mapframe.document.forms["frmMap"].hid_drawxstrmeas.value="";
			window.mapframe.document.forms["frmMap"].hid_meastexts.value=""
			//window.mapframe.document.forms["frmMap"].hid_subaction.value="";
		//end clear included
		window.mapframe.document.forms["frmMap"].hid_action.value=action;
		window.mapframe.document.forms["frmMap"].hid_ilevel.value="";
		map.style.cursor="hand";
		HideDiv();		
		//document.getElementById("tooltipdiv").style.visibility= "hidden";
		window.mapframe.document.forms["frmMap"].submit();
	}
	if (action=='clearmap')
	{				
		//window.mapframe.document.forms["frmMap"].hid_annotation.value="";
		//window.mapframe.document.forms["frmMap"].hid_annotationxdown.value="";
		//window.mapframe.document.forms["frmMap"].hid_annotationydown.value="";
		window.mapframe.document.forms["frmMap"].hid_drawxstrmeas.value="";
		window.mapframe.document.forms["frmMap"].hid_meastexts.value=""
		window.mapframe.document.forms["frmMap"].hid_subaction.value="";
		window.mapframe.document.forms["frmMap"].hid_action.value=action;
		HideMeasure();
		window.mapframe.document.forms["frmMap"].submit();
	}
	
	if (action=='upzoomlevel')
	{
		if (window.mapframe.document.forms["frmMap"].hid_ilevel.value.length > 0)
		{
			if (window.mapframe.document.forms["frmMap"].hid_ilevel.value <= 9)
			{	
				if (window.mapframe.document.forms["frmMap"].hid_ilevel.value == 1)
				{
					window.mapframe.document.forms["frmMap"].hid_ilevel.value = parseInt(window.mapframe.document.forms["frmMap"].hid_ilevel.value) + 4;		
				}
				else
				{
					window.mapframe.document.forms["frmMap"].hid_ilevel.value = parseInt(window.mapframe.document.forms["frmMap"].hid_ilevel.value) + 1;		
				}				
			}
		}
		else {window.mapframe.document.forms["frmMap"].hid_ilevel.value = 7;}
		
		window.mapframe.document.forms["frmMap"].hid_action.value="zoomlevel";
		HideDiv();
		SetZoomLevels(window.mapframe.document.forms["frmMap"].hid_ilevel.value);
		window.mapframe.document.forms["frmMap"].submit();
	}
	
	if (action=='downzoomlevel')
	{
		if (window.mapframe.document.forms["frmMap"].hid_ilevel.value.length > 0)
		{
			if (window.mapframe.document.forms["frmMap"].hid_ilevel.value >= 2)
			{	
				if (window.mapframe.document.forms["frmMap"].hid_ilevel.value == 5)
				{
					window.mapframe.document.forms["frmMap"].hid_ilevel.value = parseInt(window.mapframe.document.forms["frmMap"].hid_ilevel.value) - 4;		
				}
				else
				{
					window.mapframe.document.forms["frmMap"].hid_ilevel.value = parseInt(window.mapframe.document.document.forms["frmMap"].hid_ilevel.value) - 1;		
				}
			}
		}
		else {window.mapframe.document.forms["frmMap"].hid_ilevel.value = 7;}
		
		window.mapframe.document.forms["frmMap"].hid_action.value="zoomlevel";
		HideDiv();
		SetZoomLevels(window.mapframe.document.forms["frmMap"].hid_ilevel.value);
		window.mapframe.document.forms["frmMap"].submit();
	}
	
	if (action=='zoomlevel')
	{	
		window.mapframe.document.forms["frmMap"].hid_action.value=action;
		window.mapframe.document.forms["frmMap"].hid_ilevel.value=value;
		//document.getElementById("imgframeDiv").style.cursor="default";
		HideDiv();
		//document.getElementById("tooltipdiv").style.visibility= "hidden";
		SetZoomLevels(value);
		window.mapframe.document.forms["frmMap"].submit();
	}
	
	if (action == 'addannotation')
	{
		window.mapframe.document.forms["frmMap"].hid_action.value="addannotation";
	}
	
	if (action=='print')
	{
		window.open("print.aspx?mapurl=" + window.mapframe.document.forms["frmMap"].hid_mapurl.value ,"Print",'width=600, height=400, left=20, top=20','True');
	}
	if (action=='printguide')
	{
		window.open("printguide.aspx?minx=" + window.mapframe.document.forms["frmMap"].hid_minx.value + "&miny=" + window.mapframe.document.forms["frmMap"].hid_miny.value + "&maxx=" + window.mapframe.document.forms["frmMap"].hid_maxx.value + "&maxy=" + window.mapframe.document.forms["frmMap"].hid_maxy.value  ,"PrintGuide",'width=660, height=660, left=20, top=20','True');
	}
	if (action=='printlocation')
	{
		window.mapframe.document.forms["frmMap"].hid_action.value=action;
		map.style.cursor="normal";
		HideDiv();
		if (document.getElementById("hid_lang").value=="en")
			alert("Please click on a Plot");
		else
			alert("أنقر الان على قطعة");
	}
	if (action=='email')
	{
		var link;
		if (parent.document.frmMain.hid_lang.value=="en")
			link="http://209.120.245.180/elections/explorer.aspx?extent=";
		else
			link="http://209.120.245.180/elections/explorer.aspx?extent=";
		window.open("mailto:?subject=Map&body=This map is informational only. Click the link to get map." + link + document.frmMain.extent.value);
	}
	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/locator/arabic/main.aspx?pass=" + document.frmMain.hid_pass.value;	
	}
	if (action=='openenglish')
	{
		//window.open("arabic.html","Arabic",'width=300; height=100; left=50; top=50;','True');
		window.location="http://localhost/locator/main.aspx?pass=" + document.frmMain.hid_pass.value;	
	}	
	
	if (action=='openadvsimulator')
	{
		if (value!="ar")
			openMaxedWindow('main.aspx?simtype=1','Simulator',false,'Explorer.aspx');
			//window.open('main.aspx','Identify','resizable=yes, scrollbar=yes, width=945, height=600, left=0, top=0','True');
		else
			openMaxedWindow('main_ar.aspx?simtype=1','Simulator',false,'Explorer_ar.aspx');
			//window.open('main_ar.aspx','Identify','resizable=yes, scrollbar=yes, width=945, height=600, left=0, top=0','True');
	}	
			
	if (action=='opensimulator')
	{
		if (value!="ar")
			openMaxedWindow('main.aspx','Simulator',false,'Explorer.aspx');
			//window.open('main.aspx','Identify','resizable=yes, scrollbar=yes, width=945, height=600, left=0, top=0','True');
		else
			openMaxedWindow('main_ar.aspx','Simulator',false,'Explorer_ar.aspx');
			//window.open('main_ar.aspx','Identify','resizable=yes, scrollbar=yes, width=945, height=600, left=0, top=0','True');
	}	
	ClearImages();
	
}
//**********************************************************************

//Shows or Hides Layers
function SetLayerVisibility() {

	//check if map form is loaded or not
	var checked;
	checked= CheckMapForm();
	if (checked == false) return;

	window.mapframe.document.forms["frmMap"].hid_action.value="";
	if (window.mapframe.document.forms["frmMap"].hid_layervisibility.value== "false")
	{

		window.mapframe.document.forms["frmMap"].hid_layervisibility.value= "true";
	}
	else
	{
		window.mapframe.document.forms["frmMap"].hid_layervisibility.value= "false";
	}

	window.mapframe.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=30%><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=30%><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=30%><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=30%><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>";
	}
	document.getElementById("tooltipdiv").style.visibility="Visible";
	document.getElementById("tooltipdiv").innerHTML=inhtml;
}
//**********************************************************************

//SetZoomLevels changes the image for the zoom level buttons (checks selected level)
function SetZoomLevels(value)
{
	ClearZoomLevels();
	if (document.getElementById("imgzoomlevel" + value)) document.getElementById("imgzoomlevel" + value).src="images/level_o.jpg";
}
//**********************************************************************

//ClearZoomLevels unchecks all zoomlevel buttons)
function ClearZoomLevels()
{
var i=1 ;
var zoomlevels=13;

	while (i <= zoomlevels)
	{
		if (document.getElementById("imgzoomlevel" + i)) document.getElementById("imgzoomlevel" + i).src="images/level_n.jpg";
		i=i+1;
	}

}
//**********************************************************************

//ClearImages() resets all images in map toolbar to their original form
function ClearImages()
{
	switch (window.mapframe.document.forms["frmMap"].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/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 "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;	
	}
}
//***********************************************************************


//Zooms to Mohafaza, Kadaa, Zone, Town
function ZoomToRegion(selDistr, selElect)
{
	//check if map form is loaded or not
	//alert(document.getElementById("selRegion_r").options[document.getElementById("selRegion_r").selectedIndex].text + "_" + document.getElementById("selDivision").value);
	var checked;
	checked= CheckMapForm();
	if (checked == false) return;
	
	//var str=document.getElementById("selDivision").value;
	//if (str.length > 0)
	var str=document.getElementById("selDivision").value;
	if (str > 0)
	{
		window.mapframe.document.forms["frmMap"].hid_action.value= "zoomtoregion";
		//window.mapframe.document.forms["frmMap"].hid_searchstr.value= document.getElementById("selRegion_r").options[document.getElementById("selRegion_r").selectedIndex].text + "_" + document.getElementById("selDivision").value;//document.frmMain.Sel_Community.options[document.frmMain.Sel_Community.selectedIndex].value;
		//window.mapframe.document.forms["frmMap"].hid_searchstr.value= document.getElementById("selDistrictType").options[document.getElementById("selDistrictType").selectedIndex].text + "_" + document.getElementById("selDivision").value;
		// (document.getElementById(selElect).value == 1)
		//	window.mapframe.document.forms["frmMap"].hid_searchstr.value= document.getElementById(selElect).value + "_" + document.getElementById(selDistr).value/*document.getElementById(selDistr).options[document.getElementById(selDistr).selectedIndex].text*/ + "_" + document.getElementById("selDivision").value;
		//else if (document.getElementById(selElect).value == 2)
			if(document.getElementById(selElect))
			    window.mapframe.document.forms["frmMap"].hid_ZoomInfo.value= document.getElementById(selElect).value + "_" + "-1" + "_" + document.getElementById("selDivision").value;
		    else
		        window.mapframe.document.forms["frmMap"].hid_ZoomInfo.value=   "3_" + "-1" + "_" + document.getElementById("selDivision").value;		
		ClearZoomLevels();
		window.mapframe.document.forms["frmMap"].submit();
	}
	else
	{
	//	if (document.getElementById("hid_lang").value=="en")
	//		alert("please select a community");
	//	else
	//		alert("الرجاء اختيار منطقة");
	}
}

//Shows/Hides according to the checkbox selected, mainly Auto, Mohafaza, Kadaa, Zone
/*function SeeLayers()
{
	if (document.frmMain.chkAuto.checked == false)
	{
		window.mapframe.document.forms["frmMap"].hid_maplayer.value = "";
	}
	if (document.frmMain.chkMohafaza.checked == false)
	{
		window.mapframe.document.forms["frmMap"].hid_maplayer.value = "";
	}
	if (document.frmMain.chkKadaa.checked == false)
	{
		window.mapframe.document.forms["frmMap"].hid_maplayer.value = "";
	}
	if (document.frmMain.chkZone.checked == false)
	{
		window.mapframe.document.forms["frmMap"].hid_maplayer.value = "";
	}
	
	if (document.frmMain.chkAuto.checked == true)
	{
		window.mapframe.document.forms["frmMap"].hid_maplayer.value= "Auto";
	}
		
	if (document.frmMain.chkMohafaza.checked == true)
	{
		window.mapframe.document.forms["frmMap"].hid_maplayer.value= "Mohafaza" + "_";
	}
		
	if (document.frmMain.chkKadaa.checked == true)
	{
		window.mapframe.document.forms["frmMap"].hid_maplayer.value= window.mapframe.document.forms["frmMap"].hid_maplayer.value + "Kadaa" + "_";
	}
	
	if (document.frmMain.chkZone.checked == true)
	{
		window.mapframe.document.forms["frmMap"].hid_maplayer.value= window.mapframe.document.forms["frmMap"].hid_maplayer.value + "Zone";
	}
	
	
	//alert(window.mapframe.document.forms["frmMap"].hid_maplayer.value);
	ClearZoomLevels();
	window.mapframe.document.forms["frmMap"].submit();	
}*/

//function See (skip)
//{
//	var str= document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").value;
//	var str1= document.getElementById("selDistrictType").value;
//	var str2= document.getElementById("selDistribution").value;
	
	/*if (str2 == 4)
	{
		alert("hi");
		SeeElectoralOnMap(skip);
	}*/
//	if ((str ==1 || str1 >0)) //&& (str1 >=0))
//	{
		//if (str3 == 0 || str3 == 4)
		//	window.mapframe.document.forms["frmMap"].hid_subaction.value = 
//		SeeElectoralOnMap(skip);
//	}
//}

//Shows/Hides the Gender and Religious map layers
function SeeOnMap()
{
    
	//check if map form is loaded or not
	//alert(document.getElementById("selRegion_r").options[document.getElementById("selRegion_r").selectedIndex].text + "_" + document.getElementById("selDivision").value);
	var checked;
	checked= CheckMapForm();
	if (checked == false) return;

	
	//var str=document.getElementById("selRegion_d").value;
	//if (str.length > 0)
	var str=document.getElementById("ctl00_ContentPlaceHolder1_ctl00_ContentPlaceHolder1_selElectorallaw").value;
	var str1=document.getElementById("selDistribution").value;
	var str2=document.getElementById("selReligiousGender").value;
	var str3="-1" ;//document.getElementById("selDistrictType").value;
	
	//if (document.getElementById("selDistribution").options[document.getElementById("selDistribution").selectedIndex].text == "Summary of Constituency")
	/*if (document.getElementById("selDistribution").value == 4) // if summary of district
	{
		SeeElectoralOnMap(true);
	}
	else*/ if ((str > 0) && (str1 > 0) && (str2 != 0) &&(str2 != '333'))// && (str2 != 0))
	{
		/*if (document.getElementById("selDistribution").value == 1)
		{
			window.mapframe.document.forms["frmMap"].hid_subaction.value="ShowHideLayers";
			window.mapframe.document.forms["frmMap"].hid_layer.value= document.getElementById("selRegion_d").options[document.getElementById("selRegion_d").selectedIndex].text;
			window.mapframe.document.forms["frmMap"].hid_layervisibility.value = "True"
		}*/
//		if ((document.getElementById("selDistribution").value == 1) && (document.getElementById("selReligiousGender").value != 0))
//		{

		//window.mapframe.document.forms["frmMap"].hid_subaction.value= "ColorGenderMap";
		if (str2 != 0)
		{
			if (document.getElementById(prefixName + "hid_lang").value!="ar")
				document.getElementById("Tip2").innerHTML = "Click on a District on the Map to See the Detail";
				//setTimeout('alert("Click on a District on the Map to See the Detail")',2000);
			else
				document.getElementById("Tip2").innerHTML = "انقر على دائرة معينة في الخريطة لترى التفاصيل";
				//alert("انقر على دائرة معينة في الخريطة لترى التفاصيل");
		}
		else
			document.getElementById("Tip2").innerHTML = "";
		
		
		//if (document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").options[document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").selectedIndex].text == "2000 Electoral Law")
		if (str == 1 || str==2) // 2000 Electoral Law
		{
			window.mapframe.document.forms["frmMap"].hid_subaction.value= str;//document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").value;//options[document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").selectedIndex].text;
			window.mapframe.document.forms["frmMap"].hid_searchstr.value= str2;//document.getElementById("selReligiousGender").value;//options[document.getElementById("selReligiousGender").selectedIndex].text;
			window.mapframe.document.forms["frmMap"].hid_ColorValues.value=str2 /*document.getElementById("selReligiousGender").value*//*options[document.getElementById("selReligiousGender").selectedIndex].text*/ + "_" + str + "_" +str1 + "_" + document.getElementById("selReligiousGender").options[document.getElementById("selReligiousGender").selectedIndex].text;/*document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").value*//*options[document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").selectedIndex].value;*///document.frmMain.Sel_Community.options[document.frmMain.Sel_Community.selectedIndex].value;
			window.mapframe.document.forms["frmMap"].hid_layer.value= 10;//document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").value;
			window.mapframe.document.forms["frmMap"].hid_GeoLevel.value= "";
		}
		else if (str == 3)
		{
			window.mapframe.document.forms["frmMap"].hid_subaction.value= str;//document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").value;//options[document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").selectedIndex].text;
			window.mapframe.document.forms["frmMap"].hid_searchstr.value= str2;//document.getElementById("selReligiousGender").value;//options[document.getElementById("selReligiousGender").selectedIndex].text;
			window.mapframe.document.forms["frmMap"].hid_ColorValues.value=str2 /*document.getElementById("selReligiousGender").value*//*options[document.getElementById("selReligiousGender").selectedIndex].text*/ + "_" + str + "_" +str1 + "_" + document.getElementById("selReligiousGender").options[document.getElementById("selReligiousGender").selectedIndex].text;/*document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").value*//*options[document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").selectedIndex].value;*///document.frmMain.Sel_Community.options[document.frmMain.Sel_Community.selectedIndex].value;
			window.mapframe.document.forms["frmMap"].hid_layer.value= 12;//document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").value;
			window.mapframe.document.forms["frmMap"].hid_GeoLevel.value= "";
		}
		else
		{		
//			window.mapframe.document.forms["frmMap"].hid_subaction.value= str;/*document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").value;*///options[document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").selectedIndex].text;
//			window.mapframe.document.forms["frmMap"].hid_searchstr.value= str2;/*document.getElementById("selReligiousGender").value;*///options[document.getElementById("selReligiousGender").selectedIndex].text;
//			window.mapframe.document.forms["frmMap"].hid_ColorValues.value= str2/*document.getElementById("selReligiousGender").value*//*options[document.getElementById("selReligiousGender").selectedIndex].text*/ + "_" + str3 + "_" + str1 + "_" + document.getElementById("selReligiousGender").options[document.getElementById("selReligiousGender").selectedIndex].text;/*document.getElementById("selDistrictType").value;*///document.frmMain.Sel_Community.options[document.frmMain.Sel_Community.selectedIndex].value;
//			if (document.getElementById("selDistrictType").value > 0)
//			{
//				window.mapframe.document.forms["frmMap"].hid_layer.value= str3;/*document.getElementById("selDistrictType").value;*///options[document.getElementById("selDistrictType").selectedIndex].value;
//				window.mapframe.document.forms["frmMap"].hid_GeoLevel.value= str3;/*document.getElementById("selDistrictType").value;*///options[document.getElementById("selDistrictType").selectedIndex].text;
//			}
		}
	

	ClearZoomLevels();
	
	window.mapframe.document.forms["frmMap"].submit();
	
	}
	/*else if (document.getElementById("selDistribution").options[document.getElementById("selDistribution").selectedIndex].text == "Summary of District")
	{
		SeeElectoralOnMap();
	}*/
	else
	{
		if (str2==0)
		{
			if (document.getElementById(prefixName + "hid_lang").value!="ar")
				alert("Please Select a Geographic Concentration");
			else
				alert("الرجاء اختيار التوزيع الجغرافي");
		}
		else
		{
			if (document.getElementById(prefixName + "hid_lang").value!="ar")
				alert("Please Select an Electoral Law");
			else
				alert("الرجاء اختيار قانون أنتخابي");
		}
	}
}

//Shows/Hides the electoral map layers
function SeeElectoralOnMap(skip)
{


	//check if map form is loaded or not
	//alert(document.getElementById("selRegion_r").options[document.getElementById("selRegion_r").selectedIndex].text + "_" + document.getElementById("selDivision").value);
	var checked;
	checked= CheckMapForm();
	if (checked == false) return;
	
	var str="2"; //set default to year 2005
	if(document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw"))
	    str=document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").value;
	    
	var str1;
	if(document.getElementById("selDistribution"))
	    str1 = document.getElementById("selDistribution").value;
	else
	    str1="-1";    
	var str2 = "-1"; //document.getElementById("selDistrictType").value;
	//if (str.length > 0)
	//if (str > 0)
	//{
		//document.getElementById("Tip2").innerHTML = "click on a specific district to see the geographic concentration of a specific demographic group";
		
		if (str == 1)
		{
			window.mapframe.document.forms["frmMap"].hid_subaction.value="ShowHidelayers2000";
			window.mapframe.document.forms["frmMap"].hid_GeoLevel.value= "";
			window.mapframe.document.forms["frmMap"].hid_layer.value= str;/*document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").value;*///options[document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").selectedIndex].text;
			window.mapframe.document.forms["frmMap"].hid_layervisibility.value = "True";
						
			//if (str1 == 0)
			//{
			//	window.mapframe.document.forms["frmMap"].hid_searchstr.value = "4";
			//}
			//else
			//{
				window.mapframe.document.forms["frmMap"].hid_searchstr.value = str1;/*document.getElementById("selDistribution").value;*/
				window.mapframe.document.forms["frmMap"].hid_ColorValues.value = ""
			//}
			
			if (!skip)
			{
				window.mapframe.document.forms["frmMap"].submit();
			}
		}
		else if (str == 2)
		{
			window.mapframe.document.forms["frmMap"].hid_subaction.value="ShowHidelayers2005";
			window.mapframe.document.forms["frmMap"].hid_layer.value= str;/*document.getElementById("selDistrictType").value;*///options[document.getElementById("selDistrictType").selectedIndex].text;
			window.mapframe.document.forms["frmMap"].hid_GeoLevel.value= "";/*document.getElementById("selDistrictType").value;*///options[document.getElementById("selDistrictType").selectedIndex].text;
			window.mapframe.document.forms["frmMap"].hid_layervisibility.value = "True";
			
			//if (str1 == 0)
			//{
			//	window.mapframe.document.forms["frmMap"].hid_searchstr.value = "4";
			//}
			//else
			//{
				window.mapframe.document.forms["frmMap"].hid_searchstr.value = str1/*document.getElementById("selDistribution").value;*/
				window.mapframe.document.forms["frmMap"].hid_ColorValues.value = ""
			//}
			
			if (!skip)
			{
				window.mapframe.document.forms["frmMap"].submit();
			}
			
		}
		else if (str == 3)
		{
			window.mapframe.document.forms["frmMap"].hid_subaction.value="ShowHidelayersDOHA";
			window.mapframe.document.forms["frmMap"].hid_GeoLevel.value= "";
			window.mapframe.document.forms["frmMap"].hid_layer.value= str;/*document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").value;*///options[document.getElementById("ctl00_ContentPlaceHolder1_selElectorallaw").selectedIndex].text;
			window.mapframe.document.forms["frmMap"].hid_layervisibility.value = "True";
						
			//if (str1 == 0)
			//{
			//	window.mapframe.document.forms["frmMap"].hid_searchstr.value = "4";
			//}
			//else
			//{
				window.mapframe.document.forms["frmMap"].hid_searchstr.value = str1;/*document.getElementById("selDistribution").value;*/
				window.mapframe.document.forms["frmMap"].hid_ColorValues.value = ""
			//}
			
			if (!skip)
			{
				window.mapframe.document.forms["frmMap"].submit();
			}
		}
		
		ClearZoomLevels();
		
		/*if (!skip)
		{
			window.mapframe.document.forms["frmMap"].submit();
		}*/
		
	//}
	//else
	//{
	//	if (document.getElementById("hid_lang").value=="en")
	//		alert("please select a community");
		//else
		//	alert("الرجاء اختيار منطقة");
	//}
}

// 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();
		window.mapframe.document.forms["frmMap"].hid_action.value="zoomtoscale";
		window.mapframe.document.forms["frmMap"].hid_scale.value=document.frmMain.txtscale.value;	
		window.mapframe.document.forms["frmMap"].submit();		
	}
	else
	{
		if (document.getElementById("hid_lang").value!="ar")
			alert("Number must be a positive Integer.");
		else
			alert("يجب ان يكون الرقم عدد ايجابي");
	}
}
//**********************************************************************

//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;
	if (document.getElementById(prefixName + "hid_lang").value!="ar")
		window.open("legend.aspx?legendurl=" + window.mapframe.document.forms["frmMap"].hid_legendurl.value,"Legend",'width=250, height=350, scrollbars=yes','True');
	else
		window.open("legend_ar.aspx?legendurl=" + window.mapframe.document.forms["frmMap"].hid_legendurl.value,"Legend",'width=250, height=350, scrollbars=yes','True');
}
//**********************************************************************

//Hide measure Table from the map
function HideDiv()
{
	window.mapframe.document.getElementById("measurediv").style.visibility="hidden";
	//document.getElementById("tooltipdiv").style.visibility="hidden";
	window.mapframe.document.forms["frmMap"].hid_measurediv.value = "hidden";
}
//**********************************************************************


  //function hides measure box from the top left of the map
  function HideMeasure()
  {
	HideDiv();
	window.mapframe.document.forms["frmMap"].hid_measurediv.value = "hidden";
  }
  //**********************************************************************
  

//DoNothing is a function that does nothing
function DoNothing()
{	
	if (window.parent)		
		window.parent.focus();
}
//**********************************************************************

//CheckMapForm is a function that checks if map frame is loaded if yes it returns true else it returns false
function CheckMapForm()
{	
	if (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(e)
{
	if(isIE) e=event;
	var check = IsEnterPressed(e);
	if (check==true)
	{	
		ZoomToScale();
		DoNothing();
	}	
}


//Zooms to Mohafaza, Kadaa, Zone, Town
function ZoomToMunicipality(obj)
{

	var checked;
	checked= CheckMapForm();
	
	if (checked == false) return;
	
	
	var str=obj.value;
	
	if (str > 0)
	{
	   
		window.mapframe.document.forms["frmMap"].hid_action.value= "zoomtoMunicipality";
		
	    window.mapframe.document.forms["frmMap"].hid_ZoomInfo.value=  str;		
		ClearZoomLevels();
		window.mapframe.document.forms["frmMap"].submit();
	}
	else
	{
	//	if (document.getElementById("hid_lang").value=="en")
	//		alert("please select a community");
	//	else
	//		alert("الرجاء اختيار منطقة");
	}
}

//Zooms to Mohafaza, Kadaa, Zone, Town
function ZoomToBaldat(obj)
{

	var checked;
	checked= CheckMapForm();
	
	if (checked == false) return;
	
	
	var str=obj.value;
	
	if (str > 0)
	{
	   
		window.mapframe.document.forms["frmMap"].hid_action.value= "zoomtoBaldat";
		
	    window.mapframe.document.forms["frmMap"].hid_ZoomInfo.value=  str;		
		ClearZoomLevels();
		window.mapframe.document.forms["frmMap"].submit();
	}
	else
	{
	//	if (document.getElementById("hid_lang").value=="en")
	//		alert("please select a community");
	//	else
	//		alert("الرجاء اختيار منطقة");
	}
}

//Zooms to Mohafaza, Kadaa, Zone, Town
function ZoomToKadaa(obj)
{

	var checked;
	checked= CheckMapForm();
	
	if (checked == false) return;
	
	
	var str=obj.value;
	
	if (str > 0)
	{
	   
		window.mapframe.document.forms["frmMap"].hid_action.value= "zoomtoKadaa";
		
	    window.mapframe.document.forms["frmMap"].hid_ZoomInfo.value=  str;		
		ClearZoomLevels();
		window.mapframe.document.forms["frmMap"].submit();
	}
	else
	{
	//	if (document.getElementById("hid_lang").value=="en")
	//		alert("please select a community");
	//	else
	//		alert("الرجاء اختيار منطقة");
	}
}

//**********************************************************************