function showPopup(which,w,h)
{
  popWindow = open(which,"popup","width=" + w + ",height=" + h + ",dependent,resizable,scrollbars,menubar");
  popWindow.opener = self;
  popWindow.focus();

}

function turnAllOff(level,theLang)
{
	setButton('home',level,theLang,"off");
	setButton('cv',level,theLang,"off");
	setButton('servizi',level,theLang,"off");
	setButton('aree',level,theLang,"off");
	setButton('links',level,theLang,"off");
	setButton('contatti',level,theLang,"off");
	if(theLang == 'eng')
		setButton('italiano',level,theLang,"off");
	else
		setButton('english',level,theLang,"off");
}

function setSelButton(which, level, theLang)
{
	
	turnAllOff(level,theLang);
	if(which != "" && document.images[which])
	{
		//alert(buildPath(which, level, theLang, sel));
		document.images[which].src = buildPath(which,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)
{
	if(isSel(which))
		return;
	setButton(which, level, lang, "on");
}

function turnOff(which, level, lang)
{
	
	if(isSel(which))
		return;
	setButton(which, level, lang, "off");
}

function setButton(which, level, lang, setting)
{	
	//alert(buildPath(which, level, lang, setting));
	document.images[which].src = buildPath(which, level, lang, setting);
}


function buildPath(which, level, lang, setting)
{
	path = "";

	for(i=0;i<level;i++)
	{
		path += "../";
	}

	path +=	"images/" + 
		(lang==null?"":lang) +
		(lang==null?"":"/") +
		which + 
		(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;	
	
}
	
