
// Set up the variables

// the selected variables show which item, and from which section, has been selected.
var selectedSection = "";
var selectedSubSection = "";
var selectedID = 0;
var selectedSubID = 0;
var selectedName = "";
var selectedSubName = "";

// the higlightedID is the ID of the currently highlighted item. when selecting an item, there is a brief period when the selected item is not the highlighted item.
var autoRefresh = "1";
var bodyTag = "";
var clientMessages = "";
var CLIENTMESSAGES_REFRESH = 0;
var colorPickerObj = "";
var deploymentMethod = "";
var dragOverID = "";
var dragOverOrderID = "";
var explorerPanelWidth = 0;
var explorerPanelStartWidth = 0;
var fieldNumber = 0;
var highlightedID = 0; 
var highlightedObj = null;
var highlightedSection = "";
var highlightedElementStr = "";
var highlightedElementBorder = "";
var isDefaultSite = 0;
var unsavedChanges = 0;
var popupType = "";
var popupID = "";
var popupField = "";
var popupWin = "";
var RoleID = 0;
var siteRoot = 0;
var SITE_ROOT = "";
var tempVar = "";
var UserID = 0;
var Username = "";
var ClientID = 0;



// the current variables are used to keep in memory where the user was last, so that when they return to this section, they go back to the same place they were at last.
var currentActiveWindow = "";
var currentBlock = "";
var currentBlockName = "";
var currentBlockTemplate = "";
var currentBlockTemplateName = "";
var currentBlockTemplateCategory = "";
var currentBlockTemplateCategoryName = "";
var currentBlockVersion = "";
var currentBlockVersionName = "";
var currentEmail = "";
var currentEmailName = "";
var currentEmailDelivery = "";
var currentEmailDeliveryName = "";
var currentEvent = "";
var currentExplorerSection = "";
var currentField = "";
var currentFieldName = "";
var currentFile = "";
var currentFileName = "";
var currentFileCategory = "";
var currentFileCategoryName = "";
var currentHour = "";
var currentID = "";
var currentImage = "";
var currentImageName = "";
var currentImageCategory = "";
var currentImageCategoryName = "";
var currentItem = "";
var currentLayout = "";
var currentList = "";
var currentListName = "";
var currentOrder = "";
var currentOrderName = "";
var currentOrderCategory = "";
var currentOrderCategoryName = "";
var currentPage = "";
var currentPageName = "";
var currentPageTemplate = "";
var currentPageTemplateName = "";
var currentPageTemplateCategory = "";
var currentPageTemplateCategoryName = "";
var currentRole = "";
var currentRoleName = "";
var currentSection = "";
var currentSubSection = "";
var currentSite = "";
var currentSiteName = "";
var currentSubItem = "";
var currentTab = "";
var currentTemplate = "";
var currentTemplateName = "";
var currentTreeID = "";
var currentType = "";
var currentTypeName = "";
var currentUser = "";
var currentUserName = "";
var currentUsers = "";




function abortAction(){
	if (getDocumentVar("unsavedChanges") == "1"){
		confirm1 = confirm("The current "+currentSection+", "+currentItem+", has not been saved. If you continue all changes will be lost.\n\nAre you sure you want to continue without saving?");
		if (confirm1){
			markSaved();
			return false;
		} else {
			return true;
		}
	}
} // end abort action



function cancelEvent() {
	eval(currentActiveWindow+".event.returnValue = false;");
}



function doBeforeUnload(){
	confirm1 = "";
	if (window.top.getDocumentVar("unsavedChanges") == 1){
		return "The current "+window.top.getDocumentVar("currentSection")+", "+window.top.getDocumentVar("currentItem")+", has not been saved. If you continue all changes will be lost.";
	}
} // end before unload


function doBodyOnFocus(){
	if(getDocumentVar("popupID") > ""){
		// we are using modal popups, so don't need this
//		window.document.popupWin.focus();
	}
}


function doBodyOnUnload(){
	// the warning message for unsavedChanges could occur twice , so 
	// reset the unsavedChanges variable so that the warning message does not appear twice
	markSaved();
}







function doMenuEdit(action){

	// delete selected item
	if (action == "delete"){

		// for items in the main panel (list items), 
		// we must check that an item has been selected
		if (getDocumentVar("selectedSection") > "" && getDocumentVar("selectedID") > 0){
			// now confirm the delete
			
			// sometimes the section will have _list_detail or list_thumbnail appended
			// for readability, remove this first
			var sectionStr = String(selectedSection);
			sectionStr = sectionStr.replace(/_list_detail/,"");
			sectionStr = sectionStr.replace(/_list_thumbnail/,"");
			
			if (confirm("Are you sure you want to delete the "+sectionStr+" '"+selectedName+"'?")){

				startWaitBar();
			
				// now do the appropriate delete for each section
				if (selectedSection == "block"){
					// set the current item to the page

					// redirect the page_tabs panel to the delete block page
					window.frames["mainPanel"].location.href = "../block/delete.asp?section="+currentSubSection+"&BlockID="+selectedID+"&PageID="+getDocumentVar("currentPage");				
				}

				if (selectedSection == "client"){
					// redirect the main panel to the delete image page
					document.all.mainPanel.src = "../client/delete.asp?ClientID="+getDocumentVar("selectedID");
				}


				if (selectedSection == "email"){
					window.frames["tabs"].frames["list"].location.href = "../tools/deleteEmail.asp?EmailID="+currentEmail;
				}

					
				if (selectedSection == "event"){
					doRefreshTree();
					window.frames["mainPanel"].frames["calendarFrame"].location.href = "../event/delete.asp?EventID="+getDocumentVar("selectedID");
					window.frames["mainPanel"].frames["eventFrame"].location.href = "../calendar/blank.html";
				}


				if (selectedSection == "field"){
					window.frames["list"].location.href = "../field/delete.asp?FieldID="+getDocumentVar("currentField");
				}


				if (selectedSection == "filecategory"){
					// redirect the main panel to the delete image page
					document.all.mainPanel.src = "../filecategory/delete.asp?FileCategoryID="+currentFileCategory;
				}


				if (selectedSection == "file"){
					// redirect the main panel to the delete image page
					document.all.mainPanel.src = "../file/delete.asp?FileID="+selectedID+"&FileCategory="+currentFileCategory;
				}



				if (selectedSection == "ftpexport"){
					window.parent.iframeLoaded = 0;
					document.all.mask.style.visibility = 'visible';
					// redirect the page_tabs panel to the delete page page
					document.all.list.src = "../import/deleteFTPExport.asp?FTPExportID="+getDocumentVar('selectedID');				
				}


				if (selectedSection == "ftpimport"){
					window.parent.iframeLoaded = 0;
					document.all.mask.style.visibility = 'visible';
					// redirect the page_tabs panel to the delete page page
					document.all.list.src = "../import/deleteFTPImport.asp?FTPImportID="+getDocumentVar('selectedID');				
				}


				if (selectedSection == "ftpsite"){
					window.parent.iframeLoaded = 0;
					document.all.mask.style.visibility = 'visible';
					// redirect the page_tabs panel to the delete page page
					document.all.list.src = "../import/deleteFTPSite.asp?FTPSiteID="+selectedID;				
				}


				if (selectedSection == "image"){
					// redirect the main panel to the delete image page
					document.all.mainPanel.src = "../image/delete.asp?ImageID="+selectedID+"&ImageCategory="+currentImageCategory;
				}
				
				if (selectedSection == "imagecategory"){
					// redirect the main panel to the delete image page
					document.all.mainPanel.src = "../imagecategory/delete.asp?ImageCategoryID="+currentImageCategory;
				}

				if (selectedSection == "import"){
					// redirect the main panel to the delete image page
					document.all.mainPanel.src = "../tools/deleteimport.asp?ImportID="+selectedID;
				}

				if (selectedSection == "list_list_detail"){
					window.frames["list"].location.href = "../list/delete.asp?ListID="+currentList;
				}

				if (selectedSection == "order"){
						document.all.mainPanel.src = "../order/delete.asp?OrderID="+currentOrder;				
				}

				if (selectedSection == "page"){
					// set the current item to the page
					
					// redirect the page_tabs panel to the delete page page
						document.all.mainPanel.src = "../page/delete.asp?PageID="+currentPage;				
				}

				if (selectedSection == "role"){
						//document.all.mainPanel.src = "../role/delete.asp?RoleID="+currentRole;				
				}

				if (selectedSection == "rolepage"){
					window.frames["list"].location.href = "../role/delete_rolepage.asp?RoleID="+currentRole+"&PageID="+selectedID;				
				}

				if (selectedSection == "site"){

					// we cannot delete the default site
					if (getDocumentVar("isDefaultSite") == 1){
						alert("You cannot delete the default site.");
						stopWaitBar();
						return;
					} 
										
					// redirect the page_tabs panel to the delete page page
					document.all.mainPanel.src = "../site/delete.asp?SiteID="+currentSite;				
				}


				if (selectedSection == "status"){
					window.parent.iframeLoaded = 0;
					document.all.mask.style.visibility = 'visible';
					// redirect the page_tabs panel to the delete page page
					document.all.list.src = "../status/delete.asp?StatusID="+selectedID;				
				}

				if (selectedSection == "type"){
					window.parent.iframeLoaded = 0;
					document.all.mask.style.visibility = 'visible';
					// redirect the page_tabs panel to the delete page page
					document.all.list.src = "../type/delete.asp?TypeID="+selectedID;				
				}

				if (selectedSection == "user"){
					window.frames["mainPanel"].location.href = "../users/delete.asp?UserID="+selectedID;				
				}

				if (selectedSection == "userpage"){
					window.frames["list"].location.href = "../users/delete_userpage.asp?UserID="+currentUser+"&PageID="+selectedID;				
				}

				if (selectedSection == "webimport"){
					window.frames["list"].location.href = "../import/delete_webimport.asp?WebImportID="+selectedID;				
				}

				// reset the highlightedID and selectedID
				// if these are not they will cause an error because the selected item is now deleted
				
				resetSelected();
				resetCurrent();
				resetHighlighted();
				

			} else {
			// if they don't confirm the delete...
				// do nothing
			}
		} else {
		// if no item has been selecgted
		// we could be working on one of the 
			// do nothing
		}
	}
	
	
	if (action == "cleanwordhtml"){
		if (getDocumentVar("selectedSubSection") == "field_text"){
			eval("var docBody = window.frames[\"mainPanel\"].frames[\"page_tabs\"].document.field_"+getDocumentVar("selectedSubID")+"_preview.document.body");
			var content = String(docBody.innerHTML);
			content = content.replace(/<font .*?>/ig,"");
			content = content.replace(/<\/font>/ig,"");
			content = content.replace(/<span.*?>/ig,"");
			content = content.replace(/<\/span>/ig,"");

			content = content.replace(/ class=Mso\w+/ig,"");
			content = content.replace(/ style=".*?"/ig,"");
			content = content.replace(/<\?xml.*?>/ig,"");
			content = content.replace(/<\w:\w+.*?>.*?<\/\w:\w+>/ig,"");

			content = content.replace(/<table.*>/ig,"");
			content = content.replace(/<\/table>/ig,"");
			content = content.replace(/<tr.*>/ig,"");
			content = content.replace(/<\/tr>/ig,"");
			content = content.replace(/<td.*>/ig,"");
			content = content.replace(/<\/td>/ig,"");
			content = content.replace(/<th.*>/ig,"");
			content = content.replace(/<\/th>/ig,"");
			
			docBody.innerHTML = content;
		}
	}
	

	if (action == "hyperlink"){
		fieldName = "";
		
		if (getDocumentVar("selectedSubSection") == "field_image"){
			fieldName = 'ImageLink'+getDocumentVar("selectedSubName");
		}
		
		doPopup('link',getDocumentVar("selectedSubID"),fieldName);

	}


	if (action == "search"){

		// first check for unsaved changes
		if (abortAction()){
			return false;
		}

		window.parent.startWaitBar();
		
		setDocumentVar("currentExplorerSection","search");
			
		toggleExplorerPane("open");
		
		//''window.frames["mainPanel"].location.href = "../menu/blank_white.html";		

		// now regenerate the explorer panel 		
		window.frames["explorerPanel"].location.href = "../menu/explorerPanel.asp?section=search&currentSection="+getDocumentVar("currentSection")+"&currentID="+getDocumentVar("currentID");;

	}
	
	
} //'' end domenuedit



function doMenuExtra(action,section){

	// delete selected item
	if (action == "SetAsDefault"){

		if (getDocumentVar("selectedSection") > "" && getDocumentVar("selectedID") > 0){

			startWaitBar();
		
			if (section == "FTPSite"){
				
				// redirect the page_tabs panel to the delete block page
				window.frames["list"].location.href = "../import/makeDefaultFTPSite.asp?FTPSiteID="+getDocumentVar("selectedID");				
			}
		}
	}
}


function doMenuFile(action){

	if (action == "checkIn"){
		if (currentSection == "block"){
			// first check for unsaved changes
			if (abortAction()){
				return false;
			}
			window.frames["mainPanel"].frames["page_tabs"].location.href="../block/checkIn.asp?BlockID="+getDocumentVar("currentBlock");
		}
	}


	if (action == "checkOut"){
		if (currentSection == "block"){
			// first check for unsaved changes
			if (abortAction()){
				return false;
			}
			if(confirm("Are you sure you want to check out the block "+getDocumentVar("currentBlockName")+"?")){
				window.frames["mainPanel"].frames["page_tabs"].location.href="../block/checkOut.asp?BlockID="+getDocumentVar("currentBlock");
			}
		}
	}
	

	if (action == "commit"){
		if (currentSection == "block"){
			// first check for unsaved changes
			if (abortAction()){
				return false;
			}

			doPopup("commit");
		}
	}


	if (action == "bin"){
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		doPopup("bin","","General");
	}
	
		
	if (action == "logout"){
		//document.all.mainPanel.src = "../users/logout.asp";
		
		window.top.location.href="../users/logout.asp";
	}



	if (action == "new_version"){
		if (currentSection == "block"){
			// first check for unsaved changes
			if (abortAction()){
				return false;
			}
			
			doPopup("new_version");
		}
	}
	
	if (action == "properties"){
		if (currentSection == "block"){
			// first check for unsaved changes
			if (abortAction()){
				return false;
			}
			doPopup('blockProperties','','General')
		}

		if (currentSection == "filecategory"){
			// first check for unsaved changes
			if (abortAction()){
				return false;
			}
			doPopup('fileCategoryProperties','','General')
		}

		if (currentSection == "imagecategory"){
			// first check for unsaved changes
			if (abortAction()){
				return false;
			}
			doPopup('imageCategoryProperties','','General')
		}

		if (currentSection == "page"){
			// first check for unsaved changes
			if (abortAction()){
				return false;
			}
			startWaitBar();
			window.frames["mainPanel"].location.href = "../page_tabs/tabs.asp?section=properties&PageID="+ currentPage;
		}

		if (currentSection == "role"){
			// first check for unsaved changes
			if (abortAction()){
				return false;
			}
			doPopup('roleProperties',getDocumentVar("currentRole"),'General')
		}

		if (currentSection == "site"){
			// first check for unsaved changes
			if (abortAction()){
				return false;
			}
			doPopup('siteProperties',getDocumentVar("currentSite"),'General')
		}

	}


	if (action == "reject"){
		if (currentSection == "block"){
			// first check for unsaved changes
			if (abortAction()){
				return false;
			}
			
			doPopup("reject");
		}
	}


	if(action == "revert_previous"){
		if (currentSection == "block"){
			
			if (abortAction()){
				return false;
			}
	
			if(confirm("Are you sure you want to revert to the previous version of this block?")){
				startWaitBar();
				window.frames["mainPanel"].frames["page_tabs"].location.href = "../block/revert_previous.asp?BlockID="+ getDocumentVar("currentBlock");
			}	
		}
	}
	
	
	if (action == "save"){
	
		if (currentSection == "block"){
			
			// don't submit if the wait bar is still running
			if(document.all.waitBar.style.visibility != "visible"){
				// submit the form on the page
				window.frames["mainPanel"].frames["page_tabs"].document.all.composeForm.submit.click();
			}
		}

		if (currentSection == "email"){
			
			// don't submit if the wait bar is still running
			if(document.all.waitBar.style.visibility != "visible"){
			
				// mark the window as saved now, otherwise the beforeunload popup comes up
				markSaved();
			
				// submit the form on the page
				window.frames["mainPanel"].frames["email_tabs"].document.all.composeForm.submit.click();
			}
		}

		if (currentSection == "page"){
			startWaitBar();
			
			// mark the window as saved now, otherwise the beforeunload popup comes up
			markSaved();
			
			// submit the form on the page
			window.frames["mainPanel"].frames["page_tabs"].document.all.form1.submit.click();
		}


		if (currentSection == "pagetemplate"){
			startWaitBar();
			
			// mark the window as saved now, otherwise the beforeunload popup comes up
			markSaved();
			
			// submit the form on the page
			window.frames["mainPanel"].document.all.composeForm.submit.click();
		}

	}
	


	
	if (action == "review"){

		if (currentSection == "block"){
			
			// don't submit if the wait bar is still running
		//	if(document.all.waitBar.style.visibility != "visible"){
				// submit the form on the page
				//window.frames["mainPanel"].frames["page_tabs"].document.getElementById("review").value = 1;
				//window.frames["mainPanel"].frames["page_tabs"].document.all.composeForm.submit.click();
		//	}


			// first check for unsaved changes
			if (abortAction()){
				return false;
			}

			doPopup("review");

		}

	}

	if (action == "signoff"){
		if (currentSection == "block"){
			// first check for unsaved changes
			if (abortAction()){
				return false;
			}
			
			doPopup("signoff");
		}
	}


	if (action == "version_history"){
		if (currentSection == "block"){
			// first check for unsaved changes
			if (abortAction()){
				return false;
			}
			
			doPopup("version_history",'','Versions');
		}
	}

	
}


function doMenuFormat(action, section, option){

	// this code is used for setting the color after it has been selected in the popup
	if (action == "color"){
		if (section == "select"){
			// we get the first variable (the color type) from the temprary variable
			window.top.frames['mainPanel'].frames['page_tabs'].formatC(document.temporary.var2.value,document.temporary.var1.value);
		}
	}


	// this code opens the color picker
	if ((action == "forecolor")||(action == "backcolor")){
		// save the action in the temporary form to be picked up on select
		document.temporary.var2.value = action;
		if (section == "popup"){
			TCP.popup(document.temporary.var1);
		}
	}



	if (action == "formatC"){
		window.top.frames['mainPanel'].frames['page_tabs'].formatC(section,option);
	}



	if (action == "insertimage"){
		if (section == "popup" && (getDocumentVar("currentSubSection") == "field_text")){
			theImg = prompt("Enter the image URL:");
			if (theImg != ""){
				window.top.frames['mainPanel'].frames['page_tabs'].formatC("InsertImage",theImg);
			}
		}
	}



	if (action == "removeformat"){
		window.top.frames['mainPanel'].frames['page_tabs'].formatC('formatBlock','removeFormat');
		eval("window.top.frames['mainPanel'].frames['page_tabs'].field_text_"+window.top.getDocumentVar("selectedSubID")+"_preview.focus();");
	}


} // end doMenuFormat


function doMenuHelp(action){

	if (action == "about"){
		doPopup('about');
	}
	
	if (action == "apiDocumentation"){
		newWin("../help/api/", "API", 750, 450, "scrollbars=yes,resizable=yes", null, null, 1);
	}

	if (action == "general"){
		newWin("../help/", "HELP", 750, 450, "scrollbars=yes,resizable=yes", null, null, 1);
	}

	if (action == "toggleInlineHelp"){
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		startWaitBar();
		document.frames["junk"].location.href = "../utils/toggleInlineHelp.asp";
		document.frames["mainPanel"].location.href = document.frames["mainPanel"].location.href;
	}

	if(action == "welcome"){
		startWaitBar();
		document.all.mainPanel.src = "../users/welcome.asp";
	}

} // end function doMenuHelp




function doMenuModule(module,action){

	if(module == "stats"){
		
		if(action == "entry_pages"){
			setMainPanel("../stats/hits.aspx?section=graph&content=entry_pages");
		}

		if(action == "exit_pages"){
			setMainPanel("../stats/hits.aspx?section=graph&content=exit_pages");
		}

		if(action == "hits"){
			//'' load the hits counter in the main panel
			setMainPanel("../stats/hits.aspx?section=graph&content=hits");
		}

		if(action == "search_engines"){
			setMainPanel("../stats/hits.aspx?section=graph&content=search_engines");
		}

		if(action == "search_terms"){
			setMainPanel("../stats/hits.aspx?section=graph&content=search_terms");
		}

		if(action == "top_pages"){
			setMainPanel("../stats/hits.aspx?section=graph&content=top_pages");
		}
		
	} //'' end if stats
}



function doMenuNew(){
	
	// sections that have categories will either pass in type=category (meaning add a category)
	// or leave type blank, which means we must add an item within the currennt category
	



	// new blocktemplate
	if(currentSection == "blocktemplate" || currentSection == "blocktemplatecategory"){
		startWaitBar();
		document.all.mainPanel.src = "../blocktemplate/add.asp?BlockTemplateCategoryID="+getDocumentVar("currentBlockTemplateCategory");
	}



	// new client
	else if(currentSection == "client"){
		doPopup("addClient",'','Add');
	}


	
	// new email delivery
	else if(currentSection == "deployment"){
		startWaitBar();
		document.all.mainPanel.src = "../tools/adddeployment.asp";
	}



	// new site
	else if(currentSection == "email" || currentExplorerSection =="email"){
		doPopup('email_add');
	}	
	
	// new import
	else if(
	(currentSection == "import" )
	){
		startWaitBar();
		document.all.mainPanel.src = "../tools/importpages.asp";
	}
	

	// new pagetemplate
	else if(currentSection == "pagetemplate" || currentSection == "pagetemplatecategory"){
		startWaitBar();
		document.all.mainPanel.src = "../pagetemplate/add.asp?PageTemplateCategoryID="+getDocumentVar("currentPageTemplateCategory");
	}



	// new site
	else if(currentSection == "site" || currentExplorerSection =="site"){
		startWaitBar();
		document.all.mainPanel.src = "../site/add.asp";
	}


	// new user
//	else if(currentSection == "user" || currentSection == "role"){
//		doPopup("user_add",getDocumentVar("currentRole"));
//	}

	
	// for everything else, open the standard new wizard
	else {
		doPopup("new","","")
	}
}





function doMenuOpen(section,id){

	
	// not all calls to this function pass in the required variables, so we get them...
	if (section == "selectedItem"){
		section = getDocumentVar("selectedSection");
		id = getDocumentVar("selectedID");
	}



	if (section == "block"){
		if (getDocumentVar("popupType") > ""){
			// if it is a link picker popup
			if (getDocumentVar("popupType") == "link"){
				setPopupField("{link_block_"+id+"}"); 
			}
			// reset the popup fields on the top window
			resetPopup();
		} // end of if popup
		else {

			// first check for unsaved changes
			if (abortAction()){
				return false;
			}

			// make sure that the block is not checked out by someone else
			// only do this check if it is the current sub section is blocks
			if(getDocumentVar("currentSubSection") == "blocks"){
				eval("var checkedOutBy = window.frames[\"mainPanel\"].frames[\"page_tabs\"].document.all.Item_"+getDocumentVar("currentBlock")+"_checkedOutBy.value");
				
				if(checkedOutBy && checkedOutBy > 0 && checkedOutBy != getDocumentVar("UserID")){
					alert("This block is checked out by another user.\n\nView the block properties for more detail.");
					return false;
				}
			}
			
			startWaitBar();
			
			// we might be editing userdata, so the destination is different
			var currentSrc = String(window.frames["mainPanel"].location.href);
			if(currentSrc.match(/users\/data_menu/)){
				document.all.mainPanel.src = "../users/data_menu.aspx?section=editor&PageID="+currentPage+"&BlockID="+id;
			} else {
				document.all.mainPanel.src = "../page_tabs/tabs.asp?section=editor&PageID="+currentPage+"&BlockID="+id;
			
			}
		}
	}

	if (section == "blockTemplate" || section == "blocktemplate"){
		// NOTE: need to remove the case discrepencies on blockTemplate
		if (getDocumentVar("popupType") > ""){
			// if it is a link picker popup
			if (getDocumentVar("popupType") == "blockTemplate"){
				setPopupField(id); 
			}
			// reset the popup fields on the top window
			resetPopup();
		} // end of if popup
		else {

			// first check for unsaved changes
			if (abortAction()){
				return false;
			}

			startWaitBar();
			document.all.mainPanel.src = "../blocktemplate/edit.asp?BlockTemplateID="+id
		}
	}


	if (section == "checkedOut"){
		startWaitBar();
		document.all.mainPanel.src = "../users/checkedOut.asp";
	}

		
	if (section == "client"){
		doPopup("clientProperties",'',"General");
	}



	if (section == "deployment"){
		doPopup("deploymentProperties",'',"General");
	}

	
	if(section == "email_delivery"){
		//doPopup("email_delivery",id,'General');	
		doSelectTreeItem("email_delivery",id,currentEmailDeliveryName)
	}
	
	

	if (section == "event"){
		doPopup("event_edit",id,'Edit');
	}
	
		

	if (section == "file"){
		// if this function is called, but we are picking an image, then don't open the item,
		// rather set the variable on the calling form

		if (getDocumentVar("popupType") > ""){
			// if it is an file picker popup
			if (getDocumentVar("popupType") == "file"){
				setPopupField(id); 
				// reset the popup fields on the top window
				resetPopup();
			}

			// if it is a link picker popup
			if (getDocumentVar("popupType") == "link"){
				setPopupField("{link_file_"+id+"}"); 
				// reset the popup fields on the top window
				resetPopup();
			}
		} // end of if popup
		else {

			// first check for unsaved changes
			if (abortAction()){
				return false;
			}

			doPopup("file_edit",id,'General');
		}
	} 
	


	if (section == "hour"){
		doPopup("event_add",'','Edit');
	}
	
		
	if (section == "image"){
		// if this function is called, but we are picking an image, then don't open the item,
		// rather set the variable on the calling form

		if (getDocumentVar("popupType") > ""){
			// if it is an image picker popup
			if (getDocumentVar("popupType") == "image"){
				setPopupField(id); 
				// reset the popup fields on the top window
				resetPopup();
			}

			// if it is a link picker popup
			if (getDocumentVar("popupType") == "link"){
				setPopupField("{link_image_"+id+"}"); 
				// reset the popup fields on the top window
				resetPopup();
			}
		} // end of if popup

		else {

			// first check for unsaved changes
			if (abortAction()){
				return false;
			}

			doPopup("image_edit",id,'General');
		}

	}




	if (section == "import"){
		document.all.mainPanel.src = "../tools/importdetails.asp?ImportID="+id;
	}




	if (section == "job"){
		doPopup("job",getDocumentVar("currentID"));
	}
	
	
	
	
	if (section == "log"){
		doPopup("log",getDocumentVar("currentID"));
	}



	if (section == "page"){
		if (getDocumentVar("popupType") > ""){
			// if it is a link picker popup
			if (getDocumentVar("popupType") == "link"){
				setPopupField("{link_page_"+id+"}"); 
				// reset the popup fields on the top window
				resetPopup();
			}
		} // end of if popup
		else if (document.all.mainPanel)
		{
			startWaitBar();
			document.all.mainPanel.src = "../page_tabs/tabs.asp?section=pages";
		}
	}



	if (section == "page_list"){
		// if this function is called, but we are picking an image, then don't open the item,
		// rather set the variable on the calling form
		if (window.top.name == "popup"){

			if (window.top.opener.top.getDocumentVar("popupType") == "link"){
				window.top.opener.top.setPopupField("{link_page_"+id+"}"); 
				
				// reset the popup fields on the top window
				window.top.opener.top.resetPopup();
				
				// close the popup window
				window.top.close();
			}
		}
	}


	if (section == "pagetemplate"){
		startWaitBar();
		setMainPanel("../pagetemplate/edit.asp?PageTemplateID="+id);
	}



	if (section == "recent"){
		startWaitBar();
		document.all.mainPanel.src = "../users/recent.asp";
	}

	if (section == "template"){
		startWaitBar();
		document.all.mainPanel.src = "../template/edit.asp?TemplateID="+id;
	}

	if (section == "user"){
		doPopup("user_edit",id,'General');
	}

	if (section == "user_data"){
		startWaitBar();
		doUserDataTab("blocks");
	}

	if (section == "user_orders"){
		startWaitBar();
		setMainPanel("../order/list.asp?UserID="+ getDocumentVar("currentUser"));
	}

} // end doMenuOpen





function doMenuTools(action,section){


	if (action == "calendar_manager"){

		// first check for unsaved changes
		if (abortAction()){
			return false;
		}

		if(!(getDocumentVar("currentSection") == "page" || getDocumentVar("currentSection") == "block")){
			alert("Please first select a page to manage the calendar.");
			return false;
		}
		
		startWaitBar;
		toggleExplorerPane("open");
		doMenuView("explorer","calendar");
		setMainPanel("../calendar/default.asp?PageID="+getDocumentVar("currentPage"));
	}


	if (action == "client_manager"){

		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
	
		startWaitBar;
		toggleExplorerPane("closed");
		setMainPanel("../client/list.asp");
	}



	// deployment actions
	if (action == "deployment"){

		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		startWaitBar;
		toggleExplorerPane("closed");
		setMainPanel("../tools/deploymentlist.asp");
	
	} // end deployment



	if (action == "email_manager"){
		//doPopup("email_manager",'','General');
		doMenuView("explorer","email");
		setMainPanel("../email/campaigns_welcome.asp");

	}


		
	if (action == "events_manager"){
		setExplorerPanel("../eventsmanager/panelMenu.asp");
		setMainPanel("../eventsmanager/booking_welcome.asp");

	}

	
	
	// export actions
	if (action == "export"){

		// first check for unsaved changes
		if (abortAction()){
			return false;
		}

		// export the current item
		if (section == "current" ){
			if(getDocumentVar('deploymentMethod') == "FTP"){
				doMenuTools('export','ftpexport_run_current');
			}
			if(getDocumentVar('deploymentMethod') == "Database"){
				if(confirm("Are you sure you want to deploy all the changes that you have made?\n\n(Changes made by other users will not be deployed.)")){
					// call the jobs window with override - this will force all jobs to be run
					setTimeout("window.frames['jobs'].location.href = '../utils/runJobs.asp?override=1&UserID="+getDocumentVar("UserID")+"'",1);				
				}
			}
		}


		// FTP current item
		if (section == "ftpexport_run_current"){

			// export the current file category
			if((getDocumentVar('currentSection') == "file" || getDocumentVar('currentSection') == "filecategory") && getDocumentVar('currentFileCategory')){
				doPopup("ftpexport_run_filecategory",getDocumentVar('currentFileCategory'));
			}

			// export the current image category
			if ((getDocumentVar('currentSection') == "image" || getDocumentVar('currentSection') == "imagecategory") && getDocumentVar('currentImageCategory')){
				doPopup("ftpexport_run_imagecategory",getDocumentVar('currentImageCategory'));
			}

			// export the current page
			if ((getDocumentVar('currentSection') == "page" || getDocumentVar('currentSection') == "block") && getDocumentVar('currentPage')){
				doPopup("ftpexport_run_page",getDocumentVar('currentPage'));
			}

		}


		// export with options
		if (section == "options" ){
			if(getDocumentVar('deploymentMethod') == "FTP"){
				doPopup('ftpexport_run_options');
			}
			if(getDocumentVar('deploymentMethod') == "Database"){
				doPopup('deployment_run_options');
			}
		}


	} // end export actions



	// forms manager
	if (action == "forms_manager"){

		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		startWaitBar;
		toggleExplorerPane("open");
		doMenuView("explorer","form");
	
	} // end forms manager




	// import actions
	if (action == "import"){

		if (section == "block"){
			doPopup("block_import",((getDocumentVar("currentPage")>0)?getDocumentVar("currentPage"):""));
		}

		if (section == "file"){
			doPopup("file_upload",((getDocumentVar("currentFileCategory")>0)?getDocumentVar("currentFileCategory"):""));
		}

		if (section == "ftp"){
			doPopup("ftpsite",'',"FTPSites");
		}
	
		if (section == "image"){
			doPopup("image_upload",((getDocumentVar("currentImageCategory")>0)?getDocumentVar("currentImageCategory"):""));
		}

		if (section == "users"){
			doPopup("user_import",((getDocumentVar("currentRole")>0)?getDocumentVar("currentRole"):""));
		}

		if (section == "webpage"){
			doPopup("webimport",'',"WebImports");
		}
	
	} // end import


	if (action == "linkchecker"){
	}
	



	if (action == "list_manager"){
	
		if(section == "add_user")
		{
			doPopup("list_add_user");
		} 
		else 
		{
			doPopup("list_manager",'','General');
		}
	}

	
	

	if (action == "module_manager"){
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		setMainPanel("../utils/explorer_details.asp?data_exp=ObjClientGetModulesExplorerData()");
	
	}

	

	if (action == "publishingflow"){
		doPopup("publishingflow",'','Statuses');
	}




	// seo
	if (action == "seo"){

		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		if(section == "page_report"){
			doPopup("seo_page_report",'','Page');
		}
	
	} // end seo




	// stats
	if (action == "stats"){

		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		if(section == "visits"){
			startWaitBar;
			toggleExplorerPane("open");
			doMenuView("explorer","stats");
		}
	
	} // end stats


	if (action == "type"){
		doPopup("type",'','Types');
	}



} // end doMenuTools



function doMenuView(action,section){



	if (action == "explorer"){

		// first check for unsaved changes
		if (abortAction()){
			return false;
		}

		window.parent.startWaitBar();
		
		setDocumentVar("currentExplorerSection",section);
			
		toggleExplorerPane("open");
		
		// open a different "blank" page for different sections
		if (section == "page"){
			// don't load a blank page if the mainPanel is recent items
//			myRegExp = new RegExp("recent", "i") ;
//			if(!myRegExp.test(window.frames["mainPanel"].location.href)) { 
				window.frames["mainPanel"].location.href = "../page/blank_white.asp";		
//			}
		} else {
			window.frames["mainPanel"].location.href = "../menu/blank_white.html";		
		}
		
		// now regenerate the explorer panel 
		var destURL = "../menu/explorerPanel.asp?section="+section;
		
		if(section == "calendar"){
			destURL += "&PageID="+getDocumentVar("currentPage");
		}
		
		window.frames["explorerPanel"].location.href = destURL;

	}



	if (action == "jobs"){
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}

		resetCurrent();
		setMainPanel("../utils/viewjobs.asp");
		
	}


	if (action == "logs"){
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}

		resetCurrent();
		setMainPanel("../utils/viewlog.asp");
		
	}


	if (action == "mail"){
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}

		// hide the mail icon
		setStatusMessage("mail","default");

		newWin("../tools/mail.asp", "popup",572,396);
		
	}



	if (action == "previewitem"){

		// first check for unsaved changes
		if (abortAction()){
			return false;
		}


		if (currentBlock > 0){
		
			newWin("../block/preview_latest_version.asp?BlockID="+currentBlock,null,null,null,"resizable=1",null,null,1);
		}
	}





	if (action == "previewpage"){

		// first check for unsaved changes
		if (abortAction()){
			return false;
		}


		if (currentPage > 0){
		
			window.frames["mainPanel"].location.href = "../page_tabs/tabs.asp?section=preview&PageID="+getDocumentVar("currentPage");		

//			newWin("../../default.asp?PageID="+currentPage,null,null,null,"resizable=1");
		}
	}



	if (action == "togglesource"){
		// only toggle the source if the curent field is a text field
		if (getDocumentVar("currentSubSection") == "field_text"){
			window.top.frames['mainPanel'].frames['page_tabs'].toggleMode();
		}
	}


}



function doPageContextMenu(action,id){

	if (action == "edit"){
		startWaitBar();
		document.all.mainPanel.src = "../page_tabs/tabs.asp?section=editor&PageID="+currentPage+"&BlockID="+id;
	}
	
	if (action == "deleteblock"){
		if (confirm("Are you sure you want to delete this block?")){
			startWaitBar();
			document.all.mainPanel.src="../block/delete.asp?BlockID="+id+"&section="+getDocumentVar("currentSubSection");
		} 
	}
}



function doPageTab(section,refreshTree){

	if (section == "blocks"){
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
	
		startWaitBar();
		
		//set the current item to the page (it might be set as a block)
		// why do we need this? - it messes up the move-block function.
//		doSelectItem("page",getDocumentVar("currentPage"),getDocumentVar("currentPageName"));

		// now open the page tab
		window.frames["mainPanel"].location.href = "../page_tabs/tabs.asp?section=blocks&PageID="+getDocumentVar("currentPage")+((refreshTree)?"&refreshTree="+refreshTree:"");		
	}


	if (section == "editor"){
	
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		startWaitBar();
		
		// now open the page tab
		window.frames["mainPanel"].location.href = "../page_tabs/tabs.asp?section=editor&BlockID="+getDocumentVar("currentBlock");		
	
	}


	if (section == "layout"){
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		startWaitBar();
		
		// now open the page tab
		window.frames["mainPanel"].location.href = "../page_tabs/tabs.asp?section=layout&PageID="+getDocumentVar("currentPage");		
	
	}



	if (section == "pages"){
	
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		startWaitBar();
		
		// now open the page tab
		window.frames["mainPanel"].location.href = "../page_tabs/tabs.asp?section=pages";		
	
	}


	if (section == "preview"){
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		// don't start the wait bar, as we can't stop it from the preview window!!
//		startWaitBar();
		
		// now open the page tab
		window.frames["mainPanel"].location.href = "../page_tabs/tabs.asp?section=preview&PageID="+getDocumentVar("currentPage");		
	
	}



	if (section == "properties"){
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
	
		startWaitBar();
		
		//set the current item to the page (it might be set as a block)
		doSelectItem("page",getDocumentVar("currentPage"),getDocumentVar("currentPageName"));

		// now open the page tab
		window.frames["mainPanel"].location.href = "../page_tabs/tabs.asp?section=properties";		
	
	}


/*	if (section == "versions"){
	
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		startWaitBar();
		
		// now open the page tab
		window.frames["mainPanel"].location.href = "../page_tabs/tabs.asp?section=versions&PageID="+getDocumentVar("currentPage");		
	
	}*/

	setDocumentVar("currentTab",section);
	
}





function doPopup(type,id,fieldName){


	setDocumentVar("popupType",type);
	setDocumentVar("popupID",id);
	setDocumentVar("popupField",fieldName);

	width = 572;
	height = 396;
	xoff = 0;
	yoff = 0;
	notModal = 0;
	
	// set the popup destination
	popupDest = "";

	//picker
	if(type == "image" || type == "link" || type == "file" || type == "linked_block" || type == "search_browse" || type == "select_page" || type == "select_imagecategory" || type == "select_filecategory" || type == "select_type"){
		popupDest = "../utils/picker.asp"+"?type="+type;
	}

	if (type == "about"){
		popupDest = "../help/about.asp"+"?type="+type;
	}
	if(type == 'addClient'){
		popupDest = "../utils/propertiesFrame.asp?url="+escape("../client/add_tabs.aspx?section="+fieldName);
	}
	if (type == "bin"){
		popupDest = "../utils/propertiesFrame.asp?title=Recycle Bin&url="+escape("../tools/bin.aspx?section="+fieldName);
	}
	if (type == "bin_purge"){
		popupDest = "../utils/progressFrame.asp?title=Empty Recycle Bin&heading1=Emptying the recycle bin of "+fieldName+" items&heading2=&autoClose=1&url="+escape("../tools/purgeBin.asp?section="+fieldName+"&id="+id);
	}
	if (type == "bin_restore"){
		popupDest = "../utils/progressFrame.asp?title=Restore Recycle Bin&heading1=Restoring "+fieldName+" items from the recycle bin&heading2=&autoClose=1&url="+escape("../tools/restoreBin.asp?section="+fieldName+"&id="+id);
	}
	if (type == "block_import"){
		popupDest = "../utils/propertiesFrame.asp?title=Import Blocks&url="+escape("../block/import.asp?PageID="+id);
		width = 400;
		height = 350;
		xoff = 0;
		yoff = 0;
	}
	if (type == "blockDropOnPage"){
		popupDest = "../block/dropDialog.asp"+"?type="+type;
	}
	if (type == "blockProperties"){
		popupDest = "../utils/propertiesFrame.asp?url="+escape("../block/properties_tabs.aspx?section="+fieldName+"&BlockID="+getDocumentVar("currentBlock"));
	}
	if(type == 'blockTemplate'){
		popupDest = "../utils/picker.asp"+"?currentPickerSection=Block Template&type="+type;
	}
	if (type == "block_compare"){
		popupDest = "../utils/propertiesFrame.asp?title=View Block&propertyFrameWidth=780&url="+escape("../block/compare_tabs.aspx?section="+fieldName+"&BlockID="+getDocumentVar("currentBlock")+"&BlockID2="+id);
		width = 769;
		yoff = 50;
	}
	if (type == "block_view"){
		if(!id){
			return false;
		}
		popupDest = "../utils/propertiesFrame.asp?title=View Block&url="+escape("../block/view_tabs.aspx?section="+fieldName+"&BlockID="+id);
		xoff = 50;
		yoff = 50;
	}
	if (type == "clientProperties"){
		popupDest = "../utils/propertiesFrame.asp?url="+escape("../client/properties_tabs.aspx?section="+fieldName+"&ClientID="+getDocumentVar("selectedID"));
	}
	if (type == "commit"){
		popupDest = "../utils/propertiesFrame.asp?title=Commit&url="+escape("../block/commit.asp?BlockID="+getDocumentVar("currentBlock"));
		width = 400;
		height = 350;
	}
	if (type == "deploymentProperties"){
		popupDest = "../utils/propertiesFrame.asp?url="+escape("../tools/deploymentProperties_tabs.aspx?section="+fieldName+"&ServerID="+getDocumentVar("selectedID"));
	}
	if (type == "deployment_run_options"){
		popupDest = "../utils/propertiesFrame.asp?title=Deployment Options&url="+escape("../tools/deployment_run_options.asp");
		width = 400;
		height = 350;
	}
	if (type == "email_add"){
		popupDest = "../utils/propertiesFrame.asp?title=Add Email&url="+escape("../email/new.asp");
		width = 400;
		height = 350;
		xoff = 50;
		yoff = 50;
	}
	if (type == "email_delivery"){
		popupDest = "../utils/propertiesFrame.asp?title=Email Delivery&url="+escape("../email/emaildelivery.aspx?section="+fieldName+"&EmailID="+id);
		xoff = 0;
		yoff = 0;
	}	
	if (type == "email_edit" && getDocumentVar("currentEmail") > 0){
		popupDest = "../utils/propertiesFrame.asp?title=Edit Email&url="+escape("../email/email.aspx?section="+fieldName+"&EmailID="+getDocumentVar("currentEmail"));
		xoff = 50;
		yoff = 50;
	}
	if (type == "email_manager"){
		popupDest = "../utils/propertiesFrame.asp?title=Email Manager&url="+escape("../email/emailmanager.aspx?section="+fieldName);
	}
	if (type == "email_resendtofailed"){
		popupDest = "../utils/progressFrame.asp?title=Send Email&heading1=Sending email...&heading2=&autoClose=0&url="+escape("../tools/runEmail.asp?EmailID="+id+"&resendtofailed=1");
		xoff = 100;
		yoff = 100;
	}
	if (type == "email_send"){
		popupDest = "../utils/progressFrame.asp?title=Send Email&heading1=Sending email...&heading2=&autoClose=0&url="+escape("../tools/runEmail.asp?EmailID="+id);
		xoff = 100;
		yoff = 100;
	}
	if (type == "event_add"){
		popupDest = "../utils/propertiesFrame.asp?url="+escape("../calendar/edit_event_tabs.aspx?section="+fieldName+"&currentHour="+getDocumentVar("currentHour")+"&currentPage="+getDocumentVar("currentPage"));
	}
	if (type == "event_edit"){
		popupDest = "../utils/propertiesFrame.asp?url="+escape("../calendar/edit_event_tabs.aspx?section="+fieldName+"&EventID="+getDocumentVar("selectedID")+"&currentHour="+getDocumentVar("currentHour")+"&currentPage="+getDocumentVar("currentPage"));
	}
	if (type == "field_add"){
		popupDest = "../utils/propertiesFrame.asp?title=Add Field&url="+escape("../field/add.asp?TypeID="+id);
		width = 400;
		height = 350;
		xoff = 100;
		yoff = 100;
	}
	if (type == "field_edit"){
		popupDest = "../utils/propertiesFrame.asp?title=Edit Field&url="+escape("../field/add.asp?FieldID="+getDocumentVar("currentField"));
		width = 400;
		height = 350;
		xoff = 100;
		yoff = 100;
	}
	if (type == "file_edit"){
		popupDest = "../utils/propertiesFrame.asp?url="+escape("../file/edit_tabs.aspx?section="+fieldName+"&FileID="+id);
	}
	if (type == "file_import"){
		popupDest = "../utils/progressFrame.asp?title=File Import&heading1=Importing files&heading2=&autoClose=1&currentItem="+id+"&url="+escape("../file/importFolder.asp?FileCategoryID="+id+"&parameters="+fieldName)+"&type="+type;
		xoff = 0;
		yoff = 0;
	}
	if (type == "file_upload"){
		popupDest = "../utils/propertiesFrame.asp?title=Import Files&url="+escape("../file/upload.asp?FileCategoryID="+id);
		width = 400;
		height = 350;
		xoff = 0;
		yoff = 0;
	}
	if (type == "fileCategoryProperties"){
		popupDest = "../utils/propertiesFrame.asp?url="+escape("../filecategory/properties_tabs.aspx?section="+fieldName+"&FileCategoryID="+getDocumentVar("currentFileCategory"));
	}
	if (type == "ftpexport_add" && getDocumentVar("currentSection") == "ftpsite" && getDocumentVar("selectedID") > 0){
		popupDest = "../utils/propertiesFrame.asp?title=Export To FTP&url="+escape("../import/addFTPExport.asp?FTPSiteID="+getDocumentVar("selectedID"));
		width = 400;
		height = 350;
		xoff = -50;
		yoff = 10;
	}
	if (type == "ftpexport_run_filecategory"){
		popupDest = "../utils/progressFrame.asp?title=FTP Export&heading1=Exporting to FTP site&heading2=&autoClose=1&url="+escape("../import/runFTPExport.asp?FileCategoryID="+id)+"&type="+type;
	}
	if (type == "ftpexport_run_imagecategory"){
		popupDest = "../utils/progressFrame.asp?title=FTP Export&heading1=Exporting to FTP site&heading2=&autoClose=1&url="+escape("../import/runFTPExport.asp?ImageCategoryID="+id)+"&type="+type;
	}
	if (type == "ftpexport_run_page"){
		popupDest = "../utils/progressFrame.asp?title=FTP Export&heading1=Exporting to FTP site&heading2=&autoClose=1&url="+escape("../import/runFTPExport.asp?PageID="+id)+"&type="+type;
		notModal = 1;

	}
	if (type == "ftpexport_run"){
		popupDest = "../utils/progressFrame.asp?title=FTP Export&heading1=Exporting to FTP site&heading2=&autoClose=1&url="+escape("../import/runFTPExport.asp?FTPExportID="+id)+"&type="+type;
	}
	if (type == "ftpexport_view" && getDocumentVar("selectedID") > 0){
		popupDest = "../import/addFTPExport.asp?FTPExportID="+getDocumentVar("selectedID");
		width = 400;
		height = 350;
		xoff = 100;
		yoff = 100;
	}
	if (type == "ftpimport_add" && getDocumentVar("currentSection") == "ftpsite" && getDocumentVar("selectedID") > 0){
		popupDest = "../utils/propertiesFrame.asp?title=Import From FTP&url="+escape("../import/addFTPImport.asp?FTPSiteID="+getDocumentVar("selectedID"));
		width = 400;
		height = 350;
		xoff = -50;
		yoff = 10;
	}
	if (type == "ftpimport_run"){
		popupDest = "../utils/progressFrame.asp?title=FTP Import&heading1=Importing from FTP site&heading2=&autoClose=1&url="+escape("../import/runFTPImport.asp?FTPImportID="+id)+"&type="+type;
	}
	if (type == "ftpimport_view" && getDocumentVar("selectedID") > 0){
		popupDest = "../import/addFTPImport.asp?FTPImportID="+getDocumentVar("selectedID");
		width = 400;
		height = 350;
		xoff = 100;
		yoff = 100;
	}
	if (type == "ftpsite"){
		popupDest = "../utils/propertiesFrame.asp?title=FTP Sites&url="+escape("../import/ftp.aspx?section="+fieldName);
	}
	if (type == "ftpsite_add"){
		popupDest = "../utils/propertiesFrame.asp?title=Add FTP Site&url="+escape("../import/addFTPSite.asp");
		width = 400;
		height = 350;
		xoff = 50;
		yoff = 50;
	}
	if (type == "ftpsite_edit" && getDocumentVar("selectedID") > 0){
		popupDest = "../utils/propertiesFrame.asp?title=Edit FTP Site&url="+escape("../import/editFTPSite_tabs.aspx?section="+fieldName+"&FTPSiteID="+getDocumentVar("selectedID"));
		xoff = 50;
		yoff = 50;
	}
	if (type == "forceLogout"){
		popupDest = "../users/forceLogout.asp?UserID="+id;
		width = 400;
		height = 350;
		xoff = 20;
		yoff = 20;
	}
	if (type == "help_general_ui_status_bar"){
		popupDest = "../help/general/ui/status_bar.htm?1=1";
		width = 600;
		height = 350;
	}
	if (type == "image_edit"){
		popupDest = "../utils/propertiesFrame.asp?url="+escape("../image/edit_tabs.aspx?section="+fieldName+"&ImageID="+id);
	}
	if (type == "image_import"){
		popupDest = "../utils/progressFrame.asp?title=Image Import&heading1=Importing images&heading2=&autoClose=1&currentItem="+id+"&url="+escape("../image/importFolder.asp?ImageCategoryID="+id+"&parameters="+fieldName)+"&type="+type;
		xoff = 0;
		yoff = 0;
	}
	if (type == "image_upload"){
		popupDest = "../utils/propertiesFrame.asp?title=Import Images&url="+escape("../image/upload.asp?ImageCategoryID="+id);
		width = 400;
		height = 350;
		xoff = 0;
		yoff = 0;
	}
	if (type == "job"){
		popupDest = "../job/view.asp?title=Job&JobID="+id;
	}	
	if (type == "imageCategoryProperties"){
		popupDest = "../utils/propertiesFrame.asp?url="+escape("../imagecategory/properties_tabs.aspx?section="+fieldName+"&ImageCategoryID="+getDocumentVar("currentImageCategory"));
	}

	if(type == "editor_link"){
		popupDest = "../utils/picker_new.asp"+"?type="+type;
	}

	if (type == "list_manager"){
		popupDest = "../utils/propertiesFrame.asp?title=List Manager&url="+escape("../list/manager.aspx?section="+fieldName);
	}
	if (type == "list_add"){
		popupDest = "../utils/propertiesFrame.asp?title=Add List&url="+escape("../list/add.asp");
		width = 400;
		height = 350;
		xoff = 50;
		yoff = 50;
	}
	if (type == "list_add_user"){
		popupDest = "../utils/propertiesFrame.asp?title=Add User to List&url="+escape("../list/add_user.asp?UserID="+currentUser+"&UserIDs="+currentUsers);
		width = 400;
		height = 350;
		xoff = 50;
		yoff = 50;
	}
	if (type == "list_edit" && getDocumentVar("currentList") > 0){
		popupDest = "../utils/propertiesFrame.asp?title=Edit List&url="+escape("../list/edit.aspx?section="+fieldName+"&ListID="+getDocumentVar("currentList"));
		xoff = 50;
		yoff = 50;
	}
	if (type == "listuser_edit"){
		popupDest = "../utils/propertiesFrame.asp?title=User Properties&url="+escape("../list/listuser_edit.asp?ListID="+id+"&UserID="+getDocumentVar("currentID"));
		width = 400;
		height = 350;
		xoff = 50;
		yoff = 50;
	}
	if (type == "log"){
		popupDest = "../log/view.asp?title=Log&LogID="+id;
	}	
	if (type == "new"){
		// need to pass some current vars in to this page as they might be needed 
		popupDest = "../utils/holder.asp?title=New Item&dest="+escape("../utils/new.asp?currentSection="+getDocumentVar("currentSection")+"&item="+fieldName+"&PageID="+getDocumentVar("currentPage")+"&ImageCategoryID="+getDocumentVar("currentImageCategory")+"&FileCategoryID="+getDocumentVar("currentFileCategory")+"&RoleID="+getDocumentVar("currentRole"));
		xoff = 20;
		yoff = 20;
	}
	if (type == "new_email_delivery"){
		popupDest = "../utils/propertiesFrame.asp?title=Deliver Email&url="+escape("../email/new_delivery.asp?EmailID="+id);
		width = 400;
		height = 350;
	}	
	if (type == "new_image_advanced_options"){
		popupDest = "../utils/propertiesFrame.asp?title=Advanced Options&url="+escape("../image/advanced_options.asp?ImageID="+id+"&fieldName="+fieldName);
		xoff = 20;
		yoff = 20;
		width = 400;
		height = 350;
	}
	if (type == "new_version"){
		popupDest = "../utils/propertiesFrame.asp?title=Create New Version&url="+escape("../block/new_version.asp?BlockID="+getDocumentVar("currentBlock"));
		width = 400;
		height = 350;
	}
	if (type == "order_view"){
		popupDest = "../utils/propertiesFrame.asp?title=Order&url="+escape("../order/view.aspx?OrderID="+id+"&section="+fieldName);
	}
	if (type == "pageDropOnPage"){
		popupDest = "../page/dropDialog.asp"+"?type="+type;
	}
	if (type == "publishingflow"){
		popupDest = "../utils/propertiesFrame.asp?title=Publishing Flow&url="+escape("../status/manager.aspx?section="+fieldName);
	}
	if (type == "reject"){
		popupDest = "../utils/propertiesFrame.asp?title=Reject&url="+escape("../status/reject.asp?BlockID="+getDocumentVar("currentBlock"));
		width = 400;
		height = 350;
	}
	if (type == "rolepage_add"){
		popupDest = "../utils/propertiesFrame.asp?title=Add Page&url="+escape("../role/rolepage_add.asp?RoleID="+id);
		width = 400;
		height = 350;
		xoff = 0;
		yoff = 0;
	}
	if (type == "rolepage_edit"){
		popupDest = "../utils/propertiesFrame.asp?title=Edit Page&url="+escape("../role/rolepage_edit.asp?PageID="+id);
		width = 400;
		height = 350;
		xoff = 0;
		yoff = 0;
	}
	if (type == "roleProperties"){
		popupDest = "../utils/propertiesFrame.asp?title=Role Properties&url="+escape("../role/edit_tabs.aspx?section="+fieldName+"&RoleID="+id);
	}
	if (type == "rolestatus_edit"){
		popupDest = "../utils/propertiesFrame.asp?title=Assigned Status Properties&url="+escape("../role/rolestatus_edit.asp?RoleID="+id+"&StatusID="+getDocumentVar("selectedID"));
		width = 400;
		height = 350;
		xoff = 50;
		yoff = 50;
	}
	if (type == "review"){
		popupDest = "../utils/propertiesFrame.asp?title=Review&url="+escape("../block/review.asp?BlockID="+getDocumentVar("currentBlock"));
		width = 400;
		height = 350;
	}
	if (type == "search_stats"){
		popupDest = "../utils/propertiesFrame.asp?title=Search Stats&url="+escape("../search/stats.asp");
		width = 400;
		height = 350;
	}
	if (type == "seo_page_report"){
		popupDest = "../utils/propertiesFrame.asp?title=SEO Page Report&url="+escape("../seo/pageReport.aspx?section="+fieldName+"&PageID="+getDocumentVar("currentPage"));
		width = 800;
		height = 475;
	}
	if (type == "seo_page_report_view"){
		popupDest = "../utils/propertiesFrame.asp?title=SEO Page Report&url="+escape("../seo/pageReportView.asp?PageID="+id+"&identifier="+fieldName);
		width = 400;
		height = 350;
	}
	if (type == "signoff"){
		popupDest = "../utils/propertiesFrame.asp?title=Signoff&url="+escape("../status/signoff.asp?BlockID="+getDocumentVar("currentBlock"));
		width = 400;
		height = 350;
	}
	if (type == "siteProperties"){
		popupDest = "../utils/propertiesFrame.asp?title=Site Properties&url="+escape("../site/edit_tabs.aspx?section="+fieldName+"&SiteID="+id);
	}
	if (type == "status_add"){
		popupDest = "../utils/propertiesFrame.asp?title=Add Status&url="+escape("../status/add.asp");
		width = 400;
		height = 350;
		xoff = 50;
		yoff = 50;
	}
	if (type == "status_edit" && getDocumentVar("selectedID") > 0){
		popupDest = "../utils/propertiesFrame.asp?title=Edit Status&url="+escape("../status/edit.asp?StatusID="+getDocumentVar("selectedID"));
		width = 400;
		height = 350;
		xoff = 50;
		yoff = 50;
	}
	if (type == "type"){
		popupDest = "../utils/propertiesFrame.asp?title=Content Types&url="+escape("../type/manager.aspx?section="+fieldName);
	}
	if (type == "type_add"){
		popupDest = "../utils/propertiesFrame.asp?title=Add Type&url="+escape("../type/add.asp");
		width = 400;
		height = 350;
		xoff = 50;
		yoff = 50;
	}
	if (type == "type_edit" && getDocumentVar("selectedID") > 0){
		popupDest = "../utils/propertiesFrame.asp?title=Edit Type&url="+escape("../type/edit_tabs.aspx?section="+fieldName+"&TypeID="+getDocumentVar("selectedID"));
		xoff = 50;
		yoff = 50;
	}
	if (type == "typestatus_edit"){
		popupDest = "../utils/propertiesFrame.asp?title=Assigned Status Properties&url="+escape("../type/typestatus_edit.asp?TypeID="+id+"&StatusID="+getDocumentVar("selectedID"));
		width = 400;
		height = 350;
		xoff = 50;
		yoff = 50;
	}
	if (type == "updateURL"){
		popupDest = "../utils/progressFrame.asp?title=URL Update&heading1=Updating URLs&heading2=PageID&autoClose=1&currentItem="+id+"&url="+escape("../page/updateURLProgress.asp?PageID="+id)+"&type="+type;
	}
	if (type == "user_add"){
		popupDest = "../utils/propertiesFrame.asp?title=Add User&url="+escape("../users/add.asp?RoleID="+id);
		width = 400;
		height = 350;
		xoff = 0;
		yoff = 0;
	}
	if (type == "user_assigned_lists"){
		popupDest = "../utils/propertiesFrame.asp?title=Lists&url="+escape("../users/lists_assigned.asp?UserID="+getDocumentVar("currentUser"));
		width = 400;
		height = 350;
	}	
	if (type == "user_edit"){
		popupDest = "../utils/propertiesFrame.asp?url="+escape("../users/edit_tabs.aspx?section="+fieldName+"&UserID="+id);
	}
	if (type == "user_import"){
		popupDest = "../utils/propertiesFrame.asp?title=Import Users&url="+escape("../users/import.asp?RoleID="+id);
		width = 400;
		height = 350;
		xoff = 0;
		yoff = 0;
	}
	if (type == "userpage_add"){
		popupDest = "../utils/propertiesFrame.asp?title=Add Page&url="+escape("../users/userpage_add.asp?UserID="+id);
		width = 400;
		height = 350;
		xoff = 0;
		yoff = 0;
	}
	if (type == "userpage_edit"){
		popupDest = "../utils/propertiesFrame.asp?title=Edit Page&url="+escape("../users/userpage_edit.asp?PageID="+id);
		width = 400;
		height = 350;
		xoff = 0;
		yoff = 0;
	}
	if (type == "userstatus_edit"){
		popupDest = "../utils/propertiesFrame.asp?title=Assigned Status Properties&url="+escape("../users/userstatus_edit.asp?UserID="+id+"&StatusID="+getDocumentVar("selectedID"));
		width = 400;
		height = 350;
		xoff = 50;
		yoff = 50;
	}
	if (type == "version_history"){
		popupDest = "../utils/propertiesFrame.asp?title=Versions&url="+escape("../block/version_tabs.aspx?section="+fieldName+"&BlockID="+getDocumentVar("currentBlock"));
	}
	if (type == "webimport"){
		popupDest = "../utils/propertiesFrame.asp?title=Web Site Imports&url="+escape("../import/web.aspx?section="+fieldName);
	}
	if (type == "webimport_add"){
		popupDest = "../utils/propertiesFrame.asp?title=Import From Web Site&url="+escape("../import/addWebImport.asp");
		width = 400;
		height = 350;
		xoff = -50;
		yoff = 10;
	}
	if (type == "webimport_edit"){
		popupDest = "../utils/propertiesFrame.asp?title=Import From Web Site&url="+escape("../import/addWebImport.asp?WebImportID="+getDocumentVar("selectedID"));
		width = 400;
		height = 350;
		xoff = -50;
		yoff = 10;
	}
	if (type == "webimport_run"){
		popupDest = '../tools/importProgressFrame.asp?WebImportID='+window.getDocumentVar('selectedID')+'&start=1';
		width = 800; //400
		height = 650; //350
		xoff = -50;
		yoff = 10;
//		notModal = 1;
	}



	//'' Windows with Service pack 2 forces a status bar at the bottom of the window, so increase hight
	height += 20;

	// open the popup. the popup will return an XML string
	rVal = "";
	if(popupDest>""){
		rVal = newWin(popupDest+"&dragOverID="+getDocumentVar("dragOverID")+"&selectedID="+getDocumentVar("selectedID"), "popup",width,height,'',xoff,yoff, notModal);  
	}
		
	// break the return val into it's parts - it comes as XML
	// work out what section this is in
	var strAction = new String(rVal);
	rExp = /.*<action>(\w*)<\/action>.*/i;
	strAction = strAction.replace(rExp,"$1");

	var strID = new String(rVal);
	if (strID == "undefined"){strID = "";}
	rExp = /.*<id>(\w*)<\/id>.*/i;
	strID = strID.replace(rExp,"$1");

	var strMessage = new String(rVal);
	rExp = /.*<message>(.*)<\/message>.*/i;
	strMessage = strMessage.replace(rExp,"$1");

	var strName = new String(rVal);
	rExp = /.*<name>(.*)<\/name>.*/i;
	strName = strName.replace(rExp,"$1");

	var strSection = new String(rVal);
	rExp = /.*<section>(\w*)<\/section>.*/i;
	strSection = strSection.replace(rExp,"$1");

	var strStatus = new String(rVal);
	rExp = /.*<status>(\w*)<\/status>.*/i;
	strStatus = strStatus.replace(rExp,"$1");

	var strType = new String(rVal);
	rExp = /.*<type>(.*)<\/type>.*/i;
	strType = strType.replace(rExp,"$1");



	if (type == "addClient"){
		if (strStatus == "ok"){
			startWaitBar();
			window.frames["mainPanel"].location.href = window.frames["mainPanel"].location.href;
		}
	}


	if(type=="bin"){
		doRefreshTree();
	}
	

	if(type=="bin_purge"){
		// refresh the list
		if(window.frames['tabs'] && window.frames['tabs'].frames['list']){
			window.frames["tabs"].frames["list"].location.href = window.frames["tabs"].frames["list"].location.href;
		}
	}


	if(type=="bin_restore"){
		// refresh the list
		if(window.frames['tabs'] && window.frames['tabs'].frames['list']){
			window.frames["tabs"].frames["list"].location.href = window.frames["tabs"].frames["list"].location.href;
		}
	}
	
	
	if (type == "blockDropOnPage"){
		if (strAction == "linkedBlock"){
			if (strStatus == "success"){
				// we must refresh the main panel if the block was dropped on the current page
				if (getDocumentVar("currentPage") == getDocumentVar("dragOverID")){
					window.frames["mainPanel"].location.href = window.frames["mainPanel"].location.href;
				}
			} else {
				alert("An error ocurred while trying to create the linked block.\n\n"+strMessage);
				doRefreshTree();
			}
		}

		if (strAction == "commit"){
			if (strStatus == "success"){
				// we must refresh the main panel if the block was dropped on the current page
				window.frames["mainPanel"].location.href = window.frames["mainPanel"].location.href;
			}
		}

		if (strAction == "copy"){
			if (strStatus == "success"){
				// we must refresh the main panel if the block was dropped on the current page
				if (getDocumentVar("currentPage") == getDocumentVar("dragOverID")){
					window.frames["mainPanel"].location.href = window.frames["mainPanel"].location.href;
				}
			} else {
				alert("An error ocurred while trying to copy the block.\n\n"+strMessage);
				doRefreshTree();
			}
		}

		if (strAction == "move"){
			if (strStatus == "success"){
				// save the current pageid
				var tmpPageID = getDocumentVar("currentPage");
				var tmpPageName = getDocumentVar("currentPageName");
				
				// refresh current as it is no longer valid (since we moved the block away)
				resetCurrent();
				
				// set the page variables - needed for doPageTab()
				setDocumentVar("currentPage",tmpPageID);
				setDocumentVar("currentPageName",tmpPageName);
				
				// we must refresh the main panel as the block is no longer on it
				doPageTab("blocks");

			} else {
				alert("An error ocurred while trying to move the block.\n\n"+strMessage);
				doRefreshTree();
			}
		}
	}

	if (type == "blockProperties"){
		if (strStatus == "ok"){
			startWaitBar();
			window.frames["mainPanel"].location.href = window.frames["mainPanel"].location.href;
		}
	}


	if (type == "blockTemplate"){
		if (strStatus == "ok"){
			// this will set the field on the properties popup
			doMenuOpen(strSection,strID);
			setDocumentVar("popupType","");
			// now change the visible text so the user can see the new template details
			window.frames["tabs"].document.all.blockTemplate_name.innerText = strName;
		}
	}

	if (type == "clientProperties"){
		if (strStatus == "ok"){
			startWaitBar();
			eval(getDocumentVar("currentActiveWindow")+".location.href = "+getDocumentVar("currentActiveWindow")+".location.href ;");
		}
	}

	if (type == "commit"){
		if (strStatus == "success"){
			startWaitBar();
			eval(getDocumentVar("currentActiveWindow")+".location.href = "+getDocumentVar("currentActiveWindow")+".location.href ;");
		}
	}

	if (type == "deploymentProperties"){
		if (strStatus == "ok"){
			startWaitBar();
			eval(getDocumentVar("currentActiveWindow")+".location.href = "+getDocumentVar("currentActiveWindow")+".location.href ;");
		}
	}

	if (type == "deployment_run_options"){
		if (strStatus == "success"){
			if (strAction == "deploy_user_jobs"){
				setTimeout("window.frames['jobs'].location.href = '../utils/runJobs.asp?override=1&UserID="+getDocumentVar("UserID")+"'",1);				
			}
			if (strAction == "deploy_all_jobs"){
				setTimeout("window.frames['jobs'].location.href = '../utils/runJobs.asp?override=1'",1);				
			}
		}
	}

	if (type == "email_add" || type == "email_edit"){
		if(strStatus == "success" || strStatus == "ok"){
			doRefreshTree();
		}
	}
	
	
	if (type == "event_add" || type == "event_edit"){
		if(strStatus == "success" || strStatus == "ok"){
			doRefreshTree();
			eval(getDocumentVar("currentActiveWindow")+".location.href = "+getDocumentVar("currentActiveWindow")+".location.href");
		}
	}
	

	if (type == "pageDropOnPage"){
		if (strAction == "move"){
			if (strStatus == "success"){
				doRefreshTree();
			} else {
				alert("An error ocurred while trying to move the page.\n\n"+strMessage);
				doRefreshTree();
			}
		}
		if (strAction == "copy"){
			if (strStatus == "success"){
				doRefreshTree();
			} else {
				alert("An error ocurred while trying to move the page.\n\n"+strMessage);
				doRefreshTree();
			}
		}
	}


	if (type == "field_add" || type == "field_edit"){
		window.frames["list"].location.href = window.frames["list"].location.href;
	}
	
		
	if (type == "file" && strID){
		markUnsaved();
		// "open" the item to simulate it being select	ed
		doMenuOpen("file",strID);
	}
	
	
	if (type == "file_edit" ){
		if(strStatus == "ok"){
			window.frames["mainPanel"].location.href = window.frames["mainPanel"].location.href;
		}
	}
	

	if (type == "fileCategoryProperties"){
		if (strStatus == "ok"){
			doRefreshTree();
		}
	}


	if (type == "ftpexport_view"){
		if(strStatus == "success" || strStatus == "ok"){
			window.parent.iframeLoaded = 0;
			document.all.mask.style.visibility = 'visible';
			resetCurrent();
			document.all.list.src = document.all.list.src;
		}
	}



	if (type == "ftpimport_run"){
		return strStatus;
	}


	if (type == "ftpimport_view"){
		if(strStatus == "success" || strStatus == "ok"){
			window.parent.iframeLoaded = 0;
			document.all.mask.style.visibility = 'visible';
			resetCurrent();
			document.all.list.src = document.all.list.src;
		}
	}

	if (type == "ftpsite_add" || type == "ftpsite_edit"){
		if(strStatus == "success" || strStatus == "ok"){
			window.parent.iframeLoaded = 0;
			document.all.mask.style.visibility = 'visible';
			resetCurrent();
			document.all.list.src = document.all.list.src;
		}
	}



	if (type == "forceLogout"){
		window.frames["tabs"].location.href=window.frames["tabs"].location.href;
	}
		
	
	
	if (type == "image" && strID){
		markUnsaved();
		// "open" the item to simulate it being selected
		doMenuOpen("image",strID);
	}
	
	
	if (type == "image_edit" ){
		if(strStatus == "ok"){
			window.frames["mainPanel"].location.href = window.frames["mainPanel"].location.href;
		}
	}
	

	if (type == "imageCategoryProperties"){
		if (strStatus == "ok"){
			doRefreshTree();
		}
	}



	if (type == "link-old"){

		if (strSection == "external" && getDocumentVar("selectedSubSection") == "field_text"){
			// we need to call the createlink function on the page
			setDocumentVar("tempVar",strName);

			window.frames["mainPanel"].frames["page_tabs"].createSiteLink();
		}
		if (strSection == "external" && getDocumentVar("selectedSubSection") == "field_input"){
			setPopupField(strName); 
		}
		// if an image has been selected...
		// using doMenuOpen is clunky - we want to move this into a new function
		if ((strID) && getDocumentVar("selectedSubSection") == "field_image"){
			// the selectedSubName has the img number in it, which we need for the field name.
			// which this is a temporary solution until we have unlimited fields
			// now we must simulate "opening" the selected item
			doMenuOpen(strSection,strID);
		}
		if ((strID) && getDocumentVar("selectedSubSection") == "field_hidden"){
			// now we must simulate "opening" the selected item
			doMenuOpen(strSection,strID);
		}
		if ((strID) && getDocumentVar("selectedSubSection") == "field_input"){
			// now we must simulate "opening" the selected item
			doMenuOpen(strSection,strID);
			eval("window.top.frames['mainPanel'].frames['page_tabs'].document.all.composeForm."+fieldName+"_name.value = strName;");

		}
		if ((strID) && getDocumentVar("selectedSubSection") == "field_text"){
			// we need to call the createlink function on the page
			setDocumentVar("tempVar","{link_"+strSection+"_"+strID+"}");

			window.frames["mainPanel"].frames["page_tabs"].createSiteLink();
		}

	}


	if (type == "link"){

		if (strSection == "external" && getDocumentVar("selectedSubSection") == "field_text"){
			// we need to call the createlink function on the page
			setDocumentVar("tempVar",strName);

			window.frames["mainPanel"].frames["page_tabs"].createSiteLink();
		}
		if (strSection == "external" && getDocumentVar("selectedSubSection") == "field_input"){
			setPopupField(strName); 
		}
		// if an image has been selected...
		// using doMenuOpen is clunky - we want to move this into a new function
		if ((strID) && getDocumentVar("selectedSubSection") == "field_image"){
			// the selectedSubName has the img number in it, which we need for the field name.
			// which this is a temporary solution until we have unlimited fields
			// now we must simulate "opening" the selected item
			doMenuOpen(strSection,strID);
		}
		if ((strID) && getDocumentVar("selectedSubSection") == "field_hidden"){
			// now we must simulate "opening" the selected item
			doMenuOpen(strSection,strID);
		}
		if ((strID) && getDocumentVar("selectedSubSection") == "field_input"){
			// now we must simulate "opening" the selected item
			doMenuOpen(strSection,strID);
			eval("window.top.frames['mainPanel'].frames['page_tabs'].document.all.composeForm."+fieldName+"_name.value = strName;");

		}
		if ((strID) && getDocumentVar("selectedSubSection") == "field_text"){
			// we need to call the createlink function on the page
//			setDocumentVar("tempVar","{link_"+strSection+"_"+strID+"}");

//			window.frames["mainPanel"].frames["page_tabs"].createSiteLink();
//			parent.parent.document.getElementById("selectedSrc").value="{link_"+strSection+"_"+strID+"}";
//		    parent.parent.document.getElementById("ok").onclick();
			alert(parent.location.href);
		}

	}


	if (type == "linked_block"){
		if(strSection == "block"){
			window.frames['tabs'].document.composeForm.LinkedBlockID.value = strID;
		} else {
			alert("You must select a block.");
		}
	}


	if (type == "list_add" || type == "list_edit"){
		if(strStatus == "success" || strStatus == "ok"){
			window.parent.iframeLoaded = 0;
//			document.all.mask.style.visibility = 'visible';
			resetCurrent();
			window.frames["list"].location.href = window.frames["list"].location.href;
		}
	}


	if (type == "new" ){
		if(strStatus == "success"){
			//'' if the current main panel is block list or page preview, go to block editor
			if(strType == "block" && (getDocumentVar("currentTab") == "blocks" || getDocumentVar("currentTab") == "preview") && (getDocumentVar("currentSection") == "page" || getDocumentVar("currentSection") == "block")){
				window.frames["mainPanel"].location.href = "../page_tabs/tabs.asp?section=editor&PageID="+getDocumentVar("currentPage")+"&BlockID="+strID;
			} else if(strType == "image" && (getDocumentVar("currentSection") == "imagecategory" || getDocumentVar("currentSection") == "image")){
				window.frames["mainPanel"].location.href = window.frames["mainPanel"].location.href;
			} else if(strType == "file" && (getDocumentVar("currentSection") == "filecategory" || getDocumentVar("currentSection") == "file")){
				window.frames["mainPanel"].location.href = window.frames["mainPanel"].location.href;
			} else if(strType == "role" && (getDocumentVar("currentSection") == "role" || getDocumentVar("currentSection") == "user")){
				doRefreshTree();
			} else {
				if(getDocumentVar("currentActiveWindow") > ""){
					eval(getDocumentVar("currentActiveWindow")+".location.href = "+getDocumentVar("currentActiveWindow")+".location.href ;");
				}
			}
		}
	}

	if (type == "new_email_delivery"){
		if(strStatus == "success"){
			window.location.href = window.location.href;
		}
	}

	if (type == "new_image_advanced_options" ){
		if(strStatus == "success"){
			eval("document."+fieldName+".value = '"+strMessage+"'");
		}
	}
	
	if (type == "new_version" ){
		if(strStatus == "success"){
			eval(getDocumentVar("currentActiveWindow")+".location.href = "+getDocumentVar("currentActiveWindow")+".location.href ;");
		}
	}


	if (type == "reject" ){
		if(strStatus == "success"){
			eval(getDocumentVar("currentActiveWindow")+".location.href = "+getDocumentVar("currentActiveWindow")+".location.href ;");
		}
	}

	if (type == "review"){
		if (strStatus == "success"){
			startWaitBar();
			eval(getDocumentVar("currentActiveWindow")+".location.href = "+getDocumentVar("currentActiveWindow")+".location.href ;");
		}
	}

	if (type == "rolepage_add"){
		if(strStatus == "success" || strStatus == "ok"){
			window.location.href = window.location.href;
		}
	}

	if (type == "rolepage_edit"){
		if(strStatus == "success" || strStatus == "ok"){
			window.location.href = window.location.href;
		}
	}


	if (type == "roleProperties" ){
		if(strStatus == "ok"){
			if(getDocumentVar("currentSection") == "role" || getDocumentVar("currentSection") == "user"){
				doRefreshTree();
			}
		}
	}


	if (type == "search_browse"){

		window.frames["explorerPanel"].frames["menu"].document.composeForm.searchBrowse.value = strID;
		window.frames["explorerPanel"].frames["menu"].document.composeForm.searchBrowseName.value = strName;
		window.frames["explorerPanel"].frames["menu"].document.composeForm.searchBrowseSection.value = strSection;

	}


	if (type == "select_filecategory"){
		if(strSection == "filecategory"){
			eval(getDocumentVar("currentActiveWindow")+".document.composeForm.select_filecategory_name.value = '"+strName+"'");
			eval(getDocumentVar("currentActiveWindow")+".document.composeForm.select_filecategory_id.value = "+strID);
		}
	}
	
	
	if (type == "select_imagecategory"){
		if(strSection == "imagecategory"){
			eval(getDocumentVar("currentActiveWindow")+".document.composeForm.select_imagecategory_name.value = '"+strName+"'");
			eval(getDocumentVar("currentActiveWindow")+".document.composeForm.select_imagecategory_id.value = "+strID);
		}
	}
	
	
	if (type == "select_page"){
		if(strSection == "page"){
			eval(getDocumentVar("currentActiveWindow")+".document.composeForm.select_page_name.value = '"+strName+"'");
			eval(getDocumentVar("currentActiveWindow")+".document.composeForm.select_page_id.value = "+strID);
		}
	}


	if (type == "select_type"){
		if(strSection == "type"){
			eval(getDocumentVar("currentActiveWindow")+".document.composeForm.select_type_name.value = '"+strName+"'");
			eval(getDocumentVar("currentActiveWindow")+".document.composeForm.select_type_id.value = "+strID);
		}
	}
	
	
	if (type == "signoff" ){
		if(strStatus == "success"){
			eval(getDocumentVar("currentActiveWindow")+".location.href = "+getDocumentVar("currentActiveWindow")+".location.href ;");
		}
	}

	if (type == "siteProperties"){
		if(strStatus == "success" || strStatus == "ok"){
			doRefreshTree();
			eval(getDocumentVar("currentActiveWindow")+".location.href = "+getDocumentVar("currentActiveWindow")+".location.href");
		}
	}

	if (type == "status_add" || type == "status_edit"){
		if(strStatus == "success"){
			window.parent.iframeLoaded = 0;
			document.all.mask.style.visibility = 'visible';
			document.all.list.src = document.all.list.src;
		}
	}

	if (type == "type_add" || type == "type_edit"){
		if(strStatus == "success" || strStatus == "ok"){
			window.parent.iframeLoaded = 0;
			document.all.mask.style.visibility = 'visible';
			resetCurrent();
			document.all.list.src = document.all.list.src;
		}
	}
	
	if (type == "typestatus_edit"){
		if(strStatus == "success" || strStatus == "ok"){
			document.all.mask2.style.visibility = 'visible';
			document.all.list.src = document.all.list.src;
		}
	}
	
	if (type == "updateURL"){
		if (strStatus != "success"){
			alert ("The URL update was interrupted before it completed.\n\nWARNING: The web site may become unstable when the URL update is interrupted. To rectify this problem, change the URL Name to a new value and allow the update to complete.");
		}
	}

	if (type == "user_add" || type == "user_edit"){
		if(strStatus == "success" || strStatus == "ok"){
			window.frames["mainPanel"].location.href = window.frames["mainPanel"].location.href;
		}
	}

	if (type == "userpage_add"){
		if(strStatus == "success" || strStatus == "ok"){
			window.location.href = window.location.href;
		}
	}

	if (type == "userpage_edit"){
		if(strStatus == "success" || strStatus == "ok"){
			window.location.href = window.location.href;
		}
	}

	if (type == "user_import"){
		if((strStatus == "success" || strStatus == "ok") && (getDocumentVar("currentSection")=="role" || getDocumentVar("currentSection")=="user")){
			window.frames["mainPanel"].location.href = window.frames["mainPanel"].location.href;
		}
	}

	if (type == "webimport_add" || type == "webimport_edit"){
		if(strStatus == "success" || strStatus == "ok"){
			window.frames["list"].location.href = window.frames["list"].location.href;
		}
	}

	
	setDocumentVar("popupType","");
	setDocumentVar("popupID","");
	setDocumentVar("popupField","");
	

}


function doRefreshTree(){
	startWaitBar();
	window.frames["explorerPanel"].frames["code"].location.href = window.frames["explorerPanel"].frames["code"].location.href;

	setRefreshTree(1);
}



function doSelectTreeItem(section,id,itemName){

	if (section == "blocktemplate"){		
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		//reset the saved 
		markSaved();
		doSelectItem(section,id,itemName);
		setMainPanel("../blocktemplate/view.asp?BlockTemplateID="+ id);
	}



	if (section == "blocktemplatecategory"){		
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		//reset the saved 
		markSaved();
		doSelectItem(section,id,itemName);
		setMainPanel("../blocktemplate/list.asp?BlockTemplateCategoryID="+ id);
	}


	if (section == "email"){

		//'' if this is a delivery, call that function
		if(String(itemName).match(/^Delivery/))
			return doSelectTreeItem("email_delivery",id,itemName);
			
			
		// if the selected page is the current page, don't do anything
		if(getDocumentVar("currentSection") == "email" && getDocumentVar("currentEmail") == id){
			return false;
		}
	
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		//reset the saved 
		markSaved();

		// reset the highlighted item
		setDocumentVar("highlightedID","");

		//highglight the selected tree item
		highlightTreeItem(id,1);

		doSelectItem(section,id,itemName);

		//'' if this is the campaign node, show an overview page
		if(itemName == "Campaigns"){
			setMainPanel("../email/campaigns_welcome.asp");
		} else {
			setMainPanel("../email/email.aspx?section=General&EmailID="+ id);
		}
	}


	if (section == "email_delivery"){

		// if the selected page is the current page, don't do anything
		if(getDocumentVar("currentSection") == "email_delivery" && getDocumentVar("currentEmail") == id){
			return false;
		}
	
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		//reset the saved 
		markSaved();

		// reset the highlighted item
		setDocumentVar("highlightedID","");

		//highglight the selected tree item
		highlightTreeItem(id,1);

		doSelectItem(section,id,itemName);

		//'' if this is the campaign node, show an overview page
		setMainPanel("../email/emaildelivery.aspx?section=General&EmailID="+ id);
	}



	if (section == "filecategory"){

		// if the selected page is the current page, don't do anything
		if(getDocumentVar("currentSection") == "filecategory" && getDocumentVar("currentFileCategory") == id){
			return false;
		}
	
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		//reset the saved 
		markSaved();

		// reset the highlighted item
		setDocumentVar("highlightedID","");

		//highglight the selected tree item
		highlightTreeItem(id,1);

		doSelectItem(section,id,itemName);

		setMainPanel("../file/list.asp?FileCategoryID="+ id);
	}


	if (section == "imagecategory"){		

		// if the selected page is the current page, don't do anything
		if(getDocumentVar("currentSection") == "imagecategory" && getDocumentVar("currentImageCategory") == id){
			return false;
		}

		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		//reset the saved 
		markSaved();

		// reset the highlighted item
		setDocumentVar("highlightedID","");

		//highglight the selected tree item
		highlightTreeItem(id,1);

		doSelectItem(section,id,itemName);

		setMainPanel("../image/list.asp?ImageCategoryID="+ id);
	}



	if (section == "ordercategory"){		

		// if the selected page is the current page, don't do anything
		if(getDocumentVar("currentSection") == "ordercategory" && getDocumentVar("currentOrderCategory") == id){
			return false;
		}

		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		//reset the saved 
		markSaved();

		// reset the highlighted item
		setDocumentVar("highlightedID","");

		//highglight the selected tree item
		highlightTreeItem(id,1);

		doSelectItem(section,id,itemName);

		setMainPanel("../order/list.asp?OrderCategoryID="+ id);
	}


	if (section == "page"){
	
		// if the selected page is the current page, don't do anything
		if(getDocumentVar("currentSection") == "page" && getDocumentVar("currentPage") == id){
		//	return false;
		}
				
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		//reset the saved 
		markSaved();
		
		// reset the highlighted item
		setDocumentVar("highlightedID","");
		
		// reset the currently highlighted tree item
		// we don't need to do this as the searchHighlight function resets the tree anyway
		
		//highglight the selected tree item
		// commented out as it caused the wrong page to load. instead we reload the explorer panel
		//highlightTreeItem(id,1);
		
		// reset the block variables (we don't want to carry over a current block 
		//    that was set for another page)
		setDocumentVar("currentBlock","");
		setDocumentVar("currentBlockName","");
		
		doSelectItem(section,id,itemName);
		
		var tmpSection = "blocks";
		if(getDocumentVar("RoleID") == 4){
			tmpSection = "preview";
		}

		var currentSrc = String(window.frames["mainPanel"].location.href);
		if(currentSrc.match(/users\/data_menu/)){
			doUserDataTab("blocks");
		} else {
			doPageTab("blocks");
		}
	}

	if (section == "pagetemplatecategory"){		
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		//reset the saved 
		markSaved();
		doSelectItem(section,id,itemName);
		setMainPanel("../pagetemplate/list.asp?PageTemplateCategoryID="+ id);
	}

	
	if (section == "page_site"){		
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		//reset the saved 
		markSaved();
		doSelectItem(section,id,itemName);
		setMainPanel("../site/view.asp?SiteID="+id)	;

	}


	if (section == "role"){		
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		//reset the saved 
		markSaved();
		
		// reset the current user
		setDocumentVar("currentUser","");
		setDocumentVar("currentUserName","");

		//highglight the selected tree item
		highlightTreeItem(id,1);

		doSelectItem(section,id,itemName);
		window.top.setMainPanel("../users/list.asp?RoleID="+id)	;
		
	}



	if (section == "site"){		
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		//reset the saved 
		markSaved();
		doSelectItem(section,id,itemName);
		gotoSiteTab("general",id)
//		window.top.setMainPanel("../site/view.asp?SiteID="+id)	;

	}

	if (section == "stats"){		
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		//reset the saved 
		markSaved();
		doSelectItem(section,id,itemName);
		gotoStatsTab("current",id)
	}


	if (section == "user"){		
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		
		//reset the saved 
		markSaved();
		doSelectItem(section,id,itemName);
		window.top.setMainPanel("../users/userpermissions.asp?UserID="+id)	;

	}
	
	
} // end doSelectTreeItem




function doSelectItem(section,id,itemName){

	// set the address status field
	setStatusMessage("address",section+": "+itemName+" ("+id+")");

	if (section == "block"){

		setDocumentVar("currentActiveWindow","window.frames['mainPanel'].frames['page_tabs']");
	
		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentBlock = id;
		currentBlockName = itemName;
		
		

		// if the sub section is blocks, then set the bg color
		if (currentSubSection == "blocks"){

			// reset the current highlighted item
			if (highlightedID > 0){
				try{
					eval("var selectedObj = window.frames['mainPanel'].frames['page_tabs'].document.all.Item_"+highlightedID);
				}catch(er){}
				if(selectedObj){
					eval("window.frames['mainPanel'].frames['page_tabs'].document.all.Item_"+highlightedID+".style.backgroundColor='White';");
				}
			}

			// highlight the selected item
			highlightedID = selectedID;

			if (highlightedID > 0){
				try{
					eval("var selectedObj = window.frames['mainPanel'].frames['page_tabs'].document.all.Item_"+highlightedID);
				}catch(er){}
				if(selectedObj){
					eval("window.frames['mainPanel'].frames['page_tabs'].document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");
				}

				// now set the properites info
				try{
					propertiesStr = "";
					propertiesStr += "<br><p><strong>Block Properties</strong></p>";
					eval("propertiesStr += '<b>Block Name</b><br>'+window.frames['mainPanel'].frames['page_tabs'].Item_"+highlightedID+"_name.value+'<br>';");
					eval("propertiesStr += '<b>Type</b><br>'+window.frames['mainPanel'].frames['page_tabs'].Item_"+highlightedID+"_type.value+'<br>';");
					eval("propertiesStr += '<b>Modified By</b><br>'+window.frames['mainPanel'].frames['page_tabs'].Item_"+highlightedID+"_updatedBy.value+'<br>';");

					window.frames['mainPanel'].frames['page_tabs'].document.all.block_properties.innerHTML = propertiesStr;
					window.frames['mainPanel'].frames['page_tabs'].document.all.block_properties.className = "botborder";
				}catch(er){}
				 
			}
			
		}  // end if blocks


		if (currentSubSection == "layout"){

			// reset the current highlighted item
			if (highlightedID > 0){
				eval("window.frames['mainPanel'].frames['page_tabs'].document.all.Item_"+highlightedID+".style.border='solid white 1px';");
			}

			// highlight the selected item
			highlightedID = selectedID;

			if (highlightedID > 0){
				eval("window.frames['mainPanel'].frames['page_tabs'].document.all.Item_"+highlightedID+".style.border='dashed red 1px';");
			}			
			
			
		}	// end if layout
			
	} // end if block


	if (section == "blocktemplate"){

		// normal block template action
		setDocumentVar("currentActiveWindow","window.frames['mainPanel']");
		// set the current vars 
		setCurrentVars(section,id,itemName);
		
		setDocumentVar("currentBlockTemplate",id);
		setDocumentVar("currentBlockTemplateName",itemName);

		// reset the current highlighted item
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}

	}
	
	
	//  if selecting a blocktemplate in the add block wizard
	if (section == "blocktemplate_addblock"){
	
		setDocumentVar("currentActiveWindow","window.frames['mainPanel'].frames['page_tabs']");
		
		// reset the current highlighted item
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}

		// update the form variable
		window.frames["mainPanel"].document.form1.BlockTemplateID.value = id;

		// set the explorer preview image
		var img1 = window.frames["mainPanel"].document.all.explorer_preview_image;
		eval("img1.src = window.frames['mainPanel'].document.form1.Thumbnail_"+id+".value;");
		
	}



	if (section == "blocktemplatecategory"){

		// normal block template action
		setDocumentVar("currentActiveWindow","window.frames['mainPanel']");
		// set the current vars 
		setCurrentVars(section,id,itemName);
			currentBlockTemplateCategory = id;
			currentBlockTemplateCategoryName = itemName;
	}



	if (section == "blockversion"){

		// normal block template action
		setDocumentVar("currentActiveWindow","window.frames['tabs'].frames['list']");
		// set the current vars 
		setCurrentVars(section,id,itemName);
			currentBlockVersion = id;
			currentBlockVersionName = itemName;
			
		// reset the current highlighted item
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}


	}



	if (section == "client"){
	
		setDocumentVar("currentActiveWindow","window.frames['mainPanel']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}

	}




	if (section == "deployment"){
	
		setDocumentVar("currentActiveWindow","window.frames['mainPanel']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}

	}


	if (section == "email"){
	
		setDocumentVar("currentActiveWindow","window.frames['tabs'].frames['list']");

		// set the current vars 
		setCurrentVars("email",id,itemName);
		currentEmail = id;
		currentEmailName = itemName;

	}
	
	
	if(section == "email_delivery"){
		// set the current vars 
		setCurrentVars("email_delivery",id,itemName);
		currentEmailDelivery = id;
		currentEmailDeliveryName = itemName;
	}
	
	

	if (section == "event"){

		// normal block template action
		setDocumentVar("currentActiveWindow","window.frames['mainPanel'].frames['calendarFrame']");
		// set the current vars 
		setCurrentVars(section,id,itemName);
		
		setDocumentVar("currentEvent",id);

		// reset the current highlighted item
		if (highlightedID > ""){
			if(eval(getDocumentVar("currentActiveWindow")+".document.all.hour_"+highlightedID)){
				// get the class name from the temporary var1 field where it was savedf
				eval(getDocumentVar("currentActiveWindow")+".document.all.hour_"+highlightedID+".className=document.temporary.var1.value;");
			}
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID > ""){
			// save the class name in the temporary form
			eval("document.temporary.var1.value = "+getDocumentVar("currentActiveWindow")+".document.all.hour_"+highlightedID+".className;");

			//'' if the class is Active, then show that
			var test = String(document.temporary.var1.value);
			var activeStr = "";
			activeStr = "Active";
			eval(getDocumentVar("currentActiveWindow")+".document.all.hour_"+highlightedID+".className='jcm_calendar_event_select"+activeStr+"';");
		}

		//'' load the event in the event frame
		window.frames["mainPanel"].frames["eventFrame"].location.href = "../calendar/event.asp?EventID="+id;

	}
	

		
	if (section == "field"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentField = id;
		currentFieldName = itemName;
		
		// reset the current highlighted item
		if (getDocumentVar("highlightedSection") == "field" && highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		highlightedSection = selectedSection;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}



	if (section == "field_file"){
		// first highlight the new field (need the previous field to unhighliht it)
		highlightElement(section,id);
		// set the current sub vars 
		setCurrentSubVars(section,id,itemName);
	}


	if (section == "field_hidden"){
		// set the current sub vars 
		setCurrentSubVars(section,id,itemName);
	}



	if (section == "field_image"){
		// first highlight the new field (need the previous field to unhighliht it)
		highlightElement(section,id);
		// set the current sub vars 
		setCurrentSubVars(section,id,itemName);
	}


	if (section == "field_hidden"){
		// set the current sub vars 
		setCurrentSubVars(section,id,itemName);
	}



	if (section == "field_input"){

		setDocumentVar("currentActiveWindow","window.frames['mainPanel'].frames['page_tabs']");

		// first highlight the new field (need the previous field to unhighliht it)
		highlightElement(section,id);
		// set the current sub vars 
		setCurrentSubVars(section,id,itemName);
	}


	if (section == "field_plaintext"){
	
		markUnsaved();

		// first highlight the new field (need the previous field to unhighliht it)
		highlightElement(section,id);
		// set the current sub vars 
		setCurrentSubVars(section,id,itemName);
	}


		
	if (section == "field_text"){
	
		markUnsaved();

		// first highlight the new field (need the previous field to unhighliht it)
		highlightElement(section,id);
		// set the current sub vars 
		setCurrentSubVars(section,id,itemName);
	}


	
	if (section == "file"){
	
		setDocumentVar("currentActiveWindow","window.frames['mainPanel']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
		
		
		// now set the properites info
		propertiesStr = "";
		eval("propertiesStr += '<b>File Name</b><br>'+window.frames['mainPanel'].Item_"+highlightedID+"_name.value+'<br><br>';");
		eval("propertiesStr += '<b>Path</b><br><input type=\"text\" value=\"'+getDocumentVar('SITE_ROOT')+window.frames['mainPanel'].Item_"+highlightedID+"_src.value+'\" style=\"border:none;\"><br><br>';");
		eval("propertiesStr += '<b>Type</b><br>'+window.frames['mainPanel'].Item_"+highlightedID+"_name.value+'<br><br>';");
		eval("propertiesStr += '<b>Size</b><br>'+window.frames['mainPanel'].Item_"+highlightedID+"_size.value+'<br><br>';");		
		
		window.frames['mainPanel'].document.all.file_properties.innerHTML = propertiesStr;
	}
		

	if (section == "filecategory"){		

		setDocumentVar("currentActiveWindow","window.frames['explorerPanel']");


		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentFileCategory = id;
		currentFileCategoryName = itemName;
	}
	


	if (section == "filecategory_list_detail"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentFileCategory = id;
		currentFileCategoryName = itemName;

		// reset the current highlighted item
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail_highlighted';");
		}
	}



	if (section == "filecategory_list_detail"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentFileCategory = id;
		currentFileCategoryName = itemName;

		// reset the current highlighted item
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail_highlighted';");
		}
	}



	if (section == "ftpexport"){

		// normal block template action
		setDocumentVar("currentActiveWindow","window.frames['list']");
		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}

	}


	if (section == "ftpimport"){

		// normal block template action
		setDocumentVar("currentActiveWindow","window.frames['list']");
		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}

	}
	
	
	
	if (section == "ftpsite"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}


	if (section == "hour"){

		// normal block template action
		setDocumentVar("currentActiveWindow","window.frames['mainPanel'].frames['calendarFrame']");
		// set the current vars 
		setCurrentVars(section,id,itemName);
		
		setDocumentVar("currentHour",id);

		// reset the current highlighted item
		if (highlightedID > ""){
			// get the class name from the temporary var1 field where it was savedf
			eval(getDocumentVar("currentActiveWindow")+".document.all.hour_"+highlightedID+".className=document.temporary.var1.value;");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID > ""){
			// save the class name in the temporary form
			eval("document.temporary.var1.value = "+getDocumentVar("currentActiveWindow")+".document.all.hour_"+highlightedID+".className;");

			//'' if the class is Active, then show that
			var test = String(document.temporary.var1.value);
			var activeStr = "";
			if(test.match(/Active/)){
				activeStr = "Active";
			} 
			eval(getDocumentVar("currentActiveWindow")+".document.all.hour_"+highlightedID+".className='jcm_calendar_event_first_select"+activeStr+"';");
		}

		//'' load the event in the event frame
		window.frames["mainPanel"].frames["eventFrame"].location.href = "../calendar/blank.html";

	}
	

	
	// some selected items require highlighting
	if (section == "image"){
	
		setDocumentVar("currentActiveWindow","window.frames['mainPanel']");


		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (highlightedID > 0){
				eval("window.frames['mainPanel'].Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
				eval("window.frames['mainPanel'].Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");
		}
		
		// now set the preview image
		var img1 = new Image();
		eval("img1.src = getDocumentVar('SITE_ROOT')+window.frames['mainPanel'].Item_"+highlightedID+"_src.value;");
		window.frames['mainPanel'].document.all.image_preview.src = img1.src;
		
		// now set the properites info
		propertiesStr = "";
		eval("propertiesStr += '<b>Image Name</b><br>'+window.frames['mainPanel'].Item_"+highlightedID+"_name.value+'<br><br>';");
		eval("propertiesStr += '<b>Path</b><br><input type=\"text\" value=\"'+getDocumentVar('SITE_ROOT')+window.frames['mainPanel'].Item_"+highlightedID+"_src.value+'\" style=\"border:none;\"><br><br>';");
		eval("propertiesStr += '<b>Type</b><br>'+window.frames['mainPanel'].Item_"+highlightedID+"_type.value+'<br><br>';");
		eval("propertiesStr += '<b>Size</b><br>'+window.frames['mainPanel'].Item_"+highlightedID+"_imagesize.value+'<br><br>';");
		
		// if this is the image select popup, then include a select button
		if (window.top.name == "popup"){
			propertiesStr += '<input type="button" onClick="window.top.doMenuOpen(\'image\','+selectedID+')" value="&nbsp;&nbsp;&nbsp;Select&nbsp;&nbsp;&nbsp;"><br><br>';
		}
		
		
		window.frames['mainPanel'].document.all.image_properties.innerHTML = propertiesStr;
	}


	if (section == "image_deleted"){
	
		setDocumentVar("currentActiveWindow","window.frames['tabs'].frames['list']");

		// set the current vars 
		setCurrentVars("image",id,itemName);
		currentImage = id;
		currentImageName = itemName;

		// reset the current highlighted item
		if (highlightedID > 0 && eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID)){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}
	
	if (section == "imagecategory"){	
	
		setDocumentVar("currentActiveWindow","window.frames['explorerPanel']");
	
		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentImageCategory = id;
		currentImageCategoryName = itemName;
	}



	if (section == "imagecategory_list_detail"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentImageCategory = id;
		currentImageCategoryName = itemName;

		// reset the current highlighted item
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail_highlighted';");
		}
	}


	
	if (section == "import"){
	
		setDocumentVar("currentActiveWindow","window.frames['mainPanel']");


		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}

	}


	if(section == "job"){
		setCurrentVars(section,id);
	}


	if (section == "list_assigned"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (getDocumentVar("highlightedSection") == "list_assigned" && highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		highlightedSection = selectedSection;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}
	

	if (section == "list_available"){
	
		setDocumentVar("currentActiveWindow","window.frames['list_available']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (getDocumentVar("highlightedSection") == "list_available" && highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		highlightedSection = selectedSection;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}



	if (section == "list_list_detail"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars("list",id,itemName);
		currentList = id;
		currentListName = itemName;

		// reset the current highlighted item
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail_highlighted';");
		}
	}


	if(section == "log"){
		setCurrentVars(section,id);
	}

	if (section == "module"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (getDocumentVar("highlightedSection") == "module" && highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		highlightedSection = selectedSection;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}



	if (section == "module_available"){
	
		setDocumentVar("currentActiveWindow","window.frames['list_available']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (getDocumentVar("highlightedSection") == "module_available" && highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		highlightedSection = selectedSection;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}


	if (section == "order_list_detail"){
	
		setDocumentVar("currentActiveWindow","window.frames['mainPanel']");

		// set the current vars 
		setCurrentVars("order",id,itemName);
		currentOrder = id;
		currentOrderName = itemName;

		// reset the current highlighted item
		eval("var testObj = "+getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID);
		if (testObj){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail_highlighted';");
		}
	}


	

	if (section == "page"){
	
		setDocumentVar("currentActiveWindow","window.frames['explorerPanel']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentPage = id;
		currentPageName = itemName;
		
	}



	if (section == "page_deleted"){
	
		setDocumentVar("currentActiveWindow","window.frames['tabs'].frames['list']");

		// set the current vars 
		setCurrentVars("page",id,itemName);
		currentPage = id;
		currentPageName = itemName;

		// reset the current highlighted item
		if (highlightedID > 0 && eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID)){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}
	
	
	
	if (section == "page_list_thumbnail"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentPage = id;
		currentPageName = itemName;

		// reset the current highlighted item
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_thumbnail';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_thumbnail_highlighted';");
		}
	}
	


	if (section == "page_list"){
	
		setDocumentVar("currentActiveWindow","window.frames['mainPanel']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentPage = id;
		currentPageName = itemName;

		// reset the current highlighted item
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}



	if (section == "page_list_detail"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentPage = id;
		currentPageName = itemName;

		// reset the current highlighted item
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail_highlighted';");
		}
	}



	if (section == "page_list_thumbnail"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentPage = id;
		currentPageName = itemName;

		// reset the current highlighted item
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_thumbnail';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_thumbnail_highlighted';");
		}
	}



	if (section == "page_site"){
		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentSite = id;
		currentSiteName = itemName;
	}


	// this function is just used internally in the picker popup, not propogating to the top window
	if (section == "picker_block" || section == "picker_page" || section == "picker_image" || section == "picker_imagecategory" || section == "picker_file" || section == "picker_filecategory" || section == "picker_blockTemplate" || section == "picker_type"){


		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (highlightedID > 0){
			// first check that it exists
			eval("var test = document.pickerContent.document.all.picker_item_"+highlightedID+";");
			if(test){
				eval("document.pickerContent.document.all.picker_item_"+highlightedID+".className='listItem';");
			}
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval("document.pickerContent.document.all.picker_item_"+highlightedID+".className='listItem_down';");
		}


		// work out what section this is in
		var item_section = new String(section);
		rExp = /picker_/i;
		item_section = item_section.replace(rExp,"");

		document.all.ItemName.value=itemName;
		document.all.ItemID.value=id;
		document.all.ItemSection.value=item_section;
		document.all.ItemType.value=itemName;


	}



	if (section == "pagetemplate"){

		// normal block template action
		setDocumentVar("currentActiveWindow","window.frames['mainPanel']");
		// set the current vars 
		setCurrentVars(section,id,itemName);
		
		setDocumentVar("currentPageTemplate",id);
		setDocumentVar("currentPageTemplateName",itemName);

		// reset the current highlighted item
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID > 0){
			eval("window.frames['mainPanel'].document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}

	}


	if (section == "pagetemplate_list_detail"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentPageTemplate = id;
		currentPageTemplateName = itemName;

		// reset the current highlighted item
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail_highlighted';");
		}
	}



	if (section == "pagetemplate_list_thumbnails" || section == "pagetemplate_list_thumbnail"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentPageTemplate = id;
		currentPageTemplateName = itemName;

		// reset the current highlighted item
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_thumbnail';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail_highlighted';");
		}
	}



	if (section == "pagetemplatecategory"){

		// normal block template action
		setDocumentVar("currentActiveWindow","window.frames['mainPanel']");
		// set the current vars 
		setCurrentVars(section,id,itemName);
			currentPageTemplateCategory = id;
			currentPageTemplateCategoryName = itemName;
	}


	if (section == "role"){		

		setDocumentVar("currentActiveWindow","window.frames['mainPanel']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentRole = id;
		currentRoleName = itemName;
	}


	if (section == "rolepage"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}


	if (section == "role_assigned"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (getDocumentVar("highlightedSection") == "role_assigned" && highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		highlightedSection = selectedSection;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}


	if (section == "role_available"){
	
		setDocumentVar("currentActiveWindow","window.frames['list_available']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (getDocumentVar("highlightedSection") == "role_available" && highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		highlightedSection = selectedSection;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}


	if (section == "site"){

		setDocumentVar("currentActiveWindow","window.frames['mainPanel']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentSite = id;
		currentSiteName = itemName;
	}



	if (section == "status"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (getDocumentVar("highlightedSection") == "status" && highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		highlightedSection = selectedSection;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}


	if (section == "status_available"){
	
		setDocumentVar("currentActiveWindow","window.frames['list_available']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (getDocumentVar("highlightedSection") == "status_available" && highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		highlightedSection = selectedSection;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}



	if (section == "template"){

		setDocumentVar("currentActiveWindow","window.frames['mainPanel']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentTemplate = id;
		currentTemplateName = itemName;
	}


	if (section == "type"){
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentType = id;
		currentTypeName = itemName;

		// reset the current highlighted item
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");
		}
	}


	if (section == "type_list_detail"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentType = id;
		currentTypeName = itemName;

		// reset the current highlighted item
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_detail_highlighted';");
		}
	}


	if (section == "type_list_thumbnail"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentType = id;
		currentTypeName = itemName;

		// reset the current highlighted item
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_thumbnail';");
		}
		
		// now highlight the selected item
		highlightedID = id;
		if (highlightedID){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".className='list_thumbnail_highlighted';");
		}
	}

	if (section == "user"){		

		setDocumentVar("currentActiveWindow","window.frames['mainPanel']");

		// set the current vars 
		setCurrentVars(section,id,itemName);
		currentUser = id;
		currentUserName = itemName;


		// reset the current highlighted item
		if (highlightedID > 0 && eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID)){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0 && eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID)){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");
		}

	}
	

	if (section == "user_assigned"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (getDocumentVar("highlightedSection") == "user_assigned" && highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		highlightedSection = selectedSection;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}


	if (section == "user_available"){
	
		setDocumentVar("currentActiveWindow","window.frames['list_available']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (getDocumentVar("highlightedSection") == "user_available" && highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		highlightedSection = selectedSection;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}


	if (section == "user_deleted"){
	
		setDocumentVar("currentActiveWindow","window.frames['tabs'].frames['list']");

		// set the current vars 
		setCurrentVars("user",id,itemName);
		currentUser = id;
		currentUserName = itemName;

		// reset the current highlighted item
		if (highlightedID > 0 && eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID)){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}



	if (section == "userpage"){
	
		setDocumentVar("currentActiveWindow","window.frames['list']");

		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}
	}


	if (section == "webimport"){

		// normal block template action
		setDocumentVar("currentActiveWindow","window.frames['list']");
		// set the current vars 
		setCurrentVars(section,id,itemName);

		// reset the current highlighted item
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='White';");
		}
		
		// now highlight the selected item
		highlightedID = selectedID;
		if (highlightedID > 0){
			eval(getDocumentVar("currentActiveWindow")+".document.all.Item_"+highlightedID+".style.backgroundColor='#C2C5C8';");

		}

	}
	
} // end doSelectItem







function doSelectMultipleItems(section,idArray){

	if (section == "users"){		

		// set the current vars 
		currentUsers = idArray;
		
	}
}




function doUserDataTab(section,refreshTree){

	if (section == "blocks"){
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
	
		startWaitBar();
		
		// now open the page tab
		window.frames["mainPanel"].location.href = "../users/data_menu.aspx?section=blocks&UserID="+getDocumentVar("currentUser")+((refreshTree)?"&refreshTree="+refreshTree:"");		
	
	}


	if (section == "editor"){
	
		// first check for unsaved changes
		if (abortAction()){
			return false;
		}
		startWaitBar();
		
		// now open the page tab
		window.frames["mainPanel"].location.href = "../users/data_menu.aspx?section=editor&BlockID="+getDocumentVar("currentBlock");		
	
	}


	setDocumentVar("currentTab",section);
	
}





function dragDrop(type){
	if(type == "block"){
		// get the selected item order id 
		eval("selectedOrderID = "+currentActiveWindow+".document.all.Item_"+getDocumentVar("selectedID")+"_orderID.value;");
		// if we are moving down, increment the OrderID by one
		if (getDocumentVar("dragOverOrderID") > selectedOrderID){
			setDocumentVar("dragOverOrderID",getDocumentVar("dragOverOrderID")-1);
		}
		// don't do anything if the dropID is the same as the selected ID
		if (selectedOrderID == getDocumentVar("dragOverOrderID")){
			return;
		}

		// go to the move processing page
		startWaitBar();
		eval(currentActiveWindow+".location.href = '../block/move.asp?BlockID="+getDocumentVar("selectedID")+"&OrderID="+getDocumentVar("dragOverOrderID")+"';");	
	}


	if (type == "filecategory" && getDocumentVar("currentSection") == "file"){
		// go to the move processing page
		startWaitBar();
		eval(currentActiveWindow+".location.href = '../file/move.asp?FileID="+getDocumentVar("selectedID")+"&FileCategoryID="+getDocumentVar("dragOverID")+"';");	
	}


	if (type == "filecategory" && getDocumentVar("currentSection") == "filecategory"){
		if(confirm("Are you sure you want to move the file category \""+getDocumentVar("selectedName")+"\" to the new location?")){
			// go to the move processing page
			startWaitBar();
			eval("setMainPanel('../filecategory/move.asp?FileCategoryID="+getDocumentVar("selectedID")+"&NewFileCategoryID="+getDocumentVar("dragOverID")+"');");	
		}
	}


	if (type == "imagecategory" && getDocumentVar("currentSection") == "image"){
		// go to the move processing page
		startWaitBar();
		eval(currentActiveWindow+".location.href = '../image/move.asp?ImageID="+getDocumentVar("selectedID")+"&ImageCategoryID="+getDocumentVar("dragOverID")+"';");	
	}


	if (type == "imagecategory" && getDocumentVar("currentSection") == "imagecategory"){
		if(confirm("Are you sure you want to move the image category \""+getDocumentVar("selectedName")+"\" to the new location?")){
			// go to the move processing page
			startWaitBar();
			eval("setMainPanel('../imagecategory/move.asp?ImageCategoryID="+getDocumentVar("selectedID")+"&NewImageCategoryID="+getDocumentVar("dragOverID")+"');");	
		}
	}


	if (type == "ordercategory" && getDocumentVar("currentSection") == "order"){
		// go to the move processing page
		startWaitBar();
		eval(currentActiveWindow+".location.href = '../order/move.asp?OrderID="+getDocumentVar("selectedID")+"&OrderCategoryID="+getDocumentVar("dragOverID")+"';");	
	}


	if (type == "page" && getDocumentVar("currentSection") == "block"){
		doPopup('blockDropOnPage');
	}


	if (type == "page" && getDocumentVar("currentSection") == "page"){
		doPopup('pageDropOnPage');
		
		// fire the dragEnd action for pages
		dragEnd('page');
	}

	if(type == "role" && getDocumentVar("currentSection") == "user"){
		// check that the new role is not the current
		if(getDocumentVar("dragOverID") != getDocumentVar("currentRole")){
			if(confirm("Are you sure you want to move the user "+getDocumentVar("currentUserName")+" to the new role ("+getDocumentVar("dragOverID")+")?")){
				window.frames["mainPanel"].location.href = "../users/changeRole.asp?UserID="+getDocumentVar("currentUser")+"&RoleID="+getDocumentVar("dragOverID");
			}
		}
	}
}



function dragEnd(type){

	if (type == "block"){
		// make sure that the current page is highlighted (only if an appropriate explorer section)
/*		if(getDocumentVar("currentExplorerSection") == "page"){
			window.frames['explorerPanel'].frames['code'].searchHighlight(window.frames['explorerPanel'].frames['code'].menu, 'treeItem'+getDocumentVar("currentPage"),'startsWith,caseInsensitive', 'identifier');
		}
*/
	highlightTreeItem(getDocumentVar("currentPage"));
	}


	if (type == "page"){
		// make sure that the current page is highlighted
/*		if(getDocumentVar("currentExplorerSection") == "page"){
			window.frames['explorerPanel'].frames['code'].searchHighlight(window.frames['explorerPanel'].frames['code'].menu, 'treeItem'+getDocumentVar("currentPage"),'startsWith,caseInsensitive', 'identifier');
		}
*/
	highlightTreeItem(getDocumentVar("currentPage"));

	}
	
	
}


function dragLeave(type,dragOverID){

	if(type == "block"){
		eval(currentActiveWindow+".document.all.drag_divider_"+dragOverID+".style.backgroundColor = 'white';");
	}


	if(type == "page"){

	}
}



function dragOver(type,dragOverID){
	// save the drag over id
	setDocumentVar("dragOverID",dragOverID);
	
	
	if (type == "block" && getDocumentVar("currentSection") == "block"){
		// get and save the drag over order id
		eval("dragOverOrderID = "+currentActiveWindow+".document.all.Item_"+dragOverID+"_orderID.value;");
		setDocumentVar("dragOverOrderID",dragOverOrderID);
		
		// set the bg color of the over item
		eval(currentActiveWindow+".document.all.drag_divider_"+dragOverID+".style.backgroundColor = '#FF9A00';");
	}



	if (type == "page" && getDocumentVar("currentSection") == "block"){
		// highlight the tree item
/*		if(getDocumentVar("currentExplorerSection") == "page"){
			window.frames['explorerPanel'].frames['code'].searchHighlight(window.frames['explorerPanel'].frames['code'].menu, 'treeItem'+dragOverID,'startsWith,caseInsensitive', 'identifier');
		}
*/
		highlightTreeItem(dragOverID);
	}	



	if (type == "page" && getDocumentVar("currentSection") == "page"){
		// highlight the tree item
/*		if(getDocumentVar("currentExplorerSection") == "page"){
			window.frames['explorerPanel'].frames['code'].searchHighlight(window.frames['explorerPanel'].frames['code'].menu, 'treeItem'+dragOverID,'startsWith,caseInsensitive', 'identifier');
		}
*/
		highlightTreeItem(dragOverID);
	}	
		
}



function getCookie(Name) {
	var search = Name + "="
	if (document.cookie.length > 0) { // if there are any cookies
		offset = document.cookie.indexOf(search)
		if (offset != -1) { // if cookie exists
			offset += search.length
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset)
			// set index of end of cookie value
			if (end == -1)
				end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
		}
	}
}




function getCurrentLink(){

	// if we the current item is an image, 
	// get the link value from the link field associated with the image
	if (getDocumentVar("currentSubSection") == "field_image"){
		eval("linkVal = window.frames['mainPanel'].frames['page_tabs'].document.all.composeForm."+getDocumentVar("popupField")+".value;");
		return linkVal;
	}


} // end getCurrentLink


function gotoEmailTab(section,emailID){

	// first check for unsaved changes
	if (abortAction()){
		return false;
	}

	startWaitBar();
	
	window.top.frames["mainPanel"].location.href = "../email/email.aspx?section="+section+"&EmailID="+emailID;
}



function gotoEmailDeliveryTab(section,emailDeliveryID){

	// first check for unsaved changes
	if (abortAction()){
		return false;
	}

	startWaitBar();
	
	window.top.frames["mainPanel"].location.href = "../email/emaildelivery.aspx?section="+section+"&EmailID="+emailDeliveryID;
}




function gotoPageTab(section,pageID,blockID){
	window.top.frames["mainPanel"].location.href = "../page_tabs/tabs.asp?section="+section+"&PageID="+pageID+"&BlockID="+blockID;
}



function gotoSiteTab(section,siteID){
	startWaitBar();

	window.top.frames["mainPanel"].location.href = "../site/tabs.aspx?section="+section+"&SiteID="+siteID;
}


function gotoSEOTab(seoType,section){
	startWaitBar();

	window.loadTab(section);
}


function gotoStatsTab(statsType,section){
	startWaitBar();

	window.top.frames["mainPanel"].location.href = "../stats/"+statsType+".aspx?section="+section;
}


function highlightElement(section,id){

	//'' if there is no selected block, return
	if(!getDocumentVar("currentBlock")){
		return;
	}
	
	// first unhighlight the previous item (which should be in the selecgted vars still)
	// but only if there is a selectedSub item
	if (getDocumentVar("highlightedElementStr") > ""){
		eval("var obj1 = "+getDocumentVar('highlightedElementStr')+";");

		// set it back to what it was
		if(obj1 && obj1.style){
			obj1.style.border = getDocumentVar('highlightedElementBorder');
		}

		// if a field_text was hihghlighted, we need to put the cover back on
		if (getDocumentVar("selectedSubSection") == "field_text"){
//''			eval("window.frames['mainPanel'].frames['page_tabs'].document.all.field_"+getDocumentVar("selectedSubID")+"_cover.style.display='block';");
			eval("obj1 = window.frames['mainPanel'].frames['page_tabs'].document.all.field_"+getDocumentVar("selectedSubID")+"_cover;");
			if(obj1){
				obj1.style.display='block';
			}
		}
	}


	if (section == "field_image"){
		// save the object string of the highlighted item
		setDocumentVar("highlightedElementStr","window.frames['mainPanel'].frames['page_tabs'].document.all.field_"+id+"_preview")

		// save the current border style of the element
		eval("setDocumentVar('highlightedElementBorder',"+getDocumentVar('highlightedElementStr')+".style.border);");
		// now highlight the new element
		eval("var obj1 = "+getDocumentVar('highlightedElementStr')+";");
		obj1.style.border = "dashed red 1px";
	}		


	if (section == "field_input"){
		// save the object string of the highlighted item
		setDocumentVar("highlightedElementStr","window.frames['mainPanel'].frames['page_tabs'].document.all.field_"+id)
				
		// save the current border style of the element
		eval("setDocumentVar('highlightedElementBorder',"+getDocumentVar('highlightedElementStr')+".style.border);");		
		
		// now highlight the new element
		var obj1;
		eval("obj1 = "+getDocumentVar('highlightedElementStr')+";");
		if(obj1){
			obj1.style.border = "dashed red 1px";
		}
	}		



	if (section == "field_text"){

		// save the object string of the highlighted item
		setDocumentVar("highlightedElementStr","window.frames['mainPanel'].frames['page_tabs'].document.all.field_"+id+"_preview")

		// remove the cover
		eval("window.frames['mainPanel'].frames['page_tabs'].document.all.field_"+id+"_cover.style.display='none';");

		// save the current border style of the element
		eval("setDocumentVar('highlightedElementBorder',"+getDocumentVar('highlightedElementStr')+".style.border);");		
		
		// now highlight the new element
		eval("var obj1 = "+getDocumentVar('highlightedElementStr')+";");
		obj1.style.border = "dashed red 1px";


	}


	if (section == "field_plaintext"){

		// save the object string of the highlighted item
		setDocumentVar("highlightedElementStr","window.frames['mainPanel'].frames['page_tabs'].document.all.field_"+id)

		// save the current border style of the element
		eval("setDocumentVar('highlightedElementBorder',"+getDocumentVar('highlightedElementStr')+".style.border);");		
		
		// now highlight the new element
		eval("var obj1 = "+getDocumentVar('highlightedElementStr')+";");
		obj1.style.border = "dashed red 1px";


	}
	
			
}

function highlightTreeItem(id, jump){
	if(getDocumentVar("currentExplorerSection") == "page" || getDocumentVar("currentExplorerSection") == "imagecategory" || getDocumentVar("currentExplorerSection") == "filecategory" || getDocumentVar("currentExplorerSection") == "blocktemplatecategory" || getDocumentVar("currentExplorerSection") == "role"){


		// if there is an object for the currentID, clear the class
		if(getDocumentVar("currentTreeID")){
			eval("var nameObj = window.frames[\"explorerPanel\"].frames[\"menu\"].document.all.name_"+window.top.getDocumentVar("currentTreeID"));
			if(nameObj){
				nameObj.className = "";
			}
		}
			
		// set the class of this node name
		setDocumentVar("currentTreeID",id)
		eval("var nameObj = window.frames[\"explorerPanel\"].frames[\"menu\"].document.all.name_"+id);
		if(nameObj)
			nameObj.className = "current";
		
		if(jump){
			// jump to the bookmark in the tree
			var loc = String(window.frames["explorerPanel"].frames["menu"].location.href);
			loc = loc.replace(/\#.*/,"");
			window.frames["explorerPanel"].frames["menu"].location.href = loc+"#name_"+id;
		}		
	}

}


function markUnsaved(){
	setDocumentVar("unsavedChanges",1);
	if(document.all.image_saved){
		var img1 = document.all.image_saved;
		img1.src = "../menu-images/unsaved.gif";
		img1.alt = "Unsaved changes exist";
	}
}

function markSaved(){
	setDocumentVar("unsavedChanges",0);
	if(document.all.image_saved){
		var img1 = document.all.image_saved;
		img1.src = "../menu-images/saved.gif";
		img1.alt = "No unsaved changes";
	}
}



function newWin(url, name, w, h, other, xoff, yoff, notModal) {

	if (!w || w==""){w = 683;}
	if (!h || h==""){h = 650;}
	if (isNaN(xoff)){xoff = 0;}
	if (isNaN(yoff)){yoff = 0;}

	l = ((screen.availWidth-10 - w) / 2) + xoff;
	t = ((screen.availHeight-20 - h) / 2) + yoff;

	features = "width="+w+",height="+h+",left="+l+",top="+t;
	features += ",screenX="+l+",screenY="+t;
	features += ",scrollbars=0,location=0";
	features += ((notModal)?",resizable=1":",resizable=0");
	features += ",menubar=0,toolbar=0,status=0";
	features += ","+other;

	//'' add the property frame width and height to the URL
	var url = String(url);
	if(url.match(/\?/)){
		url += "&";
	} else {
		url += "?";
	}
	url += "propertyFrameWidth="+w+"&propertyFrameHeight="+h;
	

	if (!window.showModalDialog || notModal) {
		// if the window does not support modals, open a standard popup
		var w = window.open(url, name, features);
		window.document.popupWin = window.open(url, name, features);
//		window.focus();
		window.document.popupWin.focus();
	} else {
		// if the browser supports modal dialogs, open the popup in a modal window
		features = "dialogWidth:"+w+"px;dialogHeight:"+h+"px;dialogLeft:"+l+";dialogTop:"+t;
//		features += ";screenX:"+l+";screenY:"+t;
		features += ";scroll:0;resizable:0;center:0";
		features += ";menubar:0;toolbar:0;status:0";
		
		rVal = window.showModalDialog(url, name, features);
		return rVal;
	}
}



function previewImage(assetID){
	newWin("../../images/view.asp?AssetID="+assetID,'imagePreview',600,400,'scrollbars=no,status=no');
}



function resetCurrent(){

	resetSelected();
	
	currentSection = "";
	currentItem = "";
	currentBlock = "";
	currentPage = "";
	
	if (document.all.currentSectionField){
		document.all.currentSectionField.value = "";
		document.all.currentItemField.value = "";
		
		document.all.currentSubSectionField.value = "";
		document.all.currentSubItemField.value = "";
	}
	
	currentSubSection = "";
	currentSubItem = "";
	
}



function resetHighlighted(){
	highlightedID = ""; 
	highlightedElementStr = "";
	highlightedElementBorder = "";
	setDocumentVar("highlightedID","");
}


function resetPopup(){
	popupType = "";
	popupID = "";
	popupField = "";
}


function resetSelected(){
	// reset the highlighted Item
	resetHighlighted();
	
	selectedSection = "";
	selectedID = 0;
	selectedName = "";

	selectedSubSection = "";
	selectedSubID = 0;
	selectedSubName = "";
}


function revertItem(section,id,itemName){

	if(section == "block"){

		// fail if no block version is selected
		if(!getDocumentVar("currentBlockVersion")){
			return false;
		}

		// cannot revert to the current version
		if(getDocumentVar("currentBlock") == id){
			alert("You cannot revert to the current version.");
			return false;
		} 
		

		if(confirm("Are you sure you want to revert the current block to this version:\n\n\""+itemName+"\" ?")){
			window.location = "../block/revert.asp?BlockID="+getDocumentVar("currentBlock")+"&revertID="+id;
		}
	}
}



function sendClientMessages(){
	// if not editing a block, unlock all blocks
	// try and read the src, if it does not contain the string, or throws another error, then the main panel is not the editor, so unlock blocks
	try { 
		strMain = String(window.frames["mainPanel"].location.href);
		if(!strMain.match(/page_tabs\/tabs.aspx\?section=editor/)){
			throw "no match";
		}
	} 
	catch(er) {
		setDocumentVar("clientMessages",getDocumentVar("clientMessages")+"<cmd>environ.unlock('block','',"+getDocumentVar("UserID")+")</cmd>");
	} 

	window.frames['clientmessages'].location.href = "../utils/sendClientMessages.asp?msg="+getDocumentVar("clientMessages");
	
	// clear the client messages, and schedule next send
	setDocumentVar("clientMessages","");
	setTimeout("sendClientMessages()",getDocumentVar("CLIENTMESSAGES_REFRESH")*1000);

}


function setCookie(name, value, daysExpire) {
	if(daysExpire) {
		var expires = new Date();
		expires.setTime(expires.getTime() + 1000*60*60*24*daysExpire);
	}
	document.cookie = name + "=" + escape(value) + (daysExpire == null ? "" : (";expires=" + expires.toGMTString())) + ";path=/";
}



function setCurrentSubVars(section,id,itemName){
	// set the current variables
	currentSubSection = section;
	currentSubItem = itemName;
	if(document.all.currentSubSectionField){
		document.all.currentSubSectionField.value = section;
		document.all.currentSubItemField.value = itemName;
	}

	// set the selected variables
	selectedSubSection = section;
	selectedSubID = id;
	selectedSubName = itemName;
	
}


function setCurrentVars(section,id,itemName){
	// set the current variables
	currentSection = section;
	currentID = id;
	currentItem = itemName;

	if (document.all.currentSectionField){
		document.all.currentSectionField.value = section;
		document.all.currentItemField.value = itemName;
	}
	
	// set the selected variables
	selectedSection = section;
	selectedID = id;
	selectedName = itemName;


}




function setDocumentVar(varName,val){
	eval(varName+" = \""+val+"\"");
}

function getDocumentVar(varName){
	eval("var retVal = "+varName);
	return retVal;
}


function setJunkFrame(dest){
	window.frames["junk"].location.href = dest;
	window.frames["mainPanel"].location.href = dest;
}


function setExplorerPanel(dest){

	startWaitBar();
	window.frames["explorerPanel"].location.href = dest;
}



function setMainPanel(dest){

	startWaitBar();
	window.frames["mainPanel"].location.href = dest;
}


function setPopupField(fieldValue){

	if (getDocumentVar("popupType") == "blockTemplate"){
		// set the value of the required form field
		eval("window.frames['tabs'].document.all.composeForm."+getDocumentVar("popupField")+".value = fieldValue;");
		
	}


	if (getDocumentVar("popupType") == "file"){
		// set the value of the required form field
		eval("window.frames['mainPanel'].frames['page_tabs'].document.all.composeForm."+getDocumentVar("popupField")+".value = fieldValue;");
		
	}


	if (getDocumentVar("popupType") == "image"){
		// set the value of the required form field
		eval("window.frames['mainPanel'].frames['page_tabs'].document.all.composeForm."+getDocumentVar("popupField")+".value = fieldValue;");
		
		// set the preview image src
		var img1 = new Image();
		img1.src = "../../images/view.asp?ImageID="+fieldValue
		eval("window.frames['mainPanel'].frames['page_tabs'].document.all.field_"+getDocumentVar("popupID")+"_preview.src = img1.src;");
	}


	if (getDocumentVar("popupType") == "link"){
	
		// if the currentSubSection is an image field
		if (getDocumentVar("currentSubSection") == "field_image"){

			// set the value of the required form field
			// because we passed the field name in the popupName field, use this, not the popupID
			eval("window.frames['mainPanel'].frames['page_tabs'].document.all.composeForm."+getDocumentVar("popupField")+".value = fieldValue;");
		}


		// if the currentSubSection is an image field
		if (getDocumentVar("currentSubSection") == "field_hidden"){

			// set the value of the required form field
			// because we passed the field name in the popupName field, use this, not the popupID
			eval("window.frames['mainPanel'].document.all.composeForm."+getDocumentVar("popupField")+".value = fieldValue;");
		}


		// if the currentSubSection is an image field
		if (getDocumentVar("currentSubSection") == "field_input"){

			// set the value of the required form field
			// because we passed the field name in the popupName field, use this, not the popupID
			eval(getDocumentVar("currentActiveWindow")+".document.all.composeForm."+getDocumentVar("popupField")+".value = fieldValue;");
		}

	}


}

function setRefreshTree(treeState){

	setDocumentVar("refreshTree",treeState);
	var img1 = document.all.image_refreshTree;
	
	if (treeState == 1){
		img1.src = "../menu-images/refresh.gif";
		img1.alt = "Refresh tree required.";
		
		// if the user has auto-refresh set, then refresh the tree
		if (getDocumentVar("autoRefresh") == "1"){
			// first replace the tree with a message so they know something is happening
			explorerLoc = window.frames["explorerPanel"].location.href;
			window.frames["explorerPanel"].location.href = "../menu/menu_empty.html";
			window.frames["explorerPanel"].location.href = explorerLoc;
			setRefreshTree(0);
		}
	} else {
		img1.src = "../menu-images/refresh_off.gif";
		img1.alt = "";
	}
	
}



function setStatusMessage(msgType,msg){

	if(msgType == "address" && document.all.AddressStatus){
		if(msg=="default"){
			msg = "Address:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
		}
		document.all.AddressStatus.innerHTML = msg;
	}


	if(msgType == "deployment" && document.all.DeploymentStatus){
		var dImg = new Image();
		if(msg == "default"){
			msg = "Standby";
			dImg.src = "../menu-images/deployment_grey.gif";
		} else {
			dImg.src = "../menu-images/deployment_running.gif";
		}
		document.all.deployment_image.src = dImg.src;
		document.all.DeploymentStatus.innerHTML = msg;
	}

	if(msgType == "mail"){
		if(msg == "default"){
			document.all.image_mail.style.visibility = "hidden"
			var img1 = document.all.image_mail;
			img1.alt = "";
		} else {
			document.all.image_mail.style.visibility = "visible"
			var img1 = document.all.image_mail;
			img1.alt = msg;
		}
	}

}



function setView(view){
	document.all.ViewDropDown.style.visibility = 'hidden';
	if(window.frames["mainPanel"].document.listObj){
		window.frames["mainPanel"].document.listObj.layout=view;
		window.frames["mainPanel"].document.listObj.populate();
	}
}



function showToolbar(tbName){

	// if standard, show the standard ones and hide the others
	if (tbName == "default"){
		document.all.menuToolbar.style.display = "block";
		document.all.statusToolbar.style.display = "block";
		document.all.standardToolbar.style.display = "block";
		document.all.addressToolbar.style.display = "block";

		document.all.formatToolbar.style.display = "none";
	}
	
} // end showToolbar



function startWaitBar(){
	if(document.all.waitBar){
		document.all.waitBar.style.visibility = "visible";
	}
}

function stopWaitBar(){
	// first check that the stop bar exists
	try { 
		document.all.waitBar.style.visibility = "hidden";
	} 
	catch(er) {	}	
}



