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

var stack = 10000;

function open_content (content_tag) {
  var xmlHttp = open_request();
  xmlHttp.onreadystatechange=function() {
   if(xmlHttp.readyState==4) {
     document.getElementById("content").innerHTML += xmlHttp.responseText;
     var id = content_tag.replace(/_/g,'');
     do_stack(id);    
     return false;     
    }
  } 
  xmlHttp.open("GET","/popup.php?tag=" + content_tag,true);
  xmlHttp.send(null);
}

function close_popup (id) {
  document.getElementById('content').removeChild(document.getElementById(id));
  return false;
}

function focus_to_drag (id) {
  var mHandle = document.getElementById('handle_' + id); 
  var mRoot = document.getElementById(id);
  Drag.init(mHandle, mRoot);
  do_stack(id);
  return false; 
}

function do_stack (item) {
  stack = parseInt(stack+1);         
  // alert("we got item -> "+ item);
  document.getElementById(item).style.zIndex=stack;   
}


function do_float (content_tag) {
  document.getElementById('float_' + content_tag).style.display='block';
  return false;
}

function undo_float (content_tag) {
  document.getElementById('float_' + content_tag).style.display='none';
  return false;
}