/*=======================================================================*
*	         Copyright 2002-07 by Virtual Gallerie, LLC.             *
*     This material is the confidential trade secret and proprietary     *
*     information of Virtual Gallerie, LLC. It may not be reproduced,    *
*     used, sold or transferred to any third party without the prior     *
*     written consent of Virtual Gallerie, LLC. All rights reserved.	 *
*=======================================================================*/

var divStr = "";
var gb_useStyles = true;

var cr = String.fromCharCode(13, 10),
	crn = String.fromCharCode(10),
	crr = String.fromCharCode(13);
var tab = String.fromCharCode(9);
var br = "<br>";
var nbs = "&nbsp;";
var nbs2 = nbs + nbs;
var nbs4 = nbs2 + nbs2;
var nbs8 = nbs4 + nbs4;
var squot = String.fromCharCode(96); // for turning ' into the fancee single quote
var xquot = '&quot;';
var BrowserDetect;

initBD();

var brzr = whatbrowser();
var gb_IE = isIE();
var gb_IE7 = isIE7();
var gb_IE8 = isIE8();
var gb_mac = ismac();
var gb_safari = issafari();
var gb_chrome = ischrome();
var gb_moz = ismoz();
var gb_vista = BrowserDetect.dataOS.version && (BrowserDetect.dataOS.version[0] > 5); //well, really == 6, but for now make all as true

var b_goodMenus = false;

var menuFormName = "myForm";

var b_gebid = document.getElementById != null;
var maxInchDenom = 128;
var gb_canUseActualClipboard = false;

var gs_formClassNameStart = "f",
	gs_formClassNamePfx_FORM_FLD = "f",
	gs_formClassNamePfx_FORM_MENU = "m",
	gs_formClassNamePfx_FORM_BUTT = "b",
	gs_prefIDTextSize = "ts",
	gs_prefIDSerif = "fs";

var gs_className_BODY = "",
	gs_className_FORM_FLD = gs_formClassNamePfx_FORM_FLD ? gs_formClassNameStart + gs_formClassNamePfx_FORM_FLD : null,
	gs_className_FORM_MENU = gs_formClassNamePfx_FORM_MENU ? gs_formClassNameStart + gs_formClassNamePfx_FORM_MENU : null,
	gs_className_FORM_BUTT = gs_formClassNamePfx_FORM_BUTT ? gs_formClassNameStart + gs_formClassNamePfx_FORM_BUTT : null;

var go_moz = ismoz() ? new Object() : null;
var gi_dragImageBorder = 1;
var gb_sendMouseUps = false;

var gb_hideImageURLs = false;
var gb_debug = false;//true;
var gb_showDebugger = false;
var gb_showConsole = true;
var gb_playerDebug = false;
var gb_playerLocal = isRunningLocal();

if (!gb_debug) {
	gb_showDebugger = gb_showConsole = false;
}

function setDebug(b) {
	gb_showDebugger = gb_showConsole = b;
}

var gs_rootPathForPluginspage = "http://www.virtualgallerie.com/players",
	gs_rootPathForCodebase = gs_rootPathForPluginspage + "/english/5.2/win/"; //codebase is IE-Windows only...

function setPFP(new_base) {
	gs_rootPathForPluginspage = new_base;
	gs_rootPathForCodebase = gs_rootPathForPluginspage + "/english/5.2/win/";
}
	//http://a320.g.akamai.net/7/320/1456/v50245/www.pulse3d.com/players/
var gb_enableSelOnMouseUp = false;

var gb_dndUsesClicks = false; // should default to true if online+vista...
var go_lastEvent = null; //gets set by cte... use instead of window.event. or event. for cross-browser compatibility

var gb_forceImageHTTPSIf = false; //if an image path is hard-coded w/ http: and we're in an https: environment
		//should we force the image path to https? else will get the "mixed secure non-secure" msg
		//however, forcing https: might make them missing...
gb_dndUsesClicks = true;

var gs_ctrlKeyLabel = gb_mac? "Option" : "Ctrl";

function isRunningLocal() {
	var url = window.document.URL;

	return (url && (url.indexOf("file://") == 0));
}

//todo: unused?
function mozselectstart(event) {
	//writeToConsole(event.target.tagName);

	switch(event.target.tagName) {
	case "SELECT":
		return gb_safari;
	case "INPUT":
	case "TEXTAREA":
	case "OBJECT":
	case "EMBED":
		return true;
	}
	return false;
}

if (gb_chrome) {
	initMozObj();
	document.onmousedown= function(event) {
		//writeToConsole(event.target.tagName);
		//todo: maybe do this for all browsers? or similar
		if (event.target.onmouseup
			|| event.target.onclick
			|| event.target.ondblclick) return true;
			
		switch(event.target.tagName) {
		case "SELECT":
			return true;
		case "INPUT":
		case "TEXTAREA":
		case "OBJECT":
		case "EMBED":
		case "A":
			return true;
		default:
			var pe = getParentElement(event.target);
			if (pe && (pe.tagName == "A")) {
				return true;
			}
			if (go_focusedFld) {
				clearActualFocus(true);
				//go_focusedFld.bulr();
				//window.focus();
				//clearFocus(true);
			}
			break;
		}
		return false;
	}
} else if (go_moz) {
	initMozObj();
	//document.body.style.MozUserSelect = "none";
	//document.onmousedown=mozselectstart;

	document.onmousedown= function(event) {
	//writeToConsole(event.target.tagName);

		switch(event.target.tagName) {
		case "SELECT":
			return gb_safari;
		case "INPUT":
		case "TEXTAREA":
		case "OBJECT":
		case "EMBED":
			return true;
		default:
			if (go_focusedFld) {
				clearActualFocus(true);
				//go_focusedFld.bulr();
				//window.focus();
				//clearFocus(true);
			}
			break;
		}
		return false;
	}
} else {
	document.onselectstart = function() {
		switch(event.srcElement.tagName) {
		case "INPUT":
		case "TEXTAREA":
		case "OBJECT":
		case "EMBED":
		case "SELECT":
			return true;
		}
		return false;
	}
}

function initMozObj() {
	go_moz.dnd = new Object();
	go_moz.dnd.status = 0;
}

function getNewTag(tname, tval) {
	return ' ' + tname + '="' + tval + '"';
}

function getNewTag_REAL(tname, tval, dflt) {
	if (tval == "") {
		if (!dflt) return getNewTag(tname, 0.0);
		else return getNewTag(tname, dflt);
	}
	return getNewTag(tname, tval);
}

function getNewTag_ESC_NOQUOTES(tname, tval) { return " " + tname + "=" + escape(tval);}

function getNewTag_ESC(tname, tval) { return getNewTag(tname, escape(tval)); }

function getNewTagSet() {
	var a=getNewTagSet.arguments;
	var i, l;
	var s = "";

	l = a.length;

	for (i = 0; i < l; i+= 2) {
		s += getNewTag(a[i], a[i+1]);
	}

	return s;
}

function getNewNameIDTag(name_id) {
	return getNewTag("name", name_id) + getNewTag("id", name_id);
}

function getAltTitleTag(alt_title) {
	return getNewTag("alt", alt_title) + getNewTag("title", alt_title);
}

function replaceTag(src, tag_id, tag_v) {
	var i = src.indexOf(tag_id + '="');
	if (i > -1) {
		i += tag_id.length + 2;
		return src.substring(0, i) + tag_v + src.substring(src.indexOf('"', i + 1));
	}
	return src;
}

function imgIDFromButtID(b_id) {
	return b_id + "_IMG";
}

function setButtImgSrc(b_id, new_src) {
	var bio = getButtImg(b_id);

	if (bio) bio.src = new_src;
}

function getButtImg(b_id) {
	return objFromID(imgIDFromButtID(b_id));
}

function isUndefined(v) {
	return (typeof(v) == "undefined");
}
function getNewTagIf(tname, tval) {
	if ((tval == "") || (tval == null) || (isUndefined(tval))) return "";
	else return ' ' + tname + '="' + tval + '"';
}
function getInSQ(s) {
	return "'" + s + "'";
}

function getNewQueryAppendItem(qin, qival, b_add_quotes) {
	var qv = !b_add_quotes ? escape(qival) : getInSQ(escape(qival));

	return "&" + qin + "=" + qv;
}
function getNewFirstQueryItem(qin, qival, b_add_quotes) {
	var qv = !b_add_quotes ? escape(qival) : getInSQ(escape(qival));
	return qin + "=" + qv;
}
function getNewQueryStart(qin, qival, b_add_quotes) {
	var qv = !b_add_quotes ? escape(qival) : getInSQ(escape(qival));
	return "?" + qin + "=" + qv;
}

function getNewSafeTag(tname, tval) {
	return getNewTag(tname, ConvertStringToXMLSafe(tval));
}

// does it auto convert true to "true" anyway?
function getNewTFTag(tname, tf) {
	return (tf == true) ? getNewTag(tname, "TRUE") : getNewTag(tname, "FALSE");
}

function getNewTFPram(pname, tf) {
	if (tf == true) return getNewPram(pname, "TRUE");
	else return getNewPram(pname, "FALSE");
}

function getNewPram(pname, pval) {
	return '<PARAM NAME="' + pname + '" VALUE="' + pval + '"/>';
}

function doDeFocus(tod) {
	if (!tod) {
		clearActualFocus(true);
		window.focus();
		//debugger;
	} else {
		setTimeout("doDeFocus()", tod);
	}
}

function getNewButtonDef(name, value, custom_on_click_0, width0) {
	var s = '<input' + getNewNameIDTag(name) + getNewTag("type", "button") + getNewTag("value", value);

	var oce = gs_changeEvent;


	if (custom_on_click_0) oce += custom_on_click_0 + "('" + name + "')";
	else oce += "ButtonCmd('" + name + "')";

	//oce = "doDeFocus(2);" + oce;

	s += getNewTag("onClick", oce);

	if (width0) s += getNewTag("style", "width:" + width0);

	s += getNewTag("class", gs_className_FORM_BUTT);

	s += ">";

	return s;
}

function getNewAHTML(text, s_onclick, etc0, href0, b_imgonly) {
	if (href0) href0 = getNewTag("href", href0);
	else if (!b_imgonly) href0 = getNewTag("href", "#");

	if (!etc0) etc0 = "";
	else etc0 = " " + etc0;

	return "<a" + etc0 + getNewTag("onclick", s_onclick + ";return false") + href0 + ">" + text + "</a>";
}

function getNewButtonObj(name, value, f_on_click, o_0) { //on_click MUST call cte (well, if you need it...)
	//var o = document.createElement("button");
	var o = document.createElement("input");
	o.type = "button";

	o.name = o.id = name;
	o.value = value;
	if (ismoz()) o.innerHTML = value;
	o.onclick = f_on_click;
	o.className = gs_className_FORM_BUTT;
	if (o_0) o.o = o_0;
	return o;
}

function setObjClass(o_or_oid, classname) {
	getObjFromPram(o_or_oid).className = classname;
}

function getNewFieldDef_FILE(name, width, key_event_name, change_event_name) {
	return getNewFieldDef(true, name, "", width, key_event_name, "f", change_event_name);
}

//override if needed

var go_focusedFld = null;
var gto_blur = null;
var gb_newFocus = true;
var gs_focusedFrame = null;
var gb_sendfocusevents = true;

function setSendFocusEvents(tf) {
	if (!tf && gb_sendfocusevents) {
		if (gto_blur) {
			clearTimeout(gto_blur);
			gto_blur = null;
		}
	}
	gb_sendfocusevents = tf;
}

function childBlurred() {
	gs_focusedFrame = null;
	if (gb_sendfocusevents) DoCmd("pageevent type=blurred");
}
function childFocused(frame_name) {
	gs_focusedFrame = frame_name;
	if (gb_sendfocusevents) DoCmd("pageevent type=focused");

}

function blurTO() {
	// no focus since last blur... alert player ?
	gb_newFocus = true;

	childBlurred();
}

function blurred(obj) {
	if (gto_blur) clearTimeout(gto_blur);
	gto_blur = setTimeout("blurTO()", 2);
	go_focusedFld = null;
}

function focused(obj, lid) { //layer id (if no frames, should make focused send in this, if we really care)
	if (gb_newFocus) {
		gb_newFocus = false;
		childFocused(lid);
	}
	go_focusedFld = obj;
	if (gto_blur) {
		clearTimeout(gto_blur);
		gto_blur = null;
	}
}
function forceFocus(obj) {
	obj.focus();
	focused(obj);
}
function focused_o() {
	focused(this);
}
function blurred_o() {
	blurred(this);
}

function clearFocus(b_tell_player) {
	if (b_tell_player && go_focusedFld && gb_sendfocusevents) blurTO();
	go_focusedFld = null;
	gb_newFocus = true;


}

function clearActualFocus(b_tell_player) {
	if (go_focusedFld) {
		if (getAParentElement(go_focusedFld)) go_focusedFld.blur();
		if (b_tell_player) {
			blurTO();
		}
	}
}

function clearFocusMain(b_tell_player) {
	if (b_tell_player) {
		childBlurred(gs_focusedFrame);
	} else {
		gs_focusedFrame = null;
	}

}

function blurIf() {
	if (go_focusedFld) {
		try { //in case it's accitental, we put it in the try
			go_focusedFld.blur();
		}
		catch(e) {
			go_focusedFld = null;
		}
	}
}

function getFocusBlurTags() {
	return getNewTag("onFocus", "focused(this)") +  getNewTag("onBlur", "blurred(this)");
}

function defaultFieldKeyEvent(the_event, fld) {
	if (the_event.keyCode == 13) {
		return false;
	}
	return true;
}

function defaultFieldKeyEventForObj(e) {
	e = e ? e : window.event;
	if (e.keyCode == 13) {
		return false;
	}
	return true;
}

function defaultFieldKeyEvent_TA(the_event, fld) {
	return true;
}


function fieldKeyEventPassOn(the_event, fld) {
	return true;
}


function getNewReadOnlyFieldDef(name, value, width, ftype, err_func0) {

	/*
	//<INPUT TYPE="text" NAME="readonly" SIZE="25" value="Can't touch this." onFocus="this.blur()">
	var s = '<input' + getNewTag("type", "TEXT") + getNewNameIDTag(name);
	//s += getNewTag("onFocus", "this.blur()");
	s += getNewTag("value", value);
	s += getNewTag("size", width);
	var em = err_msg0 ? ",'" + escape(err_msg0) + "'" : "";

	s += getNewTag("onchange", "return readOnlyFldEvent(event, this, '" + escape(value) + "'" + em + ")");
	s += '>';
	return s;
	*/

	return getNewFieldDef(true, name, value, width, null, ftype, null, true, err_func0);
}
function readOnlyFldEvent(e, t, ov, ef0) {
	t.value = unescape(ov);
	if (ef0) eval(ef0 + "(e, t, ov)");
	return false;
}


function getNewFieldDef(vis, name, value, width, key_event_name, ftype, change_event_name, b_read_only, ro_err_evnt_name0) {
	var s = '<input';
	var b_ta = (ftype == "ta");
	var st = "";

	if (ftype && (ftype != "")) {
		if (b_ta) s = '<textarea';
		else if (ftype == "f") s += getNewTag("type", "file");
	} else if (vis == false) s += getNewTag("type", "hidden");

	//else s += getNewTag("type", "visible");
	s += getNewNameIDTag(name);
	//s += getNewTag("width",width);
	if (!b_ta) s += getNewTag("value", value);

	if (width < 0) st = "width:" + -width + "px;";
	else s += getNewTag("size", width);

	if (st != "") s += getNewTag("style", st);

	s += getFocusBlurTags();

	if (!key_event_name || (key_event_name == "")) {
		key_event_name = "defaultFieldKeyEvent"; // so that returns don't submit the form!
	}
	s += getNewTag("onKeyPress", "return " + key_event_name + '(event, this);'); // + ';return false;' ?


	s += getNewTag("class", gs_className_FORM_FLD);

	if (change_event_name && (change_event_name != "")) {
		s += getNewTag("onChange", change_event_name + '(event, this)');
	} else if (b_read_only) {
		var ee = ro_err_evnt_name0 ? ",'" + ro_err_evnt_name0 + "'" : "";

		s += getNewTag("onchange", "return readOnlyFldEvent(event, this, '" + escape(value) + "'" + ee + ")");

	}

	if (!b_ta) {
		s += '/>';
	} else {
		s += '>' + value + '</TEXTAREA>';
	}
	return s;
}

function getNewField_O(vis, name, value, width, f_key_event, ftype, f_change_event, b_read_only, f_ro_err_evnt0) {
	var o;// = document.createElement("input");
	var b_do_width = true;
	switch(ftype) {
	case "ta":
		o = document.createElement("textarea");
		b_do_width = false;
		break;
	case "f":
		o.document.createElement("file");
		break;
	default:
		//o = vis ? document.createElement("input") : document.createElement("hidden"); //todo: which is correct?
		o = document.createElement("input");
		if (!vis) o.type = "hidden";
		break;
	}

	var b_ta = (ftype == "ta");


	o.name = o.id = name;
	o.value = value;

	if (width && b_do_width) {
		o.style.width = width + "px";
		//o.size = o.width = width; //may need style for this?
	}
	o.onfocus = focused_o; //how to get "this"?
	o.onblur = blurred_o;

	if (!f_key_event) o.onkeypress = defaultFieldKeyEventForObj;
	else o.onkeypress = f_key_event;



	o.className = gs_className_FORM_FLD;

	if (f_change_event) {
		o.onchange = f_change_event;
	} else if (b_read_only) {
	/* todo: how to make this a proper function ?!?
		var ee = ro_err_evnt_name0 ? ",'" + ro_err_evnt_name0 + "'" : "";

		s += getNewTag("onchange", "return readOnlyFldEvent(event, this, '" + escape(value) + "'" + ee + ")");

	*/
	}

	return o;
}
function delayedFocusFromID(id, tod, b_do) {
	if (!b_do) {
		if (!tod) tod = 1;
		setTimeout("delayedFocusFromID(\"" + id + "\",0, true);", tod);
	} else {
		var o = objFromID(id);
		if (o) o.focus();
	}
}

function getNewField_TA_O(name, value, width, height, //make width and/or height neg to imply style and pixels
		f_key_event, f_change_event, b_read_only, f_ro_err_evnt0) {

	if (!f_key_event) f_key_event = function() { return true; };

	var o = getNewField_O(true, name, value, 0, f_key_event, "ta", f_change_event, b_read_only, f_ro_err_evnt0);

	if (width < 0) o.style.width = -width + "px";
	else o.cols = width;

	if (height < 0) o.style.height = -height + "px";
	else o.rows = height;

	return o;
}

function getExpanirta(id, val, w, min_h, max_h, b_expand_while_typing, f_key, f_change, b_read_only, f_read_only_err0) {
	//todo: f_change should be an additional change func, if we want an auto-expand thing while typing...
	var f = getNewField_TA_O(id, val, -w, -min_h, f_key, f_change, b_read_only, f_read_only_err0);

	f.div = document.createElement("div");
	f.div.style.width = w + "px";
	//o.div.style.visibility = "hidden";
	f.div.style.position = "absolute";
	f.div.style.left = -9999;
	f.div.style.top = -9999;
	f.div.style.overflow = "auto";
	document.body.appendChild(f.div);
	f.max_h = max_h;
	f.min_h = min_h;

	f.Update = function() {
		this.div.innerHTML = GetReplaced(this.value, "\n", "<br>");
		var h = this.div.clientHeight;
		if (h < this.min_h) h = this.min_h;
		else if (h > this.max_h) h = this.max_h;
		this.style.height = h + "px";
	};


	//todo: this isn't so purty
	if (f.b_expand_while_typing = b_expand_while_typing) {//ieq
		f.Autoupdate = function(e) {
			this.Update();

			e = e ? e : window.event;
			return (e.keyCode != 13) ? true : false;
		};
		f.onkeypress = f.Autoupdate;
	}

	f.Insert = function(ins) {
		if (this.setSelectionRange){
			this.value = this.value.substring(0,this.selectionStart) + ins
				//+ this.value.substring(this.selectionStart,this.selectionEnd)
				+ this.value.substring(this.selectionEnd,this.value.length);
		} else if (document.selection && document.selection.createRange) {
			this.focus();
			var range = document.selection.createRange();
			range.text = ins + range.text;
		}
	};

	return f;
}

function getNewFieldDef_TA(name, value, width, height, //make width and/or height neg to imply style and pixels
		key_event_name, change_event_name, b_read_only, ro_err_evnt_name0) {
	if (!key_event_name || (key_event_name == "")) key_event_name = "defaultFieldKeyEvent_TA";
	var s = getNewFieldDef(true, name, value, width, key_event_name, "ta", change_event_name, b_read_only, ro_err_evnt_name0);

	var st = "";
	var dt = "";

	if (width < 0) st = "width:" + -width + "px;";
	else dt = getNewTag("cols", width);

	if (height < 0) {
		st += "height:" + -height + "px;";
	} else {
		dt += getNewTag("rows", height);
	}

	if (st != "") dt += getNewTag("style", st);

	return "<textarea" + dt + s.substr(9);
}
//create an object for inserting text at the cursor for its text area...
function getNewInsertTAObj(id, val, cols, //make neg to imply pixels
		rows, f_key_event, f_change_event) {
	var o = getNewField_TA_O(id, val, cols, rows, f_key_event, f_change_event);

	o.Insert = function(ins) {
		var pos;
		if (this.setSelectionRange){
			pos = this.selectionStart + ins.length;
			this.value = this.value.substring(0,this.selectionStart) + ins
				//+ this.value.substring(this.selectionStart,this.selectionEnd)
				+ this.value.substring(this.selectionEnd,this.value.length);
			setCaretTo(this, pos);
		} else if (document.selection && document.selection.createRange) {

			var rans = "gf39U2j";
			this.focus();
			var range = document.selection.createRange();

			range.text = rans + ins + range.text;
			var i = this.value.indexOf(rans), ss1;
			this.value = (ss1 = this.value.substring(0, i)) + this.value.substring(i + rans.length);
			pos = (i + ins.length) - (((ss1 + ins).length - GetReplaced(ss1 + ins, cr, "").length) / 2);
			setTimeout("setCaretTo('" + this.id + "'," + pos + ");", 100);
		}
	}

	return o;

}
function setCaretTo(obj, pos) {
    obj = getObjFromPram(obj);
    if (!obj) return;
    if(obj.createTextRange) {
        /* Create a TextRange, set the internal pointer to
           a specified position and show the cursor at this
           position
        */
        obj.focus();
        var range = obj.createTextRange();
        range.move("character", pos);
        range.select();
    } else if(obj.selectionStart) {
        /* Gecko is a little bit shorter on that. Simply
           focus the element and set the selection to a
           specified position
        */
        obj.focus();
        obj.setSelectionRange(pos, pos);
    }
}
/*
//create an object for inserting text at the cursor for its text area...
function getNewInsertTAObj(id, val, cols, //make neg to imply pixels
		rows) {
	var o = new Object();
	o.id = id;
	o.o = getNewField_TA_O(id, val, cols, rows);

	o.val = val;
	o.insert = function(ins) {
		var el = objFromID(this.id);
		if (el.setSelectionRange){
				el.value = el.value.substring(0,el.selectionStart) + ins + el.value.substring(el.selectionStart,el.selectionEnd) + el.value.substring(el.selectionEnd,el.value.length);
			}
			else if (document.selection && document.selection.createRange) {
				el.focus();
				var range = document.selection.createRange();
				range.text = ins + range.text;
		}
	}
	o.getval = function() {
		return valueFromID_IF(o.id);
	}
	o.setHTMLVal = function(v) {

	}

	return o;

}*/

function embedPulseInLayer(layer_name, url, width, height, bgc, hardware, framerate) {
	var pes = getPulseEmbed(url, width, height, bgc, hardware, framerate);

	writeToDIV(layer_name, pes);

}

var gsPlayerID = "PulsePlayer";

function getPlayerObject()
{
	if (navigator.appName.indexOf("Netscape") != -1) return document.embeds[gsPlayerID];
	else if (document.all) return document.all[gsPlayerID];

	return PulsePlayer; // IE 3.0 doesn't support document.all
}

function getPulseEmbed (url, width, height, bgc, hardware, framerate) {

	var pes = "";


	var hw_pram_val = hardware ? 1 : 0; //for the pulse embed, it needs to be 0 or 1, "true"/"false" seem to do whacky things
						//ie, the first time it thinks its true, but then if we get the innerHTML
						//it returns as 0, so if we set based on that, it seems to then do it as false...

	pes += '<object' + getNewNameIDTag(gsPlayerID) + getNewTag("classid", "CLSID:A48D0309-8DA3-41aa-98E4-89194D471890");
	pes +=  getNewTag("width", width) + getNewTag("height", height);
	pes +=  getNewTag("codebase", gs_rootPathForCodebase + "PulsePlayer5.2AxWin.cab") + '>';

	pes += getNewPram("URL", url) + getNewPram("FrameRate", framerate) + getNewPram("hardware", hw_pram_val);
	pes += getNewPram("BGColor", bgc);
	pes += getNewPram("MAYSCRIPT", "true");

	pes += '<embed mayscript'  + getNewNameIDTag(gsPlayerID) + getNewTag("width", width) + getNewTag("height", height);
	//pes += '<embed'  + getNewNameIDTag(gsPlayerID) + getNewTag("width", width) + getNewTag("height", height);

	pes += getNewTag("src", url) + getNewTag("framerate", framerate) + getNewTag("hardware", hw_pram_val) + getNewTag("bgcolor", bgc);
	pes += getNewTag("type","application/x-pulse-player") + getNewTag("pluginspage", gs_rootPathForPluginspage);
	pes += ' MAYSCRIPT=true></embed></object>';

	return pes;
}

function filesInURLsAreSame(url1, url2) {
	var slashi_f, slashi_b;
	var fs1, fs2;
	slashi_f = url1.lastIndexOf('/');
	slashi_b = url1.lastIndexOf('\\');
	fs1 = Math.max(slashi_f, slashi_b) + 1;

	slashi_f = url2.lastIndexOf('/');
	slashi_b = url2.lastIndexOf('\\'); //92
	fs2 = Math.max(slashi_f, slashi_b) + 1;

	return url1.substr(fs1) == url2.substr(fs2);

}

function strEnds(s, s_end) {
	return s.substr(s.length - s_end.length) == s_end;
}

function lopOffLastChars(s, num_to_chop) {
	return s.substr(0, s.length - num_to_chop);
}
function getNamedFrame(frame_name) {
	// document.frames in IE?
	//return (brzr == 0) ? document.all[frame_name] : document.getElementById(frame_name);

	return window.frames ? window.frames[frame_name] : null;
}

function getNamedForm(form_name) {
	// document.frames in IE?
	return window.forms ? window.forms[form_name] : null;
}

function setNamedFormFldVal(form_name, fld_name, val) {
	document.forms[form_name].elements[fld_name].value = val;
}
function getNamedFormFldVal(form_name, fld_name) {
	return document.forms[form_name].elements[fld_name].value;
}
function getNamedFormFldValInWin(window, form_name, fld_name) {
	var f =  window.document.forms[form_name];
	
	if (f && (f = f.elements[fld_name])) {
		return f.value;
	}
	return "";
}
function getNamedFormMenu(form_name, menu_name) {
	var the_form = getNamedForm(form_name);
	return (the_form) ? the_form.elements[menu_name] : null; // this may not be correct;
}

////only really used by LinksWindow
function setFrameURL(f, url) {
	f.location.href = url;
}

function setNamedFrameURL(frame_name, url) {
	var the_frame = getNamedFrame(frame_name);
	if (the_frame) setFrameURL(the_frame, url); // should we even check for non-null... it's a bug if it is, btw
	else alert("bad frame: " + frame_name);
}
////

function whatbrowser() {
	//navigator.userAgent;
        if(document.layers){
            return 4;
        }
        if(document.all){
             return 0;
        }
        if(!document.all && document.getElementById){
             return 6;
        }
        return -1;
}

function isIE() {
	return (BrowserDetect.browser == "Explorer");
}
function isIEVersion(i, b_exact) {
	if (BrowserDetect.browser == "Explorer") {
		var vers = BrowserDetect.version;;
		if (navigator.userAgent.indexOf("Trident") > -1) {
			if (navigator.userAgent.indexOf("Trident/4") > -1) vers = 8;
			else if (navigator.userAgent.indexOf("Trident/5") > -1) vers = 9;
			else if (navigator.userAgent.indexOf("Trident/6") > -1) vers = 10;
			else if (navigator.userAgent.indexOf("Trident/7") > -1) vers = 11;
		}
		return (b_exact ? (vers == i) : (vers >= i));
	}
	return false;
}
function isIE7() {
	return isIEVersion(7, true);
}
function isIE8() {
	return isIEVersion(8, true);
}

function iswin() {
	return BrowserDetect.OS == "Windows";
}

function ismac() {
	return BrowserDetect.OS == "Mac";
}

function issafari() {
	return BrowserDetect.browser == "Safari";
}
function ischrome() {
	return BrowserDetect.browser == "Chrome";
}

function ismoz() {
	//!ie && navigator.product == "Gecko"
	return document.getElementById&&!document.all;
}

function getFirefoxVersion() {
	var ua = window.navigator.userAgent.toLowerCase();
	var i;
	if ((i = ua.indexOf("firefox/")) > -1) {
		ua = ua.substring(i + 8);
		if ((i = ua.indexOf(" ")) > -1) {
			ua = ua.substring(0, i);
		}
		return ua.split(".");
	}
	return null;
}

function getInnerDims() {
	var w = 100, h = 100;
	if (typeof(window.innerWidth) == 'number') {
		w = window.innerWidth;
		h = window.innerHeight;
	} else if (document.body && document.body.clientHeight) {
		w = document.body.clientWidth;
		h = document.body.clientHeight;
	} else {
		w = document.width;
		h = document.height;
	}

	return {w : w, h : h};
}

function getScrollXY() {
	var x = 0, y = 0;
	if (typeof(window.pageYOffset) == 'number') {
		x = window.pageXOffset;
		y = window.pageYOffset;
	} else if (document.body) {
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	} else if (document.documentElement) { //ie6 compliant mode
		x = document.documentElement.scrollTop;
		y = document.documentElement.scrollLeft;
	}
	return {x : x, y : y};
}
function getMyDocDims(b_ignore_potential_scroll) {
	var size_hldr = new Object();

	if (document.body && document.body.clientHeight) { //seems to include the (possible) scrollbar
	//NOTE that if you call this when the window is first opened, and there happens to be a scroll bar
	//there, it will wind up giving you a smaller size than necessary!
		size_hldr.w = document.body.clientWidth; //or body.offsetWidth, which is wider
		size_hldr.h = document.body.clientHeight;
	} else {
		size_hldr.w = document.width;
		size_hldr.h = document.height;
	}
	//document.documentElement.width ?


	if (!b_ignore_potential_scroll) {
		//size_hldr.w -= 25;
		size_hldr.h -= 25;//10;//20;//25;
	}

	return size_hldr;
}

function getMyDocDimsIf(b_ignore_potential_scroll) {
	var size_hldr = new Object();

	if (document.body && document.body.clientHeight) { //seems to include the (possible) scrollbar
	//NOTE that if you call this when the window is first opened, and there happens to be a scroll bar
	//there, it will wind up giving you a smaller size than necessary!
		size_hldr.w = document.body.clientWidth; //or body.offsetWidth, which is wider
		size_hldr.h = document.body.clientHeight;
	} else if (document.width && document.height) {
		size_hldr.w = document.width;
		size_hldr.h = document.height;
	} else { //it's possible that when doc first opens, these aren't ready yet!
		return null;
	}
	//document.documentElement.width ?


	if (!b_ignore_potential_scroll) {
		//size_hldr.w -= 25;
		size_hldr.h -= 25;
	}
	//writeToConsole(size_hldr.w + ":" + size_hldr.h);
	//debugger;
	return size_hldr;
}

function objFromID(id) {
	if (b_gebid) {
		return document.getElementById(id);
	} else if (document.all) {
		return document.all[id];
	}

	return null;
}

function objFromWinAndID(w, id) {
	if (b_gebid) {
		return w.document.getElementById(id);
	} else if (document.all) {
		return w.document.all[id];
	}

	return null;
}

function objFromIDOrEmbedIfMOZ(id, embed_id0) {
	if (document.embeds) {
		if (embed_id0) {
			if (document.embeds[embed_id0]) return document.embeds[embed_id0];
		} else if (document.embeds[id]) return document.embeds[id];
	}
	return objFromID(id);

	//return !ismoz() ? objFromID(id) : document.embeds[id];
}

function getTableSubObj(tbl0, oid, b_ditch_table_if_not_found) {
	if (tbl0) {
		if (tbl0 = objFromID(tbl0)) {
			var o;
			return (tbl0.all && (o = tbl0.all[oid]) && (o.id == oid))
				? o : getDeepChildNodeWithID(tbl0, oid);
		} else if (b_ditch_table_if_not_found) {
			return objFromID(oid);
		}

	} else {
		return objFromID(oid);
	}
	return null;
}


function getDeepChildNodeWithID(o, id) {
	var one_o;

	if (o.childNodes.length) {
		for (var i = 0; i < o.childNodes.length; i++) {
			if (o.childNodes[i].childNodes.length) {
				if (one_o = getDeepChildNodeWithID(o.childNodes[i], id)) return one_o;
			} else if (o.childNodes[i].id == id) {
				return o.childNodes[i];
			}
		}
	}
	return o.id == id ? o : null;
}

//unused/tested may be able to make more optimal? currently calls func to compare child.id
function getObjOrDeepChildNodeWithID(o, id) {
	var one_o;

	if (o.id == id) return o;
	else if (o.childNodes.length) {
		for (var i = 0; i < o.childNodes.length; i++) {
			if (one_o = getObjOrDeepChildNodeWithID(o.childNodes[i], id)) return one_o;
		}
	}
	return null;
}
function valueFromID(id) {
	return objFromID(id).value
}

function innerHTMLFromID(id, v2s) {
	var o = objFromID(id);

	if (!o) return "";

	if (innerHTMLFromID.arguments.length > 1) o.innerHTML = v2s;

	return o.innerHTML;
}
function altTitleFromID(id, v) {

}

function safeValueFromID(id) {
	var v = objFromID(id).value;

	return (v != "") ? ConvertStringToXMLSafe(v) : "";
}

function valueFromID_IF(id) {
	var o = objFromID(id);
	return o ? o.value : "";
}

function valueFromID_IF_NIN(id) {
	var o = objFromID(id);
	return o && (o.value != "") ? o.value : null;
}

function valueFromID_CB(cbid) {
	return objFromID(cbid).checked;
}

function getNewTagFromIDIf(tname, id) {
	var v = valueFromID_IF_NIN(id);

	if (v) {
		return getNewTag(tname, v);
	}
	return "";
}
function setIDObjectValue(id, v) {
	var o;
	if (o = objFromID(id)) {
		o.value = v;
	}
}
function setValueFromID(id, v) {//no CB!
	setIDObjectValue(id, v);
}

function setIDObjectValue_CB(cbid, chkd) {
	var o;
	if (o = objFromID(cbid)) {
		o.checked = chkd;
	}
}

function toggleCBValue(cbid) {
	var o;
	if (o = ((typeof(cbid) == "object") ? cbid : objFromID(cbid))) { //assumes it is indeed a cb
		return o.checked = !o.checked;
	}
	return false;//good enough
}

function setVisFromObjID(obj_id, vis) {
	var obj = objFromID(obj_id);

	if (obj && obj.style) {
		obj.style.visibility = vis ? "visible" : "hidden";
	}
}
function setObjVis(obj_id_or_obj, vis) {
	if (typeof(obj_id_or_obj) != "object") obj_id_or_obj = objFromID(obj_id_or_obj);
	obj_id_or_obj.style.visibility = vis ? "visible" : "hidden";
}

function writeToDIV(id, str) {
	writeToDIV_IF(id, str);
}

function getNamedLayer(id) {
	if (brzr != 4) return objFromID(id);
	else if (document.layers) { //ns 4...
		return document.layers[id];
	}
	return null;
}

function layerFromID(id) {
	return getNamedLayer(id);
}

function layerFromPram(p) {
	return (typeof(p) == "string") ? layerFromID(p) : p;
}

function writeToDIV_IF(id, str) {
	var l;
	if (brzr != 4) {
		if (l = objFromID(id)) {
			l.innerHTML = str;
		}
	} else if (document.layers && (l = document.layers[id])) {
		l.document.open();
		l.document.write(str);
		l.document.open();
	}
}

function focusObjFromID(id) {
	var o = objFromID(id);
	if (o) {
		o.focus();
	}
}
//because mozilla doesn't do outerHTML
function setOuterHTMLForObj(o, shtml) {
	if (o.outerHTML) o.outerHTML = shtml;
	else {
		var range = o.ownerDocument.createRange();

		range.setStartBefore(o);

		var new_frag = range.createContextualFragment(shtml);

		o.parentNode.replaceChild(new_frag, o);
	}
}

function getOuterHTML(o) {
	if (o.outerHTML) return o.outerHTML;
	else { //this will be incorrect if the parent has >1 child!
		var pe = getAParentElement(o);
		if (pe) {
			return pe.innerHTML;
		}
	}
	return "";
}

function setOuterHTMLForLayerID(lid, hs) {
	var l = objFromID(lid);

	if (l) {
		setOuterHTMLForObj(l, hs);
	}
}

var gs_MS_OPTION_OPEN = "<OPTION",
	gs_MS_OPTION_CLOSE = "</OPTION>",
	gs_MS_SELECT_OPEN = "<SELECT",
	gs_MS_SELECT_CLOSE = "</SELECT>";

if (go_moz) {
	gs_MS_OPTION_OPEN = gs_MS_OPTION_OPEN.toLowerCase();
	gs_MS_OPTION_CLOSE = gs_MS_OPTION_CLOSE.toLowerCase();
	gs_MS_SELECT_OPEN = gs_MS_SELECT_OPEN.toLowerCase();
	gs_MS_SELECT_CLOSE = gs_MS_SELECT_CLOSE.toLowerCase();
}
function setMenuObjOptionsFromOuterHTML(mo, oh) {
	if (mo) {
		if (!go_moz) {
			mo.outerHTML = oh;
		} else {
			var ih = oh.substring(oh.indexOf(gs_MS_OPTION_OPEN), oh.indexOf(gs_MS_SELECT_CLOSE)); //lower case in moz

			mo.innerHTML = ih;
		}
	} //else debugger ?
}

function getTableNameForLayer(ln) {
	return ln + "_tbl";
}

function wrapAndUpdate(layer_name, new_html, width, no_table) {


	var theHTML = "";

	if (no_table) {
		theHTML += new_html;
	} else if (new_html != "") {
		theHTML += "<table width="

		if (isUndefined(width)) {
			theHTML += 0;//200;
			alert("no table width!");
		} else {
			theHTML += width;
		}
		//mod getTableNameForLayer if ever changing this _tbl name
		theHTML += getNewNameIDTag(layer_name + "_tbl") + " border=0 cellpadding=0 cellspacing=0><TBODY><tr><td>";
		theHTML += new_html;
		theHTML += "</td></tr></TBODY></table>";
	} else {
		theHTML = "";
	}
	writeToDIV(layer_name, theHTML);
}

function setLayerDims(layer_name, w, h) {
	var l = getNamedLayer(layer_name);

	if (l) {
		if (w > 0) l.style.width = w + "px";
		if (h > 0) l.style.height = h + "px";
	}
}

function getObjOffsetLeftInPage(obj) {
	var x = obj.offsetLeft
	while (obj = obj.offsetParent) x += obj.offsetLeft;
	return x;
}
function getObjOffsetsInPage(obj) {
	var x = (obj = getObjFromPram(obj)).offsetLeft, y = obj.offsetTop;

	while (obj = obj.offsetParent) {
		x += obj.offsetLeft;
		y += obj.offsetTop;
	}
	return {x : x, y : y};
}

function getObjOffsetBottomInPage(l_or_id) {
	var obj = getObjFromPram(l_or_id);
	var y = obj.offsetTop + obj.offsetHeight;

	while (obj = obj.offsetParent) y += obj.offsetTop;

	return y;
}

function getWrapInTable(new_html, width) {


	var theHTML = "";


	theHTML += "<table width="

	if (isUndefined(width)) {
		theHTML += 200;
		alert("no table width!");
	} else theHTML += width;
	theHTML += " border=0 cellpadding=0 cellspacing=0><tr><td>";
	theHTML += new_html;
		theHTML += "</td></tr></table>";

	return theHTML;

}

function getTableHTML_START(width0, table_name0) {
	return getTableHTML_START_OPEN(width0, table_name0) + ">";
}

function getTableHTML_START_OPEN(width0, table_name0) {
	var theHTML = "";


	theHTML += "<table width="

	if (width0 > 0) {
		theHTML += width0;
	} else {
		theHTML = "<table ";
	}

	if (table_name0 && (table_name0 != "")) theHTML += getNewNameIDTag(table_name0);

	theHTML += " border=0 cellpadding=0 cellspacing=0";


	return theHTML;
}

/*
function getTableHTML_START(width, table_name0) {
	var theHTML = "";


	theHTML += "<table width="

	if (isUndefined(width)) {
		theHTML += 200;
		alert("no table width!");
	} else if (width > 0) {
		theHTML += width;
	} else {
		theHTML = "<table ";
	}

	if (table_name0 && (table_name0 != "")) theHTML += getNewNameIDTag(table_name0);

	theHTML += " border=0 cellpadding=0 cellspacing=0>";


	return theHTML;
}
*/

function getTableHTML_START_BCCBgBc(width, table_name0, border, cellpadding, cellspacing, Bg0, Bc0) {
	var theHTML = "";


	theHTML += "<table width="

	if (isUndefined(width)) {
		theHTML += 200;
		alert("no table width!");
	} else theHTML += width;

	if (table_name0 && (table_name0 != "")) theHTML += getNewNameIDTag(table_name0);

	if (Bg0) {
		theHTML += " bgcolor=" + Bg0;
	}
	if (Bc0) {
		theHTML += " borderColor=" + Bc0;
	}
	theHTML += " border=" + border
		+ " cellpadding=" + cellpadding
		+ " cellspacing=" + cellspacing + ">";


	return theHTML;
}

function getTableHTML_START_WHN_BCCBgBc(width, height, table_name0, border, cellpadding, cellspacing, Bg0, Bc0) {
	var theHTML = "";


	theHTML += "<table width="

	if (isUndefined(width)) {
		theHTML += 200;
		alert("no table width!");
	} else theHTML += width;

	theHTML += getNewTag("height", height);

	if (table_name0 && (table_name0 != "")) theHTML += getNewNameIDTag(table_name0);

	if (Bg0) {
		theHTML += " bgcolor=" + Bg0;
	}
	if (Bc0) {
		theHTML += " borderColor=" + Bc0;
	}
	theHTML += " border=" + border
		+ " cellpadding=" + cellpadding
		+ " cellspacing=" + cellspacing + ">";


	return theHTML;
}

function getTableHTML_TRTD(the_html) {
	return "<tr><td>" + the_html + "</td></tr>";
}

function getTableHTML_ROW() {
	var a = getTableHTML_ROW.arguments;
	var s = "<tr>";
	for (var i = 0; i < a.length; i++) {
		if (a[i] != null) s += "<td>" + a[i] + "</td>";
	}
	return s + "</tr>";
}

function getTableHTML_ROW_SINGLE(v, colspan) {
	return "<tr><td" + (colspan ? " colspan=" + colspan : "") + ">" + v + "</td></tr>";
}

function getTableHTML_TR(the_html) {
	return "<tr>" + the_html + "</tr>";
}

function getTableHTML_END() {
	return "</table>";
}

function getTableSpacerHTML(w) {
	return "<td width=" + w + "></td>";
}

function wrapAllInCells() {
	var a=wrapAllInCells.arguments;
	var i, l = a.length;
	var s = "";


	for (i = 0; i < l; i++) {
		s += "<td>" + a[i] + "</td>";
	}

	return s;
}

function wrapAllInCellsAndRow() {
	var a=wrapAllInCellsAndRow.arguments;
	var i, l = a.length;
	var s = "";


	for (i = 0; i < l; i++) {
		s += "<td>" + a[i] + "</td>";
	}

	return "<tr>" + s + "</tr>";
}

function getNewFilledTable(s_header_prams, items_per_line) {
	var s = "<table " + (s_header_prams ? s_header_prams : "cellpadding=0 cellspacing=0 padding=0") + "/>";
	var a = getNewFilledTable.arguments;
	var len = a.length;

	if ((len -2 )% items_per_line) {
		Debugger();

	} else {
		for (var i = 2; i < len; i += items_per_line) {
			s += "<tr>";
			for (var ii = 0; ii < items_per_line; ii++) {
				s += "<td>" + a[i + ii] + "</td>";
			}
			s += "</tr>";
		}
	}

	return s + "</table>";
}

function getBRRows() {
	var a = getBRRows.arguments;
	var len = a.length;
	var s = "", os;
	i
	for (var i = 0; i < len; i++) {
		if (os = a[i]) {
			if (s != "") s += br + os;
			else s = os;
		}
	}
	return s;
}

/* meuns functions

*/
var menuWidth = 168;

var emptyMenuItemIndex = 0;
var emptyMenuItemName = "none";

function AfterEventFocus(which_e) {

}

function ObjFromEvent(the_event) {
	return brzr ? the_event.target : the_event.srcElement; // target for netscape, srcElement for IE
}

function DoCmdFromMenu_DELAYED(menu_item, item_val, fid0) {
	if (fid0) setTimeout('DoCmdFromMenu("' + menu_item + '","' + item_val + '","' + fid0 + '")', 1);
	else setTimeout('DoCmdFromMenu("' + menu_item + '","' + item_val + '")', 1);
}
function getMenuCmdCmd(menu_name, item_val) {
	return "menuCmd" + getNewTag("menuID", menu_name) + getNewTag("selID", item_val);
}
function DoCmdFromMenu(menu_name, item_val, fid0) {
	var cmd = "menuCmd" + getNewTag("menuID", menu_name) + getNewTag("selID", item_val);

	//var cmd = 'DoCmd("menuCmd menuID=' + menu_name + ' selID=' + item_val + '")';

	DoCmd(cmd);

	if (!fid0) {
		AfterEventFocus("menu", menu_name, item_val);
		if (BrowserDetect.OS == "Mac") clearActualFocus(true);
	} else eval(fid0 + "_afterEventFocus('menu','" + menu_name + "','" + item_val + "');");

}

function ButtonCmd(button_name) {

}


function KeyCodeFromEventIfSend(the_event) {
	var kc;

	if (go_focusedFld) return 0;

	var obj_name = ObjFromEvent(the_event).id;

	if (ismoz() && obj_name) {
		if (obj_name.indexOf("Frame") == -1) return 0;
	}

	if (window.event) kc = event.keyCode;
	else kc = the_event.which ? the_event.which : ((the_event.keyCode == 27) ? 27 : 0);

	//var kc = (window.event)?event.keyCode:the_event.which; //keyCode is for special keys in ff

	return (kc > 31) ? kc : (kc != 27 ? 0 : kc);
}

function getCommaDelimedCmd() {
	var a=getCommaDelimedCmd.arguments;
	var i, l;
	var cmd = a[0] + "(";

	if ((l = a.length) > 1) {
		cmd += "'" + a[1] + "'";
		if (l > 2) {
			for (i = 2; i < l; i++) {
				cmd += ",'" + a[i] + "'";
			}
		}
	}
	cmd += ")";
	return cmd;
}

function doMultiTaggedCmd() {

	var a=doMultiTaggedCmd.arguments;
	var i, l;
	var s = a[0];

	l = a.length;

	for (i = 1; i < l; i+= 2) {
		s += getNewTag(a[i], a[i+1]);
	}

	DoCmd(s);
}

var vs_delayedCmd = "";

function DoDelayedOpenerCmd() {
	opener.eval(vs_delayedCmd);
	vs_delayedCmd = "";
}

function canAccessOpener() {
	if (opener) {
		try {
			opener.document && !isUndefined(opener.sizeType);
		}
		catch (er) {
			return false;
		}
		return true;
	}
	return false;
}

function DoOpenerEval() { // cmd_name, p1, p2,.... pn
	if (hasGoodOpener()) {
		var a=DoOpenerEval.arguments;
		var i, l;
		var cmd = a[0] + "(";

		if ((l = a.length) > 1) {
			cmd += '"' + a[1] + '"';
			if (l > 2) {
				for (i = 2; i < l; i++) {
					cmd += ',"' + a[i] + '"';
				}
			}
		}
		cmd += ")";
		try {
			opener.eval(cmd);
			//vs_delayedCmd = cmd;
			//setTimeout("DoDelayedOpenerCmd()", 2);
		}
		catch(er) {
			Debugger();
		}
		return true;
	}
	return false;
}

//don't call this if gb_frames is false, instead just call the frame's function directly
function DoFrameObjEval() { // cmd_name, p1, p2,.... pn
	var a=DoFrameObjEval.arguments;
	var i, l;
	var cmd = a[1] + "(";

	if ((l = a.length) > 2) {
		cmd += '"' + a[2] + '"';
		if (l > 3) {
			for (i = 3; i < l; i++) {
				cmd += ',"' + a[i] + '"';
			}
		}
	}
	cmd += ")";
	a[0].doEval(cmd);
}

function DoTimeoutCmd() {
	var a=DoTimeoutCmd.arguments;
	var i, l;
	var cmd = a[1] + "(";

	if ((l = a.length) > 2) {
		cmd += '"' + a[2] + '"';
		if (l > 3) {
			for (i = 3; i < l; i++) {
				cmd += ',"' + a[i] + '"';
			}
		}
	}
	cmd += ")";
	return setTimeout(cmd, a[0]);
}

function DoThisOrOpenerEval_SINGLE_QUOTES() {
	var a=DoThisOrOpenerEval_SINGLE_QUOTES.arguments;
	var i, l;
	var cmd = a[0] + "(";

	if ((l = a.length) > 1) {
		cmd += "'" + a[1] + "'";
		if (l > 2) {
			for (i = 2; i < l; i++) {
				cmd += ",'" + a[i] + "'";
			}
		}
	}
	cmd += ")";

	if (opener) opener.eval(cmd);
	else eval(cmd);

}



function DoDynamicMenuCmd(prams, the_id) {
	DynamicMenuCmd(prams, the_id);
}

function pulseMenuSelectedOverride(menu_name, val, fid0) {
	return false;
}

function pulseMenuSelected(menu_name, val, fid0) {
	if (!pulseMenuSelectedOverride(menu_name, val, fid0)) {
		DoCmdFromMenu_DELAYED(menu_name, val, fid0);
	}
}

function DoMultiTaggedEditCmdDoCmd() {

	var a=DoMultiTaggedEditCmdDoCmd.arguments;
	var l;
	var cmd = 'EditInfoUpdated type="editCmd" editCmd="' + a[0] + '"';

	if ((l = a.length) > 1) {
		var i = 1;
		do {
			cmd += getNewTag(a[i++], a[i++]);
		} while (i < l);

	}
	DoCmd_U(cmd);
}

function DoMultiTaggedDoCmd() {
	var a=DoMultiTaggedDoCmd.arguments;
	var l;
	var cmd = a[0];

	if ((l = a.length) > 1) {
		var i = 1;
		do {
			cmd += getNewTag(a[i++], a[i++]);
		} while (i < l);

	}
	DoCmd_U(cmd);
}


function DoCmd_U(cmd_str) {
	DoCmd(unescape(cmd_str));
}

function DoUnescCmd(cmd_str) {
	var cmd_str = unescape(cmd_str);

	DoCmd(cmd_str);
}

function DoCmdDelayed_EU(cmd_str, d) {
	if (!d) d = 1;
	setTimeout("DoCmd_U('" + escape(cmd_str) + "')", d);
}

function DoCmdDelayed(cmd_str, d) {
	if (!d) d = 1;
	setTimeout("DoCmd('" + cmd_str + "')", d);
}


function OpenerDoCmd(cmd_str) {
	try {
		opener.eval("DoCmd('" + cmd_str + "');");
	}
	catch(e) {
		return;
	}
}

function ThisOrOpenerDoCmd(cmd_str) {
	if (opener) OpenerDoCmd(cmd_str);
	else DoCmd(cmd_str);
}

function DoCmdIfPlayer(cmdline)
{
	if (navigator.appName.indexOf("Netscape") != -1) {
		if (document.embeds["PulsePlayer"]) {
			document.embeds["PulsePlayer"].Do(cmdline);
			return true;
		}
	} else if (document.all) {
		if (document.all["PulsePlayer"]) {
			document.all["PulsePlayer"].Do(cmdline);
			return true;
		}
	} else if (PulsePlayer) {
		PulsePlayer.Do(cmdline); // IE 3.0 doesn't support document.all
		return true;
	}
	//alert("Player not ready!");
	return false;
}

function GetReplacedProperCtrl(s) {
	return (gs_ctrlKeyLabel == "Ctrl") ? s : GetReplaced(s, "Ctrl", gs_ctrlKeyLabel);
}
var gto_ignoreNextClick = null;

function startIgnoreNextClick() {
	if (gto_ignoreNextClick) clearTimeout(gto_ignoreNextClick);
	gto_ignoreNextClick = setTimeout("dummyFunc()", 1);
}
function dummyFunc() {

}

function SendMouseUp() {
	if (crntMnu) {
		if (!miv) closeallmenus(); //else passively pass it along to the menu mouseup
		return;
	}
	if (gb_sendMouseUps) {
		if (!gto_ignoreNextClick) DoCmdIfPlayer('pageevent type=mouseUp');
		else {
			clearTimeout(gto_ignoreNextClick);
			gto_ignoreNextClick = null;
		}
	}
}

function SendDblClick(event) {
	if (gb_sendMouseUps) DoCmdIfPlayer('dblClick');
}


//override
function mozDNDmouseUp() {
	return false;
}


function getSelectedMenuItemDisplayFromMO(mo) {
	return (mo) ? mo.options[mo.selectedIndex].innerHTML : "";
}

function getSelectedMenuItemDisplayFromMID(menuID) {
	return getSelectedMenuItemDisplayFromMO(objFromID(menuID));
}

function getSelectedMenuItemFromMenuObj(menu_obj) {
	if (menu_obj) {
		return menu_obj.options[menu_obj.selectedIndex].value;
	}
	return "";
}

function getSelectedMenuItemFromID(menuID) {
	return getSelectedMenuItemFromMenuObj(objFromID(menuID));
}

function getOptionObjectFromMenuObjAndID(mo, id) {
	var op = mo.options;
	for (var i = 0; i < op.length; i++) {
		if (op[i].value == id) return op[i];
	}
	return null;
}
function getLabelFontElem () {
	return "";
	if (!brzr && 0) return getNewTag("STYLE", "font-family:" + labelFontFamily + ";" + "font-size:" + labelFontSize_IE + "pt;");
	else return '<FONT' + getNewTag("FACE", labelFontFamily) + getNewTag("SIZE", labelFontSize_NS) + '>';

}

function getLabelFontElem2 () {
	return "";
	if (!brzr) return '<FONT' + getNewTag("STYLE", "font-size:" + labelFontSize_IE + "pt;") + '>';
	else return '<FONT' + getNewTag("FACE", labelFontFamily) + getNewTag("SIZE", labelFontSize_NS) + '>';

}
var gs_changeEvent = "cte(event);";
var gi_changeEventLen = gs_changeEvent.length;

function cte(e) {
	go_lastEvent = e;
}

function dfltMenuKeyPressFunc(e, mo) {
	writeToConsole(e.keyVal);
	return true;
}
// http://www.netmechanic.com/news/vol3/css_no3.htm for setting font sizes
function getNewMenuText(name, changeFunc, label, width, vtarray, selID, menu_font, menu_font_size_ie, menu_font_size_ns) { // no selID means top will be selected
	var ms = "";
	var ocs = "";
	var b_do_fonts = !gb_useStyles && (menu_font && (menu_font != "")) && menu_font_size_ie && menu_font_size_ns;
	if (label) ms += label;

	if (b_do_fonts) {
		ms += '<FONT' + getNewTag("FACE", menu_font) + getNewTag("SIZE", menu_font_size_ns) + '>';
	}

	ms += gs_MS_SELECT_OPEN;

	if (b_do_fonts) {
		ms += getNewTag("STYLE", "font-family:" + menu_font + ";" + "font-size:" + menu_font_size_ie + "pt;");
	}


	ms += getNewNameIDTag(name);


	if (changeFunc && (changeFunc != "")) {
		ocs = changeFunc + '(this, this.options[this.selectedIndex].value);';
	} else {
		ocs = "pulseMenuSelected('" + name + "', this.options[this.selectedIndex].value);";
	}

	ms += getNewTag("onChange", gs_changeEvent + ocs);

	//ms += getNewTag("onKeyPress", "return " + "dfltMenuKeyPressFunc" + '(event, this);'); // + ';return false;' ?

	ms += getFocusBlurTags();

	//ms += 'menuSelected("' + plsCmd +',' + name + '", this.options[this.selectedIndex].value)"';

	//ms += "menuSelected('" + plsCmd + "','" + name + "', this.options[this.selectedIndex].value)";

	try {
		ms += getNewTag("class", gs_className_FORM_MENU);
	}
	catch(er) {}

	ms += ' style="height:' + 22 + (width ? ('px; width:' + width + 'px;"') : '"')  + '>';

	if (selID) {
		for (var i = 0; i < vtarray.v.length; i++) {
			ms += (vtarray.v[i] != selID)
				? getOptionStr(vtarray.v[i], vtarray.t[i])
				: getOptionStrSel(vtarray.v[i], vtarray.t[i]);
		}
	} else {
		for (var i = 0; i < vtarray.v.length; i++) {
			ms += getOptionStr(vtarray.v[i], vtarray.t[i]);
		}
	}
	ms += gs_MS_SELECT_CLOSE;

	return ms;

}

function getWidthHeightStyle(w, h, b_inc_style) {
	var s = "width:" + w + "px;height:" + h + ";";

	return b_inc_style ? 'style=' + s : s;
}
function getChangedValueFldHTML(hs, v) {
	var i = hs.toLowerCase().indexOf('</textarea>');

	if (i == -1) {
		return getReplacedTag(hs, "value", v);
	} else {
		return hs.substring(0, hs.indexOf(">") + 1) + v + hs.substring(i);
	}
}

function getChangedValueFldHTML_O(o) {
	return getChangedValueFldHTML(o.html, o.v);
}

function getChangedIDMenuHTML(hs, id) {
	hs = getReplacedTag(hs, "id", id);
	return getReplacedTag(hs, "name", id);
}

function getChangedSelectedMenuHTML(hs, ns) { //should work for options list (innerHTML) too...
	var s_end = " selected>", ns_end = ">";
	hs = GetReplaced_IFs(hs, 'selected="selected"', "", s_end, ns_end); //b/c of mozilla
	var vs = 'value="' + ns + '"',
		vs2 = 'value=' + ns;;

	return GetReplaced_IFs(hs, vs2 + ns_end, vs2 + s_end, vs + ns_end, vs + s_end);
}

function getChangedOnChangeMenuHTML_EP(hs, fs, ep, b_add_val_pram) {
	var i = hs.indexOf(gs_changeEvent);

	if (i > -1) i += gi_changeEventLen;
	else if ((i = hs.indexOf("onChange=")) > -1) i += 10;

	if (i > -1) {
		var rs;
		if (b_add_val_pram) {
			var func_str = fs + "(this.options[this.selectedIndex].value,'" + escape(ep) + "', this)";
			rs = hs.substring(0, i) + func_str + hs.substring(hs.indexOf('"', i + 2));
		} else {
			rs = hs.substring(0, i) + fs + "('" + escape(ep) + "');" + hs.substring(hs.indexOf('(', i + 2));
		}
		return rs;
	} else {
		//insert it somewhere....
		return hs;
	}
}
function getChangedOnChangeMenuHTML(hs, fs, b_add_val_pram) {

	var i = hs.indexOf(gs_changeEvent);

	if (i > -1) i += gi_changeEventLen;
	else if ((i = hs.indexOf("onChange=")) > -1) i += 10;

	if (i > -1) {
		var rs;
		if (b_add_val_pram) {
			var func_str = fs + "(this.options[this.selectedIndex].value, this)";
			rs = hs.substring(0, i) + func_str + hs.substring(hs.indexOf('"', i + 2));
		} else {
			rs = hs.substring(0, i) + fs + hs.substring(hs.indexOf('(', i + 2));
		}
		return rs;
	} else {
		//insert it somewhere....
		return hs;
	}
}

function getRemovedFirstItemMenuHTML(hs) {
	var i = hs.indexOf(gs_MS_OPTION_OPEN);
	if (i > -1) {
		var i2 = hs.indexOf(gs_MS_OPTION_CLOSE, i + 7);
		return hs.substring(0, i) + hs.substring(i2 + 9);
	}
	return hs;
}
//test b4 using
function isValueInMenuHTML(v, hs) {
	return hs.indexOf('value="' + v + '"') > -1;
}

function isItemTextInMenuHTML(v, hs) {
	return hs.indexOf('>' + v + gs_MS_OPTION_CLOSE) > -1;
}

//note: this hasn't really been completed... currently only tested for the b_keep_only_prefix == true, and the prefixeds ones being clumped at the end
function getRemovedPrefixedItemMenuHTML(hs, pfx, b_keep_only_prefix) {
	var pvs = gs_MS_OPTION_OPEN + ' value="';
	var pfxs = pvs + pfx;
	var es = gs_MS_OPTION_CLOSE;
	var ol = pfx.lentgh;
	var el = es.length;

	var i = 0, ip, io, ie = 0, iie = -1;
	var s;

	if ((i = hs.indexOf(pvs, i)) != -1) {
		s = hs.substring(0, i);
		ie = i;
	} else {
		return hs;
	}
	if (b_keep_only_prefix) {
		if ((ip = hs.indexOf(pfxs, i)) != -1) {
			while ((io = hs.indexOf(pvs, i)) != -1) {
				if ((ip = hs.indexOf(pfxs, i)) != io) { // the one at io isn't good
					i = hs.indexOf(es, ip) + el; //i is at the start of the next <option
					if (iie == -1) {
						iie = ip;
					} else {
						s += hs.substring(iie, i);
					}
				} else {
					i = hs.indexOf(es, ip) + el; //i is at the start of the next <option
				}
			}
		} else { //there aren't ANy matches
			iie = hs.indexOf(gs_MS_SELECT_CLOSE);
		}
		s += hs.substring(iie);
	}

	return s;
}

function prependEmptyMenuItemToMenuHTML(hs) {
	var vs = gs_MS_OPTION_OPEN + ' value="' + emptyMenuItemName + '"/>' + gs_MS_OPTION_CLOSE;
	var i;
	if (hs.indexOf(vs) == -1) {
		hs = hs.substring(0, (i = hs.indexOf(gs_MS_OPTION_OPEN + " "))) + vs + hs.substring(i);
	}

	return hs;
}
function getNewStyleStr() {
	var args = getNewStyleStr.arguments;
	if (args.length % 2) Debugger();
	var ss = "";
	for (var i = 0; i < args.length; i += 2) {
		ss += args[i] + ":" + args[i + 1] + ";";
	}
	return getNewTag("style", ss);
}
function getReplacedStyleVal(s, t, v) {
	var ts = t + ":";
	var i = s.indexOf("style=");
	if (i > -1) {
		i = s.indexOf(t, i + 1);
		if (i > -1) {
			return s.substring(0, i + ts.length) + v + s.substring(s.indexOf(";", i + ts.length));
		}
	}
	return s;
}
// find a tag in a string, and set its value to something else.... haven't tested this...
function getReplacedTag(s, t, v) {
	var ts = " " + t + '="';
	var end_char = '"';;
	var i = s.indexOf(ts);

	if (i == -1) {
		ts = " " + t + "='";
		i = s.indexOf(ts);
		if (i == -1) return s;
		else end_char = "'";
	}

	return s.substring(0, i + ts.length) + v + s.substring(s.indexOf(end_char, i + ts.length)); //takes into account attrib=""
}

//check to see if the version of JavaScript/JScript supports the "g" in RegExp
var gb_goodRegExp = ("abb".replace(RegExp("b", "g"),"a") == "aaa");
//7.5.9 moved this all to layers.js from fileIO.js and xml.js
function GetReplaced(src, search_str, repl_str) {
	if (gb_goodRegExp) {
		//todo: always just do the GetReplacedFSS? ... or can we make the RegExp not need the whiles, etc?
		if (search_str == "\\") {
			return src.replace(new RegExp("\\\\", "g"), repl_str);
		} else if (search_str.indexOf("\\") != -1) {


			var i = 0;

			while ((i = search_str.indexOf("\\", i)) > -1) {
				search_str = search_str.substring(0, i) + "\\" + search_str.substring(i);
				i += 2;
			}
		}
		if ((search_str.indexOf(")") != -1) || (search_str.indexOf("(") != -1)) {//this would create an invalid RegExp, or one that was an erroneous flag
			var i = 0;

			while ((i = search_str.indexOf("(", i)) > -1) {
				search_str = search_str.substring(0, i) + "\\" + search_str.substring(i);
				i += 2;
			}
			i = 0;
			while ((i = search_str.indexOf(")", i)) > -1) {
				search_str = search_str.substring(0, i) + "\\" + search_str.substring(i);
				i += 2;
			}
		}

		return src.replace(RegExp(search_str, "g"),repl_str);
	} else if ((src != "") && (src.indexOf(search_str) != -1)) {
		return GetReplacedFSS(src, search_str, repl_str);
		var c1 = src;
		var lps = "xxoo--ooxx";

		do {
			if (c1 == (src = src.replace(search_str, lps))) break;
			else c1 = src;
		} while (1);

		do {
			if (c1 == (src = src.replace(lps, repl_str))) break;
			else c1 = src;
		} while (1);


	}
	return src;
}

function GetReplacedFSS(src, search_str, repl_str) { //assume whacky regexp chars... so just manually do it...

	var i, ss = "";
	var sl = search_str.length;

	while ((i = src.indexOf(search_str)) > -1) {
		ss += src.substring(0, i) + repl_str;
		src = src.substring(i + sl);
	}
	ss += src;
	return ss;


}
//replace arg1 w/ arg2, if arg1 found, else 3 w/ 4, etc....
function GetReplaced_IFs(src) {
	var a = GetReplaced_IFs.arguments, l = a.length;

	for (var i = 1; i < l; i += 2) {
		if (src.indexOf(a[i]) > -1) return GetReplaced(src, a[i], a[i + 1]);
	}
	return src;
}
//replace arg1 w/ arg2, arg3 w/ arg4, etc...
function GetReplacedMulti(src, arg1) {//doesn't check for src being empty string or not, so check beforehand if you want optimize
	var i, a;

	if (typeof(arg1) == "object") {
		a = arg1;
		i = 0;
	} else {
		a = GetReplacedMulti.arguments;
		i = 1;
	}
	var l = a.length;

	for (i = i; i < l; i += 2) {
		src = GetReplaced(src, a[i], a[i + 1]);
	}
	return src;
}

function getDisplayTextForValueInMenuHTML(hs, v) {
	var vs = 'value="' + v + '"';
	var i = hs.indexOf(vs);

	if (i > -1) {
		return hs.substring(hs.indexOf(">", i + vs.length) + 1, hs.indexOf("<", i + vs.length));
	}
	return null;
}

function getValueForDisplayTextInMenuHTML(hs, dt) {

}

function isDisplayTextInMenuHTML(dt, hs) {
	return hs.indexOf(">" + dt + gs_MS_OPTION_CLOSE) != -1;
}

function getTaggedText(str, tag) {
	return "<" + tag + ">" + str + "</" + tag + ">";
}
function getColoredText(clr, t) {
	return "<FONT" + getNewTag("color",clr) + ">" + t + "</FONT>";
}
function getBoldedText(str) {
	return getTaggedText(str, "b");
}
function dragEnded() {

}

//override the rollOn rollOff thangs
function thumbRollOn(obj, id, ed) {

}
function thumbRollOff(obj, id, ed) {

}

function brokenUpDivTaggedID(id) {
	if (id.indexOf("div.") == 0) {
		var div_id = "";
		div_id = id.substring(4, id.indexOf(".", 5));
		id = id.substring(div_id.length + 5);

		var ro = new Object();
		ro.div_id = div_id;
		ro.id = id;
		return ro;
	}
	return null;
}
function hi(o) {
	alert(o);
}
function getImgStartWithFNF() {
	return '<img onerror="ifnf(this);"';
}
function getSpacerImg(src, w, h) {
	return "<img" + getNewTag("src", getImagesDir() + src) + getNewTag("width", w) + getNewTag("height", h) + "/>";
}

//override this.... basically set img path to image_not_found image....
function ifnf(imgo) {

}

// may need to make this browser specific, if we're even allowing this in NS....
function getNewDragImageHTML(the_id, div_id0, alt, src, w, h, drag_start_func_0, b_do_rolls, extra_data, mouseUpFunc_0, dcFunc_0) {

	if (gb_https && gb_forceImageHTTPSIf && (src.indexOf("http:") == 0)) {
		src = "https:" + src.substring(5);
	}
	if (gb_hideImageURLs) return getNewDragImageHTML_hideIU(the_id, div_id0, alt, src, w, h, drag_start_func_0, b_do_rolls, extra_data, mouseUpFunc_0, dcFunc_0);

	var tagged_id = div_id0 ? "div." + div_id0 + "." + the_id : the_id;
	var s = getImgStartWithFNF() + getNewNameIDTag(tagged_id);
	var dndf = (drag_start_func_0 && (drag_start_func_0 != "")) ? drag_start_func_0 : "dndStart";
	//var muf = (mouseUpFunc_0 && (mouseUpFunc_0 != "")) ? mouseUpFunc_0 + "(this, '" + the_id + "')" : null;
	var muf = (mouseUpFunc_0 && (mouseUpFunc_0 != "")) ? mouseUpFunc_0 : (div_id0 ? div_id0 + "_thmbC" : "thmbC");
	var dcf = (dcFunc_0 && (dcFunc_0 != "")) ? dcFunc_0 : "thmbDC";
	var rollonfunc = "thumbRollOn";
	var rollofffunc = "thumbRollOff";


	s += getNewTag("SRC", src);


	if (w) s += getNewTag("width", w);
	if (h) s += getNewTag("height", h)

	s += getNewTag("class", "wtcls");
	s += getNewTag("border", gi_dragImageBorder);
//	s += getNewTag("align", "center");

	if (alt != "") s += getAltTitleTag(alt);
	else s += getAltTitleTag(the_id);

	if (extra_data && (extra_data != "")) {
		dndf += "(event, this, '" + tagged_id + "', '" + escape(extra_data) + "')";
		if (b_do_rolls) {
			rollonfunc += "(this, '" + the_id + "', '" + escape(extra_data) + "')";
			rollofffunc += "(this, '" + the_id + "', '" + escape(extra_data) + "')";
		}
	} else {
		dndf += "(event, this, '" + tagged_id + "')";
		if (b_do_rolls) {
			rollonfunc += "(this, '" + the_id + "')";
			rollofffunc += "(this, '" + the_id + "')";
		}
	}


	s += getNewTag("ondragstart", dndf);

	if (ismoz()) {
		//s += getNewTag("onmousedown", dndf);
	}

	if (b_do_rolls) {
		s += getNewTag("onmouseover", rollonfunc);
		s += getNewTag("onmouseout", rollofffunc);
	}

	//s += getNewTag("onmousedown", "return rightCheck(event, this);");


	if (muf) {
		if (muf.indexOf(")") == -1) {
			if (extra_data && (extra_data != "")) {
				muf += "(this, '" + the_id + "', '" + escape(extra_data) + "')";
			} else {
				muf += "(this, '" + the_id + "')";
			}
		}
		s += getNewTag("onmouseup", muf);
	}

	if (dcf) {
		if (extra_data && (extra_data != "")) {
			dcf += "(this, '" + the_id + "', '" + escape(extra_data) + "')";
		} else {
			dcf += "(this, '" + the_id + "')";
		}
		s += getNewTag("onDblClick", dcf);
	}

	dndf = "dragEnded(this, '" + tagged_id + "')";

	s += getNewTag("ondragend", dndf);

	s += ">";

	return s;
}
var gooooo = 0;
// may need to make this browser specific, if we're even allowing this in NS....
function getNewDragImageHTML_hideIU(the_id, div_id0, alt, src, w, h, drag_start_func_0, b_do_rolls, extra_data, mouseUpFunc_0, dcFunc_0) {
	var tagged_id = div_id0 ? "div." + div_id0 + "." + the_id : the_id;
	var s = "<img" + getNewNameIDTag(tagged_id);
	var dndf = (drag_start_func_0 && (drag_start_func_0 != "")) ? drag_start_func_0 : "dndStart";
	//var muf = (mouseUpFunc_0 && (mouseUpFunc_0 != "")) ? mouseUpFunc_0 + "(this, '" + the_id + "')" : null;
	var muf = (mouseUpFunc_0 && (mouseUpFunc_0 != "")) ? mouseUpFunc_0 : (div_id0 ? div_id0 + "_thmbC" : "thmbC");
	var dcf = (dcFunc_0 && (dcFunc_0 != "")) ? dcFunc_0 : "thmbDC";
	var rollonfunc = "thumbRollOn";
	var rollofffunc = "thumbRollOff";

	var tpx = 0, lpx = 0;

	//<img src = "clear.gif" style="background-image: url(real.gif)" width="100" height="100">

	s += getNewTag("SRC", gs_imagesDir + "mylar.png");

	if (ismoz())  {
		tpx = -gi_dragImageBorder;
		lpx = 2 * (-gi_dragImageBorder);
		if (h) h--;
	}

	if (w) s += getNewTag("width", w);
	if (h) s += getNewTag("height", h);

	s += getNewTag("class", "wtcls");
	s += getNewTag("border", gi_dragImageBorder);
//	s += getNewTag("align", "center");

	if (alt != "") s += getAltTitleTag(alt);
	else s += getAltTitleTag(the_id);

	if (extra_data && (extra_data != "")) {
		dndf += "(event, this, '" + tagged_id + "', '" + escape(extra_data) + "')";
		if (b_do_rolls) {
			rollonfunc += "(this, '" + the_id + "', '" + escape(extra_data) + "')";
			rollofffunc += "(this, '" + the_id + "', '" + escape(extra_data) + "')";
		}
	} else {
		dndf += "(event, this, '" + tagged_id + "')";
		if (b_do_rolls) {
			rollonfunc += "(this, '" + the_id + "')";
			rollofffunc += "(this, '" + the_id + "')";
		}
	}


	s += getNewTag("ondragstart", dndf);

	//if (ismoz()) {
		//s += getNewTag("onmousedown", dndf);
	//}

	if (b_do_rolls) {
		s += getNewTag("onmouseover", rollonfunc);
		s += getNewTag("onmouseout", rollofffunc);
	}

	//s += getNewTag("onmousedown", "return rightCheck(event, this);");


	if (muf) {
		if (muf.indexOf(")") == -1) {
			if (extra_data && (extra_data != "")) {
				muf += "(this, '" + the_id + "', '" + escape(extra_data) + "')";
			} else {
				muf += "(this, '" + the_id + "')";
			}
		}
		s += getNewTag("onmouseup", muf);
	}

	if (dcf) {
		if (extra_data && (extra_data != "")) {
			dcf += "(this, '" + the_id + "', '" + escape(extra_data) + "')";
		} else {
			dcf += "(this, '" + the_id + "')";
		}
		s += getNewTag("onDblClick", dcf);
	}

	dndf = "dragEnded(this, '" + tagged_id + "')";

	s += getNewTag("ondragend", dndf);

	s += ">";

	var s2 = getImgStartWithFNF() + ' src="' + src + '"'

	if (w) s2 += getNewTag("width", w);
	if (h) s2 += getNewTag("height", h);
	s2 += getNewTag("border", gi_dragImageBorder);

	s2 += "/>";

	var st = "";
	var div = "";


	st = "style='position:relative;padding:0px;" + "left:" + lpx + "px;top:" + tpx + "px;" + "width:" + w + "px;" + "height:" + h + "px;" + "'";
	var st2 = "style='position:absolute;top:0px;left:0px;" + "width:" + "100%;" + "height:" + "100%;" + "'";

	div = "<div " + st + ">" + s2 + "<div " + st2 + ">" + s + "</div></div>";


	return div;
}
function rightCheck(event, obj) {
	//alert("ji");
	return false;
}
//override/////
function dndStart(e, obj, id, extra_data) {
	alert("dndStart:" + id + " :" + extra_data);
}

function thmbDC(obj, id, extra_data) {
	alert("thmbDC:" + id + " :" + extra_data);
}
/////

// label?
function getDynamicMenuHTML(xml_elems, the_vt, sel_id, menu_font, menu_font_size_ie, menu_font_size_ns) {
	return getDynamicMenuHTML_CF(xml_elems, the_vt, "", sel_id, menu_font, menu_font_size_ie, menu_font_size_ns);
}

function getDynamicMenuHTML_W(xml_elems, the_vt, sel_id, menu_font, menu_font_size_ie, menu_font_size_ns, menu_width) {
	var tw = menuWidth;
	var s = "";
	menuWidth = menu_width;

	s = getDynamicMenuHTML(xml_elems, the_vt, sel_id, menu_font, menu_font_size_ie, menu_font_size_ns);
	menuWidth = tw;
	return s;
}

function getDynamicMenuHTML_CF(xml_elems, the_vt, change_func, sel_id, menu_font, menu_font_size_ie, menu_font_size_ns, menu_width) {

	var mainItem = GetEventXMLChild(xml_elems, "menu");
	var menuName = GetXMLAttrib(mainItem, "name");
	var menuLabel = ""; //GetXMLAttrib(mainItem, "label") + "<br>";
	var numItems = GetXMLAttrib(mainItem, numItems);
	var vt = the_vt ? the_vt : getXMLMenuArray(xml_elems);

	if (!sel_id || (sel_id == "")) {
		sel_id = GetXMLAttrib(mainItem, "si");
	}
	var menuHTML = getNewMenuText(menuName, change_func, menuLabel, menuWidth, vt, sel_id, menu_font, menu_font_size_ie, menu_font_size_ns);
	//alert(menuText);

	return menuHTML;

}

//note: some versions of Windows (have seen in 2000) only support an older version of JavaScript/JScript
// as a result, they can neither support array.push, .pop, .splice, .shift, .unshift, nor the "g" in RegExp
// so we pass all array calls to these functions through here (and have an alterna version of GetReplaced

function getNewArraySplitWithoutFirst(s, split_val, b_add_back_split_val) {
		//NOTE: when calling this, and the split_val is a non-paired elem name, and you're passing
		//in the trailing space to avoid elem name ambiguity (ie, between "<shark" and "<sharks")
		//then make sure you set b_add_back_split_val to true,or else you won't be able to find
		//the first non-paired attrib with any of the GetXMLAttrib functions, which assume
		//all non-paired attribs are preceded by a space,ie <shark attrn="cheese"... would get
		//shortened to 'attrn="cheese"... and wouldn't be found, so you need to put it back to
		//<shark attrn="cheese"....
	var a = s.split(split_val);

	if (!b_add_back_split_val) {
		return getAShift(a);
	} else {
		var a = getAShift(a);
		if (a.length) {
			for (var i = 0; i < a.length; i++) {
				a[i] = split_val + a[i];
			}
		}
		return a;
	}
}


//actually returns the new array
function getAShift(a) {
	if (a.shift) {
		a.shift();
		return a;
	} else {
		var new_a = a.slice(1);
		return new_a;
	}
}

function getAShiftO(a) {
	return {v : a[0], a : getAShift(a) };
}
function getAPop(a) {
	if (a.pop) {
		a.pop();
		return a;
	} else {

		return a.slice(0, a.length - 1);
	}
}
function getASplice(a, si, num_elems) {
	if (a.splice) a.splice(si, num_elems);
	else {
		var b = a.slice(0, si);

		a = b.concat(a.slice(si + num_elems));
	}
	return a;
}

function addNewFirstArrayElem(a, v) {
	if (a.splice) {
		a.splice(0, 0, v);
		return a;
	} else {
		return (new Array(v)).concat(a);
	}
}

function apush(a, v) {
	if (a.push) a.push(v);
	else a[a.length] = v;
	return v;
}
function pushmult(a) {
	var aa = pushmult.arguments, l = aa.length;

	if (a.push) {
		for (var i = 1; i < l; i++) {
			a.push(aa[i]);
		}
	} else {
		for (var i = 1; i < l; i++) {
			a[a.length] = aa[i];
		}
	}
}

function addToVTArray(vt, v, t, s) {
	var a = addToVTArray.arguments;

	if (a.length <= 4) {
		apush(vt.v, v);
		apush(vt.t, t);
		apush(vt.s, s);
	} else {
		for (var i = 1; i < a.length; i += 2) {
			apush(vt.v, a[i]);
			apush(vt.t, a[i + 1]);
			apush(vt.s, null);
		}
	}
}

function addToVT2Array(vt, v, v2, t, s) {
	apush(vt.v, v);
	apush(vt.v2, v2);
	apush(vt.t, t);
	apush(vt.s, s);
}

/* need to do alterna splice if using this
function addToBeginningOfVTArray(vt, v, t, s) {
	if (vt.v.splice) {
		vt.v.splice(0, 0, v);
		vt.t.splice(0, 0, t);
		vt.s.splice(0, 0, s);
	} else {

	}
}
*/
function addCmdToVTArray(vt, cmd, v, t, s) {
	apush(vt.v, "'" + cmd + "','" + v + "'");
	apush(vt.t, t);
	apush(vt.s, s);
}

function getNewVTArray() {
	var vt = new Object();
	vt.v = new Array();
	vt.t = new Array();
	vt.s = new Array(); // for custom separators!
	return vt;
}

function getNewVT2Array() {
	var vt = new Object();
	vt.v = new Array();
	vt.v2 = new Array();
	vt.t = new Array();
	vt.s = new Array(); // for custom separators!
	return vt;
}

function getXMLMenuArray(elems, attrib_for_BOTH_id_and_fn) {

	var one_thing;
	var vt = getNewVTArray();
	var ma = getArrayFromXMLOfNamedElems(elems, "item");
	var last_i = ma.length - 1;

	addToVTArray(vt, emptyMenuItemName, "");


	if (attrib_for_BOTH_id_and_fn && (attrib_for_BOTH_id_and_fn != "")) {

		var id, fn;

		for (var ai = 0; ai <= last_i; ai++) {
			one_thing = ma[ai];

			id = fn = GetXMLAttrib(one_thing, attrib_for_BOTH_id_and_fn);

			addToVTArray(vt, id, fn);
		}
	} else {
		for (var ai = 0; ai <= last_i; ai++) {
			one_thing = ma[ai];

			addToVTArray(vt, GetXMLAttrib(one_thing, "id"), GetXMLAttrib(one_thing, "fn"));

		}
	}
	return vt;
}

function getLabledObjAsTableRowHTML(o) {
	return getTableHTML_ROW(o.label, o.getHTML());

}
function setFieldObjHTMLToItsVal(fo) {
	getChangedValueFldHTML_O
}

//note that although this returns an object, that object is not a field object, but, rather, one that contains html
function getNewFieldObj(id, key_event, v, width, label, pulse_id, b_dont_prepend_label, on_change_func) {

	return { v : v,
		id : id,
		label : label,
		pid : pulse_id ? pulse_id : null,
		html : (b_dont_prepend_label ? "" : label) + getNewFieldDef(true, id, v, width, key_event, null, on_change_func),
		getHTML : function () { return this.html = getChangedValueFldHTML(this.html, this.v); },
		getEntryValue : function() {return valueFromID(this.id);},
		setValFromEntry : function() {return this.v = this.getEntryValue();}
	};
}

function getNewMenuObj(id, pid, func_name, dflt_val, width0, label0, b_use_blank, b_index_for_val) { //follow w/ value pairs
	var mo = {id : id, v : dflt_val, w : width0, label : label0};

	var vt = getNewVTArray();
	var a = getNewMenuObj.arguments;
	var l = a.length;

	if (!b_index_for_val) {
		if (b_use_blank) {
			addToVTArray(vt, emptyMenuItemName, "");
		}

		if (l > 8) {
			for (var i = 8; i < l; i += 2) {
				addToVTArray(vt, a[i], a[i+1]);
			}
		}
	} else {
		var mi = 0;


		if (b_use_blank) {
			addToVTArray(vt, mi, "");
			mi++;
		}

		if (l > 8) {
			for (var i = 8; i < l; i++) {
				addToVTArray(vt, mi, a[i]);
				mi++;
			}
		}

	}

	mo.vt = vt;

	mo.html = getNewMenuText(id, func_name, "", width0, vt, dflt_val);
	mo.pid = pid; //pulse id

	mo.getHTML = function () { return this.html = getChangedSelectedMenuHTML(this.html, this.v); };
	return mo;

}
//assume we index with the numbers in order as passed
function getNewFilledVTArray_INDEXED() {
	var a=getNewFilledVTArray_INDEXED.arguments;
		var l;
		var vt;
		if ((l = a.length) > 0) { //ieq
			vt = getNewVTArray();

			for (var i = 0; i < l; i++) {
				addToVTArray(vt, i, a[i]);
			}

		} else {
			alert("calling getNewFilledVTArray_INDEXED w/ too few args!");
		}

	return vt;
}

function getNewFilledVTArray() {
	var a=getNewFilledVTArray.arguments;
	var l;
	var vt;
	if ((l = a.length) > 1) { //ieq
		vt = getNewVTArray();

		for (var i = 0; i < l; i += 2) {
			addToVTArray(vt, a[i], a[i + 1]);
		}

	} else {
		alert("calling getNewFilledVTArray w/ too few args!");
	}

	return vt;
}

function fillVTArray() { //first arg should be the vt, then the rest value/display pairs
	var a=fillVTArray.arguments;
	var l;
	if ((l = a.length) > 2) { //ieq
		var vt = a[0];

		for (var i = 1; i < l; i += 2) {
			addToVTArray(vt, a[i], a[i + 1]);
		}
	} else {
		alert("calling fillVTArray w/ too few args!");
	}
}

function getMenuArrayFromArray(a, b_same_for_both, b_add_empty) {

	var i;
	var vt = getNewVTArray();

	if (b_add_empty) addToVTArray(vt, emptyMenuItemName, "");

	if (b_same_for_both) {
		for (i = 0; i < a.length; i++) {
			addToVTArray(vt, a[i], a[i]);
		}
	} else {
		for (i = 0; i < a.length; i++) {
			addToVTArray(vt, a[i].id, a[i].fn);
		}
	}
	return vt;
}

function setMenuSelectedItem_INDEX(the_menu, i) {
	if (i > -1) {
		getObjFromPram(the_menu).selectedIndex = i;
		return i;
	}
	return -1;
}

function setMenuItemDisplay(menu, item_index, new_str) { //menu can be id or obj
	var mo = getObjFromPram(menu);
	if (mo) {
		mo.options[item_index].innerHTML = new_str;
	}

}
//use setMenuSelectedItem_INDEX instead!... does anything use this anyway?
//12.6.05 :removed canDoMenu, and subbed with objFromID() (would only be problematic if
	/// a page had >1 object with the same name... shouldn't do that, anyway
	// if that's the case, would need a function that takes the form name directly....
function setNamedMenuSelectedItemFromIndex(menu_name, i) {
	var mo = objFromID(menu_name);

	return mo ? setMenuSelectedItem_INDEX(mo) : -1;
}

function clearNamedMenuSelectedItem(menu_name) {
	var mo = objFromID(menu_name);

	if (mo) setMenuSelectedItem_INDEX(mo, emptyMenuItemIndex);
}



function setNamedMenuSelectedItemFromVal(menu_name, new_val) {
	var mo = objFromID(menu_name);

	return (mo) ? setMenuSelectedItemFromVal(mo, new_val) : -1;
}

function setMenuSelectedItemFromVal(mo, new_val) {
	return setMenuSelectedItem_INDEX(mo, findMenuItemIndex(mo, new_val));
}

/*
function canDoMenu() {
	return (b_goodMenus) ? true :

	(b_goodMenus = (document && document.forms && document.forms[menuFormName] && document.forms[menuFormName].elements));

	//return b_goodMenus;
}

function setNamedMenuSelectedItemFromIndex(menuName, i) {
	if (canDoMenu()) {
		var the_menu = document.forms[menuFormName].elements[menuName];
		//var the_menu = getNamedFormMenu(menuFormName, menuName);
		if (the_menu) return setMenuSelectedItem_INDEX(the_menu);
	}
	return -1;
}

function clearNamedMenuSelectedItem(menuName) {
	if (canDoMenu() && document.forms[menuFormName] && document.forms[menuFormName].elements) {
		var the_menu = document.forms[menuFormName].elements[menuName];

		if (the_menu) {
			setMenuSelectedItem_INDEX(the_menu, emptyMenuItemIndex);
		}
	}
}



function setNamedMenuSelectedItemFromVal(menuName, newVal) {
	if (canDoMenu() && document.forms[menuFormName] && document.forms[menuFormName].elements) {
		var the_menu = document.forms[menuFormName].elements[menuName];

		if (the_menu) return setMenuSelectedItemFromVal(the_menu, newVal);
	}
	return -1;
}
*/


function findMenuItemIndex(mu, itemVal) {
	if ((itemVal == "") || (itemVal == emptyMenuItemName)) return emptyMenuItemIndex;
	for (var i = 0; i < mu.length; i++) {
		if (mu.options[i].value == itemVal) return i;
	}
	return -1;
}

var LAYERS_TABLE_PIECE_TYPE_None = 0,
	LAYERS_TABLE_PIECE_TYPE_Row = 1,
	LAYERS_TABLE_PIECE_TYPE_Cells = 2;

function getOneCBFText(table_piece_type, cbname, cbval, cblabel, b_checked, cb_click_func0, fname, fval, fwidth, fld_keyfunc_0, font_size_ie, font_size_ns) {

	var s = "";

	if (table_piece_type) {
		if (table_piece_type == 1) s += "<tr>";
		s += getOneTD(cblabel)
			+ getOneTD(getOneCBText(cbname, cbval, b_checked, "", cb_click_func0))
			+ getOneTD(getNewFieldDef(true, fname, fval, fwidth, fld_keyfunc_0));

		if (table_piece_type == 1) s += "</tr>";

	} else {
		s += getOneCBText(cbname, cbval, b_checked, cblabel, cb_click_func0);
		s += getNewFieldDef(true, fname, fval, fwidth, fld_keyfunc_0);
	}


	return s;

}

function getOneTD(s) {
	return "<td>" + s + "</td>";
}

function getNewTableObj(brdr) {
	var o = {table : document.createElement("table")};

	o.table.border = brdr ? brdr : 0;

	o.table.appendChild(o.body = document.createElement("tbody"));

	o.appendChild = function (o2a) {
		o.body.appendChild(o2a);
	}
	return o;
}
function getNewTDO(tr, ih) {
	var td = document.createElement("td");
	if (ih) td.innerHTML = ih;
	if (tr) tr.appendChild(td);
	return td;
}

function getNewTDO_Etc(tr, ih_or_obj, w, colspan, align) {
	var td = document.createElement("td");
	if (tr) tr.appendChild(td);
	if (ih_or_obj) {
		if (typeof(ih_or_obj) == "object") td.appendChild(ih_or_obj);
		else if (typeof(ih_or_obj) == "string") td.innerHTML = ih_or_obj;
	}
	if (w) td.width = w;
	if (colspan) td.colspan = colspan;
	if (align) td.align = align;
	return td;
}

function getSingleTDTRO(ret_type, ih_or_obj, w, colspan, align) {
	var tr = document.createElement("tr");

	var td = getNewTDO_Etc(tr, ih_or_obj, w, colspan, align);

	switch(ret_type) {
	case "o": return {tr : tr, td : td};
	case "td": return td;
	default:
	case "tr": return tr;
	}
}
function setTDVal(td, ih_or_obj) {
	var cn;
	if (typeof(ih_or_obj) != "object") {
		td.innerHTML = ih_or_obj;
		return;
	}
	if (cn = getChildNode(td)) {//ieq
		if (cn != ih_or_obj) {
			removeElement(cn);
		} else {
			return;
		}
	}
	td.appendChild(ih_or_obj); //todo: do we need to check for a parent of ih_or_obj first? (and if so, remove first?)
}

//width, table_name0, border, cellpadding, cellspacing, Bg0, Bc0
function getNewTableObj_ETC(width0, table_name0, border, cellpadding, cellspacing, Bg0, Bc0) {
	var o = getNewTableObj(border);

	if (width) o.table.width = width;
	if (table_name0) o.table.id = table.name = table_name0;
	o.table.cellpadding = cellpadding;
	o.table.cellspacing = cellspacing;
	if (Bg0) o.bgcolor = Bg0;
	if (Bc0) o.bordercolor = Bc0;
}


function getOneCBText(name, val0, checked, label, cfn0) { // todo: could pass in "" for cfn0 to mean "no function at all" and null for dflt...
	var ocf = (cfn0 && (cfn0 != "")) ? cfn0 : "checkBoxClicked";

	ocf += "('" + name + "', this.value, this.checked, this);";

	ocf = gs_changeEvent + ocf;

	var s = "<INPUT" + getNewTag("TYPE", "checkbox") + getNewTag("onclick", ocf);

	if (checked) s += " CHECKED ";

	if (!val0 || (val0 == "")) val0 = name;

	s += getNewNameIDTag(name) + getNewTag("value", val0) + ">" + label;

	return s;
}

function getOneCBText_NO_FUNC(name, checked) { // todo: could pass in "" for cfn0 to mean "no function at all" and null for dflt...


	var s = "<INPUT" + getNewTag("TYPE", "checkbox");

	if (checked) s += " CHECKED ";


	s += getNewNameIDTag(name) + "/>";


	return s;
}

function getOneRBText(name, val, i, checked, changeFunc, label) {
	var s = "<INPUT" + getNewTag("TYPE", "radio");

	if (changeFunc) {
		s += getNewTag("onclick", changeFunc + "('" + name + "', this.value);");
	} else {
		s += getNewTag("onclick",  "pulseMenuSelected('" + name + "', this.value);");
	}

	s += getNewNameIDTag(name) + getNewTag("value", val);

	if (checked) s += " CHECKED>";//so we can easily replace it with just the value....
	else s += ">";

	s += label;

	return s;
}

function getErrStrHTML(s) {
	return '<FONT' + getNewTag("COLOR", "ee0000") + '>' + '<b>' + s + '</b></FONT>';
}
function getWarningQuestionHTML(s) {
	return '<FONT' + getNewTag("COLOR", "dd0000") + '>' + '<b>' + s + '</b></FONT>';
}

function getGreyedOutStrHTML(s) {
	return '<FONT' + getNewTag("COLOR", "888888") + '>' + s + '</FONT>';
}

function getGreyedOutStrHTML_IFNOT(s, t_or_f) {
	return t_or_f ? s : getGreyedOutStrHTML(s);
}

function getRBCheckedHTMLFromHTML_O(o) {
	return getRBCheckedHTMLFromHTML(o.html, o.v);
}
function getRBCheckedHTMLFromHTML(s, v) {
	if (s.indexOf('"' + v + '" CHECKED') > -1) return s; //already checked
	else if (s.indexOf(" CHECKED")) s = GetReplaced(s, " CHECKED", "");

	var i;

	if ((i = s.indexOf('"' + v + '">')) > -1) {
		return s.substring(0, i + v.length + 2) + " CHECKED" + s.substring(i + v.length + 2);
	} else { //value not found... alert?
		return s;
	}

}


function getNewCBO(name, val, checked, label, cfn0, pid) {
	var o = new Object();
	o.s = getOneCBText(name, val, checked, label, cfn0);
	o.c = checked; //in a cb cmd, this is the 3rd pram
	o.v = val ? val : name; //in a cb cmd, this is the 2nd pram (name is the 1st one)
	if (pid) o.p = pid;
	return o;
}
function setCBOChecked(o, c) {
	o.c = c;
}
function getCBOCheckedVal(o) {
	return o.c; //not from the html
}
function valueFromCBO_Calc(o) {
	return valueFromID_CB(o.v);
}
function setCBOCheckedToUI(o) {
	o.c = valueFromID_CB(o.v);
}
function pidFromCBO(o) {
	return o.p;
}
function pulseAttribPairFromCBO(o, b_set) {
	var c = valueFromID_CB(o.v);

	if (b_set) o.c = c;

	return getNewXMLTag_BOOL(o.p, c);

}
function getCBOCheckedForPlayer(cbo) {
	return getTFStringForPlayer(cbo.c);
}

function getProperCBHTMLFromCBO(cbo) {
	return getCBCheckedHTMLFromHTML(cbo.s, cbo.c);
}

function getCBCheckedHTMLFromHTML(s, v) {
	var i;

	if (!v) {
		if (s.indexOf("CHECKED") > -1) {
			return GetReplaced(s, "CHECKED", "");
		}
	} else if (s.indexOf("CHECKED") == -1) {
		i = s.indexOf(">", s.indexOf("checkbox"));
		s = s.substring(0, i) + " CHECKED" + s.substring(i);
	}
	return s;
}

function getCBCheckedHTMLFromHTMLUnchecked(s) {
	var i;

	return s.substring(0, (i = s.indexOf(">", s.indexOf("checkbox")))) + " CHECKED" + s.substring(i);
}

function getMenuItemTextFromMenuHTMLAndValue(hs, v) {
	var i = hs.indexOf(gs_MS_OPTION_OPEN + ' value="' + v + '"');
	if (i > -1) {
		var ii;
		return hs.substring(ii = (hs.indexOf('>', i + 18) + 1), hs.indexOf("</", ii));
	}
	return null;
}

//override!
function checkBoxClicked(cbid, val, chekd) {

}

function setCharAt(s, ci, c) {
	return s.substring(0, ci) + c + s.substring(ci + 1);
}

function insertStrAt(s, is, ci) {
	return s.substring(0, ci) + is + s.substring(ci);
}


// http://www.netmechanic.com/news/vol3/css_no3.htm for setting font sizes
function getNewRBGText(name, changeFunc, label, vtarray, selID, separator, menu_font, menu_font_size_ie, menu_font_size_ns) { // no selID means top will be selected
	var ms = "";
	var ocs = "";
	var b_do_fonts = (menu_font && (menu_font != "")) && menu_font_size_ie && menu_font_size_ns;
	var one_sep = "";
	if (label) ms += label;

	if (b_do_fonts) {
		ms += '<FONT' + getNewTag("FACE", menu_font) + getNewTag("SIZE", menu_font_size_ns) + '>';
	}

	/*

	if (b_do_fonts) {
		ms += getNewTag("STYLE", "font-family:" + menu_font + ";" + "font-size:" + menu_font_size_ie + "pt;");
	}

	*/



	//ms += 'menuSelected("' + plsCmd +',' + name + '", this.options[this.selectedIndex].value)"';

	//ms += "menuSelected('" + plsCmd + "','" + name + "', this.options[this.selectedIndex].value)";

	//ms += ' style="height:' + 22 + 'px; width: ' + width + 'px">';

	if (selID) {
		for (var i = 0; i < vtarray.v.length; i++) {
			one_sep = (one_sep = vtarray.s[i]) ? one_sep : separator;
			ms += getOneRBText(name, vtarray.v[i], i, (vtarray.v[i] == selID), changeFunc, vtarray.t[i]) + one_sep;
		}
	} else {
		for (var i = 0; i < vtarray.v.length; i++) {
			one_sep = (one_sep = vtarray.s[i]) ? one_sep : separator;
			ms += getOneRBText(name, vtarray.v[i], i, false, changeFunc, vtarray.t[i]) + one_sep;
		}
	}


	return ms;

}

function checkAndUncheckTwoRBs(idc, iduc) {
	var cb = objFromID(idc);

	if (cb) cb.checked = true;
	if (cb = objFromID(iduc)) {
		cb.checked = false;
	}
}
//individual box id
function getNewRBGText_IBID(name, changeFunc, label, vtarray, selID, separator, menu_font, menu_font_size_ie, menu_font_size_ns) { // no selID means top will be selected
	var ms = "";
	var ocs = "";
	var b_do_fonts = (menu_font && (menu_font != "")) && menu_font_size_ie && menu_font_size_ns;
	var one_sep = "";
	if (label) ms += label;

	if (b_do_fonts) {
		ms += '<FONT' + getNewTag("FACE", menu_font) + getNewTag("SIZE", menu_font_size_ns) + '>';
	}

	if (selID) {
		for (var i = 0; i < vtarray.v.length; i++) {
			one_sep = (one_sep = vtarray.s[i]) ? one_sep : separator;
			ms += getOneRBText(name + "." + vtarray.v[i], vtarray.v[i], i, (vtarray.v[i] == selID), changeFunc, vtarray.t[i]) + one_sep;
		}
	} else {
		for (var i = 0; i < vtarray.v.length; i++) {
			one_sep = (one_sep = vtarray.s[i]) ? one_sep : separator;
			ms += getOneRBText(name + "." + vtarray.v[i], vtarray.v[i], i, false, changeFunc, vtarray.t[i]) + one_sep;
		}
	}


	return ms;

}

//get a set of radio buttons with accompanying fields (note that it's a vt2array...
function getNewRBGTextWithFields(name, changeFunc, label, fld_prefix, fw, fld_keyfunc_0, vt2array, selID, fld_sep, separator, menu_font, menu_font_size_ie, menu_font_size_ns) { // no selID means top will be selected
	var ms = "";
	var ocs = "";
	var b_do_fonts = (menu_font && (menu_font != "")) && menu_font_size_ie && menu_font_size_ns;
	var one_sep = "";
	if (label) ms += label;

	if (b_do_fonts) {
		ms += '<FONT' + getNewTag("FACE", menu_font) + getNewTag("SIZE", menu_font_size_ns) + '>';
	}

	/*

	if (b_do_fonts) {
		ms += getNewTag("STYLE", "font-family:" + menu_font + ";" + "font-size:" + menu_font_size_ie + "pt;");
	}

	*/



	//ms += 'menuSelected("' + plsCmd +',' + name + '", this.options[this.selectedIndex].value)"';

	//ms += "menuSelected('" + plsCmd + "','" + name + "', this.options[this.selectedIndex].value)";

	//ms += ' style="height:' + 22 + 'px; width: ' + width + 'px">';

	if (selID) {
		for (var i = 0; i < vt2array.v.length; i++) {
			one_sep = (one_sep = vt2array.s[i]) ? one_sep : separator;
			ms += getOneRBText(name, vt2array.v[i], i, (vt2array.v[i] == selID), changeFunc, vt2array.t[i])

			+ fld_sep + getNewFieldDef(true, fld_prefix + vt2array.v[i], vt2array.v2[i], fw, fld_keyfunc_0)

			+ one_sep;
		}
	} else {
		for (var i = 0; i < vt2array.v.length; i++) {
			one_sep = (one_sep = vt2array.s[i]) ? one_sep : separator;
			ms += getOneRBText(name, vt2array.v[i], i, false, changeFunc, vt2array.t[i]) + one_sep;
		}
	}


	return ms;

}

function getCheckboxFieldGroup(name, changeFunc) {

}

function getOptionStr(val, txt) {
	var os = gs_MS_OPTION_OPEN + ' title="' + txt + '"' + ' value="' + val + '">' + txt + gs_MS_OPTION_CLOSE;
	return os;
}

function getOptionStrSel(val, txt) {
	return gs_MS_OPTION_OPEN + ' title="' + txt + '"' + ' value="' + val + '" selected>' + txt + gs_MS_OPTION_CLOSE;
}

function getPolyStr(scale) { //, array, first elem in array to use

	var a = getPolyStr.arguments;
	var si;
	if (typeof(a[1]) == "object") {
		si = a[2];
		a = a[1];
	} else {
		si = 1;
	}
	var len = a.length;
	if (((len - si) % 2) || ((len - si) < 6)) {
		alert("illegal number of getPolyStr arguments");
		return;
	}
	var s = "";

	if (scale != 1.0) {
		s = Math.round(a[si] * scale) + "," + Math.round(a[si + 1] * scale);
		for (var i = si + 2; i < len; i += 2) {
			s += "," + Math.round(a[i]*scale) + "," + Math.round(a[i + 1]*scale);
		}
	} else {
		s = a[si] + "," + a[si + 1];
		for (var i = si + 2; i < len; i += 2) {
			s += "," + a[i] + "," + a[i + 1];
		}
	}
	return s;
}
function getNewMapArea(shape, coords, hr, on_clk, alt) {
	var s = '<area' + getNewTag("shape", shape);


	s += getNewTag("coords", coords);

	s += getNewTagIf("href", hr);

	if (on_clk != "") s += getNewTag("onClick", on_clk + ";return false");

	if (alt != "") {
		s += getNewTag("alt", alt);
		s += getNewTagIf("title", alt);
	}

	s += '/>';

	return s;

}
function getNewMapArea_OLD(shape, coords, hr, on_clk, alt) {
	var s = '<area' + getNewTag("shape", shape);
	var jsc;

	s += getNewTag("coords", coords);

	//s += getNewTagIf("href", hr);
	if (on_clk != "") {
		jsc = "javascript:" + on_clk + ";return false";
		s += getNewTag("href", jsc);
	}
	if (on_clk != "") s += getNewTag("onClick", on_clk + ";return false");

	if (alt != "") {
		s += getNewTag("alt", alt);
		s += getNewTagIf("title", alt);
	}

	s += '/>';

	return s;

}

function getNewMapArea_POLY(coords, hr, on_clk, alt) {
	return getNewMapArea("poly", coords, hr, on_clk, alt);
}

function getNewMapArea_RECT(l, t, r, b, hr, on_clk, alt) {
	return getNewMapArea("rect", l + "," + t + "," + r + "," + b, hr, on_clk, alt);
}


function getConfirmation(str) {
	return confirm(str);
}

function getPrompt(str, dflt) {
	//
	if (typeof(dflt) == "undefined") dflt = "";
	//returns null if cancelled, else the text entered (which can be the dflt, or "" if empty but OK'd)
	return prompt(str, dflt);
}
function getRandomInt(max) {
	return Math.round(Math.random() * max); //between 0 and max
}

function trimStrEdges(s) {

	if (s == "") return "";

	var fsi = s.indexOf(" ");

	if (fsi == -1) return s;

	var lci = s.length - 1;
	var i;

	if (fsi == 0) {
		i = 1;
		while (s.charAt(i) == " ") {
			if (i == lci) return "";
			else i++;

		}
		s = s.substring(i);
		lci = s.length - 1;
		if ((fsi = s.indexOf(" ")) == -1) return s;
	}
	// at this point there's at least one space that's not at the beginning

	if (s.charAt(lci) != " ") return s;
	else if ((i = lci - 1) > 0) {
		i = lci - 1;
		while (s.charAt(i) == " ") {
			if (i) i--;
			else return "";
		}

		return s.substring(0, i + 1);
	} else if (!i) {
		return (s.charAt(0) != "") ? s.charAt(0) : "";
	} else {
		return "";
	}
}

function trimStringArrayAndCheckForNonEmpty(a) {
	var b_any_non_empty = false;
	var i = 0, len = a.length;
	for (i = 0; i < len; i++) {
		if ((a[i] = trimStrEdges(a[i])) != "") {
			b_any_non_empty = true;
			break;
		}
	}

	if (b_any_non_empty) {
		for (i = i; i < len; i++) {
			a[i] = trimStrEdges(a[i]);
		}
	} //else already trimmed them all and were none
	return b_any_non_empty;
}


function getNumSameChars(s, c, si) {
	var n = 0, i;

	i = s.indexOf(c, si);

	while (i > -1) {
		n++;
		i = s.indexOf(c, i + 1);
	}
	return n;

}

function doesStrEndIn(s, es) {
	var i = s.lastIndexOf(es);

	return ((i > -1) && (i == (s.length - es.length)));
}

function doesStrEndInCI(s, es) { //case-insensitive.. i guess we COuld only lowercasify the end part ;)
	return doesStrEndIn(s.toLowerCase(), es.toLowerCase());
}

function getLastChar(s) {
	return s.charAt(s.length - 1);
}

function pullOffLastChar(s) {
	return s.substring(0, s.length - 1);
}

function pullOffLastCharIfMatch(s, m) {
	return (getLastChar(s) != m) ? s : pullOffLastChar(s);
}

function lastCharMatch2(s, m1, m2) {
	var c;
	return (((c = getLastChar(s)) == m1) || (c == m2));
}
function pullOffLastCharIfMatch2(s, m1, m2) {
	return !lastCharMatch2(s, m1, m2) ? s : pullOffLastChar(s);
}

//returns null if can't exist.... can return "" if say, s = "abcd" and p1 = "b" and p2 = "c";
function getStringInBetweenPieces(s, p1, p2) {
	var is = s.indexOf(p1);

	if (is != -1) {
		is += p1.length;
		var es = s.indexOf(p2, is);

		return (es > -1) ? s.substring(is, es) : null;
	}
	return null;
}

function setClipboardContents(s, tp0) {
	var type = tp0 ? tp0 : "Text";
	if(gb_canUseActualClipboard && window.clipboardData && window.clipboardData.setData) {
        	window.clipboardData.setData(type, s);
        }
      	return s;
}
/*
http://almaer.com/blog/supporting-the-system-clipboard-in-your-web-applications-what-a-pain
copy: function(copytext) {
    try {
        if (netscape.security.PrivilegeManager.enablePrivilege) {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        } else {
            clipdata = copytext;
            return;
        }
    } catch (ex) {
        clipdata = copytext;
        return;
    }

    var str = Components.classes["@mozilla.org/supports-string;1"].
                              createInstance(Components.interfaces.nsISupportsString);
    str.data = copytext;

    var trans = Components.classes["@mozilla.org/widget/transferable;1"].
                           createInstance(Components.interfaces.nsITransferable);
    if (!trans) return false;

    trans.addDataFlavor("text/unicode");
    trans.setTransferData("text/unicode", str, copytext.length * 2);

    var clipid = Components.interfaces.nsIClipboard;
    var clip   = Components.classes["@mozilla.org/widget/clipboard;1"].getService(clipid);
    if (!clip) return false;

    clip.setData(trans, null, clipid.kGlobalClipboard);
},
*/
function getClipboardContentsMOZ(b_image) {
    try {
        if (netscape.security.PrivilegeManager.enablePrivilege) {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            //netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); //should already have been called?
        } else {
            return clipdata;
        }
    } catch (ex) {
        return clipdata;
    }

	var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(Components.interfaces.nsIClipboard);
	if (!clip) return false;

	var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
	if (!trans) return false;
	var df = !b_image ? "text/unicode" : "image/png";
	trans.addDataFlavor(df);

	clip.getData(trans, clip.kGlobalClipboard);

	if (!b_image) {
		var str       = new Object();
		var strLength = new Object();
		var pastetext = "";
		try {
			trans.getTransferData(df, str, strLength);
			if (str) str = str.value.QueryInterface(Components.interfaces.nsISupportsString);//todo: do we need to Release this?
			if (str) pastetext = str.data.substring(0, strLength.value / 2);
			return pastetext;
		}
		catch (er) {
			return "";
		}
	} else {
		var o = new Object(), olen = new Object();
		try {
			trans.getTransferData(df, o, olen);
			//var bf = new Object();
			//trans.getAnyTransferData ( bf, o, olen );

			//var ips = o.value.QueryInterface(Components.interfaces.nsIOutputStream);


		}
		catch(er) {
			return {o_data : null}; //no clipboard data of the proper type :)
		}
		//doesn't seem to work on windows mozilla :(.... o.value.data is undefined

		return {o_data : o.value, o_len : olen};
	}


}

function getClipboardContents(tp0, b_image) {
	var type = tp0 ? tp0 : "Text";
	if(window.clipboardData && clipboardData.getData) {
		return clipboardData.getData(type);
	} else if (!window.clipboardData && gb_moz) {;// && gb_playerLocal) {
		return getClipboardContentsMOZ(b_image);
	}
      	return null;
}

function CopyToClip(div_to_copy){
	var div = document.getElementById(div_to_copy);
	div.contentEditable = 'true';
	var controlRange;
	if (document.body.createControlRange) {
	controlRange = document.body.createControlRange();
	controlRange.addElement(div);
	controlRange.execCommand('Copy');
	}
	div.contentEditable = 'false';
}

function setDelayedFieldContentsToClipboard(fn) {
	var cbc = getClipboardContents();
	if (cbc) {
		var f = objFromID(fn);
		if (f) {
			f.value = cbc;
		} else {
			alert("no fld found for clipboard pasting");
		}
	}
}
/*
function imAFrame() {
	return (parent && (parent.location != window.location));
}
*/
var go_mainVGParent = parent;

function setMainVGParentFromDoc() {
	var loc = document.location.toString();

	if (parent.frames) {
		for (var i = 0; i < parent.frames.length; i++) {
			try {
				if (parent.frames[i].location.toString() == loc) {
					go_mainVGParent = parent.frames[i];
					return go_mainVGParent;
				}
			}
			catch (e) {

			}
		}
	}
	return go_mainVGParent = parent;
}
//IE only... in FF after 3.5!
function onDragOver() {
        if (window.event) window.event.returnValue = false;
        else return false;
}
//IE only ... in FF after 3.5!
function onDragEnter() {
	if (window.event) window.event.returnValue = false;
	else return false;
}
function getStyleRuleByID_STD(id, doc) {
	return getStyleRuleByID_PRIVATE(id, doc);
}
function getStyleRuleByID(id, doc) {
	return getStyleRuleByID_PRIVATE( "." + id, doc);
}
function getStyleVal(stl, id, doc) {
	if (typeof(stl) == "object") return stl[id];
	else return (stl = getStyleRuleByID_STD(stl, doc)) ?
		stl[id] : null;
}
function setStyleAttribByStyleID(id, doc, attrib, val) {
	var o = getStyleRuleByID_STD(id, doc);
	if (o) {
		o[attrib] = val;
	}
}
function numberFromStyleStr(s) {
	var i = s.indexOf("p");
	return new Number((i > -1) ? s.substring(0, i) : s);
}

function getStyleNumAttribByStyleID(id, attrib, doc) {
	var o = getStyleRuleByID_STD(id, doc);
	return o ? numberFromStyleStr(o[attrib]) : 0;
}
function getStyleNumAttrib(o_style, attrib) {
	return numberFromStyleStr(o_style[attrib]);
}
/*
function getMainStyleRuleByID(id, doc) {
	return getStyleRuleByID_PRIVATE(id.toUpperCase(), doc);
}
*/

function setStyleBackgroundImg(id, doc, img, w0, h0) {
	var stl = getStyleRuleByID_PRIVATE(id, doc);

	if (stl) {
		stl.backgroundImage = "url(" + img + ")";
		if (w0) stl.width = w0 + "px";
		if (h0) stl.height = h0 + "px";
	}
}

function getStyleRuleByID_PRIVATE(id, doc) {
	doc = doc ? doc : document;

	var rules;

	var ss;

	if (id.charAt(0) == ".") {//case sensitive
		for (var ssi = 0; ssi < doc.styleSheets.length; ssi++) {
			if ((ss = doc.styleSheets[ssi]) && ((rules = ss.rules) || (rules = ss.cssRules))) {
				for (var i = 0; i < rules.length; i++) {
					if (rules[i].selectorText == id) return rules[i].style;
				}
			}
		}
	} else { //they may have been made uppercase
		id = id.toLowerCase();
		for (var ssi = 0; ssi < doc.styleSheets.length; ssi++) {
			if ((ss = doc.styleSheets[ssi]) && ((rules = ss.rules) || (rules = ss.cssRules))) {
				for (var i = 0; i < rules.length; i++) {
					if (rules[i].selectorText.toLowerCase() == id) return rules[i].style;
				}
			}
		}
	}
	return null;
}

var go_dateStrs = null;
//todo: init this somewhere so that we don't hafta check each time....
//note: override if want to do language!
function initGODateStrs() {
	go_dateStrs = {
		a_ml : new Array("January", "February", "March",
			"April", "May", "June", "July", "August", "September",
			"October", "November", "December"),
		a_ms : new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"),
		a_dl : new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"),
		a_ds : new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
	}
}

function getTime24(d) {
	var h = d.getHours();
	var m = d.getMinutes();

	if (h < 10) h = "0" + h;
	if (m < 10) m = "0" + m;

	return h + ":" + m;
}

function getTime12(d, b_no_pre_zeros) {
	var m = d.getMinutes(), h = d.getHours();
	var b_pm;

	if (m < 10) m = "0" + m;

	if (b_pm = (h > 11)) {
		h -= 12;
	}
	if (h == 0) h = 12;
	else if (!b_no_pre_zeros && h < 10) h = "0" + h;

	return h + ":" + m + " " + (b_pm ? "PM" : "AM");

}

function getDateInMonthStr(i) {
	return (i < 10) ? "0" + i : i;
}

if (!go_dateStrs) initGODateStrs();
//m.d.y, d.m.y, d.ml.y d.ms.y
//getDateString(date, "dws.d.ms.y", "12");
function getDateString(d, d_type, t_type, b_time_first) {
	//if (!go_dateStrs) initGODateStrs();

	var s = "";

	if (d_type.indexOf("dw") == 0) { //dws. and dwl.
		s = ((d_type.charAt(2) == "s") ? go_dateStrs.a_ds[d.getDay()] : go_dateStrs.a_dl[d.getDay()]) + " ";
		d_type = d_type.substring(4);
	}
	switch(d_type) {
	case "d.ms.y":
		s += getDateInMonthStr(d.getDate()) + "-" + go_dateStrs.a_ms[d.getMonth()] + "-" + (d.getFullYear()+"").substring(2);
		break;
	case "d.ml.y":
		s += getDateInMonthStr(d.getDate()) + "-" + go_dateStrs.a_ml[d.getMonth()] + "-" + (d.getFullYear()+"").substring(2);
		break;
	case "d.m.y":
		s += getDateInMonthStr(d.getDate()) + "." + (d.getMonth() + 1) + "." + (d.getFullYear()+"").substring(2);
		break;
	case "m.d.y":
		s += (d.getMonth() + 1) + "/" + getDateInMonthStr(d.getDate()) + "/" + (d.getFullYear()+"").substring(2);
		break;
	default:
		break;
	}

	var t = "";
	switch(t_type) {
	case "24":
		t = getTime24(d);
		break;
	case "12z":
		t = getTime12(d, false);
		break;
	case "12":
		t = getTime12(d, true);
		break;
	}

	if (s) {
		if (t) {
			return b_time_first ? t + " " + s : s + " " + t;
		} else {
			return s;
		}
	} else if (t) {
		return t;
	}
	return "";
}

function getObjFromPram(o_or_id) {
	return (typeof(o_or_id) == "string") ? objFromID(o_or_id) : o_or_id;
}

function setStyleValForObj(o_or_oid, stn, val, b_add_px) {
	var o = getObjFromPram(o_or_oid);

	if (b_add_px && (val < 0)) val = 0;
	if (o && o.style) {
		o.style[stn] = val + ((b_add_px) ? "px" : "");
	}
}
function setStyleValsForObj(o_or_oid, stn0, val0) {
	var o = getObjFromPram(o_or_oid);

	if (o && o.style) {
		var args = setStyleValsForObj.arguments, len = args.length;
		for (var i = 1; i < len; i += 2) {
			o.style[args[i]] = args[i + 1];
		}
	}
}

function getObjDimW(o_or_id) {
	var o = getObjFromPram(o_or_id);
	return o ? o.clientWidth : 0;
}
function getObjDimH(o_or_id) {
	var o = getObjFromPram(o_or_id);
	return o ? o.clientHeight : 0;
}

function getObjDims(o_or_id) {
	var o = getObjFromPram(o_or_id);
	if (o) {
		return o.clientWidth
			? {w : o.clientWidth, h : o.clientHeight}
			: {w : o.offsetWidth, h : o.offsetHeight};
	}
}

function getLayerDimH(l_or_id) {
	var l = layerFromPram(l_or_id);
	return l.clientHeight;
}

function getLayerDimW(l_or_id) {
	var l = layerFromPram(l_or_id);
	return l.clientWidth;
}

function getLayerTop(l_or_id, b_rel) {
	var l = layerFromPram(l_or_id);
	return b_rel ? l.clientTop : l.offsetTop;
}

function getLayerBottom(l_or_id) {
	var l = layerFromPram(l_or_id);
	return l.offsetTop + l.offsetHeight;
}

function getObjBottom(l_or_id) {
	var l = getObjFromPram(l_or_id);
	return l.offsetTop + l.offsetHeight;
}

function setLayerLT(l_or_id, l, t) {
	var lyr = layerFromPram(l_or_id);
	lyr.style.left = l + "px";
	lyr.style.top = t + "px";
}
function setLayerWHLT(l_or_id, w, h, l, t) {
	var lyr = layerFromPram(l_or_id);
	lyr.style.left = l + "px";
	lyr.style.top = t + "px";
	if (w > 0) lyr.style.width = w + "px";
	if (h > 0) lyr.style.height = h + "px";
}
function removeElement(e) {
	var pe = getAParentElement(e);
	if (pe) pe.removeChild(e);
}
function removeElementByID(id) {
	var o = objFromID(id);
	if (o) removeElement(o);
}
function removeElementIF(e0) { // if non-null AND has parent
	if (e0) removeElement(e0);
}

function replaceElement(e_to_replace, new_e) { //only works if first has a parent!
	var p = getParentElement(e_to_replace);

	if (p) {
		if (p.replaceChild) {
			p.replaceChild(e_to_replace, new_e);
		}
	}
}
function replaceOrAddFirstChild(e, new_e) {
	var fc = getChildNode(e, 0);
	if (fc) {
		if (e.replaceChild) e.replaceChild(new_e, fc);
		else {
			Debugger();
		}
	} else {
		e.appendChild(new_e);
	}
}
function getParentElement(e) {
	return e.parentNode ? e.parentNode : e.parentElement;
}
function getAParentElement(e, i_level) {
	if (!i_level || (i_level == 1)) {
		return ismoz() ? e.parentNode : e.parentElement;
	} else {
		var p = getAParentElement(e);
		if (p) {
			if (ismoz()) {
				for (var i = 1; i < i_level; i++) {
					if (!(p = p.parentNode)) return null;
				}
			} else {
				for (var i = 1; i < i_level; i++) {
					if (!(p = p.parentElement)) return null;
				}
			}
		}
		return p;
	}
	return null;
};

function getAParentElement_TYPED(e, type) {
	var pe = ismoz() ? e.parentNode : e.parentElement;
	if (pe) {
		if (pe.tagName == type) return pe;
		return getAParentElement_TYPED(pe, type);
	}
	return null;
}

function getAFirstChildElement_TYPED(o_t, tp) { //tp has to already be lower case!
	do {

	} while ((o_t = o_t.firstChild) && (o_t.tagName.toLowerCase() != tp));

	return o_t;
}

function getChildNode(e, i) {
	return ismoz() ? e.childNodes[i] : e.children[i];
}
function getElemNextSibling(e) {
	return e.nextSibling;
}

function insertNodeAfter(newNode, referenceNode ){
	getParentElement(referenceNode).insertBefore( newNode, referenceNode.nextSibling );
}

function Debugger(b_override) {
	if (gb_showDebugger || b_override) {
		debugger;
	}
}

function showAlert(a, post_alert_action, b_now) {
    if (b_now) {
        alert(unescape(a));
        if (post_alert_action != "") eval(unescape(post_alert_action));
    } else {
        var paa = post_alert_action ? "'" + escape(post_alert_action) + "'" : "''";
        setTimeout("showAlert('" + escape(a) + "'," + paa + ", true);", 1);
    }
}

function showAlertRefocus(a) {
	var pff = go_focusedFld;
	alert(a);
	if (pff) {
		forceFocus(pff);
	}
}

var gs_consoleLog = "";
function writeToConsole(s) {
	if (gb_showConsole) {
		if (window.console) {
			window.console.log(s + "\n");
		} else {
			gs_consoleLog += cr + s;
		}
	}
}

function initBD() {

	BrowserDetect = {
		init: function () {
			this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
			this.version = this.searchVersion(navigator.userAgent)
				|| this.searchVersion(navigator.appVersion)
				|| "an unknown version";
			this.OS = this.searchString(this.dataOS) || "an unknown OS";
			if (this.OS == "Windows") {
				var i = navigator.userAgent.toLowerCase().indexOf("windows nt") + 11;
				var s = navigator.userAgent.substring(i, navigator.userAgent.indexOf(";", i));
				this.dataOS.version = s.split(".");
			} else if (this.OS == "Mac") {
				this.Mac = {b_intel : (navigator.platform.toLowerCase() == "macintel")};
				var i = navigator.appVersion.indexOf("OS X 10");
				switch(this.browser) {
				case "Safari":
				case "Chrome":
					// 10_6_3;
					this.Mac.vers = navigator.appVersion.substring(i + 5, navigator.appVersion.indexOf(";", i + 5)).split("_");
					break;
				case "Firefox":
					this.Mac.vers = navigator.appVersion.substring(i + 5).split(".");
				}
			}
		},
		searchString: function (data) {
			for (var i=0;i<data.length;i++)	{
				var dataString = data[i].string;
				var dataProp = data[i].prop;
				this.versionSearchString = data[i].versionSearch || data[i].identity;
				if (dataString) {
					if (dataString.indexOf(data[i].subString) != -1)
						return data[i].identity;
				}
				else if (dataProp)
					return data[i].identity;
			}
		},
		searchVersion: function (dataString) {
			var index = dataString.indexOf(this.versionSearchString);
			if (index == -1) return;
			return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
		},
		dataBrowser: [
			{
				string: navigator.userAgent,
				subString: "Chrome",
				identity: "Chrome"
			},
			{ 	string: navigator.userAgent,
				subString: "OmniWeb",
				versionSearch: "OmniWeb/",
				identity: "OmniWeb"
			},
			{
				string: navigator.vendor,
				subString: "Apple",
				identity: "Safari",
				versionSearch: "Version"
			},
			{
				prop: window.opera,
				identity: "Opera"
			},
			{
				string: navigator.vendor,
				subString: "iCab",
				identity: "iCab"
			},
			{
				string: navigator.vendor,
				subString: "KDE",
				identity: "Konqueror"
			},
			{
				string: navigator.userAgent,
				subString: "Firefox",
				identity: "Firefox"
			},
			{
				string: navigator.vendor,
				subString: "Camino",
				identity: "Camino"
			},
			{		// for newer Netscapes (6+)
				string: navigator.userAgent,
				subString: "Netscape",
				identity: "Netscape"
			},
			{
				string: navigator.userAgent,
				subString: "MSIE",
				identity: "Explorer",
				versionSearch: "MSIE"
			},
			{
				string: navigator.userAgent,
				subString: "Gecko",
				identity: "Mozilla",
				versionSearch: "rv"
			},
			{ 		// for older Netscapes (4-)
				string: navigator.userAgent,
				subString: "Mozilla",
				identity: "Netscape",
				versionSearch: "Mozilla"
			}
		],
		dataOS : [
			{
				string: navigator.platform,
				subString: "Win",
				identity: "Windows"
			},
			{
				string: navigator.platform,
				subString: "Mac",
				identity: "Mac"
			},
			{
				string: navigator.platform,
				subString: "Linux",
				identity: "Linux"
			}
		]

	};
	BrowserDetect.init();
}

