function openAD(fileName, width, height, scroll) {
	var s = scroll ? 1 : 0;
	var w = width ? width : 480;
	var h = height ? height : 160;
	var popup = window.open("", "AD", "resizable=0,location=0,menubar=0,scrollbars=" + s + ",status=0,toolbar=0,left=10,top=10,width=" + w + ",height=" + h);
	
	popup.location = fileName;
}

function openNews(lang) {
	var width = 320;
	var height = 360;
	var left = ",left=" + (window.screen.width - width - 20);
	var top = ",top=" + (window.screen.height - height - 40);
	var width = ",width=" + width;
	var height = ",height=" + height;
	var features = "resizable=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0" + left + top + width + height;
	var popup = window.open("", "News", features);
	
	popup.location = "/" + lang + "/news.htm";
	
}

function openPage(from) {
	var path = String(from), p, folder = "", tmp, args = "";
	
	p = path.indexOf("?");
	if (p != -1) {
		args = "&content=" + path.substr(p + 1);
		path = path.substr(0, p);
	}
	
	p = path.lastIndexOf("/");
	path = path.substr(0, p);
	
	do {
		p = path.lastIndexOf("/");
		tmp = path.substr(p);
		folder = tmp + folder;
		if ("/it/es/fr/de/uk/".indexOf(tmp) != -1)
			break;
		path = path.substr(0, p);
	} while (p != -1)
	folder = folder.substr(1);
	tmp = tmp.substr(1);
	if (folder == tmp && args == "") {
		openNews(tmp);
		// openAD("/" + tmp + "/invocazioni.htm");
		// openAD("/" + tmp + "/tempi_forti/cammino_avvento_natale/index.htm", 512, 256, true);
	}

	if (path.substr(0, 8) == "file:///")
		path = "http://toshiba/";
	else
		path = "/";
	
	window.location.replace(path + "loadPage.asp?path=" + folder + "&title=" + document.title + args);
	
}
