	var strColor = null;
    var oWindow = null;
	var strRowEnter = "#333333";
    var oDivMenu = null;
    var oHideMenus = null;
    function ShowMenu(oButton, oDiv, intWidth, intHeight) {
        HideMenus();
	    document.detachEvent("onclick", HideMenus);
	    clearTimeout(oHideMenus);
        ShowSelects(false);
	    oDiv.style.posLeft = findPosX(oButton) - intWidth;
	    oDiv.style.posTop = findPosY(oButton) - intHeight + 25;
	    oDiv.style.display = "inline";
        oDiv.parentElement.removeChild(oDiv);
        document.body.appendChild(oDiv);
	    oFrameMenu = Get("frmHelper");
	    oDivMenu = oDiv;
        setTimeout("SetHideMenus()",200);
        return false;
    }
    function SetHideMenus() {
	    document.attachEvent("onclick", HideMenus);
    }
    function HideMenus() {
	    document.detachEvent("onclick", HideMenus);
	    if (oDivMenu != null)
		    oDivMenu.style.display = "none";
        ShowSelects(true);
    }
    function HideSubMenu() {
    }
	function ShowSelects(bool) {
		var oChildren = document.body.all.tags("SELECT");
		for (ii=0; ii<oChildren.length; ii++) {
			if (bool)
				oChildren(ii).style.visibility = "visible";
			else
				oChildren(ii).style.visibility = "hidden";
		}
	}
    function findPosX(obj)
    {
	    var curleft = 0;
	    if (obj.offsetParent)
	    {
		    while (obj.offsetParent)
		    {
			    curleft += obj.offsetLeft
			    obj = obj.offsetParent;
		    }
	    }
	    else if (obj.x)
		    curleft += obj.x;
	    return curleft;
    }
    function findPosY(obj)
    {
	    var curtop = 0;
	    if (obj.offsetParent)
	    {
		    while (obj.offsetParent)
		    {
			    curtop += obj.offsetTop
			    obj = obj.offsetParent;
		    }
	    }
	    else if (obj.y)
		    curtop += obj.y;
	    return curtop;
    }
	function Get(strObject) {
	    var oObject = document.getElementById(strObject);
	    var oFrames = window.top.frames;
	    if (oObject == null && oFrames.length > 0) {
	        for (var ii=0; ii<oFrames.length; ii++) {
	            oObject = oFrames(ii).document.getElementById(strObject);
	            if (oObject != null)
	                break;
	        }
	    }
	    return oObject;
	}
    function AdminMouseOver(oRow) {
	    strColor = oRow.bgColor;
	    oRow.bgColor = strRowEnter;
	    oRow.style.cursor = "hand";
	    oRow.className = "cmwhite";
	    clearTimeout(oHideMenus);
    }
    function AdminMouseOut(oRow) {
	    oRow.bgColor = strColor;
	    oRow.style.cursor = "default";
	    oRow.className = "cmdefault";
	    clearTimeout(oHideMenus);
	    oHideMenus = setTimeout("HideMenus()",1000);
    }
    function OpenWindow(strType, oObject, strVar, boolWindow, strWidth, strHeight) {
	    if (boolWindow == true && oWindow != null && !oWindow.closed)
		    oWindow.close();
		if (oObject != null && oObject != "")
		    oObject = Get(oObject);
        else if (strType == "INSERTIMAGE") {
            if (boolWindow == false)
                window.open('/__demo/loading.htm?referrer=/__demo/image_browser.aspx?type=INSERT&' + strVar,"_blank","height=" + strHeight + ",width=" + strWidth + ",menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
        }
        else if (strType == "UPDATEIMAGE") {
            if (boolWindow == false)
                window.open('/__demo/loading.htm?referrer=/__demo/image_browser.aspx?type=UPDATE&' + strVar,"_blank","height=" + strHeight + ",width=" + strWidth + ",menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
        }
        else if (strType == "INSERTFLAG") {
            if (boolWindow == false)
                window.open('/__demo/loading.htm?referrer=/__demo/__sscms/manage_flag.aspx?type=INSERT&control=' + oObject.id,"_blank","height=" + strHeight + ",width=" + strWidth + ",menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
        }
        else if (strType == "INSERTLINK") {
            if (boolWindow == false)
                window.open('/__demo/loading.htm?referrer=/__demo/link_browser.aspx?type=INSERT&' + strVar,"_blank","height=" + strHeight + ",width=" + strWidth + ",menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
        }
        else if (strType == "UPDATELINK") {
            if (boolWindow == false)
                window.open('/__demo/loading.htm?referrer=/__demo/link_browser.aspx?type=UPDATE&' + strVar,"_blank","height=" + strHeight + ",width=" + strWidth + ",menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
        }
        else if (strType == "INSERTTABLE") {
            if (boolWindow == false)
                window.open('/__demo/loading.htm?referrer=/__demo/__sscms/manage_table.aspx?type=INSERT&' + strVar,"_blank","height=" + strHeight + ",width=" + strWidth + ",menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
        }
        else if (strType == "TABLEROW") {
            if (boolWindow == false)
                window.open('/__demo/loading.htm?referrer=/__demo/__sscms/manage_table_row.aspx' + strVar,"_blank","height=" + strHeight + ",width=" + strWidth + ",menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
        }
        else if (strType == "TABLECELL") {
            if (boolWindow == false)
                window.open('/__demo/loading.htm?referrer=/__demo/__sscms/manage_table_cell.aspx' + strVar,"_blank","height=" + strHeight + ",width=" + strWidth + ",menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
        }
        else if (strType == "COLOR") {
            if (boolWindow == false)
                window.open('/__demo/loading.htm?referrer=/__demo/__sscms/manage_color.aspx?control=' + strVar,"_blank","height=" + strHeight + ",width=" + strWidth + ",menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
        }
        return false;
    }
    var URL_Host ='http://' + window.location.hostname + '/';
    var URL_Dir = 'http://' + window.location.hostname +  window.location.pathname;
    URL_Dir = URL_Dir.substr(0,URL_Dir.lastIndexOf("/"));
    var URL = window.location.toString();
    function fixurl(strRef)
    {
	    if (strRef.substr(0,URL_Host.length)==URL_Host)
	    {
		    if(strRef.substr(0,URL_Dir.length)==URL_Dir)
		    {
			    if(strRef.substr(0,URL.length)==URL)
				    strRef =  strRef.substr(URL.length);
			    else
				    strRef =  strRef.substr(URL_Dir.length);
		    }
		    else
			    strRef = '/'+ strRef.substr(URL_Host.length);
	    }
	    return strRef; 
    }

    function cleanUp(oObject)
    {
	    for(ii = 0; ii <= oObject.all.tags('A').length -1; ii++) {               
		    oTemp = oObject.all.tags('A').item(ii);
		    oTemp.href= fixurl(oTemp.href);
	    }
	    for(ii = 0; ii <= oObject.all.tags('IMG').length -1; ii++) {               
		    oTemp = oObject.all.tags('IMG').item(ii);
		    oTemp.src = fixurl(oTemp.src);
	    }
    }
