function _gnxen(oNode){
	oNode=oNode.nextSibling;
	while(oNode!=null && oNode.nodeType!=1){
		oNode=oNode.nextSibling;
	}
	return oNode;
}

function _gaddhandler(oNode,sEvent,fpHandler){
	switch(_gdomb.bswitch){
		case 1:
			oNode.attachEvent(sEvent,fpHandler);
			break;
		case 2:
			var sEvt=sEvent.substring(2,sEvent.length);
			oNode.addEventListener(sEvt,fpHandler,true);
			break;
	}
}

function _gappStyles(){
	if(typeof(MDI._mdiStyleData)=="string"){
		if(!MDI._mdiStyleData.match("/")){
			return _gappPath() + MDI._mdiStyleData;
		}
		else{
			return MDI._mdiStyleData;
		}
	}
	return _gappPath() + "mdiStyles.xml";
}
function _gappPath(){
	return (typeof(MDI._mdiAppPath)=="string")?MDI._mdiAppPath:"";
}
function _gimgPath(){
	return location.protocol + "//" + location.host + (typeof(MDI._mdiImgPath)=="string")?MDI._mdiImgPath:"";
}

function _gevt(oEvent){
	return (typeof(event)=="object")?event:oEvent;
}
function _gevt_dest(oEvent){
	var oSource=_gevt(oEvent);
	if(oSource==null){
		alert('Bad Event Reference');
		return null;
	}
	return (oSource.relatedTarget)?oSource.relatedTarget:oSource.toElement;	
}
function _gevt_src(oEvent){
	var oSource=_gevt(oEvent);
	if(oSource==null){
		alert('Bad Event Reference');
		return null;
	}
	return (oSource.target)?oSource.target:oSource.srcElement;
}

function _gid(sID){
	return _gdocument.getElementById(sID);
}

var _guidCount=0;
function _guid(){
	var vRet="_du_gui_" + _guidCount;
	_guidCount++;
	return vRet;
}

function _gunid(){
	var oDate=new Date();
	var sTime=new String(oDate.getTime());
	sTime=sTime.substring(sTime.length - 7,sTime.length);
	var iOffset=4;
	var sRand=new String(parseInt(Math.random() * (1000 * iOffset)));
	var iRandLen=sRand.length;
	for(var x=0;x <iOffset - iRandLen;x++) sRand="0" + sRand;
	return (sTime + "x" + sRand);
}

function _gxd(sPath,sID){
	/*
		An ID, hopefully unique, is passed in, and is used so the caller knows if they should accept the value.
	*/
	if(httpRequestID != null){
		window.setTimeout("_gxd('" + sPath + "','" + sID + "')",100);
/*		alert("fix async prob with Mozilla .. can't load " + sPath + " right now.");*/
		return;
	}
	if(_gdomb.bswitch==1){
		var oXML=new ActiveXObject("MSXML.DOMDocument");
		oXML.validateOnParse=true;
		oXML.async=false;
		oXML.load(sPath);
		var vRet=null;
		if(oXML.parseError.errorCode == 0){
			vRet=oXML.documentElement;
		}
		else{
			alert("Could not load " + sPath);
		}
		CEH.fireEvent("loadXml",{"xdom":vRet,"id":sID});
	}
	if(_gdomb.bswitch==2){
		var oExp=new RegExp("^/");
		if(!sPath.match(oExp)){
			var sMod=location.pathname;
			sMod=sMod.substring(0,sMod.lastIndexOf("/")+1);
			sPath=sMod + sPath;
		}
		sPath=location.protocol + "//" + location.host + sPath;
		httpRequestID=sID;
		httpRequest = new XMLHttpRequest();
		httpRequest.addEventListener("load",_gprd,false);
		httpRequest.open('GET', sPath);
		httpRequest.send(null);
	}
}
var httpRequest;
var httpRequestID=null;
function _gprd(evt){
	vRet=httpRequest.responseXML.documentElement;
	CEH.fireEvent("loadXml",{"xdom":vRet,"id":httpRequestID});
	httpRequestID=null;
}
function _gx_serialize(oNode){
	var sRet=null;
	switch(_gdomb.bswitch){
		case 1:
			sRet=oNode.xml;
			break;
		case 2:
			var oSerializer = new XMLSerializer();
			sRet=oSerializer.serializeToString(oNode);
			break;
	}
	return sRet;
}
function _gdombrowser(){

	this.ver=0;
	this.type=0;
	this.bswitch=0;
	if(navigator.appName.match(/microsoft internet explorer/i)){
		this.type="ie";
		if(navigator.appVersion.match(/MSIE\s?([\d\.]*)/)){
			this.ver=parseFloat(navigator.appVersion.match(/MSIE\s?([\d\.]*)/)[1]);
		}
	}
	else if(navigator.appName.match(/netscape/i)){
		this.ver=parseFloat(navigator.appVersion);
		this.type="nav";
	}
	if(this.ver >= 5 && (this.type=="ie" || this.type=="nav")){
		if(this.type=="ie") this.bswitch=1;
		if(this.type=="nav") this.bswitch=2;
	}
}

function _gabs_top(oNode){
	var oCurrentNode=oNode;
	var iTop=0;
	while(oCurrentNode!=null && oCurrentNode.nodeName!="BODY"){
		iTop+=oCurrentNode.offsetTop;
		oCurrentNode=oCurrentNode.offsetParent;
	}
	return iTop;
}

function _gabs_left(oNode){
	var oCurrentNode=oNode;
	var iLeft=0;
	while(oCurrentNode!=null && oCurrentNode.nodeName!="BODY"){
		iLeft+=oCurrentNode.offsetLeft;
		oCurrentNode=oCurrentNode.offsetParent;
	}
	return iLeft;
}

function _goffsetClientHeight(oNode){
	var iRet=0;
	if(oNode){
		var iMod=parseInt(oNode.style.borderTopWidth) + parseInt(oNode.style.borderBottomWidth);
		if(!isNaN(iMod)){
			iRet += iMod;
		}
		iMod=parseInt(oNode.style.paddingTop) + parseInt(oNode.style.paddingBottom);
		if(!isNaN(iMod)){
			iRet += iMod;
		}

	}
	return iRet;

}
function _gmarginWidth(oNode){
	var iRet=0;
	if(oNode){
		var iMod=parseInt(oNode.style.marginLeft) + parseInt(oNode.style.marginRight);
		if(!isNaN(iMod)){
			iRet += iMod;
		}
	}
	return iRet;
}
function _gmarginHeight(oNode){
	var iRet=0;
	if(oNode){
		var iMod=parseInt(oNode.style.marginTop) + parseInt(oNode.style.marginBottom);
		if(!isNaN(iMod)){
			iRet += iMod;
		}
	}
	return iRet;
}

function _goffsetClientWidth(oNode){
	var iRet=0;
	if(oNode){
		var iMod=parseInt(oNode.style.borderLeftWidth) + parseInt(oNode.style.borderRightWidth);
		if(!isNaN(iMod)){
			iRet += iMod;
		}
		iMod=parseInt(oNode.style.paddingLeft) + parseInt(oNode.style.paddingRight);
		if(!isNaN(iMod)){
			iRet += iMod;
		}
	}
	return iRet;

}
function _gclientHeight(oNode){
	var iRet=0;
	if(oNode){
		var iHeight=oNode.offsetHeight;
		var iMod=parseInt(oNode.style.borderTopWidth) + parseInt(oNode.style.borderBottomWidth);
		if(!isNaN(iMod)){
			iHeight-=iMod;
		}
		iRet=iHeight;
	}
	return iRet;
}
function _gclientWidth(oNode){
	var iRet=0;
	if(oNode){
		var iWidth=oNode.offsetWidth;
		var iMod=parseInt(oNode.style.borderLeftWidth) + parseInt(oNode.style.borderRightWidth);
		if(!isNaN(iMod)){
			iWidth-=iMod;
		}
		iRet=iWidth;
	}
	return iRet;
}
var _gdomb=new _gdombrowser();

var _gdocument=document;
_gdocument._createElement=_gdocument.createElement;
