//rewritten to support GP-specific forms

function setPage(objElement)
{
	var curValue = objElement.options[objElement.selectedIndex].value;
	location.href = location.pathname+curValue;
}

function toggle(nbr, obj, rootPath)
{
	var target = document.getElementById('node' + nbr);
	var imgObj = obj.getElementsByTagName("img");
	if (target.style.display == "none")
	{
		target.style.display = "block";
		imgObj[0].src = rootPath+"/Images/Arrows/red_down.gif";
	} else if (target.style.display == "block")
	{
		target.style.display = "none";
		imgObj[0].src = rootPath+"/Images/Arrows/red_right.gif";
	}
}

// expand/collapse all div's with an id of node???
function toggleAll(opt, rootPath)
{
	var x = document.getElementsByTagName("DIV");
	var y = document.getElementsByTagName("img");
	var dsp = (opt == 0) ? "none" : "block";
	var pic = (opt == 0) ? rootPath+"/Images/Arrows/red_right.gif" : rootPath+"/Images/Arrows/red_down.gif";
	var n = new String();
	var gif;
	for(var i=0; i<x.length; i++)
	{
		n = x[i].id;
		if( n.indexOf("node") != -1)
			x[i].style.display = dsp;
	}
	for(var i=0; i<y.length; i++)
	{
		y[i].src = pic;
	}
}

// Opens up popup in new window for Group Partner site
function sendToMarriott(path)
{	
	
	var protocol = window.location.protocol;
	var hostLocation = window.location.host;
	var hostArray = hostLocation.split('.');
	
	var isGpSite= "false";
	var isTaSite= "false";
	
	for ( var i= 0 ; i< hostArray.length; i++)
	{
		if(hostArray[i] == 'grouppartners')
		{
			isGpSite = "true"
			
			
		}
		else if (hostArray[i] == 'travelagents')
		{
			isTaSite = "true";
			
		}
		
	}
	
	var fullPopupPath = protocol+"//";
	if((isGpSite == "true") || (isTaSite == "true"))
	{
		if(hostArray[0] == "www")
		{
			//fullPopupPath += "www.";
			for( var i= 2; i< hostArray.length; i++)
			{
				if(i != hostArray.length-1)
				{
					fullPopupPath += hostArray[i]+".";
				}
				else
				{
					fullPopupPath += hostArray[i]
				}
			}
			fullPopupPath += path;
		}
		else
		{
			for(var i= 1; i<hostArray.length; i++)
			{
				if(i != hostArray.length-1)
				{
					fullPopupPath += hostArray[i]+".";
				}
				else
				{
					fullPopupPath += hostArray[i];
				}
			}
			fullPopupPath += path;
		}
		
	}
	else
	{
		fullPopupPath += hostLocation+path;
	}
	window.open(fullPopupPath, "_blank");

}