var funzione="void(0)";
function funzioniAgg(){
	eval(funzione);
}
function ridimensiona(){
	scroll(0,0);
	var iAltezzaFinestra=document.body.clientHeight;
	var iLarghezzaFinestra=document.body.clientWidth;
	var objDivMain=document.getElementById("idDivMain");
	var objDivTesto=document.getElementById("idDivTesto");
	var objDivBarraTop=document.getElementById("idDivBarraTop");
	var objDivBarraDestra=document.getElementById("idDivBarraDestra");
	var objDivBarraInfoDestra=document.getElementById("idDivBarraInfoDestra");
	
	if(iLarghezzaFinestra<945)iLarghezzaFinestra=945;
	objDivTesto.style.width=iLarghezzaFinestra*75/100-25;
	objDivMain.style.width=iLarghezzaFinestra*90/100;
	objDivBarraDestra.style.width=iLarghezzaFinestra*25/100;
	objDivBarraInfoDestra.style.width=iLarghezzaFinestra*22/100;
	var maxAltezza;
	if(objDivTesto.clientHeight>(objDivBarraInfoDestra.clientHeight+20))maxAltezza=objDivTesto.clientHeight+10;
	else maxAltezza=objDivBarraInfoDestra.clientHeight+30;
	var iTotAltezza =objDivBarraTop.clientHeight+maxAltezza;
	var nuovaAltezza=0;
	if(iTotAltezza<iAltezzaFinestra){
		nuovaAltezza=iAltezzaFinestra-objDivBarraTop.clientHeight-10;

	}else{
		nuovaAltezza=maxAltezza;
//		objDivMain.style.height=maxAltezza;
	//	objDivBarraDestra.style.height=maxAltezza;
	}
	objDivMain.style.height=nuovaAltezza;
	objDivBarraDestra.style.height=nuovaAltezza;
	objDivTesto.style.height=nuovaAltezza-20;

}
function sistemaOriz(){
	var objDivTesto=document.getElementById("idDivTesto");
	var objDivBarraDestra=document.getElementById("idDivBarraDestra");
	var objDivBarraInfoDestra=document.getElementById("idDivBarraInfoDestra");
	var objDivBarraTop=document.getElementById("idDivBarraTop");
	var objDivLogoISO=document.getElementById("idDivLogoISO");
	var iLarghezzaFinestra=document.body.clientWidth;
	if(iLarghezzaFinestra<945)iLarghezzaFinestra=945;	
	objDivBarraDestra.style.right=document.body.clientWidth-iLarghezzaFinestra;
	objDivTesto.style.left=iLarghezzaFinestra*1/100;
	objDivBarraInfoDestra.style.right=document.body.clientWidth-iLarghezzaFinestra+iLarghezzaFinestra*1/100;
	objDivLogoISO.style.right=document.body.clientWidth-iLarghezzaFinestra+1;
	if(objDivBarraDestra.clientWidth<250) {
		objDivBarraDestra.style.width=250;
		objDivBarraInfoDestra.style.width=230;
	}
	objDivBarraTop.style.width=iLarghezzaFinestra-1;
}

/********************************************************
 funzioni per la gestione delle chiamate http (post)
 ********************************************************/
var http;
var objDiv;
var objCombo;
var functionPost;

function creaChiamata(){
	var chiamata;
	var browser=navigator.appName;
	if(browser=="Microsoft Internet Explorer")
		chiamata=new ActiveXObject("Microsoft.XMLHTTP");
	else
		chiamata=new XMLHttpRequest();
	return chiamata;
}

function gestisciRisposta(){
    if (http.readyState==4){
	   var risposta = http.responseXML;
		eval(functionPost);
    }
}

/********************************************************
 funzioni per i codici CER
 ********************************************************/
function caricaCategorieCER(id,combo){
 	functionPost="parseXmlCombo(risposta,'categoria')";
 	objCombo=document.getElementById(combo);
	http=creaChiamata();
	http.open('get','include/phpFunctions.inc.php?sFunc=getCategorieCER&sIdSuperCategoria='+id+'&rnd='+Math.random());
	http.onreadystatechange=gestisciRisposta;
	http.send(null);
}
function caricaCodiciCER(id,div){
  	functionPost="parseXmlTabella(risposta,'codice')";
 	objDiv=document.getElementById(div);
	http=creaChiamata();
	http.open('get','include/phpFunctions.inc.php?sFunc=getCodiciCER&sIdCategoria='+id+'&rnd='+Math.random());
	http.onreadystatechange=gestisciRisposta;
	http.send(null);
}
function parseXmlCombo(xml,tagName){
	for(i=0;i<objCombo.lenght;i++)objCombo[i+1]=null;
	objCombo.length=0;
    var opzioni = xml.getElementsByTagName(tagName);
    for (i=0;i<opzioni.length;i++) {
        opzione = opzioni.item(i);
		objOptionDest=new Option(opzione.getAttribute("id")+" - " +opzione.firstChild.data,opzione.getAttribute("id"));
		objCombo[i+1]=objOptionDest;
    } 
}

function parseXmlTabella(xml,tagName){
    var opzioni = xml.getElementsByTagName(tagName);
    html="<table class=\"tabCodiciCER\" align=\"center\" style=\"width:100%\">\n";
    html+="<tr><td class=\"titolo1\" nowrap style=\"width:100px\">Codice</td><td class=\"titolo1\">Descrizione</td></tr>";
    for (i=0;i<opzioni.length;i++) {
		opzione = opzioni.item(i);
    	html+="<tr><td>"+opzione.getAttribute("id")+"</td><td>"+opzione.firstChild.data+"</td></tr>";		
    } 
    html+="</table>";
    //objDiv.style.height=document.getElementById("idDivTesto").style.clientHeight - document.getElementById("idTableSelectCodici").style.clientHeight - 20;
	objDiv.innerHTML=html;
}

function resetCodici(div){	
	document.getElementById(div).innerHTML="";
}

function sistemaLayout(){
	if(document.getElementById("idDivTesto").clientHeight<document.getElementById("idDivBarraInfoDestra").clientHeight){
		document.getElementById("idDivTesto").style.height=document.getElementById("idDivBarraInfoDestra").clientHeight+"px";
	}
}
function illumina(sDiv){
	document.getElementById(sDiv).className+="Over";
}
function ripristina(sDiv){
	document.getElementById(sDiv).className=document.getElementById(sDiv).className.substring(0,document.getElementById(sDiv).className.indexOf("Over"));
}
function windowLoad(){
	sistemaLayout();
	
}
function apriElencoAutorizzazioni(){
	if(document.getElementById('elencoAutorizzazioni').style.display=="block") 
		document.getElementById('elencoAutorizzazioni').style.display="none";
	else document.getElementById('elencoAutorizzazioni').style.display="block";
	sistemaLayout();
}
function goTo(sPagina){
	window.location.href="index.php?pag="+sPagina;
}
Event.observe(window,'load', windowLoad);

