    function triggerURL(strURL)
        {
            if (strURL != "")
            {
                self.location.href = strURL;
            }
        }

        var msgWindow = null;
        var newWindow = null;
        var sessionWindow = null;

        function helpOpen()
        {
            msgWindow = window.open('/cms/help.php','htmlHelpWindow','toolbar=no,width=550,height=400,directories=no,status=yes,scrollbars=yes,resize=no,menubar=no');
        }

        function showAvailableImages(formName,elementName,elementID,Image_Category_ID)
	    {
	            var extraParams = '';
	            if (Image_Category_ID)
	            {
	                extraParams = '&ACTION=display&IMAGE_CATEGORY_ID='+Image_Category_ID;
	            }
	            imageWindow = window.open('../../cms/image_selector.php?formName=' + formName + '&elementName=' + elementName + '&elementID=' + elementID + extraParams,'imageWindow','toolbar=no,width=550,height=350,directories=no,status=no,scrollbars=yes,resize=yes,menubar=no,left=10,top=10,screenX=10,screenY=10');
	            if(imageWindow != null && imageWindow.opener == null)
	            {
	                imageWindow.opener = window;
	            }
	            imageWindow.focus();
	    }


        function openSessionDataWindow()
        {
            sessionWindow = window.open('/cms/session_info.php','sessionWindow','toolbar=no,width=350,height=350,directories=no,status=no,scrollbars=yes,resize=yes,menubar=no,left=10,top=10,screenX=10,screenY=10');
            if(sessionWindow != null && sessionWindow.opener == null)
            {
                sessionWindow.opener = window;
            }
        }
        
        function toogleChildCheckboxes(objName)
        {
            var holderObj = document.getElementById(objName);
            
            for(i=0; i<holderObj.childNodes.length; i++){
                var obj = holderObj.childNodes[i];
                if (obj.tagName == 'INPUT' && obj.type == 'checkbox')
                {
                    obj.checked = !obj.checked;
                }
            }
            
        }
        
        function setChildCheckboxes(objTop, checked)
        {
            var childs = objTop.getElementsByTagName("INPUT");
            for(i=0; i<childs.length; i++){
                obj = childs[i];
                if (obj.type == 'checkbox'){
                    obj.checked = checked;
                }
            }
            return;
        }


    function FindObject(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=FindObject(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    // shows or hides an object dynamically. Set show to false to hide it.
    function ShowObject(objName, show)
    {
        obj = FindObject(objName);
        if (show)
        {
            obj.style.display = 'block';
        }
        else
        {
            obj.style.display = 'none';
        }
    }
    
    // toggles an objects visability dynamically
    function ToggleObject(objName)
    {
        obj = FindObject(objName);
        objIsHidden = (obj.style.display.indexOf('none') != -1);
        ShowObject(objName, objIsHidden);
        
        //if there is an object with objName+"Plus" then change its contents to a minus/plus
        objPlus = FindObject(objName+"Plus"); 
        if (objPlus != 'undefined')
        {
            plus = (objIsHidden) ? "-" : "+";            
            objPlus.innerHTML = plus;
        }
    }
        
    function getWindowHeight()
    {
        var x,y;
        if (self.innerHeight) // all except Explorer
        {
        	x = self.innerWidth;
        	y = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        	// Explorer 6 Strict Mode
        {
        	x = document.documentElement.clientWidth;
        	y = document.documentElement.clientHeight;
        }
        else if (document.body) // other Explorers
        {
        	x = document.body.clientWidth;
        	y = document.body.clientHeight;
        }
        return y;
    }
    
    function getWindowScrollHeight()
    {
        var x,y;
        if (self.pageYOffset) // all except Explorer
        {
        	x = self.pageXOffset;
        	y = self.pageYOffset;
        }
        else if (document.documentElement && document.documentElement.scrollTop)
        	// Explorer 6 Strict
        {
        	x = document.documentElement.scrollLeft;
        	y = document.documentElement.scrollTop;
        }
        else if (document.body) // all other Explorers
        {
        	x = document.body.scrollLeft;
        	y = document.body.scrollTop;
        }
        return y;
    }
    
    function MaximiseEdit(objName, title)
    {
    	mainBodyObj = FindObject('mainBody');
    	obj = FindObject(objName);
    	div = FindObject('divMaximiseEdit');
    	divTitle = FindObject('divMaximiseEditTitle');

    	frmMaximiseEdit.text.value = obj.value;
    	frmMaximiseEdit.fieldname.value = objName;
    	frmMaximiseEdit.origPagePosition.value = getWindowScrollHeight();
    	
    	mainBodyObj.style.display = 'none';
    	div.style.display = 'block';
    	divTitle.innerHTML = title;
    	resizeMaximiseEdit();
    	window.onresize = resizeMaximiseEdit;
    	paintDHTMLEditor();
    }
    
    function paintDHTMLEditor()
    {
        //delete any old editor
        if (document.getElementById("text___Frame"))
        {
            var holder = document.getElementById("text___Config").parentNode;
            holder.removeChild(document.getElementById("text___Config"));
            holder.removeChild(document.getElementById("text___Frame"));
        }
        //create new editor
        var oFCKeditor = new FCKeditor( 'text' ) ;
    	oFCKeditor.BasePath = "/ssi/fckeditor/" ;
    	oFCKeditor.Height = "95%" 
        oFCKeditor.Config['ToolbarSet'] =  'ESHCMS1';
        oFCKeditor.ReplaceTextarea();
        
    }
    
    function resizeMaximiseEdit()
    {
        div.style.height = getWindowHeight();
        frmMaximiseEdit.text.style.height = getWindowHeight()-60 + "px";
    }
    
    function applyMaximiseEdit()
    {
        obj = FindObject(frmMaximiseEdit.fieldname.value);
        cancelMaximiseEdit();
        if (frmMaximiseEdit.text.value == '<p></p>') {
            frmMaximiseEdit.text.value = '';
        }
        obj.value = frmMaximiseEdit.text.value;
	    previewObj = document.getElementById('previewDiv_'+frmMaximiseEdit.fieldname.value);
        if (previewObj) {
            previewObj.innerHTML = frmMaximiseEdit.text.value;
        }
    }
    
    function cancelMaximiseEdit()
    {
        divMaximiseEdit.style.display = 'none';
        mainBodyObj = FindObject('mainBody');
        mainBodyObj.style.display = 'block';
        window.scrollTo(0,frmMaximiseEdit.origPagePosition.value);
    }
    
    function submitMaximiseEdit(obj)
    {
        setTimeout("applyMaximiseEdit()", 100);
    }
    
    function openWindow(url, name, options)
    {
        var v = window.open(url, name, options);
        if (v)
        {
            v.focus();
        }
        else
        {
            alert ('You browser has disabled popup windows. Please enable them for this feature to function correctly.');
        }
    }
    
    function hasFormChanged(what) {
        var edited = false;
        var output = '';
        for (var i=0, j=what.elements.length; i<j; i++) {
            myType = what.elements[i].type;
            myName = what.elements[i].name;
            
            if (myType == 'checkbox' || myType == 'radio') {
                if (what.elements[i].checked != what.elements[i].defaultChecked) 
                {
                    edited = true;
                    output += myName + " ("+ myType + ")\n";
                }
                
            }
            if (myType == 'hidden' || myType == 'password' || myType == 'text' || myType == 'textarea') 
                if (what.elements[i].value != what.elements[i].defaultValue) {
                {
                    edited = true;
                    output += myName + " ("+ myType + ")\n";
                }
            }
            if (myType == 'select-one' || myType == 'select-multiple') {
                for (var k=0, l=what.elements[i].options.length; k<l; k++) {
                    if (what.elements[i].options[k].selected != what.elements[i].options[k].defaultSelected) 
                    {
                        edited = true;
                        output += myName + " ("+ myType + ")\n";
                    }
                }
            }
        }
        return edited;
    }
    
    function safeGo()
    {
        var newUrl = arguments[0];
        var title = '';
        
        if (arguments.length > 1) { title = " to view "+arguments[1]; }
        
        if (hasFormChanged(document.cms_generator_form) && document.cms_generator_form.borage_IgnoreChanges == null)
        {
            if (!confirm("Are you sure you want to leave this page"+title+"?\n\nYou have unsaved changes on this page that will be lost if you continue."))
            {
                return void(0);
            }
        }
        document.location.href = newUrl;
    }
    
    // BEGIN INSERT FILE =================================================================
           
                                    // F. Permadi 2005.
                                    // Highlights table row
                                    // Copyright (C) F. Permadi
                                    // This code is provided "as is" and without warranty of any kind.  Use at your own risk.
                                    
                                    
                                    
                                    // These variables are for saving the original background colors
                                    var savedStates=new Array();
                                    var savedStateCount=0;
                                    
                                    /////////////////////////////////////////////////////
                                    // This function takes an element as a parameter and 
                                    //   returns an object which contain the saved state
                                    //   of the element's background color.
                                    /////////////////////////////////////////////////////
                                    function saveBackgroundStyle(myElement)
                                    {
                                      saved=new Object();
                                      saved.element=myElement;
                                      saved.className=myElement.className;
                                      saved.backgroundColor=myElement.style["backgroundColor"];
                                      return saved;   
                                    }
                                    
                                    /////////////////////////////////////////////////////
                                    // This function takes an element as a parameter and 
                                    //   returns an object which contain the saved state
                                    //   of the element's background color.
                                    /////////////////////////////////////////////////////
                                    function restoreBackgroundStyle(savedState)
                                    {
                                      savedState.element.style["backgroundColor"]=savedState.backgroundColor;
                                      if (savedState.className)
                                      {
                                        savedState.element.className=savedState.className;    
                                      }
                                    }
                                    
                                    /////////////////////////////////////////////////////
                                    // This function is used by highlightTableRow() to find table cells (TD) node
                                    /////////////////////////////////////////////////////
                                    function findNode(startingNode, tagName)
                                    {
                                      // on Firefox, the TD node might not be the firstChild node of the TR node
                                      myElement=startingNode;
                                      var i=0;
                                      while (myElement && (!myElement.tagName || (myElement.tagName && myElement.tagName!=tagName)))
                                      {
                                        myElement=startingNode.childNodes[i];
                                        i++;
                                      }  
                                      if (myElement && myElement.tagName && myElement.tagName==tagName)
                                      {
                                        return myElement;
                                      }
                                      // on IE, the TD node might be the firstChild node of the TR node  
                                      else if (startingNode.firstChild)
                                        return findNode(startingNode.firstChild, tagName);
                                      return 0;
                                    }
                                    
                                    /////////////////////////////////////////////////////
                                    // Highlight table row.
                                    // newElement could be any element nested inside the table
                                    // highlightColor is the color of the highlight
                                    /////////////////////////////////////////////////////
                                    function altLolight(myElement, highlightColor)
                                    {
                                      var i=0;
                                      // Restore color of the previously highlighted row
                                      for (i; i<savedStateCount; i++)
                                      {
                                        restoreBackgroundStyle(savedStates[i]);          
                                      }
                                      savedStateCount=0;
                                    
                                      // To get the node to the row (ie: the <TR> element), 
                                      // we need to traverse the parent nodes until we get a row element (TR)
                                      // Netscape has a weird node (if the mouse is over a text object, then there's no tagName
                                      while (myElement && ((myElement.tagName && myElement.tagName!="TR") || !myElement.tagName))
                                      {
                                        myElement=myElement.parentNode;
                                      }
                                    
                                      // If you don't want a particular row to be highlighted, set it's id to "header"
                                      // If you don't want a particular row to be highlighted, set it's id to "header"
                                      if (!myElement || (myElement && myElement.id && myElement.id=="header") )
                                        return;
                                    		  
                                      // Highlight every cell on the row
                                      if (myElement)
                                      {
                                        var tableRow=myElement;
                                        
                                        // Save the backgroundColor style OR the style class of the row (if defined)
                                        if (tableRow)
                                        {
                                    	  savedStates[savedStateCount]=saveBackgroundStyle(tableRow);
                                          savedStateCount++;
                                        }
                                    
                                        // myElement is a <TR>, then find the first TD
                                        var tableCell=findNode(myElement, "TD");    
                                    
                                        var i=0;
                                        // Loop through every sibling (a sibling of a cell should be a cell)
                                        // We then highlight every siblings
                                        while (tableCell)
                                        {
                                          // Make sure it's actually a cell (a TD)
                                          if (tableCell.tagName=="TD")
                                          {
                                            // If no style has been assigned, assign it, otherwise Netscape will 
                                            // behave weird.
                                            if (!tableCell.style)
                                            {
                                              tableCell.style={};
                                            }
                                            else
                                            {
                                              savedStates[savedStateCount]=saveBackgroundStyle(tableCell);        
                                              savedStateCount++;
                                            }
                                            // Assign the highlight color
                                            //tableCell.style["backgroundColor"]=highlightColor; // DJC Replaced with following line
                                            tableCell.className = highlightColor;
                                    
                                            // Optional: alter cursor
                                            tableCell.style.cursor='default';
                                            i++;
                                          }
                                          // Go to the next cell in the row
                                          tableCell=tableCell.nextSibling;
                                        }
                                      }
                                    }
                                    
                                    /////////////////////////////////////////////////////
                                    // This function is to be assigned to a <table> mouse event handler.
                                    // If the element that fired the event is within a table row,
                                    //   this function will highlight the row.
                                    /////////////////////////////////////////////////////
                                    function altHilight(mEvent, highlightColor)
                                    {
                                      if (!mEvent)
                                        mEvent=window.event;
                                    		
                                      // Internet Explorer
                                      if (mEvent.srcElement)
                                      {
                                        altLolight(mEvent.srcElement, highlightColor);
                                      }
                                      // Netscape and Firefox
                                      else if (mEvent.target)
                                      {
                                        altLolight( mEvent.target, highlightColor);		
                                      }
                                    }
                                    
                                    /////////////////////////////////////////////////////
                                    // Highlight table row.
                                    // newElement could be any element nested inside the table
                                    // highlightColor is the color of the highlight
                                    /////////////////////////////////////////////////////
                                    function highlightTableRowVersionA(myElement, highlightColor)
                                    {
                                      var i=0;
                                      // Restore color of the previously highlighted row
                                      for (i; i<savedStateCount; i++)
                                      {
                                        restoreBackgroundStyle(savedStates[i]);          
                                      }
                                      savedStateCount=0;
                                    
                                      // If you don't want a particular row to be highlighted, set it's id to "header"
                                      if (!myElement || (myElement && myElement.id && myElement.id=="header") )
                                        return;
                                    		  
                                      // Highlight every cell on the row
                                      if (myElement)
                                      {
                                        var tableRow=myElement;
                                        
                                        // Save the backgroundColor style OR the style class of the row (if defined)
                                        if (tableRow)
                                        {
                                    	  savedStates[savedStateCount]=saveBackgroundStyle(tableRow);
                                          savedStateCount++;
                                        }
                                    
                                        // myElement is a <TR>, then find the first TD
                                        var tableCell=findNode(myElement, "TD");    
                                    
                                        var i=0;
                                        // Loop through every sibling (a sibling of a cell should be a cell)
                                        // We then highlight every siblings
                                        while (tableCell)
                                        {
                                          // Make sure it's actually a cell (a TD)
                                          if (tableCell.tagName=="TD")
                                          {
                                            // If no style has been assigned, assign it, otherwise Netscape will 
                                            // behave weird.
                                            if (!tableCell.style)
                                            {
                                              tableCell.style={};
                                            }
                                            else
                                            {
                                              savedStates[savedStateCount]=saveBackgroundStyle(tableCell);        
                                              savedStateCount++;
                                            }
                                            // Assign the highlight color
                                            //tableCell.style["backgroundColor"]=highlightColor;
                                            alert(tableCell.className);
                                            tableCell.className = highlightColor;
                                            alert(tableCell.className);
                                    
                                            // Optional: alter cursor
                                            tableCell.style.cursor='default';
                                            i++;
                                          }
                                          // Go to the next cell in the row
                                          tableCell=tableCell.nextSibling;
                                        }
                                      }
                                    }
    // END INSERT FILE =================================================================                                    
    
    function debugList(list)
    {
        var txt = '';
        for(i=0; i<list.length;i++){
            txt += "; " + list[i].value;
        }
        alert(txt);
    }
    
    function BORAGE_LOOKUP_OBJECT_Detach(fieldName, fieldValue, linkId)
    {
        
        var listObj;
        eval("listObj = document.cms_generator_form."+fieldName);
        
        // only delete form list if it is a list
        if (listObj.options)
        {
            // find position of value in list        
            var position = null;
            for (i=0; position == null && i<listObj.options.length; i++){
                if (listObj.options[i].value == fieldValue){
                    position = i;
                }
            }
            
            // delete from list
            listObj.options[position] = null;
            
            // delete table if none in it
            if (listObj.options.length == 0){
                var tableHolder = document.getElementById("div_tableHolder_"+fieldName);
                tableHolder.innerHTML = "";
                return;
            }
        }
        else
        {
            listObj.value = null;
            var tableHolder = document.getElementById("div_tableHolder_"+fieldName);                
            tableHolder.innerHTML = "";            
        }
        
        // delete from table:
        obj = document.getElementById(linkId);
        if (!obj){ return; };
        
        // find parent TR
        for (i=0; i<10 && obj.tagName != 'TR'; i++){
            obj = obj.parentNode;
            var tBody = obj.parentNode;
        }
        if (!tBody) { return void(0); }
        obj.parentNode.removeChild(obj);
        
        AltTableRefresh(tBody);
    }    
    
    function BORAGE_LOOKUP_OBJECT_Move(fieldName, fieldValue, linkId, up)
    {
        
        var listObj;
        eval("listObj = document.cms_generator_form."+fieldName);
        
        // find position of value in list        
        var position = null;
        for (i=0; position == null && i<listObj.options.length; i++){
            if (listObj.options[i].value == fieldValue){
                position = i;
            }
        }
        if (up && position > 0)
        {
            // swap values
            tmpText = listObj.options[position-1].text;
            tmpValue = listObj.options[position-1].value;
            listObj.options[position-1].text = listObj.options[position].text;
            listObj.options[position-1].value = listObj.options[position].value;
            listObj.options[position].text = tmpText;
            listObj.options[position].value = tmpValue;
            listObj.options[position].selected = true;
            listObj.options[position-1].selected = true;
            
            // move row
            MoveParentTableRow(document.getElementById(linkId), true)
            
        }else if (!up && position < listObj.options.length-1)
        {
            // swap values
            tmpText = listObj.options[position+1].text;
            tmpValue = listObj.options[position+1].value;
            listObj.options[position+1].text = listObj.options[position].text;
            listObj.options[position+1].value = listObj.options[position].value;
            listObj.options[position].text = tmpText;
            listObj.options[position].value = tmpValue;
            listObj.options[position].selected = true;
            listObj.options[position+1].selected = true;
            
            // move row
            MoveParentTableRow(document.getElementById(linkId), false)
            
        }
        else {
            alert("Item cannot move further in that direction");
        }
    }
    
    function BORAGE_Delete_Record(objectType, id, prev){
            if (confirm("Do you really want to permanantly delete this record?")){
                document.location = "?objectType="+objectType+"&mode=delete&id="+id+"&prev="+escape(prev);
            }
    }
    

    function MoveParentTableRow(obj, up)
    {
        // find parent TR
        for (i=0; i<10 && obj.tagName != 'TR'; i++){
            obj = obj.parentNode;
            var tBody = obj.parentNode;
        }
        if (!tBody) { return void(0); }
        var newNode = MoveTableRow(obj, up);
        AltTableRefresh(tBody);
    }
  
    function AltTableRefresh(tableObj)
    {
        // redo css in table
        
        // for each ROW
        var TRs = tableObj.getElementsByTagName("TR");
        
        // ignore ROWS not directly in this table
        var tmpTRs = Array();
        for (var k=0; k<TRs.length; k++){
        	// walk up tree until we hit a table
        	obj = TRs[k];
        	while(obj.tagName != 'TABLE' && obj.parentNode){
        		obj = obj.parentNode;        		
        		if (obj && obj == tableObj){
        			tmpTRs[tmpTRs.length] = TRs[k];
        			
        		}
        	}
        }
        //alert("orig:"+TRs.length+" now:"+tmpTRs.length);
        TRs = tmpTRs;
        var tmp = "classes: ";
        
        for (var i=0; i<TRs.length; i++) {
            var tr = TRs[i];
            var TDs = tr.getElementsByTagName("TD");
            
                       
            
            for (var j=0; j<TDs.length; j++)
            {
                var td = TDs[j];
                tmp += "|    "+td.className;
                if (td.className.indexOf("alt2")!=-1 || td.className.indexOf("alt1")!=-1 || td.className.indexOf("altHilight")!=-1) {
                    //alert("i="+i+"; " + (i % 2));
                    if ((i % 2) == 0){
                        td.className = td.className.replace(/alt2/,"alt1");
                        td.className = td.className.replace(/altHilight/,"alt1");
                    }
                    else{
                        td.className = td.className.replace(/alt1/,"alt2");
                        td.className = td.className.replace(/altHilight/,"alt2");
                    }
                }
            }
        }
        
    }
  
    function MoveTableRow(obj, up)
    {

        var newTr;
        if (up && obj.sectionRowIndex > 1){
            var newTr = obj.parentNode.insertRow(obj.sectionRowIndex - 1);
    	    for(i=0; i<obj.childNodes.length; i++) {
    	        newTr.appendChild(obj.childNodes[i].cloneNode(true));
    	    }
    	    obj.parentNode.removeChild(obj);
        }
        
        if (!up && obj.sectionRowIndex < obj.parentNode.getElementsByTagName("TR").length){
            
            var newTr = obj.parentNode.insertRow(obj.sectionRowIndex + 2);
    	    for(i=0; i<obj.childNodes.length; i++) {
    	        newTr.appendChild(obj.childNodes[i].cloneNode(true));
    	    }
    	    obj.parentNode.removeChild(obj);
        }
        return newTr;
    }
    
    function BORAGE_LOOKUP_OBJECT_Append(fieldName, value, popupWindow, divId, oneOnly)
    {
        
        // disable link now we clicked it
        linkObj = popupWindow.document.getElementById("other_"+divId);
        if (linkObj) {
            linkObj.disabled = true;
        }
        
        if (oneOnly)
        {
            // detach existing one before going on
            var field = eval("document.cms_generator_form."+fieldName);
            if (field.value) {
                BORAGE_LOOKUP_OBJECT_Detach(fieldName, value, "linkDel_"+field.value)
            }
            field.value = value;
            popupWindow.close();
        }
        else
        {
            // check that item does not already exist in list
            var listObj = eval("document.cms_generator_form."+fieldName);
            
            var position = null;
            for (i=0; position == null && i<listObj.options.length; i++){
                if (listObj.options[i].value == value){
                    position = i;
                }
            }
            if (position != null){
                popupWindow.alert("That item already exists in your list. Not added.");
                return;
            } 
        
            // add to list
            listObj.options[listObj.options.length] = new Option(value,value);
            listObj.options[listObj.options.length - 1].selected = true;
        }
            
            
            
            
            
            // find parent TR of click in popup
            var divObj = popupWindow.document.getElementById(divId);
            var obj = divObj;
            for (i=0; i<10 && obj.tagName != 'TR'; i++){
                obj = obj.parentNode;
                var tBody = obj.parentNode;
            }
            if (!tBody) { alert("Sorry, there was a problem selecting your item."); return void(0); }
            var tr = obj;
            
            
            // make sure table exists first
            var table = document.getElementById(fieldName+"_table");
            if (table == null) {
                
                // create a blank table based on table from popup search result
                var tmpnewTable = document.createElement("table");
                var tmpnewTr = tmpnewTable.insertRow(0);
                
                
                var popupTable = tr.parentNode.parentNode;
                var popupTRs = tr.parentNode.parentNode.getElementsByTagName("TR");
                var popupTDs = popupTRs[0].getElementsByTagName("TH");
                
                for (i=0; i<popupTDs.length; i++){
                    var tmpnewTd = document.createElement("TH");
                    
                    tmpnewTd.className = popupTDs[i].className;
                    tmpnewTd.onmouseover = popupTDs[i].onmouseover;
                    tmpnewTd.onmouseout = popupTDs[i].onmouseout                        
                    tmpnewTd.innerHTML = popupTDs[i].innerHTML;
                    
                    tmpnewTr.appendChild(tmpnewTd);
                    
                }
                
                tmpnewTable.width = popupTable.width;
                tableHolder = document.getElementById("div_tableHolder_"+fieldName);
                
                tableHolder.innerHTML = "<table cellspacing=1 cellpadding=3 width=100% id="+fieldName+"_table>"+tmpnewTable.innerHTML+"</table>"; 
                table = document.getElementById(fieldName+"_table");
                
                table.style.clear = "both";
                table.style.width = popupTable.style.width;
                table.className = popupTable.className;
                table.onmouseover = popupTable.onmouseover;
                table.onmouseout = popupTable.onmouseout;
            }
            
            // append new TR to opener's table            
            var tBody = table.getElementsByTagName('TBODY')[table.getElementsByTagName('TBODY').length-1];
            
            var table = document.getElementById(fieldName+'_table');
            var tBody = table.getElementsByTagName('TBODY')[table.getElementsByTagName('TBODY').length-1];
            var newTr = tBody.insertRow(tBody.getElementsByTagName('TR').length);
            newTr.onmouseover = tr.onmouseover;
            newTr.onmouseout = tr.onmouseout;
            
                                
            // copy TDs of clicked row from popup
            var TDs = tr.getElementsByTagName('TD');
            for (i=0; i < TDs.length ; i++){
                var td = document.createElement('td');
                td.innerHTML = TDs[i].innerHTML;
                td.className = TDs[i].className;
                //td.style = TDs[i].style;
                td.onMouseOver = TDs[i].onMouseOver;
                td.onMouseOut = TDs[i].onMouseOut;
                var newTd = newTr.appendChild(td);
                newTd = TDs[i].cloneNode(true);
            }
                    
                    
            // get hidden version of last TD and use that instead
            divObj = document.getElementById(divId);
            divObj.style.display = "block";
            divObj = document.getElementById("other_"+divId);
            divObj.style.display = "none";
            
            AltTableRefresh(table);
    }
    
    function getUrl(url) {
         if ('undefined' == typeof(url)) return false;
         var p,rnd;
         if (document.all){
           // For IE, create an ActiveX Object instance 
           p = new ActiveXObject("Microsoft.XMLHTTP");
         } 
         else {
           // For mozilla, create an instance of XMLHttpRequest.
           p = new XMLHttpRequest();
         }
         // Prevent browsers from caching the included page
         // by appending a random  number
         rnd = Math.random().toString().substring(2);
         url = url.indexOf('?')>-1 ? url+'&rnd='+rnd : url+'?rnd='+rnd;
         // Open the url and write out the response
         p.open("GET",url,false);
         p.send(null);
         return p.responseText;
    }

    function BORAGE_SaveAndGo($url){
        document.cms_generator_form.BORAGE_SUBACTION.value = 'saveAndGoto|'+$url;
        document.cms_generator_form.submit();
    }
    
    function BORAGE_SaveAndPopup($url, $options){
        if (!$options || $options == 'undefined'){$options = ''};
        document.cms_generator_form.BORAGE_SUBACTION.value = 'saveAndPopup|'+$url+"|"+$options;
        document.cms_generator_form.submit();
    }
    
    function BORAGE_textFieldEditPopup($name, $niceName)
    {
    	var fieldName = $name;
    	var value = document.getElementById($name).value;
    	
    	var windowString = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Edit '+$niceName+'</title> </head> <style> body{font-size:10pt;background-color:#F0F0F0; 	margin: 0px; 	padding: 10px; 	font-family:Arial, Helvetica, sans-serif; 	text-align: right; } </style> <body><div align=left>Enter <b>'+$niceName+'</b> and click OK to continue:<br><br></div> <form name=form1><textarea name=text1 style="width: 100%; height: 300px; margin-bottom: 5px" tabindex=1>'+value+'</textarea> </form> <input name="button2" type="button" onclick="window.close()" value="Cancel"/> <input name="button" type="button" value="  OK  " onClick="opener.BORAGE_textFieldEditPopup_Apply(\''+fieldName+
    	'\', document.form1.text1.value, window)"/> </body> </html> '; 	 	
    	
    	
    	
    	var Window_BORAGE_Text_Popup = window.open('', "", "width=420,height=410,resize=yes,modal=yes");
    	    	
    	Window_BORAGE_Text_Popup.document.write(windowString);
    	
    	
    	Window_BORAGE_Text_Popup.focus;
    	Window_BORAGE_Text_Popup.document.close() 
    	
    }
    
    function BORAGE_textFieldEditPopup_Apply(name, value, windowObj)
    {
    	document.getElementById("BORAGE_Text_Popup_"+name).innerHTML = value.replace(/\n/g, "<br />");
    	document.getElementById(name).value = value;
    	windowObj.close();
    }
	
	
	function help()
	{
            msgWindow = window.open('data_storage/docs/Greenfly_quickstart_v1.pdf','help','toolbar=no,width=690,height=590,directories=no,status=yes,scrollbars=yes,resize=yes,menubar=no');
	}