function Win(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
var IE = document.all?true:false;

// Main function to retrieve mouse x-y pos.s
var topDivX = 1;
var topDivY = 1;
function findX(obj) { 
  var x = 0; 
	while (obj.offsetParent) { 
		x += obj.offsetLeft 
		obj = obj.offsetParent; 
	} 
	return(x)
} 
function findY(obj) { 
  var y = 0; 
	while (obj.offsetParent) { 
		y += obj.offsetTop 
		obj = obj.offsetParent; 
	} 
	return (y)
} 

//DivTownText
function moveTownTo(x, y) {
  if (document.getElementById) {
    document.getElementById('DivTownText').style.left = x;
    document.getElementById('DivTownText').style.top = y;
  }
}
function moveDotTo(x, y) {
  if (document.getElementById) {
    document.getElementById('DivTownDot').style.left = x;
    document.getElementById('DivTownDot').style.top = y;
  }
}

function getMouseTownXY(e) {
  delta = (window.document.body.clientWidth - 955)/2;
  topDivX = findX(document.all.map_layer);
  topDivY = findY(document.all.map_layer);  //alert ("topDivX(" + topDivX + ") topDivY(" + topDivY + ")");
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.documentElement.scrollLeft-topDivX  // topDivX is balise <left> of main <div>
    tempY = event.clientY + document.documentElement.scrollTop-topDivY  // topDivY is balise <top> of main <div>
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX-topDivX 
    tempY = e.pageY-topDivY 
  } 
  tempX+=3   // so that when click >>> il's on main layer >>> otherwise not detected !!!
  tempY+=3   
  if (tempX < 0){tempX = 0} // catch possible negative values in NS4
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show in the text fields named ShowX. and ShowY
  document.OutStation_edit.ShowTX.value = tempX
  document.OutStation_edit.ShowTY.value = tempY
//  document.OutStation_edit.ShowTX.value = tempX
//  document.OutStation_edit.ShowTY.value = tempY
  moveTownTo (tempX+topDivX-delta , tempY+topDivY);//-13
  return true
}
function StartGetTownXY() {
  document.all.DivTownText.style.visibility = "visible";
  document.all.DivTownText.innerHTML = document.all.txtCityName.value;
  document.getElementById("txtHelpSetPos").value = "Click on map below to set position";
  
  document.OutStation_edit.RecData.disabled = true;//OutStation_edit
// If NS -- that is, !IE -- then set up for mouse capture
  if (!IE) document.captureEvents(Event.MOUSEMOVE)
// Set-up to use getMouseXY function onMouseMove
//alert (document.getElementById("Rarea1").checked);

  document.all.map_layer.onmousemove = getMouseTownXY;
  document.all.map_layer.onclick = StoptGetTownXY;

  document.all.DivTownText.onmousemove = getMouseTownXY;
  document.all.DivTownText.onclick = StoptGetTownXY;
// Temporary variables to hold mouse x-y pos.s
  var tempX = 0
  var tempY = 0
}
function StoptGetTownXY() {
  document.all.map_layer.onmousemove = null;
  document.all.map_layer.onclick = null;
  document.getElementById("txtHelpSetPos").value = "New coordinate OK";
  document.OutStation_edit.RecData.disabled = false;//OutStation_edit
  document.all.DivTownText.onmousemove = null;
  document.all.DivTownText.onclick = null;
  
}
// mouse hanling for dot
function StartGetXY() {
  document.all.DivTownDot.style.visibility = "visible";
  document.getElementById("txtHelpSetPos").value = "Click on map below to set position";
  document.OutStation_edit.RecData.disabled = true;//OutStation_edit
// If NS -- that is, !IE -- then set up for mouse capture
  if (!IE) document.captureEvents(Event.MOUSEMOVE)
// Set-up to use getMouseXY function onMouseMove
    document.all.map_layer.onmousemove = getMouseXY;
    document.all.map_layer.onclick = StoptGetXY;

/*topDivX = document.all.map_layer.style.left;
topDivY = document.all.map_layer.style.top;
topDivX = document.body.scrollTop;
topDivY = document.body.scrollLeft;*/

//  document.all.DivTownText.onmousemove = getMouseXY;
//  document.all.DivTownText.onclick = StoptGetXY;
 // Temporary variables to hold mouse x-y pos.s
  var tempX = 0
  var tempY = 0
}

function StoptGetXY() {
  document.all.map_layer.onmousemove = null;
  document.all.map_layer.onclick = null;
  document.getElementById("txtHelpSetPos").value = "New coordinate OK";
  document.OutStation_edit.RecData.disabled = false;//OutStation_edit
//  document.all.DivTownText.onmousemove = null;
//  document.all.DivTownText.onclick = null;  
}

function getMouseXY(e) {
  delta = (window.document.body.clientWidth - 955)/2;
  topDivX = findX(document.all.map_layer);
  topDivY = findY(document.all.map_layer);  //alert ("topDivX(" + topDivX + ") topDivY(" + topDivY + ")");
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.documentElement.scrollLeft - topDivX  // topDivX is balise <left> of main <div>
    tempY = event.clientY + document.documentElement.scrollTop - topDivY  // topDivY is balise <top> of main <div>
    document.getElementById("txtHelpSetPos").value = "delta:" + delta + " / clX:" + event.clientX + " scrL:" + document.documentElement.scrollLeft + 
	     " Ofs:" + document.all.map_layer.offsetLeft + " / clY:" + event.clientY + " scrL:" + document.documentElement.scrollTop + 
													" Ofs:" + document.all.map_layer.offsetTop 
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX-topDivX 
    tempY = e.pageY-topDivY 
  }  
  if (tempX < 0){tempX = 0} // catch possible negative values in NS4
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show in the text fields named ShowX. and ShowY
  document.OutStation_edit.ShowX.value = tempX;//
  document.OutStation_edit.ShowY.value = tempY;//
  moveDotTo(tempX+topDivX-delta-5 , tempY+topDivY-5)
  return true
}
function activArea2(aId) {
//alert (document.getElementById('Rarea7').value);
  document.getElementById(aId).checked = true;
//document.all.Rarea2.value=true
}
function Verif(f) {
  arr = document.getElementsByName('OffType');
  res = false;
  for (ii=0;ii<arr.length;ii++){//    alert (arr[ii].name+"/"+arr[ii].checked);
	res = res || arr[ii].checked		
  }
  if (!res) { alert ('Please select the office type (Office, GHA, GSA ...)')
    return false;
  }
  return true;
}

//-->

