function plPanelView(){
	var path=dObj('contentLeftSideBar');
	var sw=(path.currentStyle.display=='none');
	path.style.display=sw?'inline':'none';
}
function plPageModeToggle(){
	(d.plPageMode!='e')?plEditMode():plViewMode();
}
function plEditMode(){
	dObj('pageContainer').className='';
	dObj('previewModeHeader').style.display='none';
	d.plPageMode='e';
	plSearchUnHighlight();
	
	var contentBlocks=d.getElementsByTagName('div');
	for(i=0;i<contentBlocks.length;i++){
		if(contentBlocks[i].getAttribute("content",0)!=null){
			contentBlocks[i].contentEditable=true;
			contentBlocks[i].className="editMode";
		}
	}
	dObj('barContentEdit').style.display='block';
	dObj(editButtonID).innerText='Preview';
	dObj(saveButtonID).style.display='inline';
}
function plViewMode(){
	if(d.plPageMode=='e'){
		dObj('pageContainer').className='pagePreviewMode';
		dObj('previewModeHeader').style.display='block';
	}
	d.plPageMode='v';
	
	var contentBlocks=d.getElementsByTagName('div');
	for(i=0;i<contentBlocks.length;i++){
		if(contentBlocks[i].getAttribute("content",0)!=null){
			contentBlocks[i].contentEditable=false;
			contentBlocks[i].className="";
		}
	}
	dObj('barContentEdit').style.display='none';
	dObj(editButtonID).innerText='Edit';
}
function cancelPageSaveMessage(){
	d.saveProcessInitiated=true;
}
function plSaveChanges(){
	d.saveProcessInitiated=true;
	d.forms[0].submit();
}
function chkSaveChanges(){
	/*if(d.saveProcessInitiated==null){
		event.returnValue='You have not saved your changes!\rIf you select "OK" to continue all current content changes will be discarded.\rSelect "Cancel" if you wish to return to the current page and save your changes first.';
	}*/
}
var plSearchIndex=1;
var plSearchCount=1;
function plSearchHighlight(txt){
	if(txt!=''){
		var bt='<span name="cmSearchTerm" id="cmSearchTerm';
		var mt='" class="cmSearchTerm">';
		var et='</span>';
		var conTxt=dObj('cmPageRender').innerHTML;
		txt=txt.replace(/(?!"[^" ][^"]*) (?![^"]*[^" ]")/gi,'|');
		txt=txt.replace(/"/gi,'');
		var codeRegExp=new RegExp('(?!\\<[^\\<\\>]*)\\b('+txt+')\\b(?![^\\<\\>]*\\>)','gi');
		conTxt=conTxt.replace(codeRegExp,function($0,$1){return bt+(plSearchCount++)+mt+$1+et});
		plSearchCount--;
		dObj('cmPageRender').innerHTML=conTxt;
	}
	plSearchHighlightArray(0);
}
function plSearchUnHighlight(){
	while(dObj('cmSearchTerm'))dObj('cmSearchTerm').removeNode(0);
	if(dObj('searchHits'))dObj('searchHits').style.display='hidden';
}
function plSearchHighlightArray(dir){
	dObj('cmSearchTerm'+plSearchIndex).className='cmSearchTerm';
	plSearchIndex=plSearchIndex+dir;
	if(plSearchIndex>plSearchCount) plSearchIndex=1;
	if(plSearchIndex<1) plSearchIndex=plSearchCount;
	dObj('cmSearchTerm'+plSearchIndex).className='cmSearchTerm-selected';
	dObj('cmSearchTerm'+plSearchIndex).scrollIntoView();
	dObj('plSearchCountDisplay').innerHTML=(plSearchIndex+'/'+plSearchCount);
}
function plRollOver(){
	var path=event.srcElement;
	if(path.getAttribute('hsrc',0)!=null){
		path.setAttribute('osrc',path.src,0);
		path.src=path.getAttribute('hsrc',0);
		path.attachEvent('onmouseout',plRollOut);
	}
}
function plRollOut(){
	var path=event.srcElement;
	path.src=path.getAttribute('osrc',0);
	path.removeAttribute('osrc',0);
	path.detachEvent('onmouseout',plRollOut);
}
function emailClient(adr){
	var pref='';
	if(arguments.length>1)pref=arguments[1];
	sysOpenWindow(applicationPath+'/emailClient.aspx?email='+escape(adr),506,480);
}
function emailPageLink(url,title){
	var pref='';
	if(arguments.length>1)pref=arguments[1];
	sysOpenWindow(applicationPath+'/emailPageLink.aspx?url='+url+'&title='+escape(title),506,480);
}
function bufferContent(obj){
	dObj(obj.getAttribute('bufferid',0)).value=escape(obj.innerHTML);
}