// JavaScript Document
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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 RegioniShow(regione) {
	if (regione==1) {
		//Abruzzo
		document.getElementById('pezzo3').src='http://www.villaggimania.it/img/mappa/3_a.jpg';
	}	
	if (regione==2) {
		//Lazio
		document.getElementById('pezzo2').src='http://www.villaggimania.it/img/mappa/2_a.jpg';
	}	
	if (regione==3) {
		//Molise
		document.getElementById('pezzo3').src='http://www.villaggimania.it/img/mappa/3_b.jpg';
		document.getElementById('pezzo5').src='http://www.villaggimania.it/img/mappa/5_b.jpg';
	}	
	if (regione==4) {
		//Campania
		document.getElementById('pezzo5').src='http://www.villaggimania.it/img/mappa/5_a.jpg';
		document.getElementById('pezzo6').src='http://www.villaggimania.it/img/mappa/6_a.jpg';
	}	
	if (regione==5) {
		//Puglia
		document.getElementById('pezzo3').src='http://www.villaggimania.it/img/mappa/3_c.jpg';
		document.getElementById('pezzo6').src='http://www.villaggimania.it/img/mappa/6_b.jpg';
	}	
	if (regione==6) {
		//Basilicata
		document.getElementById('pezzo6').src='http://www.villaggimania.it/img/mappa/6_c.jpg';
		document.getElementById('pezzo5').src='http://www.villaggimania.it/img/mappa/5_c.jpg';
	}	
	if (regione==7) {
		//Calabria
		document.getElementById('pezzo8').src='http://www.villaggimania.it/img/mappa/8_a.jpg';
		document.getElementById('pezzo6').src='http://www.villaggimania.it/img/mappa/6_d.jpg';
	}	
	if (regione==8) {
		//Sicilia
		document.getElementById('pezzo7').src='http://www.villaggimania.it/img/mappa/7_a.jpg';
	}	
	if (regione==9) {
		//Sardegna
		document.getElementById('pezzo4').src='http://www.villaggimania.it/img/mappa/4_a.jpg';
	}	
}
function RegioniAzzera() {
	document.getElementById('pezzo2').src='http://www.villaggimania.it/img/mappa/2.jpg';
	document.getElementById('pezzo3').src='http://www.villaggimania.it/img/mappa/3.jpg';
	document.getElementById('pezzo4').src='http://www.villaggimania.it/img/mappa/4.jpg';
	document.getElementById('pezzo5').src='http://www.villaggimania.it/img/mappa/5.jpg';
	document.getElementById('pezzo6').src='http://www.villaggimania.it/img/mappa/6.jpg';
	document.getElementById('pezzo7').src='http://www.villaggimania.it/img/mappa/7.jpg';
	document.getElementById('pezzo8').src='http://www.villaggimania.it/img/mappa/8.jpg';
}

function RegioniIntShow(regione) {
	if (regione==1) {
		//Abruzzo
		document.getElementById('italiadw').src='http://www.villaggimania.it/img/mappa/italia-int-1.jpg';
	}	
	if (regione==2) {
		//Lazio
		document.getElementById('italiadw').src='http://www.villaggimania.it/img/mappa/italia-int-2.jpg';
	}	
	if (regione==3) {
		//Molise
		document.getElementById('italiadw').src='http://www.villaggimania.it/img/mappa/italia-int-3.jpg';
	}	
	if (regione==4) {
		//Campania
		document.getElementById('italiadw').src='http://www.villaggimania.it/img/mappa/italia-int-4.jpg';
	}	
	if (regione==5) {
		//Puglia
		document.getElementById('italiadw').src='http://www.villaggimania.it/img/mappa/italia-int-5.jpg';
	}	
	if (regione==6) {
		//Basilicata
		document.getElementById('italiadw').src='http://www.villaggimania.it/img/mappa/italia-int-6.jpg';
	}	
	if (regione==7) {
		//Calabria
		document.getElementById('italiadw').src='http://www.villaggimania.it/img/mappa/italia-int-7.jpg';
	}	
	if (regione==8) {
		//Sicilia
		document.getElementById('italiadw').src='http://www.villaggimania.it/img/mappa/italia-int-8.jpg';
	}	
	if (regione==9) {
		//Sardegna
		document.getElementById('italiadw').src='http://www.villaggimania.it/img/mappa/italia-int-9.jpg';
	}	
}
function RegioniIntAzzera() {
	document.getElementById('italiadw').src='http://www.villaggimania.it/img/mappa/italia-int-dw.jpg';
}

function ImgChange(idnome,imgnome) {
	document.getElementById(idnome).src='http://www.villaggimania.it/img/'+imgnome;
}

function getBrowserHeight()
{
   if (window.innerHeight)
   {
      return window.innerHeight;
   } else if (document.documentElement && document.documentElement.clientHeight != 0) {
      return document.documentElement.clientHeight;   
   } else if (document.body) {
      return document.body.clientHeight;
   }      
return 0;
}
function getScrollingPosition()
{

	var position = [0, 0];

   if (typeof window.pageYOffset != 'undefined')
   {

      position = [ window.pageXOffset, window.pageYOffset ];
   } else if (typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop > 0) {
      position = [ document.documentElement.scrollLeft, document.documentElement.scrollTop ];
   } else if (typeof document.body.scrollTop != 'undefined') {
      position = [ document.body.scrollLeft, document.body.scrollTop ];
   }

   return position;
}

function openLightBox(id){
    var larghezzaSchermo = 0;
	var el=document.getElementById(id);
	el.style.top="-1000px";
	el.style.left="-1000px";
	document.getElementById("blackBody").style.height=getBrowserHeight()+"px";
	document.getElementById("blackBody").style.display="block";
	var x = document.getElementsByTagName("select");
	for (i = 0; i < x.length; i++) {
	   x[i].style.visibility = "hidden";
	}	
	el.style.display="block";
}

function closeLightBox(id){
	var el=document.getElementById(id);
	document.getElementById("blackBody").style.display="none";
	el.style.display="none";
	var x = document.getElementsByTagName("select");
	for (i = 0; i < x.length; i++) {
	   x[i].style.visibility = "visible";
	}
}


// POSIZIONA LAYER //
function posiziona(id_elemento, top, left) {
  var elemento = document.getElementById(id_elemento);
  if (elemento!=null){
  var is_explorer = (navigator.userAgent.indexOf("MSIE")>=0) ? true : false;
  var posLeft = (is_explorer) ? document.documentElement.scrollLeft : pageXOffset
  var posTop = (is_explorer) ? document.documentElement.scrollTop : pageYOffset

  left=parseInt((document.documentElement.clientWidth-document.getElementById(id_elemento).offsetWidth)/2);
  elemento.style.left = parseInt(posLeft) + left + "px";
  top=parseInt((document.documentElement.clientHeight-document.getElementById(id_elemento).offsetHeight)/2);
  elemento.style.top = parseInt(posTop) + top + "px";
//  elemento.style.top = posTop + top + "px";
 }
}
function aggiornaDim () {
	setInterval("document.getElementById('blackBody').style.height=getBrowserHeight()+'px';",100);
	setInterval("document.getElementById('blackBody').style.top=getScrollingPosition()[1]+'px';",100);
}

setInterval("posiziona('zoom',40,((document.documentElement.clientWidth-500)/2))",100);

function openImage(nomefoto){
	document.getElementById('imgzoom').src='http://www.villaggimania.it/img/loading.gif';
	document.getElementById('imgzoom').src='http://www.villaggimania.it/img-strutture/'+nomefoto;
	openLightBox('zoom');
}
function validateEmail(email) {
	var objRegExp  = '^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+(\.)+([a-zA-Z0-9]{2,})+$';
   	return RegExp(objRegExp).test(email);
}

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_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];}
}