//used to preload menu items
var theLevel=0; var theLang=null;
if(document.images)
{
//these are already on all pages - eventually move them off the pages
//	image1 = preLoad('buttons', theLevel, theLang, "on");
//	image3 = preLoad('email', theLevel, theLang, "on");

//	image5 = preLoad('span', theLevel, theLang, "on");
//	image7 = preLoad('ital', theLevel, theLang, "on");
	image9 = preLoad('fran', theLevel, theLang, "on");
	image11 = preLoad('sitemap', theLevel, theLang, "on");
}

function showPopup(which,w,h)
{
  popWindow = open(which,"popup","width=" + w + ",height=" + h + ",dependent,resizable,scrollbars,menubar");
  popWindow.opener = self;
  popWindow.focus();

}

function goBack(theLocation)
{
	// if the user got here through links on our site, just go back
	if (document.referrer.indexOf("heritageconservation.net") != -1) 
	{   
		history.go(-1);
	}
	// otherwise, the user came directly from a search engine 
	// or another site, load the requested page...
	else
	{
		location.href=theLocation;
	}
	
}
function turnAllOff(level,theLang,imgName)
{
	setButton('home',level,theLang,"off",imgName);
	setButton('about',level,theLang,"off",imgName);
	setButton('participant',level,theLang,"off",imgName);
	setButton('register',level,theLang,"off",imgName);
	setButton('past',level,theLang,"off",imgName);
	setButton('comments',level,theLang,"off",imgName);
	setButton('brochure',level,theLang,"off",imgName);
	setButton('workshops',level,theLang,"off",imgName);
	setButton('suggest',level,theLang,"off",imgName);
	setButton('news',level,theLang,"off",imgName);
	setButton('links',level,theLang,"off",imgName);
	setButton('support',level,theLang,"off",imgName);
	setButton('sponsors',level,theLang,"off",imgName);
	setButton('contact',level,theLang,"off",imgName);
}

function setSelButton(which, level, theLang,imgName)
{
	turnAllOff(level,theLang,imgName);
	if(which != "" && document.images[which])
	{
		document.images[which].src = buildPath(imgName,level,theLang,"sel");
		//document.images['bottom'].src = buildPath('bottom',level,theLang,which);
		//document.images['toph'].src = buildPath('top',level,theLang,which);
	}

}

function preLoad(which, level, lang, setting)
{
	theImage = new Image();
	//alert(buildPath(which, level, lang, setting));
	theImage.src = buildPath(which, level, lang, setting);
	return(theImage);
}

function turnOn(which, level, lang, imgName)
{
	if(isSel(which))
		return;
	setButton(which, level, lang, "on", imgName);
}

function turnOff(which, level, lang, imgName)
{
	
	if(isSel(which))
		return;
	setButton(which, level, lang, "off", imgName);
}

function setButton(which, level, lang, setting, imgName)
{	
	document.images[which].src = buildPath(imgName, level, lang, setting);
}


function buildPath(imgName, level, lang, setting)
{
	path = "";

	for(i=0;i<level;i++)
	{
		path += "../";
	}

	path +=	"images/" + 
		(lang==null?"":lang) +
		(lang==null?"":"/") +
		imgName + 
		(setting==null?"":"_"+setting) +
		".gif";
	return(path);
}

function replaceImage(which,level,lang,imgName)
{
	document.images[which].src = buildPath(imgName,level,lang,null)
//"../images/" + imgName + ".gif";
}

/* determines if button is selected in order to disable/enable mouseover functions*/
function isSel(which)
{
	if(document.images[which] &&
	   document.images[which].src &&
	   document.images[which].src.indexOf("_sel") == -1)
		return false;
	else
		return true;	
	
}