// JavaScript Document

//--- Riconoscimento lingua ----
lingue = new Array('it','en','de','fr','es','hr')
lingua = leggiVariabile('lang');
if (lingua == 0) {
	var indirizzo = window.location.toString();
	var posizione = indirizzo.indexOf(".htm");
	var lingua=indirizzo.substring(posizione-2, posizione);}
var a=0;
for (i=0; i<lingue.length; i++) {
	if (lingua==lingue[i]) {a++}
}
if (a==0) {lingua='it'}
//------------------------------
function leggiVariabile(variabile) {
	var indirizzo = window.location.toString()+'&'; 
	var posizione_nome = indirizzo.indexOf(variabile + '='); 
	if (posizione_nome==-1) {
		variabile=0; }
	else {
		var sottostringa = indirizzo.substring(posizione_nome);
		var inizio=sottostringa.indexOf('='); 
		var fine=sottostringa.indexOf('&'); 
		var variabile=sottostringa.substring(inizio + 1, fine);}
	return variabile;
}

function calcolagiorni() {
	var datain=document.Modulo.sd.value;
	var dataout=document.Modulo.ed.value;
	anno1=datain.substring(6,10)
	mese1=datain.substring(3,5)
	giorno1=datain.substring(0,2)
	DATAIN = new Date(anno1, mese1-1, giorno1,23,59,59); // i mesi in js vanno da 0 a 11
	anno2=dataout.substring(6,10)
	mese2=dataout.substring(3,5)
	giorno2=dataout.substring(0,2)
	DATAOUT = new Date(anno2, mese2-1, giorno2);
	one_day = 1000 * 60 * 60 * 24 ;     // in millisecondi
	TODAY = new Date();
	DiffGiorni = Math.ceil((DATAOUT.getTime()-DATAIN.getTime())/(one_day));
	switch(lingua) {
		case "it": var text = new Array('Errore nella data','La data di arrivo è prima di Oggi !','La data di partenza è antecedente a quella di arrivo !'); break;
		default  : var text = new Array('Date error','Check in date is wrong, it is before today !','Check OUT date is before check IN date !'); break;}
	text[0] = '*** '+ text[0] +' !!! ***\n'
	/*if ( DATAIN < TODAY && DiffGiorni < 0 ) { DiffGiorni = 'Err'; alert(text[0]+text[1]+'\n'+text[2]); }
	else if ( DATAIN < TODAY ) { DiffGiorni = 'Err'; alert(text[0]+text[1]); }
	else if ( DiffGiorni < 0 ) { DiffGiorni = 'Err'; alert(text[0]+text[2]); }*/
	if ( DATAIN < TODAY && DiffGiorni < 0 ) { DiffGiorni = 'Err'; }
	else if ( DATAIN < TODAY ) { DiffGiorni = 'Err'; }
	else if ( DiffGiorni < 0 ) { DiffGiorni = 'Err'; }
	document.Modulo.notti.value=DiffGiorni;
}

function flags() {
	switch(lingua) 
	{
		case "it": var QUI_it = 'flagsmall_QUI'; break;
		case "en": var QUI_en = 'flagsmall_QUI'; break;
		case "de": var QUI_de = 'flagsmall_QUI'; break;
		case "fr": var QUI_fr = 'flagsmall_QUI'; break;
		case "es": var QUI_es = 'flagsmall_QUI'; break;
		case "hr": var QUI_hr = 'flagsmall_QUI'; break;
	}
	var lang = new Array('it','en','de','fr','es','hr');
	var QUI  = new Array(QUI_it,QUI_en,QUI_de,QUI_fr,QUI_es,QUI_hr);
	document.write('<div style="text-align:left">');
	for (i=0; i<lang.length; i++) {document.write('<a href="home_'+lang[i]+'.htm" onMouseOver="linguaflag_'+lang[i]+'()" onMouseOut="DelValoreLingua()"><img class="flagsmall" src="images/flag2_'+lang[i]+'.gif" id="'+QUI[i]+'"></a> ');}
	document.write('<span class="data">&nbsp;&nbsp;<a id="ValoreLingua"> </a></span></div>');
}

function map() {
   var w = 780;
   var h = 600;
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
   finestra=window.open('mappa.htm?lang='+lingua,'','width=' + w + ',height=' + h + ',top=' + t + ',left=' + l +'resizable=no, status=yes, menubar=no, location=no, toolbar=no, scrollbars=no');
   finestra.document.close();
}

function UnderConstruction() {
   var w = 360;
   var h = 320;
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
      window.open("underconstruction.htm","","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l +'resizable=no, status=yes, menubar=no, location=no, toolbar=no, scrollbars=no');
 }


function copyright() {
	data = new Date();
	year= data.getYear();
	if(year<1900)year+=1900;
	switch(lingua){
		case "it": testo = new Array('Tutti i diritti riservati','Contattami'); break;
		case "en": testo = new Array('All rights reserved','Contact me'); break;
		case "de": testo = new Array('Alle Rechte vorbehalten','Contact me'); break;
		case "fr": testo = new Array('Tous droits r&eacute;serv&eacute;s','Contact me'); break;
		case "es": testo = new Array('Todos los Derechos Reservados','Contact me'); break;
		case "hr": testo = new Array('Sva prava pridr&#382;ana','Contact me'); break;
	}
	document.write('&copy;2000-'+year+' - Nuovo Albergo Centro - '+testo[0]+' - Web Master: <a href="http://www.emmeciwebdesign.com/"  title="EMME CI web design">EMME CI web design</a>') }
 
function linguaflag_it() {
	 anchor = document.getElementById('ValoreLingua');
	 anchor.firstChild.data = 'ITALIANO';} 
function linguaflag_en() {
	 anchor = document.getElementById('ValoreLingua');
	 anchor.firstChild.data = 'ENGLISH';} 
function linguaflag_de() {
	 anchor = document.getElementById('ValoreLingua');
	 anchor.firstChild.data = 'DEUTSCH';}  
function linguaflag_fr() {
	 anchor = document.getElementById('ValoreLingua');
	 anchor.firstChild.data = 'FRANÇAIS';}
function linguaflag_es() {
	 anchor = document.getElementById('ValoreLingua');
	 anchor.firstChild.data = 'ESPAÑOL';}
function linguaflag_hr() {
	 anchor = document.getElementById('ValoreLingua');
	 anchor.firstChild.data = 'HRVATSKI';}

function DelValoreLingua() {
	 anchor = document.getElementById('ValoreLingua');
	 anchor.firstChild.data = '';}
	 
function Itinerari() {
   var w = 600;
   var h = 500;
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
      window.open("itinerari_it/it_castelli.htm","","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + 'resizable=no, status=yes, menubar=no, location=no, toolbar=no, scrollbars=no');
 }
 
function gratisTel() {
   var w = 470;
   var h = 520;
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
      window.open("gratistel.htm","","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + 'resizable=no, status=yes, menubar=no, location=no, toolbar=no, scrollbars=no');
}
 
function feedbackPopup () {
   var w = 400;
   var h = 420;
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
   window.open('feedbackPopup.htm','','width=' + w + ',height=' + h + ',top=' + t + ',left=' + l + 'resizable=no, status=yes, menubar=no, location=no, toolbar=no, scrollbars=no');
}


function facebook() {
   var w = 350;
   var h = 80;
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
   finestra=window.open('facebook.htm','','width=' + w + ',height=' + h + ',top=' + t + ',left=' + l +'resizable=no, status=yes, menubar=no, location=no, toolbar=no, scrollbars=no');
   finestra.document.close();
}

/*function menu() {document.write('<iframe src="menu_'+lingua+'.htm" class="iframeClass" scrolling=no frameborder=0></iframe>');}*/
function menu() {document.write('<script src="js/menu.js"></script>');}

function FP_preloadImgs() {//v1.0
 var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
 for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}

function news() {
	imgnew = ' <img src="images/new3.gif">';
	gratistelHref = '<a href="gratistel.htm" rel="iframe" class="lightview" title=\' ::  :: width: 470, height: 480\'>';
	news = new Array();
	news[0] = new Array('24-08-2007','Traduzione del sito in <a href="home_hr.htm">croato</a> da parte di <a href="http://www.e-nterpreting.com/" target="_blank">E-NTERPRETING</a>.','Site translation in <a href="home_hr.htm">croatian language</a> by <a href="http://www.e-nterpreting.com/" target="_blank">E-NTERPRETING</a>.');
	news[1] = new Array('14-10-2007','Da oggi puoi chiamarchi anche gratis tramite il servizio<br>'+gratistelHref+'<img border="0" src="images/gratistel.gif" width="70" height="40"></a>','From today you can call us gratis throw the service<br>'+gratistelHref+'<img border="0" src="images/gratistel.gif" width="70" height="40"></a>');
	news[2] = new Array('02-10-2007','Adesione all\'iniziativa "FVG Card", guarda di cosa si tratta nella <a href="offerte_it.htm">sezione Offerte</a>.','We join the "FVG card" service, look for it in the <a href="offerte_'+lingua+'.htm">Special Offers</a> section.');
	news[3] = new Array('06-11-2007','Aggiunta la sezione <a href="diconoDiNoi_it.htm">Dicono di noi</a>, con gli articoli e descrizioni dell\'albergo riportate su guide o giornali.','Inserted the <a href="diconoDiNoi_'+lingua+'.htm">Appraisal</a> section, with the articles or descriptions of our hotel reported in guides or magazines.');
	news[4] = new Array('18-11-2007','Aggiunta l\'area <a href="blog_it.htm">Feedback</a> in cui puoi aggiungere i tuoi commenti al nostro servizio, di quando ci hai fatto visita','Inserted the <a href="blog_'+lingua+'.htm">Feedback</a> section, in which you can add your comments about our service.');
	news[5] = new Array('24-12-2007','Sito completamente rinnovato !!!','Site re-styled !!!');
	news[6] = new Array('27-12-2007','<a href="links_it.htm#meteo">Situazione meteo</a> a Trieste in tempo reale.','<a href="links_'+lingua+'.htm#meteo">Wheather</a> at Triest in real time.');
	news[7] = new Array('02-05-2008','Aggiunta una sezione con <a href="trieste_it.htm">foto di Trieste</a>.','Added a section with <a href="trieste_'+lingua+'.htm">photos of Triest</a>.');
	news[7] = new Array('14-10-2008','L\'albergo ha ottenuto il riconoscimento del livello “a due stelle” dalla competente commissione  territoriale.','The hotel obtains the "2-star" recognition by the territorial qualified committee');
	news[8] = new Array('30-11-2008','Nuova sezione <a href="mappa_it.htm">Dove siamo</a> con tutte le informazioni più utili per raggiungere l\'albergo.','New <a href="mappa_'+lingua+'.htm">Map section</a> with all the informations to reech the hotel by car, plane or train.');
	nuove = 0;
	tot = news.length-1;
	if ( (lingua=='en')|(lingua=='es')|(lingua=='hr') ) {tot--}
	for ( i = tot; i>=0; i-- ) {
		if ( lingua=='it') {L = 1}
		else {L = 2}
		testo = news[i][L];
		data = news[i][0];
		if ( i >= (news.length - nuove) ) { data += imgnew}
		document.write('<tr valign="top"><td width="110" align="left">'+data+'</td><td align="left">'+testo+'</td></tr>')
	}
}

function meteo() {
	var tabMeteo = '<div style="z-index:1; margin-top:-66px;"><center><iframe  src="http://www.meteowebcam.org/forecast_day_exp.php?localita=Trieste" width="570" height="392" scrolling="no" frameborder="0" vspace="0" hspace="0" marginwidth="0" marginheight="0"></iframe></center></div>';
	meteo = new Array();
	meteo[0] = new Array('Piazza Unit&agrave; d\'Italia','&quot;Unit&agrave; d\'Italia&quot; Square','http://94.81.137.210/axis-cgi/mjpg/video.cgi?resolution=320x240&dummy=1232116875379','Rete Civica di Trieste','http://www.retecivica.trieste.it/webcam.asp');
	meteo[1] = new Array('Veduta di TRIESTE dalla postazione<br>radio di Monte Grisa','View from Montegrisa Church','http://www.cisar.it/ext_site/trieste/meteo/cam1.jpg','C.I.S.A.R. - Sezione di Trieste','http://trieste.cisar.it/');
	meteo[2] = new Array('Piazza Verdi','Verdi square','http://www.2bm.org/meteolink/webcam/webcam.jpg','2bm SOFTWARE','http://www.2bm.org/');
	meteo[3] = new Array('TRIESTE PORTO NUOVO<br>Vista del Golfo in direzione NW','The harbor - NW direction','http://www.osmer.fvg.it/~www/COMMON/WEBCAM/WebcamTrieste.jpg','ARPA OSMER FVG','http://www.osmer.fvg.it/');
	meteo[4] = new Array('TRIESTE S.CROCE - Vista del Golfo<br>(nello sfondo Trieste) in direzione SSE','View from Santa Croce - SSE direction','http://www.osmer.fvg.it/~www/COMMON/WEBCAM/WebcamAurisina.jpg','ARPA OSMER FVG','http://www.osmer.fvg.it/');
	testo = new Array('Webcam a cura di','Webcam service by');
	meteo[5] = new Array('TRIESTE - Vista verso il mare','Trieste and the sea','http://www.radiopuntozero.it/webcam/rpz_webcam_1.jpg','Radiopuntozero.it','http://www.radiopuntozero.it/');
	//meteo[5] = new Array();
	testo = new Array('Webcam a cura di','Webcam service by');
	document.write(tabMeteo + '<p class="linksTitle">WEBCAM</p><table align="center" width="100%" border="0" cellspacing="0" cellpadding="0">');
	tot = meteo.length;
	col = 2;
	righe = 3;
	k=0; colspan = 1 ;
	if ( lingua=='it') {L = 0}
	else {L = 1}
	for ( i=0; i < righe; i++ ) {
		document.write('<tr valign="bottom">');
		for ( j=0; j < col; j++ ) {
			if ( k == meteo.length-1 ) { colspan = 2 }
			if ( k != meteo.length ) {
			titolo = meteo[k][L];
			SRC = meteo[k][2];
			TXT = testo[L];
			sito = meteo[k][3];
			sitoHref = meteo[k][4];
			document.write('<td width="50%" colspan="'+colspan+'" align="center"><span style="font-size:13px">'+titolo+'</span><br><br><a href="'+SRC+'" class="lightview" rel="gallery[webcam]" title="Webcam"><img width="275" src="'+SRC+'"/></a><br><span style="font-size:9px">'+TXT+' <a href="'+sitoHref+'" target="_blank">'+sito+'</a></span><br><br></td>');
			k++}
		}
		document.write('</tr>');
	}
	document.write('</table>');
}