function page_load() {
	var contentiframe=document.getElementById("contentiframe");
	if(contentiframe != null)
		contentiframe.src="../../templates/content.cfm?userid=" + gUserId;
	setTimeout("reposition_elements()", 500);
}
// reposition page elements
function reposition_elements() {
	// get client sizes
	var pHeight;
	if(window.innerHeight != null)
		pHeight=window.innerHeight;
	else
		pHeight=window.document.body.offsetHeight;
	if(pHeight < 400)
		pHeight=400;
	// resize content element
	var cHeight=0;
	var vHeight=document.getElementById("headercontainer");
	if(vHeight != null)
		cHeight+=vHeight.offsetHeight;
	vHeight=document.getElementById("navcontainer");
	if(vHeight != null)
		cHeight+=vHeight.offsetHeight;
	vHeight=document.getElementById("footercontainer");
	if(vHeight != null)
		cHeight+=vHeight.offsetHeight;
	var contentiframe=document.getElementById("contentiframe");
	if(contentiframe != null)
		contentiframe.height=pHeight-cHeight-gHeightPad;
}
function clear_selected() {
	if(document.selection != null)
		document.selection.empty();	
	else {
		var selobj=window.getSelection();
		if(selobj != null) {
			var oneRange;
			for(var i=0; i < selobj.rangeCount; i++) {
				oneRange=selobj.getRangeAt(i);
				selobj.removeRange(oneRange);
			}
		}
	}
}
function select_content(cnum) {
	gpagenum=cnum;
	var contentiframe=document.getElementById("contentiframe");
	var cinum, cid, containerid, container, vpassena, vpassword, vpcontainerid;
	if(contentiframe != null) {
		// hide all
		for(var i=0; i<gnn.length; i++) {
			containerid=gnn[i];
			cid="container_" + cnum;
			if(gnn[i]==cid) {
				cinum=i+1;
				gipagenum=cinum;
			}
			try {
				if(contentiframe.contentWindow != null) {
					container=contentiframe.contentWindow.document.getElementById(containerid);
					if(container != null)
						container.style.display="none";
				}
				else if(contentiframe.contentDocument != null) {
					container=contentiframe.contentDocument.getElementById(containerid);
					if(container != null)
						container.style.display="none";
				}
			}
			catch(e) {
				window.location.href="../../templates/designer.cfm?include=" + gdesignreturn;
				return;
			}
		}
		containerid="passchk";
		if(contentiframe.contentWindow != null) {
			container=contentiframe.contentWindow.document.getElementById(containerid);
			if(container != null)
				container.style.display="none";
		}
		else if(contentiframe.contentDocument != null) {
			container=contentiframe.contentDocument.getElementById(containerid);
			if(container != null)
				container.style.display="none";
		}
	}
	// jump to admin
	if(cnum == "6") {
		window.location.href="../../templates/designer.cfm?include=" + gdesignreturn;
		return;
	}
	// show selected
	vpassena=gnpe[cinum-1];
	vpassword=gnp[cinum-1];
	vpcontainerid="passchk";
	containerid=gnn[cinum-1];
	if(contentiframe.contentDocument != null) {
		if(vpassena > 0 && vpassword != "" && pwp[cinum-1]==0) {
			container=contentiframe.contentDocument.getElementById(vpcontainerid);
		}
		else {
			container=contentiframe.contentDocument.getElementById(containerid);
		}
		if(container != null) {
			container.style.display="block";
		}
	}
	else if(contentiframe.contentWindow != null) {
		if(vpassena > 0 && vpassword != "" && pwp[cinum-1]==0) {
			container=contentiframe.contentWindow.document.getElementById(vpcontainerid);
		}
		else {
			container=contentiframe.contentWindow.document.getElementById(containerid);
		}
		if(container != null) {
			container.style.display="block";
		}
	}
}
function passwordchk() {
	var vformpass;
	var vpassword=gnp[gipagenum-1];
	var contentiframe=document.getElementById("contentiframe");
	if(contentiframe != null) {
		if(contentiframe.contentDocument != null) {
			vformpass=contentiframe.contentDocument.passadmin.pagepass.value;
			contentiframe.contentDocument.passadmin.pagepass.value="";
		}
		else if(contentiframe.contentWindow != null) {
			vformpass=contentiframe.contentWindow.document.passadmin.pagepass.value;
			contentiframe.contentWindow.document.passadmin.pagepass.value="";
		}
		// compare and set
		if(vformpass == vpassword) {
			pwp[gipagenum-1]=1;
			select_content(gpagenum)
		}
	}
}