// JavaScript Document

//enableDebug();

function getURLVar(urlVarName) 
{
	//divide the URL in half at the '?'
	var urlHalves = String(document.location).split('?');
	var urlVarValue = '';
	if(urlHalves[1])
	{
		//load all the name/value pairs into an array
		var urlVars = urlHalves[1].split('&');
		//loop over the list, and find the specified url variable
		for(i=0; i<=(urlVars.length); i++)
		{
			if(urlVars[i])
			{
				//load the name/value pair into an array
				var urlVarPair = urlVars[i].split('=');
				if (urlVarPair[0] && urlVarPair[0] == urlVarName) 
				{
					//I found a variable that matches, load it's value into the return variable
					urlVarValue = urlVarPair[1];
				
				}
			}
		}
	}
	return urlVarValue;   
}

function toggleDiv(divid)
{
	//section=lodging&sid=1&cid=31&scid=32
	var section = getURLVar("section");
	var sid = getURLVar("sid");
	var cid = getURLVar("cid");
	var scid = getURLVar("scid");
	
	var url = "listings.php?section=" + section + "&sid=" + sid + "&cid=" + cid + "&scid=" + scid;
	
	if(document.getElementById(divid).style.display == 'none')
	{
	  //document.location.href = url;
	  document.getElementById(divid).style.display = 'block';
	  //writeDebug(url);
	}
	else
	{
	  document.getElementById(divid).style.display = 'none';
	  //writeDebug(url);
	}
}
