//--------------------
// Ahmed Saad Functions
//--------------------

// Show Hide Items 
var state = 'hidden';
var state1 = 'none';
function showhide(layer_ref) {
		if (state == 'visible') {
		state = 'hidden';
		state1= 'none';
		}
		else {
		state = 'visible';
		state1 = 'block';
		}
		if (document.all) { //IS IE 4 or 5 (or 6 beta)
		eval( "document.all." + layer_ref + ".style.visibility = state");
		eval( "document.all." + layer_ref + ".style.display = state1");
		
		}
		if (document.layers) { //IS NETSCAPE 4 or below
		document.layers[layer_ref].visibility = state;
		document.layers[layer_ref].display = state1;

		}
		if (document.getElementById && !document.all) {
		maxwell_smart = document.getElementById(layer_ref);
		maxwell_smart.style.visibility = state;
		maxwell_smart.style.display = state1;
		}

		}
//For Working area

function showhideWorking(CurState) {
		if (CurState == 'none') {
		CurState= 'block';
		}
		else {
		CurState = 'none';
		}
		if (document.all) { //IS IE 4 or 5 (or 6 beta)
			eval( "document.all.Working.style.display = CurState");
			}
		if (document.layers) { //IS NETSCAPE 4 or below
		document.layers["Working"].display = CurState;
		}
		if (document.getElementById && !document.all) {
		maxWorking = document.getElementById("Working");
		maxWorking.style.display = CurState;
		}
		}



function showhideInfor(TheElem) { // --------Show Hide Div By Sending The Name ; Ahmed Saad------
		
		if (document.all) { //IS IE 4 or 5 (or 6 beta)
			if (document.all(TheElem).style.display == "none"){
				eval( "document.all(TheElem).style.display = 'block'");
			} else {
				eval( "document.all(TheElem).style.display = 'none'");
			}
		}
		if (document.layers) { //IS NETSCAPE 4 or below
			if (document.layers[TheElem].display == "none"){
				document.layers[TheElem].display = "block";
			} else {
				document.layers[TheElem].display = "none";
			}
		}
		if (document.getElementById && !document.all) {
			maxWorking = document.getElementById(TheElem);
			if (maxWorking.style.display == "none"){
				maxWorking.style.display = "blcok";
				} else {
				maxWorking.style.display = "none";
			}
		}
	}

function ShowRemoteSplash(){
	top.main.MapForm.SplashIMG.style.display = 'block'
}

function ShowRemoteSplash_srch(){
	parent.window.opener.top.main.MapForm.SplashIMG.style.display = 'block'
}


//Navigation rollover
function NavIn(menItem) {
	menItem.style.cursor= 'hand';
}

function NavOut(menItem) {
}

function NavCat(menItem) {
	menItem.style.borderColor='#FFFFFF'; 
	menItem.style.backgroundColor='#FFFFFF';
}


function getFindIT(Val)
{ 
		ShowRemoteSplash()
		window.location ="LMaps.asp?Command=Find&MapSizeO=" + document.MapForm.MapSize.value + "&FLayer=km_lmark&Expr=" + Val;
}


function onPointXY(x, y)
	{}

function onZoomXY(x, y)
	{
		document.MapForm.map_x.value = x;
		document.MapForm.map_y.value = y;
		document.MapForm.submit();

		// Shbould be qualified only for ZoomIn, ZoomOut, and CenterAt
		//alert("AA")
		//ShowSplash();
	}

function onZoomBox(left, top, right, bottom)
	{
		document.MapForm.map_x.value = left;
		document.MapForm.map_y.value = top;
		document.MapForm.map_x2.value = right;
		document.MapForm.map_y2.value = bottom;
		document.MapForm.submit();
		ShowSplash();
	}

function OnButton(ButtonName)
	{	
		document.MapForm.Command.value = ButtonName;

		document.ZoomIn.src = "/buttons/in_up.gif";
		document.ZoomOut.src = "/buttons/out_up.gif";
		document.Pan.src = "/buttons/pan_up.gif";
		document.Id.src = "/buttons/id_up.gif";
		document.Map.src = "/buttons/Full_up.gif";
		//document.Add.src = "/buttons/Add_up.gif";  // --- Temp


		if (ButtonName == "ZoomIn")
		{	document.ZoomIn.src = "/buttons/in_dn.gif";
		}
		else if (ButtonName == "ZoomOut")
		{	document.ZoomOut.src = "/buttons/out_dn.gif";
		}
		else if (ButtonName == "Pan")
		{	document.Pan.src = "/buttons/pan_dn.gif";
		}
		else if (ButtonName == "Id")
		{	document.Id.src = "/buttons/id_dn.gif";
		}
		//else if (ButtonName == "StrPnt")
		//{	//document.StrPnt.src = "/buttons/Start_dn.gif";
		//}
		//else if (ButtonName == "EndPnt")
		//{	//document.EndPnt.src = "/buttons/End_dn.gif";
		//}
		else if (ButtonName == "Add")
		{	document.Add.src = "/buttons/Add_dn.gif";
			//parent.frames.contents.location="/inc/AddLoc1.asp";
			//parent.frames.contents.location ="Add_pnt.asp?MOD=ADD"			
		}

		else if (ButtonName == "Buffer")
		{	//document.Buffer.src = "/buttons/" + parent.frames.main.MapForm.evar.value + "Buffer_dn.gif";
			parent.frames.contents.location="/inc/Buffer.asp";
		}
		else if (ButtonName == "Find")
		{	//document.Find.src = "/buttons/Find_dn.gif";
			//document.MapForm.submit();
			//document.redirect = "LM_Search.asp"
		}
		else if (ButtonName == "Key")
		{	//document.Key.src = "/buttons/" + parent.frames.main.MapForm.evar.value + "Key_dn.gif";
			//showhide('LegendIMG');
			//parent.frames.contents.location="/inc/Legend.asp";
			document.MapForm.Command.value= "GETLEGEND"
			document.MapForm.submit();
		}
		else if (ButtonName == "Search")
		{	//document.Search.src = "/buttons/" + parent.frames.main.MapForm.evar.value + "Find_dn.gif";
			parent.frames.contents.location ="/inc/Search.asp?MOD=MAP";
			document.ZoomIn.src = "/buttons/in_dn.gif";document.MapForm.Command.value = "ZoomIn";
			//document.MapForm.submit();
		}
		else if (ButtonName == "Short")
		{	//document.Short.src = "/buttons/" + parent.frames.main.MapForm.evar.value + "Short_dn.gif";
			parent.frames.contents.location ="/inc/Short.asp";
			document.ZoomIn.src = "/buttons/in_dn.gif";document.MapForm.Command.value = "ZoomIn";
			//showhide('ShortPath');
			//document.MapForm.submit();
		}	
		else if (ButtonName == "Help")
		{	//document.Help.src = "/buttons/Help_dn.gif";
			popup('/help/help.html','Help');
			document.ZoomIn.src = "/buttons/in_dn.gif";document.MapForm.Command.value = "ZoomIn";
			//document.MapForm.submit();
		}
		else if (ButtonName == "Print")
		{	//document.Print.src = "/buttons/Print_dn.gif";
			parent.frames.contents.location="/inc/Print.asp?IMG=" + parent.frames.main.MapForm.mapimage.src + "&MSize=" + parent.frames.main.MapForm.MapSize.value;
			//bPrintSelected
		}
		else if (ButtonName == "Measure")
		{	//document.Measure.src = "/buttons/Measure_dn.gif";
			parent.frames.contents.location="/inc/Measure.asp";
		}

		else if (ButtonName == "Map")
		{
			document.MapForm.submit();
		}

	}


function popup(mylink, windowname,W,H) // PopU Window Function
{ 
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
	href=mylink;
	else
	href=mylink.href;
	
	window.open(href, windowname, 'resize=yes width=' + W + ',height=' + H + ',scrollbars=no');
	//return false; 
}

function popupa(mylink,Tit,W,H) // PopU Window Function
{ 
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
	href=mylink;
	else
	href=mylink.href;
	//href = href.replace( "/",  "Tt-");
	//alert(Tit)
	window.open("/inc/ShowPic.asp?Pic=" + mylink + "&Tit=" + Tit , "صورة", 'resize=no width=' + W + ',height=' + H + ',scrollbars=no' );
	//return false; 
}


function OnPop(CC)
{	
	return popup(CC, 'Search')
}


// Toggel Icons ----
	function ToggelOver(TheItem, Mmod)
	{
		if (Mmod == "over")
		{
			TheItem.src=TheItem.src.replace('_up','_ov');
			//TheItem.src=TheItem.src.replace('dn','ov');
		}
		else if (Mmod == "out")
		{
			TheItem.src=TheItem.src.replace('_ov','_up');
		}
		else if (Mmod == "down")
		{
			TheItem.src=TheItem.src.replace('_ov','_dn');
		}
	}


