
function PopOut(sURL,sTitle,iHeight,iWidth,ynScroll,ynResize) {
    var objWin;
    var tmpStr;

    tmpStr = "height=" + iHeight + ",width=" + iWidth + ",scrollbars=" + ynScroll + ",resizable=" + ynResize + "";
    objWin = window.open(sURL, sTitle, tmpStr);
    if (objWin.opener == null) objWin.opener = window;
    if (parseInt(navigator.appVersion) >=4) objWin.window.focus();
}


function setToolImage2(tool, mode) {

    var imageFile = '/images2/' + tool + mode + '.gif';

if (top.document.getElementById('ZOOMIN') && top.document.getElementById('ZOOMOUT') && top.document.getElementById('PAN')) {
    top.document.ZOOMIN.src = '/images2/zoomin1.gif';
    top.document.ZOOMOUT.src = '/images2/zoomout1.gif';
    top.document.PAN.src = '/images2/pan1.gif';
	}
    
if (top.document.getElementById('SELECTMULTI') && top.document.getElementById('SELECTINFO')) {
    top.document.SELECTMULTI.src = '/images2/selectmulti1.gif';
    top.document.SELECTINFO.src = '/images2/selectinfo1.gif';
	}


    if (tool.toUpperCase() == "ZOOMIN")
        top.document.ZOOMIN.src = imageFile;
    if (tool.toUpperCase() == "ZOOMOUT")
        top.document.ZOOMOUT.src = imageFile;
    if (tool.toUpperCase() == "PAN")
        top.document.PAN.src = imageFile;
    if (tool.toUpperCase() == "SELECTMULTI")
        top.document.SELECTMULTI.src = imageFile;
    if (tool.toUpperCase() == "SELECTINFO")
        top.document.SELECTINFO.src = imageFile;

		
}




function ProcessLink(sURL) {
  document.body.style.cursor = "wait";
  top.frames.map_main.location = sURL;
}

function sendClearSel() {
	showLayer("loadLayer");
	top.frames.map_main.location = 'map.asp?cmd=clear';
}

function sendClearDrawing() {
	showLayer("loadLayer");
	top.frames.map_main.location = 'map.asp?cmd=flush';
}

function sendZoomNext() {
	showLayer("loadLayer");
	top.frames.map_main.location = 'map.asp?cmd=zoomnext';
}

function sendZoomBack() {
	showLayer("loadLayer");
	top.frames.map_main.location = 'map.asp?cmd=zoomback';
}

function sendZoomCountryCode(CC) {
	showLayer("loadLayer");
	top.frames.map_main.location = 'map.asp?cmd=zoomCountry&cntr=' + CC.toString();
}

//center by user input coordinates
function sendLongLatCenter()
{
  var f = document.theCoordsForm;
  var xDeg, xMin=0, xSec=0, yDeg, yMin=0, ySec=0;
  var hemLong = f.longHemSel.value;
  var hemLat  = f.latHemSel.value;
  var splitedCoords;
  var i;
  var xSign, ySign;

  if ( hemLong == "E" ) xSign = 1; else xSign = -1;
  if ( hemLat  == "N" ) ySign = 1; else ySign = -1;
	xDeg = parseFloat( f.longValDeg.value );
	yDeg = parseFloat( f.latValDeg.value );
  if ( isNaN(xDeg) || isNaN(yDeg) )
  	alert('Please enter some values for both coordinates!');
  else
  {
	  if ( f.coordType=='DMS' ) //D M S
	  {
			xDeg = Math.ceil(xDeg);
			xMin = parseFloat( f.longValMin.value );
			xSec = parseFloat( f.longValSec.value );
			yDeg = Math.ceil(yDeg);
			yMin = parseFloat( f.latValMin.value );
			ySec = parseFloat( f.latValSec.value );
		  {
		  	if ( isNaN(xMin) ) xMin = 0; else if ( Math.abs(xMin-30) > 30 ) { alert("Improper longitude minutes value. Value is set to zero."); xMin = 0; }
		  	if ( isNaN(xSec) ) xSec = 0; else if ( Math.abs(xSec-30) > 30 ) { alert("Improper longitude seconds value. Value is set to zero."); xSec = 0; }
		  	if ( isNaN(yMin) ) yMin = 0; else if ( Math.abs(yMin-30) > 30 ) { alert("Improper latitude minutes value. Value is set to zero."); yMin = 0; }
		  	if ( isNaN(ySec) ) ySec = 0; else if ( Math.abs(ySec-30) > 30 ) { alert("Improper latitude seconds value. Value is set to zero."); ySec = 0; }
		  }
		}
		else //DD.DDDD
		{
	  	xMin = 0; xSec = 0; yMin = 0; ySec = 0;
		}
  	xDeg = xSign * (xDeg + xMin/60.0 + xSec/3600);
  	yDeg = ySign * (yDeg + yMin/60.0 + ySec/3600);
  	//alert( "xDeg = " + xDeg + "; yDeg=" + yDeg );
	  if ( Math.abs(xDeg) > 180 || Math.abs(yDeg) > 90 )
		{
	    if ( Math.abs(xDeg) > 180 ) alert('Longitude value (' + xDeg + ') is improper. Please correct it.');
	    if ( Math.abs(yDeg) > 90 )  alert('Latitude value (' + yDeg + ') is improper. Please correct it.');
		}
	  else 
		{
	    var newHref = "x=" + xDeg.toString() + "&y=" + yDeg.toString();
	    top.location = '/hub/index.asp?rid=0&tid=0&sid=0&cid=0&oid=0&vid=0&cmd=zoomLocation&' + newHref;
	  }
  }
}

//send user input coordinates to drawing engine
function sendLongLatPoint()
{
  var f = document.theCoordsForm;
  var xDeg, xMin=0, xSec=0, yDeg, yMin=0, ySec=0;
  var hemLong = f.longHemSel.value;
  var hemLat  = f.latHemSel.value;
  var splitedCoords;
  var i;
  var xSign, ySign;

  if ( hemLong == "E" ) xSign = 1; else xSign = -1;
  if ( hemLat  == "N" ) ySign = 1; else ySign = -1;
	xDeg = parseFloat( f.longValDeg.value );
	yDeg = parseFloat( f.latValDeg.value );
  if ( isNaN(xDeg) || isNaN(yDeg) )
  	alert('Please enter some values for both coordinates!');
  else
  {
	  if ( f.coordType[0].checked ) //D M S
	  {
			xDeg = Math.ceil(xDeg);
			xMin = parseFloat( f.longValMin.value );
			xSec = parseFloat( f.longValSec.value );
			yDeg = Math.ceil(yDeg);
			yMin = parseFloat( f.latValMin.value );
			ySec = parseFloat( f.latValSec.value );
		  {
		  	if ( isNaN(xMin) ) xMin = 0; else if ( Math.abs(xMin-30) > 30 ) { alert("Improper longitude minutes value. Value is set to zero."); xMin = 0; }
		  	if ( isNaN(xSec) ) xSec = 0; else if ( Math.abs(xSec-30) > 30 ) { alert("Improper longitude seconds value. Value is set to zero."); xSec = 0; }
		  	if ( isNaN(yMin) ) yMin = 0; else if ( Math.abs(yMin-30) > 30 ) { alert("Improper latitude minutes value. Value is set to zero."); yMin = 0; }
		  	if ( isNaN(ySec) ) ySec = 0; else if ( Math.abs(ySec-30) > 30 ) { alert("Improper latitude seconds value. Value is set to zero."); ySec = 0; }
		  }
		}
		else //DD.DDDD
		{
	  	xMin = 0; xSec = 0; yMin = 0; ySec = 0;
		}
  	xDeg = xSign * (xDeg + xMin/60.0 + xSec/3600);
  	yDeg = ySign * (yDeg + yMin/60.0 + ySec/3600);
  	state = top.document.getElementById('CurrentState').value;
	  if ( Math.abs(xDeg) > 180 || Math.abs(yDeg) > 90 )
		{
	    if ( Math.abs(xDeg) > 180 ) alert('Longitude value (' + xDeg + ') is improper. Please correct it.');
	    if ( Math.abs(yDeg) > 90 )  alert('Latitude value (' + yDeg + ') is improper. Please correct it.');
		}
	  else 
		{
		    var newHref = "&x=" + xDeg.toString() + "&y=" + yDeg.toString() + "&fn=2";
			if ( (state.toUpperCase() == "DRAWLINE") || (state.toUpperCase() == "DRAWPOLY") || (state.toUpperCase() == "DRAWPOINT") || (state.toUpperCase() == "DRAWTEXT") ) {
		    top.frames.map_main.location = "map.asp?Cmd="+ state + newHref;
			}
			else {
		    top.frames.map_main.location = "map.asp?Cmd=PLACEPOINT" + newHref;
			}
	  }
  }
}




//send user input coordinates to drawing engine
function sendLongLatCircle()
{
  var f = document.theCoordsForm;
  var xDeg, xMin=0, xSec=0, yDeg, yMin=0, ySec=0;
  var hemLong = f.longHemSel.value;
  var hemLat  = f.latHemSel.value;
  var Distance, DistanceUnit;
  var splitedCoords;
  var i;
  var xSign, ySign;

  if ( hemLong == "E" ) xSign = 1; else xSign = -1;
  if ( hemLat  == "N" ) ySign = 1; else ySign = -1;

	xDeg = parseFloat( f.longValDeg.value );
	yDeg = parseFloat( f.latValDeg.value );
	Distance = parseFloat( f.Distance.value );

	if ( f.DistanceUnit[0].checked ) { //KM 
	  DistanceUnit = 'KM';
	  }
	if ( f.DistanceUnit[1].checked ) { //MI
	  DistanceUnit = 'MI';
	  }

  if ( isNaN(xDeg) || isNaN(yDeg) || isNaN(Distance) )
  	alert('Please enter some values for both coordinates and Radius!');
  else
  {
	  if ( f.coordType[0].checked ) //D M S
	  {
			xDeg = Math.ceil(xDeg);
			xMin = parseFloat( f.longValMin.value );
			xSec = parseFloat( f.longValSec.value );
			yDeg = Math.ceil(yDeg);
			yMin = parseFloat( f.latValMin.value );
			ySec = parseFloat( f.latValSec.value );
		  {
		  	if ( isNaN(xMin) ) xMin = 0; else if ( Math.abs(xMin-30) > 30 ) { alert("Improper longitude minutes value. Value is set to zero."); xMin = 0; }
		  	if ( isNaN(xSec) ) xSec = 0; else if ( Math.abs(xSec-30) > 30 ) { alert("Improper longitude seconds value. Value is set to zero."); xSec = 0; }
		  	if ( isNaN(yMin) ) yMin = 0; else if ( Math.abs(yMin-30) > 30 ) { alert("Improper latitude minutes value. Value is set to zero."); yMin = 0; }
		  	if ( isNaN(ySec) ) ySec = 0; else if ( Math.abs(ySec-30) > 30 ) { alert("Improper latitude seconds value. Value is set to zero."); ySec = 0; }
		  }
		}
		else //DD.DDDD
		{
	  	xMin = 0; xSec = 0; yMin = 0; ySec = 0;
		}
  	xDeg = xSign * (xDeg + xMin/60.0 + xSec/3600);
  	yDeg = ySign * (yDeg + yMin/60.0 + ySec/3600);
  	state = top.document.getElementById('CurrentState').value;
	  if ( Math.abs(xDeg) > 180 || Math.abs(yDeg) > 90 )
		{
	    if ( Math.abs(xDeg) > 180 ) alert('Longitude value (' + xDeg + ') is improper. Please correct it.');
	    if ( Math.abs(yDeg) > 90 )  alert('Latitude value (' + yDeg + ') is improper. Please correct it.');
		}
	  else 
		{
		    var newHref = "&x=" + xDeg.toString() + "&y=" + yDeg.toString() + "&Distance=" + Distance + "&DistanceUnit=" + DistanceUnit + "&fn=2";
			showLayer("loadLayer");
		    top.frames.map_main.location = "map.asp?Cmd=PLACECIRCLE" + newHref;
	  }
  }
}



//send user input coordinates to drawing engine
function sendLongLatRect()
{
  var f = document.theCoordsForm;
  var xDeg, xMin=0, xSec=0, yDeg, yMin=0, ySec=0;
  var x2Deg, x2Min=0, x2Sec=0, y2Deg, y2Min=0, y2Sec=0;
  var hemLong = f.longHemSel.value;
  var hemLat  = f.latHemSel.value;
  var hemLong2 = f.longHemSel2.value;
  var hemLat2  = f.latHemSel2.value;
  var splitedCoords;
  var i;
  var xSign, ySign;
  var x2Sign, y2Sign;

  if ( hemLong == "E" ) xSign = 1; else xSign = -1;
  if ( hemLat  == "N" ) ySign = 1; else ySign = -1;
  if ( hemLong2 == "E" ) x2Sign = 1; else x2Sign = -1;
  if ( hemLat2  == "N" ) y2Sign = 1; else y2Sign = -1;

	xDeg = parseFloat( f.longValDeg.value );
	yDeg = parseFloat( f.latValDeg.value );
	x2Deg = parseFloat( f.longValDeg2.value );
	y2Deg = parseFloat( f.latValDeg2.value );

  if ( isNaN(xDeg) || isNaN(yDeg) || isNaN(x2Deg) || isNaN(y2Deg) )
  	alert('Please enter some values for both points!');
  else
  {
	  if ( f.coordType[0].checked ) //D M S
	  {
			xDeg = Math.ceil(xDeg);
			xMin = parseFloat( f.longValMin.value );
			xSec = parseFloat( f.longValSec.value );
			yDeg = Math.ceil(yDeg);
			yMin = parseFloat( f.latValMin.value );
			ySec = parseFloat( f.latValSec.value );

			x2Deg = Math.ceil(x2Deg);
			x2Min = parseFloat( f.longValMin2.value );
			x2Sec = parseFloat( f.longValSec2.value );
			y2Deg = Math.ceil(y2Deg);
			y2Min = parseFloat( f.latValMin2.value );
			y2Sec = parseFloat( f.latValSec2.value );
		  {
		  	if ( isNaN(xMin) ) xMin = 0; else if ( Math.abs(xMin-30) > 30 ) { alert("Improper longitude minutes value. Value is set to zero."); xMin = 0; }
		  	if ( isNaN(xSec) ) xSec = 0; else if ( Math.abs(xSec-30) > 30 ) { alert("Improper longitude seconds value. Value is set to zero."); xSec = 0; }
		  	if ( isNaN(yMin) ) yMin = 0; else if ( Math.abs(yMin-30) > 30 ) { alert("Improper latitude minutes value. Value is set to zero."); yMin = 0; }
		  	if ( isNaN(ySec) ) ySec = 0; else if ( Math.abs(ySec-30) > 30 ) { alert("Improper latitude seconds value. Value is set to zero."); ySec = 0; }

		  	if ( isNaN(x2Min) ) x2Min = 0; else if ( Math.abs(x2Min-30) > 30 ) { alert("Improper longitude minutes value. Value is set to zero."); x2Min = 0; }
		  	if ( isNaN(x2Sec) ) x2Sec = 0; else if ( Math.abs(x2Sec-30) > 30 ) { alert("Improper longitude seconds value. Value is set to zero."); x2Sec = 0; }
		  	if ( isNaN(y2Min) ) y2Min = 0; else if ( Math.abs(y2Min-30) > 30 ) { alert("Improper latitude minutes value. Value is set to zero."); y2Min = 0; }
		  	if ( isNaN(y2Sec) ) y2Sec = 0; else if ( Math.abs(y2Sec-30) > 30 ) { alert("Improper latitude seconds value. Value is set to zero."); y2Sec = 0; }
		  }
		}
		else //DD.DDDD
		{
	  	xMin = 0; xSec = 0; yMin = 0; ySec = 0;
	  	x2Min = 0; x2Sec = 0; y2Min = 0; y2Sec = 0;
		}
  	xDeg = xSign * (xDeg + xMin/60.0 + xSec/3600);
  	yDeg = ySign * (yDeg + yMin/60.0 + ySec/3600);
  	x2Deg = x2Sign * (x2Deg + x2Min/60.0 + x2Sec/3600);
  	y2Deg = y2Sign * (y2Deg + y2Min/60.0 + y2Sec/3600);
  	state = top.document.getElementById('CurrentState').value;
	  if ( Math.abs(xDeg) > 180 || Math.abs(yDeg) > 90 || Math.abs(x2Deg) > 180 || Math.abs(y2Deg) > 90 )
		{
	    if ( Math.abs(xDeg) > 180 ) alert('Longitude value (' + xDeg + ') is improper. Please correct it.');
	    if ( Math.abs(yDeg) > 90 )  alert('Latitude value (' + yDeg + ') is improper. Please correct it.');
	    if ( Math.abs(x2Deg) > 180 ) alert('Longitude value (' + x2Deg + ') is improper. Please correct it.');
	    if ( Math.abs(y2Deg) > 90 )  alert('Latitude value (' + y2Deg + ') is improper. Please correct it.');
		}
	  else 
		{
		    var newHref = "&x=" + xDeg.toString() + "&y=" + yDeg.toString() + "&x2=" + x2Deg.toString() + "&y2=" + y2Deg.toString() + "&fn=2";
			showLayer("loadLayer");
		    top.frames.map_main.location = "map.asp?Cmd=PLACERECT" + newHref;
	  }
  }
}




// enable minutes and seconds text input fields
function enableMinSecInput( isEnabled, BrowserMode )
{
  //var f = document.forms('theCoordsForm');
  //f.longValMin.disabled = !isEnabled;
  //f.longValSec.disabled = !isEnabled;
  //f.latValMin.disabled = !isEnabled;
  //f.latValSec.disabled = !isEnabled;
  if (BrowserMode.toUpperCase()=="A") {
  self.location = "input_coordinates.asp?sh=" + isEnabled.toString();
  }
  if (BrowserMode.toUpperCase()=="S") {
  self.location = "area_coordinates.asp?sh=" + isEnabled.toString();
  }
  return false;	
}


function setZoomHistory( zoomBack, zoomNext ) {

 top.document.getElementById('PREVIEW').src='/images2/preview_'+zoomBack+'.gif';
 top.document.getElementById('FORWARD').src='/images2/forward_'+zoomNext+'.gif';

if (zoomBack=='1') {
 top.document.getElementById('aPREVIEW').href="javascript:sendZoomBack();showLayer('loadLayer');";
}
else {
 top.document.getElementById('aPREVIEW').href="#";
}

if (zoomNext=='1') {
 top.document.getElementById('aFORWARD').href="javascript:sendZoomNext();showLayer('loadLayer');";
}
else {
 top.document.getElementById('aFORWARD').href="#";
}

}

function productLegend(visible) {
if (visible=='1') {
 top.document.getElementById('productLegend').innerHTML='<table cellpadding="0" cellspacing="0" border="0"><tr><td width="36" align="center"><img src="/graphix/spacer.gif" height="7" width="7" align="absmiddle" border="0" style="border: 1 solid #FFF; background: #BAEFC1;"></td><td style="color: #FFF;"><a style="color: #FFF;" target="details_space" href="legend_details.asp">Available</a></td><td width="36" align="center"><img src="/graphix/spacer.gif" height="7" width="7" align="absmiddle" border="0" style="border: 1 solid #FFF; background: #8DCCD7;"></td><td style="color: #FFF;"><a style="color: #FFF;" target="details_space" href="legend_details.asp">Please inquire</a></td><td width="36" align="center"><img src="/graphix/spacer.gif" height="7" width="7" align="absmiddle" border="0" style="border: 1 solid #FFF; background: #EEF6EF;"></td><td style="color: #FFF;"><a style="color: #FFF;" target="details_space" href="legend_details.asp">Not Available</a></td></tr></table>';
 top.document.getElementById('productLegend').style.cursor='Hand';
 top.document.getElementById('productLegend').title='Legend Details';
 }
 else {
 top.document.getElementById('productLegend').innerHTML='';
 top.document.getElementById('productLegend').style.cursor='Point';
 top.document.getElementById('productLegend').title='';
 }
}

function theSame(aTool) {

oldState = top.document.getElementById('CurrentState').value.toUpperCase();  

if (aTool.toUpperCase() == oldState) {
 proceedShow(iWidth,iHeight);
 top.document.location = '/hub/index.asp' + '?cmd=' + aTool + 'SAME&state=' + state;
}

}


