/*PRINT*/
function printit(){  
if (NS) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);
WebBrowser1.outerHTML = "";  
}
}



function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
//-->
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function loadpage() {
browver= parseInt(navigator.appVersion);
browtype = navigator.appName;
browsertype = "old";
if (browtype == "Netscape" && !(browver < 3)) {
browsertype = "new"; 
}
if (browtype == "Microsoft Internet Explorer" && !(browver < 4)) {
browsertype = "new";
}
if (browsertype == "new") {
thetimer = setTimeout("changeimage()", 3000);
banneradcode = 1;
listofimages = new Array(10);
listofimages[1] = new Image(170,145)
listofimages[1].src = "http://srv2.realcam.it/live/pub/2-1.jpg"
listofimages[2] = new Image(170,145)
listofimages[2].src = "http://srv2.realcam.it/live/pub/2-2.jpg"
listofimages[3] = new Image(170,145)
listofimages[3].src = "http://srv2.realcam.it/live/pub/2-3.jpg"
listofimages[4] = new Image(170,145)
listofimages[4].src = "http://srv2.realcam.it/live/pub/2-4.jpg"
listofimages[5] = new Image(170,145)
listofimages[5].src = "http://srv2.realcam.it/live/pub/2-5.jpg"
listofimages[6] = new Image(170,145)
listofimages[6].src = "http://srv2.realcam.it/live/pub/2-6.jpg"
listofimages[7] = new Image(170,145)
listofimages[7].src = "http://srv2.realcam.it/live/pub/2-7.jpg"
listofimages[8] = new Image(170,145)
listofimages[8].src = "http://srv2.realcam.it/live/pub/2-8.jpg"
listofimages[9] = new Image(170,145)
listofimages[9].src = "http://srv2.realcam.it/live/pub/2-9.jpg"
listofimages[10] = new Image(170,145)
listofimages[10].src = "http://srv2.realcam.it/live/pub/2-10.jpg"



}
}

function changeimage(){
if (browsertype == "new") {
banneradcode = banneradcode + 1
if (banneradcode == "10") {
banneradcode = 1
}
imagesource = "http://srv2.realcam.it/live/pub/2-" + banneradcode + ".jpg"
window.document.bannerad.src = imagesource
thetimer = setTimeout("changeimage()", 3000);
}
else if (browsertype == "old") {
}
}

function changepage() {
if (browsertype == "new") {
if (banneradcode == 1) {
newlocation = "http://srv2.realcam.it/predefinite/2/pre1.html"
}
else if (banneradcode == 2) {
newlocation = "http://srv2.realcam.it/predefinite/2/pre2.html"
}
else if (banneradcode == 3) {
newlocation = "http://srv2.realcam.it/predefinite/2/pre3.html"
}
else if (banneradcode == 4) {
newlocation = "http://srv2.realcam.it/predefinite/2/pre4.html"
}
else if (banneradcode == 5) {
newlocation = "http://srv2.realcam.it/predefinite/2/pre5.html"
}
else if (banneradcode == 6) {
newlocation = "http://srv2.realcam.it/predefinite/2/pre6.html"
}
else if (banneradcode == 7) {
newlocation = "http://srv2.realcam.it/predefinite/2/pre7.html"
}
else if (banneradcode == 8) {
newlocation = "http://srv2.realcam.it/predefinite/2/pre8.html"
}
else if (banneradcode == 9) {
newlocation = "http://srv2.realcam.it/predefinite/2/pre9.html"
}
else if (banneradcode == 10) {
newlocation = "http://srv2.realcam.it/predefinite/2/pre10.html"
}
	window.open(newlocation,'','scrollbars=no,width=352,height=288');void('');
}
else if (browsertype == "old") {
location = "http://www.ski.it"
}
}

//FUNZIONE PER IL NUMERO DI TELEFONO
function IsNumeric(sText)
	{
	   var ValidChars = "0123456789.-";
	   var IsNumber=true;
	   var Char;


	   for (i = 0; i < sText.length && IsNumber == true; i++)
	      {
	      Char = sText.charAt(i);
	      if (ValidChars.indexOf(Char) == -1)
	         {
	         IsNumber = false;
	         }
	      }
	   return IsNumber;
}

// FUNZIONE CHE CONTROLLA LA VALIDITÀ DELLE EMAIL INSERITE
function controlla_email(email) {
	if (email!="") {
		re = /^[0-9a-z]([-_\.]?[0-9a-z])*@[0-9a-z]([-_\.]?[0-9a-z])*\.[a-z]{2,4}$/i;
		if ( re.test(email) ) return true
		return false
	} else return true;
} //end func


function Verificanewsletter(){
	var error = '';
	var email = document.newsletter.email.value;

		if (document.newsletter.nome.value=='')
			error = error + 'Inserire il nome.\n';

		if (email.length == 0){
			error = error + 'Inserire indirizzo email.\n'
		}else{
			if (!controlla_email(email))
				error = error + 'Email non è stata inserita correttamente.\n';
		}

		if (error == ''){
			window.open("http://asp.infotel.it/config/HRAV/newsletter/cgi/iscrizione_web.html?email="+document.newsletter.email.value+"&nome="+document.newsletter.nome.value+"&lingua="+document.newsletter.lingua.value+"&hotel="+document.newsletter.hotel.value,"Iscrizione","width=500, height=150, scrollbars,toolbar=no,location=no,directories=no,status=no,menubar=no");
			//document.newsletter.submit();
			return true;
		}else{
			alert(error);
			return false;
		}
}

function Verificalavoraconnoi(){
	var error = '';
	var email = document.lavora.email.value;

		if (document.lavora.nome.value=='')
			error = error + 'Inserire il nome.\n';

		if (document.lavora.cognome.value=='')
			error = error + 'Inserire il cognome.\n';


		if (email.length == 0){
			error = error + 'Inserire indirizzo email.\n'
		}else{
			if (!controlla_email(email))
				error = error + 'Email non è stata inserita correttamente.\n';
		}

		if (error == ''){
			document.lavora.submit();
			return true;
		}else{
			alert(error);
			return false;
		}
}


function Verificaguestbook(){
	var error = '';
	var email = document.book.emailbook.value;

		if (document.book.titolo.value=='')
			error = error + 'Inserire il titolo.\n';

		if (email.length == 0){
			error = error + 'Inserire indirizzo email.\n';
		}else{
			if (!controlla_email(email))
				error = error + 'Email non è stata inserita correttamente.\n';
		}

		if (document.book.testo.value=='')
			error = error + 'Inserire il testo.\n';

		if (error == ''){
			document.book.submit();
			return true;
		}else{
			alert(error);
			return false;
		}
}



/*Controllo campi form prenota*/
function Verifica(){
		var error = '';
		var email = document.prenota.emailusu.value;
		var tel = document.prenota.cod_tel.value + document.prenota.pre_tel.value + document.prenota.suf_tel.value;
		
		if (document.prenota.nome.value=='')
			error = error + 'Inserire il nome.\n';
		if (document.prenota.cognome.value=='')
			error = error + 'Inserire il cognome.\n';

		/*Inserire controllo sulle date*/
		data_arrivo=new Date()
		data_partenza=new Date()
		today = new Date()
		today=Date.parse(today);
		//data di arrivo
		dal_mm=new String()
		dal_mm=document.prenota.dal_mm.options[document.prenota.dal_mm.selectedIndex].value;
		dal_gg=new String()
		dal_gg=document.prenota.dal_gg.options[document.prenota.dal_gg.selectedIndex].value;
		dal_aa=new String()
		dal_aa=document.prenota.dal_aa.options[document.prenota.dal_aa.selectedIndex].value;
		data_arrivo=new Date( dal_mm + "/" + dal_gg + "/" + dal_aa );
		data_arrivo=Date.parse(data_arrivo);

		//data di partenza
		al_mm=new String()
		al_mm=document.prenota.al_mm.options[document.prenota.al_mm.selectedIndex].value;
		al_gg=new String()
		al_gg=document.prenota.al_gg.options[document.prenota.al_gg.selectedIndex].value;
		al_aa=new String()
		al_aa=document.prenota.al_aa.options[document.prenota.al_aa.selectedIndex].value;
		data_partenza=new Date( al_mm + "/" + al_gg + "/" + al_aa );
		data_partenza=Date.parse(data_partenza);

		if (data_arrivo <= today) {
			error = error + 'La data di arrivo non può essere inferiore dalla data odierna.\n'
		}
		if (data_partenza < data_arrivo) {
			error = error + 'La data di partenza non può essere inferiore dalla data di arrivo.\n'
		}

		if (email.length == 0)
		{
			error = error + 'Inserire indirizzo email.\n'
		}else{
			if (!controlla_email(email))
				error = error + 'Email non è stata inserita correttamente.\n';
		}
		
		if (document.prenota.cod_tel.value !='' && document.prenota.pre_tel.value !='' & document.prenota.suf_tel.value!='')
		{
			if (!IsNumeric(tel))
				error = error + 'Il telefono deve essere un campo numerico.\n'
			if (window.prenota.telefono.options[window.prenota.telefono.selectedIndex].value=='')
			{
				error = error + 'Selezionare il tipo di telefono.\n';
			}
		}else{
			if (tel.length != 0)
				error = error + 'Inserire il telefono.\n';
		}
		
		if (document.prenota.commenti.value.length >500)
			error = error + 'Il commento non deve superare i 500 caratteri.\n'

		if (document.prenota.check_invio.checked==false)
			error = error + 'Non è possibile inoltrare la prenotazione senza accetare le condizioni sulla privacy.\n\n \"Grazie.\"\n'
			
				
		if (error == ''){
			document.prenota.submit();
		return true;
		}else{
			alert(error);
			return false;
		}
			
	}

var visualizzato='';
function stampa_contenuti(id) {

	if (visualizzato==id) {
		str='';
		visualizzato='';
	} else {
		str= document.getElementById(id).innerHTML;
		visualizzato=id;
	}
	if(document.getElementById)
		document.getElementById('contenuti_correlati').innerHTML = str;
	else {
		contenuti_correlati.document.write(str);
		contenuti_correlati.document.close();
	}

}

function chiudi_contenuti() {
		contenuti_correlati.document.close();
}


x = 20;
y = 70;
function setVisible(obj)
{
	obj = document.getElementById(obj);
	obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
}
function placeIt(obj)
{
	obj = document.getElementById(obj);
	if (document.documentElement)
	{
		theLeft = document.documentElement.scrollLeft;
		theTop = document.documentElement.scrollTop;
	}
	else if (document.body)
	{
		theLeft = document.body.scrollLeft;
		theTop = document.body.scrollTop;
	}
	theLeft += x;
	theTop += y;
	obj.style.left = theLeft + 'px' ;
	obj.style.top = theTop + 'px' ;
	setTimeout("placeIt('" + obj+ "')",500);
}