function imposeMaxLength(Object, MaxLen) {
	
	if (document.getElementById('maxchar').value > 0) { document.getElementById('maxchar').value = document.getElementById('maxchar').value -1; }
	
  return (Object.value.length <= MaxLen);

}

var oldString = "";
 
function countChars(d) {
 	
 	if (document.forms['msg'].descrizione.value.length > 240) {
 	
   	 document.forms['msg'].descrizione.value = oldString;
 	} 
	else {
 
    document.forms['msg'].maxchar.value = 240 - document.forms['msg'].testomsg.value.length;
    oldString = document.forms['msg'].descrizione.value.substring(0,240);
 
 }

}

function showBoxLowCostGuideFeste(box) {
	
	if (box == 'feedrss') {
		
		if (document.getElementById('tabfeed').style.display == 'block') {
			
			return false;	
		
		} else {
			document.getElementById('tabnewsletter').style.display 	= 'none';
			document.getElementById('tabfeed').style.display 		= 'block';		
		
		}
	
	}
	
	else if (box == 'nsl') {
		
		if (document.getElementById('tabnewsletter').style.display == 'block') {
			
			return false;	
		
		} else {
			
			document.getElementById('tabfeed').style.display 	= 'none';
			document.getElementById('tabnewsletter').style.display 	= 'block';		
		
		}
	
	}		


}

function showBoxFeedNsl(box) {
	
	if (box == 'feedrss') {
		
		if (document.getElementById('tabfeed').style.display == 'block') {
			
			document.getElementById('tabfeed').style.display 	= 'none';	
		
		} else {
			document.getElementById('tabnewsletter').style.display 	= 'none';
			document.getElementById('tabfeed').style.display 		= 'block';		
		
		}
	
	}
	
	else if (box == 'nsl') {
		
		if (document.getElementById('tabnewsletter').style.display == 'block') {
			
			document.getElementById('tabnewsletter').style.display 	= 'none';	
		
		} else {
			
			document.getElementById('tabfeed').style.display 	= 'none';
			document.getElementById('tabnewsletter').style.display 	= 'block';		
		
		}
	
	}		


}


function showBoxDormireMuoversi(box) {
	
	if (box == 'booking') {
		
		if (document.getElementById('tab_booking').style.display == 'block') {
			
			return false;	
		
		} else {
		
			document.getElementById('tab_enoleggio').style.display 	= 'none';
			document.getElementById('imgenoleggiojs').src	= 'http://destinazioni.zingarate.com/images/top_muoversi.gif';

			
			document.getElementById('tab_booking').style.display 		= 'block';
			document.getElementById('imgbookingjs').src	= 'http://destinazioni.zingarate.com/images/top_dormire_over.gif';
		
		
		}
	
	}
	
	else if (box == 'enoleggio') {
				
		if (document.getElementById('tab_enoleggio').style.display == 'block') {
			
			return false;	
		
		} else {
					
			document.getElementById('tab_enoleggio').style.display 	= 'block';
			document.getElementById('imgenoleggiojs').src	= 'http://destinazioni.zingarate.com/images/top_muoversi_over.gif';				
			
			document.getElementById('tab_booking').style.display 		= 'none';
			document.getElementById('imgbookingjs').src	= 'http://destinazioni.zingarate.com/images/top_dormire.gif';			
		
		
		}
	
	}	
	

}

function show_box_guide_speciali(box) {
	
	if (box == 'guide') {
		
		if (document.getElementById('box_guide_js').style.display == 'block') {
			
			return false;	
		
		} else {
		
			document.getElementById('box_speciali_js').style.display 	= 'none';
			document.getElementById('img_speciali_js').src	= 'http://destinazioni.zingarate.com/images/top_speciali.gif';

			
			document.getElementById('box_guide_js').style.display 		= 'block';
			document.getElementById('img_guide_js').src	= 'http://destinazioni.zingarate.com/images/top_zingaguide_over.gif';
		
		
		}
	
	}
	
	else if (box == 'speciali') {
		
		if (document.getElementById('box_speciali_js').style.display == 'block') {
			
			return false;	
		
		} else {
		
			document.getElementById('box_speciali_js').style.display 	= 'block';
			document.getElementById('img_speciali_js').src	= 'http://destinazioni.zingarate.com/images/top_speciali_over.gif';				
			
			document.getElementById('box_guide_js').style.display 		= 'none';
			document.getElementById('img_guide_js').src	= 'http://destinazioni.zingarate.com/images/top_zingaguide.gif';			
		
		
		}
	
	}	
	

}

function show_destinazioni() {
	
	if (document.getElementById('box_destinazioni').style.display == 'block') {
	
		document.getElementById('box_destinazioni').style.display = 'none';
	}
	else {
	
		document.getElementById('box_destinazioni').style.display = 'block';
	
	}

}

function show_destinazioni_new() {
	
	if (document.getElementById('box_destinazioni_new').style.display == 'block') {
	
		document.getElementById('box_destinazioni_new').style.display = 'none';
	}
	else {
	
		document.getElementById('box_destinazioni_new').style.display = 'block';
	
	}

}


function show_login() {
	
	if (document.getElementById('show_login').style.display == 'block') {
	
		document.getElementById('show_login').style.display = 'none';
	}
	else {
	
		document.getElementById('show_login').style.display = 'block';
	
	}

}

function show_login2(attr) {
	
	if (document.getElementById('show_login'+attr).style.display == 'block') {
	
		document.getElementById('show_login'+attr).style.display = 'none';
	}
	else {
	
		document.getElementById('show_login'+attr).style.display = 'block';
	
	}

}

function show_login1() {
	
	if (document.getElementById('show_login1').style.display == 'block') {
	
		document.getElementById('show_login1').style.display = 'none';
	}
	else {
	
		document.getElementById('show_login1').style.display = 'block';
	
	}

}

function show_editor() {
	
	if (document.getElementById('editor_guida').style.display == 'block') {
	
		document.getElementById('editor_guida').style.display = 'none';
	}
	else {
	
		document.getElementById('editor_guida').style.display = 'block';
	
	}

}

function hide_editor() {
	
	document.getElementById('editor_guida').style.display = 'none';

}

function show_error() {
	
	if (document.getElementById('editor_guida').style.display == 'block') {
	
		document.getElementById('editor_guida').style.display = 'none';
	}
	else {
	
		document.getElementById('editor_guida').style.display = 'block';
	
	}

}

function hide_error() {
	
	document.getElementById('editor_guida').style.display = 'none';

}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function openSplash(image,imageWidth,imageHeight,tipo,param,param1,param2,param3,param4) {
	
	var arrayPageSize 					= getPageSize();
	var arrayPageScroll 				= getPageScroll();
	
	var splash	=	document.createElement('div');
	
	splash.className						=	'splash';
	splash.setAttribute('id','splash');
	splash.style.position				=	'absolute';
	splash.style.zIndex 				= 1000;
	splash.style.display				=	'block';
	splash.style.top						=	'0px';
	splash.style.left						=	'0px';		
	splash.style.width					=	"100%";
	splash.style.border					=	"1px solid #ffffff";

	splash.style.height					= arrayPageSize[1]+10+"px";
	
	splash.style.background			= '#000000';
	
	splash.style.opacity = 7/10;
	splash.style.filter = 'alpha(opacity=' + 7*10 + ')';
	
	splash.style.overflow 			= 'hidden';
	
	document.getElementsByTagName('body')[0].appendChild(splash);
	

	var closeLink									=	document.createElement('a');
  closeLink.setAttribute('href','javascript:closeSplash();');
	closeLink.setAttribute('id','closeLink');
		

	var seperator	=	document.createElement('div');
	
	seperator.className							=	'seperator';
	seperator.setAttribute('id','seperator');
	seperator.style.position				=	'absolute';
	seperator.style.zIndex 					= 1001;
	seperator.style.padding					=	'5px';
	seperator.style.display					=	'block';
	seperator.style.width						=	"630px";
	seperator.style.height					=	"365px";
	seperator.style.border					=	"1px solid #fef3d0";
	seperator.style.background			= '#fef3d0';
	seperator.innerHTML							= "<div style='text-align: right; width: 605px; font-family: Arial;'><a href='javascript:closeSplash();' style='color: #cc7052; margin-bottom:2px;'><img src='http://destinazioni.zingarate.com/images/close.gif' border='0' style='margin-right: 4px;'>chiudi</a></div>";	

	var immagine										=	document.createElement('div');
	
	immagine.className					=	'immagine';
	immagine.setAttribute('id','immagine');
	immagine.style.position			=	'absolute';
	immagine.style.zIndex 			= 1001;

	seperator.style.top 				= arrayPageScroll[1] + ((arrayPageSize[3] - 35 - imageHeight) / 2) + 'px';
	seperator.style.left 				= (((arrayPageSize[0] - 20 - imageWidth) / 2) + 'px');


	
	immagine.style.display			=	'block';
	immagine.style.opacity 			= 10/10;
	immagine.style.filter 			= 'alpha(opacity=' + 10*10 + ')';	

	if (tipo == 1)	{			immagine.innerHTML					= "<a href='javascript:closeSplash();'><iframe width='610' height='350' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.it/maps/ms?hl=it&amp;ie=UTF8&amp;s=AARTsJqYilazX17VsKTLyBEqsE87mwsj9g&amp;msa=0&amp;msid=113383523340829718058.00044ed2be3a9cdb025eb&amp;ll=53.551731,9.992065&amp;spn=0.048952,0.109863&amp;z=13&amp;output=embed'></iframe><br /><small><a href='http://maps.google.it/maps/ms?hl=it&amp;ie=UTF8&amp;msa=0&amp;msid=113383523340829718058.00044ed2be3a9cdb025eb&amp;ll=53.551731,9.992065&amp;spn=0.048952,0.109863&amp;z=13&amp;source=embed' style='color:#0000FF;text-align:left'></iframe></a>"; }
	else if (tipo == 2)	{	immagine.innerHTML					= "<a href='javascript:closeSplash();'><iframe width='610' height='350' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://destinazioni.zingarate.com/inc/meteo.php?id="+image+"'></iframe></a>"; }	
	else if (tipo == 3)	{	immagine.innerHTML					= "<a href='javascript:closeSplash();'><iframe width='610' height='350' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://destinazioni.zingarate.com/inc/segnala.php?id="+image+"&user="+param+"&paragrafo="+param1+"&email="+param3+"'></iframe></a>"; }
	else if (tipo == 4)	{	immagine.innerHTML					= "<a href='javascript:closeSplash();'><iframe width='610' height='350' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://destinazioni.zingarate.com/inc/tipafriend.php?id="+image+"&user="+param+"'></iframe></a>"; }	
	else if (tipo == 5)	{	immagine.innerHTML					= "<a href='javascript:closeSplash();'><iframe width='630' height='350' frameborder='0' scrolling='yes' marginheight='0' marginwidth='0' src='http://destinazioni.zingarate.com/guida_stampa.php?id="+image+"&s="+param+"'></iframe></a>"; }	
	else if (tipo == 6)	{	immagine.innerHTML					= "<a href='javascript:closeSplash();'><iframe width='610' height='350' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://destinazioni.zingarate.com/inc/meteo.php?tipo=6&id="+image+"&nome="+param+"'></iframe></a>"; }	
		
	seperator.appendChild(immagine);
	
	closeLink.appendChild(seperator);
			
	document.getElementsByTagName('body')[0].appendChild(closeLink);

}

function closeSplash() {

	if (document.getElementById("splash")) { document.getElementsByTagName('body')[0].removeChild(document.getElementById("splash")); }
	
	if (document.getElementById("closeLink")) { document.getElementsByTagName('body')[0].removeChild(document.getElementById("closeLink"));	}

	document.getElementsByTagName('html')[0].style.overflow 	= 'auto';
	
}

