function hq(mus) {
	document.getElementById('blocca_sito_'+mus).className='sfondo_aperto';
}

function chiudi_popup(mus) {
	document.getElementById('blocca_sito_'+mus).className='sfondo_chiuso';
}

function conferma_cancellazione(id,tabella,testo,ritorno) {
	if (confirm(testo)) {
			document.location="azione-eliminaoggetto.php?Tabella="+tabella+"&Id="+id+"&Ritorno="+ritorno;
	}
}

function cambiaordine(id,tabella,where,valore,ritorno) {
	if (where!="") {
		w="&campo="+where+"&valore="+valore;
	}
	document.location="azione-cambiaordine.php?Tabella="+tabella+"&Id="+id.name+"&Nuovoordine="+id.options[id.selectedIndex].value+""+w+"&Ritorno="+ritorno
}

function anteprima() {
/*	document.formcontenutitestuali.target="_blank"
	document.formcontenutitestuali.action="/anteprima.php"
	document.formcontenutitestuali.submit()
	document.formcontenutitestuali.target="_self"
	document.formcontenutitestuali.action="azione-gestionecontenutitestuali.php"*/
	document.getElementById('form_testo').target="_blank"
	document.getElementById('form_testo').action="/anteprima.php"
	document.getElementById('form_testo').submit()
	document.getElementById('form_testo').target="_self"
	document.getElementById('form_testo').action="azioni-contenutitestuali.php"
}

function apri_chiudi(cosa) {
	alert (cosa.options[cosa.selectedIndex].value)
}
function mostra(cosa,quale,quante) {
		for (i=0;i<quante;i++) {
			document.getElementById(cosa+"_"+i).style.display="none";
		}
	document.getElementById(cosa+"_"+quale).style.display="block";
}
function getPageSize(){
	
	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;
	}
//	console.log("pageWidth " + pageWidth)

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

	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) 
	return arrayPageScroll;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
  createCookie('css',title,30);
}
