function caller_getCountryDestination(){
  x_getCountryDestination(ge('stat1').value, displayer_getCountryDestination);
}

// Fce je volala pri odeslani formulare pro upravu osobnich udaju
// kontroluje, jestli jsou nova hesla vyplnena, pokud jsou shodna, 
// tak se vola SAJAX aby zkontroloval se starym heslem.
function caller_checkOldPwd(){

  var oldpwd = trim(ge("pwdold").value);
  var pwdnew1 = trim(ge("pwdnew1").value).toString();
  var pwdnew2 = trim(ge("pwdnew2").value).toString();
  
  if(!isEmpty(pwdnew1) || !isEmpty(pwdnew2) || !isEmpty(oldpwd)){
    if(pwdnew1 != pwdnew2){
      alert("Nové heslo a kontrolní heslo se neshodují.");
    }else{
      x_compareToOldPassword(oldpwd, displayer_submitEditDataForm);  
    }
    return false;
  }
  
  return true;  
}

function displayer_submitEditDataForm(status){
  if(status != "y"){
    alert("Lituji, ale zadané heslo se neshoduje s Vaším starým heslem.");
  }else{
    ge("editdataform").submit();
  }
}

function caller_getSearchCountryDestination(){
  x_getCountryDestination(ge('stat1').value, displayer_getSearchCountryDestination);
}

function displayer_getSearchCountryDestination(result){

  var selDestValue1 = parseInt(ge("seldest1").value);
  var selDestIndex1 = 0;
  
  var selDestValue2 = parseInt(ge("seldest2").value);
  var selDestIndex2 = 0;

  var dest1 = ge("dest1");
  var dest2 = ge("dest2");
  
  dest1.options.length = 0;
  dest1.options[0] = new Option('(vyberte)',-1);
  
  dest2.options.length = 0;
  dest2.options[0] = new Option('-------------',-1);
      
  if(result != "none"){  
    var dests = result.split("#");   
    for(i=0; i < dests.length; i++){
      var buff = dests[i].split("~"); 
      
      dest1.options[i+1] = new Option(buff[1],buff[0]);
      dest2.options[i+1] = new Option(buff[1],buff[0]);      
      
      if(buff[0] == selDestValue1) selDestIndex1 = i+1;
      if(buff[0] == selDestValue2) selDestIndex2 = i+1;            
    }
    
    if(selDestIndex1 > 0) dest1.options.selectedIndex = selDestIndex1;
    if(selDestIndex2 > 0) dest2.options.selectedIndex = selDestIndex2;   
      
  }  
    
}

function displayer_getCountryDestination(result){

  var dest = ge("dest1");
  dest.options.length = 0;
  dest.options[0] = new Option('Nerozhoduje',-1);
    
  if(result != "none"){  
    var dests = result.split("#");   
    for(i=0; i < dests.length; i++){
      var buff = dests[i].split("~"); 
      dest.options[i+1] = new Option(buff[1],buff[0]);
    }  
  }    
}
