
//
//----------
// Globals
//----------
//
var ImagePropertyEditorObject;
var DialogObject;
var ACPropertyEditorObject;
var ACPropertyObject;
var TableCellPropertyObject;
var TableRowPropertyObject;
var TablePropertyObject;
var TableBodyPropertyObject;
var tableDialogEditor;
var currentRow;
var currentCol;
var rtNumRows;
var rtNumCols;
var rtTblAlign;
var rtTblWidth;
var outOfContext;
//
// FlyoutMenu Globals ---------------------
//
var activeButton = null;
var selectsHidden = false;
var menuClicks = 0;
var width;
var height;
var flag = 0;
var updated = 0;
var clickButton;
var lastClipCheck = false;
var lastSelCheck = false;
var currentPanel;
//
var ButtonObjectCount = 0;
var MenuObjectCount = 0;
var MenuHideBlock = false;
var isNS = (navigator.appName == "Netscape");
var isMacIE = ( (navigator.userAgent.indexOf("IE 4") > -1) && (navigator.userAgent.indexOf("Mac") > -1) );
var spellCheckList = "";
var browser = new BrowserType();
var RLMediaType = '';
//
//----------
//
function DeleteCheck() {
    var strConfirm = "Are you sure you would like to delete this item?\n\n";
    if (confirm( strConfirm ) == 1) {
        event.returnValue = true;
    } else {
        event.returnValue = false;
    }
}
//
//----------
//
function SetFieldName( FieldName ) { document.all[ 'fn' ].value = FieldName; return true; }
//
//----------
//
function BodyOnClick() {
	var el;
	if (browser.isIE) {
		el = event.srcElement;
	}
	else {
		el = event.currentTarget;
	}

	hideselect(false);

	if (el.id != "ccSpell.UnknownWord") {
		if (spellCheckList) {
			if (spellCheckList != "") {
				if (getContainerWith(el, "DIV", "ccMisspellChoice") == null) {
					removeSpellCheckDivs();
				}
			}
		}
	}

}
//
// ----- hide select menus
//
function hideselect(hiddenIn) {						
	var i, j;
	var index;
	var selects;

	if (hiddenIn) {
		menuClicks++;
	}

	if (!hiddenIn && menuClicks == 0 && !selectsHidden) {
		return;
	}

	var selects = document.getElementsByTagName("SELECT");
	if (selectsHidden && menuClicks == 0) {
		for (i = 0; i < selects.length; i++) {
			selects[i].style.visibility = "visible";
		}
	}
	else {
		for (i = 0; i < selects.length; i++) {
			selects[i].style.visibility = "hidden";
		}
	}

	if (selectsHidden && menuClicks == 0) {
		selectsHidden = false;
	}
	else if (selectsHidden && menuClicks != 0 && clickButton != 2) {
		menuClicks--;
	}
	else {
		selectsHidden = true;
	}
}
//
// ----- Browser Detect
//
function BrowserType() {
	var ua, s, i;
	this.isIE    = false;  // Internet Explorer
	this.isNS    = false;  // Netscape
	//this.version = null;
	this.isMac = false;
	ua = navigator.userAgent;
	s = "MSIE";

	this.version = 0.0;
	if (navigator.appVersion.indexOf("Mac")!=-1) {
		this.isMac = true;
		}
	if ((i = ua.indexOf(s)) >= 0) {
		this.isIE = true;
		this.version = parseFloat(ua.substr(i + s.length));
		return;
		}
	s = "Netscape6/";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = parseFloat(ua.substr(i + s.length));
		return;
		}
	s = "Gecko";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = 6.1;
		return;
		}
	}
//
// ----- Code for handling the menu bar and active button.
//
function PageClick(event) {
	
	var el;

	if (activeButton == null) return;
	if (browser.isIE)
		el = window.event.srcElement;
	else
		el = (event.target.tagName ? event.target : event.target.parentNode);

	if (el == activeButton)
		return;
	if (getContainerWith(el, "DIV", "kmaMenu") == null) {
		resetButton(activeButton);
		activeButton = null;
	}
}
//
// ----- Hide/Remove Spell Check Menus
//
function removeSpellCheckDivs() {
	var SpellerPanelDiv = document.getElementById( 'SpellerPanelDiv' );
	if ( SpellerPanelDiv ) SpellerPanelDiv.removeNode(true);
	spellCheckList = "";
}
//
// ----- Clear the menu
//
function ClearMenu() {
	if (activeButton == null) return;
	resetButton(activeButton);
	activeButton = null;
	}
//
// -----
//
function ccFlyoutHoverMode(val) {
	flag = val;
	if (val == 0) {
		setTimeout(timerEvent, 1000);
	}
	if (val == 1) {
		updated = 1;
	}
	return;
}
//
// -----
//
function timerEvent() {

	if (flag == 0) {
		resetFlag = 1;
		resetButton(activeButton);
		menuClicks = 0;
		hideselect(0);
		updated = 1;
	}

}
//
// -----
//
function setAnchorTagsToColor(classToFind, colorToSet) {
	var i;
	var aTags = document.getElementsByTagName("A");

	for(i = 0; i < aTags.length; i++) {
		if (hasClassName(aTags[i], classToFind)) {
			aTags[i].style.color = colorToSet;
		}
	}
}
//
// -----
//
function ccFlyoutButtonClick(event, menuId, position, StyleSheetPrefix, OpenOnHover) {
	var button;
	var x, y;
	var offY;
	//
	if ((!(clickButton == 2 && outOfContext)) && browser.isIE) {
		hideselect(true);
	}
	if (browser.isIE) {
		offY = event.offsetY;
		button = event.srcElement;
	} else {
		button = event.currentTarget;
	}
	if(button.tagName!='A') {
		button = getContainer( button, 'A' )
		if (button == null) return false;
	}
	if (menuId == '') return false;
	width=document.body.scrollWidth;
	height=document.body.scrollHeight;
	button.blur();
	if (button.menu == null) {
		button.menu = document.getElementById(menuId);
		if (button.menu.title == "")
			menuInit(button.menu);
	}
	if (activeButton != null)
		resetButton(activeButton);
	if (button != activeButton || updated == 1) {
		updated = 0;
		// Update the button's style so it looks down
		if (clickButton != 2) {
			button.className += " kmaMenuDown "+StyleSheetPrefix+"ButtonDown";
		}
		//button.className += " ccFlyoutButtonDown";
		// put menu under button
		if (position==1) {
			// Flyout to the right
			x = getPageOffsetLeft(button) + button.offsetWidth;
			y = getPageOffsetTop(button);
		} else if (position==2) {
			// Flyout up
			x = getPageOffsetLeft(button);
			y = getPageOffsetTop(button) - button.menu.offsetHeight;
		} else if (position==3) {
			// Flyout to the left
			x = getPageOffsetLeft(button) - button.menu.offsetWidth;
			y = getPageOffsetTop(button);
		} else {
			// Flyout down
			x = getPageOffsetLeft(button);
			y = getPageOffsetTop(button) + button.offsetHeight;

		}

		if (clickButton == 2) {
			x = event.clientX;
			y = event.clientY;
			if (document.body) {
				x += document.body.scrollLeft;
				y += document.body.scrollTop;
			}
		}

		if ((x + button.menu.scrollWidth) > width) {
			x = width - button.menu.scrollWidth;
		}

		button.menu.style.left = x + "px";
		button.menu.style.top  = y + "px";
		// turn it on
		button.menu.style.visibility = "visible";
		activeButton = button;
	}
	else {
		if (!OpenOnHover) {
			activeButton = null;
			}
	}
	clickButton=1;
	return false;
}
//
// -----
//
function ccFlyoutButtonHover(event, menuId, position) {
	var button;
	if (browser.isIE)
		button = window.event.srcElement;
	else
		button = event.currentTarget;
	if (activeButton != null && activeButton != button)
		ccFlyoutButtonClick(event, menuId, position);
	}
//
// -----
//
function resetButton(button) {
	if (button) {
	removeClassNameAfter(button, "kmaMenuDown");
	if (button.menu != null) {
		closeSubMenu(button.menu);
		button.menu.style.visibility = "hidden";
		}
	}
}
//
// -----
//
function activateButton(button) {
	if (button.menu != null) {
		button.menu.style.visibility = "visible";
	}
}
//
// -----
//
function ccFlyoutPanelHover(event, StyleSheetPrefix) {
	var menu;
	if (browser.isIE)
		menu = getContainerWith(window.event.srcElement, "DIV", StyleSheetPrefix+"Panel");
		//menu = getContainerWith(window.event.srcElement, "DIV", "ccFlyoutPanel");
	else
		menu = event.currentTarget;
	if (menu.title != "") {
		if (menu.activeItem == null) {
			// do nothing
		} else {
			closeSubMenu(menu);
			}
		}
	}
//
// -----
//
function ccFlyoutPanelButtonHover(event, menuId, StyleSheetPrefix) {
	var item, menu, x, y;
	var maxX, maxY;
	if (browser.isIE)
		item = getContainerWith(window.event.srcElement, "A", StyleSheetPrefix+"PanelButton");
		//item = getContainerWith(window.event.srcElement, "A", "ccFlyoutPanelButton");
	else
		item = event.currentTarget;
	menu = getContainerWith(item, "DIV", StyleSheetPrefix+"Panel");
	if (menu.activeItem == null) {
		// nothing
	} else {
		closeSubMenu(menu);
		}
	menu.activeItem = item;
	item.className += " kmaMenuDown "+StyleSheetPrefix+"PanelButtonDown";
	if (item.subMenu == null) {
		item.subMenu = document.getElementById(menuId);
		if (item.subMenu.title == "")
		//if (item.subMenu.isInitialized == null)
			menuInit(item.subMenu);
		}
	x = getPageOffsetLeft(item) + item.offsetWidth;
	y = getPageOffsetTop(item);
	if (browser.isNS) {
		maxX = window.scrollX + window.innerWidth;
		maxY = window.scrollY + window.innerHeight;
		}
	if (browser.isIE) {
		maxX = (document.documentElement.scrollLeft != 0 ? document.documentElement.scrollLeft   : document.body.scrollLeft)
			+ (document.documentElement.clientWidth  != 0 ? document.documentElement.clientWidth  : document.body.clientWidth);
		maxY = (document.documentElement.scrollTop    != 0 ? document.documentElement.scrollTop    : document.body.scrollTop)
			+ (document.documentElement.clientHeight != 0 ? document.documentElement.clientHeight : document.body.clientHeight);
		}
	maxX -= item.subMenu.offsetWidth;
	maxY -= item.subMenu.offsetHeight;
	if (x > maxX) 
		x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth + (menu.offsetWidth - item.offsetWidth));
	y = Math.max(0, Math.min(y, maxY));
	item.subMenu.style.left = x + "px";
	if (browser.isMac) {
		if (browser.version>5.1) {
			item.subMenu.style.top  = y + "px";
			}
	} else {
		item.subMenu.style.top  = y + "px";
		}
	item.subMenu.style.visibility = "visible";
	if (browser.isIE)
		window.event.cancelBubble = true;
	else
		event.stopPropagation();
	}
//
// -----
//
function closeSubMenu(menu) {
	if (!menu)
		return;
	if (menu.activeItem == null)
		return;
	if (menu.activeItem.subMenu) {
		closeSubMenu(menu.activeItem.subMenu);
		menu.activeItem.subMenu.style.visibility = "hidden";
		menu.activeItem.subMenu = null;
		}
	removeClassNameAfter(menu.activeItem, "kmaMenuDown");
	//removeClassName(menu.activeItem, "ccFlyoutPanelButtonDown");
	menu.activeItem = null;
	}
//
// -----
//
function menuInit(menu) {
	var itemList, spanList;
	var textEl, arrowEl;
	var itemWidth;
	var w, dw;
	var i, j;
	itemList = menu.getElementsByTagName("A");
	if (itemList.length == 0) {
		menu.title = 'Select One';
		menu.activeItem = null
		return false;
	}
	if (browser.isIE) {
		w = itemList[0].offsetWidth;
		itemList[0].style.width = w + "px";
		dw = itemList[0].offsetWidth - w;
		w -= dw;
		itemList[0].style.width = w + "px";
		}
	menu.title = 'Select One';
	menu.activeItem = null
	}
//
// -----
//
function getContainerWith(node, tagName, className) {
	while (node != null) {
		if (node.tagName != null && node.tagName == tagName &&
				hasClassName(node, className))
			return node;
		node = node.parentNode;
		}
	return node;
	}
//
// -----
//
function getContainer(node, tagName) {
	while (node != null) {
		if (node.tagName != null && node.tagName == tagName )
			return node;
		node = node.parentNode;
		}
	return node;
	}
//
// -----
//
function hasClassName(el, name) {
	var i, list;
	list = el.className.split(" ");
	for (i = 0; i < list.length; i++)
		if (list[i] == name) return true;
	return false;
	}
//
// -----
//
function removeClassName(el, name) {
	var i, curList, newList;
	if (el.className == null) return;
	//newList = new Array();
	curList = el.className.split(" ");
	for (i = 0; i < curList.length; i++)
		if (curList[i] != name) {
			newList=newList+' '+curList[i];
		} else {
			//newList=newList+' '+curList[i];
			el.className = newList;
			return;
			}
	}
//
// -----
//
function removeClassNameAfter(el, name) {
	var i, curList, newList;
	if (el.className == null) return;
	curList = el.className.split(" ");
	newList = '';
	for (i = 0; i < curList.length; i++)
		if (curList[i] != name) {
			newList=newList+' '+curList[i];
		} else {
			// newList=newList+' '+curList[i];
			el.className = newList;
			return;
		}
	}
//
//----------
//
function getPageOffsetLeft(el) {
	var x, p;
	p = el.offsetParent;
	x = el.offsetLeft;
	while (p !=null){
		x+=p.offsetLeft;
		p=p.offsetParent;
		}
	return x;
	}
//
//----------
//
function getPageOffsetTop(el) {
	var y, p;
	p = el.offsetParent;
	y = el.offsetTop;
	//msg = ''+y;
	while (p !=null){
		y+=p.offsetTop;
		p=p.offsetParent;
		}
	return y;
	}
//
//----------
//
function updateClipboardLinks() {
	if (!browser.isIE) {
		return;
	}
	var SelectedObject;
	var TextRange;
	setAnchorTagsToColor("ccPaste", "#000000");
	lastClipCheck=true;
	SelectedObject = document.selection;
	TextRange = SelectedObject.createRange();
	if (TextRange.text) {
		if (TextRange.text.length != 0) {
			if (!lastSelCheck) {
				setAnchorTagsToColor("ccSelect", "#000000");
				lastSelCheck=true;
			}
		}
		else {
			if (lastSelCheck) {
				setAnchorTagsToColor("ccSelect", "#FFFFFF");
				lastSelCheck=false;
			}
		}
	}

}
//
//----------
//
function updateClipboardLinksInit() {

	if (!browser.isIE) {
		return;
	}

	setAnchorTagsToColor("ccPaste", "#000000");
	lastClipCheck=true;
	setAnchorTagsToColor("ccSelect", "#FFFFFF");
}
//
//----------
//
function SaveFieldPlus( ObjectName ) {
	var RefreshTemp;
	RefreshTemp = document.all.tags('div')[ObjectName].innerHTML;
	document.all[ObjectName+'Field'].value = RefreshTemp;
	}
//
//----------
//
function OpenImagePropertyWindow( EditorObject, ImageObject ) { 
     DialogObject = ImageObject; 
     showModalDialog("/cclib/Popup/ActiveEditorImageProperties.htm",window,"status:false;dialogWidth:32em;dialogHeight:25em");
     //window.open ('/cclib/Popup/ActiveEditorImageProperties.htm', 'ImageProperties','menubar=no,toolbar=no,location=no,status=no,width=550,height=325,scrollbars=no,resizable,directories=no')
     } 
//
//----------
//
function OpenACPropertyWindow( EditorObject, ACObject ) { 
     ACPropertyObject = ACObject; 
     showModalDialog("/cclib/Popup/ActiveEditorACProperties.htm",window,"status:false;dialogWidth:18em;dialogHeight:14em");
     }
//
//----------
//
function OpenTablePropertyWindow( EditorObject, TableObject, TableBodyObject ) { 
	TablePropertyObject = TableObject;
	TableBodyPropertyObject = TableBodyObject;
	ClearMenu();
	var h = new Object();
	h.win = window;
	h.fieldName = EditorObject;
	showModalDialog("/cclib/Popup/tablepop.htm",h,"status:false;dialogWidth:315px;dialogHeight:380px;");
     }
//
//----------
//
function OpenAFPropertyWindow( ACObject ) {
    OpenAFTest( ACObject );
}
//
//----------
//
var AFinnerHTML;
document.write( '<div style="position:absolute;visibility:hidden;" ID="AFworkspace"></div>' );
//
//----------
//
function OpenAFTest( ACObject ) {
    var obj = document.getElementById("AFworkspace");
    var RawString,QueryString,SplitString;
	var PairPointer;
	var PairSplit;
	var Spacer;
	var NameVar;
	var ValueVar;
	var NVPair;
	var s;
	var RowPtr
	var OptionStart
	var OptionEnd
	var FormInput
	var Options
	var OptionSplit
	var OptionPtr
	var CurrentValue
	var OptionValue
    ACPropertyObject = ACObject;
    RawString = new String( ACObject.id );
    SplitString = RawString.split(",")
    QueryString = SplitString[4];
	Spacer='<img src=/ccLib/Images/Spacer.gif width=1 height=20>'
	s='';
	//s+='<TABLE border=0 cellpadding=0 cellspacing=0 width=155 class=ccPanel align=center>';
	//s+='<TR><TD colspan=3 class=ccPanelhilite><IMG src=/ccLib/Images/spacer.gif height=1 width=100% /></TD></TR>';
	//s+='<TR>';
	//s+='<TD width=1 height=1 class=ccPanelhilite><IMG src=/ccLib/Images/spacer.gif height=1 width=1 /></TD>';
	//s+='<TD width=100% valign=top align=left>';
	s+='<TABLE border=0 cellpadding=0 cellspacing=0 class=ccPanel width=155 align=center><TR><TD valign=top>';
	s+='<TABLE border=0 cellpadding=2 cellspacing=1 width=100% class=ccPanel><tr>';
	s+='<td width=5><img src=/ccLib/Images/spacer.gif width=5 height=1></td>';
	s+='<td width=50><img src=/ccLib/Images/spacer.gif width=50 height=1></td>';
	s+='<td width=150><img src=/ccLib/Images/spacer.gif width=150 height=1></td>';
	s+='</tr><tr>';
	s+='<td COLSPAN=3><b>'+SplitString[3]+' Properties</b>'+Spacer+'<BR>'+Spacer+'</td></tr>'
	PairPointer=0
	NVPair = QueryString.split( '&' );
	RowPtr=0;
	while (NVPair[PairPointer]){
		PairSplit = NVPair[PairPointer].split('=');
		if (PairSplit[0]) {
			NameVar = PairSplit[0];
			ValueVar = '';
			Options='';
			if (PairSplit[1]){
				PairSplit[0]='';
				ValueVar = PairSplit.join('=');
				ValueVar=ValueVar.substr(1);
			}
			FormInput = '<INPUT Name="'+NameVar+'" Type=Text ID="NV'+PairPointer+'" Value="'+ValueVar+'" Size=20>';
			OptionStart=ValueVar.indexOf('[');
			OptionEnd=ValueVar.indexOf(']');
			if ((OptionStart!=-1)&&(OptionEnd!=-1)) {
				CurrentValue='';
				if (OptionStart>0) {
					CurrentValue=ValueVar.slice(0,OptionStart);
				}
				Options = ValueVar.slice(OptionStart+1,OptionEnd);
				if (Options.indexOf('|')) {
					OptionSplit=Options.split('|');
					OptionPtr=0;
					FormInput='';
					while (OptionSplit[OptionPtr]) {
						OptionValue=OptionSplit[OptionPtr]
						if (CurrentValue==OptionValue) {
							FormInput+='<option value='+OptionValue+' selected>'+OptionValue+'</option>';
						} else {
							FormInput+='<option value='+OptionValue+'>'+OptionValue+'</option>';
						}
						OptionPtr++;
					}
					FormInput='<select name="'+NameVar+'" size=1 ID="NV'+PairPointer+'">'+FormInput+'</select>';
				}
				FormInput+='<INPUT Name="NVO'+PairPointer+'" Type=Hidden ID="NVO'+PairPointer+'" Value="'+Options+'">';
			}
			s+='<tr>';
			s+='<td>'+Spacer+'</td>';
			s+='<td class=ccPanelNormal align=left>'+NameVar+':</td>';
			s+='<td align=left class=ccPanelInput>'+FormInput+'</td>';
			s+='</tr>';
			RowPtr++
		}
		PairPointer++
	}
	if (RowPtr==0) {
		s+='<tr>';
		s+='<td>'+Spacer+'</td>';
		s+='<td class=ccPanelNormal align=left colspan=2>This object has no properties.</td>';
		s+='</tr>';
	}
	s+='<tr><td colspan=3>'+Spacer+'</td></tr>'
	s+='</TABLE>';
	s+='<TABLE border=0 cellpadding=0 cellspacing=0 width=100% class=ccPanelButtons>';
	s+='<TR>';
	s+='<TD colspan=3 class=ccPanelShadow><IMG src=/ccLib/Images/spacer.gif height=1 width=1/></TD>';
	s+='</TR><TR>';
	s+='<TD width=1 height=1 class=ccPanelShadow><IMG src=/ccLib/Images/spacer.gif height=1 width=1 /></TD>';
	s+='<TD width=100% valign=top align=left>';
	s+='<TABLE border=0 cellpadding=5 cellspacing=0 width=100% class=ccPanelButtons><TR><TD valign=top>';
	if (RowPtr!=0) {
		s+='<INPUT Type=Button Value="  OK  " onClick="SaveForm(); window.close();">';
		s+='<INPUT Type=Button Value="  Apply  " onClick="SaveForm();">';
	}
	s+='<INPUT Type=Button Value="  Cancel  " onClick="window.close();">';
	s+='</TD></TR></TABLE>';
	s+='</TD>';
	s+='<TD width=1 class=ccPanelHilite><IMG src=/ccLib/Images/spacer.gif height=1 width=1 /></TD>';
	s+='</TR><TR>';
	s+='<TD colspan=3 class=ccPanelHilite><IMG src=/ccLib/Images/spacer.gif height=1 width=100% /></TD>';
	s+='</TR></TABLE>';
	//s+='</TD></TR></TABLE>';
	AFinnerHTML = s;
	obj.innerHTML = AFinnerHTML;
	Dialog = showModalDialog('/cclib/Popup/AFTest.htm',window,'scroll:no;status:false;help:no;dialogWidth:'+(obj.scrollWidth+10)+'px;dialogHeight:'+(50+obj.scrollHeight)+'px');
}
//
//----------
//
function InsertTag(OpenTag,CloseTag) {
	var SelectionObject; 
	var SelectionObjectType; 
	var ControlRangeCollection; 
	var ParentElementObject; 
	var Pointer; 
	var ControlRange; 
	//
	SelectionObject = document.selection; 
	SelectionObjectType = SelectionObject.type; 
	if (SelectionObjectType=="Control") { 
		ControlRangeCollection = SelectionObject.createRange(); 
		for (Pointer = 0; Pointer < ControlRangeCollection.length; Pointer++) {             
			ControlRange = ControlRangeCollection(Pointer); 
			ControlRange.outerHTML = OpenTag+ControlRange.outerHTML+CloseTag;
		} 
	} else {
		var TextRange = SelectionObject.createRange();
		var text = TextRange.text;
		if (text) {
			TextRange.pasteHTML( OpenTag+text+CloseTag );
		} else {
			TextRange.pasteHTML( OpenTag+CloseTag );
		}
	ClearMenu();
	}
}
//
//----------
//
function PrintElement( ElementIdentifier ) {
	var ElementObject=document.all( ElementIdentifier );
	var tr=ElementObject.createTextRange();
	var msgWind = window.open('', '_blank', 'scrollbars=yes,toolbar=no,status=no,resizable=yes');
	msgWind.document.body.innerHTML=tr.text;
	msgWind.print();
	msgWind.close();
	}
//
//----------
//
function RemoveStyle( ElementIdentifier ) {
	var ElementObject;
	var SelectedObject;
	var TextRange;
	ElementObject=document.all( ElementIdentifier );
	ElementObject.focus;
	SelectedObject = document.selection;
	TextRange = SelectedObject.createRange();
	TextRange.pasteHTML( TextRange.text );
	ClearMenu();
	}

//
//----------
//
function ExecCmdPlus(cmd,ui,opt,ObjectName) {
	var CommandPassed, editor;
	editor = document.all[ObjectName]
	if (!editor.document.queryCommandSupported(cmd)) {
		alert('This function is not supported. Your browser may not support this command, or you may need to make a text selection before using this function.')
	}else{
		document.body.all.tags('div')[ObjectName].focus();
		CommandPassed = editor.document.execCommand(cmd,ui,opt);
		if (CommandPassed) {
			// removed to allow formating undo -- onblur covers the save case
			//SaveFieldPlus(ObjectName);
			document.body.all.tags('div')[ObjectName].focus();
		} else {
			alert('This function failed. Your browser may not support this command, or you may need to make a text selection before using this function.')
                }
            }
	ClearMenu();
	}
//
//----------
//
function OpenResourceLibrary( EditorObjectName ) {
        window.open ('?ccIPage=s033l8dm15&EditorObjectName='+EditorObjectName, 'ImageSelector','menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable')    
	}
//
//----------
//
function InsertImage( Name, Src, Alt, Width, Height, ObjectName ) {
	var tag
	tag = '<IMG SRC="'+Src+'"'
	tag += 'name="'+Name+'" ID="'+Name+'"'
	if (Width != 0) tag+=' WIDTH="'+Width+'"'
	if (Height != 0) tag+=' HEIGHT="'+Height+'"'
	tag+='>'
	oUtil.obj.insertHTML( tag );
}
//
//----------
//
function InsertDownload( RecordID, ObjectName ) {
	var tag;
	tag = '<a href="?downloadid='+RecordID+'" target="_blank"><img src="/cclib/images/IconDownload.gif" border=0 width=16 height=16 alt="Download" ></a>';
	oUtil.obj.insertHTML( tag );

}
//
//----------
//
function InsertActiveContentPlus(ACType,ACSubType,ACArg1, ObjectName  ) {
	var SelectionObject; 
	var SelectionObjectType; 
	var ControlRangeObject; 
	var ParentElementObject; 
	var Pointer; 
	var ImageObject; 
	ExecCmdPlus('InsertImage',false,'/cclib/images/AC'+ACType+ACSubType+'.gif', ObjectName );
	SelectionObject = document.selection; 
	SelectionObjectType = SelectionObject.type; 
	if (SelectionObjectType!="Control"){ 
		// 
	}else{
		ControlRangeObject = SelectionObject.createRange(); 
		for (Pointer = 0; Pointer < ControlRangeObject.length; Pointer++) {
			ImageObject = ControlRangeObject(Pointer); 
			if (ImageObject.tagName == "IMG") {
				ImageObject.id = 'AC,'+ACType+','+ACSubType+','+ACArg1; 
			} else { 
				// Non-Image found in Control Object
				} 
			} 
		}
	ClearMenu();
	}
//
//----------
//
function InsertActiveChildList(ACType, ObjectName  ) {
	var RandomNumber;
	RandomNumber = Math.floor( Math.random()*1000000 );
	InsertActiveContentPlus( ACType, '', RandomNumber, ObjectName );
	}
//
//----------
//
function OpenPropertiesWindowPlus( ObjectName ) { 
	var EditorObject; 
	var SelectionObject; 
	var TextRangeObject; 
	var ControlRangeObject; 
	var Message; 
	var ElementObject; 
	var Pointer;
	var t; 
	// Locate the object being clicked 
	SelectionObject = document.selection;

	if (SelectionObject.type=="Text"){ 
		// Text Object Found
	} else if (SelectionObject.type=="Control") { 
		ControlRangeObject = SelectionObject.createRange(); 
		for (Pointer = 0; Pointer < ControlRangeObject.length; Pointer++) {
			ElementObject = ControlRangeObject(Pointer); 
			if (ElementObject.tagName == "IMG") {
				if (ElementObject.id.substring( 0, 3 ) == "AC,") {
					if (ElementObject.id.substring( 0, 8 ) == "AC,IMAGE"){ 
						OpenImagePropertyWindow( document.all[ObjectName],ElementObject );
					} else if (ElementObject.id.substring( 0, 20 ) == "AC,AGGREGATEFUNCTION"){
						OpenAggregateFunctionPropertyWindow( document.all[ObjectName],ElementObject );
					} else {
						OpenACPropertyWindow( document.all[ObjectName],ElementObject );
					} 
				} else {
					OpenImagePropertyWindow( document.all[ObjectName],ElementObject );
				}
			} 
			else if (ElementObject.tagName == "TABLE") {
				var tBody = ElementObject.getElementsByTagName("TBODY");
				OpenTablePropertyWindow(ObjectName,ElementObject, tBody[0]);
			}
			else {
				// Non-Image found in Control Object
			} 
		} 
	} else { 
		// SelectObject is not Control or Text
	} 
} 
//
//----------
//
function tableDialog( ObjectName ){
   ClearMenu();
   var rtNumRows = null;
   var rtNumCols = null;
   var rtTblAlign = null;
   var rtTblWidth = null;
   tableDialogEditor = ObjectName;
   showModalDialog("/ccLib/popup/tablepop.htm",window,"status:false;dialogWidth:275px;");
}
//
//----------
//
function tdDialog(tabIndex, fieldName){
	ClearMenu();
	var h = new Object();
	h.win = window;
	h.tab = tabIndex;
	h.fieldName = fieldName;
	showModalDialog("/ccLib/popup/tdpopup.htm",h,"scroll:off;status:false;dialogWidth:274px;dialogHeight:400px;");
}
//
//----------
//
function createTable( ){
   var HTMLEditor=document.all[tableDialogEditor]
   var CellWidth;
   if (rtNumRows == "" || rtNumRows == "0"){
      rtNumRows = "1";}
   if (rtNumCols == "" || rtNumCols == "0"){
      rtNumCols = "1";}
   var rttrnum=1;
   var rttdnum=1;
   var rtNewTable = "<P><table border='1' align='" + rtTblAlign + "' cellpadding='0' cellspacing='0' width='" + rtTblWidth + "'>"
   CellWidth=(100/rtNumCols);
   while (rttrnum <= rtNumRows){
      rttrnum=rttrnum+1
      rtNewTable = rtNewTable + "<tr>"
      while (rttdnum <= rtNumCols){
         rtNewTable = rtNewTable + '<td width="'+CellWidth+'%">&nbsp;</td>'
         rttdnum=rttdnum+1}
      rttdnum=1
      rtNewTable = rtNewTable + "</tr>"}
   rtNewTable = rtNewTable + "</table></P>"
   HTMLEditor.focus();
   InsertTag( rtNewTable, '' );
}
//
//----------
//
function clickIE() {
	return false;
}
//
//----------
//
function createTableNew() {
	rtNumRows = currentRow;
	rtNumCols = currentCol;
	rtTblAlign = "";
	rtTblWidth = "100%";
	createTable();
	rtNumRows = null;
	rtNumCols = null;
	rtTblAlign = null;
	rtTblWidth = null;
}
//
//----------
//
function hideTableIF(ObjectName) {
	var tableDiv = document.all[ObjectName];
	tableDiv.style.visibility = "hidden";
	var tableCreateIF = tableDiv.getElementsByTagName("TABLE");
	var tableCells = tableCreateIF[0].getElementsByTagName("TD");
	for (i = 0; i < tableCells.length; i++) {
		tableCells[i].style.backgroundColor="#FFFFFF";
	}
}
//
//----------
//
function highlightTDs(ObjectName, num, CellDataHolder) {
	var tableCreateIF = document.all[ObjectName];
	var tableCells = tableCreateIF.getElementsByTagName("TD");
	var tableRows = tableCreateIF.getElementsByTagName("TR");
	var tableWidth = tableCells.length / tableRows.length;
	var col;
	var row;
	var i;
	if ( num == 0) {
		col = 1;
	}
	else {
		col = (num + 1) % tableWidth;
		if (col == 0) {
			col = tableWidth;
		}
	}
	row = Math.floor((num + tableWidth) / tableWidth);
	currentCol = col;
	currentRow = row;
	for (i = 0; i < tableCells.length; i++) {
		if (colVal(i, tableWidth) <= col && rowVal(i, tableWidth) <= row) {
			tableCells[i].style.backgroundColor="#185A98";
		}
		else {
			tableCells[i].style.backgroundColor="#FFFFFF";
		}
	}
	var TableSize = document.all[CellDataHolder];
	TableSize.value = row + " x " + col;
}
//
//----------
//
function rowVal(num, tableWidth) {
	return Math.floor((num + tableWidth) / tableWidth);
}
//
//----------
//
function colVal (num, tableWidth) {
	var retVal;
	if ( num == 0) {
		retVal = 1;
	}
	else {
		retVal = (num + 1) % tableWidth;
		if (retVal == 0) {
			retVal = tableWidth;
		}
	}
	return retVal;
}
//
//----------
//
function setEditor(objectName) {
	tableDialogEditor = objectName;
}
//
//----------
//
function editorRightClick(prefix, divName) {
	var possibleTableElement;
	if (parseInt(navigator.appVersion)>3) {
		var clickType=1;
		if (navigator.appName=="Netscape") clickType=e.which;
		else clickType=event.button;
		if (clickType!=1)  {
			var SelectedObject;
			var tRange;
			SelectedObject = document.selection;
			tRange = SelectedObject.createRange();
		
			if (SelectedObject.type == "Control") {
				if (tRange.length >= 1) {
					var selectedEl = tRange(0);
				}
			}
			else {
				var selectedEl = tRange.parentElement();
			}
			if (selectedEl.tagName != "TD") {
				selectedEl = document.elementFromPoint(event.x, event.y);
			}			
			
			if (selectedEl.tagName != "TD") {
				possibleTableElement = findTagAmongstParents(selectedEl, "TD", divName);
			}

			if (possibleTableElement != null) {
				selectedEl = possibleTableElement;
			}
			if (selectedEl.tagName == "TD") {
				var tempEl2 = selectedEl.parentElement;
				do {
					if (tempEl2.tagName == "TR") {
						TableRowPropertyObject = tempEl2;
					}
					tempEl2 = tempEl2.parentElement;
				} while (tempEl2.tagName != "TBODY");
				
				TableCellPropertyObject = selectedEl;
				TableBodyPropertyObject = tempEl2;
				TablePropertyObject = tempEl2.parentElement;

				outOfContext = false;
				return prefix + 'TableMenu';			
			
			} // if (selectedEl.tagName == "TD")
			else {
				outOfContext = true;
				return '';
			}
		} // if (clickType!=1)
	} // if (parseInt(navigator.appVersion)>3)
}
//
//----------
//
function findTagAmongstParents(startingElement, tagName, divName) {
	var found;
	var currEl;
	found = false;
	if ((startingElement.tagName == "DIV") && (startingElement.name == divName)) {
		return null;
	}
	currEl = startingElement.parentElement;
	while (currEl != null && !found){
		if ((currEl.tagName == "DIV") && (currEl.name == divName)) {
			return null;
		}
		if (currEl.tagName == tagName) {
			found = true;
		}
		else {
			currEl = currEl.parentElement;
		}
	}
	return currEl;
}
//
//----------
//
function hideRightMenu(ObjectName) {
	var i;
	var tableMenu = document.all[ObjectName];
	for (i = 0; i < tableMenu.childNodes.length; i++) {
		if (tableMenu.childNodes[i].tagName == "DIV") {
			tableMenu.childNodes[i].style.visibility="hidden";
		}
	}
	tableMenu.style.visibility="hidden";
}
//
//----------
//
function insertRowBefore() {
	var tRows = TablePropertyObject.getElementsByTagName("TR");
	var tCells = TablePropertyObject.getElementsByTagName("TD");
	var tCols = Math.round(tCells.length/tRows.length);
	trElement = document.createElement("TR");
	TableBodyPropertyObject.insertBefore(trElement, TableRowPropertyObject);
	var i;
	for (i = 0; i < tCols; i++) {
		var nc = trElement.insertCell();
		nc.insertAdjacentText("afterBegin"," ");
	}
	ClearMenu();
}
//
//----------
//
function insertRowAfter() {
	var tRows = TablePropertyObject.getElementsByTagName("TR");
	var tCells = TablePropertyObject.getElementsByTagName("TD");
	var tCols = Math.round(tCells.length/tRows.length);
	trElement = document.createElement("TR");
	TableBodyPropertyObject.insertBefore(trElement, TableRowPropertyObject);
	TableRowPropertyObject.removeNode(true);
	TableBodyPropertyObject.insertBefore(TableRowPropertyObject, trElement);
	var i;
	for (i = 0; i < tCols; i++) {
		var nc = trElement.insertCell();
		nc.insertAdjacentText("afterBegin"," ");
	}
	ClearMenu();
}
//
//----------
//
function findColumn() {
	var i;
	for (i = 0; i < TableRowPropertyObject.childNodes.length; i++) {
		if (TableRowPropertyObject.childNodes[i] == TableCellPropertyObject) {
			return i;
		}
	}
}	
//
//----------
//
function insertColLeft() {
	var colIndex = findColumn();
	var tRows = TableBodyPropertyObject.getElementsByTagName("TR");
	for (i = 0; i < tRows.length; i++) {
		if (tRows[i].childNodes[colIndex]) {
			if (tRows[i].childNodes[colIndex].tagName == "TD") {
				var newTD = tRows[i].insertCell(colIndex);
				newTD.insertAdjacentText("afterBegin"," ");
				newTD.style.width = Math.round(50/tRows[i].childNodes.length) + "%";
			}
		}
	}
	ClearMenu();
}
//
//----------
//
function deleteColumn() {
	var colIndex = findColumn();
	var tRows = TableBodyPropertyObject.getElementsByTagName("TR");
	for (i = 0; i < tRows.length; i++) {
		if (tRows[i].childNodes[colIndex]) {
			if (tRows[i].childNodes[colIndex].tagName == "TD") {
				tRows[i].childNodes[colIndex].removeNode(true);
			}
		}
	}
	ClearMenu();
}
//
//----------
//
function insertColRight() {
	var colIndex = findColumn();
	var tRows = TableBodyPropertyObject.getElementsByTagName("TR");
	for (i = 0; i < tRows.length; i++) {
		if (tRows[i].childNodes[colIndex]) {
			if (tRows[i].childNodes[colIndex].tagName == "TD") {
				var newTD = tRows[i].insertCell(colIndex + 1);
				newTD.insertAdjacentText("afterBegin"," ");
				newTD.style.width = Math.round(50/tRows[i].childNodes.length) + "%";
			}
		}
	}
	ClearMenu();
}
//
//----------
//
function deleteRow() {
	TableRowPropertyObject.removeNode(true);
	ClearMenu();
}
//
//----------
//
function showPanel(panelNum){
              if (currentPanel != null) {
		hidePanel();
	}
	document.getElementById('panel'+panelNum).style.visibility = 'visible';
	currentPanel = panelNum;
	setState(panelNum);
}
//
//----------
//
function hidePanel(){
	document.getElementById('panel'+currentPanel).style.visibility = 'hidden';
	document.getElementById('tab'+currentPanel).style.backgroundColor = '#ffffff';
	document.getElementById('tab'+currentPanel).style.color = 'navy';
}
//
//----------
//
function setState(tabNum){
	if(tabNum==currentPanel){
		document.getElementById('tab'+tabNum).style.backgroundColor = '#ddddff';
		document.getElementById('tab'+tabNum).style.color = 'red';
	}else{
		document.getElementById('tab'+tabNum).style.backgroundColor = '#ffffff';
		document.getElementById('tab'+tabNum).style.color = 'navy';
	}
}
//
//----------
//
function hover(tab){
	tab.style.backgroundColor = 'ddddff';
}
//
//----------
//
function showTab(tabnum)
  {
  var tabsDef = new Array(4)
   for (i=1;i<=tabsDef.length;i++)
    {
     tabName='tabContent' + i;
     eval(tabName + '.style.display="none"');
     tabName='tabLabel' + i;
     eval(tabName + '.style.backgroundColor="lightgrey"');
     eval(tabName + '.style.fontWeight="normal"');
     undName='tabUnderline' + i;
     eval(undName + '.style.backgroundColor="white"');
    }
   tabName='tabContent' + tabnum;
   eval(tabName + '.style.display="block"');
   tabName='tabLabel' + tabnum;
   eval(tabName + '.style.backgroundColor="lightgrey"');
   eval(tabName + '.style.fontWeight="bold"');
   undName='tabUnderline' + tabnum;
   eval(undName + '.style.backgroundColor="lightgrey"');
  }
//
//----------
//
function ImagePreview( ImageURL, ImageHeight, ImageWidth ) {
	var Options
	Options='menubar=no,toolbar=no,location=no,status=no,scrollbars=no,resizable,directories=no'
	if ( ImageWidth ) { 
		Options+=',width='+ImageWidth;
		}
	if ( ImageHeight ) { 
		Options+=',height='+ImageHeight;
		}
	var MsgWin=window.open ('', '_blank',Options)
	var MsgText='<HTML><body bgcolor="white" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">'+ImageURL+'</BODY></HTML>'
	MsgWin.document.write( MsgText );
	}
//
//----------
//
function HelpBubbleOn( BubbleID, Source ) {
	var DivTarget;
	var DivLeft, DivTop;
	//
	DivTarget = document.getElementById( BubbleID );
	if ( DivTarget ) {
		DivLeft = getPageOffsetLeft( Source )+Source.offsetWidth;
		if ( DivLeft > document.body.scrollWidth ) {
			DivLeft = document.body.scrollWidth - DivTarget.offsetWidth;
		}
		DivTop = getPageOffsetTop( Source )-DivTarget.offsetHeight;
		if ( DivTop < 0 ) {
			DivTop = 0;
		}
		DivTarget.style.left = DivLeft;
		DivTarget.style.top = DivTop;
		DivTarget.style.visibility = 'visible';
	}
}
//
//----------
//
function HelpBubbleOff( BubbleID ) {
	var DivTarget = document.getElementById( BubbleID );
	if ( DivTarget ) {
		DivTarget.style.visibility = 'hidden';
		}
	}
//
//----------
//
function InsertFolderRow() {
	var RLTable = document.getElementById('AddFolderTable' );
	var CountElement = document.getElementById('AddFolderCount' );
	var tCols,tRows,NewRowNumber;
	var NewRow,NewCell1,NewCell2,NewCell3,NewCell4;
	if ( RLTable ) {
		NewRowNumber = parseInt( CountElement.value )+1;
		CountElement.value = NewRowNumber;
		tRows = RLTable.getElementsByTagName("TR");
		NewRow = RLTable.insertRow();
		NewCell1 = NewRow.insertCell();
		NewCell1.align = 'right';
		NewCell1.innerHTML= NewRowNumber+'&nbsp;';
		NewCell3 = NewRow.insertCell();
		NewCell3.innerHTML='<INPUT TYPE="Text" NAME="FolderName.'+NewRowNumber+'" SIZE="30">';
		NewCell4 = NewRow.insertCell();
		NewCell4.innerHTML='<INPUT TYPE="Text" NAME="FolderDescription.'+NewRowNumber+'" SIZE="40">';
	}
}
//
//----------
//
function InsertUploadRow() {
	var RLTable = document.getElementById('UploadInsert' );
	var CountElement = document.getElementById('LibraryUploadCount' );
	var tCols,tRows,NewRowNumber;
	var NewRow,NewCell1,NewCell2,NewCell3,NewCell4;
	if ( RLTable ) {
		NewRowNumber = parseInt( CountElement.value )+1;
		CountElement.value = NewRowNumber;
		tRows = RLTable.getElementsByTagName("TR");
		NewRow = RLTable.insertRow();
		NewCell1 = NewRow.insertCell();
		NewCell1.align = 'right';
		NewCell1.innerHTML= NewRowNumber+'&nbsp;';
		NewCell2 = NewRow.insertCell();
		NewCell2.innerHTML='<INPUT TYPE="file" name="LibraryUpload.'+NewRowNumber+'">';
		NewCell3 = NewRow.insertCell();
		NewCell3.innerHTML='<INPUT TYPE="Text" NAME="LibraryName.'+NewRowNumber+'" SIZE="30">';
		NewCell4 = NewRow.insertCell();
		NewCell4.innerHTML='<INPUT TYPE="Text" NAME="LibraryDescription.'+NewRowNumber+'" SIZE="40">';
	}
}
//
//----------
//
function RLRowClick(IsChecked,RowID) {
	var RLRow = document.getElementById(RowID);
	if (IsChecked) {
		RLRow.style.backgroundColor="#F0F0F0";
	} else {
		RLRow.style.backgroundColor="white";
	}
}
//
//----------
//
if (browser.isIE) {
	document.onmousedown = PageClick;
}
else if(browser.version > 5) {
	document.addEventListener("mousedown", PageClick, true);
}
if (browser.isIE) {
	if (document.body) {
		document.body.onclick = BodyOnClick;
		document.body.oncontextmenu = BodyOnClick;
	}
	else {
		window.onclick = BodyOnClick;
		window.oncontextmenu = BodyOnClick;
	}
	updateClipboardLinksInit();
}
else if(browser.version > 5) {
	document.addEventListener("mouseclick", BodyOnClick, true);
}
//
//----------
//
function spellcheckRightClick( ) {
	var spellElement;
	var spellOptionList;
	var spellOptions;
	var theDiv;
	var theRange;
	var wordChoice;
	var inputBox;
	var inputBoxSize;
	var height;
	var width;
	var i;
	var divName;
	var ignoreButton;
	var changeButton;
	var Panel;
	var PanelDiv;	
	//
	removeSpellCheckDivs();
	//
	browser = new BrowserType();

	if (browser.isIE) {
		spellElement = event.srcElement;
	}
	else {
		spellElement = event.currentTarget;
	}
	//
	Panel = '';
	Panel += '<TABLE border="0" cellpadding="0" cellspacing="0" width="200" class="ccPanel">';
	Panel += '<TR><TD colspan="3" class="ccPanelHilite"><IMG alt="" src="/ccLib/Images/spacer.gif" height="1" width="100%" /></TD></TR>';
	Panel += '<TR>';
	Panel += '<TD width="1" height="1" class="ccPanelHilite"><IMG alt="" src="/ccLib/Images/spacer.gif" height="1" width="1" /></TD>';
	Panel += '<TD width="100%" valign="top" align="left">';
	//
	Panel += '<TABLE border="0" cellpadding="5" cellspacing="0" width="100%" class="ccPanel">';
	Panel += '<TR><TD valign="top"><Span Class="ccPanel"><P><B>Unknown Word</B></P></SPAN></TD></TR>';
	Panel += '</TABLE>';
	//
	Panel += '</TD>';
	Panel += '<TD width="1" class="ccPanelShadow"><IMG alt="" src="/ccLib/Images/spacer.gif" height="1" width="1" /></TD></TR>';
	Panel += '<TR><TD colspan="3" class="ccPanelShadow"><IMG alt="" src="/ccLib/Images/spacer.gif" height="1" width="100%" /></TD></TR>';
	Panel += '<TR><TD colspan="3" class="ccPanelHilite"><IMG alt="" src="/ccLib/Images/spacer.gif" height="1" width="100%" /></TD></TR>';
	Panel += '<TR>';
	Panel += '<TD width="1" height="1" class="ccPanelHilite"><IMG alt="" src="/ccLib/Images/spacer.gif" height="1" width="1" /></TD>';
	Panel += '<TD width="100%" valign="top" align="left">';
	//
	Panel += '<TABLE border="0" cellpadding="5" cellspacing="0" width="100%" class="ccPanel">';
	Panel += '<TR><TD valign="top"><Span Class="ccPanel"><DIV class="ccMisspellChoice" ID="SpellerDiv"></DIV></SPAN></TD></TR>';
	Panel += '</TABLE>';
	//
	Panel += '<TABLE border="0" cellpadding="0" cellspacing="0" width="100%" class="ccPanelButtons">';
	Panel += '<TR>';
	Panel += '<TD colspan="3" class="ccPanelShadow"><IMG alt="" src="/ccLib/Images/spacer.gif" height="1" width="100%" /></TD>';
	Panel += '</TR><TR>';
	Panel += '<TD width="1" height="1" class="ccPanelShadow"><IMG alt="" src="/ccLib/Images/spacer.gif" height="1" width="1" /></TD>';
	Panel += '<TD width="100%" valign="top" align="left"><TABLE border="0" cellpadding="4" cellspacing="0" width="100%" class="ccPanelButtons"><TR><TD valign="top"><Span Class="ccPanelButtons"><NOBR>';
	Panel += '<INPUT ID="SpellerChangeButton" TYPE="BUTTON" NAME="ChangeWord" VALUE=" Change Word" onClick="changeWord();" style="">';
	Panel += '<INPUT ID="SpellerIgnoreButton" TYPE="BUTTON" NAME="IgnoreWord" VALUE=" Ignore All" onClick="ignoreWord();">';
	Panel += '</NOBR></SPAN></TD></TR></TABLE></TD>';
	Panel += '<TD width="1" class="ccPanelHilite"><IMG alt="" src="/ccLib/Images/spacer.gif" height="1" width="1" /></TD>';
	Panel += '</TR><TR>';
	Panel += '<TD colspan="3" class="ccPanelHilite"><IMG alt="" src="/ccLib/Images/spacer.gif" height="1" width="100%" /></TD>';
	Panel += '</TR>';
	Panel += '</TABLE>';
	//
	Panel += '</TD>';
	Panel += '<TD width="1" class="ccPanelShadow"><IMG alt="" src="/ccLib/Images/spacer.gif" height="1" width="1" /></TD></TR>';
	Panel += '<TR><TD colspan="3" class="ccPanelShadow"><IMG alt="" src="/ccLib/Images/spacer.gif" height="1" width="100%" /></TD></TR>';
	Panel += '</TABLE>';
	//
	PanelDiv = document.createElement("DIV");
	PanelDiv.id = 'SpellerPanelDiv';
	PanelDiv.style.position="absolute";
	PanelDiv.style.border="1px solid #000000";
	PanelDiv.style.top = getPageOffsetTop(spellElement);
	PanelDiv.style.left = getPageOffsetLeft(spellElement) + spellElement.offsetWidth;
	PanelDiv.style.visibility = "visible";
	PanelDiv.innerHTML=Panel;
	//
	document.body.appendChild(PanelDiv);
	divName = 'SpellerDiv';
	theDiv = document.getElementById( divName );
	//
	spellOptionList = new String(spellElement.name);
	spellOptions = spellOptionList.split(",");
	//
	theDiv.misspelledElement = spellElement;
	//
	spellCheckList += (divName + ",");

	width = 0;
	height = 0;

	inputBox = document.createElement("INPUT");
	inputBoxSize = 20;
	inputBox.style.fontSize = "8pt";
	inputBox.value = spellElement.innerText;

	for (i = 0; i < spellOptions.length; i++) {
		wordChoice = document.createElement("A");
		wordChoice.className = "ccFlyoutPanelButton";
		wordChoice.divName = divName;
		wordChoice.href = "#"
		wordChoice.onclick = editMisspelledWordBox;
		wordChoice.onmouseover = SpellerHover;
		wordChoice.onmouseout = SpellerUnHover;
		wordChoice.style.cursor = "hand";
		wordChoice.innerHTML = spellOptions[i];
		theDiv.appendChild(wordChoice);
	}

	inputBox.setAttribute("size", "" + inputBoxSize);
	inputBox.size = inputBoxSize;
	inputBox.length = inputBoxSize + 2;
	inputBox.className = "ccFlyoutPanelButton";
	theDiv.inputBox = inputBox;
	theDiv.insertBefore(document.createElement("BR"), theDiv.childNodes[0]);
	theDiv.insertBefore(inputBox, theDiv.childNodes[0]);
	
	// create the two buttons for ignore, change

	ignoreButton = document.getElementById( "SpellerIgnoreButton" );
	ignoreButton.divName = divName;
	ignoreButton.onclick = ignoreWord;
	//
	changeButton = document.getElementById( "SpellerChangeButton" );
	changeButton.divName = divName;
	changeButton.onclick = changeWord;
}
//
//----------
//
function editMisspelledWordBox () {
	var divObj;
	var wordElement;
	if (browser.isIE) {
		wordElement = event.srcElement;
	}
	else {
		wordElement = event.currentTarget;
	}
	divObj = document.all[wordElement.divName];
	
	divObj.inputBox.value = wordElement.innerHTML;
	return false;
}
//
//----------
//
function changeWord() {
    var outerDivObj;
    var outerDivFound;
    var divName;
    var textareaName;
    var textareaObj;
    var divObj;
    var el;
     
    if (browser.isIE) {
        el = event.srcElement;
    } else {
        el = event.currentTarget;
    }
    divObj = document.all[el.divName];
    if (divObj.inputBox.value == "") {
        return;
    }
    outerDivFound = false;
    textareaObj = null;
    outerDivObj = divObj.misspelledElement;
    while (!outerDivFound) {
    if (outerDivObj.tagName == "DIV") {
        divName = new String(outerDivObj.id);
        if (divName.indexOf(".spell") != -1) {
            textareaName = divName.replace(".spell", "");
            textareaObj = document.getElementById(textareaName);
            if (textareaObj.tagName != "TEXTAREA") {
                textareaObj = null;
            }
            outerDivFound = true;
        } else {
            outerDivObj = outerDivObj.parentElement;
        }
    } else {
        outerDivObj = outerDivObj.parentElement;
    }
    }
    divObj.misspelledElement.innerHTML = divObj.inputBox.value;
    divObj.misspelledElement.style.backgroundColor = "transparent";
    if (textareaObj != null) {
        textareaObj.value = outerDivObj.innerHTML;
    }
    divObj.style.visibility="hidden";
    divObj.removeNode(true);
}
//
//----------
//
function ignoreWord() {

	var divObj;
	var el;
	var i;
	var wordToIgnore;
	var spanElements;
	var outerDivFound;
	var outerDivObj;
	var textareaName;
	var textareaObj;
	var divName;

	if (browser.isIE) {
		el = event.srcElement;
	}
	else {
		el = event.currentTarget;
	}

	divObj = document.all[el.divName];

	wordToIgnore = divObj.misspelledElement.innerHTML;

	spanElements = document.getElementsByTagName("SPAN");

	if (spanElements) {

		for (i = 0; i < spanElements.length; i++) {
	
			if (spanElements[i].innerHTML == wordToIgnore && spanElements[i].id == "ccSpell.UnknownWord") {
				spanElements[i].id = "ccSpell.Add";
				spanElements[i].style.backgroundColor="transparent";
			}

		}

	}

	outerDivFound = false;
	textareaObj = null;
	outerDivObj = divObj.misspelledElement;

	while (!outerDivFound) {
		if (outerDivObj.tagName == "DIV") {
			divName = new String(outerDivObj.id);
			if (divName.indexOf(".spell") != -1) {
				textareaName = divName.replace(".spell", "");
				textareaObj = document.getElementById(textareaName);
				if (textareaObj.tagName != "TEXTAREA") {
					textareaObj = null;
				}
				outerDivFound = true;
			}
		}
		else {
			outerDivObj = outerDivObj.parentElement;
		}
	}

	divObj.misspelledElement.id = "ccSpell.Add";
	divObj.misspelledElement.style.backgroundColor = "transparent";

	if (textareaObj != null) {
		textareaObj.value = outerDivObj.innerHTML;
	}

	removeSpellCheckDivs();	
}
//
//----------
//
function SpellerHover() {
	var item
	if (browser.isIE)
		item = event.srcElement;
	else
		item = event.currentTarget;
	item.className += " ccFlyoutPanelButtonDown";
}
//
//----------
//
function SpellerUnHover() {
	var item
	if (browser.isIE)
		item = event.srcElement;
	else
		item = event.currentTarget;
	removeClassNameAfter(item, "ccFlyoutPanelButtonDown");
}
//
//----------
//
var DPanel='0';
function ToggleToolPanelDev() {
    if (DPanel=='0') {
        DPanel='1';
        document.all['ToolPanelDev'].style.visibility='visible';
    } else {
        DPanel='0';
        document.all['ToolPanelDev'].style.visibility='hidden';
    }
    return false;
}
//
//----------
//
function SubmitToolsPanel() {
    var SelectedObject;
    var TextRange;
    SelectedObject = document.selection;
    TextRange = SelectedObject.createRange();
    if (TextRange.text) {
        if (TextRange.text.length != 0) {
            document.all['ToolsPanelSelection'].value=TextRange.htmlText;
        }
    }
    return true;
}
//
//----------
//
function InsertTemplateIcon(ImageLink, ObjectName  ) {
	ExecCmdPlus('InsertImage',false,ImageLink, ObjectName );
	ClearMenu();
	}
//
//----------
//

//StyleRight = "color:black;background-color:white;border-bottom: 1px solid #a0a0a0;padding-left:5px;padding-right:5px;"
//Style = StyleRight & "border-right: 1px solid #a0a0a0;"

function InsertCartRow() {
	var RLTable = document.getElementById('CartTable');
	var CountElement = document.getElementById('CartRows');
	var tCols,tRows,NewRowNumber;
	var NewRow,e,NewCell2,NewCell3,NewCell4;
	if ( RLTable ) {
		NewRowNumber = parseInt( CountElement.value );
		CountElement.value = NewRowNumber+1;
		tRows = RLTable.getElementsByTagName("TR");
		NewRow = RLTable.insertRow();
		e = NewRow.insertCell();
		e.align = 'center';
		e.style.color='black';
		e.style.backgroundColor='white';
		e.style.borderBottom='1px solid #a0a0a0';
		e.style.borderRight='1px solid #a0a0a0';
		e.style.paddingRight='5px';
		e.style.paddingLeft='5px';
		e.innerHTML= '<INPUT TYPE=TEXT NAME=Q'+NewRowNumber+' VALUE=1 SIZE=2 MAXLENGTH=5>';
		e = NewRow.insertCell();
		e.style.color='black';
		e.style.backgroundColor='white';
		e.style.borderBottom='1px solid #a0a0a0';
		e.style.borderRight='1px solid #a0a0a0';
		e.style.paddingRight='5px';
		e.style.paddingLeft='5px';
		e.innerHTML=ItemSelect.replace('row0id','ID'+NewRowNumber);
		NewCell3 = NewRow.insertCell();
		NewCell3.style.color='black';
		NewCell3.style.backgroundColor='white';
		NewCell3.style.borderBottom='1px solid #a0a0a0';
		NewCell3.style.borderRight='1px solid #a0a0a0';
		NewCell3.style.paddingRight='5px';
		NewCell3.style.paddingLeft='5px';
		NewCell3.innerHTML='&nbsp;';
		NewCell4 = NewRow.insertCell();
		NewCell4.style.color='black';
		NewCell4.style.backgroundColor='white';
		NewCell4.style.borderBottom='1px solid #a0a0a0';
		NewCell4.style.paddingRight='5px';
		NewCell4.style.paddingLeft='5px';
		NewCell4.innerHTML='&nbsp;';
	}
}


