function fmOnContextMenu() {
	var o= event.srcElement;
	var s= o.tagName;
	if ((s && !(s == "INPUT" && o.type == "text") && s != "TEXTAREA") || o.disabled || o.className == "selectBox") event.returnValue= false;
}
function fmOnSelectStart() {
	var o= event.srcElement;
	var s= o.tagName;
	if (s == "INPUT" || s == "TEXTAREA" || s == "A" || o.contentEditable == "true") event.returnValue= true;
	else event.returnValue= false;
}
if (document.attachEvent) {
document.attachEvent("oncontextmenu", window.fmOnContextMenu);
document.attachEvent("onselectstart", window.fmOnSelectStart);
document.attachEvent("ondragstart", window.fmOnSelectStart);
}

function openStdWin(sPath, sName, iX, iY, scroll, full) {
	if (!iX) iX= 750;if (!iY) iY= 510;
	var top, left;
	try {
		if (full) { iX= screen.width - 5; iY= screen.availHeight - 60; top= 0; left= 0;
		} else { left= (screen.width - iX) / 2; top= (screen.availHeight - iY) / 2 - 30; }
		var params= "width=" + iX + ",height=" + iY + ",top=" + top + ",left=" + left + ",status=1,resizable=1,scrollbars=" + ((scroll) ? "1" : "0");
		window.open(sPath, sName, params);
	} catch(e) {}
}
function openStdDlg(sPath, oArgs, iX, iY, scroll) {
	return window.showModalDialog(sPath, oArgs, "dialogWidth:" + iX + "px;dialogHeight:" + iY + "px;help:0;status:0;scroll:" + ((scroll) ? "1" : "0") + ";center:1");
}
function openPopup() { return window.createPopup(); }

function buildWinName(s) {
	if (s) return s.replace(/[\s-\{\}]/g, "");
	var d= new Date();
	return d.getTime();
}

function HtmlEncode(s) {
	s= s.replace(/&/g, "&amp;");
	s= s.replace(/</g, "&lt;");
	s= s.replace(/>/g, "&gt;");
	s= s.replace(/\"/g, "&quot;");
	return s;
}

function XmlEncode(s) {
	if (IsNull(s)) return "";
	if (typeof(s) != "string") s= s.toString();
	s= escape(s);
	s= s.replace(/%20/g, " ");
	s= s.replace(/%u(\w{4})/g,	"&#x$1;");
	s= s.replace(/%(\w{2})/g,	"&#x$1;");
	return s;
}
function XmlDecode(s) {
	s= s.replace(/&lt;/g, "<");
	s= s.replace(/&gt;/g, ">");
	s= s.replace(/&apos;/g, "'");
	s= s.replace(/&quot;/g, "\"");
	s= s.replace(/&amp;/g, "&");
	return s;
}
function isArray(item) {
	return (item != null && ((item instanceof Array) || (typeof item.splice) == "function"));
}

function decodeXml(s) {
	// remove all unicode encoded symbols
	try { s= eval('"' + s.replace(/&#x(\w\w\w\w);/g, "\\u$1").replace(/"/g, '\\"') + '"'); } catch (e) {;}
	s= s.replace(/&lt;/g, "<");
	s= s.replace(/&gt;/g, ">");
	s= s.replace(/&apos;/g, "'");
	s= s.replace(/&quot;/g, "\"");
	s= s.replace(/&amp;/g, "&");
	return s;
}
function URLEncode(s) {
	s= s.replace(/ /g, "%20");
	s= s.replace(/"/g, "%22");
	s= s.replace(/#/g, "%23");
	s= s.replace(/&/g, "%26");
	s= s.replace("+", "%2B");
	return s;
}
function Trim(s) {
	return s.replace(/^\s+|\s+$/g,'');
}
function FullTrim(s) {
	s= Trim(s);
	return s.replace(/'|"/g,'');
}
function IsNull(o) {
	return (typeof(o) == "undefined" || typeof(o) == "unknown" || o == null);
}
function formatString() {
if (arguments.length == 0) return "";
var s= arguments[0];
var args= arguments;
if (args.length > 1 && isArray(args[1])) { args= args[1];args.unshift(s); }
for (var i= 1; i < args.length; i++) {
	var argIndex= i - 1;
	s= s.replace(new RegExp("\\{" + argIndex + "\\}", "g"), args[i].toString());
}
return s;
}

function getNextSibling(o) {
do o = o.nextSibling;
while (o && o.nodeType != 1);
return o;
}
function getFirstElement(o) {
if (!o) return o;
o= o.firstChild;
if (o && o.nodeType == 1) return o;
while (o && o.nodeType != 1) o= o.nextSibling;
return o;
}
function getLastElement(o) {
o= o.lastChild;
if (o && o.nodeType == 1) return o;
while (o && o.nodeType != 1) o= o.previousSibling;
return o;
}
function getInnerText(o) { return (Sys.Browser.agent == Sys.Browser.Firefox) ? o.textContent : o.innerText; }

function getBrowserWidth() { var w= window.innerWidth; return (w) ? w : document.body.clientWidth; }
function getBrowserHeight() { var h= window.innerHeight; return (h) ? h : document.body.clientHeight; }

var oFHttp;
function Server_ReceiveData(url, returnXml) {
	if (oFHttp == null) oFHttp= new ActiveXObject("Msxml2.XMLHTTP");
	oFHttp.Open("GET", url, false); oFHttp.Send();
	return (returnXml) ? oFHttp.responseXML : oFHttp.responseText;
}

window._fmres= new Array();
function fmres(key, defaultText){
var s=window.parent._fmres[key];
return (s)?s:defaultText;
}
window._help= true;
