function switchHotel(divid) {
	var divelement = document.getElementById('hotel-' + divid);
	var imgelement = document.getElementById('img-' + divid);
	if (divelement.innerHTML.length > 2  ) {
		divelement.innerHTML = "";
		imgelement.src = "/images/ico_plus.gif"; 
	} else {
		caricaTesto('/code/hotel-scheda.php?hid=' + divid,'hotel-' + divid );
		imgelement.src = "/images/ico_minus.gif";
	}
}


function mmenu(mID) {
	var menu = document.getElementById(mID);
	var display = menu.style.display;
	menu.style.display = (display == "block") ? "none" : "block";
}

function dmenu(mID) {
	var menu = document.getElementById(mID);
	var mclasse = 'hide';
	var mclass = ( document.getElementById(mID).className == mclasse)  ? "block" : "hide";
	document.getElementById(mID).className = mclass;
	
	var imgID = mID + "-img";
	var classe = 'minus';
	var imgclass = ( document.getElementById(imgID).className == classe)  ? "plus" : "minus";
	document.getElementById(imgID).className = imgclass;
}

function enlargeImage(id){
   var Image = document.getElementById(id); 
   Image.width="300";
}

function dropImage(id){
   var Image = document.getElementById(id); 
   Image.width="200";
}

function mvoli(mID) {
	var menu = document.getElementById(mID);
	document.getElementById('voli-selected').innerHTML = "";
  document.getElementById('voli-selected').innerHTML = document.getElementById("voli-" + mID).innerHTML;
  if ("label-" + mID == "label-destinazionepaese") {
  	document.getElementById("label-destinazionepaese").className = "section-selected";
	} else {
  	document.getElementById("label-destinazionepaese").className = "section";
	};
	if ("label-" + mID == "label-partenza") {
  	document.getElementById("label-partenza").className = "section-selected";
	} else {
  	document.getElementById("label-partenza").className = "section";
	};
	if ("label-" + mID == "label-destinazione") {
  	document.getElementById("label-destinazione").className = "section-selected";
	} else {
  	document.getElementById("label-destinazione").className = "section";
	};
}



function switchDiv(origin,destination) {
	var orig = document.getElementById(origin);
	var dest = document.getElementById(destination);
	dest.innerHTML = orig.innerHTML;
	switchLabelEstero(origin);
}

function switchDivision(divid,divcontainer) {
  var divcont = document.getElementById(divcontainer);
  var debug = divid + "\n";
  var m =  divcont.childNodes;
  debug += divcont.innerHTML;
    for (i=0; i<m.length; i++) {
   		 debug += m[i].id; 	
   		 if ( m[i].id == divid ) {
   		 	m[i].className = "show";
   		 	debug += (" - OK! \n");
   		 } else {
   		 	m[i].className = "hide";
   		 	debug += (" - KO! \n");

   		 };
     };
//alert(debug);
switchLabel(divid,'labels-estero'); 
}
function switchLabelEstero(label) {
	var labelsDiv = document.getElementById('labels-estero');
	var labels = labelsDiv.getElementsByTagName('span');
	for( var i = 0; i < labels.length; i++ ) {
		if ( labels[i].id == 'label-' + label ) {
			labels[i].className = 'section-selected';
		} else {
			labels[i].className = 'section';
		}
	}
}

function switchLabel(labelid,labelcontainer) {
	var labelsDiv = document.getElementById(labelcontainer);
	var labels = labelsDiv.getElementsByTagName('span');
	for( var i = 0; i < labels.length; i++ ) {
		if ( labels[i].id == 'label-' + labelid ) {
			labels[i].className = 'section-selected';
		} else {
			labels[i].className = 'section';
		}
	}
}

//funzione invio mail ad un amico
function SendMailFriend(pagetitle,pageurl) {
	var pageurlencoded = escape(pageurl);
	var mailurl = 'mailto:?subject=' + pagetitle + '&body=%0A%0A' + pageurlencoded;
	location.href = mailurl;
}

//funzione creazione bookmark per mozilla explorer opera
function CreateBookmarkLink(title,url) {
	if (window.sidebar) { // Mozilla Firefox Bookmark
  		window.sidebar.addPanel(title, url, "");
	} else if ( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title ); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	}
}


function showAds () {
var how_many_ads = 5;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;


if (ad==1) {
//Lastminute.com -  AD/GE ID: 17381922 AD/GE name: it_rfp-468x60.swf 
var uri = 'http://impit.tradedoubler.com/imp?type(js)g(17381922)a(936781)' + new String (Math.random()).substring (2, 11);
document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
}

if (ad==2) {
//Feltrinelli - 468x60_gif
var uri = 'http://impit.tradedoubler.com/imp?type(js)g(17348164)a(936781)' + new String (Math.random()).substring (2, 11);
document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
}

if (ad==3) {
//Hotels.com - IT_468x60
var uri = 'http://impit.tradedoubler.com/imp?type(js)g(17949062)a(936781)' + new String (Math.random()).substring (2, 11);
document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
}

if (ad==4) {
//Hotels.com - it_rfs-468x60.gif
var uri = 'http://impit.tradedoubler.com/imp?type(js)g(17383382)a(936781)' + new String (Math.random()).substring (2, 11);
document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
} 


if (ad==5) {
//Airfrance - Caraibi_468x60
var uri = 'http://impit.tradedoubler.com/imp?type(js)g(18098676)a(936781)' + new String (Math.random()).substring (2, 11);
document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
} 


if ( ad==6 ) {
google_ad_client = "pub-6279831290719084";
google_ad_slot = "5071407863";
google_ad_width = 468;
google_ad_height = 60;
document.write('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>');
}

//document.write(ad);
}

/*
if (ad==1) {
//Lastminute.com - Vacanze
var uri = 'http://impit.tradedoubler.com/imp?type(js)g(172888)a(936781)' + new String (Math.random()).substring (2, 11);
document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
}

if (ad==2) {
//Lastminute.com - Voli
var uri = 'http://impit.tradedoubler.com/imp?type(js)g(181819)a(936781)' + new String (Math.random()).substring (2, 11);
document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');
}
*/

