/* *******************************************************************
incCommonAPI.js
General Browser Variables and DOM functions
-scott 5/12/06

Adapted From:
	Example 4-3 (DHTMLapi.js)
	"Dynamic HTML:The Definitive Reference"
	2nd Edition
	by Danny Goodman
	Published by O'Reilly & Associates  ISBN 1-56592-494-0
	http://www.oreilly.com
	Copyright 2002 Danny Goodman.  All Rights Reserved.
	// DHTMLapi.js custom API for cross-platform
	// object positioning by Danny Goodman (http://www.dannyg.com).
	// Release 2.0. Supports NN4, IE, and W3C DOMs.
******************************************************************** */

/* *******************************************************************
	GLOBAL BROWSER SETTINGS AND OBJECT REFERENCES******************************************************************** */
// -------------------------------------------------------------------
// Global variables
// -------------------------------------------------------------------
var gbIncCommonAPILoaded = false;
var gIsCSS, gIsW3C, gIsIE4, gIsNN4;
// initialize upon load to let all browsers establish content objects
function initDHTMLAPI() {
	if (document.images) {
		gIsCSS = (document.body && document.body.style) ? true : false;
		gIsW3C = (gIsCSS && document.getElementById) ? true : false;
		gIsIE4 = (gIsCSS && document.all) ? true : false;
		gIsNN4 = (document.layers) ? true : false;
		isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
	}	gbIncCommonAPILoaded = true;
}
// set event handler to initialize API
window.onload = initDHTMLAPI;
// -------------------------------------------------------------------
// End Global variables
// -------------------------------------------------------------------

// -------------------------------------------------------------------
// seekLayer(doc, name)// Private Utility Function Seek nested NN4 layer from string name// -------------------------------------------------------------------
function seekLayer(doc, name) {
	var theObj;
	for (var i = 0; i < doc.layers.length; i++) {
		if (doc.layers[i].name == name) {
			theObj = doc.layers[i];
			break;
		}
		// dive into nested layers if necessary
		if (doc.layers[i].document.layers.length > 0) {
			theObj = seekLayer(document.layers[i].document, name);
		}
	}
	return theObj;
}

// -------------------------------------------------------------------
// g_getRawObject(obj)// Utility function to Convert object name string or object reference
// into a valid element object reference
// -------------------------------------------------------------------
function g_getRawObject(obj) {	if (!gbIncCommonAPILoaded) initDHTMLAPI();
	var theObj;
	if (typeof obj == "string" && obj != "" && obj != null) {
		if (gIsW3C) {
			theObj = document.getElementById(obj);
		}		else if (gIsIE4) {
			theObj = document.all(obj);
		}		else if (gIsNN4) {
			theObj = seekLayer(document, obj);
		}		if (theObj == null) {
		    try {
    		    theObj = eval("document." + obj);
    	    }
    	    catch (e) {
    	        theObj = null;
    	    }
		}
	}	else {
		// pass through object reference
		theObj = obj;
	}
	return theObj;
}

// -------------------------------------------------------------------
// g_getObject(obj)// Utility function to Convert object name string or object reference
// into a valid style (or NN4 layer) reference
// -------------------------------------------------------------------
function g_getObject(obj) {
	var theObj = g_getRawObject(obj);
	if (theObj && gIsCSS) {
		if (theObj.style) theObj = theObj.style;
	}
	return theObj;
}
/* *******************************************************************
	CUSTOM COLLECTION OBJECT******************************************************************** */
// -------------------------------------------------------------------
// gObjCollection()// Custom name/value associative array object
// Properties:
//		count: Total numbers of items
//		error: Error indicator
// Methods:
//		add(sKey, sValue): Add an item to the collection.
//		item(sKey, sValue): Get an Item in the collection, or sets it if sValue is defined
//		exists(sKey): Returns true if a key exists, otherwise false 
//		keys(): Returns an Array of all the keys
//		removeAll(): Removes all key and item pairs from the collection
//		remove(sKey): Removes a key and item pair from the collection
// -------------------------------------------------------------------
function gObjCollection() {
	this.objcollection = new Object();	//	Associative array
	this.count = 0;						//	Total numbers of items
	this.error = false;					//	Error indicator
	this.add = colAdd;					//	Add method
	this.item = colItem;				//	Item method	this.exists = colExists;			//	Exists method	this.keys = colGetKeys;				//	Keys method
	this.removeAll = colRemoveAll;  	//	Remove all Items and Keys	this.remove = colRemove;			//	Remove one Item and Key	//Add an item to the collection object.
	function colAdd(sKey, sValue) {
		this.error = false;		//	 Default successful		if( ! this.exists(sKey) ) {			this.count++;
			this.objcollection[sKey] = sValue;		}		else			this.error = true; 	//	 Error	}
	//Get an Item in the collection, or sets it if sValue is defined	function colItem(sKey, sValue) {		this.error = false;		//	 Default successful
		if( this.exists(sKey) ) {			if (sValue != null) this.objcollection[sKey] = sValue;			return this.objcollection[sKey];		}		else			this.error = true; 	//	 Error	}		//Returns true if a key exists, otherwise false 	function colExists(sKey) {		return (typeof(this.objcollection[sKey]) != 'undefined');
	}
	
	//Removes all key and item pairs from the collection	function colRemoveAll() {
		this.objcollection = new Object();
		this.count = 0;
	}	//Removes a key and item pair from the collection	function colRemove(sKey) {		if( this.exists(sKey) ) {			delete this.objcollection[sKey];			this.count--;
		}	}
		// Returns an Array of all the keys
	function colGetKeys() {
		var aryKeys = new Array();
		var i = 0;		for (var k in this.objcollection) {			aryKeys[i] = k;
			i++;		}				return aryKeys;
	}
}


/* *******************************************************************
	STYLES MANIPULATION FUNCTIONS******************************************************************** */

// -------------------------------------------------------------------
// gAryStyleProperties// Array of Style Properties to save/copy
// -------------------------------------------------------------------
var gAryStyleProperties = new Array(
	"background",
	"color", 
	"font", 
	"border", 
	"padding", 
	"cursor", 
	"textDecoration");

// -------------------------------------------------------------------
// g_getStyle(obj)// Gets the Current style object (CSSStyleDeclaration of an element)
// -------------------------------------------------------------------
function g_getStyle(obj) {
	var theObj = g_getRawObject(obj);
	if (window.getComputedStyle) return window.getComputedStyle(theObj, null);
	else if (theObj.currentStyle) return theObj.currentStyle;
	else if (theObj.style) return theObj.style;
	
	return obj;}

// -------------------------------------------------------------------
// g_saveStyle(obj)// Returns an gObjCollection of an Element's Current Style
// -------------------------------------------------------------------
function g_saveStyle(obj) {
	var objStyle = g_getStyle(obj);
	var objSavedStyle = new gObjCollection();	if (objStyle) {
		for (var i = 0; i < gAryStyleProperties.length; i++) {			objSavedStyle.add(gAryStyleProperties[i], g_getStyleValueFromStyle(objStyle, gAryStyleProperties[i]));
		}	}
	return objSavedStyle;
}
// -------------------------------------------------------------------
// g_setStyle(obj, objStyle)// Sets the Style properties of an Object to the all the Styles //	contained in a CSSStyleDeclaration
// -------------------------------------------------------------------
function g_setStyle(obj, objStyle) {	var obj = g_getRawObject(obj);
	var bSuccess = false;
	if (obj.style && objStyle.cssText) {		try {			obj.style.cssText = objStyle.cssText;			bSuccess = true;
		}
		catch(e) {
			if (obj.setAttribute) obj.setAttribute("style", objStyle.cssText);
			bSuccess = false;		}	}	if (!bSuccess) {		if (objStyle.keys) {			for (var i = 0; i < gAryStyleProperties.length; i++) {
				g_setStyleValue(obj, gAryStyleProperties[i], objStyle.item(gAryStyleProperties[i]));			}		}		else {
			for (var i = 0; i < gAryStyleProperties.length; i++) {
				g_setStyleValue(obj, gAryStyleProperties[i], g_getStyleValueFromStyle(objStyle,gAryStyleProperties[i]));			}		}
	}
}

// -------------------------------------------------------------------
// g_getStyleValue(obj, sProperty)// Gets the Value of a Particular style property for an element
// -------------------------------------------------------------------
function g_getStyleValue(obj, sProperty) {	var objStyle = g_getStyle(obj);
	
	var sValue;	if (objStyle) {		sValue = (objStyle.getPropertyValue) ? objStyle.getPropertyValue(sProperty) : objStyle[sProperty];
	}		return sValue;
}

// -------------------------------------------------------------------
// g_getStyleValueFromStyle(objStyle, sProperty)// Gets the Value of a Particular style property from a Style Object
// -------------------------------------------------------------------
function g_getStyleValueFromStyle(objStyle, sProperty) {	var sValue;
	if (objStyle) {		sValue = (objStyle.getPropertyValue) ? objStyle.getPropertyValue(sProperty) : objStyle[sProperty];
	}		return sValue;
}


// -------------------------------------------------------------------
// g_setStyleValue(obj, sProperty, sValue)// Sets the Value of a Particular style property for an element
// -------------------------------------------------------------------
function g_setStyleValue(obj, sProperty, sValue) {
	var theObj = g_getObject(obj);
		if (theObj) {
		if (theObj.setProperty) theObj.setProperty(sProperty, sValue, null);		else if (typeof(theObj[sProperty]) != "undefined") {
			try {				theObj[sProperty] = sValue;
			}
			catch(e) {
				if (sValue == "" || sValue == "undefined") sValue = "auto";
			}		}
	}}

// -------------------------------------------------------------------
// toCamelCase(input)// Utility function to Convert string input to a camel cased version //	of itself.// Example:
//		toCamelCase("z-index"); // returns zIndex
//		toCamelCase("border-bottom-style"); // returns borderBottomStyle.
// -------------------------------------------------------------------
function toCamelCase(s) {
	for(
		var exp = toCamelCase.exp; 
		exp.test(s);
		s = s.replace(exp, RegExp.$1.toUpperCase())
	);
	return s;
}
toCamelCase.exp = /-([a-z])/;


// -------------------------------------------------------------------
// gfunClassDefStyle(sStyleSheetID, sClassName)// Returns a style object for a specific class definition
// -------------------------------------------------------------------
function gfunClassDefStyle(sStyleSheetID, sClassName) {

	var objStylesheet = g_getRawObject(objStylesheet);
	objStylesheet = (objStylesheet.sheet) ? objStylesheet.sheet : objStylesheet.styleSheet;

	if (!objStylesheet) {
		var sID;
		for (var i = 0; i < document.styleSheets.length; i++) {
			sID = (document.styleSheets[i].ownerNode) ? document.styleSheets[i].ownerNode.id : document.styleSheets[i].owningElement.id;
			if (sID == sStyleSheetID) {
				objStylesheet = document.styleSheets[i];
				break;
			}
		}
	}

	var objRules = (objStylesheet.cssRules) ? objStylesheet.cssRules : objStylesheet.rules;
	for (var i = 0; i < objRules.length; i++) {
		if (objRules[i].selectorText.toLowerCase() == sClassName.toLowerCase()) {
			return objRules[i].style;
			break;
		}
	}
}


/* *******************************************************************
	OTHER UTILITY FUNCTIONS******************************************************************** */

// -------------------------------------------------------------------
// gfunAddElement(obj, sType, id, name, class, aryAttributes, aryValues)// Utility function to create a new element and append it to another// -------------------------------------------------------------------
function gfunAddElement(obj, sType, sID, sName, sClass, aryAttributes, aryValues) {
	var theObj = g_getRawObject(obj);

	var objNode;
	if (document.createElement) {
		var objNode = document.createElement(sType);
		if (sID != null) objNode.setAttribute("id", sID);

		// Add Misc Attributes
		if (aryAttributes) if (aryAttributes.length) {
			for (var i = 0; i < aryAttributes.length; i++) {
				if (objNode.setAttribute) objNode.setAttribute(aryAttributes[i], aryValues[i]);
				else if (objNode[aryAttributes[i]]) objNode[aryAttributes[i]] = aryValues[i];
			}
		}

		// Add the New element to the DOM
		theObj.appendChild(objNode);
		objNode = (sID != null) ? g_getRawObject(sID) : theObj.lastChild;

		if (sName != null) {
			objNode.setAttribute("name", sName);
			objNode.name = sName;
		}
		if (sClass != null) gfunSetClass(objNode, sClass);

	}
	else if (theObj.innerHTML) {
		var sHTML = "<" + sType;
		if (sID != null) sHTML += " id=\"" + sID + "\"";
		if (sName != null) sHTML += " name=\"" + sName + "\"";
		if (sClass != null) sHTML += " class=\"" + sClass + "\"";
		// Add Misc Attributes
		for (var i = 0; i < aryAttributes.length; i++) {
			 sHTML += " " + aryAttributes[i] + "=\"" + aryValues[i] + "\"";
		}
		// End the Tag
		sHTML += " />";
		
		// Add the new HTML to the Object
		theObj.innerHTML += sHTML;
		
		//Get the Node
		if (sID != null) objNode = g_getRawObject(sID);
		else if (theObj.hasChildren) objNode = theObj.lastChild;
		else objNode = null;
	}
	return objNode;
}


// -------------------------------------------------------------------
// gfunCreateElement(sType, id, name, class, aryAttributes, aryValues)// Utility function to create a new element, but does not Add it to the DOM// -------------------------------------------------------------------
function gfunCreateElement(sType, sID, sName, sClass, aryAttributes, aryValues) {
    var objNode;
	if (document.createElement) {
		var objNode = document.createElement(sType);
		if (sID != null) objNode.setAttribute("id", sID);

		// Add Misc Attributes
		if (aryAttributes) if (aryAttributes.length) {
			for (var i = 0; i < aryAttributes.length; i++) {
				if (objNode.setAttribute) objNode.setAttribute(aryAttributes[i], aryValues[i]);
				else if (objNode[aryAttributes[i]]) objNode[aryAttributes[i]] = aryValues[i];
			}
		}
		
		// Add the element to the DOM temporarily
		document.appendChild(objNode);
		objNode = (sID != null) ? g_getRawObject(sID) : document.lastChild;
		
		// Try the Name and the class
		if (sName != null) {
			objNode.setAttribute("name", sName);
			objNode.name = sName;
		}
		if (sClass != null) gfunSetClass(objNode, sClass);

        // Remove the Node from the DOM
        objNode = document.removeChild(document.lastChild);

        return objNode;
	}
	else if (theObj.innerHTML) {
		var sHTML = "<" + sType;
		if (sID != null) sHTML += " id=\"" + sID + "\"";
		if (sName != null) sHTML += " name=\"" + sName + "\"";
		if (sClass != null) sHTML += " class=\"" + sClass + "\"";
		// Add Misc Attributes
		for (var i = 0; i < aryAttributes.length; i++) {
			 sHTML += " " + aryAttributes[i] + "=\"" + aryValues[i] + "\"";
		}
		// End the Tag
		sHTML += " />";
		
		// Add the new HTML to the Object
		document.innerHTML += sHTML;
				
		//Get the Node
		objNode = (document.hasChildren) ? document.removeChild(document.lastChild) : null;
		
		return objNode;
	}
}


// -------------------------------------------------------------------
// gfunSetClass(obj, sClass)// Updates the Class of an Object// -------------------------------------------------------------------
function gfunSetClass(obj, sClass) {
	var theObj = g_getRawObject(obj);
	
	if (theObj != null) {
		if (theObj.setAttribute != null) theObj.setAttribute("class", sClass);
		if (theObj.className != null) theObj.className = sClass;
	}
	return null;
}

// -------------------------------------------------------------------
// gfunGetClass(obj)// Gets the Current Class of an Object// -------------------------------------------------------------------
function gfunGetClass(obj) {
	var theObj = g_getRawObject(obj);
	var sClass = "";
	if (theObj != null) {
		if (theObj.className != null) sClass = theObj.className;
		else sClass = gfunGetAttribute(theObj, "class");
	}
	return sClass;
}

// -------------------------------------------------------------------
// gfunAppendClass(obj, sClass)// Appends a Class to an Element if it isn't already part of it// -------------------------------------------------------------------
function gfunAppendClass(obj, sClass) {
	var theObj = g_getRawObject(obj);
	var sNewClass = gfunGetClass(theObj);
	if (sNewClass == "" || sNewClass == null) sNewClass = sClass;
	else if (sNewClass.indexOf(sClass) == -1) sNewClass = sNewClass + " " + sClass;
	gfunSetClass(theObj, sNewClass);
}

// -------------------------------------------------------------------
// gfunRemoveClass(obj, sClass)// Removes a Class to an Element// -------------------------------------------------------------------
function gfunRemoveClass(obj, sClass) {
	var theObj = g_getRawObject(obj);
	var sNewClass = gfunGetClass(theObj);
	if (sNewClass != null && sNewClass != "") {
    	if (sNewClass.indexOf(sClass) >= 0) {
            var re = new RegExp("(\s*" + sClass + "\s+)|(\s*" + sClass + "$)", "gi");
            sNewClass = sNewClass.replace(re, "");
        }
    	gfunSetClass(theObj, sNewClass);
    }
}

// -------------------------------------------------------------------
// gfunGetAttribute(obj, sAttribute)// Returns the Attribute value for a custom Attribute// -------------------------------------------------------------------
function gfunGetAttribute(obj, sAttribute) {
	var theObj = g_getRawObject(obj);
	
	if (theObj != null) {
		if (theObj.getAttribute) if (theObj.getAttribute(sAttribute) != null) return theObj.getAttribute(sAttribute);
		if (theObj.getAttributeNode) if (theObj.getAttributeNode(sAttribute) != null)  return theObj.getAttributeNode(sAttribute).value;
		if (theObj.attributes) if (theObj.attributes.getNamedItem) if (theObj.attributes.getNamedItem(sAttribute)) return theObj.attributes.getNamedItem(sAttribute).value;
		if (theObj[sAttribute] != null) return theObj[sAttribute];
	}
	return null;
}

// -------------------------------------------------------------------
// gfunGetKeyCode(evt)// Utility function to return the key code of the key pressed by user// -------------------------------------------------------------------
function gfunGetKeyCode(evt) {
	var iKeyCode;
	if (!evt) evt = window.event;
	if (evt.keyCode) iKeyCode = evt.keyCode;
	else if (evt.which) iKeyCode = evt.which;
	
	return iKeyCode;
}

// -------------------------------------------------------------------
// gfunOpenWindow(sURL, sWindowName, sParameters)//	Utility function to open a new window.
//	Returns a reference to this new window// -------------------------------------------------------------------
function gfunOpenWindow(sURL, sWindowName, sParameters) {
	// Set the default parameters if not specified
	if (sWindowName == null) sWindowName = "NewWindow";
	if (sParameters == null) sParameters = "";

	// Open the window and focus on it	
	var objNewWin = window.open(sURL, sWindowName, sParameters);
	if (objNewWin.focus) objNewWin.focus();

	// Return the new window object
	return objNewWin;
}

// -------------------------------------------------------------------
// gfunSwapImage(ImgageID, NewImage)
//	Replaces an Image with a new Image (for mouseovers)// -------------------------------------------------------------------
function gfunSwapImage(ImgageID, NewImage) {
	var objImage = g_getRawObject(ImgageID);
	if (objImage.src) objImage.src = (NewImage.src) ? NewImage.src : NewImage;
}


// -------------------------------------------------------------------
// gfunCancelEvent(evt)
//	Cancels an event// -------------------------------------------------------------------
function gfunCancelEvent(evt) {
	if (!evt && window.event) evt = window.event;
	if (evt.stopPropagation != null) evt.stopPropagation();
	if (evt.cancelable != null) evt.preventDefault();
	evt.cancelBubble = true;

	return false;
}


// -------------------------------------------------------------------
// gfunDynamicTextUpdate(obj, sInnerText)
//	Dynamically updates the inner text (NOT HTML!!) of an object// -------------------------------------------------------------------
function gfunDynamicTextUpdate(obj, sInnerText) {
	var theObj = g_getRawObject(obj);
	if (theObj) {
		if (theObj.replaceChild) {
			var objTextNode = document.createTextNode(sInnerText);
			if (theObj.childNodes.length > 0) theObj.replaceChild(objTextNode, theObj.firstChild);
			else theObj.appendChild(objTextNode);
		}
		else if (theObj.innerText != null) theObj.innerText = sInnerText;
	}
}

// -------------------------------------------------------------------
// gfunGetInnerText(obj)
// Gets the inner text (NOT HTML!!) of an object// -------------------------------------------------------------------
function gfunGetInnerText(obj) {
	var theObj = g_getRawObject(obj);
	if (theObj) {
		if (theObj.innerText != null) return theObj.innerText;
		else if (theObj.contentText != null) return theObj.contentText;
		else if (theObj.childNodes.length > 0) {
			var s = "";
			for (var i = 0; i < theObj.childNodes.length; i++) {
				if (theObj.childNodes[i].data != null) s += theObj.childNodes[i].data;
				else if (theObj.childNodes[i].childNodes.length > 0) s += gfunGetInnerText(theObj.childNodes[i]);
			}
			return s;
		}
	}
}


// -------------------------------------------------------------------
// gfunJavascriptMessageBox(sMessage)
// Shows a message and buttons: Yes, No, and Cancel// Calls a specified function when finished with values: "Yes", "No"// -------------------------------------------------------------------
function gfunJavascriptMessageBox(sMessage, sFunctionName) {
    if (g_getRawObject("gMsgBox")) {
        // Remove the Old one
        document.body.removeChild(g_getRawObject("gMsgBox"));
    }
    if (document.body.appendChild) {
        // Build the Box
        var objBoxBG = document.createElement("div");
		objBoxBG.setAttribute("id", "gMsgBox");
        objBoxBG.style.position = "absolute";
		objBoxBG.style.visible = "hidden";
        var nX = (window.gfunGetInsideWindowWidth == null) ? 200 : ((gfunGetInsideWindowWidth() / 2) - 200) + gfunGetScrollValueX();
        var nY = (window.gfunGetInsideWindowHeight == null) ? 300 : ((gfunGetInsideWindowHeight() / 2) - 100) + gfunGetScrollValueY();
        objBoxBG.style.textAlign = "center";
        objBoxBG.style.paddingLeft = nX;
        objBoxBG.style.paddingRight = nX;
        objBoxBG.style.paddingTop = nY;
        objBoxBG.style.paddingBottom = nY+200;
        objBoxBG.style.left = 0;
        objBoxBG.style.top = 0;
        objBoxBG.style.backgroundColor = "#fff";
        
        var objBox = document.createElement("div");
		objBox.style.width = 400;
		objBox.style.padding = 20;
        objBox.style.color = "#000";
        objBox.style.textAlign = "center";
        objBox.style.fontWeight = "bold";
        objBox.style.backgroundColor = "#CCC";
        objBox.style.borderTop = "solid 3px #EEE";
        objBox.style.borderLeft = "solid 3px #EEE";
        objBox.style.borderRight = "solid 3px #666";
        objBox.style.borderBottom = "solid 3px #666";
        objBox.style.position = "relative";

        // Build the message
        var objMessage = document.createElement("p");
		objMessage.setAttribute("id", "gMsgBoxText");
        objBox.appendChild(objMessage);

        // Build the Buttons
        var objButtons = document.createElement("div");
		gfunSetClass(objButtons, "gMsgBoxButtons");

		var objButton_Yes = document.createElement("input");
		objButton_Yes.setAttribute("id", "gMsgBoxBtnYes");
		objButton_Yes.setAttribute("type", "button");
        objButton_Yes.setAttribute("value", "Yes");
        objButton_Yes.setAttribute("onclick", sFunctionName + "('Yes');gfunHide('gMsgBox');");
        if (window.event) objButton_Yes.onclick = function() { eval(sFunctionName + "('Yes')");gfunHide('gMsgBox'); }
        if (objButton_Yes.attachEvent) objButton_Yes.attachEvent('onclick', function() { eval(sFunctionName + "('Yes')"); gfunHide('gMsgBox'); });
		objButton_Yes.style.margin = 10;
        objButtons.appendChild(objButton_Yes);

		var objButton_No = document.createElement("input");
		objButton_No.setAttribute("id", "gMsgBoxBtnNo");
		objButton_No.setAttribute("type", "button");
        objButton_No.setAttribute("value", "No");
        objButton_No.setAttribute("onclick", sFunctionName + "('No');gfunHide('gMsgBox');");
        if (window.event) objButton_No.onclick = function() { eval(sFunctionName + "('No')"); gfunHide('gMsgBox'); }
        if (objButton_No.attachEvent) objButton_No.attachEvent('onclick', function() { eval(sFunctionName + "('No')"); gfunHide('gMsgBox'); });
		objButton_No.style.margin = 10;
        objButtons.appendChild(objButton_No);

		var objButton_Cancel = document.createElement("input");
		objButton_Cancel.setAttribute("id", "gMsgBoxBtnCancel");
		objButton_Cancel.setAttribute("type", "button");
        objButton_Cancel.setAttribute("value", "Cancel");
        objButton_Cancel.setAttribute("onclick", "gfunHide('gMsgBox');");
        if (window.event) objButton_Cancel.onclick = function() { gfunHide('gMsgBox'); }
        if (objButton_Cancel.attachEvent) objButton_Cancel.attachEvent('onclick', function() { gfunHide('gMsgBox'); });
		objButton_Cancel.style.margin = 10;
        objButtons.appendChild(objButton_Cancel);

        objBox.appendChild(objButtons);
        objBoxBG.appendChild(objBox);
        
        document.body.appendChild(objBoxBG);
    }
    
    var objMessageBox = g_getObject("gMsgBox");
    if (objMessageBox) {
        gfunDynamicTextUpdate("gMsgBoxText", sMessage);
/*
        var objButtonYes = g_getObject("gMsgBoxBtnYes");
        if (objButtonYes) {
            var objButtonNo = g_getObject("gMsgBoxBtnNo");
            if (objButtonYes.setAttribute) {
                objButtonYes.setAttribute("onclick", sFunctionName + "('Yes');gfunHide('gMsgBox');");
                objButtonNo.setAttribute("onclick", sFunctionName + "('No');gfunHide('gMsgBox');");
            }
            if (window.event) {
                objButtonYes.onclick = function() { eval(sFunctionName + "('Yes')"); gfunHide('gMsgBox');};
                objButtonNo.onclick = function() { eval(sFunctionName + "('No')"); gfunHide('gMsgBox');};
            }
            if (objButtonYes.attachEvent) {
                objButtonYes.attachEvent("onclick", function() { eval(sFunctionName + "('Yes')"); gfunHide('gMsgBox');});
                objButtonNo.attachEvent("onclick", function() { eval(sFunctionName + "('No')"); gfunHide('gMsgBox');});
            }
            if (objButtonYes.addEventListener) {
                objButtonYes.addEventListener("click", function() { eval(sFunctionName + "('Yes')"); gfunHide('gMsgBox');});
                objButtonNo.addEventListener("click", function() { eval(sFunctionName + "('No')"); gfunHide('gMsgBox');});
            }
        }
*/
                      
    	gfunShow(objMessageBox);
    }
}


// -------------------------------------------------------------------
// gfunDoNothing()
//	Does Nothing at All. To be used as a Placeholder or to cancel an event// -------------------------------------------------------------------
function gfunDoNothing() {
	// Don't do a thing!
}

