		//currentobj stores the variable field that is currently being edited
		var currentobj
		//If the URL is changed, and pages require saving, inform the user
	    window.onbeforeunload = confirmExit;

		
		function confirmExit()
		{
		//If there are unsaved pages, ask the user if they want to leave
		var fra=window.frame_contents;
		if (fra!=null)
			{
			var savebutton=fra.document.getElementById('imgsave');
			//if the savebutton is null, it means we're in live mode
			if (savebutton!=null)
				{
				var sbuttonsrc = savebutton.src
				if (sbuttonsrc.indexOf("save_red.gif") != -1)
					{
					return "There are unsaved pages.";
					}
				}
			}
		}

		
		function changemode_checkbox(obj)
			{
			//Cancel this action if the activation key page is displayed
			//if (parent.document.getElementById("frame_work").src == "activationkey.aspx"){return}
			if (document.getElementById("frame_work").src == "activationkey.aspx"){return}
			
			//Determine if we will set the mode to EDIT or LIVE depending on the checkbox
			if (obj.checked == true)
				{
				//-- set mode to EDIT
				//alert("showing edit mode")
				ShowEditMode();
				}
			else
				{
				//-- set mode to LIVE
				//alert("showing live mode")
				ShowLiveMode();
				}
			}

		function ShowEditMode()
			{
			var sfilename = window.frame_contents.document.Form1.txtcurrentpage.value;
			var sprojectname = window.frame_contents.document.Form1.txtProjectName.value;
			//Switch to "EDIT MODE"

				//the username is already set, reload the main frame and contents frame
				//hide frame_contents so that the user cannot click a link while loading.
				//the frame will be shown when the main frame has finished loading
				//Reload the main frame
				window.frame_contents.document.Form1.txtmode.value='edit';
				
				//If this is an external page then display the work frame and load it.
				if (sfilename.toLowerCase().substr(0,4)=="www." || sfilename.toLowerCase().substr(0,7)=="http://")
					{
					//window.frame_work.style.display = "none";
					//window.frame_work.src = "blank.htm";
					//window.frame_main.style.display = "";
					//window.frame_main.src="projects/" + sprojectname + "/_editor.aspx?filename=-external-&projectname="+sprojectname;
					document.getElementById("frame_window").style.display = "";
					document.getElementById("frame_window").src = sfilename;
					document.getElementById("frame_main").style.display = "none";
					document.getElementById("frame_main").src="_editor.aspx?filename=-external-&projectname="+sprojectname;
					}
				else
					{
					//document.getElementById("frame_work").style.visibility="hidden";
					document.getElementById("frame_work").style.display="none";
					window.frame_main.location.href="_editor.aspx?filename="+sfilename+"&projectname="+sprojectname;
					}
				//Determine if the contents should be hidden
				var cont=document.getElementById("td_contents_hidden")
				if (cont != null)
					{
					//show the contents frame
					//document.getElementById("td_contents_hidden").width="25%";
					//document.getElementById("td_main_visible").width="75%";
					document.getElementById("td_contents_hidden").style.display="";
					document.getElementById("td_main_visible").style.display="";
					//PositionFrames();
					}
				//Reload the contents frame
				window.frame_contents.document.Form1.submit();
				
			}

		
//		function ShowEditMode()
//			{
//			var sfilename = window.frame_contents.document.Form1.txtcurrentpage.value;
//			var sprojectname = window.frame_contents.document.Form1.txtProjectName.value;
//			//Switch to "EDIT MODE"
//			var sUserName = Get_*ookie("username");
//			if (sUserName == "" || sUserName == null)
//				{
//				//If the user is not logged into the project, then display the login form
//				//parent.frame_work.location.href="../_engine/projectlogin.aspx"
//				frame_work.location.href="../_engine/projectlogin.aspx"
//				//parent.frame_work.location.href="../_engine/login.aspx"
//				//Show the work frame 
//				document.getElementById("frame_work").style.top=document.body.clientHeight/2-202;
//  			document.getElementById("frame_work").style.left=document.body.clientWidth/2-152;
//  			document.getElementById("frame_work").style.width=404;
//	  			document.getElementById("frame_work").style.height=304;
//  				document.getElementById("frame_work").style.position="absolute";
//				//document.getElementById("frame_work").style.visibility="visible";
//				document.getElementById("frame_work").style.display="";
//				}
//			else
//				{
//				//the username is already set, reload the main frame and contents frame
//				//hide frame_contents so that the user cannot click a link while loading.
//				//the frame will be shown when the main frame has finished loading
//				//Reload the main frame
//				window.frame_contents.document.Form1.txtmode.value='edit';
//				
//				//If this is an external page then display the work frame and load it.
//				if (sfilename.toLowerCase().substr(0,4)=="www." || sfilename.toLowerCase().substr(0,7)=="http://")
//					{
//					//window.frame_work.style.display = "none";
//					//window.frame_work.src = "blank.htm";
//					//window.frame_main.style.display = "";
//					//window.frame_main.src="projects/" + sprojectname + "/_editor.aspx?filename=-external-&projectname="+sprojectname;
//					document.getElementById("frame_window").style.display = "";
//					document.getElementById("frame_window").src = sfilename;
//					document.getElementById("frame_main").style.display = "none";
//					document.getElementById("frame_main").src="_editor.aspx?filename=-external-&projectname="+sprojectname;
//					}
//				else
//					{
//					//document.getElementById("frame_work").style.visibility="hidden";
//					document.getElementById("frame_work").style.display="none";
//					window.frame_main.location.href="_editor.aspx?filename="+sfilename+"&projectname="+sprojectname;
//					}
//				//Determine if the contents should be hidden
//				var cont=document.getElementById("td_contents_hidden")
//				if (cont != null)
//					{
//					//show the contents frame
//					//document.getElementById("td_contents_hidden").width="25%";
//					//document.getElementById("td_main_visible").width="75%";
//					document.getElementById("td_contents_hidden").style.display="";
//					document.getElementById("td_main_visible").style.display="";
//					//PositionFrames();
//					}
//				//Reload the contents frame
//				window.frame_contents.document.Form1.submit();
//				}
//			}
		
		
		
		
		function ShowLiveMode()
			{
			var sfilename = window.frame_contents.document.Form1.txtcurrentpage.value;
			var sprojectname = window.frame_contents.document.Form1.txtProjectName.value;
			var mode=window.frame_contents.document.Form1.txtmode.value;

			//alert("framework left = "+document.getElementById("frame_work").style.top);

			//Switch to "LIVE MODE"
			//Ensure that the project has been created
			//if (mode.toLowerCase() == "edit_new")
			//	{
			//	alert("Live mode cannot be displayed until the project is saved.");
			//	return;
			//	}
			//Display a warning if the project needs to be saved
			if (window.frame_contents.document.getElementById('imgsave').src.indexOf("images/save_red.gif")!=-1)
				{
				var response=confirm("This project has not been saved. Do you wish to continue anyway?")
				if (response!=true)
					{
					alert("responded false");
					return;
					}
				}
			window.frame_contents.document.Form1.txtmode.value='live';
			//if the main frame is hidden, show it now.
			//if (parent.document.getElementById("frame_main").style.visibility == "hidden")
			//if (parent.document.getElementById("frame_main").style.display == "none")
			//if (window.frame_main.style.display == "none")
			if (document.getElementById("frame_main").style.display == "none")
				{
				//window.frame_work.style.display = "none";
				//window.frame_work.src="blank.htm";
				//window.frame_main.style.display = "none";
				document.getElementById("frame_work").style.display = "none";
				document.getElementById("frame_work").src="blank.htm";
				document.getElementById("frame_main").style.display = "none";
				}
			//Reload the file (if sfilename starts with "http://" then assume external)
			if (sfilename.toLowerCase().substr(0,4)=="www." || sfilename.toLowerCase().substr(0,7)=="http://")
				{
				var sfullpath = sfilename
				}
			else
				{
				//include a dummy parameter so that the page is not cached
				var d = new Date()
				var sdummy = "?dummy="+d.getHours()+d.getMinutes()+d.getSeconds()
				//var sfullpath = "projects/" + sprojectname + "/" + sfilename + sdummy
				var sfullpath = sfilename + sdummy
				}
			//parent.frame_main.location.href=sfullpath
			window.frame_main.location.href=sfullpath
			//Determine if the contents should be hidden
			var cont=document.getElementById("td_contents_hidden")
			if (cont != null)
				{
				//hide the contents frame
				//document.getElementById("td_contents_hidden").width="1";
				//document.getElementById("td_main_visible").width="100%";
				document.getElementById("td_contents_hidden").style.display="none";
				document.getElementById("td_main_visible").style.display="";
				//PositionFrames();
				}
			window.frame_contents.document.Form1.submit();
			}
		
		


		function ToggleEditIcon(sfrom, sto)
			{
				var sSrc = document.getElementById("imgedit").src
				//alert("src = " + sSrc);
				//var smouseover = sSrc.replace("toolbar_"+sfrommode+"_mouseover.gif", "toolbar_"+stomode+"_mouseover.gif")
				//var smouseout = sSrc.replace("toolbar_"+sfrommode+"_mouseover.gif", "toolbar_"+stomode+".gif")
				//alert("smouseover = "+smouseover);
				//alert("smouseout = "+smouseout);
				//document.getElementById("imgedit").src = smouseout
				//document.getElementById("imgedit").attachEvent("onmouseover", document.images.imgedit.src=smouseover)
				//document.getElementById("imgedit").setAttribute("onmouseover", "document.images.imgedit.src='"+smouseover+"'",0)
				//document.getElementById("imgedit").setAttribute("onmouseout", "document.images.imgedit.src='"+smouseout+"'",0)

			
//				var smouseover = ""
//				//alert("imgedit outerhtml = "+document.getElementById("imgedit").outerHTML);
//				//alert("imgedit src = "+document.getElementById("imgedit").src);
//				//alert("imgedit onmouseover = "+document.getElementById("imgedit").getAttribute("onmouseover"));
//				alert("step1");
//				smouseover = String(document.getElementById("imgedit").getAttribute("onmouseover"));
//				//sfrom = "toolbar_"+sfrommode+"_mouseover.gif"
//				//sto = "toolbar_"+stomode+"_mouseover.gif"
//				//alert("sfrom = " + sfrom);
//				//alert("sto = " + sto);
//				//alert("j = " + smouseover.replace("gif", "tif"));
//				smouseover = smouseover.replace("toolbar_"+sfrommode+"_mouseover.gif", "toolbar_"+stomode+"_mouseover.gif")
//				alert("step3");
//				var smouseout = String(document.getElementById("imgedit").getAttribute("onmouseout"));
//				alert("step4");
//				smouseout = smouseout.replace("toolbar_"+sfrom+".gif", "toolbar_"+sto+".gif")
//				alert("step5");
//				var sSrc = String(document.getElementById("imgedit").src);
//				alert("step6");
				sSrc = sSrc.replace("toolbar_"+sfrom+"_mouseover.gif", "toolbar_"+sto+".gif")
//				alert("step7");
//				//change the src, mouseover and mouseout to the 'edit page' icon
				document.getElementById("imgedit").src = sSrc
//				document.getElementById("imgedit").setAttribute("onmouseover", smouseover,0)
//				document.getElementById("imgedit").setAttribute("onmouseout", smouseout,0)

			}			
			
		function _delete_edit_mouseover(obj)
			{
			//alert("obj.src = "+obj.src);
			var sSrc = obj.src;
			if (sSrc.indexOf("toolbar_edit.gif") == -1)
				{
				obj.src = sSrc.replace("toolbar_live.gif", "toolbar_live_mouseover.gif")
				}
			else
				{
				obj.src = sSrc.replace("toolbar_edit.gif", "toolbar_edit_mouseover.gif")
				}
			}
			
		function _delete_edit_mouseout(obj)
			{
			//alert("obj.src = "+obj.src);
			var sSrc = obj.src;
			if (sSrc.indexOf("toolbar_edit_mouseover.gif") == -1)
				{
				obj.src = sSrc.replace("toolbar_live_mouseover.gif", "toolbar_live.gif")
				}
			else
				{
				obj.src = sSrc.replace("toolbar_edit_mouseover.gif", "toolbar_edit.gif")
				}
			}
			
		function SearchKeyPress(searchtext,e)
			{
		
		    var key;
			if(window.event)
				{
				key = window.event.keyCode;     //IE
				}
			else
				{
				key = e.which;     //firefox
				}

    		if(key == 13)
    			{
				search(searchtext);
				return false;
				}
			else
				{
				return true;
				}
			}

			
		function search(stext, sPageName)
			{
			//write the search text to the contents frame
			window.frame_contents.document.Form1.txtsearch.value = stext;
			if (sPageName == "" || sPageName == null)
				{
				//alert("search");
				window.frame_contents.document.Form1.txtaction.value = "search";
				}
			else
				{
				//alert("search children");
				window.frame_contents.document.Form1.txtaction.value = "search"+sPageName;
				}
			//if the contents frame is hidden then show it now
			if (document.getElementById("td_contents_hidden") != null && window.frame_contents.document.Form1.txtmode.value.toLowerCase() != "edit")
				{
				document.getElementById("td_contents_hidden").style.display="";
				document.getElementById("td_main_visible").style.display="none";
				//alert("td_contents_hidden found");
				}
			
			//Copy lstpages to the contents page
			window.frame_contents.SubmitLstPages(false);
			
			//Reload the contents to activate the search
			window.frame_contents.document.Form1.submit();
			}


		
		function addtofav()
			{
			if (document.all)
				{
				//Get the skin, project and page
				var mode=window.frame_contents.document.Form1.txtmode.value;
				var sProjectParm="?projectname="+window.frame_contents.document.Form1.txtProjectName.value 
				var sSkinParm="&skin="+window.frame_contents.document.Form1.txtcurrentskin.value;
				var sPageParm="&page="+window.frame_contents.document.Form1.txtcurrentpage.value;
				var sModeParm="&mode="+window.frame_contents.document.Form1.txtmode.value;
				var sProjectName=window.frame_contents.document.Form1.txtProjectName.value;
				var sPageURL="http://" + location.hostname + location.pathname;
				var sURL=sPageURL+sProjectParm+sSkinParm+sPageParm+sModeParm;
				//alert("URL = "+sURL);
				var sTitle=sProjectName + " - " + window.frame_contents.document.Form1.txtcurrentpage.value;
				//if we are in edit mode then add (edit) to the end of the title
				//if (mode == "edit" || mode == "edit_new")
				if (mode == "edit")
					{
					sTitle = sTitle + " (edit)";
					}
				window.external.AddFavorite(sURL,sTitle);
				}
			}
		
		//this function not currently used
		function goback()
			{
			window.frame_main.history.back();
			}

		//this function not currently used
		function goforward()
			{
			window.frame_main.history.forward();
			}

		function showoptions()
			{
			//if the options form is already displayed then hide it
			if (document.getElementById("tbloptions").style.display=="")
				{
				document.getElementById("tbloptions").style.display="none";
				}
			else
				{
				document.getElementById("tbloptions").style.display="";
				document.getElementById("tbloptions").focus();
				//position the options list below the options button
				document.getElementById("tbloptions").style.top=document.getElementById("imgoptions").offsetTop+document.getElementById("imgoptions").offsetHeight;
				document.getElementById("tbloptions").style.left=document.getElementById("imgoptions").offsetLeft+document.getElementById("imgoptions").offsetWidth-198;
				}
			}
		
		function printpage()
			{
			var mode=window.frame_contents.document.Form1.txtmode.value;
			//if (mode == "edit" || mode == "edit_new")
			if (mode == "edit")
				{
				//if we are in edit mode, print the contents of the editor
				print_edit();
				}
			else
				{
				//if we are in live mode, print the main_frame iframe
				window.frames['frame_main'].focus(); 
				window.frames['frame_main'].print();
				}
			}

		function previouspage()
			{
			if (window.frame_contents.document.Form1.txtmode.value.toLowerCase() == "edit")
				{
				alert("This function is not available in edit mode")
				}
			else
				{
				onclick = history.back()
				}
			}
			
		function nextpage()
			{
			if (window.frame_contents.document.Form1.txtmode.value.toLowerCase() == "edit")
				{
				alert("This function is not available in edit mode")
				}
			else
				{
				onclick = history.forward()
				}
			}

		function showaskpage()
			{
			if (window.frame_contents.document.Form1.txtmode.value.toLowerCase() == "edit")
				{
				alert("This function is not available in edit mode")
				}
			else
				{
				window.open("ask.aspx", "frame_main")
	
				//if this is a flat type skin then display the page window now
				if (document.getElementById("td_contents_hidden") != null)
					{
					document.getElementById("td_contents_hidden").style.display="none";
					document.getElementById("td_main_visible").style.display="";
					}

				}
			}

		function showhomepage(homepage)
			{
			if (window.frame_contents.document.Form1.txtmode.value.toLowerCase() == "edit")
				{
				alert("This function is not available in edit mode")
				}
			else
				{
				//ensure that the work frame is hidden
				document.getElementById("frame_window").style.display="none";
				document.getElementById("frame_main").style.display="";
				
				window.open(homepage, "frame_main")
				//if this is a flat type skin then display the page window now
				if (document.getElementById("td_contents_hidden") != null)
					{
					document.getElementById("td_contents_hidden").style.display="none";
					document.getElementById("td_main_visible").style.display="";
					}
				}
			}

		function browse()
			{
			if (window.frame_contents.document.Form1.txtmode.value.toLowerCase() == "edit")
				{
				alert("This function is not available in edit mode")
				}
			else
				{
				document.getElementById("td_contents_hidden").style.display="";
				document.getElementById("td_main_visible").style.display="none";
				}
			}

		function print_edit()
			{
			var printIframe = document.createElement("IFRAME");
			document.body.appendChild(printIframe);
			var printDocument = printIframe.contentWindow.document;
			printDocument.designMode = "on";
			printDocument.open();
			var currentLocation = document.location.href;
			currentLocation = currentLocation.substring(0, currentLocation.lastIndexOf("/") + 1);
			var editor = window.frame_main.GetRadEditor("editor1");
			

			// --------- NORMAL VIEW --------------
			var sPrintHTML = "<html><head></head><body>" + editor.GetHtml() + "</body></html>";

			//printDocument.write("<html><head></head><body>" + editor.GetHtml() + "</body></html>");
			printDocument.write(sPrintHTML);
			printDocument.close();

			try
				{
				if (document.all)
					{
					var oLink = printDocument.createElement("link");
					oLink.setAttribute("href", currentLocation + "pagestyles.css", 0);
					oLink.setAttribute("type", "text/css");
					oLink.setAttribute("rel", "stylesheet", 0);
					printDocument.getElementsByTagName("head")[0].appendChild(oLink);
					printDocument.execCommand("Print");
					}
				else
					{
					printDocument.body.innerHTML = "<link rel='stylesheet' type='text/css' href='" + currentLocation + "pagestyles.css'></link>" + printDocument.body.innerHTML;
					printIframe.contentWindow.print();
					}
				}
			catch(ex)
				{
				}
			document.body.removeChild(printIframe);
			}
		
		function DisplayIndex()
			{
			//window.frame_contents.document.Form1.txtaction.value = "index";
			//window.frame_contents.document.Form1.submit();
			window.frame_contents.ShowIndex();
			
			//if this is a flat style skin then show the contents window and hide the page window
			if (document.getElementById("td_contents_hidden") != null && window.frame_contents.document.Form1.txtmode.value.toLowerCase() != "edit")
				{
				document.getElementById("td_contents_hidden").style.display="";
				document.getElementById("td_main_visible").style.display="none";
				}

			}

			

		function PositionUploadBox()
			{
			var divPlaceHolder = document.getElementById('divUploadPlaceholder')
			//alert("divPlaceHolder = "+divPlaceHolder);
			if (divPlaceHolder != null)
				{
				document.getElementById('divupload').style.top=divPlaceHolder.offsetTop;
				document.getElementById('divupload').style.left=divPlaceHolder.offsetLeft;
				//document.getElementById('divupload').style.visibility="visible";
				document.getElementById('divupload').style.display="";
				divPlaceHolder.style.visibility="hidden";
				}
			}


		function showicons(idx)
			{
			document.getElementById('tr'+idx).style.backgroundColor="yellow";
			document.getElementById('datefont'+idx).color="blue";
			document.getElementById('imgdelete'+idx).style.visibility="visible";
			document.getElementById('imgproperties'+idx).style.visibility="visible";
			document.getElementById('imgcopy'+idx).style.visibility="visible";
			}
			
		function hideicons(idx)
			{
			document.getElementById('tr'+idx).style.backgroundColor="";
			//document.getElementById('datefont'+idx).color="#E2E2E2";
			document.getElementById('datefont'+idx).color="#FFFFFF";
			document.getElementById('imgdelete'+idx).style.visibility="hidden";
			document.getElementById('imgproperties'+idx).style.visibility="hidden";
			document.getElementById('imgcopy'+idx).style.visibility="hidden";
			}
			
		function deleteproject(sProjectName)
			{
			//ask the user if they're sure
			if(confirm("The project '"+sProjectName+"' will be permanently deleted.") == true)
				{
				//change the cursor to an hourglass
				document.body.style.cursor="wait";
				//Set the action to delete and submit the form
				document.getElementById('txtaction').value="deleteproject:"+sProjectName;
				document.Form1.submit();
				}
			}

		function copyproject(sProjectName)
			{
			//prompt for the new project name
			var sNewName = prompt('Please enter a name for the new project.','Copy of '+sProjectName)
			if (sNewName != "" && sNewName != null)
				{
				//If we are copying a template then add template_<name>
				if (sProjectName.toLowerCase().indexOf("template_") != -1)
					{
					sNewName = "template_" + sNewName
					}
				//change the cursor to an hourglass
				document.body.style.cursor="wait";
				//Set the action to copy and submit the form
				document.getElementById('txtaction').value="copyproject:"+sProjectName+"-to-"+sNewName;
				document.Form1.submit();
				}
			}
			
		function copytemplateproject(sProjectName)
			{
			//prompt for the new project name
			var sNewName = prompt('Please enter a name for the new project.','New Project')
			if (sNewName != "" && sNewName != null)
				{
				//change the cursor to an hourglass
				document.body.style.cursor="wait";
				//Set the action to copy and submit the form
				document.getElementById('txtaction').value="copyproject:"+sProjectName+"-to-"+sNewName;
				document.Form1.submit();
				//Reload the startup form
				//window.open("default.aspx", "_blank")
				}
			}

			
			
		function HideSplash()
			{
			//Once the page has finished loading, hide the splash (unless the frame contains the activation key prompt)
			if (document.getElementById('frame_work').src.indexOf("activationkey.aspx") == -1)
				{
				document.getElementById('frame_work').src="../_engine/blank.htm"
				document.getElementById('frame_work').style.display = "none"
				//document.getElementById('frame_work').style.visibility = "hidden"
				}
			}

		function CloseAppForm()
			{
			parent.location.href='apptools.aspx';
			}


		function ShowProgress()
			{
			//Show the progress bar
			if (document.getElementById("divProgress") != null)
				{
				document.getElementById("divProgress").style.visibility = "visible";
				}
			return true;
			}

		function createskin()
			{
			//prompt for the name of the new skin
			var sNewName = prompt('Please enter a name for the new Skin.','New Skin')
			if (sNewName != "")
				{
				//change the cursor to an hourglass
				document.body.style.cursor="wait";
				//Set the action to addskin and submit the form
				document.getElementById('txtaction').value="addskin:"+sNewName;
				document.Form1.submit();
				}
			}
			
		function copyskin(SkinName)
			{
			//prompt for the new skin name
			var sNewName = prompt('Please enter a name for the new Skin.','copy of '+SkinName)
			//alert("sNewName = "+sNewName);
			if (sNewName != "" && sNewName != null)
				{
				//change the cursor to an hourglass
				document.body.style.cursor="wait";
				//Set the action to copy and submit the form
				document.getElementById('txtaction').value="copyskin:"+SkinName+"-to-"+sNewName;
				document.Form1.submit();
				}
			}

		function deleteskin(SkinName)
			{
			//ask the user if they're sure
			if(confirm("The Skin '"+SkinName+"' will be permanently deleted.") == true)
				{
				//change the cursor to an hourglass
				document.body.style.cursor="wait";
				//Set the action to delete and submit the form
				document.getElementById('txtaction').value="deleteskin:"+SkinName;
				document.Form1.submit();
				}
			}
			
			
		
//		// this function gets the *ookie, if it exists
//		function Get_*ookie(name) 
//			{
//			//alert("document.*ookie = " + document.*ookie);
//			var start = document.*ookie.indexOf( name + "=" );
//			var len = start + name.length + 1;
//			if ( ( !start ) && ( name != document.*ookie.substring( 0, name.length ) ) )
//				{
//				return null;
//				}
//			if ( start == -1 ) return null;
//			var end = document.*ookie.indexOf( ";", len );
//			if ( end == -1 ) end = document.*ookie.length;
//			return unescape( document.*ookie.substring( len, end ) );
//			}
//
//		function create*ookie(name,value,days)
//			{
//			//If you set the number of days to 0 the *ookie is trashed when the user closes the browser. If you set the days to a negative number the *ookie is trashed immediately.
//			//For syntax, see: http://www.quirksmode.org/js/*ookies.html
//			if (days)
//				{
//				var date = new Date();
//				date.setTime(date.getTime()+(days*24*60*60*1000));
//				var expires = "; expires="+date.toGMTString();
//				}
//			else var expires = "";
//			document.*ookie = name+"="+value+expires+"; path=/";
//			}
//
//		function erase*ookie(name)
//			{
//			create*ookie(name,"",-1);
//			}

		function showpdf()
			{
			//If we are in design mode, exit
			if (window.frame_contents.document.Form1.txtmode.value=='edit')
				{
				alert("Pages cannot be viewed in PDF format while in edit mode.")
				return;
				}

			//reload the page and pass the PDF parameter
			var sProjectParm="&projectname="+frame_contents.document.Form1.txtProjectName.value;
			var sFileParm="&filename="+frame_contents.document.Form1.txtcurrentpage.value;
			window.frame_window.location.href="../_engine/showpdf.aspx?format=PDF" + sProjectParm + sFileParm;
			//Show the window frame and hide the main frame
			//parent.document.getElementById('frame_main').style.display="none";
			//parent.document.getElementById('frame_window').style.display="";
			document.getElementById('frame_main').style.display="none";
			document.getElementById('frame_window').style.display="";

			}

		function showpageurl()
			{
			//Load ShowPageURL.aspx into the work frame
			var sProjectParm="?projectname="+frame_contents.document.Form1.txtProjectName.value;
			var sFileParm="&filename="+frame_contents.document.Form1.txtcurrentpage.value;
			window.frame_work.location.href="../_engine/showpageurl.aspx"+ sProjectParm + sFileParm;
			//parent.document.getElementById('frame_work').style.width="700px";
			//parent.document.getElementById('frame_work').style.height="400px";
			//parent.document.getElementById('frame_work').style.top=document.body.clientHeight/2-200;
			//parent.document.getElementById('frame_work').style.left=document.body.clientWidth/2-350;
			document.getElementById('frame_work').style.width="700px";
			document.getElementById('frame_work').style.height="400px";
			document.getElementById('frame_work').style.top=document.body.clientHeight/2-200;
			document.getElementById('frame_work').style.left=document.body.clientWidth/2-350;
			//Show the work frame 
			//parent.document.getElementById('frame_work').style.display="";
			document.getElementById('frame_work').style.display="";
			}

		function DisplayTools()
			{
			//Cancel this action if the activation key page is displayed
			if (document.getElementById("frame_work").src == "activationkey.aspx"){return}
			
			var sProjectParm="?projectname="+frame_contents.document.Form1.txtProjectName.value
			var sSkinParm="&skin="+frame_contents.document.Form1.txtcurrentskin.value;
			frame_window.location.href="../_engine/tools.aspx"+sProjectParm+sSkinParm;
			//Hide the main frame & show the work frame
			document.getElementById("frame_main").style.display="none";
			document.getElementById("frame_window").style.display="";
			}



	function changeskin()
		{
		//if [Edit skin] was selected then load the skin editor form
		var sSelectedIndex = document.Form1.LstSkins.options.selectedIndex
		var sSelectedValue = document.Form1.LstSkins.options[sSelectedIndex].value;
		if (sSelectedValue.toLowerCase() == "[edit skin]")
			{
			//---- [EDIT SKIN] selected ---
			var sProjectParm = "?projectname="+window.frame_contents.document.Form1.txtProjectName.value;
			var sSkinParm = "&skin="+window.frame_contents.document.Form1.txtcurrentskin.value;
			var stype = "&type=skineditor";
			var sURL = "_editor.aspx" + sProjectParm + sSkinParm + stype;
			window.open(sURL, "skineditor");
			//Set the selected item back to the skin
			document.Form1.LstSkins.value = window.frame_contents.document.Form1.txtcurrentskin.value;
			}

		else
			{
			//---- Skin Selected ----
			//Show the loading... message
			var sSkinParm = "?skin="+document.Form1.LstSkins.options[document.Form1.LstSkins.options.selectedIndex].value;
			window.location.href="default.aspx" + sSkinParm;
			document.getElementById("frame_work").style.visibility="visible";

			}
		}
	




		function Publish(stype)
			{
			//Cancel this action if the activation key page is displayed
			if (document.getElementById("frame_work").src == "activationkey.aspx"){return}
			
			
			var sProjectParm="?projectname="+frame_contents.document.Form1.txtProjectName.value 
			var sSkinParm="&skin="+frame_contents.document.Form1.txtcurrentskin.value;
			var sThemeParm="&treetheme="+frame_contents.document.Form1.txttreetheme.value;
			var sTypeParm="&type="+stype;
			frame_window.location.href="../_engine/publish.aspx"+sProjectParm+sSkinParm+sThemeParm+sTypeParm;
			document.getElementById("frame_main").style.display="none";
			document.getElementById("frame_window").style.display="";
			}
			
		function ShowAppLogin()
			{
			//Load the login form into the work frame.
			document.getElementById("frame_work").src="applogin.aspx"
			
			//Make the work frame visible
  			document.getElementById("frame_work").style.position="absolute";
			document.getElementById("frame_work").style.top=document.body.clientHeight/2-65;
			document.getElementById("frame_work").style.left=document.body.clientWidth/2-150;

			document.getElementById("frame_work").style.width="304px";
			document.getElementById("frame_work").style.height="130px";
			//document.getElementById("frame_work").style.visibility="visible";
			document.getElementById("frame_work").style.display="";
			}

			
		function ShowProjectLogin()
			{
			//If the project needs to be saved, don't allow the user to login
			obj=document.getElementById("frame_contents")
			//alert("obj = " +obj);
			if (obj != null)
				{
				//if (parent.frame_contents.document.getElementById('imgsave').src.indexOf("images/save.gif")==-1)
				if (frame_contents.document.getElementById('imgsave').src.indexOf("images/save.gif")==-1)
					{
					//Save Required
					alert("Please save the project before logging in.");
					return;
					}
				}

			
			//Load the login form into the work frame.
			//var sProjectParm="?projectname="+parent.frame_contents.document.Form1.txtProjectName.value; 
			var sProjectParm="?projectname="+frame_contents.document.Form1.txtProjectName.value; 
			document.getElementById("frame_work").src="../_engine/projectlogin.aspx"+sProjectParm;
			
			//Make the work frame visible
			//parent.frame_contents.ShowWorkFrame(false,false);
  			document.getElementById("frame_work").style.position="absolute";
			document.getElementById("frame_work").style.top=document.body.clientHeight/2-65;
			document.getElementById("frame_work").style.left=document.body.clientWidth/2-150;
			document.getElementById("frame_work").style.width="304px";
			document.getElementById("frame_work").style.height="130px";
			//document.getElementById("frame_work").style.visibility="visible";
			document.getElementById("frame_work").style.display="";

			}
		
		function app_logout()
			{
			//erase*ookie("startup")

			//Reload the startup or the project form
			document.location.href="default.aspx?username=public";
			}
			
		function project_logout()
			{

			//Get the current Project name
			//var sProjectName=frame_contents.document.Form1.txtProjectName.value;

			//erase*ookie(sProjectName)
			
			//Reload the project form
			document.location.href="default.aspx?username=public";
			}

		
		function tabclick_contents(sSkinName)
			{
			//alert("tabclick_contents")
			//display the contents tab
			document.getElementById("imgtabs").src="skinimages/"+sSkinName+"_tabs_contents.gif";
			document.getElementById("trSearchBox").style.display="none";
			//Show the contents, hide the search results and keywords
			window.frame_contents.document.getElementById("divContents").style.display = "";
			window.frame_contents.document.getElementById("divSearchResults").style.display = "none";
			window.frame_contents.document.getElementById("divKeywords").style.display = "none";

			}
			
		function tabclick_index(sSkinName)
			{
			//alert("tabclick_index")
			//display the index tab
			document.getElementById("imgtabs").src="skinimages/"+sSkinName+"_tabs_index.gif";
			document.getElementById("trSearchBox").style.display="none";
			//Show the Index, hide the search results and contents
			window.frame_contents.document.getElementById("divSearchResults").style.display = "none";
			window.frame_contents.document.getElementById("divKeywords").style.display = "";
			//If we are in live mode, hide the contents frame
			if (window.frame_contents.document.Form1.txtmode.value.toLowerCase() != "edit")
				{
				window.frame_contents.document.getElementById("divContents").style.display = "none";
				}

			}
			
		function tabclick_search(sSkinName)
			{
			//alert("tabclick_search")
			//display the search tab
			document.getElementById("imgtabs").src="skinimages/"+sSkinName+"_tabs_search.gif";
			
			//show the search box
			document.getElementById("trSearchBox").style.display="";
			
			//Hide the contents, search results, and index
			window.frame_contents.document.getElementById("divSearchResults").style.display = "none";
			window.frame_contents.document.getElementById("divKeywords").style.display = "none";

			//If we are in live mode, hide the contents frame
			if (window.frame_contents.document.Form1.txtmode.value.toLowerCase() != "edit")
				{
				window.frame_contents.document.getElementById("divContents").style.display = "none";
				}

			}
			
