
var ajax_done = false;

/*onload = function()
{
 document.getElementById(current_bar).style.background = '#CE0500';
}*/

function getForm(lang, section, form)
{
 changeBarPosition(form);
 document.getElementById('mn_menu_id').innerHTML = '<span style="color:#FFFFFF;">&nbsp;loading...</span>';
 var ajax = new Ajax();
 
 ajax.onDone = function(ajaxObj, responseText)
 {
   ajax_done = true;
   var form = responseText;
   document.getElementById('mn_menu_id').innerHTML = form;
 }
 
 ajax.onFail = function(ajaxObj) {}
 params = 'a=1&f=' + form;
 ajax.get('/' + lang + '/' + section + '/', params);
}

function changeBarPosition(bar_id)
{
 document.getElementById(current_bar).style.background = '';
 document.getElementById(bar_id).style.background = '#CE0500';
 current_bar = bar_id;
}

function clearList(el)
{
 var opt = document.getElementById(el);
 if (opt.length > 0) {
  for (var i = opt.length; i >= 0; i--) {
   opt.remove(i);
  }
 } 
}

function fillList(el)
{
 if (json_vars.total != 0)
 {
  setText('Select City', el)   
  for ( var i = 1; i <= json_vars.total; i++) {
   var name = json_vars.opt[i].name;
   var id = json_vars.opt[i].id;
   var select = document.getElementById(el);
   opt = document.createElement('option');
   opt.text = name;
   opt.value = id;
   if( isGecko ) {
    // for Mozilla
    document.getElementById(el).appendChild(opt);
   } else {
    // for IE
    document.getElementById(el).add(opt);
   } 
  }
 } else setText('', el);
}

function setText(text, el)
{
 opt = document.createElement('option');
 opt.text = text;    
 opt.value = "";
 if (IsCompitableBrowser()) isGecko = true; else isGecko = false;
 if( isGecko ) {
  // for Mozilla
  document.getElementById(el).appendChild(opt);
 } else {
  // for IE
  document.getElementById(el).add(opt);
 }
}

function getCity(lang, section)
{
 clearList('st_city');
 qt = document.getElementById('st_country');
 var country_id = qt.options[qt.selectedIndex].getAttribute('value');
 
 var ajax = new Ajax();
 ajax.onDone = function(ajaxObj, responseText)
 {
  var json_opt = responseText;
  json_vars = json_opt.parseJSON();
  clearList('st_city');
  fillList('st_city');  
 }

 ajax.onFail = function(ajaxObj) {}
 setText('Loading...', 'st_city');
 params = 'c_id=' + country_id; 
 ajax.get('/getcity.php', params);
}


