﻿// JScript File

var mozilla=document.getElementById && !document.all
var ie=document.all

var d=document;
function dObj(idx){
	var o=d.getElementById(idx);
	//if(o==null) alert('Cannot find ID: '+idx);
	return o;
}
function dAEv(a,b){
	a=a.split(',');
	for(i in a){
		if(ie) document.attachEvent('on'+a[i],b);
		if(mozilla) document.addEventListener(a[i],b,false);
	}
}
function dDEv(a,b){
	a=a.split(',');
	{
		if(ie) document.detachEvent('on'+a[i],b);
		if(mozilla) document.removeEventListener(a[i],b,false);
	}
}
function obj(idx){
	var t=this;
	t.path=(typeof(idx)=='string')?dObj(idx):idx;
	var p=t.path;
	t.w=p.offsetWidth;
	t.h=p.offsetHeight;
	t.x=0;
	t.y=0;
	while(p.offsetParent!=null){
		var style=ie?p.currentStyle:window.getComputedStyle(p,'');
		if(style.position=='absolute'){
			t.x+=parseInt(style.left);
			t.y+=parseInt(style.top);
			break;
		}
		t.x+=p.offsetLeft-p.scrollLeft;
		t.y+=p.offsetTop-p.scrollTop;
		p=p.offsetParent;
	}
}
function objArray(objx){
	var output=new Array();
	if(objx!=null){
		/*if(objx.length!=null){
			if(objx.length>0) for(x=0;x<objx.length;x++)output[x]=objx[x];
			else output[0]=objx;
		}
		else output[0]=objx;
	}*/
		try{
			if(objx.id!=null){
				throw 1;
			}
			else{
				throw 0;
			}
		}
		catch(e){
			if(e==1){
				output[0]=objx;
			}
			else{
				if(objx.length>0) for(x=0;x<objx.length;x++)output[x]=objx[x];
				else output[0]=objx;
			}
		}
	}
	return output;
}
obj.prototype.setXY=function(x,y){
	var buf=this.path.offsetParent.tagName;
	//if(buf!='BODY'){
		var b=d.getElementsByTagName('BODY')[0];
		b.insertBefore(this.path,b.firstChild);
	//}
	var p=this.path.style;
	p.position='absolute';
	p.left=x+'px';
	p.top=y+'px';
};
obj.prototype.alignObject=function(idxp,c1,c2){
	idx=new obj(idxp);
	idx.setXY(0,0);
	idx=new obj(idxp);
	
	var cx=[,[0,0],[1,0],[1,1],[0,1]],t=this;
	c1=cx[c1];c2=cx[c2];
	var x=t.x+(c1[0]?t.w:0)-(c2[0]?idx.w-2:0);
	var y=t.y+(c1[1]?t.h:0)-(c2[1]?idx.h-2:0);
	
	var wChk=((x<0&&c2[0])||(x+idx.w>d.body.offsetWidth&&!c2[0]));
	var hChk=((y<0&&c2[1])||(y+idx.h>d.body.offsetHeight&&!c2[1]));
	if(wChk)x=t.x+(c1[0]?0:t.w)-(c2[0]?0:idx.w-2);
	if(hChk)y=t.y+(c1[1]?0:t.h)-(c2[1]?0:idx.h-2);
	idx.setXY(x,y);
};
function nodePath(obj,idxp){
	var dbx=idxp.split(/\b/gi),i=0;
	if(dbx[i].indexOf('*')>-1&&obj.id==dbx[i+1])i+=2;
	for(i;i<dbx.length;i+=2){
		if(dbx[i].match(/\./g)){
			obj=obj.parentNode;
			while(obj.id!=dbx[i+1])obj=obj.parentNode;
		}
		if(dbx[i].match(/\\/g)){
			obj=obj.getElementsByTagName('*')[dbx[i+1]];
			if(typeof(obj.style)=='undefined')obj=obj[0];
		}
	}
	return obj;
}
function styleParser(str){
	var obx=new Object();
	var str=str.split(';');
	for(i=0;i<str.length;i++){
		str[i]=str[i].split(':');
		obx[str[i][0]]=str[i][1];
	}
	return obx;
}
function mouseX(e){
	return e.clientX+d.documentElement.scrollLeft+d.body.scrollLeft;
}
function mouseY(e){
	return e.clientY+d.documentElement.scrollTop+d.body.scrollTop;
}
function mouseXY(e){
	var p=e.srcElement;
	var x=e.clientX;
	var y=e.clientY;
	while(p.offsetParent!=null){
		if(p.scrollLeft!=null)x+=p.scrollLeft;
		if(p.scrollTop!=null)y+=p.scrollTop;
		p=p.offsetParent;
	}
	return [x,y];
}
Array.prototype.removeIndex=function(x){
	var t=this,a;
	for(a=x;a<t.length-1;a++)t[a]=t[a+1];
	t.length--;
};
Array.prototype.addValue=function(x){
	var t=this;
	t[t.length]=x;
};
Array.prototype.valExists=function(x){
	var sw=-1,t=this,a;
	for(a=0;a<t.length;a++){
		if(t[a]==x){
			sw=a;
			break;
		}
	}
	return sw;
};
Array.prototype.removeValue=function(x){
	var t=this,sw=0,a;
	for(a=0;a<t.length;a++){
		if(sw)t[a-1]=t[a];
		if(t[a]==x)sw=1;
	}
	if(sw)t.length--;
};



function lnk(lnk){dObj('content').src=lnk;}
function pageTitleChange(txt){
	if(dObj('pageTitle')){
		dObj('pageTitle').innerHTML=txt;
		if(txt.toLowerCase()=='page loading...'){
			dObj('pageTitle').innerHTML+='<img alt="X" src="img.ashx?img=/banner/pageLoading.gif">';
		}
	}
}
var prevMenuHighlights;
function nodeFilterTxt(pnx,idx,txt){
	pnx=dObj(pnx).children;
	var cn;
	for(i=0;i<pnx.length;i++){
		cn=nodePath(pnx[i],'*\\'+idx).innerHTML;
		pnx[i].style.display=(cn.indexOf(txt)==-1&&txt!='*')?'none':'block';
	}
}
function sysModal(page){
	var props=new Array();
	props[0]='dialogWidth:'+((arguments.length>1)?arguments[1]:'300')+'px';
	props[1]='dialogHeight:'+((arguments.length>2)?arguments[2]:'155')+'px';
	props[2]='resizable:yes';
	props[3]='scroll:no';
	props[4]='status:yes';
	props[5]='edge:raised';
	return nm=window.showModalDialog(page,'',props.join(';'));
}
function sysOpenWindow(page){
	var props=new Array();
	props[0]='width='+((arguments.length>1)?arguments[1]:'310')+'px';
	props[1]='height='+((arguments.length>2)?arguments[2]:'200')+'px';
	props[2]='resizable=no';
	props[3]='scroll=no';
	props[4]='status=no';
	props[5]='edge=raised';
	props[6]='help=no';
	var data=window.open(page,'',props.join(','));
	return data;
}

function nothing(){}

dAEv('mousewheel',killControlScroll);
function killControlScroll(){
	if(event.ctrlKey){
		event.returnValue=false;
	}
}

function confirmDelete(){
	if(!confirm('Are you sure you would like to delete?')){
		event.returnValue=false;
	}
}
function enterKey(id){
	if(event.keyCode==13){
		dObj(id).click();
		event.returnValue=false;
	}
}



function context(path,menu){
	event.cancelBubble=1;
	if(d.activeContextMenu)contextHide();
	d.activeContextLink=path;
	d.activeContextMenu=menu;
	var c=menu.style;
	c.display='block';
	c.top=mouseXY(event)[1];
	c.left=mouseXY(event)[0];
	dAEv('contextmenu,click',contextHide);
	if(path.hasChildren){
		if(path.firstChild.nodeName.toLowerCase()==('textarea'||'input'))path.firstChild.blur();
	}
	window.event.returnValue=false;
}
function context2(path,menu){
	event.cancelBubble=1;
	if(d.activeContextMenu)contextHide();
	d.activeContextLink=path;
	d.activeContextMenu=menu;
	menu.style.display='block';
	var srp=new obj(event.srcElement);
	srp.alignObject(menu,4,1);
	dAEv('contextmenu,click',contextHide);
	if(path.hasChildren){
		if(path.firstChild.nodeName.toLowerCase()==('textarea'||'input'))path.firstChild.blur();
	}
	window.event.returnValue=false;
}
function contextHide(){
	var path=event.srcElement;
	var ac=d.activeContextMenu;
	var sw=1;
	if(event.type=='mousedown'){
		while(path.id){
			if(path==ac){
				sw=0;
				break;
			}
			path=path.parentNode;
		}
	}
	if(sw){
		ac.style.display='none';
		dDEv('contextmenu,click',contextHide);
	}
}
function contextTip(a){
	nodePath(d.activeContextMenu,'\\contextMenuTip').innerText=a;
}



dAEv('mouseover',hewkoMenuInit);
var hewkoMenuTracking=new Array();
function hewkoMenuInit(e){
	var path=ie?event.srcElement:e.target;
	var dbx=hewkoMenuTracking;
	var sw=-1;
	var path2;
	while(path.id!=null){
		if(path.getAttribute('hewkoMenu')&&!path2)path2=path;
		sw=dbx.valExists(path);
		if(sw>-1)break;
		path=path.parentNode;
	}
	for(b=dbx.length-2;b>sw;b-=2){
		hewkoMenuHide(dbx[b]);
		dbx.length-=2;
	}
	if(dbx.valExists(path2)==-1&&path2){
		var ix=path2.getAttribute('hewkoMenu',0);
		path2.hewkoMenuObj=styleParser(ix);
		dbx.addValue(path2);
		dbx.addValue(dObj(path2.hewkoMenuObj.idx));
		path2.hewkoMenuObj.trigClassOrig=path2.className;
		hewkoMenuShow(path2);
	}
}
function hewkoMenuShow(path){
	var prop=path.hewkoMenuObj;
	if(prop.trigClass)path.className=prop.trigClass;
	if(path.hewkoMenuObj.idx){
		var menuPath=dObj(path.hewkoMenuObj.idx);
		(prop.transition)?hewkoTransition(prop.transition,1):menuPath.style.display='block';
		new obj(path).alignObject(prop.idx,((prop.align)?prop.align.substring(0,1):4),((prop.align)?prop.align.substring(2,3):1));
		menuPath.attachEvent('onclick',hewkoMenuHideAll);
	}
	
}
function hewkoMenuHide(path){
	var prop=path.hewkoMenuObj;
	if(prop.trigClass)path.className=prop.trigClassOrig;
	if(prop.idx){
		var menuPath=dObj(prop.idx);
		(prop.transition)?hewkoTransition(prop.transition,0):menuPath.style.display='none';
	}
}
function hewkoMenuHideAll(){
	var dbx=hewkoMenuTracking;
	for(b=dbx.length-2;b>=0;b-=2){
		hewkoMenuHide(dbx[b]);
		dbx.length-=2;
	}
}



var hfxMoveObj;
var hfxMoveHandle;
var hfxMoveGroup;
var hfxMoveRestrict;

function hfxMoveStart(){
	var path=event.srcElement;
	var att=path.getAttribute('hfxMove',0);
	if(att){
		att=att.split(':');
		hfxMoveGroup=att[0];
		hfxMoveRestrict=(att.length>2)?att[2]:null;
		var origin=nodePath(path,'*.'+att[1]);
		var orj=new obj(origin);
		hfxMoveHandle=origin.cloneNode(true);
		for(st in origin.currentStyle)hfxMoveHandle.style[st]=origin.currentStyle[st];
		with(hfxMoveHandle.style){
			position='absolute';
			width=origin.offsetWidth+'px';
			var xFactor=(hfxMoveRestrict=='h')?10:7;
			var yFactor=(hfxMoveRestrict=='v')?1:-10;
			left=((hfxMoveRestrict!='v')?mouseX(event)+xFactor:orj.x)+'px';
			top=((hfxMoveRestrict!='h')?mouseY(event)+yFactor:orj.y)+'px';
			filter='alpha(opacity=80)';
		}
		with(origin){
			attachEvent('ondrag',hfxMoveDrag);
			attachEvent('ondragend',hfxMoveEnd);
		}
		hfxMoveObj=(att.length>3)?nodePath(origin,att[3]).cloneNode(1):origin;
		d.body.appendChild(hfxMoveHandle);
	}
}

function hfxMoveStart2(){
	var path=event.srcElement;
	var att=path.getAttribute('hfxMove',0);
	if(att){
		att=att.split(':');
		hfxMoveGroup=att[0];
		hfxMoveRestrict=(att.length>2)?att[2]:null;
		var origin=nodePath(path,'*.'+att[1]);
		var orj=new obj(origin);
		hfxMoveHandle=origin.cloneNode(true);
		for(st in origin.currentStyle)hfxMoveHandle.style[st]=origin.currentStyle[st];
		with(hfxMoveHandle.style){
			position='absolute';
			width=origin.offsetWidth+'px';
			var xFactor=(hfxMoveRestrict=='h')?10:7;
			var yFactor=(hfxMoveRestrict=='v')?1:-10;
			left=((hfxMoveRestrict!='v')?mouseX(event)+xFactor:orj.x)+'px';
			top=((hfxMoveRestrict!='h')?mouseY(event)+yFactor:orj.y)+'px';
			filter='alpha(opacity=80)';
		}
		with(origin){
			attachEvent('ondrag',hfxMoveDrag);
			attachEvent('ondragend',hfxMoveEnd);
		}
		hfxMoveObj=(att.length>3)?nodePath(origin,att[3]).children[0].cloneNode(1):origin;
		d.body.appendChild(hfxMoveHandle);
	}
}

function hfxMoveDrag(){
	with(hfxMoveHandle.style){
		var xFactor=(hfxMoveRestrict=='h')?10:7;
		var yFactor=(hfxMoveRestrict=='v')?1:-10;
		if(hfxMoveRestrict!='v')left=(mouseX(event)+xFactor)+'px';
		if(hfxMoveRestrict!='h')top=(mouseY(event)+yFactor)+'px';
	}
}
function hfxMoveEnd(){hfxMoveHandle.removeNode(1)}
function hfxMoveEnter(){
	var path=event.srcElement;
	var att=path.getAttribute('hfxAcceptMove',0);
	if(att){
		att=att.split(':')[0];
		if(att==hfxMoveGroup){
			path.className='dropArea-highlight';
			with(path){
				attachEvent('ondrop',hfxMoveDrop);
				attachEvent('ondragover',hfxMoveOver);
				attachEvent('ondragleave',hfxMoveLeave);
			}
		}
	}
}
function hfxMoveOver(){event.returnValue=false}
function hfxMoveLeave(){
	with(event.srcElement){
		className='dropArea';
		detachEvent('ondrop',hfxMoveDrop);
		detachEvent('ondragover',hfxMoveOver);
		detachEvent('ondragleave',hfxMoveLeave);
	}
}
function hfxMoveDrop(){
	var path=event.srcElement;
	var att=path.getAttribute('hfxAcceptMove',0).split(':')[1];
	path.className='dropArea';
	var cdx=nodePath(path,att);
	cdx.parentNode.insertBefore(hfxMoveObj,cdx);
	with(event.srcElement){
		className='dropArea';
		detachEvent('ondrop',hfxMoveDrop);
		detachEvent('ondragover',hfxMoveOver);
		detachEvent('ondragleave',hfxMoveLeave);
	}
	hfxMoveGroup=null;
}



var menuScrollInterval;
function hfxScroll(idx,drx,spd){
	clearInterval(menuScrollInterval);
	dAEv('mouseover,mouseup',hfxScrollStop);
	hfxScrollGo(idx,drx,spd);
	menuScrollInterval=setInterval('hfxScrollGo(\''+idx+'\','+drx+','+spd+')',20);
}
function hfxScrollGo(idx,drx,spd){
	idx=dObj(idx);
	var px=spd*((drx<3)?1:-1);
	(drx%2==0)?idx.scrollTop+=px:idx.scrollLeft+=px;
}
function hfxScrollStop(){
	clearInterval(menuScrollInterval);
	dDEv('mouseover,mouseup',hfxScrollStop);
}



dAEv('click',fxPanelInit);
function fxPanelInit(){
	var path=event.srcElement;
	while(path.id!=null){
		if(path.getAttribute('fxPanel',0)){
			if(styleParser(path.getAttribute('fxPanel')).group)fxPanelGroupHide(path);
			fxPanelSwitch(path);
			break;
		}
		path=path.parentNode;
	}
}
function fxPanelGroupHide(trig){
	var att;
	var groupVal=styleParser(trig.getAttribute('fxPanel',0)).group;
	var grp=(groupVal=='true')?trig.parentNode.children:d.getElementsByTagName('*')[groupVal];
	for(c=0;c<grp.length;c++){
		att=grp[c].getAttribute('fxPanel',0);
		if(att){
			var panel=(styleParser(att).idx=='*next')?grp[c].nextSibling:dObj(styleParser(att).idx);
			if(panel.currentStyle.display!='none')fxPanelSwitch(grp[c]);
		}
	}
}
function fxPanelSwitch(trig){
	var ix=trig.getAttribute('fxPanel',0);
	trig.fxPanelObj=styleParser(ix);
	var panel=(trig.fxPanelObj.idx=='*next')?trig.nextSibling:dObj(trig.fxPanelObj.idx);
	var sw=!(panel.currentStyle.display=='none');
	panel.style.display=(sw)?'none':'inline';
	if(trig.fxPanelObj.trigClass && trig.fxPanelObj.trigClassDisplayed){
		trig.className=(sw)?trig.fxPanelObj.trigClass:trig.fxPanelObj.trigClassDisplayed;
	}
}



function nodeSort(pnx,idx,dir){//dir=direction[1,-1]
	var path=event.srcElement;
	if(path==d.nodeSortPrevPath)dir=(d.nodeSortPrevDir*=-1);
	if(d.nodeSortPrevPath)d.nodeSortPrevPath.className=d.nodeSortPrevPath.className.replace(/(-asc|-desc).*$/gi,'');
	var curCls=path.className.split('-')[0];
	path.className=curCls+((dir==1)?'-asc':'-desc');
	d.nodeSortPrevPath=path;
	d.nodeSortPrevDir=dir;
	pnx=dObj(pnx).children;
	var dbx=new Array();
	idx=idx.split(',');
	for(i=0;i<idx.length;i++){
		idx[i]=idx[i].split(':');
		if(idx[i].length<2)idx[i][1]=1;
	}
	for(i=0;i<pnx.length;i++){
		dbx[i]=[pnx[i].outerHTML];
		for(j=0;j<idx.length;j++)dbx[i][dbx[i].length]=typeVal(nodePath(pnx[i],'\\'+idx[j]));
	}
	dbx.sort(function(a,b){return sortDbx(a,b,1)});
	for(i=0;i<dbx.length;i++)pnx[i].outerHTML=dbx[i][0];
	function typeVal(path){
		var val=path.innerText;
		if(path.tagName.toLowerCase()=='input'){
			var ptt=path.type.toLowerCase();
			if(ptt=='checkbox'||ptt=='radio')val=!path.checked;
		}
		return val;
	}
	function sortDbx(a,b,d){
		if(a[d]<b[d])this.r=-1*idx[d-1][1]*dir;
		if(a[d]==b[d]&&d<a.length-1)this.r=sortDbx(a,b,d+1);
		if(a[d]>b[d])this.r=1*idx[d-1][1]*dir;
		return this.r;
	}
}

function elementSort(pnx,idx,dir){//dir=direction[1,-1]
	var path=event.srcElement;
	if(path==d.nodeSortPrevPath)dir=(d.nodeSortPrevDir*=-1);
	if(d.nodeSortPrevPath)d.nodeSortPrevPath.className=d.nodeSortPrevPath.className.replace(/(-asc|-desc).*$/gi,'');
	var curCls=path.className.split('-')[0];
	path.className=curCls+((dir==1)?'-asc':'-desc');
	d.nodeSortPrevPath=path;
	d.nodeSortPrevDir=dir;
	pnx=dObj(pnx).children;
	var dbx=new Array();
	idx=idx.split(',');
	for(i=0;i<idx.length;i++){
		idx[i]=idx[i].split(':');
		if(idx[i].length<2)idx[i][1]=1;
	}
	for(i=0;i<pnx.length;i++){
		dbx[i]=[pnx[i].outerHTML];
		for(j=0;j<idx.length;j++)dbx[i][dbx[i].length]=pnx[i].getAttribute(idx[j][0],0);
	}
	dbx.sort(function(a,b){return sortDbx(a,b,1)});
	function sortDbx(a,b,d){
		if(a[d]<b[d])this.r=-1*idx[d-1][1]*dir;
		if(a[d]==b[d]&&d<a.length-1) this.r=sortDbx(a,b,d+1);
		if(a[d]==b[d]&&d>=a.length-1) this.r=0;
		if(a[d]>b[d])this.r=1*idx[d-1][1]*dir;
		return this.r;
	}
	for(i=0;i<dbx.length;i++) pnx[i].outerHTML=dbx[i][0];
}



var hfxTipTimer;
var hfxTipPath;
var hfxTipVisible=0;
var hfxTipXY=[0,0];

function hfxTip(txt){
	hfxTipXY=[(mouseX(event)),(mouseY(event)+20)];
	if(hfxTipVisible) hfxTipShow(txt);
	else hfxTipTimer=setTimeout('hfxTipShow(\''+txt+'\')',1000);
	event.srcElement.attachEvent('onmouseout',hfxTipHide);
	event.srcElement.attachEvent('onmousedown',hfxTipHide);
	event.srcElement.attachEvent('onmousemove',hfxTipTrack);
}
function hfxTipTrack(){
	hfxTipXY=[(mouseX(event)),(mouseY(event)+20)];
}
function hfxTipShow(txt){
	clearTimeout(hfxTipTimer);
	hfxTipVisible=1;
	var tip=d.createElement('span');
	tip.style.position='absolute';
	tip.innerHTML=txt;
	tip.className='hfxTip';
	tip.style.left=hfxTipXY[0]+'px';
	tip.style.top=hfxTipXY[1]+'px';
	hfxTipPath=d.body.appendChild(tip);
}
function hfxTipHide(){
	if(hfxTipVisible)hfxTipPath.removeNode(1);
	clearTimeout(hfxTipTimer);
	hfxTipTimer=setTimeout('hfxTipVisible=0',250)
	event.srcElement.detachEvent('onmouseout',hfxTipHide);
	event.srcElement.detachEvent('onmousedown',hfxTipHide);
	event.srcElement.detachEvent('onmousemove',hfxTipTrack);
}



function XmlString(str){
	var out=new ActiveXObject("Microsoft.XMLDOM");
	out.async=false;
	out.loadXML(str);
	return out;
}
function XmlFile(file){
	var out=new ActiveXObject("Microsoft.XMLDOM");
	out.async=false;
	out.load(file);
	return out;
}



function templateInfo(){
	var path=event.srcElement;
	dObj('templateTitle').innerHTML=nodePath(path,'*.templateInfo\\templateTitleInfo').innerHTML;
	dObj('templateFile').innerHTML=nodePath(path,'*.templateInfo\\templateFileInfo').innerHTML;
	dObj('templateDescription').innerHTML=nodePath(path,'*.templateInfo\\templateDescriptionInfo').innerHTML;
}
function aceInfo(){
	var path=event.srcElement;
	nodePath(path,'*.panel\\aceTitleInfo').innerText=nodePath(path,'*.aceInfo\\aceTitle').innerText;
	nodePath(path,'*.panel\\aceDescriptionInfo').innerText=nodePath(path,'*.aceInfo\\aceDescription').innerHTML;
}
function optionInfo(titleDisplayID,messageDisplayID){
	var path=event.srcElement;
	dObj(titleDisplayID).innerHTML=path.getAttribute("title",0);
	dObj(messageDisplayID).innerHTML=path.getAttribute("description",0);
}
function aceSelect(){
	var ord=['checkView','checkContribute','checkApprove'];
	var path=event.srcElement;
	var id=nodePath(path,'*.aceInfo\\aceID').innerText;
	var type=nodePath(path,'*.aceInfo\\aceType').innerText;
	var out=nodePath(path,'*.aceInfo\\aceLevel');
	var itm,isw=false,indx=0;
	for(f=0;f<ord.length;f++){
		if(nodePath(path,'*.aceInfo').getElementsByTagName('*')[ord[f]]!=null){
			itm=nodePath(path,'*.aceInfo\\'+ord[f]);
			if(itm==path){
				isw=true;
				if(path.className=='check '+ord[f])indx=f+1;
				itm.className='check '+ord[f]+((path.className!='check '+ord[f])?'':'Selected');
			}
			else itm.className='check '+ord[f]+((isw)?'':'Selected');
			if(!isw)indx=f+1;
		}
	}
	if(indx>0)gxAltTag('ace',['id='+id,'t='+type],['lvl='+indx]);
	else{
		gxDelete('ace',['id='+id,'t='+type]);
		var cdx=nodePath(gxCurDataNode,'.opt').getElementsByTagName('ace')[id];
		if(cdx){
			if(cdx.id)if(!gxMatch(cdx,['nodelete=1']))cdx.removeNode();
			else for(a=0;a<cdx.length;a++)if(!gxMatch(cdx[a],['nodelete=1']))cdx[a].removeNode();
		}
	}
	out.innerText=indx;
	aceOrderEnforce();
	workflowUpdate();
}
function aceOrderEnforce(){
	var a3=new Array();
	var a2=new Array();
	var a1=new Array();
	var lvl='';
	var aces=gxCurDataNode.getElementsByTagName('ace');
	for(j=0;j<aces.length;j++){
		lvl=aces[j].getAttribute('lvl',0);
		var tag=aces[j];
		if(lvl=='3')a3[a3.length]=tag.outerHTML;
		if(lvl=='2')a2[a2.length]=tag.outerHTML;
		if(lvl=='1')a1[a1.length]=tag.outerHTML;
		tag.outerHTML='';
	}
	var out='';
	out=a3.join(' ')+a2.join(' ')+a1.join(' ');
	gxCurDataNode.innerHTML+=out;
}
function aceAdmSelect(){
	var ord=['chkAdm'];
	var path=event.srcElement;
	var id=nodePath(path,'*.aceInfo\\aceID').innerText;
	var type=nodePath(path,'*.aceInfo\\aceType').innerText;
	var out=nodePath(path,'*.aceInfo\\aceLevel');
	var itm,isw=false,indx=0;
	for(f=0;f<ord.length;f++){
		itm=nodePath(path,'*.aceInfo\\'+ord[f]);
		if(itm==path){
			isw=true;
			indx=((path.className=='')?3:0);
			itm.className=(path.className!='')?'':'selected';
		}
		else itm.className=(isw)?'':'selected';
	}
	if(indx>0) gxAltTag('ace',['id='+id,'t='+type],['lvl='+indx]);
	else{
		gxDelete('ace',['id='+id,'t='+type]);
		var cdx=nodePath(gxCurDataNode,'.opt').getElementsByTagName('ace')[id];
		if(cdx){
			if(cdx.id)cdx.removeNode();
			else for(a=0;a<cdx.length;a++)cdx[a].removeNode();
		}
	}
	out.innerText=indx;
}
function securityInheritance(){
	if(!dObj('securityInherit').checked){
		var c,t,indx;
		var ord=['checkView','checkContribute','checkApprove'];
		var cdx=dObj('aceContainer').getElementsByTagName('a');
		for(k=0;k<cdx.length;k++){
			c=nodePath(cdx[k],'\\aceID').innerText;
			t=nodePath(cdx[k],'\\aceType').innerText;
			indx=0;
			for(f=0;f<ord.length;f++){
				if(cdx[k].getElementsByTagName('*')[ord[f]]!=null){
					if(nodePath(cdx[k],'\\'+ord[f]).className!='check '+ord[f])indx=f+1;
				}
			}
			if(indx>0)gxAdd('ace',['id='+c,'t='+t,'lvl='+indx]);
		}
		if(nodePath(gxCurDataNode,'.opt').getElementsByTagName('opt')[0].getAttribute('type',0)=='home'){
			gxAdd('ace',['id=users','t=g','lvl=1','nodelete=1']);
		}
	}
	else gxClear('ace');
	panelUpdate();
}
function securityAdmInherit(){
	if(!dObj('securityInherit').checked){
		var c,t,indx;
		var ord=['chkAdmDis'];
		var cdx=dObj('aceContainer').getElementsByTagName('a');
		for(k=0;k<cdx.length;k++){
			c=nodePath(cdx[k],'\\aceID').innerText;
			t=nodePath(cdx[k],'\\aceType').innerText;
			indx=0;
			if(nodePath(cdx[k],'\\'+ord[indx]).className!='')indx=3;
			if(indx>0)gxAdd('ace',['id='+c,'t='+t,'lvl='+indx]);
		}
	}
	else gxClear('ace');
	panelAdmUpdate();
}


function securitySelectAll(){
	var c,t,l;
	var cdx=dObj('aceContainer').getElementsByTagName('a');
	for(k=0;k<cdx.length;k++){
		c=nodePath(cdx[k],'\\aceID').innerText;
		t=nodePath(cdx[k],'\\aceType').innerText;
		l=nodePath(cdx[k],'\\aceLevel').innerText;
		if((l=='0')||(l=='')){
			status=k;
			gxAdd('ace',['id='+c,'t='+t,'lvl=1']);
		}
	}
	panelUpdate();
}

function securityDeselectAll(){
	gxClear('ace');
	panelUpdate();
}

function attributePageActive(){
	var sw=(event.srcElement.checked)?'':1;
	gxAltTag('pageattributes',[],['pageinactive='+sw]);
}
function attributeSearchable(){
	gxAltTag('pageattributes',[],['xsearch='+(event.srcElement.checked?'x':'')]);
}
function attributeMenu(){
	gxAltTag('pageattributes',[],['xmenu='+(event.srcElement.checked?'x':'')]);
}
function attributeInfo(){
	var path=event.srcElement;
	dObj('attributeTitle').innerText=nodePath(path,'*.attributeInfo\\attributeTitleInfo').innerText;
	dObj('attributeDescription').innerText=nodePath(path,'*.attributeInfo\\attributeDescriptionInfo').innerText;
}

function templateSelect(templateID){
	gxAltTag('pageattributes',[],['templateID='+templateID,'templateChanged=1']);
	var options=dObj('templates').getElementsByTagName('a');
	for(i=0;i<options.length;i++){
		options[i].className='option optionPadded';
	}
	var path=event.srcElement;
	path.className+=" selected";
}

function workflow2gx(){
	cnx=dObj('workflowContainer').children;
	var ix,t;
	for(a=cnx.length-1;a>=0;a--){
		if(cnx[a].id=='workflowBlock'){
			ix=nodePath(cnx[a],'\\aceID').innerText;
			t=nodePath(cnx[a],'\\aceType').innerText;
			gxMove2First('ace',['id='+ix,'t='+t]);
		}
	}
}

function userStringFilter(pnx,idx){
	var txt=event.srcElement.value;
	pnx=dObj(pnx).children;
	var dbx=new Array();
	var nd,show,sw;
	txt=txt.replace(/  /g,' ');
	txt=txt.replace(/^ |,| $/g,'');
	var reg1=new RegExp('\\b'+txt.replace(/ /g,'.*\\b'),'gi');
	var reg2=new RegExp('\\b'+txt.replace(/ /g,'|\\b'),'gi');
	var s1='<span class="panelOptSearchHighlight">';
	var s2='</span>';
	for(i=0;i<pnx.length;i++){
		nd=nodePath(pnx[i],'\\'+idx);
		sw=nd.innerText.search(reg1);
		if(sw>-1){
			show=1;
			nd.innerHTML=nd.innerText.replace(reg2,function($0){return s1+$0+s2});
		}
		else{
			show=0;
		}
		hfxListFilterDisplay(show,pnx[i],'strSearch');
		dbx[i]=[nd.innerText.substring(0,sw).split(' ').length,nd.innerText,pnx[i].outerHTML];
	}
	dbx.sort();
	for(i=0;i<dbx.length;i++)pnx[i].outerHTML=dbx[i][2];
}



// For custom implementation features

function lawyerBioPrint(lawyerID,recordID){
	LawyerID=lawyerID;
	RecordID=recordID;
	//var url='PrintBio.aspx?LawyerID='+lawyerID+'&RecordID='+recordID;
	sysOpenWindow('PrintBioConfirmation.aspx',300,200);
	//return printPage(url);
}
var LawyerID;
var RecordID;
function continueBioPrint(url){
	var newUrl='PrintBio.aspx?LawyerID='+LawyerID+'&RecordID='+RecordID;
	newUrl+=url;
	return printPage(newUrl);
}

function printPage(url){
	if (window.navigator.userAgent.indexOf("MSIE ")!=-1 && navigator.appVersion.substr(0, 1) >= 4){
		if(window.printHiddenFrame==null){
			window.document.body.insertAdjacentHTML("beforeEnd", "<iframe name='printHiddenFrame' width='0' height='0'></iframe>");
			framedoc=window.printHiddenFrame.document;
			framedoc.open();
			framedoc.write(
				"<frameset name=test onload='printMe.focus();printMe.print();' rows=\"100%\">" +
				"<frame name=printMe src=\""+url+"\">" +
				"</frameset>");
			framedoc.close();
		}
		else{
			framedoc=window.printHiddenFrame.document;
			framedoc.innerHTML='';
			framedoc.open();
			framedoc.write(
				"<frameset name=test onload='printMe.focus();printMe.print();' rows=\"100%\">" +
				"<frame name=printMe src=\""+url+"\">" +
				"</frameset>");
			framedoc.close();
			/*
			window.printHiddenFrame.printMe.focus();
			window.printHiddenFrame.printMe.print();
			*/
		}
	}		
	else{
		window.location.href=url;
	}
	return true;
}