// 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-my-trip.gif";
	document.getElementById("searchTab").src = "i/bt-tp-2.gif";
	document.getElementById("tipsTab").src = "i/bt-tips.gif";
}

function openTabById(idstring)
{
	
	
	closeAllTabs();
	//closeInfoWindows();
	hideAllMarkers();
	
	
	switch(idstring)
	{
		case "tp":
			document.getElementById("tp").style.visibility = "visible";
			//document.getElementById("tpTab").className = "openTab";
			document.getElementById("tpTab").src = "i/bt-my-trip-on.gif";
			
			//map the TP items
			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-tp-2-on.gif";
			
			//map the section services, photos, etc.
			//mapSearchResults();
			//show the currentcategoy
			
			showCategory(currentServiceTypeID);
			
			break;
	}
	
	
	
}

function viewingTP()
{
	if(document.getElementById("tp").style.visibility == "visible")
	{
		return true;
	}
	else return false;
}



/********* 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 NFCT Trip Planner! 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);	
}

/**** called from gmap_serviceManager.js when new service category is selected  *****/
function loadServices(sectionID,serviceCatId)
{
	  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
				document.getElementById("searchResults").innerHTML=xmlHttp.responseText;
				//show the description DIV
				//openTabById("searchResults");
			}
		}
		
		var queryURL = 'CFHandlers/loadServices.cfm?sectionID='+sectionID+'&serviceCatID='+serviceCatId;
		xmlHttp.open("GET",queryURL,true);
		xmlHttp.send(null);	
}