
function test22(){
	var editBody=document.frames("LatticeEditDocument").document.body;
	for(var intLoop=0;intLoop<editBody.all.length;intLoop++){
		el=editBody.all[intLoop];
		el.removeAttribute("className","",0);
		el.removeAttribute("style","",0);
	}
	var html=document.frames("LatticeEditDocument").document.body.innerHTML;
	html=html.replace(/<o:p>&nbsp;<\/o:p>/g,"");
	html=html.replace(/o:/g,"");
	document.frames("LatticeEditDocument").document.body.innerHTML=html;
}

function tableProp(){
	var tableflag=false;
	var xsel=document.frames("LatticeEditDocument").document.selection;
	var xobj=document.frames("LatticeEditDocument").document.selection.createRange();
	if(xsel.type=="None"||xsel.type=="Text"){
		xsel=xobj.parentElement();
		while(xsel.tagName!="BODY"&&tableflag==false){
			if(xsel.tagName=="TABLE"){tableflag=true;}
			if(tableflag==false){xsel=xsel.parentElement;}
		}
	}else if(xsel.type=="Control"){
		xsel=xobj.item(0);
		if(xsel.tagName=="TABLE"){
			tableflag=true;
		}else{
			while(xsel.tagName!="BODY"&&tableflag==false){
				if(xsel.tagName=="TABLE"){tableflag=true;}
				if(tableflag==false){xsel=xsel.parentElement;}
			}
		}
	}
	if(tableflag==true){
		if(xsel.className!=""&&xsel.className!=null){tableclass=xsel.className;}else{tableclass="";}
		if(xsel.width!=""&&xsel.width!=null){tablewidthspecified="yes";tablewidth=xsel.width;}else{tablewidthspecified="no";tablewith="";}
		if(xsel.align!=""&&xsel.align!=null){tablealign=xsel.align;}else{tablealign="";}
		if(xsel.border!=""&&xsel.border!=null){tablebordersize=xsel.border;}else{tablebordersize="";}
		if(xsel.cellPadding!=""&&xsel.cellPadding!=null){tablecellpadding=xsel.cellPadding;}else{tablecellpadding="";}
		if(xsel.cellSpacing!=""&&xsel.cellSpacing!=null){tablecellspacing=xsel.cellSpacing;}else{tablecellspacing="";}
		if(xsel.borderColor!=""&&xsel.borderColor!=null){tablebordercolor=xsel.borderColor;}else{tablebordercolor="";}
		if(xsel.bgColor!=""&&xsel.bgColor!=null){tablebackgroundcolor=xsel.bgColor;}else{tablebackgroundcolor="";}
		tableiscancel="";
		window.showModalDialog("../latticeeditor/tableprops.htm",window,"dialogHeight: 350px; dialogWidth: 400px; help: no;scroll: no; status: no");
		if(tableiscancel=="no"){
			if(tablewidthspecified=="yes"){
				var tw1="";
				if(tablewidthtype=="percentage"){
					tw1=tablewidth+"%";
				}else{
					tw1=tablewidth;
				}
				xsel.width=tw1;
			}else{
				xsel.removeAttribute("width",0);
			}
			if(tablealign!=""&&tablealign!="Default"){xsel.align=tablealign;}else{xsel.removeAttribute("align",0);}
			if(tableclass!=""&&tableclass!="Default"){xsel.className=tableclass;}else{xsel.removeAttribute("className",0);}
			if(tablebordersize!=""&&tablebordersize!=null){xsel.border=tablebordersize;}else{xsel.removeAttribute("border",0);}
			if(tablecellpadding!=""&&tablecellpadding!=null){xsel.cellPadding=tablecellpadding;}else{xsel.removeAttribute("cellPadding",0);}
			if(tablecellspacing!=""&&tablecellspacing!=null){xsel.cellSpacing=tablecellspacing;}else{xsel.removeAttribute("cellSpacing",0);}
			if(tablebordercolor!=""&&tablebordercolor!="Default"){xsel.borderColor=tablebordercolor;}else{xsel.removeAttribute("borderColor",0);}
			if(tablebackgroundcolor!=""&&tablebackgroundcolor!="Default"){xsel.bgColor=tablebackgroundcolor;}else{xsel.removeAttribute("bgColor",0);}
		}
	}
}

function cellProp(){
	var cellflag=false;
	var xsel=document.frames("LatticeEditDocument").document.selection;
	var xobj=document.frames("LatticeEditDocument").document.selection.createRange();
	if(xsel.type=="None"||xsel.type=="Text"){
		xsel=xobj.parentElement();
		while(xsel.tagName!="BODY"&&cellflag==false){
			if(xsel.tagName=="TD"){cellflag=true;}
			if(cellflag==false){xsel=xsel.parentElement;}
		}
	}else if(xsel.type=="Control"){
		xsel=xobj.item(0);
		if(xsel.tagName=="TD"){
			cellflag=true;
		}else{
			while(xsel.tagName!="BODY"&&cellflag==false){
				if(xsel.tagName=="TD"){cellflag=true;}
				if(cellflag==false){xsel=xsel.parentElement;}
			}
		}
	}
	if(cellflag==true){
		if(xsel.width!=""&&xsel.width!=null){tablewidthspecified="yes";tablewidth=xsel.width;}else{tablewidthspecified="no";tablewith="";}
		if(xsel.align!=""&&xsel.align!=null){tablealign=xsel.align;}else{tablealign="";}
		if(xsel.className!=""&&xsel.className!=null){tablecellclass=xsel.className;}else{tablecellclass="";}
		if(xsel.vAlign!=""&&xsel.vAlign!=null){tablevalign=xsel.vAlign;}else{tablevalign="";}
		if(xsel.borderColor!=""&&xsel.borderColor!=null){tablebordercolor=xsel.borderColor;}else{tablebordercolor="";}
		if(xsel.bgColor!=""&&xsel.bgColor!=null){tablebackgroundcolor=xsel.bgColor;}else{tablebackgroundcolor="";}
		tableiscancel="";
		window.showModalDialog("../latticeeditor/cellprops.htm",window,"dialogHeight: 300px; dialogWidth: 400px; help: no;scroll: no; status: no");
		if(tableiscancel=="no"){
			if(tablewidthspecified=="yes"){
				var tw1="";
				if(tablewidthtype=="percentage"){tw1=tablewidth+"%";}else{tw1=tablewidth;}
				xsel.width=tw1;
			}else{
				xsel.removeAttribute("width",0);
			}
			if(tablealign!=""&&tablealign!="Default"){xsel.align=tablealign;}else{xsel.removeAttribute("align",0);}
			if(tablevalign!=""&&tablevalign!="Default"){xsel.vAlign=tablevalign;}else{xsel.removeAttribute("vAlign",0);}
			if(tablecellclass!=""&&tablecellclass!="Default"){xsel.className=tablecellclass;}else{xsel.removeAttribute("className",0);}
			if(tablebordercolor!=""&&tablebordercolor!="Default"){xsel.borderColor=tablebordercolor;}else{xsel.removeAttribute("borderColor",0);}
			if(tablebackgroundcolor!=""&&tablebackgroundcolor!="Default"){xsel.bgColor=tablebackgroundcolor;}else{xsel.removeAttribute("bgColor",0);}
		}
	}
}

function imageProp(){
	var imageflag=false;
	var xsel=document.frames("LatticeEditDocument").document.selection;
	var xobj=document.frames("LatticeEditDocument").document.selection.createRange();
	if(xsel.type=="Control"){
		xsel=xobj.item(0);
		if(xsel.tagName=="IMG"){imageflag=true;}
	}
	if(imageflag==true){
		var z=xsel.outerHTML;
		z=z.toUpperCase();
		var z2=z.indexOf(" HEIGHT=");
		if(z2!=-1){imagespecifysize="yes";}
		if(xsel.height!=""&&xsel.height!=null){imageheight=xsel.height;}else{imageheight="";}
		if(xsel.width!=""&&xsel.width!=null){imagewidth=xsel.width;}else{imagewidth="";}
		if(xsel.border!=""&&xsel.border!=null){imagebordersize=xsel.border;}else{imagebordersize="";}
		if(xsel.align!=""&&xsel.align!=null){imagealignment=xsel.align;}else{imagealignment="";}
		if(xsel.hspace!=""&&xsel.hspace!=null){imagehspacing=xsel.hspace;}else{imagehspacing="";}
		if(xsel.vspace!=""&&xsel.vspace!=null){imagevspacing=xsel.vspace;}else{imagevspacing="";}imageiscancel="";window.showModalDialog("../latticeeditor/imageprops.htm",window,"dialogHeight: 360px; dialogWidth: 250px; help: no;scroll: no; status: no");
		if(imageiscancel=="no"){
			if(imagespecifysize=="yes"){
				if(imageheight!=""){xsel.height=imageheight;}else{xsel.removeAttribute("height",0);}
				if(imagewidth!=""){xsel.width=imagewidth;}else{xsel.removeAttribute("width",0);}
			}
			if(imagebordersize!=""){xsel.border=imagebordersize;}else{xsel.removeAttribute("border",0);}
			if(imagealignment!=""&&imagealignment!="Default"){xsel.align=imagealignment;}else{xsel.removeAttribute("align",0);}
			if(imagehspacing!=""){xsel.hspace=imagehspacing;}else{xsel.removeAttribute("hspace",0);}
			if(imagevspacing!=""){xsel.vspace=imagevspacing;}else{xsel.removeAttribute("vspace",0);}
		}
	}
}

function contextmenu(){return false;}

function loadbookmarks(){
	hyperlinkbookmarklist="";
	var bmancs2;
	var bmanccount2=0;
	var bmfirst=true;
	bmancs2=frames ['LatticeEditDocument'].document.all.tags("A");
	if(bmancs2.length>0){
		for(var i=0;i<=bmancs2.length-1;i++){
			if(bmancs2[i].name!=""){
				if(bmfirst==false){hyperlinkbookmarklist=hyperlinkbookmarklist+"|";}
				hyperlinkbookmarklist=hyperlinkbookmarklist+bmancs2[i].name;bmfirst=false;bmanccount2++;
			}
		}
	}
}

function setlink(){
	var xsel=document.frames("LatticeEditDocument").document.selection;
	var xobj=document.frames("LatticeEditDocument").document.selection.createRange();
	var objtype;
	var ancfound=false;
	var xseltype=xsel.type;
	var y=xseltype.toUpperCase();
	if(y=="NONE"||y=="TEXT"){
		objtype=xobj.parentElement();
		while(objtype.tagName!="BODY"){
			if(objtype.tagName=="A"){
				ancfound=true;
				xobj.moveToElementText(objtype);
				xobj.select();
				var anchref=objtype.href;
				var anctarget=objtype.target;
				var ancstyle=objtype.className;
				hyperlinkurl=anchref;
				hyperlinktarget=anctarget;
				hyperlinkclass=ancstyle;
				hyperlinkiscancel="";
				var gethere=""+parent.location.href;
				var subgethere=gethere.substring(0,(gethere.lastIndexOf("/")+1));
				if(hyperlinkurl!=""){
					var workingstring1a="";
					var workingstring2a="";
					var anchorre=new RegExp(gethere,"gi");
					workingstring1a=hyperlinkurl;
					workingstring2a=workingstring1a.replace(anchorre,"");
					var workingstring3a="";
					var anchorre2=new RegExp(subgethere,"gi");
					workingstring3a=workingstring2a.replace(anchorre2,"");
					hyperlinkurl=workingstring3a;
				}
				loadbookmarks();
				window.showModalDialog("../latticeeditor/hyperlink.htm",window,"dialogHeight: 260px; dialogWidth: 400px; help: no;scroll: no; status: no");
				if(hyperlinkiscancel!="yes"){
					if(hyperlinkurl==""&&hyperlinkbookmark==""){
						xobj.execCommand("Unlink");
					}else{
						if(hyperlinkbookmark==""){objtype.href=hyperlinkurl;}else{objtype.setAttribute("href",(hyperlinkurl+"#"+hyperlinkbookmark),0);}
					}
					if(hyperlinktarget!=""){objtype.target=hyperlinktarget;}else{objtype.removeAttribute("target",0);}
					if(hyperlinkclass!=""){objtype.className=hyperlinkclass;}else{objtype.removeAttribute("className",0);}
				}
				break;
			}
			objtype=objtype.parentElement;
		}
		if(ancfound==false&&y=="TEXT"){
			var tempbookmark="";
			var temphyperlink="";
			var temptarget="";
			var tempstyle="";
			hyperlinkurl="";
			hyperlinktarget="";
			hyperlinkclass="";
			hyperlinkiscancel="";
			loadbookmarks();
			window.showModalDialog("../latticeeditor/hyperlink.htm",window,"dialogHeight: 260px; dialogWidth: 400px; help: no;scroll: no; status: no");
			if(hyperlinkiscancel!="yes"){
				var newhtml="";
				if(hyperlinkurl==""&&hyperlinkbookmark==""){
					var wxy=123;
				}else{
					if(hyperlinkbookmark==""){temphyperlink=hyperlinkurl;}else{temphyperlink=hyperlinkurl+"#"+hyperlinkbookmark;}
					newhtml='<A HREF="'+temphyperlink+'"';
					if(hyperlinktarget!=""){newhtml+=' TARGET="'+hyperlinktarget+'"';}
					if(hyperlinkclass!=""){newhtml+=' CLASS="'+hyperlinkclass+'"';}
					newhtml+='>'+xobj.htmlText+'</A>';
					xobj.pasteHTML(newhtml);
				}
			}
		}
	}else if(y=="CONTROL"){
		objtype=xobj.item(0);
		if(objtype.tagName=="IMG"){
			while(objtype.tagName!="BODY"){
				if(objtype.tagName=="A"){
					ancfound=true;
					var anchref=objtype.href;
					var anctarget=objtype.target;
					var ancstyle=objtype.className;
					hyperlinkurl=anchref;
					hyperlinktarget=anctarget;
					hyperlinkclass=ancstyle;
					hyperlinkiscancel="";
					var gethere=""+parent.location.href;
					var subgethere=gethere.substring(0,(gethere.lastIndexOf("/")+1));
					if(hyperlinkurl!=""){
						var workingstring1a="";
						var workingstring2a="";
						var anchorre=new RegExp(gethere,"gi");
						workingstring1a=hyperlinkurl;
						workingstring2a=workingstring1a.replace(anchorre,"");
						var workingstring3a="";
						var anchorre2=new RegExp(subgethere,"gi");
						workingstring3a=workingstring2a.replace(anchorre2,"");
						hyperlinkurl=workingstring3a;
					}
					loadbookmarks();
					window.showModalDialog("../latticeeditor/hyperlink.htm",window,"dialogHeight: 260px; dialogWidth: 400px; help: no;scroll: no; status: no");
					if(hyperlinkiscancel!="yes"){
						if(hyperlinkurl==""&&hyperlinkbookmark==""){
							xobj.execCommand("Unlink");
						}else{
							if(hyperlinkbookmark==""){objtype.href=hyperlinkurl;}else{objtype.setAttribute("href",(hyperlinkurl+"#"+hyperlinkbookmark),0);}
						}
						if(hyperlinktarget!=""){objtype.target=hyperlinktarget;}else{objtype.removeAttribute("target",0);}
						if(hyperlinkclass!=""){objtype.className=hyperlinkclass;}else{objtype.removeAttribute("className",0);}
					}
					break;
				}
				objtype=objtype.parentElement;
			}
			if(ancfound==false&&y=="CONTROL"){
				var tempbookmark="";
				var temphyperlink="";
				var temptarget="";
				var tempstyle="";
				hyperlinkurl="";
				hyperlinktarget="";
				hyperlinkclass="";
				hyperlinkiscancel="";
				loadbookmarks();
				window.showModalDialog("../latticeeditor/hyperlink.htm",window,"dialogHeight: 260px; dialogWidth: 400px; help: no;scroll: no; status: no");
				if(hyperlinkiscancel!="yes"){
					var newhtml="";
					if(hyperlinkurl==""&&hyperlinkbookmark==""){
						var wxy=123;
					}else{
						if(hyperlinkbookmark==""){temphyperlink=hyperlinkurl;}else{temphyperlink=hyperlinkurl+"#"+hyperlinkbookmark;}
						newhtml='<A HREF="'+temphyperlink+'"';
						if(hyperlinktarget!=""){newhtml+=' TARGET="'+hyperlinktarget+'"';}
						if(hyperlinkclass!=""){newhtml+=' CLASS="'+hyperlinkclass+'"';}
						newhtml+='>'+xobj.item(0).outerHTML+'</A>';
						xobj.item(0).outerHTML=newhtml;
					}
				}
			}
		}
	}
}

function insertbookmark(){
	var xsel=document.frames("LatticeEditDocument").document.selection;
	var xobj=document.frames("LatticeEditDocument").document.selection.createRange();
	var objtype;var ancfound=false;
	var xseltype=xsel.type;
	var y=xseltype.toUpperCase();
	if(y=="NONE"){
		loadbookmarks();
		insertbookmarkiscancel="";
		window.showModalDialog("../latticeeditor/insertbookmark.htm",window,"dialogHeight: 250px; dialogWidth: 300px; help: no;scroll: no; status: no");
		if(insertbookmarkiscancel=="no"&&bookmarktoinsert!=""){
			var x='<A NAME="'+bookmarktoinsert+'"></A>';
			xobj.pasteHTML(x);
		}
	}else if(y=="TEXT"){
		xobj.collapse();
		loadbookmarks();
		insertbookmarkiscancel="";
		window.showModalDialog("../latticeeditor/insertbookmark.htm",window,"dialogHeight: 250px; dialogWidth: 300px; help: no;scroll: no; status: no");
		if(insertbookmarkiscancel=="no"&&bookmarktoinsert!=""){
			var x='<A NAME="'+bookmarktoinsert+'"></A>';
			xobj.pasteHTML(x);
		}
	}else{
		loadbookmarks();
		insertbookmarkiscancel="";
		window.showModalDialog("../latticeeditor/insertbookmark.htm",window,"dialogHeight: 250px; dialogWidth: 300px; help: no;scroll: no; status: no");
		if(insertbookmarkiscancel=="no"&&bookmarktoinsert!=""){
			var x='<A NAME="'+bookmarktoinsert+'"></A>';
			var y=x+xobj.item(0).outerHTML;
			xobj.item(0).outerHTML=y;
		}
	}
}

function deleterow(rowname){
	var x=document.getElementById("toolbar").rows;
	var y;
	for(z=0;z<=x.length-1;z++){
		y=document.getElementById("toolbar").rows(z).id;
		if(y==rowname){document.getElementById("toolbar").deleteRow(z);}
	}
}

function deletecell(cellname){document.getElementById(cellname).innerHTML="";}

function teststyle(){
	alert(document.frames("LatticeEditDocument").document.readyState);
	document.frames("LatticeEditDocument").document.designMode="on";
	alert(document.frames("LatticeEditDocument").document.readyState);
	document.frames("LatticeEditDocument").document.createStyleSheet(StyleSheetURL);
}

function teststyle2(){var x=document.frames("LatticeEditDocument").document.styleSheets;alert(x.length);}

function teststyle3(){deleterow("toolrow3");deleterow("toolrow3a");}

function teststyle4(){deleterow("toolrow4");}

function hidebuttons(){
	if(ButtonHide!=""){
		if(ButtonHide.indexOf("|")==-1){ButtonHide=ButtonHide+"|junk";}
		var ButtonHide2=ButtonHide.toLowerCase();
		var x=ButtonHide2.split("|");
		var xlength=x.length;
		for(z=0;z<=xlength-1;z++){
			if(x[z]=="save"){
				deletecell("cell_btn_save");
			}else if(x[z]=="cut"){
				deletecell("cell_btn_cut");
			}else if(x[z]=="copy"){
				deletecell("cell_btn_copy");
			}else if(x[z]=="paste"){
				deletecell("cell_btn_paste");
			}else if(x[z]=="find"){
				deletecell("cell_btn_find");
			}else if(x[z]=="undo"){
				deletecell("cell_btn_undo");
			}else if(x[z]=="redo"){
				deletecell("cell_btn_redo");
			}else if(x[z]=="table"){
				deletecell("cell_btn_table");
			}else if(x[z]=="image"){
				deletecell("cell_btn_image");
			}else if(x[z]=="link"){
				deletecell("cell_btn_hyperlink");
			}else if(x[z]=="unlink"){
				deletecell("cell_btn_unlink");
			}else if(x[z]=="hr"){
				deletecell("cell_btn_hr");
			}else if(x[z]=="html"){
				deletecell("cell_btn_html");
			}else if(x[z]=="special"){
				deletecell("cell_btn_special");
			}else if(x[z]=="help"){
				deletecell("cell_btn_help");
			}else if(x[z]=="about"){
				deletecell("cell_btn_about");
			}else if(x[z]=="fontname"){
				deletecell("cell_FontNameSelect");
			}else if(x[z]=="fontsize"){
				deletecell("cell_FontSizeSelect");
			}else if(x[z]=="bold"){
				deletecell("cell_btn_bold");
			}else if(x[z]=="italic"){
				deletecell("cell_btn_italics");
			}else if(x[z]=="underline"){
				deletecell("cell_btn_underline");
			}else if(x[z]=="fontcolor"){
				deletecell("cell_btn_fontcolor");
			}else if(x[z]=="fonthighlight"){
				deletecell("cell_btn_fonthilight");
				deletecell("space_btn_fonthilight");
			}else if(x[z]=="left"){
				deletecell("cell_btn_left");
			}else if(x[z]=="center"){
				deletecell("cell_btn_center");
			}else if(x[z]=="right"){
				deletecell("cell_btn_right");
			}else if(x[z]=="format"){
				deletecell("cell_FormatSelect");
			}else if(x[z]=="numlist"){
				deletecell("cell_btn_numlist");
			}else if(x[z]=="bltlist"){
				deletecell("cell_btn_bltlist");
			}else if(x[z]=="outdent"){
				deletecell("cell_btn_outdent");
			}else if(x[z]=="indent"){
				deletecell("cell_btn_indent");
			}
		}
	}
}

function hiderows(){
	if(RowHide!=""){
		if(RowHide.indexOf("|")==-1){RowHide=RowHide+"|junk";}
		var RowHide2=RowHide.toLowerCase();
		var x=RowHide2.split("|");
		var xlength=x.length;
		for(zrow=0;zrow<=xlength-1;zrow++){
			if(x[zrow]=="1"){deleterow("toolrow2");
				deleterow("toolrow2a");
			}else if(x[zrow]=="2"){
				deleterow("toolrow3");
				deleterow("toolrow3a");
			}else if(x[zrow]=="3"){
				deleterow("toolrow4");
			}
		}
	}
}

LL=0;
function LatticeMax(qxw){
if (qxw==0){
		if (LL==0){
		L0.className="max";
		LL=1;
		 }else{
		L0.className="max1";
		LL=0;
	 	}
	}else{
		L0.className="max1";
		LL=0;
	}
}
