function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) 
		selObj.selectedIndex=0;
}
function stampa(){
   st = parseInt(navigator.appVersion)
   if (st >= 4) window.print()
}

function Color(t) {
	t.className='sep_tr_over';
}

function Decolor(t) {
	t.className='sep_tr';
}

/**** finestre popup ****/
function popup(){
	newwin = window.open('','win_img','width=700, height=500,scrollbars=0,status=0,statusbar=0,toolbar=no,location=no,menubar=no,resizable=no,top=20,left=20,screenX=20,screenY=20');
	newwin.focus();
}

function imgpopup(){
	newwin = window.open('','pgpreview','width=520, height=425,scrollbars=0,status=0,statusbar=0,toolbar=no,location=no,menubar=no,resizable=no,top=20,left=20,screenX=20,screenY=20');
	newwin.focus();
}
function popup_ring(){
	newwin = window.open('','win_img_ring','width=360, height=330,scrollbars=0,status=0,statusbar=0,toolbar=no,location=no,menubar=no,resizable=no,top=20,left=20,screenX=20,screenY=20');
	newwin.focus();
}
function target_blank(x){
	document.getElementById(x).target="_blank";
}


/**** info privacy ****/
function switchdivid(){
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		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;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			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;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

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

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}
	arrayPageScroll = new Array(xScroll,yScroll) 
	ilvalore_y=arrayPageScroll[1]+60;

	
	leftdemo2 = (windowWidth-990)/2+320;
	document.getElementById('appear_demo3').style.height = pageHeight+"px";
	document.getElementById('appear_demo_int3').style.left = leftdemo2+"px";
	document.getElementById('appear_demo_int3').style.top = ilvalore_y+"px";
	$('appear_demo3').appear();
	
	return true;

}

/**** info privacy ****/
function switchdivid2(){
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		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;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			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;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

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

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}
	arrayPageScroll = new Array(xScroll,yScroll) 
	ilvalore_y=arrayPageScroll[1]+60;

	
	leftdemo2 = (windowWidth-990)/2+320;
	document.getElementById('appear_demo3').style.height = pageHeight+"px";
	document.getElementById('appear_demo_int3').style.left = leftdemo2+"px";
	document.getElementById('appear_demo_int3').style.top = ilvalore_y+"px";
	$('appear_demo3').appear();
	
	

}
function mostra_informa(){
	document.getElementById('testo_informativa_1').style.display ='None';
	document.getElementById('testo_informativa_2').style.display ='';
}

function nascondi_informa(){
	document.getElementById('testo_informativa_1').style.display ='';
	document.getElementById('testo_informativa_2').style.display ='None';
}


/**** colonna dx bilanci/progetti per js attivo/no ****/
function mostra_jdx(id){
	document.getElementById('el'+id+'Child').className ='';
	document.getElementById('el'+id+'Parent').className ='menu_hidden';
}

function nascondi_jdx(id){
	document.getElementById('el'+id+'Child').className ='menu_hidden';
	document.getElementById('el'+id+'Parent').className ='menu_jright';
}

/****cartiografia ****/
function mappaita(){
	e=window.open('', 'mappa', "width=750,height=560,scrollbars=1,status=0,statusbar=0,toolbar=no,location=no,menubar=no,resizable=no,top=20,left=20,screenX=20,screenY=20");
	e.focus();
}


function newsletter(){
		d=window.open('', 'newsletter', "width=560,height=640,scrollbars=0,status=0,statusbar=0,toolbar=no,location=no,menubar=no,resizable=no,top=20,left=20,screenX=20,screenY=20");
		d.focus();
	}

/**** colonna dx bilanci/progetti per js attivo/no ****/



function mostra_aree(id, fine_indice){
	var inizio_indice_aree = 1;
	var fine_indice_aree = fine_indice;
	for (indice=inizio_indice_aree;indice<=fine_indice_aree;indice++) {
		if (indice==id) {
			document.getElementById('elmod_'+indice).className='menu_jright_att';
			document.getElementById('elmod_'+indice+'_Child').className='menu_hidden_att';
		} else {
			document.getElementById('elmod_'+indice).className='menu_jright';
			document.getElementById('elmod_'+indice+'_Child').className='menu_hidden';
		}
	}
}
/* rnd img come background */
function rnd_image(){
	
	// array con le img presenti nella dir
	var imgs = new Array("1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg", "6.jpg");
	
	var rnd_img = Math.floor(Math.random()*imgs.length);
	
	document.write('<style type="text\/css">body {background:#e7e1de url(..\/..\/img\/share\/back-random\/' + imgs[rnd_img] +') no-repeat 0 0;}<\/style>');

}




/* PRENOTAZIONI */

function privacypopup(x) {
	newwin = window.open('','privacyp','width=500, height=400,scrollbars=1,status=0,statusbar=0,toolbar=no,location=no,menubar=no,resizable=no,top=20,left=20,screenX=20,screenY=20');
	document.getElementById(x).target="privacyp";
	newwin.focus();
}
function ricordapopup(x) {
	newwin = window.open('','ricordap','width=330, height=365,scrollbars=1,status=0,statusbar=0,toolbar=no,location=no,menubar=no,resizable=no,top=20,left=20,screenX=20,screenY=20');
	document.getElementById(x).target="ricordap";
	newwin.focus();
}
function condpopup(x) {
	newwin = window.open('','condp2','width=660, height=660,scrollbars=1,status=0,statusbar=0,toolbar=no,location=no,menubar=no,resizable=no,top=20,left=20,screenX=20,screenY=20');
	document.getElementById(x).target="condp2";
	newwin.focus();
}

function tarpopup(x) {
	newwin = window.open('','tarp2','width=660, height=660,scrollbars=1,status=0,statusbar=0,toolbar=no,location=no,menubar=no,resizable=no,top=20,left=20,screenX=20,screenY=20');
	document.getElementById(x).target="tarp2";
	newwin.focus();
}

function aziendapopup(x) {
	newwin = window.open('','tarp2','width=920, height=660,scrollbars=1,status=0,statusbar=0,toolbar=no,location=no,menubar=no,resizable=yes,top=20,left=20,screenX=20,screenY=20');
	document.getElementById(x).target="tarp2";
	newwin.focus();
}

agg_calendario = function(x, y) {
	new Ajax.Updater(x, y, {
		evalScripts:true 
		}
	);
}
agg_calendario_2 = function(x, y) {
	new Ajax.Updater(x, y, {
		evalScripts:true 
		}
	);
}
agg_login = function(x, y) {
	new Ajax.Updater(x, y, {
		evalScripts:true 
		}
	);
}

function isEmail(str) {
	var supported = 0;
	if(window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}
	if(!supported)
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");

	return (!r1.test(str) && r2.test(str));
}

function isDate(str) {
	var arrivoArray = str.split("/"); 
	var dataarrivo=new Date()
	dataarrivo.setFullYear(arrivoArray[2],arrivoArray[1],arrivoArray[0])
	return (dataarrivo);
}

function MyTrim(myObj){
	var i;
	var myObjTmp;
	var myObjTmp2;

	if (myObj==null){
		myObj=''; 
		return myObj;
	}

	if (myObj=='') {
		return myObj;
	}

	for (i = 0; i < myObj.length; i++) {
		if(myObj.charAt(i) == ' '){
			myObjTmp = myObj.substr(i+1)
		} else {
			if (i==0) { 
				myObjTmp = myObj;
			}
			break;
		}
	}

	myObjTmp2 = myObjTmp

	if (myObjTmp.length > 0) {
		for (i = myObjTmp.length-1; i > 0; i--) {// elimina gli spazi finali
			if (myObjTmp.charAt(i) == ' '){
				myObjTmp2 = myObjTmp.substr(0,i)
			} else {
				break;
			}
		}
	}

	myObj = myObjTmp2
	return (myObj)
}
function cambia_stazione() {
	document.getElementById('cambia_stazione_2').style.display = "";
	document.getElementById('cambia_stazione_1').style.display = "none";
}

function set_partenza(x) {
	document.getElementById('partenza').value = x;
}

function set_rientro(x) {
	document.getElementById('rientro').value = x;
}

function changestatusauto(id, fine_indice){
	var inizio_indice_aree = 1;
	var fine_indice_aree = fine_indice;
	for (indice=inizio_indice_aree;indice<=fine_indice_aree;indice++) {
		if (indice==id) {
			document.getElementById('autolinkint_'+indice).className='attivoautolink';
			document.getElementById('liautolinkint_'+indice).className='attivoauto';
		} else {
			document.getElementById('autolinkint_'+indice).className='autolink';
			document.getElementById('liautolinkint_'+indice).className='';
		}
		
	}
	var nextvalue = id+1;
	if (nextvalue <=  fine_indice){
		document.getElementById('autolinkint_'+nextvalue).className='autolink';
		document.getElementById('liautolinkint_'+nextvalue).className='levasep';
	}
}
