///////////////////////////////////////////////////////////////////////////////////////////////////
function sideswitch(to_side_name)
/*


disable this for bristoldev...is hidin maplayers_sidebar...use gFloatingInterface



*/
{
	if( document.forms[0].app.value == 'bristol_dev')//fkg undef
		return;
	if( from_side_name == to_side_name)
		return;//do nothing if active one hit

//FIRST set up sidebar from cookies if any by calling restore_<which>()....//(in case, say, changed but not applied)
	var restorefunc = "restore_" + to_side_name + "()";
	//if(typeof restorefunc == 'function')//-make dummy restores for all *NO NEED WITH THIS* BOGUS-type is string if not an unquoted literal
	try{ eval( restorefunc);}
	catch(e)	{	;	}//is ok...optional

	var blurfunc = "exit_" + from_side_name + "()";
	//if(typeof restorefunc == 'function')//-make dummy restores for all *NO NEED WITH THIS* BOGUS-type is string if not an unquoted literal
	try{ eval( blurfunc);}
	catch(e)	{	;	}//is ok...optional


//HIGHLIGHT NEW TAB optional...need not exist, IF THERE IS ONE (none for prefs,print)
	var to_tabid = "tab_"+to_side_name;
	var to_tab = document.getElementById( to_tabid);
	if( to_tab != null)
	{
		//to tab is brighter & has no onclick
		to_tab.style.color = "#052254";
		to_tab.style.background = "url(../IGIScommon/images/tab_1.gif)";
		//to_tab.style.background = "url(IGISimages/tab_1.gif)";
	}
//	else		alert("sideswitch: no elem with ID: "+to_tabid);

// DIM OLD TAB if was one
	var from_tab_id = "tab_"+from_side_name;
	//alert("sideswitch:"+from_side_name+": "+from_tab_id+"->"+to_tabid);
	var from_tab = document.getElementById( from_tab_id);
	if( from_side_name != "none" && from_tab != null)//was not first time, not a tab
	{
		//from-tab darkens & gets a click to its sidebar
		if( document.forms[0].app.value == 'citrus')
			from_tab.style.color = "#54101D";
		else
			from_tab.style.color = "#43639B";
		from_tab.style.background = "url(../IGIScommon/images/tab_0.gif)";
		//from_tab.style.background = "url(IGISimages/tab_0.gif)";
	}

//if(document.forms[0].app.value == 'citrus') alert(document.forms[0].app.value); 84, 16 29 #54101D

//if from print, hide stuff covering map
//NAH, do it always, will show cover after
//if( to_side_name != "print" && to_side_name != "help")//TODO: generalize
	hide_cover_map_div();
//if to print, show preview
	if( to_side_name == "print")
		printPreview();

	if( to_side_name == "help")
		showHelp();

	if( to_side_name == "help_custom")
	{
		show_cover_map_div();//caller needs to call showHelp(custompage.html); after
		to_side_name = "help";//so it gets side_help div
	}

	if( to_side_name == "admin")
		showAdmin();

	if( to_side_name == "fcb_status")
		showFCBStatus();


//SHOW NEW SIDEBAR
	var to_side_id = "side_"+to_side_name;
	var to_side_div = document.getElementById( to_side_id);
//alert("sideswitch:"+to_side_id+"-display="+to_side_div.style.display);
	if( to_side_div != null)
		to_side_div.style.display = "inline";

//FOOTER BUTTONS optional- separate so it does not scroll w/sidebar & can be half outside
	to_foot_id = "foot_"+to_side_name;
	to_foot_div = document.getElementById( to_foot_id);
	if( to_foot_div != null)
		to_foot_div.style.display = "inline";

//HIDE OLD SIDEBAR//FOOT
	if( from_side_name !="none")
	{
		var from_div = document.getElementById( "side_"+from_side_name);
//alert(from_side_name);
		if( from_div != null)
		{
			from_div.style.display = "none";
			foot_div = document.getElementById( "foot_"+from_side_name);
			if( foot_div != null)
				foot_div.style.display = "none";
		}
	}

/*NOT?
	from_div.visibility = "hidden";
	to_side_div.visibility  = "visible";
*/

	//save it in the form input for reloading state
//alert( "formval=document.forms[0]." + elemID + ".value=" + display_style + ";");
	eval( "document.forms[0].whichTab.value='" + to_side_name + "';" );
//NOGODDANYWHERE..............................................................ok here . mapview after reload

//alert("sideswitch: "+document.forms[0].whichTab.value);
	from_side_name = to_side_name;
}

function show_cover_map_div()
//don't need to turn on/off the map if z-order < cover (?)
{
//	alert("show_cover_map_div");
//	mapdiv = document.getElementById( "map");
//	mapdiv.style.display = "none";
	if( document.getElementById( "covermap"))
	{
		coverdiv = document.getElementById( "covermap");
		coverdiv.style.display = "inline";
	}
}

function hide_cover_map_div()
{
//	alert("hide_cover_map_div");
//don't need to turn on/off the map if z-order < cover (?)
//	mapdiv = document.getElementById( "map");
//	mapdiv.style.display = "none";
	if( document.getElementById( "covermap"))//is a DIV! nay: document.forms[0].coverdiv != undefined)
	{
		var coverdiv = document.getElementById( "covermap");
		coverdiv.style.display = "none";
	}
//	mapdiv = document.getElementById( "map");
//	mapdiv.style.display = "inline";
}

///////////////////////////////////////////////////////////////////////////////////////
//show/hides thing w/given ID; sets cookie WITH SAME NAME
function setViz(elemID, display_style)//inline or none
{
	var elem = document.getElementById(elemID);
	if( elem == null)
		return;//may be remmed, etc
	var style = elem.style;
	style.display = display_style;//why does this work? copied the var!
//alert("setViz elem="+elem.id+" disp="+ elem.style.display+' set to:'+display_style);

	//save it in the form input for reloading state
//alert( "formval=document.forms[0]." + elemID + ".value=" + display_style + ";");
//	eval( "document.forms[0]." + elemID + ".value='" + display_style + "';" );//DOES NOT SURVIVE RELOAD: thus cookies

//COOKIE IT here for now
	setCookie( elemID, display_style, 365);
}

///////////////////////////////////////////////////////////////////////////////////////
//show/hides thing w/given ID; sets cookie WITH SAME NAME
function setVizNoCookie(elemID, display_style)//inline or none
{
	var elem = document.getElementById(elemID);
	if( elem == null || elem==undefined)
	{
		//alert(elemID +" is null, style="+display_style);
		return;//may be remmed, etc
	}
	elem.style.display = display_style;
}

///////////////////////////////////////////////////////////////////////////////////////
//show/hides thing w/given ID using value from input w/same name
function setVizOnLoad(elemID)//inline or none
{
//COOKIE WAY
	var value = getCookie( elemID);
	if(value == "")
		value="inline";
	setViz( elemID, value);

//FORM INPUT WAY
// eval( "setViz( elemID, document.forms[0]." + elemID + ".value);")
}

///////////////////////////////////////////////////////////////////////////////////////
//toggles visbility of the thing; cookies it
function toggleViz(elemID)
{
//alert("toggleViz:"+elemID);
	var display = document.getElementById(elemID).style.display;
	if( display == "none")
		display = "inline";
	else
		display = "none";
	setViz(elemID, display);
}


var minushtml = '<b>&nbsp;(--)</b>';
var plushtml = '<b>&nbsp;(+)</b>';

///////////////////////////////////////////////////////////////////////////////////////
// toggles the click thing (+) / (-)
function togglePlusMinusElem( plusMinusElemID)//UNUSED
{

	var oPlusMinusElem = document.getElementById( plusMinusElemID);
//disps all '' alert("togglePlusMinusElem: "+ visElemID+", "+plusMinusElemID+" disp="+oVisElem.style.display);
//alert("tog inner="+oPlusMinusElem.innerHTML+" plush="+plushtml);


	if( oPlusMinusElem.innerHTML.toLowerCase() == plushtml)//FKKG IE CAPS THE <b>
		oPlusMinusElem.innerHTML = minushtml;
	else
		oPlusMinusElem.innerHTML = plushtml;//- is low & small
//alert("tog innerafter="+oPlusMinusElem.innerHTML+" plush="+plushtml);
}

///////////////////////////////////////////////////////////////////////////////////////
// toggles the click thing (-) if visElemID visible (+) if not - flips innerhtml
//FKG IE: this makes closed fcps groups dbl spaced...even if oPlusMinusElem.innerHTML = '' not if no innerhtml;
function setPlusMinusElemByElemViz( visElemID, plusMinusElemID)
{
//alert("setPlusMinusElemByElemViz: "+ visElemID+', '+ plusMinusElemID);
	var oVisElem = document.getElementById( visElemID);
	var oPlusMinusElem = document.getElementById( plusMinusElemID);
//disps all '' alert("togglePlusMinusElem: "+ visElemID+", "+plusMinusElemID+" disp="+oVisElem.style.display);
	if( oVisElem.style.display == '' || oVisElem.style.display == 'block' || oVisElem.style.display == 'inline')//expander does block
		oPlusMinusElem.innerHTML = minushtml;
	else
		oPlusMinusElem.innerHTML = plushtml;//- is low & small


}

///////////////////////////////////////////////////////////////////////////////////////
// toggles the click thing (-) if visElemID visible (+) if not -- by show/hiding + & - elems
function setPlusMinusElemsByElemViz( oVisElem, oPlusElem, oMinusElem)
{
//alert("setPlusMinusElemsByElemViz: "+ visElemID+', '+ plusElemID+', '+ minusElemID);
/*	var oVisElem = document.getElementById( visElemID);
	var oPlusElem = document.getElementById( plusElemID);
	var oMinusElem = document.getElementById( minusElemID);
*/
//disps all '' alert("togglePlusMinusElem: "+ visElemID+", "+plusMinusElemID+" disp="+oVisElem.style.display);

/*



hit detailed get...(cultdev, not fcb)
Error: oVisElem is undefined
Source File: http://localhost/IGIScommon/toggle.js
Line: 241
called by update_all_maplayers_plusminusthings

*/
//if(oVisElem==undefined){ alert("oVisElem undef!");return;}

	if( oVisElem.style.display == 'none')//vis - show -
	{
		oPlusElem.style.display = 'inline';
		oMinusElem.style.display = 'none';
	}
	else//vis-show +
	{
		oPlusElem.style.display = 'none';
		oMinusElem.style.display = 'inline';
	}
}

////////////////////////////////////////////////////////////////////////////////////////
function toggleLayer(whichLayer)
{
	if (document.getElementById)
	{
		var style2 = document.getElementById(whichLayer).style;
//alert("toggleLayer: getElementById, disp="+style2.display);
		style2.display = style2.display? "":"none";//the
	}
	else if (document.all)
	{
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"none";
	}
	else if (document.layers)
	{
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"none";
	}
}

function toggleText(targetId)
{

	if (document.getElementById)
	{
		document.getElementById('infolink1').style.display = "none";
		document.getElementById('infolink2').style.display = "none";
		var style2 = document.getElementById(targetId).style;
		//style2.display = style2.display? "none":"block";
		style2.display = "block";
	}
	else if (document.all)
	{
		document.all['infolink1'].style.display = "none";
		document.all['infolink2'].style.display = "none";
		var style2 = document.all[targetId].style;
		//style2.display = style2.display? "none":"block";
		style2.display = "block";
	}
	else if (document.layers)
	{
		document.layers['infolink1'].style.display = "none";
		document.layers['infolink2'].style.display = "none";
		var style2 = document.layers[targetId].style;
		//style2.display = style2.display? "none":"block";
		style2.display = "block";
	}

}

function setDisplay(div,setting)
{
	if (document.getElementById)
		document.getElementById(div).style.display = setting;
}



