function onLoaded(){
	document.getElementById("loading").style.display = "none";
}
function onLoading(){
	document.getElementById("loading").style.display = "block";
}

function getSelect(){
        url = window.location.pathname;

        if(document.getElementById("cod_provincia"))
	   var cod_provincia = document.getElementById("cod_provincia").value;
	if(document.getElementById("cod_commontana"))
	   var cod_commontana = document.getElementById("cod_commontana").value;
	if(document.getElementById("cod_comune"))
	   var cod_comune = document.getElementById("cod_comune").value;
	if(document.getElementById("cod_tipologia"))
	   var cod_tipologia = document.getElementById("cod_tipologia").value;
	if(document.getElementById("cod_categoria"))
	   var cod_categoria = document.getElementById("cod_categoria").value;
	if(document.getElementById("sid"))
	   var sid = document.getElementById("sid").value;
			
	var ajax = new sack();
        ajax.setVar("cod_provincia", cod_provincia);
	ajax.setVar("cod_commontana", cod_commontana);
	ajax.setVar("cod_comune", cod_comune);
	ajax.setVar("cod_tipologia", cod_tipologia);
	ajax.setVar("cod_categoria", cod_categoria);
	ajax.setVar("prosegui", 0);
	ajax.setVar("sid", sid);
	ajax.setVar("ajax", 1);
	ajax.method = "POST";

	ajax.requestFile = url;
	ajax.element = 'form_ajax';
	ajax.onLoading = onLoading;
	ajax.onLoaded = onLoaded;
        ajax.runAJAX();
}
		
function getRisultati(){
        url = window.location.pathname;

        if(document.getElementById("cod_provincia"))
	   var cod_provincia = document.getElementById("cod_provincia").value;
	if(document.getElementById("cod_commontana"))
	   var cod_commontana = document.getElementById("cod_commontana").value;
	if(document.getElementById("cod_comune"))
	   var cod_comune = document.getElementById("cod_comune").value;
	if(document.getElementById("cod_tipologia"))
	   var cod_tipologia = document.getElementById("cod_tipologia").value;
	if(document.getElementById("cod_categoria"))
	   var cod_categoria = document.getElementById("cod_categoria").value;
	if(document.getElementById("sid"))
	   var sid = document.getElementById("sid").value;
		
	var ajax = new sack();
        ajax.setVar("cod_provincia", cod_provincia);
	ajax.setVar("cod_commontana", cod_commontana);
	ajax.setVar("cod_comune", cod_comune);
	ajax.setVar("cod_tipologia", cod_tipologia);
	ajax.setVar("cod_categoria", cod_categoria);
	ajax.setVar("prosegui", "prosegui");
	ajax.setVar("sid", sid);
	ajax.setVar("ajax", 2);
	ajax.method = "POST";
	ajax.requestFile = url;
	ajax.element = 'ajax_results';
	ajax.onLoading = onLoading;
	ajax.onLoaded = onLoaded;
	ajax.onCompletion = MyWindowInit;
	ajax.runAJAX();
}

function getPage(get){
	url = window.location.pathname;

        var gets = get.split("&");
	var ajax = new sack();
		
	if(document.getElementById("sid"))
	   var sid = document.getElementById("sid").value;
		
	for(x=0;x<gets.length;x++){
	   param = gets[x].split("=");
	   ajax.setVar(param[0], param[1]);
	}
	ajax.setVar("sid", sid);
	ajax.setVar("prosegui", "prosegui");
	ajax.setVar("ajax", 2);
	ajax.method = "GET";
	ajax.requestFile = url;
	ajax.element = 'ajax_results';
	ajax.onLoading = onLoading;
	ajax.onLoaded = onLoaded;
        ajax.onCompletion = MyWindowInit;
        ajax.runAJAX();
} 
function myPagingAjax(){
    identificatore = 'pageajax';
    a = document.getElementsByTagName('a');
    for(i=0;a[i];i++) if(a[i].className == identificatore) 
    {
        a[i].href = "#anchor_paginazione";
    }
}
function myNoDisplay(){
    identificatore = 'nodisplay';
    span = document.getElementsByTagName('span');
    for(i=0;span[i];i++) if(span[i].className == identificatore) 
    {
        span[i].style.display = "none";
    }
}
function myDisplay(element){
    //alert(id); 
    note = document.getElementById("note_"+element);
   
    if(note.style.display == "none"){
        note.style.display  = "inline";
    }else{
        note.style.display  = "none";
    }

}

function init(){
        if(document.getElementById("prosegui")){
            if(navigator.appName.indexOf("Microsoft") == -1){
							document.getElementById("prosegui").type = "button";
						}
						document.getElementById("prosegui").onclick = function() {getRisultati();};
        }
        myPagingAjax();
        myNoDisplay();
        
}

MyWindowInit = function() {init();InitNewWinPop();InitLoading();};
window.onload = MyWindowInit;

