var h = '../admin/catsBrowse.php?';
var q = '';
var s = '';
var all = '';

function start(x){
  all = getList();
  if(x > -1){
    getCountry(x);
  }
}

function getList(){
  return document.getElementById('display').innerHTML;
}

function listall(){
  document.getElementById('display').innerHTML = all;
}

function setDrop(x){
  var map = document.getElementById('dropdown');
  if(x < 3){
    var n = x + 2;
  }else if(x == 3){
    var n = 5;
  }else if(x > 3){
    var n = x + 3;
  }
  if(x == 8){
    var n = 1;
  }else if(x == 10){
    var n = 5;
  }else if(x == 9){
    var n = 11;
  }
  map.selectedIndex = n;
}

function mapFocus(x){
  setDrop(x);
  select(x);
}

function select(x){
  if(x == '0'){
    var id = 'US';
  }else if(x == '1'){
    var id = 'MX';
  }else if(x == '2'){
    var id = 'BR';
  }else if(x == '3'){
    var id = 'KE';
  }else if(x == '4'){
    var id = 'IR';
  }else if(x == '5'){
    var id = 'FR';
  }else if(x == '6'){
    var id = 'KZ';
  }else if(x == '7'){
    var id = 'CH';
  }else if(x == '8'){
    var id = 'IN';
  }else if(x == '9'){
    var id = 'AS';
  }else if(x == '10'){
    var id ='ML';
    x = '3';
  }else if(x = 'all'){
    listall();
    flashProxy.call('zoomOut');
    return;
  }
  linkGetCats(x);
  flashProxy.call('zoomTo',id);
}

function getCats(x){
  setDrop(x);
  q = 'action=map&set='+x;
  var req = h+q+s;
  send(req);
}

function linkGetCats(x){
  q = 'action=map&set='+x;
  var req = h+q+s;
  send(req);
}

function listCat(x){
  window.location='topic.php?id='+x;
}

function listLoc(x){
  getCountry(x);
}

function sort(x){
  s = '&sort='+x;
  var req = h+q+s;
  send(req);
}

function getCountry(x){
  q = 'action=map&country='+x;
  var req = h+q+s;
  send(req);
}

function send(req){
  xmlHttp=ajaxFunction();
  xmlHttp.onreadystatechange=d;
  xmlHttp.open("GET",req,true);
  xmlHttp.send(null);
}

function d() 
{
  if (xmlHttp.readyState==4)
  { 
    document.getElementById('display').innerHTML = xmlHttp.responseText;
    window.location.hash="map";
  }
}

function ajaxFunction()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
return xmlHttp;
}
