/**
 *  Writes and supports global javascript functions
 *  global.js
 *
 */

// refresh the page on resize in netscape

//function handleResize() {
//    location.href = location.href;
//    return false;

//}
//if ( document.layers ) {
//added version check 122701 because NN 4.0 versions go into continuous reload loop - GS
//added url text check 010702 because resize/reload of page after form submit causes error - GS
//var pageUrl = document.URL;
//if ((navigator.appName == "Netscape") &&
//(parseFloat(navigator.appVersion) > 4.1 ))
//{
//	window.captureEvents(Event.RESIZE);
//	if (pageUrl.indexOf("page")!=-1)
//	{
//    		
//    		window.onresize = handleResize;
//	}
//	else
//	{
//		window.onresize = userReload;	
//	}
//}
//function userReload() {
//alert('Please use your browser\'s Reload button to complete the page resize.');
//}
// Window Opening / Closing Functions 

function openChildWindow( appurl, windowname ) {
	var appwindow = window.open( appurl , windowname, "toolbar=yes,status=yes,top=10,left=10,outerWidth=790,outerHeight=500,width=790,height=500,scrollbars=yes,resizable=yes,menubar=yes");
	appwindow.focus();
}

function openLargePopup( url, windowname ) {
	var popup = window.open( url , windowname, "toolbar=no,status=yes,scrollbars=yes,menubar=no,locationbar=no,top=10,left=50,outerWidth=643,outerHeight=525,width=643,height=525,resizable=yes");
	popup.focus();
}

function openSmallPopup( popupurl, windowname ) {
	var popup = window.open( popupurl , windowname, "toolbar=no,status=yes,top=100,left=200,width=300,height=190,resizable=no");
	popup.focus();
}

function openWindow(theURL,winName,features) {
                
                var pixWindow = window.open(theURL,winName,features);
		pixWindow.focus(); 
        }

function closeWindow() {
	self.close();
}

function changeParentUrl( newurl ) {
	var openerClosed = false;
	if( document.all && !document.getElementById() ) {
		// opener.closed always returns false in IE ... makes sense, right?
		// let's roll our own function in VB, where we can trap errors...
		openerClosed = isOpenerClosed();
	} else {
		if( top.opener ) {
			openerClosed = top.opener.closed;
		} else {
			openerClosed = true;
		}
	}
	if( openerClosed ) {
		var newwin = window.open( newurl);
		newwin.focus();
	} else {
		top.opener.location.href = newurl;
		top.opener.focus();	
	}
}

// Creates a browser-generated alert or message box
// note:
// this was abstracted just in case we ever want to do anything
// with the string or send to non-pcs devices
function openMessage(str) {
	alert(str);
}

// Grabs a parameter from the URL.  Returns an empty
// string if parameter does not exist.
function getParameter(param) {

        var val = "";
        var qs = window.location.search;
        var start = qs.indexOf(param);

        if (start != -1) {
                start += param.length + 1;
                var end = qs.indexOf("&", start);
                if (end == -1) {
                        end = qs.length
                }
                val = qs.substring(start,end);
        }
        return val;
}

// Drop-down location.href redirection
function dropdown_redirect(select_name) {
	var theselect=eval(select_name);
	var tmp=theselect.selectedIndex;
	theselect.options[0].selected=true;
	location.href=theselect.options[tmp].value;
}

// Get the BaseTag, if specified in the current page
function get_baseTag() {
	var baseTag = "";
	if ( document.all ) {	
		var baseTagsCol = document.all.tags("BASE");
		if (baseTagsCol.length!=0){
			baseTag = baseTagsCol[0].href;
		}
/*	} else if (window.opera) {
		var baseTagsCol;
		alert(document.getElementByName('BASE').href) */
	}
	return baseTag;
}

// Drop-down location.href redirection
function dropdown_redirect(select_name,reset) {
	if (reset == null) { reset = true };
	var theselect=eval(select_name);
	var tmp=theselect.selectedIndex;
	if (reset) { theselect.options[0].selected=true; }
	if(theselect.options[tmp].value != "") {
		location.href=get_baseTag()+theselect.options[tmp].value;
	}
}
// Area drop-down redirection
var areanav_current = 0;
function set_areanav_current( index ) {
	// xsl position starts at 1, array index starts at 0
	areanav_current = index-1;
}
function areanav_redirect(select_name) {	
  var theselect=eval(select_name);
  var tmp=theselect.selectedIndex;
  if(theselect.options[tmp].value != "") {
	 theselect.options[areanav_current].selected=true;
	 location.href=get_baseTag()+theselect.options[tmp].value;
  }
}
