<!--
//var openMenu		   = null;
var selectedContainer = null;
var containerName = null;

var myTable = null;
var tableSelected = false;
var rowIndex = -1;
var cellIndex=-1;
var currentRow = null;
var currentCell = null;
var cellCount = 0;


	
	function LCID() {
		var cbo = document.all("cboRegions");
		return cbo(cbo.selectedIndex).value;
	}
	
	function pageName() {
		return document.all("PageName").innerText;
	}
	
	function createCMSContent() {

		var fldrName;
		var	TemplateID;
		var	LanguageID;
		var newName;
		var URL;
	
		closeActionMenu();
				
	
		//fldrName = selectedFolderObj.innerText;
		fldrName = "test Folder";

		var sFeatures="dialogHeight:350px;dialogWidth:600px";
		URL="../DynEdit/NewContent.asp?Folder=" + fldrName;
		vReturnValue = window.showModalDialog(URL, null,sFeatures);
		
		if (vReturnValue != null) {
			TemplateID = vReturnValue[1];
			//var temp = xmlFolders.selectSingleNode("FOLDERS/LANGUAGES/LANGUAGE[@LANGUAGEORDER='1']");
			//if (temp == null) {alert("Default Language is missing\n" + xmlFolders.xml);}
			//LanguageID = temp.getAttribute("LANGUAGEID");
			//if (LanguageID == null) {alert("Default Language is missing\n" + xmlFolders.xml);}
			
			//xmlContents.loadXML("<CONTENTS/>");
			//xmlContents.documentElement.setAttribute("ACTION", "Add Content");
			newName = vReturnValue[0];
			if (newName == '') {
				alert("Name is required");
				return;
			}
			
			alert(TemplateID);
			alert(newName);
			//xmlContents.documentElement.setAttribute("NEWNAME", newName);
			//xmlContents.documentElement.setAttribute("TEMPLATEID", TemplateID);
			//xmlContents.documentElement.setAttribute("STARTDATE", vReturnValue[2]);
			//xmlContents.documentElement.setAttribute("ENDDATE", vReturnValue[3]);
			//xmlContents.documentElement.setAttribute("FOLDERID", selectedFolderID);
			//xmlContents.documentElement.setAttribute("REGIONID", RegionID);
			//xmlContents.documentElement.setAttribute("SORTFIELD", sortField);
			//xmlContents.documentElement.setAttribute("SORTDIR", sortDir);
			//xmlContents.documentElement.setAttribute("GLOBAL", vReturnValue[4]);
			
			//var url = "Process.asp?P=SaveContentValues";
			//if ( processPost(url, false, 'contents')) {
			//	var ContentID = xmlContents.documentElement.getAttribute("NEWCONTENTID");
			//	if (ContentID != null) {
			//		editContent(ContentID, TemplateID, LanguageID);
			//	} else {
			//		alert("Create Failed. \nReturned ContentID = 0.");
			//	}
			//}
		}
	}




	function arrangeContent(cName) {
		var oElem, left, top, par, te;
		var oXML = new ActiveXObject("MSXML2.DOMDocument.3.0");
		
		containerName = cName;
		selectedContainer = document.all(containerName);
		
		oXML.loadXML("<CMAX />");

		oElem = oXML.createElement("ACTION");
		oElem.setAttribute("ACTION", "LAYOUT_GET");
		oXML.documentElement.appendChild(oElem);
		getContent(oXML);
		
		
		//selectedContainer.innerHTML='<div id="layoutDiv" valign="center" contenteditable="true" style="background:lavender;color:blue;width:100%;height:100%;"><table border="1" valign="center" width="100%" id="layoutTable" onClick="tableClick();"><tr><td align="center"><span name="CMS" cStyle="Teaser" contenteditable="false" id="1">One</span></td><td><span name="CMS" cStyle="Teaser" contenteditable="false" id="2">Two</span></td></tr><tr><td><span name="CMS" cStyle="Teaser" contenteditable="false" id="3">Three</span></td><td><span name="CMS" cStyle="Teaser" contenteditable="false" id="4">Four</span></td></tr></table></div>';
		myTable = selectedContainer.all('layoutTable');
		myTable.attachEvent('onclick',tableClick);
		myTable.setAttribute("border","1");
		myTable.className = "layout_border";
		myTable.removeAttribute("style",0);
		//alert(myTable.outerHTML);

		left = selectedContainer.offsetLeft + selectedContainer.offsetWidth + 10;
		top = selectedContainer.offsetTop;
		par = selectedContainer.offsetParent
		while (par != null) {
			left += par.offsetLeft
			top += par.offsetTop;
			par = par.offsetParent
		}

		te = document.all("tableEdit");
		te.style.posLeft  = left;
		te.style.posTop   = top + document.body.scrollTop + 2;
		te.style.display  = 'inline';
		myTable.rows(0).cells(0).click();

		return;
	}
	

	function saveLayout() {
		var oElem, cElem, oTbl, oRow, te, spans, i;
		var oXML = new ActiveXObject("MSXML2.DOMDocument.3.0");

		if (selectedContainer != null) {
			//alert(selectedContainer.innerHTML);
			te = document.all("tableEdit");
			te.style.display  = 'none';
			
			oTbl = selectedContainer.firstChild.firstChild;
			oTbl.className="main_text";
			oTbl.removeAttribute("onclick",0);
			oTbl.removeAttribute("style",0);
			oTbl.setAttribute("border", "0");
			oTbl.setAttribute("width", "100%");
			for (i=0;i<oTbl.rows.length; i++) {
				oRow = oTbl.rows[i];
				for (j=0; j<oRow.cells.length; j++) {
					oRow.cells[j].removeAttribute("style",0);
				}
			}

			oXML.loadXML("<CMAX />");
			oElem = oXML.createElement("ACTION");
			oElem.setAttribute("ACTION", "LAYOUT_SAVE");
			cElem = oXML.createCDATASection(oTbl.outerHTML);
			oElem.appendChild(cElem);		
			oXML.documentElement.appendChild(oElem);
			oElem = oXML.createElement("CONTENTS");
			spans = selectedContainer.getElementsByTagName("SPAN");
			for (i=0; i<spans.length; i++) {
				if(spans[i].name == 'CMS') {
					cElem = oXML.createElement("CONTENT");
					//alert(spans[i].outerHTML);
					cElem.setAttribute("ID",spans[i].getAttribute('CONTENTID'));
					cElem.setAttribute("CSTYLE", spans[i].getAttribute("cStyle"));
					oElem.appendChild(cElem);
				}
			}
			oXML.documentElement.appendChild(oElem);
			//alert(oXML.xml);
			//alert(oTbl.outerHTML);
			getContent(oXML);
			myTable=null;
		}
	}
	
	function cancelLayout() {
		var oElem;
		var oXML = new ActiveXObject("MSXML2.DOMDocument.3.0");
		
		var te = document.all("tableEdit");
		te.style.display  = 'none';
		oXML.loadXML("<CMAX />");
		oXML.documentElement.setAttribute("CONTAINER", containerName);
		oElem = oXML.createElement("ACTION");
		oElem.setAttribute("ACTION", "CONTENT_GET");
		oXML.documentElement.appendChild(oElem);
		getContent(oXML);
		myTable=null;
	}

	function addCMSContent(page) {
		var features, url, ret, oElem, contentID, style, oElem; 
		var oXML = new ActiveXObject("MSXML2.DOMDocument.3.0");
		
		features="dialogHeight:350px;dialogWidth:600px";
	
		url="../Library/Process.asp?P=BrowseContents";
		//url='/BrowseContents';
		if (page != '') {
		    url += "&Page=" + page;
		}
		url += "&Container=" + selectedContainer.id;

		ret = window.showModalDialog(url, null, features);
		if (ret != null) {
			contentID = ret[0];
			style = ret[2];
			oElem = document.createElement("SPAN");
			//<span contenteditable="false" CONTENTID="1" name="CMS" cStyle="Teaser" >One</span>			
			oElem.contentEditable=false;
			oElem.setAttribute("CONTENTID", contentID);
			oElem.setAttribute("name", "CMS");
			oElem.setAttribute("cStyle", style);
			oElem.innerText=ret[1];
			//alert(oElem.outerHTML);
			if (currentCell != null) {
				currentCell.appendChild(oElem);
			} else {
				selectedContainer.firstChild.appendChild(oElem);
			}
			return;
		}
	}

	function getContent(oXML){
		var ret, url;
//		alert(oXML);
//		alert(oXML.xml);

		oXML.documentElement.setAttribute("PAGE", pageName());
		oXML.documentElement.setAttribute("CONTAINER", containerName);

		url="/Library/Process.asp?P=cmax_BaseASync&axPage="+pageName()+"&C="+containerName;
		
		//alert(oXML.xml);
		//alert(url);
		//url='/cmax_BaseASync?axPage=' + pageName() + '&C=' + containerName;

		window.status="Retrieving data";
		document.body.style.cursor = "wait";
		//alert(oXML.xml);
		ret = httpPost2(url, oXML.xml);
		document.body.style.cursor = "default";
		window.status="";

		if (ret != null) {
		//alert(ret);
		//alert(ret.xml);
		//alert(ret.text);
			if (selectedContainer != null) {
				selectedContainer.innerHTML = ret.documentElement.selectSingleNode("RETURN").text;
				//alert(selectedContainer.innerHTML);
			}
		}
	}

	function httpPost2(url, data) {
    
		var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.Open("POST", url, false);
		xmlhttp.setRequestHeader("hasXML", "TRUE");
		xmlhttp.Send(data);
		
		if (xmlhttp.readyState != 4) {
			return null;
		}
		//alert(xmlhttp.responseText);
		return xmlhttp.responseXML;
	}


	function editContent(CID) {
		if (CID == '') {return};
		
		var url='';
		url = "../Library/Process.asp?P=ContentTemplate" + "&CID=" + CID + "&axPage="+pageName();
		//url = '/ContentTemplate?CID=' + CID + '&axPage=' + pageName();
		
		//alert(url);
						
		var newWin = window.open(url, "Content", "resizable=yes,status=yes,scrollbars=yes")
		return;		
	}

	function publishPage() {
		var ret, url, oErr;
			
		url = "../Library/Process.asp?P=PublishPage&axPage="+pageName();
		//url = '/PublishPage?axPage=' + pageName();
		
		window.status="Retrieving data";
		document.body.style.cursor = "wait";
		ret = httpPost(url, "<X />");
		document.body.style.cursor = "default";
		window.status="";
		if (ret != null) {
			oErr = ret.selectSingleNode("PARAMS/VALUES/VALUE[@NAME='XMLPOST']/ERROR");
			if (oErr == null) {
				alert("Published");
			} else {
				alert(oErr.Text);
			}
		} else {
			alert("Publish Failed.");
		}
	}
	

	function tableClick(){
		var el = event.srcElement;
		//alert(el.nodeName);
		if (el.nodeName=="TABLE") {
			tableSelected=true;
			if (currentCell != null) {
				currentCell.style.backgroundColor="lavender";
			}
			cellIndex=-1;
			cellCount=0;
			rowIndex=-1;
			currentRow = null
			currentCell = null;
			myTable.style.backgroundColor="#CDC1C5";
		} else {		
			if (el.nodeName=='TD') {
				if (currentCell != null) {
					currentCell.style.backgroundColor="lavender";
				}
				if (tableSelected) {
					myTable.style.backgroundColor="lavender";			
					tableSelected=false;
				}
				currentCell=el;
				cellIndex=el.cellIndex;
				rowIndex = el.parentNode.rowIndex;
				currentRow = myTable.rows[rowIndex];
				cellCount = currentRow.cells.length;
				currentCell.style.backgroundColor="#CDC1C5";
			} else {
				el = el.parentNode
				if (el.nodeName=='TD') {
					if (currentCell != null) {
						currentCell.style.backgroundColor="lavender";
					}
					if (tableSelected) {
						myTable.style.backgroundColor="lavender";			
						tableSelected=false;
					}
					currentCell=el;
					cellIndex=el.cellIndex;
					rowIndex = el.parentNode.rowIndex;
					currentRow = myTable.rows[rowIndex];
					cellCount = currentRow.cells.length;
					currentCell.style.backgroundColor="#CDC1C5";
				}				
			}
		}
	}

	function vAlign(attr) {
		if(tableSelected) {
			myTable.setAttribute("vAlign",attr)
		} else {
			if (currentCell != null) {
				currentCell.setAttribute("vAlign",attr);
			}
		}
	}
	
	function hAlign(attr) {
		if(tableSelected) {
			myTable.setAttribute("Align",attr)
		} else {
			if (currentCell != null) {
				currentCell.setAttribute("align",attr);
			}
		}
	}
	
	function addStyle(style) {
	}
	
	function addRow(where) {
		var i, oTr;

		if(currentRow == null) {
			oTr = myTable.insertRow(-1);
			for (i=0; i<myTable.rows[0].cells.length; i++) {
				oTr.insertBefore(document.createElement("td"));	
			}			
		} else {
			if (where == 'top') {
				if (rowIndex == 0) {
					oTr = myTable.insertRow(0);
				} else {
					oTr = myTable.insertRow(rowIndex);
				}
			} else {
				oTr = myTable.insertRow(rowIndex+1);
			}
			for (i=0; i<cellCount; i++) {
				if (where == 'top') {
					oTr.insertBefore(document.createElement("td"));	
				} else {
					oTr.appendChild(document.createElement("td"));	
				}
			}	
			oTr.cells[cellIndex].click();		
		}
	}
	
	function addCell() {
		if (currentRow != null) {
			currentRow.insertBefore(document.createElement("td"), currentCell);
			//alert(myTable.innerHTML);
		}
	}
	
	function addCol(where) {
		var i, pos;
		
		if (where == 'left') {
			pos=cellIndex;
			for (i=0; i<myTable.rows.length; i++) {
				myTable.rows[i].insertBefore(document.createElement("td"), myTable.rows[i].cells[pos]);		
			}
			currentRow.cells[pos].click();	
				
		} else {
			if (cellIndex < cellCount-1) {
				pos=cellIndex+1;
				for (i=0; i<myTable.rows.length; i++) {
					myTable.rows[i].insertBefore(document.createElement("td"), myTable.rows[i].cells[pos]);		
				}
				currentRow.cells[pos].click();	
			} else {
				pos=cellIndex+1;
				for (i=0; i<myTable.rows.length; i++) {
					myTable.rows[i].insertBefore(document.createElement("td"));		
				}
				currentRow.cells[pos].click();	
			}
		}
	}
	
	
	function deleteRow() {
		if (rowIndex < 0 ) {
			return;
		}

		myTable.deleteRow(rowIndex);
		rowIndex=-1;
		currentRow=null;
	}
	
	function deleteCell() {
		if (currentCell != null) {
			currentRow.removeChild(currentCell);
			currentCell = null
			cellIndex=-1;
		}
	}

	function deleteCol() {
		if (cellIndex < 0) {
			return;
		}
		
		var i;
		for (i=0; i<myTable.rows.length; i++) {
			myTable.rows[i].removeChild(myTable.rows[i].cells[cellIndex]);
		}
	
	}

	
	function cellWidth() {
	}
	
	function colSpan() {
		var attribVal;
		if (currentCell!= null) {
			attribVal = currentCell.getAttribute("colspan");
			if (attribVal =='' || attribVal == null) {
				attribVal = 0;
			}
			attribVal +=1;
			currentCell.setAttribute("colspan", attribVal);
		}
	}
	
	function rowSpan() {
	}
	
	
	
-->