function showInfo(div,nome,codice,periodo,inizio,fine,stato,utente,id){
	var azione = 'approva';
	var out ='<form action="/pimm/admin/approve.do" method="POST">';
	out = out + '<input type="hidden" name="riservazione" value="'+id+'"/>';	
	out = out + '<table>';
	out = out + '<tr><td>Impianto:</td><td>'+nome+'</td></tr>';
	out = out + '<tr><td>Codice:</td><td>'+codice+'</td></tr><input type="hidden" name="codice" value="'+codice+'"/>';	
	out = out + '<tr><td>Periodo:</td><td>'+inizio+'-'+fine+'</td></tr><input type="hidden" name="periodo" value="'+periodo+'"/>';	
	out = out + '<tr><td>Stato:</td><td>'+stato+'</td></tr>';
	if (stato == 'attesa'){
		azione='abilita';
	}
	out = out + '<tr><td>Utente:</td><td>'+utente+'</td></tr><input type="hidden" name="user" value="'+utente+'"/>';	
	out = out + '<tr><td><input type="submit" name="azione" value="'+azione+'"/></td><td><input type="submit" name="azione" value="rifiuta"/></td></tr>';
	out = out + '</table>';
	out = out + '</form>';
	document.getElementById(div).innerHTML = out;
}

function xmlHttpGet(strURL, div) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

    //self.xmlHttpReq.open('GET', strURL, true, user,psw);
    self.xmlHttpReq.open('GET', strURL, true);
    // self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.setRequestHeader('Content-Type', 'text/plain');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
        	var str = self.xmlHttpReq.responseText;

        	updatemypage(self.xmlHttpReq.responseText, div);
        }
    }
    self.xmlHttpReq.send(null);
}

function showServerInfo(div,id){
	var url = '/pimm/admin/showInfo.do?riservazione='+id;
	xmlHttpGet(url,div);
}

function updatemypage(str,div){
	document.getElementById(div).innerHTML = str;
	
}
function showCat(div,e,r,t){
	var url = "/tracking/cgi-bin/showPBList.pl?eventi="+e+"&race="+r+"&data="+t;
	
	xmlHttpGet(url, div) ;
	
}

function closePB(div,e,r,t){
	var text = "<li><a href=\"javascript:showCat('"+div+"','"+e+"','"+r+"','"+t+"')\">Show Classes</a></li>";
	document.getElementById(div).innerHTML = text;
}



function getNews(url,evento,div){

	var nurl = url +'?evento='+evento;
	//alert('invoco '+nurl);
	//xmlHttpGet(nurl, div);
	var text = getSynchInfo(nurl);
	var t = text.split('###');
	if (t.length>0){
		text = t[1];
	}
	document.getElementById(div).innerHTML=text;

}


function getSynchInfo(url,user,psw){

        var xmlHttpReq = false;
        var self = this;
        // Mozilla/Safari
        var strURL = url;

         if (window.XMLHttpRequest) {
                self.xmlHttpReq = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
                self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
        }
        if ((user != "")||(user != null)){
                self.xmlHttpReq.open('GET', strURL, false, user,psw);
        }
        else{
                self.xmlHttpReq.open('GET', strURL, false);
        }
        self.xmlHttpReq.setRequestHeader('Content-Type', 'text/plain');
        self.xmlHttpReq.send(null);
        var str = self.xmlHttpReq.responseText;
        return str;
}


