// onmouseenter/leave for IE4+, Netscape 6+, Opera 7 divs


function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

function checkMouseEnter (element, evt) {
  if (element.contains && evt.fromElement) {
    return !element.contains(evt.fromElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

function checkMouseLeave (element, evt) {
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}





// begin menu functions
var cm=null;
//document.onclick = new Function("show(null)")
function getPos(el,sProp) {
	var iPos = 0
	while (el!=null) {
		iPos+=el["offset" + sProp]
		el = el.offsetParent
	}
	return iPos

}

function show(el,m) {
	if (m) {
		m.style.display='';
		m.style.pixelLeft = getPos(el,"Left")
		m.style.pixelTop = getPos(el,"Top") + el.offsetHeight
	}
	if ((m!=cm) && (cm)) cm.style.display='none'
	cm=m
}


function hideCheck(what, event) // requires onmouseenterleave functions (above)
{
if (checkMouseLeave(what, event)) 
	{
	hide();
	}
}


function hide()
{
if(cm != null)
	{
	cm.style.display='none'
	}
}



// end menu functions

function startup()
{
preloadImages();
}



function preloadImages() {
	var img = new Array(
		'nav_blank'
	);
	
	var endings = new Array (
        '_off',
        '_on',
	'_over'
	);
	
	for (var i=0; i<img.length; i++) {
		for (var j=0; j<endings.length; j++) {
			var statement = "document." + img[i] + endings[j] + " = new Object()";
			var result = eval(statement);
			statement = "document." + img[i] + endings[j] + ".src = urlPrefix + 'images/" + img[i] + endings[j] + ".gif'";
			result = eval(statement);
		}
	}
}

function promptStatus (s)
{   window.status = s
}


//-- popup with screen centering

var popWindow;

function winTopCtr(mypage)
{
var vLength = arguments.length;
var vURL;

// set default values for each of the following vars
var vWidth = "900";
var vHeight = "500";
var vToolbar = "no";
var vLocation = "no";
var vStatus = "yes";
var vResize = "yes";
var vScroll = "yes";

var vName = "TopWindow";

for (var i = 0; i<vLength; i++)
  {
  switch (i)
    {
    case 0:
       vURL = arguments[i];
       break;
    case 1:
       vName = arguments[i];
       break;
    case 2:
       vWidth = arguments[i];
       break;
    case 3:
       vHeight = arguments[i];
       break;
    case 4:
       vToolbar = arguments[i];
       break;
    case 5:
       vLocation = arguments[i];
       break;
    case 6:
       vStatus = arguments[i];
       break;
    case 7:
       vResuze = arguments[i];
       break;
    case 8:
       vScroll = arguments[i];
       break;
    default:
       alert("this is an error");
       break;
    }
  }

  var winl = (screen.width-vWidth)/2;
  if (winl<0) winl = 0;
  var wint = (screen.height-vHeight)/2 -100;
  if(wint<0) wint = 0;

  var settings  ='height='+vHeight+',';
      settings +='width='+vWidth+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+vScroll+',';
      settings +='resizable=' + vResize +',';
	settings +='toolbar=' + vToolbar + ',';
	settings += 'location=' + vLocation +',';
	settings += 'status=' + vStatus + ',';
	settings += 'menubar=no';



if(popWindow!=null)
	{
	// it has already been defined
	if(!popWindow.closed)
		{
		//still open
		popWindow.close();
		}
	}
var title = "AUSD Map"
popWindow=window.open('',vName, settings);    
popWindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body> <center>');
popWindow.document.writeln('<img src=' + vURL + ' title=\"' + title + '\" alt=\"' + title + '\" >');
popWindow.document.writeln('<\/center>');
popWindow.document.writeln('<iframe id="RSIFrame" name="RSIFrame" style="width:0px; height:0px; border: 0px" src="mapGif.htm"></iframe>')
popWindow.document.writeln('<\/body> <\/html>');
popWindow.document.close();



if(parseInt(navigator.appVersion) >= 4)
     {
     //window.setTimeout('popWindow.focus()',3000);
     if(window.focus){popWindow.focus()}
     }

return 
}



/**************************************************

PopUp DocViewer
- opens document inside a popup browser window
(granted appropriate software/plugin is installed)

(c) 2003 Glenn G. Vergara
http://www21.brinkster.com/gver/
glenngv[at]yahoo[dot]com

MS Office documents open inside IE (.doc, .xls, .ppt)
Acrobat documents open inside IE, Netscape4 and Netscape6 (.pdf)
Shockwave files open inside IE and Netscape6 (.swf)
*************************************************/

function openDoc(filename,target,windowTitle){
//to ensure no global variable conflict with other script
//var strWinHandle = target + "objDocWin"; 
var strWinHandle = target; 

//just focus to the corresponding window if it is already open
if (window[strWinHandle] && !window[strWinHandle].closed){
//window[strWinHandle].focus();
//return false;
window[strWinHandle].close();
}

//open blank page
window[strWinHandle] = window.open('',target,'menubar=1,location=0,toolbar=0,resizable=1,status=0');

//change window name (target); later, target will be used as frame name
window[strWinHandle].name = strWinHandle; 

//create frameset with only 1 frame 
var strHTML = '<html>\r\n<head>\r\n';
//window title defaults to filename if not specified
var winTitle = (windowTitle) ? windowTitle:filename.substring(filename.lastIndexOf("/")+1);
strHTML += '<title>'+winTitle+'</title>\r\n';
strHTML += '</head>\r\n';
strHTML += '<frameset onload="window.focus()" rows="0,*" border="0" frameborder="0" framespacing="0">\r\n';
strHTML += '<frame name="mappdf" src="mappdf.htm">\r\n'; //hidden frame for counter
strHTML += '<frame name="'+target+'" src="about:blank">\r\n'; //set target as frame name
strHTML += '</frameset>\r\n';
strHTML += '</html>';
window[strWinHandle].document.write(strHTML);
window[strWinHandle].document.close();

//put a little delay; Netscape6 causes a null document object when called directly
setTimeout('loadDoc("'+strWinHandle+'","'+target+'","'+filename+'")',0);

return false; //this cancels href of the calling link
}

function loadDoc(strWinHandle,target,filename){
//Flash the 'Loading...' message
var strHTML = '<html>\n<head>\n<title></title>\n';
strHTML += '<style type="text/css">\nbody{margin:20px 0px 0px 0px;}\n#container{width:100%;text-align:center;font-family:Arial,Tahoma,Verdana}\n#status{font-weight:bold;font-size:14px;color:red;width:100%;}\n#alternative{font-size:11px;color:gray;width:100%;}\n</style>';
strHTML += '</head>\n<body>';
strHTML += '<div id="container">\n<div id="status">Loading...Please wait.</div>\n';
//provide link to close window (for browsers with no appropriate plugin for the needed software)
strHTML += '<div id="alternative">If you do not have the needed software/plugin to launch the document inside the browser, please <a href="#" onclick="top.close();return false;">close</a> this window.</div>\n</div>';
strHTML += '</body>\n</html>';
var winDocFrame = window[strWinHandle].frames[target];
winDocFrame.document.write(strHTML); //winDocFrame.document is null in Netscape6 if called directly
winDocFrame.document.close();

//preload the document
var doc = new Image();
doc.onerror = function(){
//check window if still open, the user might have closed it
if (window[strWinHandle] && !window[strWinHandle].closed){
winDocFrame.location.replace(this.src); //finally, set frameset's location to the document filename
}
}
doc.src = filename; //onerror handler fires since image src is not actually an image
}

/***********
Sample calls: 

for anchor links: 
(backward compatible since if javascript is disabled, the document will still be opened in a new window)
(each link must have different target, target must not have spaces and other special characters except underscore)

<a href="docs/file.pdf" target="_pdf" onlick="return openDoc(this.href,this.target,this.title)" title="This is document 1">doc 1</a>
<a href="docs/file2.pdf" target="_pdf2" onlick="return openDoc(this.href,this.target,this.title)" title="This is document 2">doc 2</a>

for buttons:
<input type="button" value="Open doc 1" onclick="openDoc('docs/file.pdf','_pdf','Acrobat File 1')">
<input type="button" value="Open doc2" onclick="openDoc('docs/file2.pdf','_pdf2','Acrobat File 2')">

for onload popups:

<body onload="openDoc('docs/file.swf','_swf','My ShockWave File')">

***********/





