var NODE_ELEMENT				= 1;

var NODE_ATTRIBUTE				= 2;

var NODE_TEXT					= 3;

var NODE_CDATA_SECTION			= 4;

var NODE_ENTITY_REFERENCE		= 5;

var NODE_ENTITY					= 6;

var NODE_PROCESSING_INSTRUCTION	= 7;

var NODE_COMMENT				= 8;

var NODE_DOCUMENT				= 9;

var NODE_DOCUMENT_TYPE			= 10;

var NODE_DOCUMENT_FRAGMENT		= 11;

var NODE_NOTATION				= 12;



function ESCFNode(objXMLNode)

{

	this.CheckXMLNode = function(objNode)

	{

		var bOK = false;

		try {

			if(objNode != null && typeof(objNode) != "undefined" && objNode.nodeType != null && typeof(objNode.nodeType) != "undefined" && !(isNaN(objNode.nodeType))) bOK = true;

		} catch(e) { bOK = false; }

		return bOK;	

	}



	this.GetName = function()

	{

		if(!this.CheckXMLNode(objXMLNode)) return "";

		return objXMLNode.nodeName;

	}



	this.GetValue = function()

	{

		if(!this.CheckXMLNode(objXMLNode) || objXMLNode.nodeType != NODE_TEXT) return "";

		return objXMLNode.nodeValue;

	}



	this.GetType = function()

	{

		if(!this.CheckXMLNode(objXMLNode)) return -1;

		return objXMLNode.nodeType;

	}



	this.GetAttribute = function(strName)

	{

		if(!this.CheckXMLNode(objXMLNode) || objXMLNode.nodeType != NODE_ELEMENT) return "";

		return objXMLNode.getAttribute(strName);

	}



	this.ChildGetNum = function()

	{

		if(!this.CheckXMLNode(objXMLNode)) return 0;

		return objXMLNode.childNodes.length;

	}



	this.ChildGetIndex = function(nIndex)

	{

		if(!this.CheckXMLNode(objXMLNode)) return null;

		return new ESCFNode(objXMLNode.childNodes.item(nIndex));

	}



	this.ChildGetByName = function(strName)

	{

		if(!this.CheckXMLNode(objXMLNode)) return null;

		for(var i = 0; i < objXMLNode.childNodes.length; ++i) {

			var s = objXMLNode.childNodes.item(i).nodeName;

			if(s.toUpperCase() == strName.toUpperCase()) return new ESCFNode(objXMLNode.childNodes.item(i));

		}

		return null;

	}



	this.GetFirstText = function()

	{

		if(!this.CheckXMLNode(objXMLNode)) return "";

		if(this.GetType() == NODE_TEXT) return this.GetValue();

		for(var i = 0; i < this.ChildGetNum(); ++i) {

			var s = this.ChildGetIndex(i).GetFirstText();

			if(s != "") return s;

		}

		return "";

	}

}



function ESCFListener(strChannelId, objFunction)

{

	this.strChannelId	= strChannelId;

	this.objFunction	= objFunction;

}



var g_ESCFMessageListeners = new Array();



function ESCF()

{

	this.XMLDoc		= null;



	this.GetRef = function(strId)

	{

		return (document.all) ? document.all[strId] : document.getElementById(strId);

	}



	this.QuoteHtmlAttribute = function(str)

	{

		str += "";

		str = str.replace(/\&/g, "&amp;");

		str = str.replace(/\</g, "&lt;");

		str = str.replace(/\>/g, "&gt;");

		str = str.replace(/\"/g, "&quot;");

		str = str.replace(/\'/g, "&#39;");

		return str;

	}

	

	this.LayerWrite = function(strId, strHtml)

	{

		var obj = this.GetRef(strId);

		if(obj == null || typeof(obj) == "undefined") return;

		obj.innerHTML = strHtml;

	}



	this.SwitchImage = function(strId, strFileName)

	{

		var objImage = this.GetRef(strId);

		if(objImage == null || typeof(objImage) == "undefined") return;

		objImage.src = strFileName;

	}



	this.CreateDateFromInternalFormatString = function(str)

	{

		var arr = str.split(",");

		if(arr.length != 6) return new Date();

		return new Date(arr[0], parseInt(arr[1]) - 1, arr[2], arr[3], arr[4], arr[5]); 

	}



	this.Fix2Digits = function(str)

	{

		str += "";

		return (str.length < 2 ? "0" + str : str);

	}



	this.IsAdminLoggedOn = function()

	{

		return (document.cookie + "").search(/AdminLoginOkSessionId=true/i) != -1;

	}



	this.MessageSend = function(strChannelId, strFromId, strCmd, nParam, strParam, objParam)

	{

		if(window.opener && typeof(window.opener.g_ESCFMessageListeners) != "undefined")

			g_ESCFMessageListeners = window.opener.g_ESCFMessageListeners;

		for(var i = 0; i < g_ESCFMessageListeners.length; ++i) {

			if(strChannelId == g_ESCFMessageListeners[i].strChannelId)

				g_ESCFMessageListeners[i].objFunction(strChannelId, strFromId, strCmd, nParam, strParam, objParam);

		}

	}



	this.MessageListenerAdd = function(strChannelId, objFunction)

	{

		g_ESCFMessageListeners[g_ESCFMessageListeners.length] = new ESCFListener(strChannelId, objFunction);

	}		

		

	this.IsAjaxEnabled = function()

	{

		var bOK = false;

		try {

			var objHttpXmlRequest = null;

			if(window.XMLHttpRequest) {		// If IE7, Mozilla, Safari, etc: Use native object

				objHttpXmlRequest = new XMLHttpRequest();

			} else {

				if(window.ActiveXObject) {	// ...otherwise, use the ActiveX control for IE5.x and IE6

					objHttpXmlRequest = new ActiveXObject("Microsoft.XMLHTTP");

				}

			}

			bOK = objHttpXmlRequest != null;

			objHttpXmlRequest = null;

		} catch(e) { bOK = false; }

		return bOK;

	}



	this.NodeGetRoot = function()

	{

		return new ESCFNode(this.XMLDoc);

	}



	this.NodesGetByTagName = function(strTagName)

	{

		var arr = new Array();

		if(this.XMLDoc == null) return arr;

		var objItems = this.XMLDoc.getElementsByTagName(strTagName);

		for(var i = 0; i < objItems.length; ++i) {

			arr[i] = new ESCFNode(objItems.item(i));

		}

		return arr;

	}



	this.FormGetQuerystring = function(strFormId)

	{

		var objForm = this.GetRef(strFormId);

		if(objForm == null || typeof(objForm) + "" == "undefined") return "";



		var strRet = "";

		// Extract the name and value for each form element

		for(var i = 0; i < objForm.elements.length; ++i) {

			var objElement = objForm.elements[i];

			switch(objElement.type + "") {

				case "text":

				case "hidden":

				case "password":

				case "textarea":

					strRet += "&" + objElement.name + "=" + encodeURIComponent(objElement.value);

					break;



				case "select-one":

				case "select-multiple":

					for(var j = 0; j < objElement.options.length; ++j) {

						strRet += objElement.options[j].selected ? "&" + objElement.name + "=" + encodeURIComponent(objElement.options[j].value) : "";

					}

					break;



				case "checkbox":

				case "radio":

					strRet += objElement.checked ? "&" + objElement.name + "=" + encodeURIComponent(objElement.value) : "";

					break;

			}

		}

		if(strRet.substr(0, 1) == "&") strRet = strRet.substr(1);

		return strRet;

	}



	this.DoRequest = function(strMethod, strUrl, strData)

	{

		this.XMLDoc = null;

		var objHttpXmlRequest = null;

		if(window.XMLHttpRequest) {		// If IE7, Mozilla, Safari, etc: Use native object

			objHttpXmlRequest = new XMLHttpRequest();

		} else {

			if(window.ActiveXObject) {	// ...otherwise, use the ActiveX control for IE5.x and IE6

				objHttpXmlRequest = new ActiveXObject("Microsoft.XMLHTTP");

			}

		}



		objHttpXmlRequest.open(strMethod.toUpperCase(), strUrl, false);

		if(strMethod.search(/POST/i) == 0) {

			objHttpXmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

		}

		objHttpXmlRequest.send(strData);



		if(objHttpXmlRequest.status == 200) {

			this.XMLDoc = objHttpXmlRequest.responseXML;

		}

		return this.XMLDoc != null;

	}



	this.DoRequestPostForm = function(strFormId, strUrl)

	{

		return this.DoRequest("POST", strUrl, this.FormGetQuerystring(strFormId));

	}

}



function EscfSwitchImage(strId, strFilename)

{

	var objESCF = new ESCF();

	objESCF.SwitchImage(strId, strFilename);

}



function escf_tb()

{

	try {

		var obj = new ESCF();

		if(obj.IsAdminLoggedOn()) {

			document.write("<div style=\"background-image:url(admin/img/essf_adminbar_bg.jpg);background-repeat:repeat-x;background-position:center top;height:45px;\">");

			document.write("	<table style=\"width:100%;\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");

			document.write("		<tr>");

			document.write("			<td style=\"width:270px;height:45px;\"><img src=\"admin/img/essf_admin_logo.jpg\" width=\"295\" height=\"45\" alt=\"\" title=\"\" /></td>");

			document.write("			<td style=\"text-align:right\"><a href=\"http://tiw-pro.web.internet.telia.com/~2061025/admin/index.php?logoff=yes\"><img src=\"admin/img/essf_adminbar_btn_logoff.jpg\" width=\"112\" height=\"45\" alt=\"Logga ut\" title=\"Logga ut\" id=\"EssfLogOff\" onmouseover=\"EscfSwitchImage('EssfLogOff', 'admin/img/essf_adminbar_btn_logoff_o.jpg');\" onmouseout=\"EscfSwitchImage('EssfLogOff', 'admin/img/essf_adminbar_btn_logoff.jpg');\" /></td>");

//			document.write("			<td style=\"width:244px;height:45px;\"><a href=\"http://www.effectivestudios.se\"><img src=\"admin/img/essf_adminbar_logo.jpg\" width=\"244\" height=\"45\" alt=\"Gå till Effective Studios\" title=\"Gå till Effective Studios\" /></a></td>");

			document.write("		</tr>");

			document.write("	</table>");

			document.write("</div>");

		}

	} catch (e) {}

}