function prop_check(field){

var theForm = field.form;
var valueget=field.value;
if (field.value==0){
for(z=0; z<theForm.length;z++){
  if(theForm[z].type == 'checkbox' &&  theForm[z].name == 'TypeProperties' &&  theForm[z].value != '0'){
   theForm[z].checked=false
  }
  }
}
else{
for(z=0; z<theForm.length;z++){
  if(theForm[z].type == 'checkbox' &&  theForm[z].name == 'TypeProperties' &&  theForm[z].value == '0'){
   theForm[z].checked=false
  }
  }
}


}

function toggle_it(itemID){
//var menu1= 
document.getElementById("menubyuser").innerHTML=""; 
if (itemID=="azienda")
          document.getElementById("menubyuser").innerHTML="<table class=\"checkUser\">"+
	"<tr>"+
		"<td><input type=\"checkbox\" name=\"TypeProperties\" checked=\"checked\" value=\"0\" onclick=\"prop_check(this);\" />Tutti</td>"+
    "<td><input type=\"checkbox\" name=\"TypeProperties\" value=\"1\" onclick=\"prop_check(this);\" />Ufficio</td>"+
    "<td><input type=\"checkbox\" name=\"TypeProperties\"  value=\"2\"onclick=\"prop_check(this);\" />Negozio</td>"+
	"</tr><tr>"+
		"<td><input type=\"checkbox\" name=\"TypeProperties\" value=\"3\" onclick=\"prop_check(this);\" />Laboratorio</td>"+
    "<td><input  type=\"checkbox\" name=\"TypeProperties\" value=\"4\" onclick=\"prop_check(this);\" />Capannone</td>"+
    "<td><input type=\"checkbox\" name=\"TypeProperties\" value=\"5\" onclick=\"prop_check(this);\"/>Albergo</td>"+
	"</tr>"+
"</table>";
else
    document.getElementById("menubyuser").innerHTML="<table class=\"checkUser\">"+
	"<tr>"+
		"<td><input type=\"checkbox\" name=\"TypeProperties\" checked=\"checked\" value=\"0\" onclick=\"prop_check(this);\" />Tutti</td>"+
    "<td><input type=\"checkbox\" name=\"TypeProperties\" value=\"1\" onclick=\"prop_check(this);\" />Appartamento</td>"+
    "<td><input type=\"checkbox\" name=\"TypeProperties\"  value=\"2\"onclick=\"prop_check(this);\" />Attico</td>"+
	"</tr><tr>"+
		"<td><input type=\"checkbox\" name=\"TypeProperties\" value=\"3\" onclick=\"prop_check(this);\" />Villa</td>"+
    "<td><input  type=\"checkbox\" name=\"TypeProperties\" value=\"4\" onclick=\"prop_check(this);\" />Rustico</td>"+
    "<td><input type=\"checkbox\" name=\"TypeProperties\" value=\"5\" onclick=\"prop_check(this);\"/>Box</td>"+
	"</tr>"+
"</table>";

} 
var ajax = new Array();
function initformsearch(){
getCountryInit();
}
function getCountryInit(){
    document.getElementById('search_country').options.length = 0;
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'varpage/formSearchPosition.php?getCountry=1';	// Specifying which file to get
		ajax[index].onCompletion = function(){ iCountry(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
}
function getCountry(value){
 
    document.getElementById('search_country').options.length = 0;
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'varpage/formSearchPosition.php?getCountry='+value;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCountry(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
}
function getRegioni(value){
  document.getElementById('search_regioni').options.length = 0;
  var index = ajax.length;
	ajax[index] = new sack();
	ajax[index].requestFile = 'varpage/formSearchPosition.php?codeCountry='+value;	// Specifying which file to get
	ajax[index].onCompletion = function(){ createRegioni(index) };	// Specify function that will be executed after file has been found
	ajax[index].runAJAX();
	}
function getProvince(value){
   document.getElementById('search_province').options.length = 0;
  var index = ajax.length;
	ajax[index] = new sack();
	ajax[index].requestFile = 'varpage/formSearchPosition.php?codeRegion='+value;	// Specifying which file to get
	ajax[index].onCompletion = function(){ createProvince(index) };	// Specify function that will be executed after file has been found
	ajax[index].runAJAX();
	
}
function getComuni(value){
  document.getElementById('search_comuni').options.length = 0;
  var index = ajax.length;
	ajax[index] = new sack();
	ajax[index].requestFile = 'varpage/formSearchPosition.php?codeProvince='+value;	// Specifying which file to get
	ajax[index].onCompletion = function(){ createComuni(index) };	// Specify function that will be executed after file has been found
	ajax[index].runAJAX();
}

function createCountry(index){

	var obj = document.getElementById('search_country');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code

	}
function iCountry(index){

	var obj = document.getElementById('search_country');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code
	obj.options[1].selected=true;
	getRegioni("1");

  
	}
function createRegioni(index){
	var obj = document.getElementById('search_regioni');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code
	getProvince(obj.options[0].value);
}
function createProvince(index){
  var obj = document.getElementById('search_province');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code
	getComuni(obj.options[0].value);
}
function createComuni(index){
  var obj = document.getElementById('search_comuni');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code

}
