var numofferte = 0;
var siteext;

// riposizinamento di 'contenitore'
function Posizione() {
	if (document.body.clientHeight<550)
		document.getElementById("contenitore").style.top = "285px"
	if (document.body.clientWidth<900)
		document.getElementById("contenitore").style.left = "480px"
}

// precaricamento delle immagini
function preloadImgAll(args) {
	for (var i=0; i<arguments.length; i++) {
		preloadImgOne(arguments[i])
	}

	function preloadImgOne(percorso) {
		var temp = new Image()
		temp.src = percorso
	}
}
// precaricamento delle immagini (fine)

// gestione effetto menu
var oggetto
var funzione

function Scroll(quale) {
	switch(quale)
	{
		case 0:			// nasconde il menu
			clearInterval(funzione)
			document.getElementById("menu_1").style.top = -270 + "px"
			document.getElementById("menu_2").style.top = -270 + "px"
			document.getElementById("menu_3").style.top = -270 + "px"
			document.getElementById("menu_4").style.top = 550 + "px"
			break
		case 4:			// menu delle offerte speciali
			clearInterval(funzione)
			document.getElementById("menu_1").style.top = -270 + "px"
			document.getElementById("menu_2").style.top = -270 + "px"
			document.getElementById("menu_3").style.top = -270 + "px"
			document.getElementById("menu_4").style.top = 550 + "px"
			oggetto = "menu_" + quale
			posiz = parseInt(document.getElementById(oggetto).style.top)
			if (posiz > 508)
				funzione = setInterval("RipetiScrollSotto()", 1)
			break
		default:		// posiziona il menu 'quale' (1, 2 o 3)
			clearInterval(funzione)
			document.getElementById("menu_1").style.top = -270 + "px"
			document.getElementById("menu_2").style.top = -270 + "px"
			document.getElementById("menu_3").style.top = -270 + "px"
			document.getElementById("menu_4").style.top = 550 + "px"
			oggetto = "menu_" + quale
			posiz = parseInt(document.getElementById(oggetto).style.top)
			if (posiz < 0)
				funzione = setInterval("RipetiScroll()", 1)
	}
}

function RipetiScroll() {
	document.getElementById(oggetto).style.top = (parseInt(document.getElementById(oggetto).style.top)+10) + "px"
	if (parseInt(document.getElementById(oggetto).style.top) > 10)
		clearInterval(funzione)
}



function RipetiScrollSotto() {
	document.getElementById(oggetto).style.top = (parseInt(document.getElementById(oggetto).style.top)-5) + "px"
	if (parseInt(document.getElementById(oggetto).style.top) < 533-numofferte*23)
		clearInterval(funzione)
}
// gestione effetto menu (fine)


// scrive su html le voci dei 3 menu a tendina
var paghtml_it = new Array()
paghtml_it[0] = new Array('atmosfera.html','camere.html','tavola.html','attivita_sportive.html','arte_cultura.html','dove_siamo.html')
paghtml_it[1] = new Array('percorsi_thermal_anti_aging.html','fango_colli_euganei.html','acque_termali.html','cosa_curiamo.html','termalismo_moderno.html')
paghtml_it[2] = new Array('percorsi_salute_bellezza.asp','terra_acqua_fuoco_aria.html','settimana_a_tema.asp','termalismo_moderno_a_la_carte.html','regala_benessere.html')

var paghtml_de = new Array()
paghtml_de[0] = new Array('atmosphaere.html','zimmer.html','gastronomie.html','sportmoeglichkeiten.html','kunst_kultur.html','das_hotel_erreichen.html')
paghtml_de[1] = new Array('thermalbehandlungen_anti_aging.html','heilfango_der_euganeischen_huegel.html','thermalwasser.html','was_wir_behandeln.html','termalismo_moderno.html')
paghtml_de[2] = new Array('gesundheit_und_schoenheitsbehandlungen.asp','erde_wasser_feuer_luft.html','themenwochen.asp','termalismo_moderno_a_la_carte.html','wohlbefinden_schenken.html')

var paghtml_en = new Array()
paghtml_en[0] = new Array('atmosphere.html','rooms.html','dining.html','sporting_activities.html','art_culture.html','where_we_are.html')
paghtml_en[1] = new Array('anti_aging_treatments.html','mud_euganean_hills.html','spa_waters.html','what_we_treat.html','termalismo_moderno.html')
paghtml_en[2] = new Array('wellbeing_beauty_treatments.asp','earth_water_fire_air.html','themed_weeks.asp','termalismo_moderno_a_la_carte.html','gift_wellness.html')


var paghtml_fr = new Array()
paghtml_fr[0] = new Array('ambiance.html','chambres.html','table.html','activites_sportives.html','art_culture.html','comment_rejoindre_hotel.html')
paghtml_fr[1] = new Array('parcours_thermal_anti_aging.html','boues_collines_euganeennes.html','eaux_thermales.html','que_traitons_nous.html','termalismo_moderno.html')
paghtml_fr[2] = new Array('parcours_sante_beaute.asp','terre_eau_feu_air.html','semaines_a_theme.asp','termalismo_moderno_a_la_carte.html','offrir_sejour.html')

var paghtml_ru = new Array()
paghtml_ru[0] = new Array('atmosphere.html','rooms.html','dining.html','sporting_activities.html','art_culture.html','where_we_are.html')
paghtml_ru[1] = new Array('anti_aging_treatments.html','mud_euganean_hills.html','spa_waters.html','what_we_treat.html','termalismo_moderno.html')
paghtml_ru[2] = new Array('wellbeing_beauty_treatments.asp','earth_water_fire_air.html','themed_weeks.asp','termalismo_moderno_a_la_carte.html','gift_wellness.html')



// Toglie il menu aperto (menu in alto)
function CheckDim(altezza,evento,menu) {
	if (document.all)	{	// IE
		coordX = event.clientX
		coordY = event.clientY
	} else {
		coordX = evento.clientX
		coordY = evento.clientY
	}

	// guarda la posizione Y
	if (document.body.clientHeight>594)
		regolaY = (document.body.clientHeight-594)/2 + 32
	else
		regolaY = 20
	if ((coordY - regolaY)>(altezza+10))
		Scroll(0)

	// guarda la posizione X
	if (document.body.clientWidth>990)
		regolaX = (document.body.clientWidth-990)/2 + 12 + 323*menu
	else
		regolaX = 0
	if ((coordX - regolaX)<5 || (coordX - regolaX)>320)
		Scroll(0)
}

// Toglie il menu aperto (menu offerte)
function CheckDimOff(numoff,evento,deltaX) {
	if (document.all)	{	// IE
		coordX = event.clientX
		coordY = event.clientY
	} else {
		coordX = evento.clientX
		coordY = evento.clientY
	}

	// guarda la posizione Y
	if (document.body.clientHeight>594)
		regolaY = (document.body.clientHeight-594)/2 + 32
	else
		regolaY = 20
	if ((coordY - regolaY)<(535-20*numoff))
		Scroll(0)

	// guarda la posizione X
	if (document.body.clientWidth>990)
		regolaX = (document.body.clientWidth-990)/2 + 12 + deltaX
	else
		regolaX = 0
	if ((coordX - regolaX)<5 || (coordX - regolaX)>320)
		Scroll(0)
}



function Sini(str, n)
{
   if (n <= 0)
         return "";
   else if (n > String(str).length)
         return str;
   else
         return String(str).substring(0,n);
}



function ModificaArray(albergo){

	alb = Sini(albergo, 1)
	if (alb=='m'){
	paghtml_it[1][0] = 'percorsi_benessere.html'
	paghtml_de[1][0] = 'behandlungen_koerper_geist.html'
	paghtml_en[1][0] = 'treatments_body_mind.html'
	paghtml_fr[1][0] = 'parcours_corp_esprit.html'
	paghtml_ru[1][0] = 'treatments_body_mind.html'
	}

	if (alb=='d'){
	paghtml_it[1][0] = 'percorsi_osmosi_di_coppia.html'
	paghtml_de[1][0] = 'verwoehnprogramm_fuer_paare.html'
	paghtml_en[1][0] = 'osmosis_treatments_for_couples.html'
	paghtml_fr[1][0] = 'parcours_osmose_de_couple.html'
	paghtml_ru[1][0] = 'osmosis_treatments_for_couples.html'
	}

	if (alb=='r'){
	paghtml_it[1][0] = 'percorsi_active.html'
	paghtml_de[1][0] = 'behandlungen_active.html'
	paghtml_en[1][0] = 'active_treatments.html'
	paghtml_fr[1][0] = 'parcours_active.html'
	paghtml_ru[1][0] = 'active_treatments.html'
	}

	if (alb=='t'){
	paghtml_it[1][0] = 'percorsi_fango_forma.html'
	paghtml_de[1][0] = 'behandlungen_fango_form.html'
	paghtml_en[1][0] = 'fango_form_treatments.html'
	paghtml_fr[1][0] = 'parcours_boue_forme.html'
	paghtml_ru[1][0] = 'fango_form_treatments.html'
	}


}

function costruisci(albergo,lingua,menu){
	if (lingua=="en")
		siteext = "com"
	else
		siteext = lingua

	if (menu!=0)
		numero_voci=4
	else
		numero_voci=5
	Posizione()

	ModificaArray(albergo)

	for(var c=0; c<=numero_voci; c++){
		document.write("<a onmouseout=javascript:CheckDim(" + numero_voci*20 + ",event," + menu + ") href=" + eval('paghtml'+'_'+lingua)[menu][c] + "><img border=0 name=voce" + menu + c + " width=322 height=19 src=http://www.hoteltriestevictoria." + siteext + "/img/voce_" + menu + c + ".gif></a><br>")
		if(c!=numero_voci)
			document.write("<img width=322 height=1 src=../../img/sfondo_bianco.gif><br>")
	}
}
// scrive su html le voci dei 3 menu a tendina (fine)

// gestisce la selezione e l'ingrandimento dell'immagine
function cambia_immagine(quale,alto,sinistra,larghezza,altezza){
	eval("document.foto").src = "../img/" + quale + "_big.jpg"
	document.getElementById("copri_img").style.top = alto + "px"
	document.getElementById("copri_img").style.left = sinistra + "px"
	eval("document.patacca").style.width = larghezza + "px"
	eval("document.patacca").style.height = altezza + "px"
	document.getElementById("copri_img").style.width = larghezza + "px"
	document.getElementById("copri_img").style.height = altezza + "px"
}

function cambia_immagine_russo(quale,alto,sinistra,larghezza,altezza){
	eval("document.foto").src = "img/" + quale + "_big.jpg"
	document.getElementById("copri_img").style.top = alto + "px"
	document.getElementById("copri_img").style.left = sinistra + "px"
	eval("document.patacca").style.width = larghezza + "px"
	eval("document.patacca").style.height = altezza + "px"
	document.getElementById("copri_img").style.width = larghezza + "px"
	document.getElementById("copri_img").style.height = altezza + "px"
}
// gestisce la selezione e l'ingrandimento dell'immagine (fine)

// apertura popup piscine
deltay = 4
deltax = 3
var finquadro
function apri_piscina(quale,lar,alt) {
	margine_alto = (screen.height-500)/deltay
	margine_sin = (screen.width-780)/deltax
	window.open(quale,'sito','scrollbars=no,toolbar=no,top=' + margine_alto + ',left=' + margine_sin + ',screenY=' + margine_alto + ',screenX=' + margine_sin + ',directories=no,menubar=no,width='+ lar +',height='+ alt +',resizable=no');
}
// apertura popup piscine (fine)

// apertura popup dove siamo dettaglio
deltay = 4
deltax = 3
var finquadro
function apri_dettaglio() {
	margine_alto = (screen.height-500)/deltay
	margine_sin = (screen.width-780)/deltax
	window.open('dove_siamo_popup.html','sito','scrollbars=no,toolbar=no,top=' + margine_alto + ',left=' + margine_sin + ',screenY=' + margine_alto + ',screenX=' + margine_sin + ',directories=no,menubar=no,width=450px,height=500px,resizable=no');
}
// apertura popup dove siamo dettaglio (fine)

var	offerte_IT = new Array()
var	offerte_DE = new Array()
var	offerte_EN = new Array()
var	offerte_FR = new Array()
var	offerte_RU = new Array()

function ScriviDivOfferte(lin) {
	document.write("<img width=8 height=1 src=../../img/sfondo.gif>")
	if (eval('offerte_'+lin).length == 0) {
		document.write("<div onmouseout=javascript:CheckDimOff(1,event,320) style=font-size:11px;padding-left:8px;></div>")
		document.write("<img width=322 height=3 src=../../img/sfondo.gif><br><img width=322 height=1 src=../../img/sfondo_bianco.gif><br>")
		document.write("<img width=8 height=1 src=../../img/sfondo.gif>")
		numofferte = 0
	} else {
		for (t=0; t<eval('offerte_'+lin).length; t++) {
			document.write("<div onmouseout=javascript:CheckDimOff(" + eval('offerte_'+lin).length + ",event,320) style=font-size:11px;padding-left:8px;><a class=bianco href=" + eval('offerte_'+lin)[t][1] + ">" + eval('offerte_'+lin)[t][0] + "</a></div>")
			document.write("<img width=322 height=3 src=../../img/sfondo.gif><br><img width=322 height=1 src=../../img/sfondo_bianco.gif><br>")
		}
		numofferte = eval('offerte_'+lin).length - 1
	}
}

function ScriviDivOfferteRES(lin) {
	document.write("<img width=8 height=1 src=../../img/sfondo.gif>")
	if (eval('offerte_'+lin).length == 0) {
		document.write("<div onmouseout=javascript:CheckDimOff(1,event,485) style=font-size:11px;padding-left:8px;></div>")
		document.write("<img width=322 height=3 src=../../img/sfondo.gif><br><img width=322 height=1 src=../../img/sfondo_bianco.gif><br>")
		document.write("<img width=8 height=1 src=../../img/sfondo.gif>")
		numofferte = 0
	} else {
		for (t=0; t<eval('offerte_'+lin).length; t++) {
			document.write("<div onmouseout=javascript:CheckDimOff(" + eval('offerte_'+lin).length + ",event,485) style=font-size:11px;padding-left:8px;><a class=bianco href=" + eval('offerte_'+lin)[t][1] + ">" + eval('offerte_'+lin)[t][0] + "</a></div>")
			document.write("<img width=322 height=3 src=../../img/sfondo.gif><br><img width=322 height=1 src=../../img/sfondo_bianco.gif><br>")
		}
		numofferte = eval('offerte_'+lin).length - 1
	}
}
