// JavaScript Document

//QUERY COMUNI
function getSelect(what,value,stile){
	if(what=='provincia'){
		AyaxRequest('ajax_request.php', 'POST', 'filetocall=query_comuni&what='+what+'&value='+value+'&class='+stile, SelectProvincia_html);
	}
	if(what=='citta'){
		AyaxRequest('ajax_request.php', 'POST', 'filetocall=query_comuni&what='+what+'&value='+value+'&class='+stile, SelectCitta_html);
	}
	if(what=='cap'){
		AyaxRequest('ajax_request.php', 'POST', 'filetocall=query_comuni&what='+what+'&value='+value+'&class='+stile, SelectCAP_html);
	}
}
function SelectProvincia_html(){
	document.getElementById('provincia_container').innerHTML=this.req.responseText;
	document.getElementById('citta').value='';
	document.getElementById('citta').disabled=true;
	document.getElementById('cap').disabled=true;
	document.getElementById('cap').value='';
}
function SelectCitta_html(){
	document.getElementById('citta').disabled=false;
	document.getElementById('cap').disabled=false;
	document.getElementById('cap').value='';
	document.getElementById('citta_container').innerHTML=this.req.responseText;
}
function SelectCAP_html(){
	document.getElementById('cap').disabled=false;
	document.getElementById('cap').value=this.req.responseText;
}
function Agenti(settore,provincia){
	AyaxRequest('ajax_request.php', 'POST', 'filetocall=agenti&settore='+settore+'&provincia='+provincia, Agenti_html);
}
function Agenti_html(){
	document.getElementById('agenticontainer').innerHTML=this.req.responseText;
}

function Popup(){
	showOverPage('overlaypopup',700,500,'overlay');
	document.getElementById('overlaypopup').style.height='auto';
	AyaxRequest('ajax_request.php', 'POST', 'filetocall=popup',Popup_HTML);
}
function Popup_HTML(){
	document.getElementById('overlaypopup').innerHTML=this.req.responseText;
}	

function recuperopassword(){
	showOverPage('overlayrecuperopassword',400,0,'overlay');
	AyaxRequest('ajax_request.php', 'POST', 'filetocall=recuperopassword',recuperopassword_HTML);
}
function recuperopassword_HTML(){
	document.getElementById('overlayrecuperopassword').innerHTML=this.req.responseText;
}	

function getResellers(page){	
		var regione=document.getElementById('regione').value;
		var prov=document.getElementById('provincia').value;
		var citta=document.getElementById('citta').value;
		//document.getElementById('resellers_container').innerHTML=getLoadingImage();
		AyaxRequest("ajax_request.php", "POST", "filetocall=resellers_list&regione="+regione+"&provincia="+ prov+"&citta="+citta+"&page=" + page, setResellers_html);
	}
function setResellers_html(){
	document.getElementById('resellers_container').innerHTML=this.req.responseText;
}

