var mainmtabs={
	subcontainers:[], last_accessed_tab:null,
	revealsubmenu:function(curtabref){
	this.hideallsubs()
	if (this.last_accessed_tab!=null)
		this.last_accessed_tab.className=""
	if (curtabref.getAttribute("rel")) //If there's a sub menu defined for this tab item, show it
	document.getElementById(curtabref.getAttribute("rel")).style.display="block"
	var test6= new String(curtabref);
	curtabref.className="current"+test6.substring(test6.length-1);
	this.last_accessed_tab=curtabref;
	},

	hideallsubs:function(){
	for (var i=0; i<this.subcontainers.length; i++)
		document.getElementById(this.subcontainers[i]).style.display="none"
	},

	init:function(menuId, selectedIndex){
	var tabItems=document.getElementById(menuId).getElementsByTagName("a")
		for (var i=0; i<tabItems.length; i++){
			if (tabItems[i].getAttribute("rel"))
				this.subcontainers[this.subcontainers.length]=tabItems[i].getAttribute("rel") //store id of submenu div of tab menu item
			if (i==selectedIndex){ //if this tab item should be selected by default
				var ttt="current"+selectedIndex;
				tabItems[i].className=ttt;
				this.revealsubmenu(tabItems[i])
			}
		tabItems[i].onclick=function(){
		mainmtabs.revealsubmenu(this);
		}
		} //END FOR LOOP
	}
}


function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

function toggleAllCities(elem)
{
	val = elem.checked;
	if (val)
	{
		Set_Cookie('allCities', '1', '1', '/', '', '');
	}
	else
	{
		Set_Cookie('allCities', '0', '1', '/', '', '');
	}
}

function toggleAllCitiesCustom(v, elem)
{
	val = elem.checked;
	if (val)
	{
		Set_Cookie('allCities'+v, '1', '1', '/', '', '');
	}
	else
	{
		Set_Cookie('allCities'+v, '0', '1', '/', '', '');
	}
}
