var moused = false;
var offsetx = 0;
var offsety = 0;

function ajaxMovableWinInit() {
	document.getElementById('ajaxhttppostshadow').style.left = 480 + 'px';
	document.getElementById('ajaxhttppostshadow').style.top = 210 + 'px';
	if(document.all)
		document.getElementById('ajaxhttppostshadow').style.width = '65%';
}

function xmlhttpPost(strURL) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send('');
}

function updatepage(str){
    document.getElementById("ajaxhttppostshadow").style.display = '';
    document.getElementById("ajaxhttppost").style.display = '';
    document.getElementById("ajaxhttppost").innerHTML = "<div class='javalink' onmousedown='setMoused(true,event);' onmouseup='setMoused(false);'><span class=\"ajaxlogo\" style=\"float:left;margin-left:3px;\">ajax</span> <a style='cursor: pointer; cursor: hand;' onclick='document.getElementById(\"ajaxhttppostshadow\").style.display = \"none\"; document.getElementById(\"ajaxhttppost\").style.display = \"none\"; ajaxMovableWinInit();'>X</a></div>" + str;
}

function moveBox(e)
{
	if(moused){
		var pos = getMouseXY(e);
		var newx = pos[0] - offsetx;
		var newy = pos[1] - offsety;
		document.getElementById("ajaxhttppostshadow").style.left = newx + 'px';
		document.getElementById("ajaxhttppostshadow").style.top = newy + 'px';
	}
}

function setMoused(val,e)
{
	moused=val;
	if(e){
		offsetx = 0;
		offsety = 0;
		var pos = getMouseXY(e);
		var divx = parseInt(document.getElementById("ajaxhttppostshadow").style.left);
		var divy = parseInt(document.getElementById("ajaxhttppostshadow").style.top);
		offsetx = pos[0] - divx;
		offsety = pos[1] - divy;
	}
}

function getMouseXY(e)
{
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		posx = e.clientX + document.body.scrollLeft;
		posy = e.clientY + document.body.scrollTop;
	}
	return [posx,posy];
}

