var IE = document.all?true:false;
if( !IE ) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var MouseX = 0;
var MouseY = 0;
var WinX = 0;
var WinY = 0;
function getMouseXY(e)
{
	if( IE )
	{
		MouseX = event.clientX + document.body.scrollLeft;
		MouseY = event.clientY + document.body.scrollTop;
	}
	else
	{
		MouseX = e.pageX;
		MouseY = e.pageY;
	}
	if( MouseX < 0 ){MouseX = 0;}
	if( MouseY < 0 ){MouseY = 0;}  
	
	return true;
}
/*
if( document.all )
{
	WinW = document.body.offsetWidth;
	WinH = document.body.offsetHeight;
}
else
{
	WinW = window.outerWidth;
	WinH = window.outerHeight;
}*/

function jA(Xu,Xc,XcP,Xr)
{
	try{ js_conn = new XMLHttpRequest(); }
	catch(e){ try{ js_conn = new ActiveXObject("Msxml2.XMLHTTP"); }
	catch(e){ try{ js_conn = new ActiveXObject("Microsoft.XMLHTTP"); }
	catch(e){ try{ js_conn = new XMLHttpRequest(); }
	catch(e){ alert('You need ActiveX to be enabled in your browser to use it.'); } } } }
	
	try
	{
		js_conn.onreadystatechange = function()
		{
			if( js_conn.readyState == 4 )
			{
				if( js_conn.status == 200 )
				{
					if( !XcP ) XcP = '';
					if( Xr )
					{
						eval(Xc + '(js_conn.responseXML '+XcP+')');
					}
					else
					{
						eval(Xc + '(js_conn.responseText '+XcP+')');
					}
				}
				//else
				//{
				//	alert('There was a problem with the request.(Code: ' + js_conn.status + ')');
				//}
			}
		}

		js_conn.open("GET", Xu, true);
		js_conn.send(null);
	}
	catch(e){}
}

function jB(result)
{
	try
	{
		if( document.implementation.createDocument )
		{ 
			var xml_conn = (new DOMParser()).parseFromString(result, "text/xml");
		}
		else if( window.ActiveXObject )
		{ 
    		var xml_conn = new ActiveXObject("Microsoft.XMLDOM"); 
			xml_conn.async="false"; 
    		xml_conn.loadXML(result);
		}

		var root = xml_conn.getElementsByTagName('report')[0];
		for( i = 0 ; i < root.childNodes.length ; i++ )
		{
			var node = root.childNodes.item(i);
			if( node.nodeType == 1 )
			{
				var name = node.nodeName;
				var value = ''; if( node.firstChild ) value = node.firstChild.nodeValue;
				var action = node.getAttribute("action");
				switch(action)
				{
					case 'alert': alert(value); break;
					case 'location': document.location.href=value;break;
					case 'eval': eval(value);break;
					default: eval("if(document.getElementById('"+name+"')){document.getElementById('"+name+"')."+action+" = '"+value+"'};");
					//alert("if(document.getElementById('"+name+"')){document.getElementById('"+name+"')."+action+" = '"+value+"'};");
				}
			}
		}
	}
	catch(e){}
}

function jN(result)
{
}

function jC(result, _id, _append)
{
	if( !document.getElementById(_id) ) return;
	if( _append == true )
		document.getElementById(_id).innerHTML += result;
	else
		document.getElementById(_id).innerHTML = result;
}

var optShowHideVar = '';
function optShowHide(_id)
{
	if( document.getElementById(_id) )
	{
		if( document.getElementById(_id).style.display == '' )
		{
			optHide(_id);
			optShowHideVar = '';
		}
		else
		{
			//close previous
			if( optShowHideVar != '' && document.getElementById(optShowHideVar) ) optHide(optShowHideVar);
			optShow(_id);
			optShowHideVar = _id;
		}
	}
}
function optHide(_id)
{
	document.getElementById(_id).style.display = 'none';
	if( document.getElementById(_id+'TO') ) document.getElementById(_id+'TO').className = 'optO';
}
function optShow(_id)
{
	document.getElementById(_id).style.display = '';
	if( document.getElementById(_id+'TO') ) document.getElementById(_id+'TO').className = 'optX';
}

function createPopup(_parent, _id, _style)
{
	if( !document.getElementById(_parent) ) return;
	if( document.getElementById(_id) ){ showPopup(_id); return; }
	
	obj = document.createElement("DIV");
    obj.id = _id+'Shadow';
    obj.className = "div_popup_shadow";
    for( var name in _style )
	{
		value = _style[name];
		if( name == "left" || name == "top") value = parseInt(value) + 5;
		if( value != "" && /*!(value instanceof Object) && */name != "length" && name !="parentRule" ){obj.style[name] = value;}
    }
	document.getElementById(_parent).appendChild(obj);

	obj = document.createElement("DIV");
    obj.id = _id;
    obj.className = "div_popup";
    for( var name in _style )
	{
		value = _style[name];
		if( value != "" && /*!(value instanceof Object) && */name != "length" && name !="parentRule" ){obj.style[name] = value;}
    }
    objX = document.createElement("DIV");
    objX.style["position"] = "absolute";
    objX.style["right"] = "2";
    objX.style["top"] = "1";
    objX.innerHTML = '<a href="" onclick="hidePopup(\''+_id+'\');return false;"><b>X</b></a>';
    obj.appendChild(objX);
	document.getElementById(_parent).appendChild(obj);
}

function createFillPopup(_parent, _id, _idContent, _style)
{
	if( !document.getElementById(_parent) ) return;
	if( document.getElementById(_id) ){ showPopup(_id); return; }
	if( !document.getElementById(_idContent) ) return;
	createPopup(_parent, _id, _style);
	
	document.getElementById(_id).innerHTML = document.getElementById(_id).innerHTML+document.getElementById(_idContent).innerHTML;
}

function showPopup(_id)
{
	if( document.getElementById(_id+'Shadow') ) document.getElementById(_id+'Shadow').style.display = '';
	if( document.getElementById(_id) ) document.getElementById(_id).style.display = '';
}

function hidePopup(_id)
{
	if( document.getElementById(_id+'Shadow') ) document.getElementById(_id+'Shadow').style.display = 'none';
	if( document.getElementById(_id) ) document.getElementById(_id).style.display = 'none';
}

function AppendOptionToSelection( _select, _name, _val, _selected )
{
	if( document.getElementById(_select) )
	{
		var opt = document.createElement("option");
        opt.value = _val;
        opt.innerHTML = _name;
        opt.selected = _selected;
        document.getElementById(_select).appendChild(opt);
    }
}