﻿// JScript File
if (self.screen.width == 1152 & self.screen.height == 864)
 document.write("<link href=\"Style1152_864.css\" rel=\"stylesheet\" type=\"text/css\" />");
 else if (self.screen.width == 1024 & self.screen.height == 768)
 document.write("<link href=\"Style1024_768.css\" rel=\"stylesheet\" type=\"text/css\" />");
 else if (self.screen.width == 1280 & self.screen.height == 1024)
 document.write("<link href=\"Style1280_1024.css\" rel=\"stylesheet\" type=\"text/css\" />");
 else if (self.screen.width == 1600 & self.screen.height == 1200)
 document.write("<link href=\"Style1600_1200.css\" rel=\"stylesheet\" type=\"text/css\" />");
 else if (self.screen.width == 1680 & self.screen.height == 1050)
 document.write("<link href=\"Style1680_1050.css\" rel=\"stylesheet\" type=\"text/css\" />");
 else if (self.screen.width == 800 & self.screen.height == 600)
 document.write("<link href=\"Style800_600.css\" rel=\"stylesheet\" type=\"text/css\" />");
 else if (self.screen.width == 1280 & self.screen.height == 800)
 document.write("<link href=\"Style1280_800.css\" rel=\"stylesheet\" type=\"text/css\" />");
 else if (self.screen.width == 1440 & self.screen.height == 900)
 document.write("<link href=\"Style1440_900.css\" rel=\"stylesheet\" type=\"text/css\" />");
 else document.write("<link href=\"Style1024_768.css\" rel=\"stylesheet\" type=\"text/css\" />");
 
 /////////////////////////////////////////////////////
function foo()
{
    var o = window.event.srcElement;
    if (o.tagName == "INPUT" && o.type == "checkbox")
    {
        __doPostBack("","");
    } 
}

function DRAW(linex, liney, linex2, liney2)
{
//if (!stopDraw)
{   
//var t0 = (new Date()).getTime();
    jg2.setColor("#00ff00");
    jg2.setStroke(2);
    //jg2.setStroke(Stroke.DOTTED);
    jg2.drawLine(linex, liney, linex2, liney2);
    jg2.paint();
  //  var t1 = (new Date()).getTime() - t0;
}
}
function DRAWtempline(linex, liney, linex2, liney2)
{
//if (!stopDraw)
{    
    jg_templine.setColor("#00ff00");
    jg_templine.setStroke(2);
    //jg2.setStroke(Stroke.DOTTED);
    jg_templine.drawLine(linex, liney, linex2, liney2);
    jg_templine.paint();
  //  var t1 = (new Date()).getTime() - t0;
}
}
function DRAWellipse(x, y, w, h)
{
//if (!stopDraw)
{
    jg2.setColor("#FF0000");
    jg2.fillEllipse(x,y,w,h);
    jg2.paint();
}
}
function resetCounters()
{
    stopDraw = false;
    jg2.clear();
    jg_templine.clear();
    full_len = 0;
    len = 0;
   // document.MapForm.txbSquare.value = "";
    document.MapForm.TxbFullLen.value = "";
    document.MapForm.Txblen.value = "";
    XArray = new Array();
    YArray = new Array();
}
function ShowOwMap()
{
var x=document.MapForm.screen_X.value;
var y=document.MapForm.screen_Y.value;
var stringOwPath = "OwMap.aspx?x="+x+"&y="+y;
OwMap = window.open(stringOwPath, 'Default', config='top=50,left=550,status=1,height=150,width=200,scrollbars=0,resizable=1');
self.name="OwMap";
}
function ShowSearch()
{
Search = window.open('Search_new.aspx', 'Data', config='top,left=550,height=300,width=400,scrollbars=1,resizable=1');
self.name='Search_window';
}

function ShowLegend()
{
//Search = window.open('legend.htm', 'Data', config='top,left=150,height=300,width=400,scrollbars=0,resizable=0');
//self.name='Legend_window';
    var legend = document.getElementById('legDiv');
    if(legend.style.visibility == 'visible')
    {
        legend.style.visibility = 'hidden';
    }
    else
    {
        legend.style.visibility = 'visible';
    }

}
function ShowAdvancedSearch()
{
Search = window.open('Advanced_Search_new.aspx', 'Data', config='top,left=550,height=320,width=550,scrollbars=1,resizable=1');
self.name='Advanced_search_new';
Search.focus();
}
function ShowExport()
{
Export = window.open('Export.aspx', 'Data', config='top,left=550,height=300,width=400,scrollbars=1,resizable=1');
self.name='Export';
Export.focus();
}
function ShowReport()
{
Report = window.open('Report.aspx?Top='+document.MapForm.Top.value+'&Left='+document.MapForm.Left.value+'&Right='+document.MapForm.Right.value+'&Bottom='+document.MapForm.Bottom.value+'&Square='+document.MapForm.Square_value.value+'&FeatureID='+document.MapForm.featureid.value, '_blank', config='top,left=550,height=300,width=400, menubar=1, scrollbars=1,resizable=1');
self.name='Report';
Report.focus();
}
function ShowImportPoints1()
{
ShowImportPoints = window.open('ShowImportPoints.aspx', 'Data', config='top,left=550,height=300,width=400,scrollbars=1,resizable=1');
self.name='ShowImportPoints';
ShowImportPoints.focus();
}
///////////////////////////
function pan(dir)
{
if(dir == "left"){onPanTool(1 , document.MapForm.MapImage.height/2);}
if(dir == "top"){onPanTool(document.MapForm.MapImage.width/2, 1);}  
if(dir == "right"){onPanTool(document.MapForm.MapImage.width-1, document.MapForm.MapImage.height/2 );} 
if(dir == "bottom"){onPanTool(document.MapForm.MapImage.width/2, document.MapForm.MapImage.height-1);}
}
function onPanTool(X, Y)
{
    setXY(X, Y);
    sendCommand("PanCompas");
}
///////
function onZoomXY(x, y)
{
document.MapForm.map_x.value = x;
document.MapForm.map_y.value = y;
//sendCommand("ZoomIn");
document.MapForm.submit();
}

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;
//sendCommand("ZoomIn");
document.MapForm.submit();
}
 
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.TrackPolyline.src = "buttons/measure_up.gif";
	document.TrackPolygon.src = "buttons/area_up.gif";
	document.Point.src = "buttons/point_up.gif";
	document.SelectByRectangle.src = "buttons/select_by_rectangle_up.gif";
	document.Back.src = "buttons/back_up.gif";

	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 == "TrackPolyline")
	{
	    document.TrackPolyline.src = "buttons/measure_dn.gif";
	}
	else if (ButtonName == "TrackPolygon")
	{
	    document.TrackPolygon.src = "buttons/area_dn.gif";
	}	
	else if (ButtonName == "Point")
	{
	    document.Point.src = "buttons/point_dn.gif";
	}else if (ButtonName == "SelectByRectangle")
	{
	    document.SelectByRectangle.src = "buttons/select_by_rectangle_dn.gif";
	}else if (ButtonName == "Back")
	{
	    document.Back.src = "buttons/back_dn.gif";
	}
}
///////////////////////////////////////////////
function TB_OnDoubleClick(e)
{
	stopDraw = true;
		if (document.MapForm.Command.value.toUpperCase() == "TRACKPOLYLINE")	
			{
			    onPolylineTool(XArray, YArray);
			}
		else if (document.MapForm.Command.value.toUpperCase() == "TRACKPOLYGON")
			{
				Calc();
				onPolygonTool(XArray, YArray);		
			}
		else if (document.MapForm.Command.value.toUpperCase() == "POINT")
			{
			    onPointTool(XArray, YArray);
			}
					
	return false;	
}
function onPolylineTool(pointsX, pointsY)
{
	setXY(pointsX.join(";"), pointsY.join(";"));
	sendCommand("TrackPolyline");
}
function onPolygonTool(pointsX, pointsY)
{
	setXY(pointsX.join(";"), pointsY.join(";"));
	sendCommand("TrackPolygon");
}
function onPointTool(pointsX, pointsY)
{
    setXY(pointsX.join(";"), pointsY.join(";"));
    sendCommand("Point");
}
function setXY(x, y)
{
	document.MapForm.map_x.value = x;
	document.MapForm.map_y.value = y;
}
///////////////////////////////////////////

function ZoomAll()
{
    sendCommand("Map");
}
function onOverviewMapClick()
{
	sendCommand("OverviewMap");
}
function onRecord(layerName, featureID)
{
	document.MapForm.layername.value = layerName;	
	document.MapForm.featureid.value = featureID;	
	sendCommand("ZoomToFeature");
}
function sendCommand(command)
{
    
    document.MapForm.Command.value = command;
	//document.MapForm.TextBox1.value = document.MapForm.TxbFullLen.value;
	document.MapForm.submit();
	
}
function BackNavigate()
{
    document.Back.src = "buttons/back_dn.gif";
    window.history.back();
}
////////////////////////////////////////
function FP_swapImg() {//v1.0
 var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
 n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
 elm.$src=elm.src; elm.src=args[n+1]; } }
}

function FP_preloadImgs() {//v1.0
 var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
 for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}

function FP_getObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
 return null;
}

