//********************************************************************************************************
//Javascripts.js - Collection of javascript functions called throughout the presentation portion of
//the VaOrg site.  Initialized by the <script LANGUAGE="JavaScript" src="javascripts.asp"></script> line
//in Page_begin.asp.
//********************************************************************************************************

//********************************************************************************************************
// Determine local browser and version
//********************************************************************************************************

// convert all characters to lowercase to simplify testing 
var agt=navigator.userAgent.toLowerCase(); 

// *** BROWSER VERSION *** 
// Note: On IE5, these return 4, so use is_ie5up to detect IE5. 
var is_major = parseInt(navigator.appVersion); 
var is_minor = parseFloat(navigator.appVersion); 

//alert(navigator.appVersion);

var is_ie   = (agt.indexOf("msie") != -1); 
var is_ie3  = (is_ie && (is_major < 4)); 
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.")==-1) ); 
var is_ie4up  = (is_ie  && (is_major >= 4)); 
var is_ie5  = is_ie && is_major == 4 && agt.indexOf("msie 5.0") !=-1; 
var is_ie6  = is_ie && is_major == 4 && agt.indexOf("msie 6.0") !=-1; 
var is_ie55up  = (is_ie  && !is_ie3 && !is_ie4 && !is_ie5); // || (agt.indexOf("msie 5.5")); 

//alert (is_ie55up);
// 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_opera = (agt.indexOf("opera") != -1); 
var is_webtv = (agt.indexOf("webtv") != -1); 

var is_mac    = (agt.indexOf("mac")!=-1);
var is_sun   = (agt.indexOf("sunos")!=-1);
var is_irix  = (agt.indexOf("irix") !=-1);    // SGI
var is_hpux  = (agt.indexOf("hp-ux")!=-1);
var is_aix   = (agt.indexOf("aix") !=-1);      // IBM
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); 

//These two window properties hold variables for showing an attractions MapQuest map and photograph
mapWin = null;
photoWin = null;

//
window.offscreenBuffering = true

var	ClearPixel,CatOn1,CatOn2,CatOff1,CatOff2;
var	home_navigation,home_navigation_f2,home_navigation_f3,home_navigation_f4,home_navigation_f5,home_navigation_f6,home_navigation_f7,home_navigation_f8,home_navigation_f9;
var	about_the_state,about_the_state_f2,about_the_state_f3,about_the_state_f4,about_the_state_f5,about_the_state_f6,about_the_state_f7,about_the_state_f8,about_the_state_f9;

//********************************************************************************************************
//'Use Style sheets for those browsers that can take advantage of them (NS & IE 3.0 and higher)
//********************************************************************************************************

var n=navigator.appName

if (n == "Microsoft Internet Explorer") {
	document.write("<style type='text/css'>");
	document.write(".content       {font-family:arial,sans-serif;font-size:  9pt;}");
	document.write(".contentlabel1 {font-family:arial,sans-serif;font-size:  9pt;}");
	document.write(".contentlabel2 {font-family:arial,sans-serif;font-size: 10pt;}");
	document.write(".contentlabel3 {font-family:arial,sans-serif;font-size: 11pt;}");
	document.write(".contentlabel4 {font-family:arial,sans-serif;font-size: 12pt;}");
	document.write(".demograph     {font-family:arial,sans-serif;font-size:  9pt;}");
	document.write(".letterlist    {font-family:arial,sans-serif;font-size:  8pt;}");
	document.write(".menuitemlist  {font-family:arial,sans-serif;font-size:  9pt;}");
	document.write(".menulist      {font-family:arial,sans-serif;font-size:  7.5pt;}");
	document.write("form		   {margin-bottom: 0px;margin-top: 0px;}");
	document.write("</style>");
}
	
if (n == "Netscape")   {
	document.write("<style type='text/css'>");
	document.write(".content       {font-family:arial,sans-serif;font-size:  9pt;}");
	document.write(".contentlabel1 {font-family:arial,sans-serif;font-size:  9pt;}");
	document.write(".contentlabel2 {font-family:arial,sans-serif;font-size: 10pt;}");
	document.write(".contentlabel3 {font-family:arial,sans-serif;font-size: 11pt;}");
	document.write(".contentlabel4 {font-family:arial,sans-serif;font-size: 12pt;}");
	document.write(".demograph     {font-family:arial,sans-serif;font-size:  9pt;}");
	document.write(".letterlist    {font-family:arial,sans-serif;font-size:  8pt;}");
	document.write(".menuitemlist  {font-family:arial,sans-serif;font-size:  9pt;}");
	document.write(".menulist      {font-family:arial,sans-serif;font-size:  7.5pt;}");
	document.write("form		   {margin-bottom: 0px;margin-top: 0px;}");
	document.write("</style>");
}

//********************************************************************************************************
//Function fired from the body onload event
//********************************************************************************************************
function pageLoad(pageTitle,pageName,currentURL,targetTD,referringPage,footerImg,footerURL,navMapName,imgLocation) {

	//referring page apparently is not used
    
	//Check for applicable browser/OS status
	if (properEnvironment()) {

		//Resolve the current document container by checking if the Home (HomeHref) Anchor is present on the page.
		if (document.all.HomeHref) { 
			var docname = document;
		} else { 
			var docname = parent.document; 
		}

		//Change special character "|" back to single quote in the title parameter (pageTitle) passed to this
		//function from the page's onLoad event.
		docname.title = pageTitle.replace("|","'");
		
		//Store passed variables to document object properties
		docname.pageName = pageName;
		docname.currentURL = currentURL;
		
		//Images location is always relative to the website root
		imgLocation = imgLocation.replace("../","")
	
		//Here the contentFrame has content, so adjust its size to display all of the content because it has
		//no scrollbar itself to show it (it uses the page (body) scrollbar to show offscreen content).
		//Also, blank out the innercontentDiv content which is really behind the contentFrame IFrame.
		if (document.all.contentDiv) {
			parent.document.all.contentFrame.width = "100%";
			parent.document.all.contentFrame.style.display = "";
			parent.document.all.innercontentDiv.innerHTML = "";	
		}
		
		//Show the current Va navigation map regional section in the upper right corner.
		docname.all.homenavigation.src = imgLocation + navMapName;

		//Start the new page content at the top
		parent.scrollTo(0,0);
		
		//If the page contains a search form, re-route it to the frame-based URL
		if (docname.all.frmSearch) {
			if (docname.all.frmSearch.action.indexOf("targetTD") == -1) {
				docname.all.frmSearch.action = docname.all.frmSearch.action + "?targetTD=content";
			}		
			docname.all.frmSearch.target = "contentFrame";
			docname.all.frmSearch.formTarget.value = "contentFrame";
		}
		//If the current page is the Home page, hide the Home and Statewide Anchors
		if (pageName == "home.asp") {
			hideHomePageElements();
		}else{
			//If the current page is not Home page, show the Home and Statewide Anchors
			docname.all.HomeHref.style.visibility = "visible";
			docname.all.HomeHref.href = "home.asp";
			docname.all.ImgHomeHref.src = imgLocation + "test-gradient3.jpg";
			docname.all.HomeHrefLabel.innerText = " Home";
			docname.all.navFeatures.style.display = "";
		}
	
		//This section is called when the page is a content-type page (level 3).
		if (targetTD == "content") {
			//If the current page is a content or search results page, show the footer image and activate the footer URL
			if (pageName == "content.asp" || pageName == "search.asp") {
				
				if (docname.all.footerImage.src != imgLocation + footerImg) {
					docname.all.footerImage.src = imgLocation + footerImg;
				}
			
				if (footerURL != "" && footerURL != null) {
					docname.all.footerImageHref.href = footerURL.replace("../","");
					docname.all.footerImageHref.target = "_blank";
				}else{
					//If there is no footer URL, remove the property from the page (setting the value to "" or null
					//just results in an invalid, but clickable URL).
		//*************Next 3 lines commented out on 4-12-01, caused problems with IE 5.5**********
		//*************Tested in IE 5 and greate,  and Netscape 4.7 seemed fine *******************
					//if (docname.all.footerImageHref.href) {
					//	docname.all.footerImageHref.removeAttribute("href",false);
					//}
				}
			}else {
				//Show the clear pixel image because there is no applicable footer image
				docname.all.footerImage.src = imgLocation + "clear-pixel.gif";
			}

			//The Statewide Anchor in the upper left corner has several functions.  If this is a content (level 3) page,
			//it needs to point to content.asp and be visible.
			if (pageName == "content.asp") {
				docname.all.StatewideHref.style.visibility = "visible";
				docname.all.StatewideHref.href = "content.asp?Rgn=10000";
				docname.all.ImgStatewideHref.src = imgLocation + "test-gradient3.jpg";
				docname.all.StatewideHrefLabel.innerText = " Statewide";
			} else {
				//Hide it otherwise
				docname.all.StatewideHref.style.visibility = "hidden";
			}
		}

		//Here the contentFrame has content, so adjust its size to display all of the content because it has
		//no scrollbar itself to show it (it uses the page (body) scrollbar to show offscreen content).
		//Delayed until the last section for IE 5.5 to correctly calculate contentDiv.scrollHeight
		if (document.all.contentDiv) {
			var docHeight = Math.max(document.all.contentDiv.scrollHeight,(parent.document.all.lastDivider.offsetTop-8));
			parent.document.all.contentFrame.height = docHeight;
		}

	parent.document.all.contentFrame.contentWindow.document.body.style.cursor = '';
	parent.document.body.style.cursor = '';

	}
}

//********************************************************************************************************
//Function to return a javascript href
//********************************************************************************************************
function getHref(obj) {
	//Check for applicable browser/OS status
	//alert("getHref - start");
	//alert(obj);
	if (properEnvironment()) {
		
		parent.document.body.style.cursor = 'wait';
		if (parent.document.all.contentFrame.contentWindow.document != null) {
			    parent.document.all.contentFrame.contentWindow.document.body.style.cursor = 'wait';
		}

		if (!obj.href) 
		{
			if (!obj.action) 
			{
				return;
			}
			else 
			{
				if (obj.name=="frmCities")
				{
					obj.DescripOnly.value = "Yes";
					obj.target = "newContentFrame";
					obj.submit()
					}
			return;
			}	
		}

		var oldHref = parent.document.currentURL;
		oldHref = oldHref.replace("javascript:newContent('","");
		oldHref = oldHref.replace("&targetTD=content'","");
		oldHref = oldHref.replace("?targetTD=content'","");
		oldHref = oldHref.replace("&DescripOnly=Yes'","");
		oldHref = oldHref.replace("&btnSubmit=Search&formTarget=contentFrame","");
		oldHref = oldHref.replace("')","");
		oldHref = oldHref.replace(")","");
		
		var newHref = obj.href;
		newHref = newHref.replace("javascript:newContent('","");
		newHref = newHref.replace("&targetTD=content'","");
		newHref = newHref.replace("?targetTD=content'","");
		newHref = newHref.replace("&DescripOnly=Yes'","");
		newHref = newHref.replace("&btnSubmit=Search&formTarget=contentFrame","");
		newHref = newHref.replace("')","");
		newHref = newHref.replace(")","");

		if (oldHref.indexOf("Rgn=") > -1  && newHref.indexOf("Rgn=") > -1) {

			var oldRegion = oldHref.substr(oldHref.indexOf("Rgn="),9);
			var newRegion = newHref.substr(newHref.indexOf("Rgn="),9);

			if (obj.name == "bannerNavMap" || obj.name == "StatewideHref") {

				if (document.pageName == "content.asp") {
								
					newHref = oldHref.replace(oldRegion,newRegion);
				}	

				if (document.pageName != "content.asp")	{
						
					newHref = newHref.replace("content.asp","main.asp");
				}
					
			}else{
   		
				newHref = newHref.replace(newRegion,oldRegion);
   			}
		}
		
if (false) {

		if (oldHref.indexOf("ESM=&") == -1) {
		
			if (oldHref.indexOf("ESM=") > -1 && newHref.indexOf("ESM=") == -1 ) { //Events
				newHref = newHref + "&" + oldHref.substr(oldHref.indexOf("ESM="),(oldHref.indexOf("EEY=") + 7) - oldHref.indexOf("ESM=") + 1);
			}

			if (oldHref.indexOf("ESM=") == -1 && newHref.indexOf("ESM=") > -1 ) { //Events
				newHref = newHref.replace(newHref.substr(newHref.indexOf("ESM=")-1,(newHref.indexOf("EEY=") + 7) - newHref.indexOf("ESM=") + 1),"");
			}
		}		
		
		if (oldHref.indexOf("ESM=&") > -1 || oldHref.indexOf("ESM=") == -1) {
			if (newHref.indexOf("ESM=&") > -1 || newHref.indexOf("ESM=") > -1) {
				newHref = newHref.replace(newHref.substr(newHref.indexOf("ESM=")-1,(newHref.indexOf("EEY=") + 3) - newHref.indexOf("ESM=") + 1),"");
			}		
		}

}		

		if (newHref.indexOf("javascript:newContent(") == -1) {
			newHref = "javascript:newContent('" + newHref;
		}

		
		if (newHref.indexOf("&DescripOnly=") == -1) {
			if (newHref.indexOf("StrtLtr=") > -1 || newHref.indexOf("Dir=") > -1 || newHref.indexOf("CtyLU=") > -1) {
				newHref = newHref + "&DescripOnly=Yes";
			}else{
				newHref = newHref.replace("SrchCity=","SC=")
			}
		}


		if (newHref.indexOf("&targetTD=") == -1) {
			newHref = newHref + "&targetTD=content";
		}

						
		newHref = newHref + "')";
		newHref = newHref.replace(".asp=&",".asp?");
		newHref = newHref.replace(".asp&",".asp?");
	
		obj.href = newHref;

	}
}

//********************************************************************************************************
//Function to Build New Content In the Content Frame Only
//********************************************************************************************************
function newContent(strURL) {

	if (strURL.indexOf("DescripOnly=Yes") > -1) {
		parent.document.all.newContentFrame.contentWindow.document.location.href = strURL;	
	}else{
		parent.document.all.contentFrame.contentWindow.document.location.href = strURL;	
	}
}

//********************************************************************************************************
//Function to Build Letterlist And Attraction Description In the divDescrip Only
//********************************************************************************************************
function descripLoad() {
       //alert ("descripLoad at function statement");
	   //alert (parent.document.all.newContentFrame.contentWindow.document.all.divDescrip);
	if (parent.document.all.newContentFrame.contentWindow.document.all.divDescrip
	    && parent.document.all.newContentFrame.contentWindow.document.all.divDescrip != null) {
		var strHTML = parent.document.all.newContentFrame.contentWindow.document.all.divDescrip.innerHTML;
		
	parent.document.all.contentFrame.contentWindow.document.all.divDescrip.innerHTML = strHTML;
   	var docHeight = Math.max(parent.document.all.contentFrame.contentWindow.document.all.contentDiv.scrollHeight,(parent.document.all.lastDivider.offsetTop-8));
	parent.document.all.contentFrame.height = docHeight;
	
	//	parent.document.all.contentFrame.contentWindow.document.all.divDescrip.innerHTML = strHTML;
	//	var docHeight = Math.max(parent.document.all.contentFrame.contentWindow.document.all.contentDiv.scrollHeight,(parent.document.all.lastDivider.offsetTop-8));
	//	parent.document.all.contentFrame.height = docHeight;
	}	else {
	   //alert ("descripLoad inside of else statement");
	}
	parent.document.all.contentFrame.contentWindow.document.body.style.cursor = '';
	parent.document.body.style.cursor = '';
}

//********************************************************************************************************
//Function to hide page elemets if the current page is the home page
//********************************************************************************************************
function hideHomePageElements() {

	//Check for applicable browser/OS status
	if (properEnvironment()) {
		parent.document.all.HomeHref.style.visibility = "hidden";
		parent.document.all.HomeHref.href = "";
		parent.document.all.StatewideHref.style.visibility = "hidden";
		parent.document.all.StatewideHref.href = "";
//		parent.document.all.navFeatures.style.display = "none";
	}
}

//********************************************************************************************************
//Function to set the home page search form target
//********************************************************************************************************
function setHomePageSearchTarget() {

	if (!document.currentURL) {document.currentURL = "home.asp"}
	if (!document.pageName)   {document.pageName = "home.asp"}

	//Check for applicable browser/OS status
	if (properEnvironment()) {
		//If the parent page contains the site search form, re-route it to the frame-based URL
		if (parent.document.all.frmSearch) {
			if (parent.document.all.frmSearch.action.indexOf("targetTD") == -1) {
				parent.document.all.frmSearch.action = parent.document.all.frmSearch.action + "?targetTD=content";
			}		
			parent.document.all.frmSearch.target = "contentFrame";
			parent.document.all.frmSearch.formTarget.value = "contentFrame";
		}
	}
}

//********************************************************************************************************
//Functions to Support Mouse Rollover Effects
//********************************************************************************************************
//not used for SRHR
//home_navigation	  = new Image(); home_navigation.src		= strImagesLocation + "home-navigation.gif";
//home_navigation_f2  = new Image(); home_navigation_f2.src	= strImagesLocation + "home-navigation_f2.gif";
//home_navigation_f3  = new Image(); home_navigation_f3.src	= strImagesLocation + "home-navigation_f3.gif";
//home_navigation_f4  = new Image(); home_navigation_f4.src	= strImagesLocation + "home-navigation_f4.gif";
//home_navigation_f5  = new Image(); home_navigation_f5.src	= strImagesLocation + "home-navigation_f5.gif"
//home_navigation_f6  = new Image(); home_navigation_f6.src	= strImagesLocation + "home-navigation_f6.gif";
//home_navigation_f7  = new Image(); home_navigation_f7.src	= strImagesLocation + "home-navigation_f7.gif";
//home_navigation_f8  = new Image(); home_navigation_f8.src	= strImagesLocation + "home-navigation_f8.gif";
//home_navigation_f9  = new Image(); home_navigation_f9.src	= strImagesLocation + "home-navigation_f9.gif";
//about_the_state	  = new Image(); about_the_state.src		= strImagesLocation + "about-the-state.gif";
//about_the_state_f2  = new Image(); about_the_state_f2.src	= strImagesLocation + "about-the-state_f2.gif";
//about_the_state_f3  = new Image(); about_the_state_f3.src	= strImagesLocation + "about-the-state_f3.gif";
//about_the_state_f4  = new Image(); about_the_state_f4.src	= strImagesLocation + "about-the-state_f4.gif";
//about_the_state_f5  = new Image(); about_the_state_f5.src	= strImagesLocation + "about-the-state_f5.gif";
//about_the_state_f6  = new Image(); about_the_state_f6.src	= strImagesLocation + "about-the-state_f6.gif";
//about_the_state_f7  = new Image(); about_the_state_f7.src	= strImagesLocation + "about-the-state_f7.gif";
//about_the_state_f8  = new Image(); about_the_state_f8.src	= strImagesLocation + "about-the-state_f8.gif";
//about_the_state_f9  = new Image(); about_the_state_f9.src	= strImagesLocation + "about-the-state_f9.gif";


function preloadImages(strImagesLocation) {
	var d=parent.document; 
	if(d.images){ 
		ClearPixel			= new Image(); ClearPixel.src			= strImagesLocation + "clear-pixel.gif";
		CatOn1				= new Image(); CatOn1.src				= strImagesLocation + "test-gradient2.gif";
		CatOn2				= new Image(); CatOn2.src				= strImagesLocation + "test-gradient4.jpg";
		CatOff1				= new Image(); CatOff1.src				= strImagesLocation + "test-gradient.gif";
		CatOff2				= new Image(); CatOff2.src				= strImagesLocation + "test-gradient3.jpg";

	}
}

//********************************************************************************************************
function rollMouse(imgName,newImage) {

	if (parent.document.images) {
		if (parent.document[imgName]) {
		   
			parent.document[imgName].src = eval(newImage).src;
		}else{
			if (document[imgName]) {
			   document[imgName].src = parent.eval(newImage).src;
			}
		}
	}
}

//********************************************************************************************************
//Functions to Support the MapIt and ShowIt Icons under each content entry
//********************************************************************************************************
function openMap(theURL) {
	//This function opens a new browser on the client in which to present
	//the MapQuest results
	var n = navigator.appName;
	if (n == "Microsoft Internet Explorer") {
		if (mapWin) {
			mapWin.close();
		}
	    var ch = parent.window.document.body.clientHeight + 65;
	}    
   	if (n == "Netscape") {
   		if (mapWin) { 
   			if (mapWin.document) {
   				mapWin.close();
   			}
   		}
	    var ch = parent.window.innerHeight + 65;
   	}
    var winParms = "width=570,height=" + ch + ",scrollbars=yes,resizable=yes,menubar=no";
    mapWin=open(theURL,"mapWin",winParms,false);
    mapWin.document.close()
    mapWin.focus();
}

//********************************************************************************************************
function openPhoto(thePhoto,winTitle) {
	//This function opens a new browser on the client in which to present
	//the associated attraction photograph

	var n = navigator.appName;
	if (n == "Microsoft Internet Explorer") {if (photoWin) {photoWin.close();}}    
   	if (n == "Netscape") {if (photoWin) { if (photoWin.document) {photoWin.close();}}}

	var crlf = String.fromCharCode(13) + String.fromCharCode(13);

    photoWin = window.open("","photoWin","scrollbars=no,menubar=no,resizable=yes,height=100,width=100",true);

    photoWin.document.write("<HTML>" + crlf);
	photoWin.document.write("<HEAD>" + crlf);
	photoWin.document.write("<TITLE>" + winTitle + "</TITLE>" + crlf);
    photoWin.document.write("</HEAD>" + crlf);
    photoWin.document.write("<BODY background='../images/background.jpg'>" + crlf);

    if (n == "Microsoft Internet Explorer") {
		photoWin.document.write("<IMG name='photo' SRC='" + thePhoto + "' ALT='" + winTitle + "' TITLE='" + winTitle +"' vspace=0 hspace=0 border=0 onload='window.resizeTo(this.width+30,this.height+60)'>" + crlf);
	}else{
		photoWin.document.write("<IMG name='photo' SRC='" + thePhoto + "' ALT='" + winTitle + "' TITLE='" + winTitle +"' vspace=0 hspace=0 border=0 onload='window.resizeTo(this.width+20,this.height+20)'>" + crlf);
	}
    photoWin.document.write("</BODY>" + crlf);
    photoWin.document.write("</HTML>" + crlf);
    photoWin.document.close();
    photoWin.focus();
}

//********************************************************************************************************
//Functions to Support the Trip Planner Cookie
//********************************************************************************************************
function saveToTrip(CharacteristicID) {
	//This function sets a client cookie and adds an Item (Characteristic ID)to the Trip Planner
	//The cookie expires after thirty days 
	var cookieDate	 = new Date();
	cookieDate.setTime (cookieDate.getTime() + 
	(1000 * 60 * 60 * 24 * 30));
	var cookieExpire = new Date();
	cookieExpire.setTime = cookieDate.getTime();

	//Check for the existence of a cookie on the client computer
	//If CharacteristicID Is Not In Cookie, Add It
	var cookieStr = unescape(document.cookie)

	if (cookieStr.indexOf("¦" + CharacteristicID + "¦") == -1 ) {
		//Find the end of the cookie string and add the new CharacteristicID to it
		startpos		= cookieStr.indexOf("TripID=") + 7;
		endpos			= cookieStr.lastIndexOf("¦");
		cookieLength	= endpos - startpos;
		cookieStr		= cookieStr.substr(startpos,cookieLength) + "¦" + CharacteristicID + "¦";
		document.cookie = "TripID=" + escape(cookieStr) + ";expires=" + cookieDate.toGMTString();
	}

	alert('This Item Has Been Saved To Your Trip Planner.');
	return;
}	

//********************************************************************************************************
function removeFromTrip(CharacteristicID) {
	//This function gets a client cookie and removes an Item (CharacteristicID) from the Trip Planner
	//The cookie is reset to expire after thirty days 
	var cookieDate	 = new Date();
	cookieDate.setTime (cookieDate.getTime() + 
	(1000 * 60 * 60 * 24 * 30));
	
	var cookieExpire = new Date();
	cookieExpire.setTime = cookieDate.getTime();

	//Netscape and Explorer don't play together well, have to use differnent delimiters
	//IE is the pipe symbol, Netscape's is ASCII character 179
	var n=navigator.appName
	if (n=="Microsoft Internet Explorer") {
		var strDelimiter = "¦";
	}
	if (n=="Netscape")   {
		var strDelimiter = "¦";
	}
			
	//Find The position of the CharacteristicID in the cookie and delete it
	//By rebuilding the cookie string without it
	var cookieStr	= unescape(document.cookie);
	startpos		= cookieStr.indexOf("TripID=") + 7;
	endpos			= cookieStr.lastIndexOf(strDelimiter) + 1;
	cookieLength	= endpos - startpos;
	cookieStr		= cookieStr.substr(startpos,cookieLength);
	//Remove the deleted attraction from the cookie string
	cookieStr		= cookieStr.replace(strDelimiter + CharacteristicID + strDelimiter,strDelimiter);
	//Delete the old cookie by expiring it
	document.cookie = "TripID=0;expires=" + cookieExpire.toGMTString(); 
	//Set the new cookie if the length is greater than 1
	if (cookieStr.length > 1) {
		document.cookie = "TripID=" + escape(cookieStr) + ";expires=" + cookieDate.toGMTString();
	}
	document.location.reload(true);
}	

//********************************************************************************************************
function removeAllTrip() {
	//This function gets a client cookie and removes an all Item from the Trip Planner
	//The cookie is reset to expire after thirty days 
	var cookieDate	 = new Date();
	cookieDate.setTime (cookieDate.getTime() + 
	(1000 * 60 * 60 * 24 * 30));
	
	var cookieExpire = new Date();
	cookieExpire.setTime = cookieDate.getTime();

	//Netscape and Explorer don't play together well, have to use differnent delimiters
	//IE is the pipe symbol, Netscape's is ASCII character 179
	var n=navigator.appName
	if (n=="Microsoft Internet Explorer") {
		var strDelimiter = "¦";
	}
	if (n=="Netscape")   {
		var strDelimiter = "¦";
	}
	
	//Delete the old cookie by expiring it
	document.cookie = "TripID=0;expires=" + cookieExpire.toGMTString(); 

	document.location.reload(true);
}	

//********************************************************************************************************
//Functions to Support the Expanded Search Page
//********************************************************************************************************
function initializeCategories()
	{
	// Inititalize the new 'items' selection 
		document.frmSearch.ddlCategories.options.length = arrItems.length;
		
	// Now select all categories and populate the category drop down
		var strOut = "No categories : " + arrItems.length + "\n";
		for (var i=1; i < arrItems.length; i++){
			frmSearch.ddlCategories.options[i].text = arrItems[i][0];
			frmSearch.ddlCategories.options[i].value = arrItems[i][1];
		}
		frmSearch.ddlCategories.options[0].text = "All Categories";
		frmSearch.ddlCategories.options[0].value = 0;
		frmSearch.ddlItems.options[0].selected = true;
	}
	
//*********************************************************************************************************
//NOTE 1-10-02 commenting out javascript that defaults to dropdown box w/ 'All Cities' and nothing else 
//because Region is no longer being selected.  var i refers to which region is being selected-
//region 8 corresponds to SRHR 
function selectCity(objForm)
//*********************************************************************************************************
{
//var i = objForm.ddlRegions.selectedIndex;
var i=8;
var OldCity = objForm.ddlCities.value;
var NewRegion = true;

//if (i > 0){
	
	objForm.ddlCities.options.length = arrCities[i].length - 1;
	for (var j=1; j < arrCities[i].length; j++)
	{
		objForm.ddlCities.options[j-1].text = arrCities[i][j];
		objForm.ddlCities.options[j-1].value = arrCities[i][j];
		
		if (arrCities[i][j] == OldCity){objForm.ddlCities.options[j-1].selected = true;NewRegion = false;}

	}
	
	if (NewRegion == true) {objForm.ddlCities.options[0].selected = true;}

//}
//else
//{
	// User has reselected the blank option
	//	objForm.ddlCities.options.length = 1;
		//objForm.ddlCities.options[0].text = "All Cities";
		//objForm.ddlCities.options[0].value = "";
		//objForm.ddlCities.options[0].selected = true;
//}
	
}

//*********************************************************************************************************
function selectItems(objForm)
//*********************************************************************************************************
{

var i = objForm.ddlCategories.selectedIndex;
var OldItem = objForm.ddlItems.value;
var NewCategory = true;

if (i > 0){
	
	objForm.ddlItems.options.length = arrItems[i].length - 1;
	for (var j=1; j < arrItems[i].length; j++)
	{
		objForm.ddlItems.options[j-1].text = arrItems[i][j];
		objForm.ddlItems.options[j-1].value = arrItems[i][j];

		if (arrItems[i][j] == OldItem){objForm.ddlItems.options[j-1].selected = true;NewCategory = false;}

	}
	
	if (objForm.ddlCategories.options[objForm.ddlCategories.selectedIndex].value == "11") 
	{
		var n=navigator.appName;
		if (n == "Netscape") 
		{
			document.tags.TR.display = 'list-item';
		} 
		else 
		{
			objForm.document.all.trEventDates.style.display = 'block';
		}
	}
	else
	{
		var n=navigator.appName;
		if (n == "Netscape") 
		{
			document.tags.TR.display = 'none';
		} 
		else 
		{
			objForm.document.all.trEventDates.style.display = 'none';
		}
	}

	if (NewCategory == true) {objForm.ddlItems.options[0].selected = true;}

}
else
{
	// User has reselected the blank option
		objForm.ddlItems.options.length = 1;
		objForm.ddlItems.options[0].text = "All Sub-Categories";
		objForm.ddlItems.options[0].value = "";
		objForm.ddlItems.options[0].selected = true;
}
	
}

//********************************************************************************************************
//properEnvironment - Function to determine if client browser can use advanced JavaScript functionality
//********************************************************************************************************
function properEnvironment() {

	var goodEnvironment = false;
    //alert (is_ie55up);
	//JavaScript only available for non-AOL, non-Mac PC's running IE 5 or greater
	if (is_ie && ! is_aol && ! is_mac && ! is_sun && ! is_ie5 && ! is_ie55up && ! is_ie6) {
			goodEnvironment = true;
	}		 
	//alert (goodEnvironment);
	return goodEnvironment;
}

//****************************************************************************************
//The function ValidateRecordName ensures that the user entered a non-blank record name
//****************************************************************************************
function ValidateDateFields(objForm) {

	var ESM = objForm.ESM.options[objForm.ESM.selectedIndex].value;
	var ESD = objForm.ESD.options[objForm.ESD.selectedIndex].value;
	var ESY = objForm.ESY.options[objForm.ESY.selectedIndex].value;
	var EEM = objForm.EEM.options[objForm.EEM.selectedIndex].value;
	var EED = objForm.EED.options[objForm.EED.selectedIndex].value;
	var EEY = objForm.EEY.options[objForm.EEY.selectedIndex].value;
 
	if (!(ESM == "" && ESD == "" && ESY == "" && EEM == "" && EED == "" && EEY == ""))
	{
	
		if (ESM == "")
		{
			alert("You must enter a starting month.");
			return false;
		}

		if (ESD == "")
		{
			alert("You must enter a starting day.");
			return false;
		}

		if (ESY == "")
		{
			alert("You must enter a starting year.");
			return false;
		}

		if (EEM == "")
		{
			alert("You must enter an ending month.");
			return false;
		}

		if (EED == "")
		{
			alert("You must enter an ending day.");
			return false;
		}

		if (EEY == "")
		{
			alert("You must enter an ending year.");
			return false;
		}

		if (ESY > EEY)
		{
			alert("The starting date is after the ending date.");
			return false;
		}

		if ((ESY == EEY) && (parseInt(ESM) > parseInt(EEM)))
		{
			alert("The starting date is after the ending date.");
			return false;
		}

		if ((ESY == EEY) && (ESM == EEM) && (parseInt(ESD) > parseInt(EED)))
		{
			alert("The starting date is after the ending date.");
			return false;
		}
	
	}
	
}
