var ie4 = document.all;
var ns6 = document.getElementById && !document.all;
var first = true;

inAjaxWindow = function(window_id, box_id, use_url)
{
	var window = document.getElementById(window_id);
	var box = document.getElementById(box_id);
	var url = use_url;
	this.method = 'GET';
	this.left = 100;
	this.top = 400;
	this.visibility = 'visible';
	
	this.LoadData = function(action, query)
	{
		var req = new Subsys_JsHttpRequest_Js();
		req.left = this.left;
		req.top = this.top;
		req.visibility = this.visibility;
		req.onreadystatechange = function()
		{
			if (req.readyState == 4)
			{
				if (req.responseJS.text!='')
				{
					box.innerHTML = req.responseJS.text;
					window.style.left = this.left;
					window.style.top = this.top;
					first = false;
					window.style.visibility = this.visibility;
				}
			}
		}
		req.caching = false;
		req.open(this.method, use_url, false);
		req.send({a: action, q: query});
	}
	this.OneLoadData = function(action, query)
	{
		if (first)
		{
			this.LoadData(action, query);
		}
		else
		{
			window.style.visibility = this.visibility;
		}
	}
}

function hide(id)
{
	document.getElementById(id).style.visibility = 'hidden';
}

function show(id)
{
	document.getElementById(id).style.visibility = 'visible';
}

Array.prototype.toString = 
Object.prototype.toString = function()
{
	var cont = [];
	var addslashes = function(s)
	{
		return s.split('\\').join('\\\\').split('"').join('\\"');
	}
	for (var k in this)
	{
		if (cont.length) cont[cont.length-1] += ",";
		var v = this[k];
		var vs = '';
		if (v.constructor == String)
			vs = '"' + addslashes(v) + '"';
		else
      vs = v.toString();
			if (this.constructor == Array)
		cont[cont.length]
			else 
		cont[cont.length] = k + ": " + vs;
	}
	cont = "  " + cont.join("\n").split("\n").join("\n  ");
	var s = cont;
	if (this.constructor == Object)
	{
		s = "{\n"+cont+"\n}";
	}
	else if (this.constructor == Array)
	{
		s = "[\n"+cont+"\n]";
	}
	return s;
}

function drag_drop(e)
{
	if (ie4 && dragapproved)
	{
		cross.style.left = tempx + event.clientX - offsetx;
		cross.style.top = tempy + event.clientY - offsety;
		return false;
	}
	else if (ns6 && dragapproved)
	{
		cross.style.left = tempx + e.clientX - offsetx + "px";
		cross.style.top = tempy + e.clientY - offsety + "px";
		return false;
	}
}
function indrag(e, el, base_elem)
{
	cross = document.getElementById(el);
	
	var firedobj = ns6 ? e.target : event.srcElement;
	var topelement = ns6 ? "html" : document.compatMode && document.compatMode!="BackCompat" ? "documentElement" : "body";
	while (firedobj.tagName != topelement.toUpperCase() && firedobj.id!=base_elem)
	{
		firedobj = ns6 ? firedobj.parentNode : firedobj.parentElement;
	}
	if (firedobj.id==base_elem)
	{
		offsetx = ie4 ? event.clientX : e.clientX;
		offsety = ie4 ? event.clientY : e.clientY;
		
		tempx = (first) ? 100 : parseInt(cross.style.left);
		tempy = (first) ? 100 : parseInt(cross.style.top);
		first = false;
		dragapproved = true;
		document.onmousemove = drag_drop;
	}
}

function of()
{
	dragapproved = false;
	document.onmousemove = new function(){};
}