// JavaScript Document Mostra Nascondi DIV (Gallery)
function HideDiv(ID){
			document.getElementById(ID).style.display='none';
		}
		
		function ShowDiv(ID){
			document.getElementById(ID).style.display='';
		}
		
		function ShowHideDiv(ID){
			if(document.getElementById(ID).style.display==''){
				/*HideDiv(ID);*/
			}else{
				HideAll("cat",5);
				ShowDiv(ID);
			}
		}
		
		function HideAll(prefix,iterations){
			for (i=1;i<=iterations;i++){
				HideDiv(prefix+i);
			}
		}
		
// JavaScript Gestione menu (Destinazioni)
function mmenu(mID) {
	var menu = document.getElementById(mID);
	var display = menu.style.display;
	menu.style.display = (display == "block") ? "none" : "block";
	menu.parentNode.style.listStyleImage = (display == "block") ? "url(files/nolines_plus.gif)" : "url(files/nolines_minus.gif)";
}

window.onload = function() {
	var uls = document.getElementsByTagName("ul");
	for (i=0;i<uls.length;i++) {
		if(uls[i].className=="submenu")uls[i].style.display = "none";
	}
}

// JavaScript Rollover Bandiere (Lingue)
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_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_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

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];}
}

// JavaScript Document Aggiungi a Preferiti
function CreateBookmarkLink() {
 var title = document.title;
 var url = location.href;
 if (title == '')
   title = "icastelli.net: history and luxury accommodations";
 if (url == '')
   url = "www.icastelli.net";
  // Blogger - Replace with <$BlogItemTitle$> 
  // MovableType - Replace with <$MTEntryTitle$>

  // Blogger - Replace with <$BlogItemPermalinkURL$> 
  // MovableType - Replace with <$MTEntryPermalink$>
  // WordPress - <?php bloginfo('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; }
 }

// JavaScript Document Apri Pop UP
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// JavaScript Document Apri Link Cart

function ShowAndHide(id1,id2){
if(document.getElementById){
    el1=document.getElementById(id1);
    el2=document.getElementById(id2);
    if(el1.style.display=="none"){
        el1.style.display="block";
        el2.style.display="none";
        }
    else{
        el1.style.display="none";
        el2.style.display="block";
        }
    }
}

// Selec Concatenate (età bambini)
maxc = 3;
function showChild(sel){
	frm = sel.form;
	n = sel.options[sel.selectedIndex].value;
	hideAll(frm);
	for(i=1;i<=n;i++){
     frm["num_"+i].style.display="inline";
    }	
}
function hideAll(frm){
	for(i=1;i<=maxc;i++){
		frm["num_"+i].style.display="none";
	}
}


// Mosta Nasconde DIV (select stati home page)
<!--
var lastDiv = "";
function showDiv(divName) {
	// hide last div
	if (lastDiv) {
		document.getElementById(lastDiv).className = "hiddenDiv";
	}
	//if value of the box is not nothing and an object with that name exists, then change the class
	if (divName && document.getElementById(divName)) {
		document.getElementById(divName).className = "visibleDiv";
		lastDiv = divName;
	}
}
//-->

//photo gallery
function showPic(whichpic) {
  if (document.getElementById) {
    document.getElementById('placeholder').src = whichpic.href;
    if (whichpic.title) {
      document.getElementById('desc').childNodes[0].nodeValue = whichpic.title;
    } else {
      
    }
    return false;
  } else {
  return true;
  }
}

var previousToggle=null;
function toggleMe(a){
  var e=document.getElementById(a);
  if(!e)return true;
  if(e.style.display=="none"){
    e.style.display="block";
    if(previousToggle)previousToggle.style.display="none";
    previousToggle=e;
  }
  return true;
}

function switchEnable(idSelect){
		for(var a=1;a<9;a++){
			document.getElementById('select_'+a).disabled = true;	
		}
		document.getElementById('select_'+idSelect).disabled = false;			
		
		
		
		
	}

///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
/////////     pop up maps                     /////////
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////

var numDivPopUp=1;
var zdx=1;
function createPopUp(){
	outerdiv=document.getElementById(this.id);
	outerdiv.style.height=this.height+'px';
	outerdiv.style.width=this.width+'px';
	outerdiv.style.display="block";
	outerdiv.style.borderStyle=this.borderStyle;
	outerdiv.style.borderWidth=this.borderWidth+'px';
	outerdiv.style.borderColor=this.borderColor;
	outerdiv.style.backgroundColor=this.bgColor;
	outerdiv.style.position='absolute';
	outerdiv.style.left=this.x+'px';
	outerdiv.style.top=this.y+'px';
	outerdiv.style.display='none';
	outerdiv.style.zIndex=zdx++;
	
	iframeObj = document.createElement('IFRAME');
	
	iframeObj.style.position = 'absolute';
	iframeObj.frameBorder='0px';
	iframeObj.style.left='0px';
	iframeObj.style.top='0px';
	iframeObj.style.display = '';
	iframeObj.style.height = this.height+'px';
	iframeObj.style.width = this.width+'px';
	iframeObj.style.zIndex =-1000;
	
	if (this.isExternalPage){
		if (this.showClose==true){
	 		outerdiv.innerHTML='<div style="20px" align="right" ><a style="cursor:pointer;color:#FFFFFF" onClick="hidebox(\''+this.id+'\')"  >close x</a> &nbsp;</div><iframe  src="'+this.content+'" width="100%" height="100%" frameborder="0"></iframe>';
		}
		else {
	 		outerdiv.innerHTML='<iframe  src="'+this.content+'" width="100%" height="100%" frameborder="0"></iframe>';
		}
	}
	
	else{
		outerdiv.innerHTML=this.content;
	}
	this.isInit=true;
}

function hidebox(id){
	div=document.getElementById(id);
	div.style.display='none';
	return false;
}


function hide(){
	 hidebox(this.id);
}


function showbox(id){
	
	div=document.getElementById(id);
	div.style.display='block';
	return false;
}
function show(){
	if (!this.isInit){
		this.createPopUp();
	}
	showbox(this.id);
}


function setSize(width,height){
		this.height=height;
		this.width=width;
}
function setSeize(width,height){
		this.height=height;
		this.width=width;
}

function setPos(x,y){
		this.x=x;
		this.y=y;
}



function addContent(text){
	this.isExternalPage=false;
	this.content=text;
}
function setUrl(url){
		this.isExternalPage=true;
		this.content=url;
}
function center(){
	var largeur = 0, hauteur = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
  		largeur = window.innerWidth;
  		hauteur = window.innerHeight;
  	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
 		 largeur = document.documentElement.clientWidth;
  		 hauteur = document.documentElement.clientHeight;
 	 } 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		  largeur = document.body.clientWidth;
		  hauteur = document.body.clientHeight;
  	}
	else {
	  largeur = -1;
	  hauteur = -1;
    }
	var pos=0;
	if (window.innerHeight) {
    	pos = window.pageYOffset
	  }
 	 else if (document.documentElement && document.documentElement.scrollTop) {
    	pos = document.documentElement.scrollTop
 	 }
  	else if (document.body) {
    	pos = document.body.scrollTop
  	}

	dx=((largeur-this.width > 0)? parseInt((largeur-this.width)/2) :100);
	dy=((hauteur-this.height > 0)? parseInt((hauteur-this.height)/2) :100);
	this.x=document.body.scrollLeft+dx;
	this.y=pos+dy ;
}

function  PopUpTs(){
	numDivPopUp++;
	this.id="DivPopUp"+numDivPopUp;
	objdiv=document.createElement('DIV');
	objdiv.id=this.id;
	document.body.appendChild(objdiv);
	
	if (document.body){
		this.x=document.body.scrollLeft+100;
		this.y=document.body.scrollTop+100 ;
	}else{
		this.x=100;
		this.y=100;
	}
	this.height=200;
	this.width=200;
	this.isExternalPage=true;
	this.content="";
	this.title="";
	this.isInit=false;
	this.showClose=false;
	
	this.borderColor="#CFAE3F";
	this.bgColor="#FFFFFF";
	this.borderWidth="1px";
	this.borderStyle="solid";
	
	this.hide=hide;
	this.show=show;
	this.setUrl=setUrl;
	this.center=center;
	this.addContent=addContent;
	
	this.setSeize=setSeize;
	this.setSize=setSize;
	this.setPos=setPos;
	this.createPopUp=createPopUp;
	
}
//////////////// fine //////////////////////
////////////////////////////////////////////

//select footer search
function switchEnable(idSelect){
		for(var a=1;a<9;a++){
			document.getElementById('select_'+a).disabled = true;	
		}
		document.getElementById('select_'+idSelect).disabled = false;			
		
		
		
		
	}
	
/// mostra nascondi div
var stato= new Array();
var num_elementi=250;

if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switch{display:block;}')
document.write('</style>')
}

function modifica(elem){
	if (stato[elem]=="block") stato[elem]="none";
	else stato[elem]="block";
	document.getElementById('agenzia'+elem).style.display=stato[elem];
}
function modifica_all(num){
   for(i=1;i<=num_elementi;i++){
   stato[i]="none";
	if (num==0) stato[i]="block";   
     modifica(i);
   }
}
