
/*******************************************************************************
* GLOBAL VARAIBLES 
*******************************************************************************/

popupBlockWarningMessage = "You are possibly using a window popup blocking software.\nPlease enable window popup for this site.";

//self.onerror = function() {return true;}

// convert all characters to lowercase to simplify testing
var agt = navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();

// ############################################################################
// *** BROWSER VERSION ***
// ############################################################################

var is_minor = parseFloat(appVer);
var is_major = parseInt(is_minor);

var is_opera = (agt.indexOf("opera") != -1);
var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
var is_opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1);
var is_opera7 = (agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1);
var is_opera8 = (agt.indexOf("opera 8") != -1 || agt.indexOf("opera/8") != -1);
var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);
var is_opera6up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5);
var is_opera7up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5 && !is_opera6);
var is_opera7up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5 && !is_opera6 && !is_opera7);


// Note: On IE, start of appVersion return 3 or 4
// which supposedly is_ the version of Netscape it is_ compatible with.
// So we look for the real version further on in the string
// And on Mac IE5+, we look for is_minor in the ua; since 
// it appears to be more accurate than appVersion.
var is_mac = (agt.indexOf("mac")!=-1);
var iePos  = appVer.indexOf('msie');
if (iePos !=-1) {
   if(is_mac) {
       var iePos = agt.indexOf('msie');
       is_minor = parseFloat(agt.substring(iePos+5,agt.indexOf(';',iePos)));
   }
   else is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
   is_major = parseInt(is_minor);
}


// The same for konqueror                                
var is_konq = false;
var kqPos   = agt.indexOf('konqueror');
if (kqPos !=-1) {                 
   is_konq  = true;
   is_minor = parseFloat(agt.substring(kqPos+10,agt.indexOf(';',kqPos)));
   is_major = parseInt(is_minor);
}                                 

var is_getElementById   = (document.getElementById) ? true : false;
var is_getElementsByTagName = (document.getElementsByTagName) ? true : false;
var is_documentElement = (document.documentElement) ? true : false;

// cant have the mac check here cause we might be on windows  && (agt.indexOf('mac')!=-1)
var is_safari = (agt.indexOf('safari')!=-1) ? true : false;

/* added by Steve Dawson on 9/28/2005 */
/* based on http://developer.apple.com/internet/safari/faq.html#anchor2 */
/* used to determine if we are running safari 1.2 or up */
if (is_safari) {
	var kitName = "applewebkit/";
	var tempStr = navigator.userAgent.toLowerCase();
	var pos = tempStr.indexOf(kitName);
	var isAppleWebkit = (pos != -1);
	if (isAppleWebkit) {
		// grab the version
		var kitVersion = tempStr.substring(pos + kitName.length,tempStr.length);
		kitVersion = kitVersion.substring(0,kitVersion.indexOf(" "));
		// strip any decimals
		if (kitVersion.indexOf(".") != -1) {
			kitVersion = kitVersion.substring(0,kitVersion.indexOf("."));
		}
		if (kitVersion >= 125) {
			is_safari12up = true;
		} else {
			is_safari12up = false;
		}
	} else {
		// all safari browsers should have the applewebkit UA string - this should never happen
		is_safari12up = false;
	}
}

var is_khtml  = (is_safari || is_konq);

var is_gecko = ((!is_khtml)&&(navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;
var is_gver  = 0;
if (is_gecko) is_gver=navigator.productSub;

var is_moz   = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                (is_gecko) && 
                ((navigator.vendor=="")||(navigator.vendor=="Mozilla")||(navigator.vendor=="Debian")));
var is_fb = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
             (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
             (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
             (is_gecko) && (navigator.vendor=="Firebird"));
var is_fx = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
             (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
             (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
             (is_gecko) && (navigator.vendor=="Firefox"));
if ((is_moz)||(is_fb)||(is_fx)) {  // 032504 - dmr
   var is_moz_ver = (navigator.vendorSub)?navigator.vendorSub:0;
   if(!(is_moz_ver)) {
       is_moz_ver = agt.indexOf('rv:');
       is_moz_ver = agt.substring(is_moz_ver+3);
       is_paren   = is_moz_ver.indexOf(')');
       is_moz_ver = is_moz_ver.substring(0,is_paren);
   }
   is_minor = is_moz_ver;
   is_major = parseInt(is_moz_ver);
}
   var is_fb_ver = is_moz_ver;
   var is_fx_ver = is_moz_ver;

var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
            && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)
            && (!is_khtml) && (!(is_moz)) && (!is_fb) && (!is_fx));

// Netscape6 is_ mozilla/5 + Netscape6/6.0!!!
// Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0
// Changed this_ to use navigator.vendor/vendorSub
if ((navigator.vendor)&&
    ((navigator.vendor=="Netscape6")||(navigator.vendor=="Netscape"))&&
    (is_nav)) {
   is_major = parseInt(navigator.vendorSub);
   // here we need is_minor as a valid float for testing. We'll
   // revert to the actual content before printing the result. 
   is_minor = parseFloat(navigator.vendorSub);
}

var is_nav2 = (is_nav && (is_major == 2));
var is_nav3 = (is_nav && (is_major == 3));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && is_minor >= 4);  // changed to is_minor for consis_tency
var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)) );

var is_nav6   = (is_nav && is_major==6);
var is_nav6up = (is_nav && is_minor >= 6);

var is_nav5   = (is_nav && is_major == 5 && !is_nav6);
var is_nav5up = (is_nav && is_minor >= 5);

var is_nav7   = (is_nav && is_major == 7);
var is_nav7up = (is_nav && is_minor >= 7);

var is_nav8   = (is_nav && is_major == 8);
var is_nav8up = (is_nav && is_minor >= 8);

var is_ie   = ((iePos!=-1) && (!is_opera) && (!is_khtml));
var is_ie3  = (is_ie && (is_major < 4));

var is_ie4   = (is_ie && is_major == 4);
var is_ie4up = (is_ie && is_minor >= 4);
var is_ie5   = (is_ie && is_major == 5);
var is_ie5up = (is_ie && is_minor >= 5);

var is_ie5_5  = (is_ie && (agt.indexOf("msie 5.5") !=-1));
var is_ie5_5up =(is_ie && is_minor >= 5.5);
	
var is_ie6   = (is_ie && is_major == 6);
var is_ie6up = (is_ie && is_minor >= 6);

// KNOWN BUG: On AOL4, returns false if IE3 is_ embedded browser
// or if this_ is_ the first browser window opened.  Thus the
// variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.

var is_aol   = (agt.indexOf("aol") != -1);
var is_aol3  = (is_aol && is_ie3);
var is_aol4  = (is_aol && is_ie4);
var is_aol5  = (agt.indexOf("aol 5") != -1);
var is_aol6  = (agt.indexOf("aol 6") != -1);
var is_aol7  = ((agt.indexOf("aol 7")!=-1) || (agt.indexOf("aol7")!=-1));
var is_aol8  = ((agt.indexOf("aol 8")!=-1) || (agt.indexOf("aol8")!=-1));

var is_webtv = (agt.indexOf("webtv") != -1);


var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
var is_AOLTV = is_TVNavigator;

var is_hotjava = (agt.indexOf("hotjava") != -1);
var is_hotjava3 = (is_hotjava && (is_major == 3));
var is_hotjava3up = (is_hotjava && (is_major >= 3));
	

	
// ############################################################################
// *** JAVASCRIPT VERSION CHECK ***
// ############################################################################

// Useful to workaround Nav3 bug in which Nav3
// loads <SCRIPT LANGUAGE="JavaScript1.2">.
var is_js;
if (is_nav2 || is_ie3) is_js = 1.0;
else if (is_nav3) is_js = 1.1;
else if ((is_opera5)||(is_opera6)) is_js = 1.3;
else if (is_opera7up) is_js = 1.5;
else if (is_khtml) is_js = 1.5;
else if (is_opera) is_js = 1.1;
else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2;
else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3;
else if (is_nav5 && !(is_nav6)) is_js = 1.4;
else if (is_hotjava3up) is_js = 1.4;
else if (is_nav6up) is_js = 1.5;

// NOTE: In the future, update this_ code when newer versions of JS
// are released. For now, we try to provide some upward compatibility
// so that future versions of Nav and IE will show they are at
// *least* JS 1.x capable. Always check for JS version compatibility
// with > or >=.

else if (is_nav && (is_major > 5)) is_js = 1.4;
else if (is_ie && (is_major > 5)) is_js = 1.3;
else if (is_moz) is_js = 1.5;
else if (is_fb||is_fx) is_js = 1.5;

// HACK: no idea for other browsers; always check for JS version 
// with > or >=
else is_js = 0.0;
// HACK FOR IE5 MAC = js vers = 1.4 (if put inside if/else jumps out at 1.3)
if ((agt.indexOf("mac")!=-1) && is_ie5up) is_js = 1.4; // 020128 - abk

// Done with is_minor testing; revert to real for N6/7
if (is_nav6up) {
   is_minor = navigator.vendorSub;
}



// ############################################################################
// *** PLATFORM ***
// ############################################################################

var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
// NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
//        Win32, so you can't dis_tinguis_h between Win95 and WinNT.
var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

// is_ this_ a 16 bit compiled version?
var is_win16 = ((agt.indexOf("win16")!=-1) ||
           (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) ||
           (agt.indexOf("windows 16-bit")!=-1) );

var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                (agt.indexOf("windows 16-bit")!=-1));
	
	var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));    // new 020128 - abk
var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1) || (agt.indexOf("windows 2000")!=-1)); // 020214 - dmr
var is_winxp = ((agt.indexOf("windows nt 5.1")!=-1) || (agt.indexOf("windows xp")!=-1)); // 020214 - dmr

// NOTE: Reliable detection of Win98 may not be possible. It appears that:
//       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
//       - On Mercury client, the 32-bit version will return "Win98", but
//         the 16-bit version running on Win98 will still return "Win95".
var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
var is_win32 = (is_win95 || is_winnt || is_win98 ||
                ((is_major >= 4) && (navigator.platform == "Win32")) ||
                (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

var is_os2   = ((agt.indexOf("os/2")!=-1) ||
                (navigator.appVersion.indexOf("OS/2")!=-1) ||
                (agt.indexOf("ibm-webexplorer")!=-1));

var is_mac    = (agt.indexOf("mac")!=-1);
if (is_mac) { is_win = !is_mac; } // dmr - 06/20/2002
var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) ||
                           (agt.indexOf("68000")!=-1)));
var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) ||
                            (agt.indexOf("powerpc")!=-1)));

var is_sun   = (agt.indexOf("sunos")!=-1);
var is_sun4  = (agt.indexOf("sunos 4")!=-1);
var is_sun5  = (agt.indexOf("sunos 5")!=-1);
var is_suni86= (is_sun && (agt.indexOf("i86")!=-1));
var is_irix  = (agt.indexOf("irix") !=-1);    // SGI
var is_irix5 = (agt.indexOf("irix 5") !=-1);
var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
var is_hpux  = (agt.indexOf("hp-ux")!=-1);
var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1));
var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1));
var is_aix   = (agt.indexOf("aix") !=-1);      // IBM
var is_aix1  = (agt.indexOf("aix 1") !=-1);
var is_aix2  = (agt.indexOf("aix 2") !=-1);
var is_aix3  = (agt.indexOf("aix 3") !=-1);
var is_aix4  = (agt.indexOf("aix 4") !=-1);
var is_linux = (agt.indexOf("inux")!=-1);
var is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
var is_unixware = (agt.indexOf("unix_system_v")!=-1);
var is_mpras    = (agt.indexOf("ncr")!=-1);
var is_reliant  = (agt.indexOf("reliantunix")!=-1);
var is_dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) ||
       (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) ||
       (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1));
var is_sinix = (agt.indexOf("sinix")!=-1);
var is_freebsd = (agt.indexOf("freebsd")!=-1);
var is_bsd = (agt.indexOf("bsd")!=-1);
var is_unix  = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux ||
             is_sco ||is_unixware || is_mpras || is_reliant ||
             is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);

var is_vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));


/*******************************************************************************
* REGISTER ONLOAD & ONSUBMIT SCRIPTS  -- THIS NEEDS TO BE AT TOP OF PAGE
*******************************************************************************/

// used by registerOnLoadEvent - do not call directly
function getFunctionName( functionReference ) {
	var code			= functionReference.toString();
	var functionName	= null;
	var startPos		= -1;
	var endPos			= -1;

	// go to the index after the word "function".
	var startPos = code.indexOf("function");
	if (startPos == -1) {
		return null;
	}
	startPos = startPos + 8;


	// find the index where the "(" is located
	endPos = code.indexOf( "(", startPos );
	if (endPos == -1) {
		return null;
	}
	
	// extract function name
	functionName = code.substring( startPos, endPos );
	if (functionName != null) {
		var re = new RegExp( "\\s*", "g" );
		functionName = functionName.replace( re, "" );
	}
	
	return functionName;
}


// contains list of functions to call upon onload - do not access directly
var onLoadEventFunctions = new Array();

// registers a custom onload event method to be invoked by upon page load
// usage: registerOnLoadEvent(functionName);
function registerOnLoadEvent(functionReference) {
	
	// parse out function name
	var functionName = getFunctionName(functionReference);

	if (functionName == null) {
		alert( "registerOnLoadEvent: Failed to extract the function name.  The following method will NOT get registered for onload event.\n\n" + functionReference.toString() );
		return;
	} else {
		// add function to event list
		onLoadEventFunctions[ onLoadEventFunctions.length ] = functionName + "()";
	}
}

// execute registered events - only call from template <body onLoad="">
function onLoadEvent() {
	for (var i = 0; i < onLoadEventFunctions.length; i++) {	
		// call registered functions
		eval( onLoadEventFunctions[i] );
	}
}

// contains list of functions to call upon onsubmit - do not access directly
var onSubmitEventFunctions = new Array();

// registers a custom onsubmit event method to be invoked by upon form submission
// usage: registerOnSubmitEvent(formName, functionName);
function registerOnSubmitEvent(formName, functionReference) {
	if (typeof(formName) != "string") {
		alert("registerOnSubmitEvent():  formName is not of type String.");
	} else {
		// parse out function name
		var functionName = getFunctionName(functionReference);
	
		if (functionName == null) {
			alert( "registerOnSubmitEvent: Failed to extract the function name.  The following method will NOT get registered for onSubmit event.\n\n" + functionReference.toString() );
			return;
		} else {
			if (onSubmitEventFunctions[formName] == null) {
				onSubmitEventFunctions[formName] = new Array();
			}
			
			// add function to event list
			var index = onSubmitEventFunctions[formName].length;
			onSubmitEventFunctions[formName][index] = functionName + "()";
		}
	}
}

// execute registered events - only call from template <form onSubmit="">
function onSubmitEvent(formName) {
	var okToSubmit = true;
	
	var formFunctions = onSubmitEventFunctions[formName + ""];

	if (formFunctions != null) {
		for (var i = 0; i < formFunctions.length; i++) {	
			// call registered functions
			var result = eval( formFunctions[i] );
			
			// So the interstitial doesn't get displayed when there's an error
			// we will return as soon as we get our first error.  
			//
			// This means, however, that callbacks are called only when prevous
			// on ran successfully.			
			if (result == false) {
				return false;
			}
		}
	}
	
	return true;
}



/*******************************************************************************
* Popup Window Scripts
*******************************************************************************/

// popup window (full) - all window elements are enabled
function popUpFull(url, width, height) {
	wndHndl = window.open(url, 'popup' + Math.floor(Math.random()*1000), 'toolbar=yes,scrollbars=yes,location=yes,statusbar=yes,menubar=yes,resizable=yes,width=' + width + ',height=' + height + ',left=100,top=100');
	if (wndHndl) {
		wndHndl.focus();
	} else {
	  alert(popupBlockWarningMessage);
	}
}

// popup window (limited) - only scrollbars and window resizing are enabled
function popUpLimited(url, width, height) {
	wndHndl = window.open(url, 'popup' + Math.floor(Math.random()*1000), 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=yes,width=' + width + ',height=' + height + ',left=100,top=100');
	if (wndHndl) {
		wndHndl.focus();
	} else {
	  alert(popupBlockWarningMessage);
	}
}

// popup window (modal) - all window elements are disabled
function popUpModal(url, width, height) {
	wndHndl = window.open(url, 'popup' + Math.floor(Math.random()*1000), 'toolbar=no,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=no,width=' + width + ',height=' + height + ',left=100,top=100');
	if (wndHndl) {
		wndHndl.focus();
	} else {
	  alert(popupBlockWarningMessage);
	}
}


// popup window (limited) - only scrollbars and window resizing are enabled
function popUpSingleMap(url) {
	popUpLimited(url, 440, 515);
}

// popup window (limited) - only scrollbars and window resizing are enabled
function popUpMultipleMap(url) {
	popUpLimited(url, 490, 590);
}



/*******************************************************************************
* DHTML Hide / Show Scripts
*******************************************************************************/

// show target element by id
function show(targetId) {
	target = document.getElementById(targetId);
	if (target != null)
	{
		target.style.display = "block";
	}
}

// show target element by id (inline)
function showInline(targetId) {
	target = document.getElementById(targetId);
	if (target != null)
	{
		target.style.display = "inline";
	}
}

// hide target element by id
function hide(targetId) {
	target = document.getElementById(targetId);
	if (target != null)
	{
		target.style.display = "none";
	}
}

// toggle target element between show and hide
function showAndHide(targetId) {	
	target = document.getElementById(targetId);
	if (target != null)
	{		
		if (target.style.display == "block") {
			target.style.display = "none";
		} else {
			target.style.display = "block";
		}
	}
}

// determine whether an element is hidden
function isHidden(targetId) {
	target = document.getElementById(targetId);
	if (target != null)
	{
		if (target.style.display == "block") {
			return false;
		} else {
			return true;
		}
	}
}

// show target tab and hide all others
// tab <li> ids should start with "[tabIdentifier]_[name]"
// tab content <div> ids should start with "[tabIdentifier]_[name]_content"
// usage: showTab('[tabIdentifier]_[name]');
function showTabExtended(targetId, tabIdentifier) {
	
	targetTab = targetId;
	targetContent = targetId + "_content";
	
	// get all li on the page
	lis = document.getElementsByTagName("li");
	for (i = 0; i < lis.length; i++) {
		li = lis[i];
		if(!li) continue;
		
		// if li starts with "tab_"
		if ( (new String(li.id)).indexOf(tabIdentifier) == 0) {
			// determine if we select or deselect
			if (li.id == targetId) {
				li.className = "selected";
			} else {
				li.className = "";
			}
		}
	}

	// get all divs on the page
	divs = document.getElementsByTagName("div");
	for (i = 0; i < divs.length; i++) {
		div = divs[i];
		if(!div) continue;
		
		// if div starts with "tab_"
		if ( (new String(div.id)).indexOf(tabIdentifier) == 0) {
			// determine if we show or hide
			if (div.id == targetContent) {
				show(div.id);
			} else {
				hide(div.id);
			}
		}
	}
}

// show target tab and hide all others
// tab <li> ids should start with "tab_[name]"
// tab content <div> ids should start with "tab_[name]_content"
// usage: showTab('tab_[name]');
function showTab(targetId) {
	showTabExtended(targetId, "tab_");
}

// add (show) an additional div
// div ids must be in the following format:
//		div_[targetType]_[number] - div wrapping the fields
//		div_add_[targetType] - add link
// max should be set to the maximum number of programs for the given targetType
function doAddDiv(targetType, max) {
	
	// find the first hidden div and display it
	for (i = 1; i <= max; i++) {
		target = document.getElementById("div_" + targetType + "_" + i);
		if (target != null) {
			if (target.style.display == "none") {
				target.style.display = "block";
				break;
			}
		}
	}

	// if the number of open divs reaches the maximum, hide the "add" link
	if (i == max) {
		target = document.getElementById("div_add_" + targetType);
		if (target != null) {
			target.style.display = "none";
		}
	}

}



/*******************************************************************************
* Cookie Scripts
*******************************************************************************/

// this function gets the cookie, if it exists
function getCookie( name ) {
	
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

/*
only the first 2 parameters are required, the cookie name, the cookie
value. Cookie time is in milliseconds, so the below expires will make the 
number you pass in the Set_Cookie function call the number of days the cookie
lasts, if you want it to be hours or minutes, just get rid of 24 and 60.

Generally you don't need to worry about domain, path or secure for most applications
so unless you need that, leave those parameters blank in the function call.
*/
function setCookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	// if the expires variable is set, make the correct expires time, the
	// current script below will set it for x number of days, to make it
	// for hours, delete * 24, for minutes, delete * 60 * 24
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	//alert( 'today ' + today.toGMTString() );// this is for testing purpose only
	var expires_date = new Date( today.getTime() + (expires) );
	//alert('expires ' + expires_date.toGMTString());// this is for testing purposes only

	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}

// this deletes the cookie when called
function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}



/*******************************************************************************
* Client-Side Pagination Scripts
*******************************************************************************/

// javascript variable pageMax must be set on the page

// global variable to set the currently displayed page - default to 1
var pageCurrent = 1;

// perform page next
function doPageNext() {
	
	// ensure the next page exists
	if (pageCurrent < pageMax) {
		
		// increase the page
		pageCurrent++;

		// show the new page, hide all others
		for (i = 1; i <= pageMax; i++) {
			if (i == pageCurrent) {
				show("div_page_" + i);
			} else {
				hide("div_page_" + i);
			}
		}

		// show previous link, hide next link if we have reached the max
		doPageLinkVisibility();
	}
	
	// perform page number highlighting
	doPageHighlight();

	// jump to the top of the page (simulate server hit)
	scroll(0, 0);

}

// perform page previous
function doPagePrevious() {

	// ensure the previous page exists
	if (pageCurrent > 1) {

		// decrease the page index
		pageCurrent--;

		// show the new page, hide all others
		for (i = 1; i <= pageMax; i++) {
			if (i == pageCurrent) {
				show("div_page_" + i);
			} else {
				hide("div_page_" + i);
			}
		}

		// show next link, hide previous link if we have reached the minimum
		doPageLinkVisibility();
	}
	
	// perform page number highlighting
	doPageHighlight();

	// jump to the top of the page (simulate server hit)
	scroll(0, 0);

}

// perform page click
// pass in the page number to display
function doPageClick(index) {
	
	// set the new page
	pageCurrent = index;

	// show the new page, hide all others
	for (i = 1; i <= pageMax; i++) {
		if (i == pageCurrent) {
			show("div_page_" + i);
		} else {
			hide("div_page_" + i);
		}
	}
	
	// perform link visibility
	doPageLinkVisibility();
	
	// perform page number highlighting
	doPageHighlight();
	
	// jump to the top of the page (simulate server hit)
	scroll(0, 0);

}

// perform link visibility check
function doPageLinkVisibility() {

	// if the current page is 1, hide the previous link
	
	if (pageCurrent == 1) {
		document.getElementById("span_page_previous").style.visibility = "hidden";
	} else {
		document.getElementById("span_page_previous").style.visibility = "visible";
	}
	
	// if the current page is the max, hide the next link
	if (pageCurrent == pageMax) {
		document.getElementById("span_page_next").style.visibility = "hidden";
	} else {
		document.getElementById("span_page_next").style.visibility = "visible";
	}

}

// perform page number highlighting
function doPageHighlight() {

	// display the current page link in black bold, all others normal
	for (i = 1; i <= pageMax; i++) {
		pageLink = document.getElementById("a_page_" + i);
		if (pageLink != null) {
			if (i == pageCurrent) {
				pageLink.className = "default bold";
				//pageLink.style.fontWeight = "bold";
			} else {
				pageLink.className = "";
				//pageLink.style.fontWeight = "normal";
			}
		}
	}

}



/*******************************************************************************
* Utility Scripts
*******************************************************************************/

 function trim(TRIM_VALUE){


	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = rtrim(TRIM_VALUE);
	TRIM_VALUE = ltrim(TRIM_VALUE);


	if(TRIM_VALUE==""){
		return "";
	}


	else{
		return TRIM_VALUE;
	}
}


function rtrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";


	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;


	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){}


		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	}
	return strTemp;
}


function ltrim(VALUE){
	var w_space = String.fromCharCode(32);


	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";
	var iTemp = 0;


	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){}


    		else{
    			strTemp = VALUE.substring(iTemp,v_length);
    			break;
    		}
    		iTemp = iTemp + 1;
    	}
	return strTemp;
}

// return a number with comma formatting - ie. 10000 -> 10,000
function formatNumberComma(number) {
    number = '' + number;
    if (number.length > 3) {
        var mod = number.length % 3;
        var output = (mod > 0 ? (number.substring(0,mod)) : '');
        for (i=0 ; i < Math.floor(number.length/3) ; i++) {
            if ((mod ==0) && (i ==0))
                output += number.substring(mod+3*i,mod+3*i+3);
            else
                output += ',' + number.substring(mod+3*i,mod+3*i+3);
        }
        return (output);
    }
    else return number;
}

// go to the given url
function go(url) {
	location.href = url;
}

// get a request parameter - returns empty string if not found
function getParameter(parameterName) {
	var queryString = window.location.search;
	var parameterName = parameterName + "=";
	
	if (queryString.length > 0) {
		begin = queryString.indexOf ( parameterName );
		if (begin != -1) {
			begin += parameterName.length;
			end = queryString.indexOf ("&" , begin);
			if (end == -1) {
				end = queryString.length
			}
			return unescape (queryString.substring(begin, end));
		}
	}
	return "";
}

// if the passed in object value equals the value passed in text,
// clear the object's value - used for clearing the default
// state of textboxes onfocus
function doClearDefaultText(object, text) {
	if (object) {
		if (object.value == text) {
			object.value = '';
		}
	}
}

// change the property of an element.
// i.e.: changeProp("myElementID", "*not used*", "style.dysplay", "block"); 
function changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = getObject(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

/*******************************************************************************
* SHOW INTERSTITIAL PAGE (PLEASE WAIT)
*******************************************************************************/

function resetInterstitialImage() {
	// IE won't animate a GIF after form submit
	// resetting the image src after submit fixes the problem
	imgInterstitial = document.getElementById("interstitial_img");
	if (imgInterstitial != null) {
		imgInterstitial.src = imgInterstitial.src;
	}
	imgInterstitial = document.getElementById("wait_img");
	if (imgInterstitial != null) {
		imgInterstitial.src = imgInterstitial.src;
	}
}

function hideInterstitial(divName) {
	if (divName == null) {
		divName = "interstitial";
	}
	
	var divInterstitial = document.getElementById(divName);
	var divSite = document.getElementById("site");
	
	if (divInterstitial != null && divSite != null) {
		divSite.style.display = "block";
		divInterstitial.style.display = "none";
	}
}

function showInterstitial(divName) {
	if (divName == null) {
		divName = "interstitial";
	}
	
	var divInterstitial = document.getElementById(divName);
	var divSite = document.getElementById("site");
	
	if (divInterstitial != null && divSite != null) {
		divSite.style.display = "none";
		divInterstitial.style.display = "block";
		
		// IE won't animate a GIF after form submit
		// resetting the image src after submit fixes the problem
		setTimeout('resetInterstitialImage()', 200);
		
	}
}



/*******************************************************************************
* HIGHLIGHT FIELDS ASSOCIATED WITH AN ERROR MESSAGE
*******************************************************************************/

// Highlights all the form field labels that have errors.
// Simply pass in an array of the labels' div name
function highlightErrorFields(divNames) {
	highlightErrorFields(divNames, false);
}

function highlightErrorFields(divNames, alertOnMissingDivs) {
	if (divNames == null) {
		alert("highlightErrorFields():  \"divNames\" must not be null.");
	} else {
		if ((divNames instanceof Array) == false) {
			alert("highlightErrorFields():  \"divNames\" input parameter is not of type Array.");
		} else {
			for (i = 0; i < divNames.length; i++) {
				if (divNames[i] != null) {
					if ((typeof(divNames[i]) == "string") == false) {
						alert("highlightErrorFields():  \"divNames[" + i + "]\" input parameter is not of type String.");
					} else {
						var divRef = document.getElementById(divNames[i]);
						if (divRef == null) {
							if (alertOnMissingDivs == true) {
								alert("highlightErrorFields():  The div referrence for \"" + divNames[i] + "\" is null.");
							}
						} else {
							divRef.className += " error";
						}
					}
				}
			}
		}
	}
}



/*******************************************************************************
* Miscellaneous Functions
*******************************************************************************/

// TODO Are these being used?

// Get a document object by name reference
// Generated by Macromedia Dreamweaver... cleaned up by Eric.
function getObject(n, d) {
	var i = 0;
	var p = 0;				// position
	var o = null;			// object ref.
	
	if (!d) {
		d = document;
	}


	// See if the object name is referring to an object within another frame window.
	// Object name would be   <object name>?<frame name>
	// Variable name will be replaced with the substring for <object name>
    p = n.indexOf("?");
	if (p > 0 && parent.frames.length) {
    	d = parent.frames[n.substring(p + 1)].document; 
    	n = n.substring(0, p);
    }


	// Check to see the object (which may have been extracted from a frame document)
	// is found at the root of the DOM
	o = d[n];
  	if (!o && d.all) {
  		o = d.all[n];
  	}
  		
  		
  	// Nothing yet... then check to see if it's a form element
  	for (i = 0; !o && i < d.forms.length; i++) {
  		o = d.forms[i][n];
  	}
  		
  		
  	// Alright, now check to see if it's a layer
  	for (i = 0; !o == null && d.layers && i < d.layers.length; i++) {
  		o = getObject(n, d.layers[i].document);
  	}
  		
  	
  	// Last ditch... try by ID
	if (!o && document.getElementById)  {
		o = document.getElementById(n); 
	}
		
	// Returns null by default if it wasn't found
	return o;
}


// Get the style property... this is different for IE & Netscape
function getStyleObject(object) {
	var o = object;
	
	if (o != null) {
		if (o.style) {
			return  o.style; 
		} else {
			return o;
		}
	} else {
		return null;
	}
}


// Display a given layer
function showLayer(layerName) {
	var layerObj = getObject(layerName);

	if (layerObj != null) {
		var style = getStyleObject(layerObj);
		
		if (style != null) { 
    		style.visibility = "visible";
    	} else {
    		alert("Could not locate style reference for object named: " + layerName);
    	}
	} else {
		alert("Could not obtain a reference for an object named: " + layerName);
	}
}


// Hide a given layer
function hideLayer(layerName) {
	var layerObj = getObject(layerName);

	if (layerObj != null) {
		var style = getStyleObject(layerObj);
		
		if (style != null) { 
    		style.visibility = "hidden";
    	} else {
    		alert("Could not locate style reference for object named: " + layerName);
    	}
	} else {
		alert("Could not obtain a reference for an object named: " + layerName);
	}
}


  	function getDocumentWidth() {
		if( typeof( window.innerWidth ) == "number" ) {
			// Non-IE
			return window.innerWidth;
		} else {
			if( document.documentElement &&document.documentElement.clientWidth ) {

				//IE 6+ in 'standards compliant mode'
				return document.documentElement.clientWidth;
			} else {
				if( document.body && document.body.clientWidth ) {
					//IE 4 compatible
					return document.body.clientWidth;
				}
			}
		}
	}


  	function getDocumentHeight() {
		if( typeof( window.innerHeight ) == "number" ) {
			// Non-IE
			return window.innerHeight;
		} else {
			if( document.documentElement && document.documentElement.clientHeight ) {

				//IE 6+ in 'standards compliant mode'
				return document.documentElement.clientHeight;
			} else {
				if( document.body && document.body.clientHeight ) {
					//IE 4 compatible
					return document.body.clientHeight;
				}
			}
		}
	}  	
  	
	function centerLayer(pLayerID, pLayerWidth, pLayerHeight) {
		var winWidth  = getDocumentWidth();
		var winHeight = getDocumentHeight();
		
		//alert( "Document Width: " + winWidth + "\nDocument Height: " + winHeight );
		
		var newLeft  = (winWidth - pLayerWidth) / 2;
		var newTop   = (winHeight - pLayerHeight) / 2;
		
		//alert( "Layer Left: " + newLeft + "\nLayer Top: " + newTop );

		var docLayer = getObject( pLayerID );
		
		if (docLayer != null) {
			docLayerStyle = getStyleObject( docLayer );

			if (docLayerStyle != null) {
   				docLayerStyle.top = newTop;
				docLayerStyle.left = newLeft;
			} else {
				alert( "Could not locate the layer object's style property for " + pLayerID );
			}
		} else { 
			alert( "Could not locate the layer object for " + pLayerID );
		}
	}


// Fix to the Netscape resize problem.  When the window resizes it is reloaded
// so that it properly formats itself with the new window dimensions.
function NetscapeResizeFix_reloadPage(init) {
	if (init == true) with (navigator) {
		if ( (appName == "Netscape") && (parseInt(appVersion)==4) ) {
			document.MM_pgW = innerWidth;
			document.MM_pgH = innerHeight;
			onresize = NetscapeResizeFix_reloadPage;
		}
	} else if (innerWidth != document.MM_pgW || innerHeight != document.MM_pgH) {
		location.reload();
	}
}
// Initialize the Netscape resize fix
NetscapeResizeFix_reloadPage(true);



// Method that does nothing.  Replaces the <a href="#"> code, which
// use to reload the page and put it in history.  Since it was in
// history, it would cause problems when clicking back.
function doNothing() {
}


function openPopupWindow(url, windowName, settings) {
	var wndHndl = window.open(url, windowName, settings);
	if (wndHndl) {
		wndHndl.focus();
	} else {
	  alert(popupBlockWarningMessage);
	}
	return wndHndl;
}


// Opens a popup window that is centered on the screen.
function openCenteredPopupWindow(url, windowName, settings, windowWidth, windowHeight) {
	var windowX = (screen.width - windowWidth) / 2;
	var windowY = (screen.height - windowHeight) / 2;
	
	settings = settings + ",width=" + windowWidth + ",height=" + windowHeight + ",top=" + windowY + ",left=" + windowX;
	var wndHndl = window.open(url, windowName, settings);
	if (wndHndl) {
		wndHndl.focus();
	} else {
	  alert(popupBlockWarningMessage);
	}
	return wndHndl;
}

//functions needed to check if a date is within certain range
function getYear(d) { 
  return (d < 1000) ? d + 1900 : d;
 }

function isDate (year, month, day) {
  // month argument must be in the range 0 - 11
  var tempDate = new Date(year,month,day);
  if ( (getYear(tempDate.getYear()) == year) &&
     (month == tempDate.getMonth()) &&
     (day == tempDate.getDate()) ) {
      return true;
  } else {
     return false;
  }
}

function isDateInRange(year, month, day, beginDate, endDate)
{
	if(!isDate(year, month, day))
	{
		return false;
	}
	
	var date = new Date(year, month, day);
	
	if((date.getTime()<beginDate.getTime()) || date.getTime()>endDate.getTime())
	{
		return false;
	}
	
	return true;
}


var veriSignSealWindow = null;
function openVeriSignSealWindow(digestNumber) {
	veriSignURL = "https://digitalid.verisign.com/as2/" + digestNumber;
	
	veriSignSealWindow = openCenteredPopupWindow(
		veriSignURL, 
		"VeriSignSealWindow", 
		"toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1",
		720, 
		450);

	self.name = "mainWin";
}


function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}


function getDocumentHeight(doc) {
	var docHt = 0, sh, oh;
	
	if (doc.height) {
		docHt = doc.height;
	} else if (doc.body) {
	    if (doc.body.scrollHeight) {
	    	docHt = sh = doc.body.scrollHeight;
	    }
	    
    	if (doc.body.offsetHeight) {
    		docHt = oh = doc.body.offsetHeight;
    	}
    	
	    if (sh && oh) {
	    	docHt = Math.max(sh, oh);
	    }
	}

	return docHt;
}


function setIframeHeight(iframeName, height) {
	var iframeWin = window.frames[iframeName];
	var iframeEl = document.getElementById ? 
			document.getElementById(iframeName) : document.all ? 
				document.all[iframeName] : null;

	if (iframeEl && iframeWin) {
		// helps resize (for some) if new doc shorter than previous  
		iframeEl.style.height = "auto"; 

		var docHt = 0;
		if (height != null) {
			docHt = height;
		} else {
			docHt = getDocumentHeight(iframeWin.document) + 5;
		}

		// need to add to height to be sure it will all show
		if (docHt) {
			//alert("setting height for " + iframeName + ": " + docHt);
			iframeEl.style.height = docHt + "px";
		}
	}
}

// 317914:  Clicking on browser back button from resort details page does NOT bring user back to 
// the flexible resort search results page.  Turns out that IE 7 (6?) does NOT keep track of 
// the URL of the current page of a clicked iframe link.  
//
// Solution (don't know why) is to have the link do a top.location url replace.
function backButtonFixForNavigatingLinkWithinIFrame(url)
{
	top.location = url;
}

var resortSearchInProgress = true; 

function doFreeze()
{
		document.getElementById('pleasewait').style.display = "inline";
		document.getElementById('completeOrder').style.display = "none";
}

function doFreezeByIndex(theIndex)
{
	var pleasewait= 'pleasewait' + theIndex;
	document.getElementById(pleasewait).style.display = "inline";

	var completeOrder= 'completeOrder' + theIndex;
	document.getElementById(completeOrder).style.display = "none";
	
	return true;
}

