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

}
function showImagePopup(which,caption,w,h)
{	
  var x = (screen.width - (w+50)) / 2;
  var y = (screen.height - (h+75)) / 2;

  var html = "";
  var imgsrc = "./images/common/photos/" + which + ".jpg";
  var winFeatures = "width=" + (w+50) + ",height=" + (h+75) + ",left="+ x + ",top=" + y;
  //alert(winFeatures);
  html = html + "<html>\r\n<head>\r\n  <title>Comfortitalia - Photo Gallery</title>\r\n";
  html = html + "</head>\r\n<body TEXT='#993333' BGCOLOR='#FFFFFF'>\r\n";
  html = html + "<p align='center'><table border='0' width='" + w + "'><tr><td width='50%'align='left'><font face='Arial'>"+ caption + "</font></td><td width='50%'align='right'><font face='Arial'><a href='javascript:self.close();'>Close</a></font></td></tr></table>\r\n"; 
  html = html + "<img src='" + imgsrc + "' width='" + w + "' height='" + h + "' border='1'>\r\n</body>\r\n</html>\r\n";
  
  //html = html + "<img src='" + imgsrc + "' width='" + w + "' height='" + h + "' border='1'><br><font face='Arial'>" + caption + "</p>";
  //html = html + "<p> </p><p align='right'><a href='javascript:self.close();'>Close</a></p></font>\r\n</body>\r\n</html>\r\n";
    
  popWindow = open("","photos",winFeatures);
  popWindow.document.open();
  popWindow.document.writeln(html);
  popWindow.document.close();
  popWindow.opener = self;
  popWindow.focus();

}

function showApartments()
{
	loadProperPage("rome_apartments.htm");
}
function showRentals()
{
	loadProperPage("vacation_rentals_italy.htm");
}

function loadProperPage(thePage)
{
	// if the user got here through links on our site, just go back
	if (document.referrer.indexOf("comfortitalia.com") != -1) 
	{   
		// make sure the user came from the rentals page
		if (document.referrer.indexOf(thePage) != -1) 
		{
			history.go(-1);
		}
		else
		{
		location.href = thePage;
		}
	}
	// otherwise, the user came directly from a search engine 
	// or another site, load the requested page...
	else
	{
		location.href = thePage;
	}
}

function initPage(which,level,theLang)
{
	setSelButton(which,level,theLang);
}

function turnAllOff(level,theLang)
{
	setButton('home',level,theLang,"off");
	setButton('apartment_rome',level,theLang,"off");
	setButton('hotels', level,theLang,"off");
	setButton('rental_italy',level,theLang,"off");
	setButton('about',level,theLang,"off");
	setButton('comments',level,theLang,"off");
	setButton('booking_reservation',level,theLang,"off");
	setButton('italy_rome_links',level,theLang,"off");
	setButton('contact',level,theLang,"off");
	
}

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


/*function setIndicator(which, level)
{

	document.images['indicator'].src = buildPath(which,level,null,"sel");

//"images/" + which + "_con.gif";
}
*/

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;
	//alert(buildPath(which, level, lang, "on"));
	setButton(which, level, lang, "on");
}

function turnOff(which, level, lang)
{
	
	if(isSel(which))
		return;
	//alert(buildPath(which, level, lang, "on"));
	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 buildHelpPath(which, level, lang)
{
	path = "";

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

	path +=	"help/" + 
		(lang==null?"":lang) +
		(lang==null?"":"/") +
		which;
	return(path);
}

function replaceImage(which,imgName)
{
	document.images[which].src = "../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;	

}



