function layerSetClip() {	
	if (x1>x2) {
		zright=x1;
		zleft=x2;
	} else {
		zleft=x1;
		zright=x2;
	}
	if (y1>y2) {
		zbottom=y1;
		ztop=y2;
	} else {
		ztop=y1;
		zbottom=y2;
	}
	if ((x1 != x2) && (y1 != y2)) {
		layerClip("zoomBoxTop",zleft,ztop,zright,ztop+BoxSize);
		layerClip("zoomBoxLeft",zleft,ztop,zleft+BoxSize,zbottom);
		layerClip("zoomBoxRight",zright-BoxSize,ztop,zright,zbottom);
		layerClip("zoomBoxBottom",zleft,zbottom-BoxSize,zright,zbottom);
	}
}

// Create a DHTML layer
function layerCreate(name, ileft, itop, iwidth, iheight, visible, content) {
	  var layer;
	if (top.isNav4) {
		document.writeln('<layer name="' + name + '" left=' + ileft + ' top=' + itop + ' width=' + iwidth + ' height=' + iheight +  ' visibility=' + (visible ? '"show"' : '"hide"') +  '>');
		document.writeln(content);
		document.writeln('</layer>');
	} else {
		document.writeln('<div id="' + name + '" style="position:absolute; overflow:none; left:' + ileft + 'px; top:' + itop + 'px; width:' + iwidth + 'px; height:' + iheight + 'px;' + ' visibility:' + (visible ? 'visible;' : 'hidden;') +  '">');
		document.writeln(content);
		document.writeln('</div>');
	}
	  layerClip(name, 0, 0, iwidth, iheight);
}

// get the layer object called "name"
function layerGet(name) {
	if (top.isNav4) {
		return(document.layers[name]);
	} else if (top.isIE) {
		layer = eval('document.all.' + name + '.style');
		return(layer);
	} else if ((top.isNav) || (top.isNav6) ){
		var theElements = document.getElementsByTagName("div");
		var theObj;
		var j = -1;
		for (i=0;i<theElements.length;i++) {
			if (theElements[i].id==name) theObj = theElements[i].style;
		}
		return theObj;
	} else {
		return(null);
	}
}

// move layer to x,y
function layerMove(name, x, y) {
	var layer = layerGet(name);
	if (top.isNav4) {
		layer.moveTo(x,y);
	} else {
		layer.left = x;
		layer.top  = y;
		
	}
}

// set layer background color
function layerSetBackgroundColor(name, color) {		
	var layer = layerGet(name);
	if (top.isNav4) {
		layer.bgColor = color;
	} else {
		layer.backgroundColor = color;
	
	}
}



// toggle layer to invisible
function layerHide(name) {		
	IsLoadMapShowing = false;
	var layer = layerGet(name);
	if (top.isNav4) {
		layer.visibility = "hide";
	} else {
		layer.visibility = "hidden";
	}
}

// toggle layer to visible
function layerShow(name) {		
	IsLoadMapShowing = true;
	var layer = layerGet(name);
	if (top.isNav4) {
		layer.visibility = "show";
	} else {
		layer.visibility = "visible";
	}
}


// clip layer display to clipleft, cliptip, clipright, clipbottom
function layerClip(name, clipleft, cliptop, clipright, clipbottom) {		
	var layer = layerGet(name);
	if (top.isNav4) {
		layer.clip.top    = cliptop;
		layer.clip.left   = clipleft;
		layer.clip.right  = clipright;
		layer.clip.bottom = clipbottom;
	} else {
		layer.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
	}
}

// replace layer's content with new content
function layerReplaceContent(name, content) {

	if (top.isNav4) {
		var layer = layerGet(name);
		layer.document.open();
		layer.document.writeln(content);
		layer.document.close();
	} else if (top.isIE) {
		var str = "document.all." + name + ".innerHTML = '" + content + "'";
		eval(str);
	}
	else if (top.isNav6)
	{
		document.getElementById(name).innerHTML = content;
	}
}




// s = select
// sb = select box
// sl = select line
// sp = select polygon

var isAddSelected;
var uniqueID;

var stw;
var ssw;

//if (parent.toolbar)
//{
//var ActiveLayer = parent.toolbar.document.frm.layer_name.options[parent.toolbar.document.frm.layer_name.selectedIndex].value;
//}




function select_window_control(spatial_layer,l,thisdate)
{
	ssw = window.open('build_select_frameset.asp?spatial_layer=' + spatial_layer + '&l=' + l + '&d=' + thisdate ,'ssw','toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,copyhistory=no,screenX=0,screenY=0,top=0,left=0,scrollbars=no,width=600,height=500');					
}


//function select(e) 
//{
//	var lyr = //parent.MAP.stw.document.frm.layer_name.options[parent.MAP.stw.document.frm.layer_name.selectedIndex].//value;	
//	var uid = parent.MAP.stw.layerid[parent.MAP.stw.document.frm.layer_name.selectedIndex];	
//	parent.asp.location.href = //'select_click.asp?uniqueid='+uid+'&isSelect='+isAddSelected+'&l='+lyr+'&t=select&x1=' + mouseX + //'&y1=' + mouseY;
//	parent.MAP.layerShow('LoadMap');
//}

//function select_box(e) 
//{	
//	var lyr = //parent.MAP.stw.document.frm.layer_name.options[parent.MAP.stw.document.frm.layer_name.selectedIndex].//value;	
//	var uid = parent.MAP.stw.layerid[parent.MAP.stw.document.frm.layer_name.selectedIndex];	
//	parent.asp.location.href = //'select_box.asp?uniqueid='+uid+'&isSelect='+isAddSelected+'&l='+lyr+'&t=select_box&x1=' + x1 + '&y1=' //+ y1 + '&x2='+x2+'&y2=' +y2;
//	parent.MAP.layerShow('LoadMap');
//}

//function select_line(e) 
//{
//	var lyr = //parent.MAP.stw.document.frm.layer_name.options[parent.MAP.stw.document.frm.layer_name.selectedIndex].//value;	
//	var uid = parent.MAP.stw.layerid[parent.MAP.stw.document.frm.layer_name.selectedIndex];	
//	parent.asp.location.href = //'select_feature.asp?uniqueid='+uid+'&isSelect='+isAddSelected+'&l='+lyr+'&t=select_line&x1=' + mouseX //+ '&y1=' + mouseY;
//	parent.MAP.layerShow('LoadMap');
//}

//function select_poly(e) 
//{
//	var lyr = //parent.MAP.stw.document.frm.layer_name.options[parent.MAP.stw.document.frm.layer_name.selectedIndex].//value;	
//	var uid = parent.MAP.stw.layerid[parent.MAP.stw.document.frm.layer_name.selectedIndex];	
//	parent.asp.location.href = //'select_feature.asp?uniqueid='+uid+'&isSelect='+isAddSelected+'&l='+lyr+'&t=select_poly&x1=' + mouseX //+ '&y1=' + mouseY;
//	parent.MAP.layerShow('LoadMap');
//}

function selectClear() 
{
	parent.address.location='select.asp?action=clear';
}

function identify(e) {
parent.MAP.createWindow('select.asp?action=id&x1=' + mouseX + '&y1=' + mouseY + '&x2=0&y2=0','no','no','no','yes','yes','no',10,10,800,300,'query');
}

function view_image() {
parent.MAP.createWindow('view_image.asp?action=id&x1=' + mouseX + '&y1=' + mouseY + '&x2=0&y2=0','no','no','no','yes','yes','no',10,10,800,300,'query');
}
