//Nifty
/* Nifty Corners Cube - rounded corners with CSS and Javascript
Copyright 2006 Alessandro Fulciniti (a.fulciniti@html.it)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

var niftyOk=(document.getElementById && document.createElement && Array.prototype.push);

String.prototype.find=function(what){
return(this.indexOf(what)>=0 ? true : false);
}

function Nifty(selector,options){
if(niftyOk==false) return;
var i,v=selector.split(","),h=0;
if(options==null) options="";
if(options.find("fixed-height"))
    h=getElementsBySelector(v[0])[0].offsetHeight;
for(i=0;i<v.length;i++)
    Rounded(v[i],options);
if(options.find("height")) SameHeight(selector,h);
}

function Rounded(selector,options){
var i,top="",bottom="",v=new Array();
if(options!=""){
    options=options.replace("left","tl bl");
    options=options.replace("right","tr br");
    options=options.replace("top","tr tl");
    options=options.replace("bottom","br bl");
    options=options.replace("transparent","alias");
    if(options.find("tl")){
        top="both";
        if(!options.find("tr")) top="left";
        }
    else if(options.find("tr")) top="right";
    if(options.find("bl")){
        bottom="both";
        if(!options.find("br")) bottom="left";
        }
    else if(options.find("br")) bottom="right";
    }
if(top=="" && bottom=="" && !options.find("none")){top="both";bottom="both";}
v=getElementsBySelector(selector);
for(i=0;i<v.length;i++){
    FixIE(v[i]);
    if(top!="") AddTop(v[i],top,options);
    if(bottom!="") AddBottom(v[i],bottom,options);
    }
}

function AddTop(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Top");
if(options.find("small")){
    d.style.marginBottom=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginBottom=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginBottom=(p-5)+"px";
for(i=1;i<=lim;i++)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingTop="0";
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Bottom");
if(options.find("small")){
    d.style.marginTop=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginTop=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginTop=(p-5)+"px";
for(i=lim;i>0;i--)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingBottom=0;
el.appendChild(d);
}

function CreateStrip(index,side,color,border,btype){
var x=CreateEl("b");
x.className=btype+index;
x.style.backgroundColor=color;
x.style.borderColor=border;
if(side=="left"){
    x.style.borderRightWidth="0";
    x.style.marginRight="0";
    }
else if(side=="right"){
    x.style.borderLeftWidth="0";
    x.style.marginLeft="0";
    }
return(x);
}

function CreateEl(x){
return(document.createElement(x));
}

function FixIE(el){
if(el.currentStyle!=null && el.currentStyle.hasLayout!=null && el.currentStyle.hasLayout==false)
    el.style.display="inline-block";
}

function SameHeight(selector,maxh){
var i,v=selector.split(","),t,j,els=[],gap;
for(i=0;i<v.length;i++){
    t=getElementsBySelector(v[i]);
    els=els.concat(t);
    }
for(i=0;i<els.length;i++){
    if(els[i].offsetHeight>maxh) maxh=els[i].offsetHeight;
    els[i].style.height="auto";
    }
for(i=0;i<els.length;i++){
    gap=maxh-els[i].offsetHeight;
    if(gap>0){
        t=CreateEl("b");t.className="niftyfill";t.style.height=gap+"px";
        nc=els[i].lastChild;
        if(nc.className=="niftycorners")
            els[i].insertBefore(t,nc);
        else els[i].appendChild(t);
        }
    }
}

function getElementsBySelector(selector){
var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c;
if(selector.find("#")){ //id selector like "tag#id"
    if(selector.find(" ")){  //descendant selector like "tag#id tag"
        s=selector.split(" ");
        var fs=s[0].split("#");
        if(fs.length==1) return(objlist);
        f=document.getElementById(fs[1]);
        if(f){
            v=f.getElementsByTagName(s[1]);
            for(i=0;i<v.length;i++) objlist.push(v[i]);
            }
        return(objlist);
        }
    else{
        s=selector.split("#");
        tag=s[0];
        selid=s[1];
        if(selid!=""){
            f=document.getElementById(selid);
            if(f) objlist.push(f);
            return(objlist);
            }
        }
    }
if(selector.find(".")){      //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    if(selclass.find(" ")){   //descendant selector like tag1.classname tag2
        s=selclass.split(" ");
        selclass=s[0];
        tag2=s[1];
        }
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass==""){
    for(i=0;i<v.length;i++) objlist.push(v[i]);
    return(objlist);
    }
for(i=0;i<v.length;i++){
    c=v[i].className.split(" ");
    for(j=0;j<c.length;j++){
        if(c[j]==selclass){
            if(tag2=="") objlist.push(v[i]);
            else{
                v2=v[i].getElementsByTagName(tag2);
                for(k=0;k<v2.length;k++) objlist.push(v2[k]);
                }
            }
        }
    }
return(objlist);
}

function getParentBk(x){
var el=x.parentNode,c;
while(el.tagName.toUpperCase()!="HTML" && (c=getBk(el))=="transparent")
    el=el.parentNode;
if(c=="transparent") c="#FFFFFF";
return(c);
}

function getBk(x){
var c=getStyleProp(x,"backgroundColor");
if(c==null || c=="transparent" || c.find("rgba(0, 0, 0, 0)"))
    return("transparent");
if(c.find("rgb")) c=rgb2hex(c);
return(c);
}

function getPadding(x,side){
var p=getStyleProp(x,"padding"+side);
if(p==null || !p.find("px")) return(0);
return(parseInt(p));
}

function getStyleProp(x,prop){
if(x.currentStyle)
    return(x.currentStyle[prop]);
if(document.defaultView.getComputedStyle)
    return(document.defaultView.getComputedStyle(x,'')[prop]);
return(null);
}

function rgb2hex(value){
var hex="",v,h,i;
var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
var h=regexp.exec(value);
for(i=1;i<4;i++){
    v=parseInt(h[i]).toString(16);
    if(v.length==1) hex+="0"+v;
    else hex+=v;
    }
return("#"+hex);
}

function Mix(c1,c2){
var i,step1,step2,x,y,r=new Array(3);
if(c1.length==4)step1=1;
else step1=2;
if(c2.length==4) step2=1;
else step2=2;
for(i=0;i<3;i++){
    x=parseInt(c1.substr(1+step1*i,step1),16);
    if(step1==1) x=16*x+x;
    y=parseInt(c2.substr(1+step2*i,step2),16);
    if(step2==1) y=16*y+y;
    r[i]=Math.floor((x*50+y*50)/100);
    r[i]=r[i].toString(16);
    if(r[i].length==1) r[i]="0"+r[i];
    }
return("#"+r[0]+r[1]+r[2]);
}

function toggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

	function sortColumn(el) {
  	return false;
  }
  function changePage() {
  	document.writeln("<a href='"+absoluteWebRoot+"link.cfm?display_page="+document.location+"'><b>Load Menu</b></a>");
  }
  
	function openNewWindow(fileName,windowName,theWidth,theHeight,theScroll) {
		if (document.all) {
			showLeft = document.body.clientWidth - theWidth - 40;
		} else {
			showLeft = 	document.width - theWidth - 40;
		}
		window.open(fileName,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+theScroll+",resizable=0,left="+showLeft+",top=10,width="+theWidth+",height="+theHeight);
	}

	function WidgetToggle(id,widgetName,graphicsRoot) {
		i = eval("document.images."+widgetName+"IconExpand");
		c=document.all[id];
		if(c.style.visibility == "hidden") {
			c.style.visibility = "visible";
			c.style.display='block';
			img = graphicsRoot+"icon_collapse.gif";
			WidgetToggleImg(i,img);
			setTimeout("WidgetToggleImg(i,img);",500);
		} else {
			i.src = graphicsRoot+"icon_expand.gif";
			c.style.visibility = "hidden";
			c.style.display='none';
			//alert(i.src);
			img = graphicsRoot+"icon_expand.gif";
			WidgetToggleImg(i,img);
			setTimeout("WidgetToggleImg(i,img);",500);
		}
	}	
	function WidgetToggleImg(i,img) {
		i.src = img;
	}
function AddFromLookup(frmName,frmField,txt,val) {
	frmFieldObj = eval("document."+frmName+"."+frmField);
	target = frmFieldObj.options.length;
	newOpt = new Option(txt, val, false, false);
	frmFieldObj.options[target]=newOpt;
	frmFieldObj.selectedIndex = target;
	}
function showMenu(e, s, oElement) {
	// find anchor element
	noDisplayElement('OBJECT');noDisplayElement('SELECT');noDisplayElement('IFRAME');
	var el = e.target ? e.target : e.srcElement;
	while (el.tagName != "TD" && el.tagName != "A")
		el = el.parentNode;
	
	// is there already a tooltip? If so, remove it
	if (el._cMenu) {
		document.body.removeChild(el._cMenu);
		el._cMenu = null;
		el.onblur = null;
		displayElement('OBJECT');displayElement('SELECT');displayElement('IFRAME');
		return;
	}

	// create element and insert last into the body
	var d = document.createElement("DIV");
	d.className = "cMenuSub";
	document.body.appendChild(d);
	str = "";
	for (i=0; i<s.length; i++) {
		str += '<a target="'+s[i][2]+'" href="'+s[i][1]+'">'+s[i][0]+'</a><br>';
	}
	str += "";
	d.style.backgroundColor = 'menu';
	d.innerHTML = str;
	
	// Allow clicks on A elements inside tooltip
	d.onmousedown = function (e) {
		if (!e) e = event;
		var t = e.target ? e.target : e.srcElement;
		while (t.tagName != "A" && t != d)
			t = t.parentNode;
		if (t == d) return;
		
		el._onblur = el.onblur;
		el.onblur = null;
	};
	d.onmouseup = function () {
		el.onblur = el._onblur;
		el.focus();
	};
	// position tooltip
	var dw = document.width ? document.width : document.documentElement.offsetWidth - 25;
	var scroll = getScroll();
	if (e.clientX > dw - d.offsetWidth)
		d.style.left = dw - d.offsetWidth + scroll.x + "px";
	else
	   var tmp = oElement;
	   var left = 0;
	   var top = 0;
	   while (tmp != null) {
	      left += tmp.offsetLeft;
	      top += tmp.offsetTop;
	      tmp = tmp.offsetParent;
	   }
		d.style.left = left;
		d.style.top = top + oElement.offsetHeight + 3;
		//d.style.left = e.clientX - 2 + scroll.x + "px";
		//d.style.top = e.clientY + 8 + scroll.y + "px";

	// add a listener to the blur event. When blurred remove tooltip and restore anchor
	el.onblur = function () {
		if (d) document.body.removeChild(d);
		el.onblur = null;
		el._cMenu = null;
		displayElement('OBJECT');displayElement('SELECT');displayElement('IFRAME');
	};
	
	// store a reference to the tooltip div
	el._cMenu = d;
}

function leadingZero(nr) {
	if (parseInt(nr) < 10) nr = "0" + parseInt(nr);
	return nr;
}

function noDisplayElement(elmID) {
	if (document.all) {
		for (i = 0; i < document.all.tags(elmID).length; i++) {
			obj = document.all.tags(elmID)[i];
			if (! obj || ! obj.offsetParent)
				continue;
			obj.style.visibility = "hidden";
		}
	}
}

function displayElement(elmID) {
	if (document.all) {
		for (i = 0; i < document.all.tags(elmID).length; i++) {
			obj = document.all.tags(elmID)[i];
			if (! obj || ! obj.offsetParent)
			continue;
			obj.style.visibility = "";
		}
	}
}

// returns the scroll left and top for the browser viewport.
function getScroll() {
	if (document.body.scrollTop) {	// IE model
		var ieBox = document.compatMode != "CSS1Compat";
		var cont = ieBox ? document.body : document.documentElement;
		return {x : cont.scrollLeft, y : cont.scrollTop};
	}
	else {
		return {x : window.pageXOffset, y : window.pageYOffset};
	}
}

var TimeOutWaitMilliseconds = 120000; // 2 minutes
var timerID, timeoutUrl, resetTimeoutURL="";

function writeToTimeoutWin(curTimeOut) {
	 var timeout_option = "toolbar=0" + ",location=0" + ",directories=0"
             + ",status=0" + ",menubar=0" + ",scrollbars=0"
             + ",resizable=0"  + ",width=300" + ",height=200";
	var timeout_win = window.open(timeoutPopUpUrl, "TimeOut", timeout_option, true );
}

function clearGoToTimeout()  {
 	clearTimeout(timerID);
 	if(this["UITimeoutMilliseconds"] != null) {
		curTimeOut=UITimeoutMilliseconds;
	}
 	setupTimeout(curTimeOut);
}

function goToTimeout(curTimeOut) {
	self.location=timeoutUrl;
	return;
}

function setupTimeout(curTimeOut) {
	window.setTimeout('writeToTimeoutWin(curTimeOut)', curTimeOut);
	timerID=window.setTimeout('goToTimeout(curTimeOut)', curTimeOut+TimeOutWaitMilliseconds); 
}

function showHelp(hlp) {
	window.open(absoluteWebRoot+'modules/portal/help.cfm?h='+hlp,"Help","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,left=0,top=0,width=320,height=275");
}

function ListFind(list,val,del) {
	if (!del) del=",";
	listArr = list.split(del);
	fnd=0;
	for (l=0; l < listArr.length; l++) {
		if (listArr[l] == val) {
			fnd=l+1;
			break;
		}
	}
	return fnd;
}

function ListDeleteAt(list,ind,del) {
	if (!del) del=",";
	listArr = list.split(del);
	list="";
	for (l=0; l < listArr.length; l++) {
		if (l == (ind-1)) txt = "";
		else txt = listArr[l];
		if (txt != "") {
			list += (list.length>0)?del+txt:""+txt;
		}
	}
	return list;
}

function ListAppend(list,val,del) {
	if (!del) del=",";
	list += (list.length>0)?del+val:""+val;
	return list;
}

/* BEGIN SELECT FUNCTIONS */
var selectKeys = "";
function setupAutoSearch(selBox) {
	if (selBox.attachEvent) {
		selBox.attachEvent("onkeypress",function(){selectKeyPress();});
		selBox.attachEvent("onkeydown",function(){selectKeyDown();});
		selBox.attachEvent("onblur",function(){clr();});
		selBox.attachEvent("onfocus",function(){clr();});
	}
}

function selectKeyDown() {
    if(window.event.keyCode == 46 || window.event.keyCode == 8 || window.event.keyCode == 27)
        clr();
}

function selectKeyPress() {
    var sndr = window.event.srcElement;
    var pre = selectKeys;
    var key = window.event.keyCode;
    var chr = String.fromCharCode(key);
	var re = new RegExp("^" + pre + chr, "i"); 
    for(var i=0; i<sndr.options.length; i++) {
        if(re.test(sndr.options[i].text.replace(/\./g,""))) {
            sndr.options[i].selected=true;
            selectKeys += chr;
			if (typeof document.fireEvent != "undefined") {
				sndr.fireEvent("onchange");
			} else if (typeof document.createEvent != 'undefined') {
				try {
					sndr.dispatchEvent("change");
				} catch(e) {;}
			}
			window.status = selectKeys;
            window.event.returnValue = false;
            break;
        }
    }
}
function clr() {
    selectKeys = "";
	window.status = selectKeys;
}

function setupSelectBoxes() {
	var selBoxes = document.getElementsByTagName("SELECT");
	for (var s=0;s<selBoxes.length;s++) {
		//fix IE focus bug - when you click on a label for a select box, it resets the value
		if (document.all && window.attachEvent) {
			selBoxes[s].attachEvent("onfocusin",function(){SelectOnFocusIn();});
			selBoxes[s].attachEvent("onfocus",function(){SelectOnFocus();});
		}
		setupAutoSearch(selBoxes[s]);
	}
}

function SelectOnFocusIn() {
	try {
		var eSrc = window.event.srcElement;
		if (eSrc) eSrc.tmpIndex = eSrc.selectedIndex;
	} catch (e) {;}
}
function SelectOnFocus() {
	try {
		var eSrc = window.event.srcElement;
		if (eSrc) eSrc.selectedIndex = eSrc.tmpIndex;
	} catch (e) {;}
}

function getObjectProperties(elObj) {
	var objProp = Position.get(elObj);
	var objArr = new Array();
	objArr["x"] = objProp["left"];
	objArr["y"] = objProp["top"];
	objArr["h"] = objProp["height"];
	objArr["w"] = objProp["width"];
	return objArr;
}

function getObjectPosition(elObj) {
	var objRealPos = Position.get(elObj);
	var posArr = new Array();
	posArr["x"] = objRealPos["left"];
	posArr["y"] = objRealPos["top"];
	return posArr;
}

var Position =(function(){function resolveObject(s){if(document.getElementById && document.getElementById(s)!=null){return document.getElementById(s);}else if(document.all && document.all[s]!=null){return document.all[s];}else if(document.anchors && document.anchors.length && document.anchors.length>0 && document.anchors[0].x){for(var i=0;i<document.anchors.length;i++){if(document.anchors[i].name==s){return document.anchors[i]}}}}var pos ={};
pos.set = function(o,left,top){if(typeof(o)=="string"){o = resolveObject(o);}if(o==null || !o.style){return false;}o.style.position = "absolute";if(typeof(left)=="object"){var pos = left;left = pos.left;top = pos.top;}o.style.left = left + "px";o.style.top = top + "px";return true;};
pos.get = function(o){var fixBrowserQuirks = true;if(typeof(o)=="string"){o = resolveObject(o);}if(o==null){return null;}var left = 0;var top = 0;var width = 0;var height = 0;var parentNode = null;var offsetParent = null;offsetParent = o.offsetParent;var originalObject = o;var el = o;while(el.parentNode!=null){el = el.parentNode;if(el.offsetParent==null){}else{var considerScroll = true;if(fixBrowserQuirks && window.opera){if(el==originalObject.parentNode || el.nodeName=="TR"){considerScroll = false;}}if(considerScroll){if(el.scrollTop && el.scrollTop>0){top -= el.scrollTop;}if(el.scrollLeft && el.scrollLeft>0){left -= el.scrollLeft;}}}if(el == offsetParent){left += o.offsetLeft;if(el.clientLeft && el.nodeName!="TABLE"){left += el.clientLeft;}top += o.offsetTop;if(el.clientTop && el.nodeName!="TABLE"){top += el.clientTop;}o = el;if(o.offsetParent==null){if(o.offsetLeft){left += o.offsetLeft;}if(o.offsetTop){top += o.offsetTop;}}offsetParent = o.offsetParent;}}if(originalObject.offsetWidth){width = originalObject.offsetWidth;}if(originalObject.offsetHeight){height = originalObject.offsetHeight;}return{'left':left, 'top':top, 'width':width, 'height':height};};
pos.getCenter = function(o){var c = this.get(o);if(c==null){return null;}c.left = c.left +(c.width/2);c.top = c.top +(c.height/2);return c;};return pos;})();

/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var enabletip=false
var tipobj=null;
var pointerobj=null;

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function ddrivetip(objId,thetext, thewidth, thecolor){
	var obj = document.getElementById(objId);
	if (tipobj == null) {
		tipobj = document.createElement("DIV");
		tipobj.id = "dhtmltooltip";
		document.body.appendChild(tipobj);
	}
	if (pointerobj == null) {
		pointerobj = document.createElement("DIV");
		pointerobj.id = "dhtmlpointer";
		pointerobj.innerHTML = "<img src=\"/graphics/arrow_tip_up.gif\">";
		document.body.appendChild(pointerobj);
	}
	if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px";
	if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor;
	tipobj.innerHTML=thetext;
	enabletip=true;
	positiontip(objId);
	return false;
}

function showTitleTip(obj,thetext, thewidth, thecolor){
	if (thetext == "") return;
	if (tipobj == null) {
		tipobj = document.createElement("DIV");
		tipobj.id = "dhtmltooltip";
		document.body.appendChild(tipobj);
	}
	if (pointerobj == null) {
		pointerobj = document.createElement("DIV");
		pointerobj.id = "dhtmlpointer";
		pointerobj.innerHTML = "<img src=\"/graphics/arrow_tip_up.gif\">";
		document.body.appendChild(pointerobj);
	}
	if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px";
	if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor;
	tipobj.innerHTML=thetext;
	enabletip=true;
	document.onclick=hideddrivetip;
	document.body.onscroll=hideddrivetip;
	var offsetfromcursorX=12 //Customize x offset of tooltip
	var offsetfromcursorY=10 //Customize y offset of tooltip
	
	var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
	var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).
	
	var offsetX = 0;
	var offsetY = 0;
	var nondefaultpos=false;

	var objPos = getObjectPosition(obj);
	var curX=objPos["x"]-offsetX;
	var curY=objPos["y"]-offsetY;

	//Let's see if the tooltip will be too wide;
	if ((curX+tipobj.offsetWidth) > document.body.scrollWidth) {
		curX = objPos["x"]-offsetX-tipobj.offsetWidth+40;
		offsetfromcursorX = tipobj.offsetWidth-30;
	} else if (curY+tipobj.offsetHeight > document.body.offsetHeight) { //If the tooltip will be too tall for the page
		//curX = objPos["y"]-offsetY-tipobj.offsetHeight+40;
		//offsetfromcursorY = tipobj.offsetHeight-30;
		//alert(0);
	}
	//window.status = offsetfromcursorX+" "+curX;
	var tooltipX = curX;
	var tooltipY = curY+offsetfromcursorY+offsetdivfrompointerY;
	var pointerX = curX+offsetfromcursorX;
	var pointerY = curY+offsetfromcursorY;
	
	tipobj.style.left = tooltipX+"px";
	tipobj.style.top=tooltipY+"px";
	pointerobj.style.left = pointerX+"px";
	pointerobj.style.top=pointerY+"px";

	tipobj.style.visibility="visible"
	pointerobj.style.visibility=(!nondefaultpos)?"visible":"hidden";
	return false;
}

function positiontip(objId){
	if (enabletip){
		document.onclick=hideddrivetip;
		document.body.onscroll=hideddrivetip;
		var offsetfromcursorX=12 //Customize x offset of tooltip
		var offsetfromcursorY=10 //Customize y offset of tooltip
		
		var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
		var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).
		
		var obj = document.getElementById(objId);
		var offsetX = 0;
		var offsetY = 0;
		var nondefaultpos=false;

		var objPos = getObjectPosition(obj);
		var curX=objPos["x"]-offsetX;
		var curY=objPos["y"]-offsetY;

		//Let's see if the tooltip will be too wide;
		if ((curX+tipobj.offsetWidth) > document.body.scrollWidth) {
			curX = objPos["x"]-offsetX-tipobj.offsetWidth+40;
			offsetfromcursorX = tipobj.offsetWidth-30;
		} else if (curY+tipobj.offsetHeight > document.body.offsetHeight) { //If the tooltip will be too tall for the page
			//curX = objPos["y"]-offsetY-tipobj.offsetHeight+40;
			//offsetfromcursorY = tipobj.offsetHeight-30;
			//alert(0);
		}
		//window.status = offsetfromcursorX+" "+curX;
		var tooltipX = curX;
		var tooltipY = curY+offsetfromcursorY+offsetdivfrompointerY;
		var pointerX = curX+offsetfromcursorX;
		var pointerY = curY+offsetfromcursorY;
		
		tipobj.style.left = tooltipX+"px";
		tipobj.style.top=tooltipY+"px";
		pointerobj.style.left = pointerX+"px";
		pointerobj.style.top=pointerY+"px";

		tipobj.style.visibility="visible"
		pointerobj.style.visibility=(!nondefaultpos)?"visible":"hidden";
	}
}

function hideddrivetip(){
	enabletip=false
	tipobj.style.visibility="hidden"
	pointerobj.style.visibility="hidden"
	tipobj.style.left="-1000px"
	tipobj.style.backgroundColor=''
	tipobj.style.width=''
}

function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if (browser == "Microsoft Internet Explorer") {
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		ro = new XMLHttpRequest();
	}
	return ro;
}

function fixObjectTags() {
	return;
	var elems = document.getElementsByTagName("object");
	var newEls = new Array();
	for(i=0;i<elems.length;i++) {
		newEls[i] = elems[i].cloneNode(true);
		elems[i].outerHTML = newEls[i].outerHTML;
	}
	elems = document.getElementsByTagName("embed");
	for(i=0;i<elems.length;i++) {
		newEls[i] = elems[i].cloneNode(true);
		elems[i].outerHTML = newEls[i].outerHTML;
	}
	elems = document.getElementsByTagName("applet");
	for(i=0;i<elems.length;i++) {
		newEls[i] = elems[i].cloneNode(true);
		elems[i].outerHTML = newEls[i].outerHTML;
	}
}

/*	EventCache Version 1.0
	Copyright 2005 Mark Wubben

	Provides a way for automagically removing events from nodes and thus preventing memory leakage.
	See <http://novemberborn.net/javascript/event-cache> for more information.
	
	This software is licensed under the CC-GNU LGPL <http://creativecommons.org/licenses/LGPL/2.1/>
*/

/*	Implement array.push for browsers which don't support it natively.
	Please remove this if it's already in other code */
if(Array.prototype.push == null){
	Array.prototype.push = function(){
		for(var i = 0; i < arguments.length; i++){
			this[this.length] = arguments[i];
		};
		return this.length;
	};
};

/*	Event Cache uses an anonymous function to create a hidden scope chain.
	This is to prevent scoping issues. */
var EventCache = function(){
	var listEvents = [];
	
	return {
		listEvents : listEvents,
	
		add : function(node, sEventName, fHandler, bCapture){
			listEvents.push(arguments);
		},
	
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				
				/* From this point on we need the event names to be prefixed with 'on" */
				if(item[1].substring(0, 2) != "on"){
					item[1] = "on" + item[1];
				};
				
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				
				item[0][item[1]] = null;
			};
		}
	};
}();

function addEvent(obj, evType, fn, useCapture){
    var result;
	if (typeof(useCapture) == "undefined") useCapture = false;
    if (obj.addEventListener){
        obj.addEventListener(evType, fn, useCapture);
        result = true;
    } else if (obj.attachEvent){
        var r = obj.attachEvent("on"+evType, fn);
        result = r;
    } else {
        return false;
    }
    EventCache.add(obj, evType, fn, useCapture);
    return result;
}
addEvent(window, "unload", EventCache.flush);

//ddrivetip('JavaScriptKit.com JavaScript tutorials', 300)
//document.onmousemove=positiontip;

/* END SELECT FUNCTIONS */
window.focus();
window.status = '';

function globalOnload() {
	Nifty("div.RoundBox","smooth");
	Nifty("div.RoundTop","smooth top");
	if ($("loadingFrame") && $("loadingDiv")) {
		$("loadingFrame").style.display="none";
		$("loadingDiv").style.display="none";	
	}
	

	if (document.all) {
		setupSelectBoxes();
		fixObjectTags();
	};
}








function $(id) {
	return document.getElementById(id);	
}

function sendToBack(obj) {
	var ifrm = $("XMFrameOverlay");
	if (ifrm) ifrm.style.display = "none";
	if (!obj) return;
};

function bringToFront(obj,ht,wdt,lft,top) {
	if (!browserIE) return;
	var objPos = getObjectPosition(obj);
	var ifrm = $("XMFrameOverlay");
	if (!ifrm) {
		ifrm = document.createElement("IFRAME");
		ifrm.id="XMFrameOverlay";
		ifrm.setAttribute("scrolling","no");
		ifrm.setAttribute("frameborder","no");
		ifrm.src = "/blank.cfm"
		document.body.appendChild(ifrm);
	}
	ifrm.style.height = ((ht)?ht:obj.offsetHeight)+"px";
	ifrm.style.top = ((top)?top:objPos["y"])+"px";
	ifrm.style.left = ((lft)?lft:objPos["x"])+"px";		
	ifrm.style.width = ((wdt)?wdt:obj.offsetWidth)+"px";
	ifrm.style.display = "block";
	ifrm.style.zIndex = 10;
	obj.style.zIndex = 20;
	ifrm = null;
};

var overObj = new Object();
function showObj(e,el,pos,clickToClose) {
	var obj = $(el);
	var clickToClose = (typeof(clickToClose) != "undefined")?clickToClose:true;
	var docWidth = document.body.offsetWidth;
	if (obj) {
		if (typeof overObj[el] == "undefined") overObj[el] = false;
		var pos = (typeof(pos) != "undefined")?pos:"bottom";
		var eProp = getObjectProperties(e);
		obj.onmouseover = function(){overObj[el]=true;};
		obj.onmouseout = function(){overObj[el]=false;};
		obj.style.display = "block";
		obj.style.left  = Math.min(eProp["x"],(docWidth-obj.offsetWidth))+"px";
		obj.style.top = eProp["y"]+eProp["h"]+"px";
		if (pos == "top") obj.style.top = eProp["y"]-obj.offsetHeight-5+"px";
		else if (pos == "right") {
			obj.style.left  = Math.min(eProp["x"]+eProp["w"],(docWidth-obj.offsetWidth))+"px";
			obj.style.top = eProp["y"]+"px";
		}
		if (obj.offsetHeight > (document.body.offsetHeight-(eProp["y"]+eProp["h"]))) {
			if (document.body.offsetHeight-(eProp["y"]+eProp["h"]) > 0)
				obj.style.height = Math.min(200,document.body.offsetHeight-(eProp["y"]+eProp["h"]))+"px";
			obj.style.overflow = "auto";
		}
		bringToFront(obj);

		if (clickToClose) {
			document.onmouseup = function(e) {
				for (var m in overObj) {
					if (!overObj[m]) {
						this.onmouseup = null;
						hideObj(m); 
					}
				}
			}
		}
	}
}

function hideObj(el) {
	var obj = $(el);
	if (obj) obj.style.display = "none";
	sendToBack(obj);
}

function getObjectProperties(elObj) {
	var o = elObj;
	var elPos = getObjectPosition(o);
	var objArr = new Array();
	objArr["x"] = elPos["x"];
	objArr["y"] = elPos["y"];
	objArr["h"] = o.offsetHeight;
	objArr["w"] = o.offsetWidth;
	return objArr;
};

function getObjectPosition(elObj) {
	var objRealPos = Position.get(elObj);
	var posArr = new Array();
	posArr["x"] = objRealPos["left"];
	posArr["y"] = objRealPos["top"];
	return posArr;
};


var Position =(function(){function resolveObject(s){if(document.getElementById && document.getElementById(s)!=null){return document.getElementById(s);}else if(document.all && document.all[s]!=null){return document.all[s];}else if(document.anchors && document.anchors.length && document.anchors.length>0 && document.anchors[0].x){for(var i=0;i<document.anchors.length;i++){if(document.anchors[i].name==s){return document.anchors[i]}}}}var pos ={};
pos.set = function(o,left,top){if(typeof(o)=="string"){o = resolveObject(o);}if(o==null || !o.style){return false;}o.style.position = "absolute";if(typeof(left)=="object"){var pos = left;left = pos.left;top = pos.top;}o.style.left = left + "px";o.style.top = top + "px";return true;};
pos.get = function(o){var fixBrowserQuirks = true;if(typeof(o)=="string"){o = resolveObject(o);}if(o==null){return null;}var left = 0;var top = 0;var width = 0;var height = 0;var parentNode = null;var offsetParent = null;offsetParent = o.offsetParent;var originalObject = o;var el = o;while(el.parentNode!=null){el = el.parentNode;if(el.offsetParent==null){}else{var considerScroll = true;if(fixBrowserQuirks && window.opera){if(el==originalObject.parentNode || el.nodeName=="TR"){considerScroll = false;}}if(considerScroll){if(el.scrollTop && el.scrollTop>0){top -= el.scrollTop;}if(el.scrollLeft && el.scrollLeft>0){left -= el.scrollLeft;}}}if(el == offsetParent){left += o.offsetLeft;if(el.clientLeft && el.nodeName!="TABLE"){left += el.clientLeft;}top += o.offsetTop;if(el.clientTop && el.nodeName!="TABLE"){top += el.clientTop;}o = el;if(o.offsetParent==null){if(o.offsetLeft){left += o.offsetLeft;}if(o.offsetTop){top += o.offsetTop;}}offsetParent = o.offsetParent;}}if(originalObject.offsetWidth){width = originalObject.offsetWidth;}if(originalObject.offsetHeight){height = originalObject.offsetHeight;}return{'left':left, 'top':top, 'width':width, 'height':height};};
pos.getCenter = function(o){var c = this.get(o);if(c==null){return null;}c.left = c.left +(c.width/2);c.top = c.top +(c.height/2);return c;};return pos;})();

/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
//tooltip

//General Scripts
var ie = (navigator.userAgent.indexOf('MSIE') != -1);
var moz = !ie && document.getElementById != null && document.layers == null;
var browserIE = ie;
var browserMozilla = moz;
var browserSafari = (navigator.userAgent.indexOf('Safari') != -1);
var browserOpera = (navigator.userAgent.indexOf('Opera') != -1);

var windowLoaded = false;
var filtering = false; //Used when filtering on a list page - flag set so we don't fire the "ENTER" key event
var BreadCrumbs = null;//Track breadcrumb path

var Class = {
  create: function() {
    return function() { 
      this.initialize.apply(this, arguments);
    }
  }
};

Object.extend = function(destination, source) {
  for (property in source) {
    destination[property] = source[property];
  }
  return destination;
};

Function.prototype.bind = function(object) {
  var __method = this;
  return function() {
    return __method.apply(object, arguments);
  }
};

ajax = Class.create();
ajax.prototype = {
	initialize: function(url, options){
		this.transport = this.getTransport();
		this.postBody = options.postBody || '';
		this.method = options.method || 'post';
		this.onComplete = options.onComplete || null;
		this.update = $(options.update) || null;
		this.request(url);
	},

	request: function(url){
		this.transport.open(this.method, url, true);
		this.transport.onreadystatechange = this.onStateChange.bind(this);
		if (this.method == 'post') {
			this.transport.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
			if (this.transport.overrideMimeType) this.transport.setRequestHeader('Connection', 'close');
		}
		this.transport.send(this.postBody);
	},

	onStateChange: function(){
		if (this.transport.readyState == 4 && this.transport.status == 200) {
			if (this.onComplete) 
				setTimeout(function(){this.onComplete(this.transport.responseText);}.bind(this), 10);
			if (this.update)
				setTimeout(function(){this.update.innerHTML = this.transport.responseText;}.bind(this), 10);
			this.transport.onreadystatechange = function(){};
		}
	},

	getTransport: function() {
		if (window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP');
		else if (window.XMLHttpRequest) return new XMLHttpRequest();
		else return false;
	}
};

var remoteXMRequestCounter = 0;
var webServices = new Array();

function WebServiceCall(com,mth,arg,requestid,ss,varFx) {
	var rid = (typeof requestid != "undefined" && requestid != null)?requestid:remoteXMRequestCounter++;
	var styl = (typeof ss != "undefined" && ss != null)?ss:"";
	var xmlStr = '<component '+ ' name="' + com + '"'; 
	xmlStr = xmlStr + ' stylesheet="' + styl + '"'; 
	xmlStr = xmlStr + ' requestid="' + rid + '"'; 
	xmlStr = xmlStr + '>'; 
	xmlStr = xmlStr + '<method name="' + mth + '">'; 
	for (a in arg) { 
		//xmlStr = xmlStr + '<param name="'+a+'" value="'+escape(arg[a].replace('@','_a_'))+'"/>';
		xmlStr = xmlStr + '<param name="'+a+'"><![CDATA['+arg[a]+']]></param>';
		//xmlStr = xmlStr + '<'+a+'><![CDATA['+arg[a]+']]><'+a+'/>';
	}
	xmlStr = xmlStr + '</method>'; 
	xmlStr = xmlStr + '</component>'; 


	var fx = (typeof(varFx) != "undefined")?varFx:this[mth+"_Result"];
	new ajax("/htm/shared/remote.cfm",{method:"post",postBody:"xmlInput="+escape(xmlStr),onComplete: fx});
};

/*===================================================================
 Author: Matt Kruse
 View documentation, examples, and source code at:
     http://www.JavascriptToolbox.com/
 ===================================================================*/
Date.$VERSION = 1.02;
Date.LZ = function(x){return(x<0||x>9?"":"0")+x};Date.monthNames = new Array('January','February','March','April','May','June','July','August','September','October','November','December');Date.monthAbbreviations = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');Date.dayNames = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');Date.dayAbbreviations = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');Date.preferAmericanFormat = true;if(!Date.prototype.getFullYear){Date.prototype.getFullYear = function(){var yy=this.getYear();return(yy<1900?yy+1900:yy);}}
Date.parseString = function(val, format){if(typeof(format)=="undefined" || format==null || format==""){var generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d','MMM-d','d-MMM');var monthFirst=new Array('M/d/y','M-d-y','M.d.y','M/d','M-d');var dateFirst =new Array('d/M/y','d-M-y','d.M.y','d/M','d-M');var checkList=new Array(generalFormats,Date.preferAmericanFormat?monthFirst:dateFirst,Date.preferAmericanFormat?dateFirst:monthFirst);for(var i=0;i<checkList.length;i++){var l=checkList[i];for(var j=0;j<l.length;j++){var d=Date.parseString(val,l[j]);if(d!=null){return d;}}}return null;}
this.isInteger = function(val){for(var i=0;i < val.length;i++){if("1234567890".indexOf(val.charAt(i))==-1){return false;}}return true;};
this.getInt = function(str,i,minlength,maxlength){for(var x=maxlength;x>=minlength;x--){var token=str.substring(i,i+x);if(token.length < minlength){return null;}if(this.isInteger(token)){return token;}}return null;};val=val+"";format=format+"";var i_val=0;var i_format=0;var c="";var token="";var token2="";var x,y;var year=new Date().getFullYear();var month=1;var date=1;var hh=0;var mm=0;var ss=0;var ampm="";while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(token=="yyyy" || token=="yy" || token=="y"){if(token=="yyyy"){x=4;y=4;}if(token=="yy"){x=2;y=2;}if(token=="y"){x=2;y=4;}year=this.getInt(val,i_val,x,y);if(year==null){return null;}i_val += year.length;if(year.length==2){if(year > 70){year=1900+(year-0);}else{year=2000+(year-0);}}}else if(token=="MMM" || token=="NNN"){month=0;var names =(token=="MMM"?(Date.monthNames.concat(Date.monthAbbreviations)):Date.monthAbbreviations);for(var i=0;i<names.length;i++){var month_name=names[i];if(val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()){month=(i%12)+1;i_val += month_name.length;break;}}if((month < 1)||(month>12)){return null;}}else if(token=="EE"||token=="E"){var names =(token=="EE"?Date.dayNames:Date.dayAbbreviations);for(var i=0;i<names.length;i++){var day_name=names[i];if(val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()){i_val += day_name.length;break;}}}else if(token=="MM"||token=="M"){month=this.getInt(val,i_val,token.length,2);if(month==null||(month<1)||(month>12)){return null;}i_val+=month.length;}else if(token=="dd"||token=="d"){date=this.getInt(val,i_val,token.length,2);if(date==null||(date<1)||(date>31)){return null;}i_val+=date.length;}else if(token=="hh"||token=="h"){hh=this.getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>12)){return null;}i_val+=hh.length;}else if(token=="HH"||token=="H"){hh=this.getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>23)){return null;}i_val+=hh.length;}else if(token=="KK"||token=="K"){hh=this.getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>11)){return null;}i_val+=hh.length;hh++;}else if(token=="kk"||token=="k"){hh=this.getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>24)){return null;}i_val+=hh.length;hh--;}else if(token=="mm"||token=="m"){mm=this.getInt(val,i_val,token.length,2);if(mm==null||(mm<0)||(mm>59)){return null;}i_val+=mm.length;}else if(token=="ss"||token=="s"){ss=this.getInt(val,i_val,token.length,2);if(ss==null||(ss<0)||(ss>59)){return null;}i_val+=ss.length;}else if(token=="a"){if(val.substring(i_val,i_val+2).toLowerCase()=="am"){ampm="AM";}else if(val.substring(i_val,i_val+2).toLowerCase()=="pm"){ampm="PM";}else{return null;}i_val+=2;}else{if(val.substring(i_val,i_val+token.length)!=token){return null;}else{i_val+=token.length;}}}if(i_val != val.length){return null;}if(month==2){if( ((year%4==0)&&(year%100 != 0) ) ||(year%400==0) ){if(date > 29){return null;}}else{if(date > 28){return null;}}}if((month==4)||(month==6)||(month==9)||(month==11)){if(date > 30){return null;}}if(hh<12 && ampm=="PM"){hh=hh-0+12;}else if(hh>11 && ampm=="AM"){hh-=12;}return new Date(year,month-1,date,hh,mm,ss);}
Date.isValid = function(val,format){return(Date.parseString(val,format) != null);}
Date.prototype.isBefore = function(date2){if(date2==null){return false;}return(this.getTime()<date2.getTime());}
Date.prototype.isAfter = function(date2){if(date2==null){return false;}return(this.getTime()>date2.getTime());}
Date.prototype.equals = function(date2){if(date2==null){return false;}return(this.getTime()==date2.getTime());}
Date.prototype.equalsIgnoreTime = function(date2){if(date2==null){return false;}var d1 = new Date(this.getTime()).clearTime();var d2 = new Date(date2.getTime()).clearTime();return(d1.getTime()==d2.getTime());}
Date.prototype.format = function(format){format=format+"";var result="";var i_format=0;var c="";var token="";var y=this.getYear()+"";var M=this.getMonth()+1;var d=this.getDate();var E=this.getDay();var H=this.getHours();var m=this.getMinutes();var s=this.getSeconds();var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;var value=new Object();if(y.length < 4){y=""+(+y+1900);}value["y"]=""+y;value["yyyy"]=y;value["yy"]=y.substring(2,4);value["M"]=M;value["MM"]=Date.LZ(M);value["MMM"]=Date.monthNames[M-1];value["NNN"]=Date.monthAbbreviations[M-1];value["d"]=d;value["dd"]=Date.LZ(d);value["E"]=Date.dayAbbreviations[E];value["EE"]=Date.dayNames[E];value["H"]=H;value["HH"]=Date.LZ(H);if(H==0){value["h"]=12;}else if(H>12){value["h"]=H-12;}else{value["h"]=H;}value["hh"]=Date.LZ(value["h"]);value["K"]=value["h"]-1;value["k"]=value["H"]+1;value["KK"]=Date.LZ(value["K"]);value["kk"]=Date.LZ(value["k"]);if(H > 11){value["a"]="PM";}else{value["a"]="AM";}value["m"]=m;value["mm"]=Date.LZ(m);value["s"]=s;value["ss"]=Date.LZ(s);while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(typeof(value[token])!="undefined"){result=result + value[token];}else{result=result + token;}}return result;}
Date.prototype.getDayName = function(){return Date.dayNames[this.getDay()];}
Date.prototype.getDayAbbreviation = function(){return Date.dayAbbreviations[this.getDay()];}
Date.prototype.getMonthName = function(){return Date.monthNames[this.getMonth()];}
Date.prototype.getMonthAbbreviation = function(){return Date.monthAbbreviations[this.getMonth()];}
Date.prototype.clearTime = function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);
return this;}
Date.prototype.add = function(interval, number){if(typeof(interval)=="undefined" || interval==null || typeof(number)=="undefined" || number==null){
return this;}number = +number;if(interval=='y'){this.setFullYear(this.getFullYear()+number);}else if(interval=='M'){this.setMonth(this.getMonth()+number);}else if(interval=='d'){this.setDate(this.getDate()+number);}else if(interval=='w'){var step =(number>0)?1:-1;while(number!=0){this.add('d',step);while(this.getDay()==0 || this.getDay()==6){this.add('d',step);}number -= step;}}else if(interval=='h'){this.setHours(this.getHours() + number);}else if(interval=='m'){this.setMinutes(this.getMinutes() + number);}else if(interval=='s'){this.setSeconds(this.getSeconds() + number);}
return this;}

var CGI = new Array(); CGI.script_name = location.href; CGI.http_host = location.host; CGI.query_string = document.location.search; var URL = new Array(); var queryString = document.location.search; if (queryString.length > 1) { var nmValPairs = queryString.substring(1,queryString.length); for (var q=1;q <= ListLen(nmValPairs,"&");q++) { var nmVal = ListGetAt(nmValPairs,q,"&"); URL[ListFirst(nmVal,"=")] = ListLast(nmVal,"=");}
}
function getURL(str) { return (typeof(URL[str]) != "undefined")?URL[str]:"";}
function getCookie(name) { if (document.cookie) { var cookies=document.cookie.split(";"); for (var i=0; i<cookies.length; i++) { var varName=(cookies[i].split("=")[0]); var varValue=(cookies[i].split("=")[1]); while (varName.charAt(0)==" ")
varName=varName.substr(1,varName.length); if (varName.toLowerCase()==name.toLowerCase())
return varValue;}
}
return "";}
function TRIM(strValue) { var objRegExp = /^(\s*)$/; if(objRegExp.test(strValue)) { strValue = strValue.replace(objRegExp, ''); if( strValue.length == 0) return strValue;}
objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/; if(objRegExp.test(strValue)) { strValue = strValue.replace(objRegExp, '$2');}
return strValue;}
function XMLFormat(xmlStr) { var regEx = new RegExp("\r\n","ig"); xmlStr = TRIM(xmlStr); var xml = "<![CDATA["+xmlStr.replace(regEx, "<br>")+"]]>"; return xml;}
function ListFind(lst,val,del) { var lstArr = lst.split(del); var fnd = 0; for (var a=0;a<lstArr.length;a++) { if (lstArr[a] == val) { fnd = a+1; break;}
}
return fnd;}
function ListFindNoCase(lst,val,del) { var lstArr = lst.split(del); var fnd = 0; for (var a=0;a<lstArr.length;a++) { if (lstArr[a].toLowerCase() == val.toLowerCase()) { fnd = a+1; break;}
}
return fnd;}
function getLeadingZero(nbr) {var nr = nbr;var nrStr = ""+nbr;if (nr < 10 && nrStr.length == 1) nr = "0"+nr;return nr;}
function ListToArray(lst,del) { return lst.split(del);}
function ArrayToList(arr,del) { return arr.join(del);}
function Val(nbr) { return (isNaN(nbr) || nbr == "")?0:parseFloat(nbr);}
function ListAppend(lst,val,del) { var del=del?del:",";if (lst == "") return val; var lstArr = ListToArray(lst,del); lstArr[lstArr.length] = val; var newlst = ArrayToList(lstArr,del); return newlst;}
function ListLen(lst,del) { var del=del?del:",";var lstArr = lst.split(del); return lstArr.length;}
function ListDeleteAt(lst,pos,del) { var del=del?del:",";var lstArr = lst.split(del); remArr = lstArr.splice(pos-1,1); var newlst = ArrayToList(lstArr,del); return newlst;}
function ListGetAt(lst,pos,del) { var del=del?del:",";var lstArr = lst.split(del); return lstArr[pos-1];}
function ListLast(lst,del) { var del=del?del:",";return ListGetAt(lst,ListLen(lst,del),del);}
function ListFirst(lst,del) {var del=del?del:","; return ListGetAt(lst,1,del);}
function NumberFormat(num) { return FormatNumber(num,0);}
function DecimalFormat(num) { return FormatNumber(num,2);}
function FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas) { if (isNaN(parseInt(num))) return "NaN"; var tmpNum = num; var iSign = num < 0 ? -1 : 1; tmpNum *= Math.pow(10,decimalNum); tmpNum = Math.round(Math.abs(tmpNum));tmpNum /= Math.pow(10,decimalNum); tmpNum *= iSign; var tmpNumStr = new String(tmpNum); if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
if (num > 0)
tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length); else
tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length); if (bolCommas && (num >= 1000 || num <= -1000)) { var iStart = tmpNumStr.indexOf("."); if (iStart < 0)
iStart = tmpNumStr.length; iStart -= 3; while (iStart >= 1) { tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
iStart -= 3;}
}
if (bolParens && num < 0) tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")"; return tmpNumStr;}
function isDate(p_Expression){ return !isNaN(new Date(p_Expression));}
function dateAdd(p_Interval, p_Number, p_Date){ if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
if(isNaN(p_Number)){return "invalid number: '" + p_Number + "'";}
p_Number = new Number(p_Number); var dt = new Date(p_Date); switch(p_Interval.toLowerCase()){ case "yyyy": { dt.setFullYear(dt.getFullYear() + p_Number); break;}
case "q": { dt.setMonth(dt.getMonth() + (p_Number*3)); break;}
case "m": { dt.setMonth(dt.getMonth() + p_Number); break;}
case "y":
case "d":
case "w": { dt.setDate(dt.getDate() + p_Number); break;}
case "ww": { dt.setDate(dt.getDate() + (p_Number*7)); break;}
case "h": { dt.setHours(dt.getHours() + p_Number); break;}
case "n": { dt.setMinutes(dt.getMinutes() + p_Number); break;}
case "s": { dt.setSeconds(dt.getSeconds() + p_Number); break;}
case "ms": { dt.setMilliseconds(dt.getMilliseconds() + p_Number); break;}
default: { return "invalid interval: '" + p_Interval + "'";}
}
return dt;}
function dateDiff(p_Interval, p_Date1, p_Date2, p_firstdayofweek, p_firstweekofyear){ if(!isDate(p_Date1)){return "invalid date: '" + p_Date1 + "'";}
if(!isDate(p_Date2)){return "invalid date: '" + p_Date2 + "'";}
var dt1 = new Date(p_Date1); var dt2 = new Date(p_Date2); var iDiffMS = dt2.valueOf() - dt1.valueOf(); var dtDiff = new Date(iDiffMS); var nYears = dtDiff.getUTCFullYear()-1970; var nMonths = dtDiff.getUTCMonth() + (nYears!=0 ? nYears*12 : 0); var nQuarters = parseInt(nMonths/3); var nWeeks = parseInt(iDiffMS/1000/60/60/24/7); var nDays = parseInt(iDiffMS/1000/60/60/24); var nHours = parseInt(iDiffMS/1000/60/60); var nMinutes = parseInt(iDiffMS/1000/60); var nSeconds= parseInt(iDiffMS/1000); var nMilliseconds = iDiffMS; var iDiff = 0; switch(p_Interval.toLowerCase()){ case "yyyy": return nYears; case "q": return nQuarters; case "m": return nMonths; case "y":
case "d": return nDays; case "w": return nDays; case "ww":return nWeeks; case "h": return nHours; case "n": return nMinutes; case "s": return nSeconds; case "ms":return nMilliseconds; default: return "invalid interval: '" + p_Interval + "'";}
}
function datePart(p_Interval, p_Date, p_firstdayofweek, p_firstweekofyear){ if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
var dtPart = new Date(p_Date); switch(p_Interval.toLowerCase()){ case "yyyy": return dtPart.getFullYear(); case "q": return parseInt(dtPart.getMonth()/3)+1; case "m": return dtPart.getMonth()+1; case "y": return dateDiff("y", "1/1/" + dtPart.getFullYear(), dtPart); case "d": return dtPart.getDate(); case "w": return dtPart.getDay(); case "ww":return dateDiff("ww", "1/1/" + dtPart.getFullYear(), dtPart); case "h": return dtPart.getHours(); case "n": return dtPart.getMinutes(); case "s": return dtPart.getSeconds(); case "ms":return dtPart.getMilliseconds(); default: return "invalid interval: '" + p_Interval + "'";}
}
function weekdayName(p_Date, p_abbreviate){ if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
var dt = new Date(p_Date); var retVal = dt.toString().split(' ')[0]; var retVal = Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')[dt.getDay()]; if(p_abbreviate==true){retVal = retVal.substring(0, 3)}
return retVal;}
function monthName(p_Date, p_abbreviate){ if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
var dt = new Date(p_Date); var retVal = Array('January','February','March','April','May','June','July','August','September','October','November','December')[dt.getMonth()]; if(p_abbreviate==true){retVal = retVal.substring(0, 3)}
return retVal;}
function IsDate(p_Expression){ return isDate(p_Expression);}
function DateAdd(p_Interval, p_Number, p_Date){ return dateAdd(p_Interval, p_Number, p_Date);}
function DateDiff(p_interval, p_date1, p_date2, p_firstdayofweek, p_firstweekofyear){ return dateDiff(p_interval, p_date1, p_date2, p_firstdayofweek, p_firstweekofyear);}
function DatePart(p_Interval, p_Date, p_firstdayofweek, p_firstweekofyear){ return datePart(p_Interval, p_Date, p_firstdayofweek, p_firstweekofyear);}
function WeekdayName(p_Date){ return weekdayName(p_Date);}
function MonthName(p_Date){ return monthName(p_Date);}
function DateTimeFormat(dt) {return getLeadingZero(DatePart("m",dt))+"/"+getLeadingZero(DatePart("d",dt))+"/"+DatePart("yyyy",dt)+" "+getLeadingZero(DatePart("h",dt))+":"+getLeadingZero(DatePart("n",dt));}

/* Duplicating rows */

var dynCounter = new Object();

function createDynRow(ind,prefix) {
	var tblObj = $(prefix+"_table");
	var rowSrc = tblObj.tBodies[ind].rows[0];
	var rowDest = rowSrc.cloneNode(true);
	if (typeof dynCounter[prefix] == "undefined") dynCounter[prefix] = 0;
	rowDest.style.display = "block";
	//Update the clone to have its own identity.
	tblObj.tBodies[ind].appendChild(rowDest);
	var a = document.createElement("span");
	a.innerHTML = "<img src='../lib/img/icon/icon_delete.gif' alt='Delete' border='0' align='absmiddle'> Delete";
	a.onclick = function() {deleteDynRow(rowDest,ind,prefix);};
	rowDest.cells[rowDest.cells.length-1].appendChild(a);
	var cntr = ++dynCounter[prefix];
	rowDest.id = prefix+"_Row"+cntr;
	//get input boxes so we can rename them
	var inBoxes = rowDest.getElementsByTagName("INPUT");
	for (var i=0;i<inBoxes.length;i++) {
		var prvNm = inBoxes[i].name;
		inBoxes[i].name = prvNm+"_"+cntr;
		inBoxes[i].id = prvNm+"_"+cntr;
		if (inBoxes[i].type == "checkbox") inBoxes[i].checked = false;
		else if (inBoxes[i].type == "text") inBoxes[i].value = "";
	}
	var tsrows = $(prefix+"_rows");
	tsrows.value = ListAppend(tsrows.value,cntr,",");
}

function deleteDynRow(obj,ind,prefix) {
	var tsrows = $(prefix+"_rows");
	tsrows.value = ListDeleteAt(tsrows.value,ListFind(tsrows.value,obj.id.replace(prefix+"_Row",""),","),",");
	var tblObj = $(prefix+"_table");
	tblObj.tBodies[0].removeChild(obj);
}

function getParentElement(obj,parentTag) {
	var parObj = (obj.parentNode)?obj.parentNode:obj.parentElement;
	var nestedLimit = 50;
	var counter = 0;
	while(parObj.tagName && parObj.tagName.toLowerCase() != parentTag.toLowerCase()) {
		counter++;
		parObj=parObj.parentNode;
		if (counter > nestedLimit) break;
	}
	return parObj;
}

function printObject(obj,width,height) {
	openNewWindow("/modules/portal/print_object.cfm?id="+obj.id,"PrintMode",width,height,"yes");
}

function loadQuickTime(id,width,height,src) {
	var str = "";
	str = str + '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="'+height+'" width="'+width+'" id="'+id+'">'; 
	str = str + '<param name="cache" value="false">'; 
	str = str + '<param name="kioskmode" value="true">'; 
	str = str + '<param name="enablejavascript" value="true">'; 
	str = str + '<param name="src" value="'+src+'">';
	str = str + '<param name="autoplay" value="false">';
	str = str + '<param name="controller" value="true">';
	str = str + '<embed height="'+height+'" pluginspage="http://www.apple.com/quicktime/download/" src="'+src+'" type="video/quicktime" width="'+width+'" controller="true" autoplay="false" enablejavascript="true" kioskmode="true" name="'+id+'" cache="false">';
	str = str + '</object>';
	return str;
}

function ValidatePassword(frm) {
	var ret = true;
	/*var msg = "";
	var regexCaps = /[A-Z]/;
	var objRegExp = eval(regexCaps);
	var capsCount = 0;
	for (var i=0;i<frm.password.value.length;i++) {
		if (objRegExp.test(frm.password.value.substring(i))) capsCount++;
	}


	var regexLC = /[a-z]/;
	var objRegExpLC = eval(regexLC);
	var lCaseCount = 0;
	for (var i=0;i<frm.password.value.length;i++) {
		if (objRegExpLC.test(frm.password.value.substring(i))) lCaseCount++;
	}

	var regexNum = /[0-9]/;
	var objRegExpNum = eval(regexNum);
	var numCount = 0;
	for (var i=0;i<frm.password.value.length;i++) {
		if (objRegExpNum.test(frm.password.value.substring(i))) numCount++;
	}

	//Check form confirm password
	if (frm.password.value != frm.confirm_password.value) {
		msg = "Your passwords do not match";
		ret = false;
	} else if (frm.password.value.length < 8) {
		msg = "Your password must be at least 8 characters in length";
		ret = false;
	} else if (capsCount < 1) {
		msg = "Your password must contain at least 1 capital letter";
		ret = false;
	} else if (lCaseCount < 1) {
		msg = "Your password must contain at least 1 lower case letter";
		ret = false;
	} else if (numCount < 3) {
		msg = "Your password must contain at least 3 numberic characters";
		ret = false;
	}
	
	
	if (msg != "") {
		alert(msg);
	}*/
	return ret;
}

addEvent(window,"load",function(){globalOnload();});

