function movediv(this_div){
var h=document.body.scrollTop;

window.scroll(0,h);
var this_div=document.getElementById (this_div);
var left=(document.body.clientWidth-parseInt(this_div.style.width))/2;
var top=h+document.body.clientHeight/2-parseInt(this_div.style.height)/2;
this_div.style.left=left
this_div.style.top=top
}

////////////////////////////////////
var dragapproved=false;
var start_x=0;
var start_y=0;
var cursor_x=0;
var cursor_y=0;
var div_to_move;
   function start_move(div_id){
	   if(window.event){
         dragapproved=true;
		 div_to_move=document.getElementById(div_id);
         start_x=parseInt(div_to_move.style.left);
         start_y=parseInt(div_to_move.style.top);
         cursor_x=event.x;
		 cursor_y=event.y;
		 document.onmousemove=moveit;
	   }
   }
   function moveit(){
      if (dragapproved==true){
         	div_to_move.style.left=start_x+(event.x-cursor_x)+"px"
         	div_to_move.style.top=start_y+(event.y-cursor_y)+"px"
		 return false;
      }
   }
   function stop_move(){
	  dragapproved=false; 
   }

////////////////////////////////

var req;

function update_online(){

	send_request("GET","?update_online")

}

function send_request(method,url){

    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open(method, url, true);
        req.send(null);

    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open(method, url, true);
            req.send();
        }
    }


function processReqChange() {   
    
    ab = window.setTimeout("req.abort();", 50000);
    
    if (req.readyState == 4) {
        clearTimeout(ab);
    }  
}
}

function new_window(url,w,h){
	var s_w=screen.availWidth;
	var s_h=screen.availHeight;
	
	if (w>s_w) w=s_w
	if (h>s_h-50) h=s_h-50
	
	w=w*1+17;
	h=h*1+4;
	w_left=(s_w-w)/2
	w_top=(s_h-h)/2
	
	
	window_size="scrollbars=1, resizable=1, height="+h+",width="+w+",left="+w_left+",top="+w_top
	nw = window.open(url,"nw",window_size)
	nw.focus()
}

function open_editor(){
w=screen.availWidth-10
h=screen.availHeight-40

	window_size="scrollbars=0, height="+h+",width="+w+",left=0,top=0";
	nw = window.open("./?htmleditor","nw_htmleditor",window_size)
	nw.focus();

}

if (window.Node)
{
if(typeof(Node.prototype.__defineGetter__)!="undefined"){
  Node.prototype.__defineGetter__('innerText', function() {
    if (this.nodeType == 3)
      return this.nodeValue;
    else
    {
      var result = '';
      for (var child = this.firstChild; child; child = child.nextSibling)
        result += child.innerText;
      return result;
    }
  });
}
}