// JavaScript for controlling the Flash map overlay
// Define some vars for the different browsers

isIE = document.all;
isNN = !document.all&&document.getElementById;
isN4 = document.layers;
layerHot = false;

// ddInit function is invoked when the user clicks the mouse in the titlebar
// to begin the drag. 
// e is defines to be window.event
function dragInit(e){  
	topDoc = (isIE) ? "BODY" : "HTML";
  whichDoc = (isIE) ? document.all.mapeditbox : document.getElementById("mapeditbox");  
  hotDoc = (isIE) ? event.srcElement : e.target; 
	
	// loop through the srcElements below the BODY and find the correct titlebar Element 
  while (hotDoc.id!="titleBar"&&hotDoc.tagName!=topDoc){
    hotDoc = (isIE) ? hotDoc.parentElement : hotDoc.parentNode;
  }  
  if (hotDoc.id=="titleBar"){
		// if we found a titlebar then save the cursor offset within the element 
    offsetx = (isIE) ? event.clientX : e.clientX;
    offsety = (isIE) ? event.clientY : e.clientY;
		// now save the position of the top/left corner of the element
    nowX = parseInt(whichDoc.style.left);
    nowY = parseInt(whichDoc.style.top);
   // allow the drag operation to take place
    dragEnabled=true;
		// define the function for the mouse movement
    document.onmousemove=drag;
  }
}

// This function is invoked when the mouse moves
function drag(e){ 
	if (!dragEnabled) return; // Out of here if we haven't enabled drag operations
	// move the element to the new mouse coodinates
	// event.clientX/Y is the new position if the mouse
  whichDoc.style.left = (isIE) ? nowX + event.clientX - offsetx : nowX + e.clientX - offsetx; 
  whichDoc.style.top = (isIE) ? nowY + event.clientY - offsety : nowY + e.clientY - offsety;
  return false;  
}

function dragN4(whatDoc){
  if (!isN4) return;
  N4=eval(whatDoc);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (hotDoc){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  if (isIE||isNN) whichDoc.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}

function showMe(){
  if (isIE||isNN) whichDoc.style.visibility="visible";
  else if (isN4) document.theLayer.visibility="show";
}
function chgImage(refName){
	imgcache.src = refName + "?" + Date.parse(new Date().toString());
}

function refreshImage (imgFile) {   
	 imgcache.src = "images/refresh_splash.gif";
	 tstr = "chgImage('"+imgFile+"');";
	 setTimeout(tstr,3000);	 
}

function showMap(){	  
	showMe ();
}



