


	//
	// A function for onclicks to use the values of radio Buttons
	//

    	function getRadioValue(radioGroupName) {
	        radios = document.getElementsByName(radioGroupName);
	        for (i = 0; i < radios.length; i++) {     
		        if (radios[i].checked) return radios[i].value;
	                }
	        }
	

	//
	// A function for listMask stuff to not show titles of things not checked
	//

        function setTemplateOption() {
                var args = setTemplateOption.arguments;
                for (var i = 1; i < args.length; i++) {
                        document.getElementById(args[i]).style.display = args[0].checked ? '' : 'none';
                }
        }
 
	//
	// Toolmans code we use for ordring lists of data. Thanks for the sweet stuff Tim! You saved us some time.
	//

// #########################################################################
// imaage gallery tool
// #########################################################################
/***********************************************
* CMotion Image Gallery- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for source code
* This copyright notice must stay intact for legal use
* Modified for autowidth and optional starting positions in
* http://www.dynamicdrive.com/forums/showthread.php?t=11839 by jschuer1 8/5/06
***********************************************/

 //1) Set width of the "neutral" area in the center of the gallery.
var restarea=6;
 //2) Set top scroll speed in pixels. Script auto creates a range from 0 to top speed.
var maxspeed=4;
 //3) Set to maximum width for gallery - must be less than the actual length of the image train.
var maxwidth=1000;
 //4) Set to 1 for left start, 0 for right, 2 for center.
var startpos=0;
 //5) Set message to show at end of gallery. Enter "" to disable message.
var endofgallerymsg='<span style="font-size: 11px;">End of Gallery</span>';

function enlargeimage(path, optWidth, optHeight){ //function to enlarge image. Change as desired.
var actualWidth=typeof optWidth!="undefined" ? optWidth : "600px" //set 600px to default width
var actualHeight=typeof optHeight!="undefined" ? optHeight : "500px" //set 500px to  default height
var winattributes="width="+actualWidth+",height="+actualHeight+",resizable=yes"
window.open(path,"", winattributes)
}

////NO NEED TO EDIT BELOW THIS LINE////////////

var iedom=document.all||document.getElementById, scrollspeed=0, movestate='', actualwidth='', cross_scroll, ns_scroll, statusdiv, loadedyes=0, lefttime, righttime;

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function creatediv(){
statusdiv=document.createElement("div")
statusdiv.setAttribute("id","statusdiv")
document.body.appendChild(statusdiv)
statusdiv=document.getElementById("statusdiv")
statusdiv.innerHTML=endofgallerymsg
}

function positiondiv(){
var mainobjoffset=getposOffset(crossmain, "left"),
menuheight=parseInt(crossmain.offsetHeight),
mainobjoffsetH=getposOffset(crossmain, "top");
statusdiv.style.left=mainobjoffset+(menuwidth/2)-(statusdiv.offsetWidth/2)+"px";
statusdiv.style.top=menuheight+mainobjoffsetH+"px";
}

function showhidediv(what){
if (endofgallerymsg!="") {
positiondiv();
statusdiv.style.visibility=what;
}
}

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft: what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function moveleft(){
if (loadedyes){
movestate="left";
if (iedom&&parseInt(cross_scroll.style.left)>(menuwidth-actualwidth)){
cross_scroll.style.left=parseInt(cross_scroll.style.left)-scrollspeed+"px";
showhidediv("hidden");
}
else
showhidediv("visible");
}
lefttime=setTimeout("moveleft()",10);
}

function moveright(){
if (loadedyes){
movestate="right";
if (iedom&&parseInt(cross_scroll.style.left)<0){
cross_scroll.style.left=parseInt(cross_scroll.style.left)+scrollspeed+"px";
showhidediv("hidden");
}
else
showhidediv("visible");
}
righttime=setTimeout("moveright()",10);
}

function motionengine(e){
var mainobjoffset=getposOffset(crossmain, "left"),
dsocx=(window.pageXOffset)? pageXOffset: ietruebody().scrollLeft,
dsocy=(window.pageYOffset)? pageYOffset : ietruebody().scrollTop,
curposy=window.event? event.clientX : e.clientX? e.clientX: "";
curposy-=mainobjoffset-dsocx;
var leftbound=(menuwidth-restarea)/2;
var rightbound=(menuwidth+restarea)/2;
if (curposy>rightbound){
scrollspeed=(curposy-rightbound)/((menuwidth-restarea)/2) * maxspeed;
clearTimeout(righttime);
if (movestate!="left") moveleft();
}
else if (curposy<leftbound){
scrollspeed=(leftbound-curposy)/((menuwidth-restarea)/2) * maxspeed;
clearTimeout(lefttime);
if (movestate!="right") moveright();
}
else
scrollspeed=0;
}

function contains_ns6(a, b) {
if (b!==null)
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function stopmotion(e){
if (!window.opera||(window.opera&&e.relatedTarget!==null))
if ((window.event&&!crossmain.contains(event.toElement)) || (e && e.currentTarget && e.currentTarget!= e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget))){
clearTimeout(lefttime);
clearTimeout(righttime);
movestate="";
}
}

function fillup(){
if (iedom){
crossmain=document.getElementById? document.getElementById("motioncontainer") : document.all.motioncontainer;
if(typeof crossmain.style.maxWidth!=='undefined')
crossmain.style.maxWidth=maxwidth+'px';
menuwidth=crossmain.offsetWidth;
cross_scroll=document.getElementById? document.getElementById("motiongallery") : document.all.motiongallery;
actualwidth=document.getElementById? document.getElementById("trueContainer").offsetWidth : document.all['trueContainer'].offsetWidth;
if (startpos)
cross_scroll.style.left=(menuwidth-actualwidth)/startpos+'px';
crossmain.onmousemove=function(e){
motionengine(e);
}

crossmain.onmouseout=function(e){
stopmotion(e);
showhidediv("hidden");
}
}
loadedyes=1
if (endofgallerymsg!=""){
creatediv();
positiondiv();
}


// REMOVED BECAUSE IT WOULD GIVE ERROS ON RESIZING any page on the GNF.  Don't think its used with the scroller

//if (document.body.filters)
//onresize()
}

//onresize=function(){
//if (typeof motioncontainer!=='undefined'&&motioncontainer.filters){
//motioncontainer.style.width="0";
//motioncontainer.style.width="";
//motioncontainer.style.width=Math.min(motioncontainer.offsetWidth, maxwidth)+'px';
//}
//menuwidth=crossmain.offsetWidth;
//cross_scroll.style.left=startpos? (menuwidth-actualwidth)/startpos+'px' : 0;
//}



//GNF ADD

function setImage(img,site,product,file,prevFile,nextFile){
        var url;
        url = "/v4files/"+site+"/gallery/"+product+"/"+file;
        //document[img].src=url;
        document.getElementById(img).src=url;
        }






//Copyright (c) 2005 Tim Taylor Consulting http://tool-man.org
//
//Permission is hereby granted, free of charge, to any person obtaining a
//copy of this software and associated documentation files (the "Software"),
//to deal in the Software without restriction, including without limitation
//the rights to use, copy, modify, merge, publish, distribute, sublicense,
//andor sell copies of the Software, and to permit persons to whom the
//Software is furnished to do so, subject to the following conditions//:


var ToolMan = {
	events : function() {
		if (!ToolMan._eventsFactory) throw "ToolMan Events module isn't loaded";
		return ToolMan._eventsFactory
	},

	css : function() {
		if (!ToolMan._cssFactory) throw "ToolMan CSS module isn't loaded";
		return ToolMan._cssFactory
	},

	coordinates : function() {
		if (!ToolMan._coordinatesFactory) throw "ToolMan Coordinates module isn't loaded";
		return ToolMan._coordinatesFactory
	},

	drag : function() {
		if (!ToolMan._dragFactory) throw "ToolMan Drag module isn't loaded";
		return ToolMan._dragFactory
	},

	dragsort : function() {
		if (!ToolMan._dragsortFactory) throw "ToolMan DragSort module isn't loaded";
		return ToolMan._dragsortFactory
	},

	helpers : function() {
		return ToolMan._helpers
	},

	junkdrawer : function() {
		return ToolMan._junkdrawer
	}

}

ToolMan._helpers = {
	map : function(array, func) {
		for (var i = 0, n = array.length; i < n; i++) func(array[i])
	},

	nextItem : function(item, nodeName) {
		if (item == null) return
		var next = item.nextSibling
		while (next != null) {
			if (next.nodeName == nodeName) return next
			next = next.nextSibling
		}
		return null
	},

	previousItem : function(item, nodeName) {
		var previous = item.previousSibling
		while (previous != null) {
			if (previous.nodeName == nodeName) return previous
			previous = previous.previousSibling
		}
		return null
	},

	moveBefore : function(item1, item2) {
		var parent = item1.parentNode
		parent.removeChild(item1)
		parent.insertBefore(item1, item2)
	},

	moveAfter : function(item1, item2) {
		var parent = item1.parentNode
		parent.removeChild(item1)
		parent.insertBefore(item1, item2 ? item2.nextSibling : null)
	}
}

/** 
 * scripts without a proper home
 *
 * stuff here is subject to change unapologetically and without warning
 */
ToolMan._junkdrawer = {
	serializeList : function(list) {
                var itemsPreParse = document.getElementsByTagName("div");
                var items = new Array();
                for (var i = 0; i < itemsPreParse.length; i++) {
                        if (!itemsPreParse[i].id.search('catLine')) {items.push(itemsPreParse[i]);} 
                        if (!itemsPreParse[i].id.search('proLine')) {items.push(itemsPreParse[i]);} 
                        if (!itemsPreParse[i].id.search('listLine')) {items.push(itemsPreParse[i]);} 
                        if (!itemsPreParse[i].id.search('workLine')) {items.push(itemsPreParse[i]);} 
                        }             
                
	//	var items = list.getElementsByTagName("div")
		var array = new Array()
		for (var i = 0, n = items.length; i < n; i++) {
			var item = items[i]
			array.push(ToolMan.junkdrawer()._identifier(item))
		}
		return array.join('|')
	},

	inspectListOrder : function(id) {
                submitRequest(scriptPath+queryHead+'&parentId='+document.getElementById('parentId').value+'&returnStatusNote=1&pageAction=reorderItems&itemOrder='+ ToolMan.junkdrawer().serializeList(document.getElementById(id)));
	},

	_identifier : function(item) {
		var trim = ToolMan.junkdrawer().trim
		var identifier

		identifier = trim(item.getAttribute("id"))
		if (identifier != null && identifier.length > 0) return identifier;
		
		identifier = trim(item.getAttribute("itemID"))
		if (identifier != null && identifier.length > 0) return identifier;
		
		// FIXME: strip out special chars or make this an MD5 hash or something
		return trim(item.innerHTML)
	},

	_itemsByID : function(list) {
		var array = new Array()
	        var itemsPreParse = document.getElementsByTagName("div");
                var items = new Array();
                for (var i = 0; i < itemsPreParse.length; i++) {
                        if (!itemsPreParse[i].id.search('catLine')) {items.push(itemsPreParse[i]);} 
                        if (!itemsPreParse[i].id.search('proLine')) {items.push(itemsPreParse[i]);} 
                        if (!itemsPreParse[i].id.search('listLine')) {items.push(itemsPreParse[i]);} 
                        if (!itemsPreParse[i].id.search('workLine')) {items.push(itemsPreParse[i]);} 
                        }             
                
		//var items = list.getElementsByTagName('div')
		for (var i = 0, n = items.length; i < n; i++) {
			var item = items[i]
			array[ToolMan.junkdrawer()._identifier(item)] = item
		}
		return array
	},

	trim : function(text) {
		if (text == null) return null
		return text.replace(/^(\s+)?(.*\S)(\s+)?$/, '$2')
	}
}


ToolMan._cssFactory = {
	readStyle : function(element, property) {
		if (element.style[property]) {
			return element.style[property]
		} else if (element.currentStyle) {
			return element.currentStyle[property]
		} else if (document.defaultView && document.defaultView.getComputedStyle) {
			var style = document.defaultView.getComputedStyle(element, null)
			return style.getPropertyValue(property)
		} else {
			return null
		}
	}
}


/* Copyright (c) 2005 Tim Taylor Consulting (see LICENSE.txt) */

ToolMan._eventsFactory = {
	fix : function(event) {
		if (!event) event = window.event

		if (event.target) {
			if (event.target.nodeType == 3) event.target = event.target.parentNode
		} else if (event.srcElement) {
			event.target = event.srcElement
		}

		return event
	},

	register : function(element, type, func) {
		if (element.addEventListener) {
			element.addEventListener(type, func, false)
		} else if (element.attachEvent) {
			if (!element._listeners) element._listeners = new Array()
			if (!element._listeners[type]) element._listeners[type] = new Array()
			var workaroundFunc = function() {
				func.apply(element, new Array())
			}
			element._listeners[type][func] = workaroundFunc
			element.attachEvent('on' + type, workaroundFunc)
		}
	},

	unregister : function(element, type, func) {
		if (element.removeEventListener) {
			element.removeEventListener(type, func, false)
		} else if (element.detachEvent) {
			if (element._listeners 
					&& element._listeners[type] 
					&& element._listeners[type][func]) {

				element.detachEvent('on' + type, 
						element._listeners[type][func])
			}
		}
	}
}



/* Copyright (c) 2005 Tim Taylor Consulting (see LICENSE.txt) */

/* FIXME: assumes position styles are specified in 'px' */

ToolMan._coordinatesFactory = {

	create : function(x, y) {
		// FIXME: Safari won't parse 'throw' and aborts trying to do anything with this file
		//if (isNaN(x) || isNaN(y)) throw "invalid x,y: " + x + "," + y
		return new _ToolManCoordinate(this, x, y)
	},

	origin : function() {
		return this.create(0, 0)
	},

	/*
	 * FIXME: Safari 1.2, returns (0,0) on absolutely positioned elements
	 */
	topLeftPosition : function(element) {
		var left = parseInt(ToolMan.css().readStyle(element, "left"))
		var left = isNaN(left) ? 0 : left
		var top = parseInt(ToolMan.css().readStyle(element, "top"))
		var top = isNaN(top) ? 0 : top

		return this.create(left, top)
	},

	bottomRightPosition : function(element) {
		return this.topLeftPosition(element).plus(this._size(element))
	},

	topLeftOffset : function(element) {
		var offset = this._offset(element) 

		var parent = element.offsetParent
		while (parent) {
			offset = offset.plus(this._offset(parent))
			parent = parent.offsetParent
		}
		return offset
	},

	bottomRightOffset : function(element) {
		return this.topLeftOffset(element).plus(
				this.create(element.offsetWidth, element.offsetHeight))
	},

	scrollOffset : function() {
		if (window.pageXOffset) {
			return this.create(window.pageXOffset, window.pageYOffset)
		} else if (document.documentElement) {
			return this.create(
					document.body.scrollLeft + document.documentElement.scrollLeft, 
					document.body.scrollTop + document.documentElement.scrollTop)
		} else if (document.body.scrollLeft >= 0) {
			return this.create(document.body.scrollLeft, document.body.scrollTop)
		} else {
			return this.create(0, 0)
		}
	},

	clientSize : function() {
		if (window.innerHeight >= 0) {
			return this.create(window.innerWidth, window.innerHeight)
		} else if (document.documentElement) {
			return this.create(document.documentElement.clientWidth,
					document.documentElement.clientHeight)
		} else if (document.body.clientHeight >= 0) {
			return this.create(document.body.clientWidth,
					document.body.clientHeight)
		} else {
			return this.create(0, 0)
		}
	},

	/**
	 * mouse coordinate relative to the window (technically the
	 * browser client area) i.e. the part showing your page
	 *
	 * NOTE: in Safari the coordinate is relative to the document
	 */
	mousePosition : function(event) {
		event = ToolMan.events().fix(event)
		return this.create(event.clientX, event.clientY)
	},

	/**
	 * mouse coordinate relative to the document
	 */
	mouseOffset : function(event) {
		event = ToolMan.events().fix(event)
		if (event.pageX >= 0 || event.pageX < 0) {
			return this.create(event.pageX, event.pageY)
		} else if (event.clientX >= 0 || event.clientX < 0) {
			return this.mousePosition(event).plus(this.scrollOffset())
		}
	},

	_size : function(element) {
	/* TODO: move to a Dimension class */
		return this.create(element.offsetWidth, element.offsetHeight)
	},

	_offset : function(element) {
		return this.create(element.offsetLeft, element.offsetTop)
	}
}

function _ToolManCoordinate(factory, x, y) {
	this.factory = factory
	this.x = isNaN(x) ? 0 : x
	this.y = isNaN(y) ? 0 : y
}

_ToolManCoordinate.prototype = {
	toString : function() {
		return "(" + this.x + "," + this.y + ")"
	},

	plus : function(that) {
		return this.factory.create(this.x + that.x, this.y + that.y)
	},

	minus : function(that) {
		return this.factory.create(this.x - that.x, this.y - that.y)
	},

	min : function(that) {
		return this.factory.create(
				Math.min(this.x , that.x), Math.min(this.y , that.y))
	},

	max : function(that) {
		return this.factory.create(
				Math.max(this.x , that.x), Math.max(this.y , that.y))
	},

	constrainTo : function (one, two) {
		var min = one.min(two)
		var max = one.max(two)

		return this.max(min).min(max)
	},

	distance : function (that) {
		return Math.sqrt(Math.pow(this.x - that.x, 2) + Math.pow(this.y - that.y, 2))
	},

	reposition : function(element) {
		element.style["top"] = this.y + "px"
		element.style["left"] = this.x + "px"
	}
}

/* Copyright (c) 2005 Tim Taylor Consulting (see LICENSE.txt) */

ToolMan._dragFactory = {
	createSimpleGroup : function(element, handle) {
		handle = handle ? handle : element
		var group = this.createGroup(element)
		group.setHandle(handle)
		group.transparentDrag()
		group.onTopWhileDragging()
		return group
	},

	createGroup : function(element) {
		var group = new _ToolManDragGroup(this, element)

		var position = ToolMan.css().readStyle(element, 'position')
		if (position == 'static') {
			element.style["position"] = 'relative'
		} else if (position == 'absolute') {
			/* for Safari 1.2 */
			ToolMan.coordinates().topLeftOffset(element).reposition(element)
		}

		// TODO: only if ToolMan.isDebugging()
		group.register('draginit', this._showDragEventStatus)
		group.register('dragmove', this._showDragEventStatus)
		group.register('dragend', this._showDragEventStatus)

		return group
	},

	_showDragEventStatus : function(dragEvent) {
		window.status = dragEvent.toString()
	},

	constraints : function() {
		return this._constraintFactory
	},

	_createEvent : function(type, event, group) {
		return new _ToolManDragEvent(type, event, group)
	}
}

function _ToolManDragGroup(factory, element) {
	this.factory = factory
	this.element = element
	this._handle = null
	this._thresholdDistance = 0
	this._transforms = new Array()
	// TODO: refactor into a helper object, move into events.js
	this._listeners = new Array()
	this._listeners['draginit'] = new Array()
	this._listeners['dragstart'] = new Array()
	this._listeners['dragmove'] = new Array()
	this._listeners['dragend'] = new Array()
}

_ToolManDragGroup.prototype = {
	/*
	 * TODO:
	 *   - unregister(type, func)
	 *   - move custom event listener stuff into Event library
	 *   - keyboard nudging of "selected" group
	 */

	setHandle : function(handle) {
		var events = ToolMan.events()
		handle.toolManDragGroup = this
		events.register(handle, 'mousedown', this._dragInit)
		handle.onmousedown = function() { return false }
		this.addTransform(this.factory.constraints().vertical())

		if (this.element != handle)
			events.unregister(this.element, 'mousedown', this._dragInit)
	},

	register : function(type, func) {
		this._listeners[type].push(func)
	},

	addTransform : function(transformFunc) {
		this._transforms.push(transformFunc)
	},

	verticalOnly : function() {
		this.addTransform(this.factory.constraints().vertical())
	},

	horizontalOnly : function() {
		this.addTransform(this.factory.constraints().horizontal())
	},

	setThreshold : function(thresholdDistance) {
		this._thresholdDistance = thresholdDistance
	},

	transparentDrag : function(opacity) {
		var opacity = typeof(opacity) != "undefined" ? opacity : 0.75;
		var originalOpacity = ToolMan.css().readStyle(this.element, "opacity")

		this.register('dragstart', function(dragEvent) {
			var element = dragEvent.group.element
			element.style.opacity = opacity
			element.style.filter = 'alpha(opacity=' + (opacity * 100) + ')'
		})
		this.register('dragend', function(dragEvent) {
			var element = dragEvent.group.element
			element.style.opacity = originalOpacity
			element.style.filter = 'alpha(opacity=100)'
		})
	},

	onTopWhileDragging : function(zIndex) {
		var zIndex = typeof(zIndex) != "undefined" ? zIndex : 100000;
		var originalZIndex = ToolMan.css().readStyle(this.element, "z-index")

		this.register('dragstart', function(dragEvent) {
			dragEvent.group.element.style.zIndex = zIndex
		})
		this.register('dragend', function(dragEvent) {
			dragEvent.group.element.style.zIndex = originalZIndex
		})
	},

	_dragInit : function(event) {
		event = ToolMan.events().fix(event)
		var group = document.toolManDragGroup = this.toolManDragGroup
		var dragEvent = group.factory._createEvent('draginit', event, group)

		group._isThresholdExceeded = false
		group._initialMouseOffset = dragEvent.mouseOffset
		group._grabOffset = dragEvent.mouseOffset.minus(dragEvent.topLeftOffset)
		ToolMan.events().register(document, 'mousemove', group._drag)
		document.onmousemove = function() { return false }
		ToolMan.events().register(document, 'mouseup', group._dragEnd)

		group._notifyListeners(dragEvent)
	},

	_drag : function(event) {
		event = ToolMan.events().fix(event)
		var coordinates = ToolMan.coordinates()
		var group = this.toolManDragGroup
		if (!group) return
		var dragEvent = group.factory._createEvent('dragmove', event, group)

		var newTopLeftOffset = dragEvent.mouseOffset.minus(group._grabOffset)

		// TODO: replace with DragThreshold object
		if (!group._isThresholdExceeded) {
			var distance = 
					dragEvent.mouseOffset.distance(group._initialMouseOffset)
			if (distance < group._thresholdDistance) return
			group._isThresholdExceeded = true
			group._notifyListeners(
					group.factory._createEvent('dragstart', event, group))
		}

		for (i in group._transforms) {
			var transform = group._transforms[i]
			newTopLeftOffset = transform(newTopLeftOffset, dragEvent)
		}

		var dragDelta = newTopLeftOffset.minus(dragEvent.topLeftOffset)
		var newTopLeftPosition = dragEvent.topLeftPosition.plus(dragDelta)
		newTopLeftPosition.reposition(group.element)
		dragEvent.transformedMouseOffset = newTopLeftOffset.plus(group._grabOffset)

		group._notifyListeners(dragEvent)

		var errorDelta = newTopLeftOffset.minus(coordinates.topLeftOffset(group.element))
		if (errorDelta.x != 0 || errorDelta.y != 0) {
			coordinates.topLeftPosition(group.element).plus(errorDelta).reposition(group.element)
		}
	},

	_dragEnd : function(event) {
		event = ToolMan.events().fix(event)
		var group = this.toolManDragGroup
		var dragEvent = group.factory._createEvent('dragend', event, group)

		group._notifyListeners(dragEvent)

		this.toolManDragGroup = null
		ToolMan.events().unregister(document, 'mousemove', group._drag)
		document.onmousemove = null
		ToolMan.events().unregister(document, 'mouseup', group._dragEnd)

	},

	_notifyListeners : function(dragEvent) {
		var listeners = this._listeners[dragEvent.type]
		for (i in listeners) {
			listeners[i](dragEvent)
		}
	}
}

function _ToolManDragEvent(type, event, group) {
	this.type = type
	this.group = group
	this.mousePosition = ToolMan.coordinates().mousePosition(event)
	this.mouseOffset = ToolMan.coordinates().mouseOffset(event)
	this.transformedMouseOffset = this.mouseOffset
	this.topLeftPosition = ToolMan.coordinates().topLeftPosition(group.element)
	this.topLeftOffset = ToolMan.coordinates().topLeftOffset(group.element)
}

_ToolManDragEvent.prototype = {
	toString : function() {
		return "mouse: " + this.mousePosition + this.mouseOffset + "    " +
				"xmouse: " + this.transformedMouseOffset + "    " +
				"left,top: " + this.topLeftPosition + this.topLeftOffset
	}
}

ToolMan._dragFactory._constraintFactory = {
	vertical : function() {
		return function(coordinate, dragEvent) {
			var x = dragEvent.topLeftOffset.x
			return coordinate.x != x
					? coordinate.factory.create(x, coordinate.y) 
					: coordinate
		}
	},

	horizontal : function() {
		return function(coordinate, dragEvent) {
			var y = dragEvent.topLeftOffset.y
			return coordinate.y != y
					? coordinate.factory.create(coordinate.x, y) 
					: coordinate
		}
	}
}


/* Copyright (c) 2005 Tim Taylor Consulting (see LICENSE.txt) */

ToolMan._dragsortFactory = {
	makeSortable : function(item) {
		var group = ToolMan.drag().createSimpleGroup(item)

		group.register('dragstart', this._onDragStart)
		group.register('dragmove', this._onDragMove)
		group.register('dragend', this._onDragEnd)

		return group
	},

	/** 
	 * Iterates over a list's items, making them sortable, applying
	 * optional functions to each item.
	 *
	 * example: makeListSortable(myList, myFunc1, myFunc2, ... , myFuncN)
	 */
	makeListSortable : function(list) {
		var helpers = ToolMan.helpers()
		var coordinates = ToolMan.coordinates()
		var itemsPreParse = document.getElementsByTagName("div");
		var items = new Array();
		for (var i = 0; i < itemsPreParse.length; i++) {
			if (!itemsPreParse[i].id.search('catLine')) {items.push(itemsPreParse[i]);}
			if (!itemsPreParse[i].id.search('proLine')) {items.push(itemsPreParse[i]);}
			if (!itemsPreParse[i].id.search('listLine')) {items.push(itemsPreParse[i]);}
			if (!itemsPreParse[i].id.search('workLine')) {items.push(itemsPreParse[i]);}
			}
		
		
		
		//var items = list.getElementsByTagName("div")

		helpers.map(items, function(item) {
			var dragGroup = ToolMan.dragsort().makeSortable(item)
			dragGroup.setThreshold(4)
			var min, max
			dragGroup.addTransform(function(coordinate, dragEvent) {
				return coordinate.constrainTo(min, max)
			})
			dragGroup.register('dragstart', function() {

                var itemsPreParse = document.getElementsByTagName("div");
                var items = new Array();
                for (var i = 0; i < itemsPreParse.length; i++) {
                        if (!itemsPreParse[i].id.search('catLine')) {items.push(itemsPreParse[i]);} 
                        if (!itemsPreParse[i].id.search('proLine')) {items.push(itemsPreParse[i]);} 
                        if (!itemsPreParse[i].id.search('listLine')) {items.push(itemsPreParse[i]);} 
                        if (!itemsPreParse[i].id.search('workLine')) {items.push(itemsPreParse[i]);} 
                        }             
                
	//			var items = list.getElementsByTagName("div")
				min = max = coordinates.topLeftOffset(items[0])
				for (var i = 1, n = items.length; i < n; i++) {
					var offset = coordinates.topLeftOffset(items[i])
					min = min.min(offset)
					max = max.max(offset)
				}
			})
		})
		for (var i = 1, n = arguments.length; i < n; i++)
			helpers.map(items, arguments[i])
		ToolMan.junkdrawer().inspectListOrder('cat0');
	},

	_onDragStart : function(dragEvent) {
	},

	_onDragMove : function(dragEvent) {
		var helpers = ToolMan.helpers()
		var coordinates = ToolMan.coordinates()

		var item = dragEvent.group.element
		var xmouse = dragEvent.transformedMouseOffset
		var moveTo = null

		var previous = helpers.previousItem(item, item.nodeName)
		while (previous != null) {
			var bottomRight = coordinates.bottomRightOffset(previous)
			if (xmouse.y <= bottomRight.y && xmouse.x <= bottomRight.x) {
				moveTo = previous
			}
			previous = helpers.previousItem(previous, item.nodeName)
		}
		if (moveTo != null) {
			helpers.moveBefore(item, moveTo)
			return
		}

		var next = helpers.nextItem(item, item.nodeName)
		while (next != null) {
			var topLeft = coordinates.topLeftOffset(next)
			if (topLeft.y <= xmouse.y && topLeft.x <= xmouse.x) {
				moveTo = next
			}
			next = helpers.nextItem(next, item.nodeName)
		}
		if (moveTo != null) {
			helpers.moveBefore(item, helpers.nextItem(moveTo, item.nodeName))
			return
		}
	},

	_onDragEnd : function(dragEvent) {
		ToolMan.coordinates().create(0, 0).reposition(dragEvent.group.element);
		ToolMan.junkdrawer().inspectListOrder('cat0');
	}

}
	//var dragsort = ToolMan.dragsort()
	//var junkdrawer = ToolMan.junkdrawer()

	function speak(id, what) {
		var element = document.getElementById(id);
		element.innerHTML = 'Clicked ' + what;
	}

        //
        // 
        //
        function GNFTreeUpdate(catId,scriptPath,queryFoot,depth,forceRefresh) {
        var lastInList = GNFTreeUpdate.arguments[5];
        if (typeof lastInList == 'undefined') { lastInList = 0; }
                
        var cursorType = 'hourGlass';
        //if (forceRefresh) { cursorType = '' }
        if (document.getElementById('cat'+catId).innerHTML == '' || forceRefresh==1) {
                GNFAjax(scriptPath,queryFoot+'&amp;parentId='+catId+'&amp;depth='+depth,'cat'+catId,cursorType);
                if (catId!=0) { document.getElementById('tree'+catId).src = '/v4files/ispadmin/tree/minus.gif'; }
                document.getElementById('cat'+catId).style.display = 'none';
                }
        if((document.getElementById('cat'+catId).style.display != 'none')) {
                document.getElementById('cat'+catId).style.display = 'none';
                if (lastInList) {
                        document.getElementById('tree'+catId).src = '/v4files/ispadmin/tree/plus.gif';
                        }
                else {  
                        document.getElementById('tree'+catId).src = '/v4files/ispadmin/tree/plusbottom.gif';
                        }   
                }
        else {
                document.getElementById('cat'+catId).style.display = 'block';
                if (lastInList) {
                        document.getElementById('tree'+catId).src = '/v4files/ispadmin/tree/minus.gif';
                        }
                else { 
                        document.getElementById('tree'+catId).src = '/v4files/ispadmin/tree/minusbottom.gif';
                        } 
                }
        }
                       
        
	//
	//
	//
        function treeUpdate(catId,queryFoot,depth,forceRefresh) {
	var lastInList = treeUpdate.arguments[4];
	if (typeof lastInList == 'undefined') { lastInList = 0; }

        var cursorType = 'hourGlass';
        //if (forceRefresh) { cursorType = '' }
        if (document.getElementById('cat'+catId).innerHTML == '' || forceRefresh==1) {
                submitRequest(queryFoot+'&amp;n=panel&amp;d=navigationList&amp;format=admin&amp;parentId='+catId+'&amp;depth='+depth,'cat'+catId,cursorType);
                if (catId!=0) { document.getElementById('tree'+catId).src = '/v4files/ispadmin/tree/minus.gif'; }
                document.getElementById('cat'+catId).style.display = 'none';
                }
        if((document.getElementById('cat'+catId).style.display != 'none')) {
                document.getElementById('cat'+catId).style.display = 'none';
		if (lastInList) {
                	document.getElementById('tree'+catId).src = '/v4files/ispadmin/tree/plus.gif';
			}
		else {
                	document.getElementById('tree'+catId).src = '/v4files/ispadmin/tree/plusbottom.gif';
			}
                }
        else {       
                document.getElementById('cat'+catId).style.display = 'block';
		if (lastInList) {
                	document.getElementById('tree'+catId).src = '/v4files/ispadmin/tree/minus.gif';
			}
		else {
                	document.getElementById('tree'+catId).src = '/v4files/ispadmin/tree/minusbottom.gif';
			}
                }   
	}


        //
        // Handle the enter key to move to next object, instead of submitting form
        //

	function handleEnter(field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}      


	//
	// Ajax functions
	//
	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 submitRequest() {
    		var spanId 	= submitRequest.arguments[1];
    		var dialogText 	= submitRequest.arguments[2];
    		var execWhenFinished 	= submitRequest.arguments[3];
		var http 	= createRequestObject();
		var randomnumber= Math.floor(Math.random()*11111);
       		var url;
                if (scriptPath!=''){
       	          url 	= scriptPath;
                }else{
       	          url 	= "/v4/go.gnf";
                }
    		var parameters 	= "&"+submitRequest.arguments[0] + "&cache="+randomnumber;

		parameters 	= parameters.replace(/\?/g,"");

		
		if (dialogText=="hourGlass") {
			document.body.style.cursor = 'wait'; 
			var elems = document.getElementsByTagName("a"); 
			for (var i = 0; i < elems.length; i++) { elems[i].style.cursor = 'wait'; } 
			dialogText= undefined; 
			} 

		if (typeof dialogText != 'undefined') { dialog('',dialogText); }



	
		//alert(spanId+":"+url+"?"+parameters);
       		http.onreadystatechange = function () {
	        	if (http.readyState==4 || http.readyState=="complete") {
				//alert(document.getElementById('ajaxResponse'));
	
				if (typeof documentChanged != 'undefined') { documentChanged=false; } 
				if (typeof dialogText != 'undefined') { closeDialog(); } 
				//if (typeof children != 'undefined') { 
					document.body.style.cursor = ''; 
					var elems = document.getElementsByTagName("a"); 
					for (var i = 0; i < elems.length; i++) { elems[i].style.cursor = ''; } 
				//		}
				var response = http.responseText;
				//alert(response);
				//alert(spanId);
				if (typeof spanId != 'undefined') { document.getElementById(spanId).innerHTML=response; }
				if (typeof execWhenFinished != 'undefined') { eval(execWhenFinished);}
				}

			}

		http.open('POST', url, true);
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	      	http.setRequestHeader("Content-length", parameters.length);
	      	http.setRequestHeader("Connection", "close");
		http.send(parameters);

       		}

        function GNFAjax() {

                //GNFAjax parameters
                //(url,parameters,spanId,dialogText,execWhenFinished,debugWin);
		
		var debugWin	= GNFAjax.arguments[5];
                var spanId      = GNFAjax.arguments[2];
                var dialogText  = GNFAjax.arguments[3];
                var execWhenFinished    = GNFAjax.arguments[4];
                var http        = createRequestObject();
                var randomnumber= Math.floor(Math.random()*11111);
                var url         = GNFAjax.arguments[0];
                var parameters  = "&"+GNFAjax.arguments[1] + "&cache="+randomnumber;
                parameters      = parameters.replace(/\?/g,"");

                
                if (dialogText=="hourGlass") {
                        document.body.style.cursor = 'wait';
                        var elems = document.getElementsByTagName("a");
                        for (var i = 0; i < elems.length; i++) { elems[i].style.cursor = 'wait'; }
                        dialogText= undefined;
                        }
                 
                if (typeof dialogText != 'undefined') { dialog('',dialogText); }
                        
                        
          
          
                //alert(spanId+":"+url+"?"+parameters);
                http.onreadystatechange = function () {
                        if (http.readyState==4 || http.readyState=="complete") {
                                //alert(document.getElementById('ajaxResponse'));
                 
                                if (typeof documentChanged != 'undefined') { documentChanged=false; }
                                if (typeof dialogText != 'undefined') { closeDialog(); }
                                //if (typeof children != 'undefined') {
                                        document.body.style.cursor = '';
                                        var elems = document.getElementsByTagName("a");
                                        for (var i = 0; i < elems.length; i++) { elems[i].style.cursor = ''; }
                                //              }
                                var response = http.responseText;
                                //alert(response);
                                if (typeof spanId != 'undefined') { 
                                	//alert(spanId);
					document.getElementById(spanId).innerHTML=response; 
					}
                                if (typeof execWhenFinished != 'undefined') { eval(execWhenFinished);}
                                }

                        }
	
		if(debugWin == "1"){
			window.open(url+"?n=default"+parameters);
			}
		else{
                	http.open('POST', url, true);
               		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
               		http.setRequestHeader("Content-length", parameters.length);
               		http.setRequestHeader("Connection", "close");
               		http.send(parameters);
			}
                }



	//
	// Autologout Script functions
	//
	function theAlert(){
	        alertMsg = "Your session will time out in 1 minute.  Please save your work within that time";
	        window.alert(alertMsg);
	        }
	function logoutReminder(){
	        minutes = 29;                       // minutes before your session will log out
	        setTimeout("theAlert()", minutes*60000);
	        }

	//
	// Dialog Script Functions
	//
  	var dialogNum = 0;
	var dialogInfo = new Array();
	function closeDialog(){
	   	document.getElementById('GNFDialog').style.display = 'none';
		}
  
	function dialog_buttonOnClick(id,button){
	 	if (dialogNum){
	     		var functionName = "function"+button;
			var buttonFunction = dialogInfo[id][functionName];
			if (buttonFunction){ setTimeout(buttonFunction, 0); }
			else{ closeDialog(id); }
			}
	 	}

        function refreshDialog(){
	  var width 	= '350';
    	  var height 	= '100';
    	  var top 	= '';
    	  var left 	= '';
    	  var id 	= 'GNFDialog';
          if (dialogInfo[id]){
            if (!dialogInfo[id]['width']){
              width='350';
            }else{
              width = dialogInfo[id]['width'];
            }
            if (!dialogInfo[id]['height']){
              height='100';
            }else{
              height = dialogInfo[id]['height'];
            }
          }
          var top=eval(eval(eval(document.body.clientHeight/2)-eval(height/2))+eval(document.body.scrollTop));
          var left=eval(eval(eval(document.body.clientWidth/2)-eval(width/2))+eval(document.body.scrollLeft));
          document.getElementById(id).style.top = top;
          document.getElementById(id).style.left = left;
        }
  
  function dialog(){
    // arguments
    var title 		= dialog.arguments[0];
    var body 		= dialog.arguments[1];
    var buttonLabel1 	= dialog.arguments[2];
    var function1	= dialog.arguments[3];
    var buttonLabel2	= dialog.arguments[4];
    var function2 	= dialog.arguments[5];
    var buttonLabel3	= dialog.arguments[6];
    var function3 	= dialog.arguments[7];
    var width	 	= dialog.arguments[8];
    var height	 	= dialog.arguments[9];

    
//	var width 	= '350';
 //   	var height 	= '100';
    if (!width){width="350";}
    if (!height){height="100";}
    	var top 	= '';
    	var left 	= '';
    	var id 	= 'GNFDialog';

    var titleId = id+"Title";
    var tableId = id+"Table";
    var bodyId 	= id+"Body";
    var button1 = "button1-"+id;
    var button2 = "button2-"+id;
    var button3 = "button3-"+id;

	if (buttonLabel1 != '' && typeof buttonLabel1 != 'undefined') { 
		 document.getElementById('dialogButton1').innerHTML= '<input type="button" class="btnFrmubmit" name="button1-GNFDialog" value="' + buttonLabel1 + '" onclick="dialog_buttonOnClick(\'GNFDialog\',\'1\');"/>';
		}
	else { document.getElementById('dialogButton1').innerHTML=''; }

	if (buttonLabel2 != '' && typeof buttonLabel2 != 'undefined') { 
		 document.getElementById('dialogButton2').innerHTML= '<input type="button" class="btnFrmSubmit" name="button2-GNFDialog" value="' + buttonLabel2 + '" onclick="dialog_buttonOnClick(\'GNFDialog\',\'2\');"/>';
		}
	else { document.getElementById('dialogButton2').innerHTML=''; }

	if (buttonLabel3 != '' && typeof buttonLabel3 != 'undefined') { 
		 document.getElementById('dialogButton3').innerHTML= '<input type="button" class="btnFrmSubmit" name="button3-GNFDialog" value="' + buttonLabel3 + '" onclick="dialog_buttonOnClick(\'GNFDialog\',\'3\');"/>';
		}
	else { document.getElementById('dialogButton3').innerHTML=''; }


    dialogInfo[id] 			= new Array(10);
    dialogInfo[id]['id'] 		= id;
    dialogInfo[id]['title'] 		= title;
    dialogInfo[id]['body'] 		= body;
    dialogInfo[id]['width'] 		= width;
    dialogInfo[id]['height'] 		= height;
    dialogInfo[id]['top'] 		= top;
    dialogInfo[id]['left'] 		= left;
    dialogInfo[id]['function1']		= function1;
    dialogInfo[id]['function2']		= function2;
    dialogInfo[id]['function3']		= function3;
    dialogNum++;
    if (top==''){ top=eval(eval(eval(document.body.clientHeight/2)-eval(height/2))+eval(document.body.scrollTop)); }
    if (left==''){ left=eval(eval(eval(document.body.clientWidth/2)-eval(width/2))+eval(document.body.scrollLeft)); }

    document.getElementById(titleId).innerHTML = title;
    document.getElementById(bodyId).innerHTML = body;
    document.getElementById(tableId).style.width = width;
    document.getElementById(tableId).style.height = height;
    document.getElementById(id).style.top = top;
    document.getElementById(id).style.left = left;
    document.getElementById(id).style.display = '';
  }


	//
	// Content management functions
	// 	
        tinyMCE.init({
                mode : "exact",
                mode : "specific_textareas",
                theme : "advanced",
		relative_urls : false,
		auto_reset_designmode : true,
		convert_urls : false,
		cleanup:true,
		editor_selector : "HTMLEditor",
                plugins : "spellchecker,flash,style,layer,table,save,advhr,advlink,insertdatetime,preview,searchreplace,contextmenu,paste,directionality,fullscreen,ibrowser,noneditable",
                theme_advanced_buttons1_add_before : "",
                theme_advanced_buttons1_add : "fontselect,fontsizeselect",
                theme_advanced_buttons2_add : "ibrowser",
                theme_advanced_buttons2_add_before: "cut,copy,paste,pasteword,separator,search,replace,separator",
                theme_advanced_buttons3_add_before : "tablecontrols",
                theme_advanced_buttons3_add : "",
                theme_advanced_buttons4 : "spellchecker,|,insertlayer,moveforward,movebackward,absolute,|,flash,styleprops,forecolor,backcolor,|,preview,separator,ltr,rtl,separator,fullscreen",
                theme_advanced_buttons4_add : "code",
                theme_advanced_buttons4_add_before : "",
                theme_advanced_buttons5 : "",
                theme_advanced_toolbar_location : "top",
                theme_advanced_toolbar_align : "left",
                theme_advanced_path : false,
		theme_advanced_disable : "advimage,formatselect,cleanup,sub,sup,styleselect,help,strikethrough,code,image",
		external_link_list_url : "example_link_list.js",
                external_image_list_url : "example_image_list.js",
                flash_external_list_url : "example_flash_list.js",
                onchange_callback : "myCustomOnChangeHandler",
		file_browser_callback : "fileBrowserCallBack",
		button_tile_map : true,
		currentUser : currentUser,
		documentRoot : documentRoot,
                theme_advanced_resize_horizontal : false,
                theme_advanced_resizing : true,
valid_elements : ""
+"a[accesskey|charset|class|coords|dir<ltr?rtl|href|hreflang|id|lang|name"
  +"|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup"
  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|rev"
  +"|shape<circle?default?poly?rect|style|tabindex|title|target|type],"
+"abbr[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"acronym[class|dir<ltr?rtl|id|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"address[class|align|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
  +"|onmouseup|style|title],"
+"applet[align<bottom?left?middle?right?top|alt|archive|class|code|codebase"
  +"|height|hspace|id|name|object|style|title|vspace|width],"
+"area[accesskey|alt|class|coords|dir<ltr?rtl|href|id|lang|nohref<nohref"
  +"|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup"
  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup"
  +"|shape<circle?default?poly?rect|style|tabindex|title|target],"
+"base[href|target],"
+"basefont[color|face|id|size],"
+"bdo[class|dir<ltr?rtl|id|lang|style|title],"
+"big[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"blockquote[dir|style|cite|class|dir<ltr?rtl|id|lang|onclick|ondblclick"
  +"|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout"
  +"|onmouseover|onmouseup|style|title],"
+"body[alink|background|bgcolor|class|dir<ltr?rtl|id|lang|link|onclick"
  +"|ondblclick|onkeydown|onkeypress|onkeyup|onload|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|onunload|style|title|text|vlink],"
+"br[class|clear<all?left?none?right|id|style|title],"
+"button[accesskey|class|dir<ltr?rtl|disabled<disabled|id|lang|name|onblur"
  +"|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown"
  +"|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex|title|type"
  +"|value],"
+"caption[align<bottom?left?right?top|class|dir<ltr?rtl|id|lang|onclick"
  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|style|title],"
+"center[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"cite[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"code[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"col[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id"
  +"|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown"
  +"|onmousemove|onmouseout|onmouseover|onmouseup|span|style|title"
  +"|valign<baseline?bottom?middle?top|width],"
+"colgroup[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl"
  +"|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown"
  +"|onmousemove|onmouseout|onmouseover|onmouseup|span|style|title"
  +"|valign<baseline?bottom?middle?top|width],"
+"dd[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"
+"del[cite|class|datetime|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
  +"|onmouseup|style|title],"
+"dfn[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"dir[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
  +"|onmouseup|style|title],"
+"div[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|style|title],"
+"dl[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
  +"|onmouseup|style|title],"
+"dt[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"
+"em/i[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"fieldset[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"font[class|color|dir<ltr?rtl|face|id|lang|size|style|title],"
+"form[accept|accept-charset|action|class|dir<ltr?rtl|enctype|id|lang"
  +"|method<get?post|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onreset|onsubmit"
  +"|style|title|target],"
+"frame[class|frameborder|id|longdesc|marginheight|marginwidth|name"
  +"|noresize<noresize|scrolling<auto?no?yes|src|style|title],"
+"frameset[class|cols|id|onload|onunload|rows|style|title],"
+"h1[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|style|title],"
+"h2[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|style|title],"
+"h3[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|style|title],"
+"h4[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|style|title],"
+"h5[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|style|title],"
+"h6[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|style|title],"
+"head[dir<ltr?rtl|lang|profile],"
+"hr[align<center?left?right|class|dir<ltr?rtl|id|lang|noshade<noshade|onclick"
  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|size|style|title|width],"
+"html[dir<ltr?rtl|lang|version],"
+"iframe[align<bottom?left?middle?right?top|class|frameborder|height|id"
  +"|longdesc|marginheight|marginwidth|name|scrolling<auto?no?yes|src|style"
  +"|title|width],"
+"img[align<bottom?left?middle?right?top|alt|border|class|dir<ltr?rtl|height"
  +"|hspace|id|ismap<ismap|lang|longdesc|name|onclick|ondblclick|onkeydown"
  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
  +"|onmouseup|src|style|title|usemap|vspace|width],"
+"input[accept|accesskey|align<bottom?left?middle?right?top|alt"
  +"|checked<checked|class|dir<ltr?rtl|disabled<disabled|id|ismap<ismap|lang"
  +"|maxlength|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect"
  +"|readonly<readonly|size|src|style|tabindex|title"
  +"|type<button?checkbox?file?hidden?image?password?radio?reset?submit?text"
  +"|usemap|value],"
+"ins[cite|class|datetime|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
  +"|onmouseup|style|title],"
+"isindex[class|dir<ltr?rtl|id|lang|prompt|style|title],"
+"kbd[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"label[accesskey|class|dir<ltr?rtl|for|id|lang|onblur|onclick|ondblclick"
  +"|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout"
  +"|onmouseover|onmouseup|style|title],"
+"legend[align<bottom?left?right?top|accesskey|class|dir<ltr?rtl|id|lang"
  +"|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|style|title],"
+"li[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|type"
  +"|value],"
+"link[charset|class|dir<ltr?rtl|href|hreflang|id|lang|media|onclick"
  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|rel|rev|style|title|target|type],"
+"map[class|dir<ltr?rtl|id|lang|name|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"menu[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
  +"|onmouseup|style|title],"
+"meta[content|dir<ltr?rtl|http-equiv|lang|name|scheme],"
+"noframes[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"noscript[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"object[align<bottom?left?middle?right?top|archive|border|class|classid"
  +"|codebase|codetype|data|declare|dir<ltr?rtl|height|hspace|id|lang|name"
  +"|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|standby|style|tabindex|title|type|usemap"
  +"|flashvars|vspace|width],"
+"ol[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
  +"|onmouseup|start|style|title|type],"
+"optgroup[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick"
  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|style|title],"
+"option[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick|ondblclick"
  +"|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout"
  +"|onmouseover|onmouseup|selected<selected|style|title|value],"
+"p[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|style|title],"
+"param[id|name|type|value|valuetype<DATA?OBJECT?REF],"
+"pre/listing/plaintext/xmp[align|class|dir<ltr?rtl|id|lang|onclick|ondblclick"
  +"|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout"
  +"|onmouseover|onmouseup|style|title|width],"
+"q[cite|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"s[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"
+"samp[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"script[charset|defer|language|src|type],"
+"select[class|dir<ltr?rtl|disabled<disabled|id|lang|multiple<multiple|name"
  +"|onblur|onchange|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup"
  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|size|style"
  +"|tabindex|title],"
+"small[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"span[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
  +"|onmouseup|style|title],"
+"strike[class|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
  +"|onmouseup|style|title],"
+"strong/b[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"style[dir<ltr?rtl|lang|media|title|type],"
+"sub[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"sup[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title],"
+"table[align<center?left?right|bgcolor|border|cellpadding|cellspacing|class"
  +"|dir<ltr?rtl|frame|height|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rules"
  +"|style|summary|title|width],"
+"tbody[align<center?char?justify?left?right|char|class|charoff|dir<ltr?rtl|id"
  +"|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown"
  +"|onmousemove|onmouseout|onmouseover|onmouseup|style|title"
  +"|valign<baseline?bottom?middle?top],"
+"td[abbr|align<center?char?justify?left?right|axis|bgcolor|char|charoff|class"
  +"|colspan|dir<ltr?rtl|headers|height|id|lang|nowrap<nowrap|onclick"
  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|rowspan|scope<col?colgroup?row?rowgroup"
  +"|style|title|valign<baseline?bottom?middle?top|width],"
+"textarea[accesskey|class|cols|dir<ltr?rtl|disabled<disabled|id|lang|name"
  +"|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup"
  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect"
  +"|readonly<readonly|rows|style|tabindex|title],"
+"tfoot[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id"
  +"|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown"
  +"|onmousemove|onmouseout|onmouseover|onmouseup|style|title"
  +"|valign<baseline?bottom?middle?top],"
+"th[abbr|align<center?char?justify?left?right|axis|bgcolor|char|charoff|class"
  +"|colspan|dir<ltr?rtl|headers|height|id|lang|nowrap<nowrap|onclick"
  +"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
  +"|onmouseout|onmouseover|onmouseup|rowspan|scope<col?colgroup?row?rowgroup"
  +"|style|title|valign<baseline?bottom?middle?top|width],"
+"thead[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id"
  +"|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown"
  +"|onmousemove|onmouseout|onmouseover|onmouseup|style|title"
  +"|valign<baseline?bottom?middle?top],"
+"title[dir<ltr?rtl|lang],"
+"tr[abbr|align<center?char?justify?left?right|bgcolor|char|charoff|class"
  +"|rowspan|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title|valign<baseline?bottom?middle?top],"
+"tt[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"
+"u[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],"
+"ul[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
  +"|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
  +"|onmouseup|style|title|type],"
+"var[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
  +"|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
  +"|title]"

        });




function getElementsByClassName(classname, node)  {
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");       
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;                  
    }
                                   
function myCustomOnChangeHandler(inst) {
        var textareas = getElementsByClassName('HTMLEditor');
        for(i=0;i<textareas.length;i++){
                if (tinyMCE.getInstanceById(textareas[i].id).isDirty()) {
                        document.getElementById(textareas[i].id+'Status').innerHTML='<font color="red">Content not currently saved!</font>';
                        }
                }
        }

var fileBrowserReturnURL = "";
var fileBrowserWin;
var fileBrowserFieldName;
function fileBrowserCallBack(field_name, url, type, win) {
	window.open(scriptPath+queryHead+'&n=MCEPopup&d=imageUpload', 
  '', 'scrollbars=1,width=700,height=500');
  fileBrowserWin = win;
  fileBrowserFieldName = field_name;
}

function fileBrowserReturn(url) {
  fileBrowserWin.document.forms[0].elements[fileBrowserFieldName].value = url;    
  fileBrowserWin.document.forms[0].elements[fileBrowserFieldName].focus();
}


	//
	// Editor Submission Functions
	//
        function submitEditor(formName) {

                                       
                if (formName == null || formName == '') {
                        formName = 'mainForm';
                        }
                eval('document.' + formName).submit();
                                                
                return true;
                                        
        }


                var cp = new ColorPicker('window'); // Popup window

                 function makeTime(fieldName,formName) {
                        if (formName == null || formName == '') {
                                 formName = 'mainForm';
                                 }
                        // Set the time if all of the drop downs were filled in
                        var hourSelect 	= parseFloat(document.getElementById(fieldName+'_hour').value);
			//alert(hourSelect);
                        var minSelect 	= document.getElementById(fieldName+'_minute').value;
                        var ampmSelect 	= document.getElementById(fieldName+'_am_pm').value;

			if (minSelect == '') {document.getElementById(fieldName+'_minute').value='00';}
			if (hourSelect == '') {document.getElementById(fieldName+'_hour').value='01';}


			var hourSelectConverted = hourSelect;
                        if ((ampmSelect == 'PM') && (hourSelect == '12')) 	{ hourSelectConverted = '12'; }
                        if ((ampmSelect == 'PM') && (hourSelect < '12')) 	{ hourSelectConverted = parseFloat(hourSelect)+12; }
                        if ((ampmSelect == 'AM') && (hourSelect == '12')) 	{ hourSelectConverted = '0'; }
                        if ((ampmSelect == 'AM') && (hourSelect < '12')) 	{ hourSelectConverted = parseFloat(hourSelect); }
                        if (hourSelect != '' && minSelect != '') {
                                var date = new Date();
                                document.getElementById(fieldName).value = hourSelectConverted + ':' + minSelect + ':00';

				//alert (     document.getElementById(fieldName).value);
                        }
                        return true;
                }

                        function humanDate(dateString) {
                        // fix the string to get rid of anything funky

                        dateString = dateString.replace("\\","-");
                        dateString = dateString.replace("/","-");
                        function removeSpaces(string) {
                                var tstring = "";
                                string = '' + string;
                                splitstring = string.split(" ");
                                for(i = 0; i < splitstring.length; i++)
                                tstring += splitstring[i];
                                return tstring;
                        }
                        dateString = removeSpaces(dateString);

                        // Split the string up into three parts;


                        var dateArray = dateString.split("-");

                        if (dateArray[0] == '' || dateArray[0] == null) { dateArray[0] = '0000';; }
                        if (dateArray[1] == null) { dateArray[1] = '00';; }
                        if (dateArray[2] == null) { dateArray[2] = '00';; }
                        dateString = dateArray[1]+'-'+dateArray[2]+'-'+dateArray[0];

                        if (dateString == '00-00-0000') {dateString = '';}

                        return dateString;
                        }

                        function ODBCDate(dateString) {
                        // fix the string to get rid of anything funky

                        dateString = dateString.replace("\\","-");
                        dateString = dateString.replace("/","-");
                        function removeSpaces(string) {
                                var tstring = "";
                                string = '' + string;
                                splitstring = string.split(" ");
                                for(i = 0; i < splitstring.length; i++)
                                tstring += splitstring[i];
                                return tstring;
                        }
                        dateString = removeSpaces(dateString);

                        // Split the string up into three parts;

                        var dateArray = dateString.split("-");

                        dateString = dateArray[2]+'-'+dateArray[0]+'-'+dateArray[1];
                        return dateString;
                }

var wr_loaded=0;

function uploadWorkRequestAttachment(){
  dialog('Uploading','<img src="/v4files/ispadmin/loader.gif"/><br/>Uploading attachment...');
}

function deleteWorkRequestAttachment(divId,id,work_request_attachment_id){
  if (confirm("Delete this file?")){
    dialog('Deleting','<img src="/v4files/ispadmin/loader.gif"/><br/>Deleting attachment...');
    GNFTreeUpdate(divId,scriptPath,queryHead+'n=panel&amp;d=workRequest_singleRequest&amp;id='+id+'&pageAction=deleteWorkRequestAttachment&attachment_id='+work_request_attachment_id,1,1);
  }
}

function reloadWorkRequest(divId,id){
  if (wr_loaded){
    GNFTreeUpdate(divId,scriptPath,queryHead+'n=panel&amp;d=workRequest_singleRequest&id='+id,1,1);
    wr_loaded=0;
  }else{
    closeDialog();
  }
}
