// WhitefaceLakePlacidInfo.com/tripPlanner dhtml functions, see dhtml.css for affected DIV objects 
var tabbedLayerArray = new Array();
//add Strings of the div objects we want tabbed
tabbedLayerArray.push("'tips'");
tabbedLayerArray.push("'tp'");
tabbedLayerArray.push("'searchResults'");

function closeAllTabs()
{
	for(var i=0;i < tabbedLayerArray.length;i++)
	{
		document.getElementById(eval(tabbedLayerArray[i])).style.visibility = "hidden";
	}
	
	//update the actual tabs so they are closed
	/*document.getElementById("tpTab").className = "closedTab";
	document.getElementById("tipsTab").className = "closedTab";
	document.getElementById("searchTab").className = "closedTab";*/
	document.getElementById("tpTab").src = "i/bt-tp.gif";
	document.getElementById("searchTab").src = "i/bt-searchResults.gif";
	document.getElementById("tipsTab").src = "i/bt-tips.gif";
}

function openTabById(idstring)
{

	closeAllTabs();
	closeInfoWindows();//clear any pop ups off the map
	hideMarkers();//hides search results, removes TP markers, leaves venues alone
	switch(idstring)
	{
		case "tp":
			document.getElementById("tp").style.visibility = "visible";
			//document.getElementById("tpTab").className = "openTab";
			document.getElementById("tpTab").src = "i/bt-tp-on.gif";
			
			//get the latest
			mapTPMarkers();
			break;
	
		case "tips":
			document.getElementById("tips").style.visibility = "visible";
			//document.getElementById("tipsTab").className = "openTab";
			document.getElementById("tipsTab").src = "i/bt-tips-on.gif";
			break;

		case "searchResults":
			document.getElementById("searchResults").style.visibility = "visible";
			//document.getElementById("searchTab").className = "openTab";
			document.getElementById("searchTab").src = "i/bt-searchResults-on.gif";
			//show the hidden Markers
			showSearchResultMarkers();
			break;
	}
	
}

function viewingTP()
{
	if(document.getElementById("tp").style.visibility == "visible")
	{
		return true;
	}
	else return false;
}


function showSearching()
{
	document.getElementById("searchStatus").innerHTML = "SEARCHING...";
}

/********* trip planner DIV update functions, called from Add and Remove functions (tripplanner.js) *************/
function updateTripPlanner()
{
	  var xmlHttp;
	  try
		{    // Firefox, Opera 8.0+, Safari    
				xmlHttp=new XMLHttpRequest();    }
	  	catch (e)
		{    // Internet Explorer    
			try
		  	{      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      }
			catch (e)
		  	{
				try
				{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
		  		catch (e)
				{
					//no AJAX support, so just refresh the browser
					document.location = 'index.cfm';
				}
			}
		}
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4)
			{
				//update the text
				if(!hasTripPlannerItems())//there are no items left, so reset the welcome text
				{
					document.getElementById("tp").innerHTML="Welcome to the WhitefaceLakePlacidInfo.com Trip Planner! We've provided a search function for you to find businesses located near the four Olympic venues. Once you've found an item that interests you, click the \"add to trip planner\" link to store the item. You can view your trip planner items at any time by opening up this tab. Once your finished, click the \"Map My Trip Planner\" button to view all your items on the map, and print when ready.";
				}
				else
				{
					document.getElementById("tp").innerHTML=xmlHttp.responseText;
				}
				//if the TP is visible, update IT
				if( viewingTP() )
				{
					mapTPMarkers();
				}
			}
		}
		var queryURL = 'CFHandlers/loadTripPlanner.cfm';
		xmlHttp.open("GET",queryURL,true);
		xmlHttp.send(null);	
}