var csimg = "/img/";
var gSessionTimeout = "60";
var mainFormName = "master_form";
function calCloseAction(){if(calTarget.onblur){ calTarget.onblur(); }}

var toolBarAction = false;

var browser;
var version;
var popupLayer1 = "";
var popupLayer2 = "";
var popupIframe1;
var popupIframe2;
var popupXmin1;
var popupXmax1;
var popupYmin1;
var popupYmax1;
var popupXmin2;
var popupXmax2;
var popupYmin2;
var popupYmax2;
var popupOn = 0;
var popupEventObj = "";
var sessionTimer = 0;
var resetSession = 0;
var expireSecs;
var expireSecsLeft = 60;
var cursor;

var appPrivsJson;

if(!window.XMLHttpRequest){ version = 6; }
if (navigator.appName != "Microsoft Internet Explorer"){
	browser = "moz";
} else {
	browser = "ie";
}
function loadAppPrivJsonCB(ajaxResp){
	eval(ajaxResp[1]);
}
function loadAppPrivJson(){
	if(appPrivsJson){ return; }
	xmlRequest("te_admin.p_app_priv_json", "POST", loadAppPrivJsonCB);
}
function isExplorer6(){
	if (typeof document.body.style.maxHeight == "undefined"){
		return true;
	} else {
		return false;
	}	
}
function getElementsByClassName(el, className){
	if(document.getElementsByClassName){
		return el.getElementsByClassName(className);
	} else {
		var docList = el.all || el.getElementsByTagName('*');
   		var matchArray = new Array();
		var re = new RegExp("(?:^|\\s)"+ className +"(?:\\s|$)");

		for (var i = 0; i < docList.length; i++) {
			if (re.test(docList[i].className) ) {
				matchArray[matchArray.length] = docList[i];
			}
		}

		return matchArray;
	}
}
function stopError(){
	return true;
}
function startError(){
	return false;
}
var subContent;
function subInit(){
	subContent = document.getElementById("sub-content");
	subSetHeight();
	window.onresize = subSetHeight; 
}
function subSetHeight(){
	subContent.style.height = document.documentElement.getBoundingClientRect().bottom - subContent.getBoundingClientRect().top - 10 + "px";
	subContent.style.width = document.documentElement.getBoundingClientRect().right - subContent.getBoundingClientRect().left - 10 + "px";
}
// Get Object from ID
function getObj(id){
	if(document.getElementById(id)){
		return document.getElementById(id);
	} else {
		return "";
	}
}
// Place Cursor at End of Focus Object
function focus(obj){
	obj.focus();
	var range;
	if(obj.createTextRange) {
		range = obj.createTextRange();
		range.collapse(false);
		range.select();
	}
}
// Remove non numbers
function removeNonNum(val){
	if(val === ""){ return ""; }
	return parseInt(val.replace(/[^0-9]/g, ""), 10);
}
function roundNumber(rnum, dec) {
	var newnumber;
	if(dec === ""){ dec = 0; }
	if (rnum > 8191 && rnum < 10485) {
		rnum = rnum-5000;
		newnumber = Math.round(rnum*Math.pow(10,dec))/Math.pow(10,dec);
		newnumber = newnumber+5000;
	} else {
		newnumber = Math.round(rnum*Math.pow(10,dec))/Math.pow(10,dec);
	}
	return newnumber;
}
/**********************************************************************
* getLabelForObj - Gets label text for given object
***********************************************************************/
function getLabelForObj(obj) {
    var label, labels = document.getElementsByTagName("label");
    for (var i = 0; (label = labels[i]); i++) {
        if ((label.htmlFor == obj.id) && (label.className == "fl2")) {		
            return(label.innerHTML);
        }
    }
    return "";
} // end getLabelForObj
/**********************************************************************
* setLabelForObj - Sets label text for given object
***********************************************************************/
function setLabelForObj(obj, label_txt) {
    var label, labels = document.getElementsByTagName("label");
    for (var i = 0; (label = labels[i]); i++) {
        if ((label.htmlFor == obj.id) && (label.className == "fl2")) {		
            label.innerHTML = label_txt;
        }
    }
    return true;
} // end setLabelForObj
/**********************************************************************
* setLabelHintForObj - Sets label hint text for given object
***********************************************************************/
function setLabelHintForObj(obj, label_hint_txt) {
    var label, labels = document.getElementsByTagName("label");
    for (var i = 0; (label = labels[i]); i++) {
        if ((label.htmlFor == obj.id) && (label.className == "fl2")) {	
            label.title = label_hint_txt;
        }
    }
    return true;
} // end setLabelHintForObj
/**********************************************************************
* setLabelWidthForObj - Sets label width for given object
***********************************************************************/
function setLabelWidthForObj(obj, label_width) {
    var label, labels = document.getElementsByTagName("label");
    for (var i = 0; (label = labels[i]); i++) {
        if ((label.htmlFor == obj.id) && (label.className == "fl2")) {	
            label.style.width = label_width;
        }
    }
    return true;
} // end setLabelWidthForObj
/**********************************************************************
* getDescForObj - Gets description label text for given object
***********************************************************************/
function getDescForObj(obj) {
    var label, labels = document.getElementsByTagName("label");
    for (var i = 0; (label = labels[i]); i++) {
        if ((label.htmlFor == obj.id) && (label.className == "desc")) {		
            return(label.innerHTML);
        }
    }
    return "";
} // end getDescForObj
/**********************************************************************
* setDescForObj - Sets description label text for given object
***********************************************************************/
function setDescForObj(obj, desc_txt) {
    var label, labels = document.getElementsByTagName("label");
    for (var i = 0; (label = labels[i]); i++) {
        if ((label.htmlFor == obj.id) && (label.className == "desc")) {		
            label.innerHTML = desc_txt;
        }
    }
    return true;
} // end setDescForObj
/**********************************************************************
* setDescHintForObj - Sets description hint text for given object
***********************************************************************/
function setDescHintForObj(obj, desc_hint_txt) {
    var label, labels = document.getElementsByTagName("label");
    for (var i = 0; (label = labels[i]); i++) {
        if ((label.htmlFor == obj.id) && (label.className == "desc")) {		
            label.title = desc_hint_txt;
        }
    }
    return true;
} // end setDescHintForObj
/**********************************************************************
* setDescWidthForObj - Sets description label width for given object
***********************************************************************/
function setDescWidthForObj(obj, desc_width) {
    var label, labels = document.getElementsByTagName("label");
    for (var i = 0; (label = labels[i]); i++) {
        if ((label.htmlFor == obj.id) && (label.className == "desc")) {	
            label.style.width = desc_width;
        }
    }
    return true;
} // end setDescWidthForObj
/***********************************************************************
* updateInputSourceDiv - update input source to match new value
************************************************************************/
function updateInputSourceDiv(div_obj, param_name, new_value) {
    var idx;
    var assign_val_idx;
    var start_val_idx;	
	var end_val_idx;
	var str;
	var str2;		
	var new_val = new_value;

	// Convert true and false to Oracle format
	if (new_value == true) new_val = "TRUE";
	if (new_value == false) new_val = "FALSE";
	
	// any manipulation of innerHTML strips out spaces and newlines, so 
	// use special HTML characters to preserve the formatting first
	div_obj.innerHTML = div_obj.innerHTML.replace(/\s/g, "&nbsp;");	
	div_obj.innerHTML = div_obj.innerHTML.replace(/\(/g, "(<br>");			
	div_obj.innerHTML = div_obj.innerHTML.replace(/\,/g, ",<br>");	
	div_obj.innerHTML = div_obj.innerHTML.replace(/\);/g, ");<br>");
	div_obj.innerHTML = div_obj.innerHTML.replace("<br><br>", "<br>");	
		
	// find parameter in div text
	idx = div_obj.innerHTML.search(param_name);
	if (idx < 0) return;
	
	// now find assignment part of parameter
	str = div_obj.innerHTML.substr(idx);	
	assign_val_idx = str.search(/=&gt;/);
	if (assign_val_idx < 0) return;
	
	// now find start of actual value
	assign_val_idx = assign_val_idx + 5;
	str2 = str.substr(assign_val_idx);

	// we replaced all whitespace with &nbsp;
	str2 = str2.replace(/&nbsp;/g, " ");		
	start_val_idx = str2.search(/\S/);	
	if (start_val_idx < 0) return;	
	str2 = str2.replace(/\s/g, "&nbsp;");		
	start_val_idx = start_val_idx * 6;

	// add quotes if necessary
    if (str2.charAt(start_val_idx) == "'") new_val = "'" + new_val + "'";
	start_val_idx = idx + assign_val_idx + start_val_idx;

	// now find end of old value string
	//end_val_idx = str2.search(/[,\)]/);
	end_val_idx = str2.search(/,/);
	if (end_val_idx < 0) return;
	
	// insert new value in place of old value
	div_obj.innerHTML = div_obj.innerHTML.substr(0, start_val_idx) +
	                    new_val +
						str2.substr(end_val_idx);
} // end updateInputSourceDiv
// Turn cursor selection off
function selectionOff(){
	if (document.selection) {
		document.selection.empty();
	} else if (window.getSelection){
		window.getSelection().removeAllRanges();
	}
}
// Determine Window/Frame Width and Height
function getWindowSize() {
    var win_width;
	var win_height;
	
	// If not IE, use Mozilla method
    if (navigator.appName != "Microsoft Internet Explorer") {
        win_width = window.innerWidth;
        win_height = window.innerHeight;
	}
	// Default to IE method
	else {
        win_width = document.body.offsetWidth;
        win_height = document.body.offsetHeight;
    }

	return [win_width, win_height];
} // end getWindowSize
// Find object position

function findPos(el, event) {
	if(event){ return [event.clientX, event.clientY] }
	var posX, posY;
	if( typeof(el.offsetParent) != "undefined"){
		for(posX = 0, posY = 0; el; el = el.offsetParent ) {
			posX += el.offsetLeft - el.scrollLeft;
			posY += el.offsetTop - el.scrollTop;
		}
		return [posX, posY];
	} else {
		return [el.x, obj.y];
	}
}
function findPosX(obj, event) {
	return findPos(obj, event)[0];
}
function findPosY(obj, event) {
	return findPos(obj, event)[1];
}
function mouseX(event) {
	if (event.pageX){ return event.pageX; }
	if (event.clientX){
		return event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
	}
	return null;
}
function mouseY(event) {
	if (event.pageY){ return event.pageY; }
	if (event.clientY){ 
		return event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	}
	return null;
}
// Event Functions
function attachEvent(el, eventType, eventFunction, captures){
	if (!captures){ captures = false;}
	if (el.addEventListener){
		el.addEventListener(eventType, eventFunction, captures);
	} else {
		el.attachEvent("on" + eventType, eventFunction);
	}
}
function detachEvent(el, eventType){
	if (el.removeEventListener){
		el.removeEventListener(eventType, eventFunction);
	} else {
		el.detachEvent("on" + eventType, eventFunction);
	}
}
function eventListenerStart(eventType, eventHandle, captures){
	if(document.addEventListener){
		document.addEventListener(eventType, eventHandle, captures);
	} else {
		document.attachEvent("on" + eventType, eventHandle);
	}
}
function eventListenerStop(eventType, eventHandle, captures){
	if(document.removeEventListener){
		document.removeEventListener(eventType, eventHandle, captures);
	} else {
		document.detachEvent("on" + eventType, eventHandle);
	}
}
function eventStopPropagation(event){
	if (event.stopPropagation){
		event.stopPropagation();
	} else {
		event.cancelBubble = true;
	}
}
function eventDefault(event){
	if(event.preventDefault){
		event.preventDefault();
	} else {
		event.returnValue = false;
	}
}
function eventSrc(event){
	return event.target ? event.target : event.srcElement;
}
function eventFalse(event){
	eventStopPropagation(event);
	eventDefault(event);
	return false;
}
function nodeExpCol(obj){
	targetDiv = getObj("ng" + removeNonNum(obj.id));
	var srcArray = obj.src.split("/");
	var imgSrc = srcArray[srcArray.length - 1];

	var fldObj = getObj("fi" + removeNonNum(obj.id));
	var fldArray = fldObj.src.split("/");
	var fldSrc = fldArray[fldArray.length - 1];

	if(imgSrc == "col.gif"){
		targetDiv.style.display = "none";
		obj.src = csimg + "exp.gif";
		obj.alt = "Expand";

		if(fldSrc == "folder1.gif"){
			fldObj.src = csimg + "folder0.gif";
		}

	} else {
		targetDiv.style.display = "block";
		obj.src = csimg +"col.gif";
		obj.alt = "Collapse";

		if(fldSrc == "folder0.gif"){
			fldObj.src = csimg + "folder1.gif";
		}
	}
}
function fieldsetToggle(button, idx){
	var div = document.getElementById("fieldset-div" + idx);
	var bool = div.style.visibility == "visible" ? true : false;
	var fieldset = document.getElementById("fieldset" + idx);
	fieldset.className = bool ? fieldset.className + " collapse" : fieldset.className.replace(/ collapse/g, "");
	div.style.visibility = bool ? "hidden" : "visible";
	div.style.overflow = bool ? "hidden" : "";
	div.style.height = bool ? "0px" : "";
	button.className = bool ? "fieldset-toggle1" : "fieldset-toggle0";
}
function returnFalse(){
	return false;
}
function cursorOn(xPos, yPos, cursorStyle){
	cursor = getObj("divCursor");
	cursor.style.width = "100px";
	cursor.style.height = "100px";
	cursor.style.top = (yPos - 50) + "px";
	cursor.style.left = (xPos - 50) + "px";
	cursor.style.cursor = cursorStyle;
	document.onselectstart = returnFalse;
}
function cursorChangeIcon(cursorStyle){
	cursor.style.cursor = cursorStyle;
}
function cursorMove(xPos, yPos){
	cursor.style.top = (yPos - 50) + "px";
	cursor.style.left = (xPos - 50) + "px";
}
function cursorOff(){
	cursor.style.width = "0px";
	cursor.style.height = "0px";
	cursor.style.top = "0px";
	cursor.style.left = "0px";
	document.onselectstart = returnFalse;
}
function popupSetSize(popupID){
	var popup;
	var iframe;
	
	// default to popup 1 - J. Avila
	if(!popupID){popupID = 1;}	
	if(popupID == 1){	
		popup = popupLayer1;
		iframe = popupIframe1;
		popupXmax = popup.offsetWidth;
		popupYmax = popup.offsetHeight;
		popupXmax1 = popupXmax;
		popupYmax1 = popupYmax;
	} else {
		popup = popupLayer2;
		iframe = popupIframe2;
		popupXmax = popup.offsetWidth;
		popupYmax = popup.offsetHeight;
		popupXmax2 = popupXmax;
		popupYmax2 = popupYmax;
	}

	iframe.style.width = popupXmax + "px";
	iframe.style.height = popupYmax + "px";
}
function popupMouseClose(event){
	if(!event){ event = window.event;}
	popupEventObj = eventSrc(event);
	var obj    = popupEventObj;
	if(obj.id == "popupLayer1" || obj.id == "popupLayer2"){
		popupClose();
		eventListenerStop("mouseup", popupMouseClose, true);
		eventStopPropagation(event);
		return;
	}

	while(obj.id != "popupLayer1" && obj.id != "popupLayer2" && obj.tagName != "BODY"){
		obj = obj.parentNode;
	}

	if(obj.tagName == "BODY"){
		popupClose();
		eventListenerStop("mouseup", popupMouseClose, true);
		eventStopPropagation(event);
	}
}
function popupOpen(posTop, posLeft, innerVal, mouseClose, popupID, transparent){
	// must pass in popup ID! - J. Avila
	popupClose(popupID);
	
	if(!popupID){popupID = 1;}
	var iframe = getObj("popupIframe" + popupID);
	iframe.style.top = posTop + "px";
	iframe.style.left = posLeft + "px";
	iframe.style.display = "";

	var div = getObj("popupLayer" + popupID);
	div.style.display = "";
	div.style.position = "absolute";
	div.style.zIndex = "101";
	div.style.top = posTop + "px";
	div.style.left = posLeft + "px";
	div.innerHTML = innerVal;

	iframe.style.width = div.offsetWidth + "px";
	iframe.style.height = div.offsetHeight + "px";

	if(popupID == 1){
		popupLayer1 = div;
		popupIframe1 = iframe;
	} else {
		popupLayer2 = div;
		popupIframe2 = iframe;
	}

	// must pass in popup ID! - J. Avila
	popupSetSize(popupID);		
	popupOn = 1;

	if(mouseClose == 1){
		eventListenerStart("mouseup", popupMouseClose, true);
	}

	return;
}
function popupClose(popupID){
	// default to popup 1 - J. Avila
	if(!popupID){popupID = 1;}	
	
	if (popupID != 1){
		if(popupLayer2 !== ""){
			popupLayer2.innerHTML = "";
			popupLayer2.style.display = "none";
			popupIframe2.style.display = "none";
			popupLayer2 = "";
			popupIframe2 = "";
		}
		return;
	}

	if(popupLayer2 !== ""){
		popupLayer2.style.display = "none";
		popupIframe2.style.display = "none";

		popupLayer2 = "";
		popupIframe2 = "";
	}

	if(popupLayer1 !== ""){
		popupLayer1.style.display = "none";
		popupIframe1.style.display = "none";

		popupOn = 0;
		autoCompOn = 0;
		autoEvent = 0;
		autoDiv = "";
		popupLayer1 = "";
		popupIframe1 = "";
		//JE  added contextButtonObj !=="undefined" to avoid JS error
		
		
		
	
		if(typeof contextButtonObj != "undefined" ){
			if (contextButtonObj !== "") {
				if(popupEventObj != contextButtonObj){
					contextID = "";
				}
				contextButtonObj.className = "toolbar-button";
				contextButtonObj = "";
			}
		}
	}
}
function textAreaSize(txtAreaObj,maxVal) {
	if (txtAreaObj.value.length == (maxVal+1)) {
		txtAreaObj.value = txtAreaObj.value.substr(0,maxVal);
	}

	if (txtAreaObj.value.length > (maxVal+1)) {
		alert("This field allows maximum of "+ maxVal +" characters");
		txtAreaObj.value = txtAreaObj.value.substr(0,maxVal);
	}
}
function xmldecode(val){
	val.replace("&amp;", "&");
	val.replace("&lt;", "<");
	val.replace("&gt;", ">");
	val.replace("&apos;", "'");
	val.replace("&quot;", '"');
	val.replace("&#160;", "");
	return val;
}
function xmlencode(val){
	val.replace("&", "&amp;");
	val.replace("<", "&lt;");
	val.replace(">", "&gt;");
	val.replace("'", "&apos;");
	val.replace('"', "&quot;");
	return val;
}
function addCommas(num){
	num += "";
	var x = num.split(".");
	var x1 = x[0];
	var x2 = x.length > 1 ? "." + x[1] : "";
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, "$1" + "," + "$2");
	}
	return x1 + x2;
}
function getFirstParentOfType(obj,tag){
	while(obj.tagName!=tag && obj.tagName!="BODY"){
		obj = obj.parentNode;
	}
	return obj;
}
function getBounds(el){
	var pos = findPos(el);
	var offsetWidth = el.offsetWidth;
    var offsetHeight = el.offsetHeight;

    return {left: pos[0], top: pos[1], width: offsetWidth, height:  offsetHeight};
}
function getStyle(el, styleProp){
	if (el.currentStyle)
		var y = el.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(el,null).getPropertyValue(styleProp);
	return y;
}

function getParentByTagName(el, tag){
	while (el !== null && el.tagName !== tag){
		el = el.parentNode;
	}

	return el;
}
function getParentByClassName(el, className){
	while(el !== null){
		if(el.className && el.className.match(className)){
			return el;
		}
		el = el.parentNode;
	}
}
function getParentById(el, id){
	while(el.id != id){
		el = el.parentNode;
	}
	
	if(el.id == id){
		return el;
	} else {
		return null;
	}
}
function setOpacity(obj, opacity){
	obj.style.opacity = opacity/100;
	if (obj.filters){
		obj.style.filter = "alpha(opacity=" + opacity + ")";
		//obj.filters.alpha.opacity = opacity;
	}
}

function fade(el, inOut, fadeTime, fadeInterval, vertical, horizontal, opacity, callback){
	var parms = {
		elArr:[], 
		inOutArr:[], 
		elHeight:[], 
		elWidth:[], 
		fadeTime:fadeTime, 
		fadeInterval:fadeInterval, 
		vertical:vertical, 
		horizontal:horizontal, 
		opacity:opacity, 
		loopIdx:1, 
		callback:callback};
		
	if(el.length){
		parms.elArr = el;
		parms.inOutArr = inOut;
	} else {
		parms.elArr[0] = el;
		parms.inOutArr[0] = inOut;
	}
	
	for(i = 0; i < parms.elArr.length; i++){
		parms.elArr[i].style.display = "";
		parms.elHeight[i] = parms.elArr[i].offsetHeight;
		parms.elWidth[i] = parms.elArr[i].offsetWidth;
	
		if(parms.inOutArr[i] == "in"){
			if(vertical){ parms.elArr[i].style.height = "0px"}
			if(horizontal){ parms.elArr[i].style.width = "0px"; }
			if(opacity){ setOpacity(parms.elArr[i], 0); }
		}
		
		parms.elArr[i].style.overflow = "hidden";
		parms.elArr[i].style.visibility = "visible";
	}
	fadeInLoop(parms);
}
function fadeInLoop(parms){
	var pct, newHeight, newWidth, opacityMulitplier;
	
	for(i = 0; i < parms.elArr.length; i++){
		pct = parms.loopIdx/parms.fadeInterval;
		newHeight = parms.inOutArr[i] == "in" ? parms.elHeight[i] * pct : parms.elHeight[i] - parms.elHeight[i] * pct;
		newWidth = parms.inOutArr[i] == "in" ? parms.elWidth[i] * pct : parms.elWidth[i] - parms.elWidth[i] * pct;
		opacityMulitplier = parms.inOutArr[i] == "in" ?  1 : 0;
		pct  = parms.inOutArr[i] == "in" ? pct : 1 - pct;
		
		if(parms.vertical){ parms.elArr[i].style.height = newHeight + "px"; }
		if(parms.horizontal){ parms.elArr[i].style.width = newWidth + "px"; }
		if(parms.opacity){ setOpacity(parms.elArr[i], pct * 100); }
		
		if(parms.loopIdx == parms.fadeInterval - 1){
			parms.elArr[i].style.overflow = "";
			parms.elArr[i].style.height = "";
			parms.elArr[i].style.width = "";
			if(parms.opacity){setOpacity( parms.elArr[i], (1 * 100) * opacityMulitplier); }
					
			if(parms.inOutArr[i] == "out"){
				parms.elArr[i].style.display = "none";
				parms.elArr[i].style.visibility = "hidden";
			}
		}
	}
	
	if(parms.loopIdx == parms.fadeInterval - 1){ parms.callback(); return; }

	parms.loopIdx++;
	setTimeout(function(){fadeInLoop(parms)}, parseInt(parms.fadeTime/parms.fadeInterval), 10);
}
function runScripts(e) {
	if(e.nodeType != 1){ return; }
 
	if(e.tagName.toLowerCase() == "script") {
		eval(e.text);
	}
	else {
		var n = e.firstChild;
		while(n) {
			if(n.nodeType == 1) runScripts(n);
			n = n.nextSibling;
		}
	}
}
function loadJS(src, onload){
	var head = document.getElementsByTagName("head")[0];         
	var script = document.createElement("script");
	script.type = "text/javascript";
	if(onload){ script.onload = onload; }
	script.src = src;
	head.appendChild(script);
}
function loadCSS(href){
	var head = document.getElementsByTagName("head")[0];         
	var cssNode = document.createElement("link");
	cssNode.type = "text/css";
	cssNode.rel = "stylesheet";
	cssNode.href = href;
	cssNode.media = "all";
	head.appendChild(cssNode);
}
function teDrag(event, parmObj){
	if(!event){event = window.event;}
	var dragObj = [];
	dragObj.startX = event.clientX;
	dragObj.startY = event.clientY;
	dragObj.enabled = parmObj.tolerance ? false : true;
	parmObj = parmObj.start(parmObj, dragObj);
	
	function teDragStart(event){
		if(!event){event = window.event;}
		eventStopPropagation(event);
		eventDefault(event);
		dragObj.x = event.clientX;
		dragObj.y = event.clientY;
		dragObj.mouseX = mouseX(event);
		dragObj.mouseY = mouseY(event);
		dragObj.deltaX = dragObj.x - dragObj.startX;
		dragObj.deltaY = dragObj.y - dragObj.startY;
		dragObj.el = event.target ? event.target : event.srcElement;
		
		if(!dragObj.enabled){
			if (Math.abs(dragObj.deltaX) > parmObj.tolerance || Math.abs(dragObj.deltaY) > parmObj.tolerance){
				dragObj.enabled = true;
		 	} else {
		 		return;
		 	}
		 }
		
		parmObj = parmObj.drag(parmObj, dragObj);		
	}
	
	function teDragStop(event){
		if(!event){event = window.event;}
		parmObj = parmObj.stop(parmObj, dragObj);
		eventStopPropagation(event);
		eventDefault(event);
		eventListenerStop("mousemove", teDragStart, true);
		eventListenerStop("mouseup", teDragStop, true);
		
	}
	
	eventListenerStart("mousemove", teDragStart, true);
	eventListenerStart("mouseup", teDragStop, true);
	eventStopPropagation(event);
	eventDefault(event);

}

/*****************************************************************
* This is a copy of mainIframeSrc() from L_DHTML_MAIN, but it can
* be called from within the mainIframe instead of the parent page.
*-----------------------------------------------------------------
* Save current page. Application-specific javascript can use this
* info to return user to previous page after a Save and Close
* submit, when history.back() may not work.
******************************************************************/
function newLocationSaveHistory(url){
	if(url === ""){ return;}
    window.parent.previousPage = window.parent.currentPage;	
    window.parent.currentPage = url;
	window.location = url;
	//window.parent.mainIframe.src = url;
}


if(!this.JSON){this.JSON={};}(function(){function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}if(typeof rep==='function'){value=rep.call(holder,key,value);}switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}return str('',{'':value});};}if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}return reviver.call(holder,key,value);}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}throw new SyntaxError('JSON.parse');};}}());
// AJAX functions
function createXMLHttpRequest() {
	var msxmls = new Array(5);
	if (window.XMLHttpRequest){
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		msxmls[0] = "Msxml2.XMLHTTP.5.0";
		msxmls[1] = "Msxml2.XMLHTTP.4.0";
		msxmls[2] = "Msxml2.XMLHTTP.3.0";
		msxmls[3] = "Msxml2.XMLHTTP";
		msxmls[4] = "Microsoft.XMLHTTP";
		for (var i = 0; i < msxmls.length; i++) {
			try {return new ActiveXObject(msxmls[i]);}
			catch (e) {}
		}
	}
}
function xmlRequest(xmlFile, method, callback, cbArgs){
	ajaxReqPost(xmlFile, "", callback, cbArgs);
}
function ajaxReqPost(url, args, callback, cbArgs){
	var xmlHttp, ajaxResp = [];

	xmlHttp = createXMLHttpRequest(xmlHttp);
	xmlHttp.open("POST", url, true);
	xmlHttp.onreadystatechange = xmlStateChange;
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form_urlencoded;");
	xmlHttp.send(args);

	function xmlStateChange(){
		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				ajaxResp[0] = xmlHttp.responseXML;
				ajaxResp[1] = xmlHttp.responseText;
				callback(ajaxResp, cbArgs);
				delete xmlHttp.onreadystatechange;
				xmlHttp = null;
				if(window.ActiveXObject){
					CollectGarbage();
				}
			}
		}
	}

}
function xslRunTransform(xml, xsl){
	var transformHTML, xsltProcessor, xsltResult, xmlSerial;
	if(window.ActiveXObject){
		transformHTML = (xml.transformNode(xsl));
	} else {
		xsltProcessor = new XSLTProcessor();
		xsltProcessor.importStylesheet(xsl);
		xsltResult = xsltProcessor.transformToDocument(xml);
		xmlSerial = new XMLSerializer();
		transformHTML = xmlSerial.serializeToString(xsltResult);
	}

	return transformHTML;
}
// XSL Transformation
function xslTransform(xmlURL, xslURL){
	var ajaxResp = [];
	var xml;
	var xsl;

	if(window.ActiveXObject) {
		// Load XML
		xml = new ActiveXObject("MSXML2.DOMDocument");
		xml.async = false;
		xml.load(xmlURL);

		// Load XSL
		xsl = new ActiveXObject("MSXML2.DOMDocument");
		xsl.async = false;
		xsl.load(xslURL);
	} else if(window.XMLHttpRequest){
		// Load XML
		xml = document.implementation.createDocument("", "", null);
		xml.async = false;
		xml.load(xmlURL);

		// Load XSL
		xsl = document.implementation.createDocument("", "", null);
		xsl.async = false;
		xsl.load(xslURL);
	}

	ajaxResp[0] = xslRunTransform(xml, xsl);
	ajaxResp[1] = xml;
	ajaxResp[2] = xsl;
	return ajaxResp;
}
function xslTransformLocalXSL(xmlURL, xsl){
	var ajaxResp = [];
	var xml;

	if(window.ActiveXObject) {
		// Load XML
		xml = new ActiveXObject("MSXML2.DOMDocument");
		xml.async = false;
		xml.load(xmlURL);

	} else if(window.XMLHttpRequest){
		// Load XML
		xml = document.implementation.createDocument("", "", null);
		xml.async = false;
		xml.load(xmlURL);
	}

	ajaxResp[0] = xslRunTransform(xml, xsl);
	ajaxResp[1] = xml;
	ajaxResp[2] = xsl;
	return ajaxResp;
}
function xslTransformLocalXML(xml, xslURL){
	var ajaxResp = [];
	var xsl;

	if(window.ActiveXObject) {
		// Load XML
		xsl = new ActiveXObject("MSXML2.DOMDocument");
		xsl.async = false;
		xsl.load(xslURL);

	} else if(window.XMLHttpRequest){
		// Load XML
		xsl = document.implementation.createDocument("", "", null);
		xsl.async = false;
		xsl.load(xslURL);
	}

	ajaxResp[0] = xslRunTransform(xml, xsl);
	ajaxResp[1] = xml;
	ajaxResp[2] = xsl;
	return ajaxResp;
}
function xslTransformLocal(xml, xsl){
	var ajaxResp = [];

	ajaxResp[0] = xslRunTransform(xml, xsl);
	ajaxResp[1] = xml;
	ajaxResp[2] = xsl;
	return ajaxResp;
}
function xmlSerialize(obj) {
	if (obj.xml) {
		return obj.xml;
	} else{
		var serializer = new XMLSerializer();
		return serializer.serializeToString(obj);
	}
}
var tbElement = [];
var tbOpenContextArray = [];
var tbTimer = [];

function toolbarInit(tb){
	attachEvent(tb, "mouseover", function(e){toolbarMouseOver(e, tb)});
	attachEvent(tb, "mouseout", function(e){toolbarMouseOut(e, tb)});
}

function toolbarMouseOut(event, tb){
	tbElement[tb] = null;
	tbTimer[tb] = setTimeout("toolbarBlur('" + tb.id + "')", 500);
}

function toolbarBlur(tbID){
	var tb = document.getElementById(tbID);
	var contextArray = tb.getElementsByTagName("UL");
	var idSubstring, parentDiv;
	for(var i = 0; i < contextArray.length; i++){
		contextArray[i].style.visibility = "hidden";
		parentDiv = getParentByTagName(contextArray[i], "LI").getElementsByTagName("A")[0];
		parentDiv.className = parentDiv.className.replace(" tb-active", "");
	}
}

function toolbarMouseOver(event, tb){
	if(!event){ event = window.event; }
	clearTimeout(tbTimer[tb]);
	var el = eventSrc(event);
	
	if(el.tagName != "LI"){ el = getParentByTagName(el, "LI"); }
	tbElement[tb] = el;
	
	var contextArray = tb.getElementsByTagName("UL");
	var idSubstring, parentDiv;
	for(var i = 0; i < contextArray.length; i++){
		idSubstring = contextArray[i].id.substring(5);
		if(idSubstring != el.id.substring(5).substring(0, idSubstring.length)){
			contextArray[i].style.visibility = "hidden";
			parentDiv = getParentByTagName(contextArray[i], "LI").getElementsByTagName("A")[0];
			parentDiv.className = parentDiv.className.replace(" tb-active", "");
		}
	}
	
	if(el.getElementsByTagName("UL").length === 0){ return; }
	
	var ul = el.getElementsByTagName("UL")[0];
	
	if(!ul){ return; }
	
	if(ul.style.visibility === "visible"){ return; }
	
	var bounds =  getBounds(el);
	if(el.id.split(".").length == 1){
		ul.style.top = bounds["top"] + bounds["height"] - 4 + "px";
		ul.style.left = bounds["left"] + "px";
	} else {
		ul.style.top = el.offsetTop + "px";
		ul.style.left = bounds["width"] + 2 + "px";
	}
	
	el.getElementsByTagName("A")[0].className += " tb-active";
	
	ul.style.visibility = "visible";

}
function toolbarChangeText(tbID, hierarchy, text){
	document.getElementById("tbli_" + tbID + "_" + hierarchy).getElementsByTagName("SPAN")[0].innerHTML = text;
}
/****************************************************************************************
* Global used in Save Form Warning Logic. Set clearUnload to true before Save or Reset
* to turn off save warning.
*****************************************************************************************/
var clearUnload = false;

/****************************************************************************************
* THIS VERSION WILL WORK IN FIREFOX!
* What if this event is triggered by a Keep Alive message? Need to disable in that case?
*****************************************************************************************
* noSaveChk - onload() callback for any page with a form submit callback procedure.
* Activates onbeforeunload event handler.
*----------------------------------------------------------------------------------------
* function noSaveChk()
*****************************************************************************************/
function noSaveChk() {
	var isModified = false;
	window.onbeforeunload = function (oEvent){
		if (!oEvent) oEvent = window.event;

		isModified = isFormModified(getObj(mainFormName));
		if(!clearUnload && isModified){
			oEvent.returnValue = "Form changes have not been saved.";
			return("Form changes have not been saved.");
		}
	}
}

/************************************************************************************
* THIS VERSION WILL ***!NOT!*** WORK IN FIREFOX!
* noSaveChk - onbeforeunload() callback for any page with a form
* submit callback procedure.
*------------------------------------------------------------------------------------
* function noSaveChk()
*************************************************************************************/
function noSaveChkOld(){
	if(!clearUnload && isFormModified(getObj(mainFormName))){
		event.returnValue = "Form changes have not been saved.";
		//return("Form changes have not been saved.");
	}
}

/************************************************************************************
* onUnloadForFormProcPage - default onUnload() callback for any page with a form
* submit callback procedure.
*------------------------------------------------------------------------------------
* function onUnloadForFormProcPage()
*************************************************************************************/
function onUnloadForFormProcPage() {
	clearUnload = true;
	// DOES NOT WORK in IE7
	//window.onbeforeunload = null;
	return true;
}

function singleFileUpload(id, i_attach_idx){
	var url = "te_gui_utils.p_upload?i_single=T&i_input_id=" + id + "&i_attach_idx=" + i_attach_idx;
	intPopup('<iframe id="multifile" frameborder="0" height="100" width="350" scrolling="no" src="'+ url +'" allowtransparency="true"></iframe>');
}
function singleFileProc(id, attach_idx, file){
	intPopupClose();
	var fileObj = getObj(id);
	fileObj.value = file;
	if(fileObj.onblur){ fileObj.onblur(); }
}
function multiFileCleanup(id){
	var url = "te_gui_utils.p_multi_file_cleanup?i_input_id=" + id;
	xmlRequest(url, "post", multiFileCleanupCB);
}
function multiFileCleanupCB(ajaxResp, id){
	return;
}
function multiFileUpload(id, i_attach_idx){
	var url = "te_gui_utils.p_upload?i_input_id=" + id + "&i_attach_idx=" + i_attach_idx;
	intPopup('<iframe id="multifile" frameborder="0" height="100" width="350" scrolling="no" src="'+ url +'" allowtransparency="true"></iframe>');
}
function multiFileDelete(file, id, i_attach_idx){
	var agree = confirm("Click OK to confirm the deletion of this file.");
	if(!agree){ return; }
	var url = "te_gui_utils.p_multi_file_delete?i_file=" + file + "&i_input_id=" + id + "&i_attach_idx=" + i_attach_idx;
	xmlRequest(url, "post", multiFileListCB, id);
}
function multiFileList(id, i_attach_idx){
	var url = "te_gui_utils.p_multi_file_list?i_input_id=" + id + "&i_attach_idx=" + i_attach_idx;
	xmlRequest(url, "post", multiFileListCB, id);
}
function multiFileListCB(ajaxResp, id){
	getObj(id).innerHTML = ajaxResp[1];
	intPopupClose();
}
function formSave(formName, formClose){
	clearUnload = true;
	var reqFields = getObj("cs_req_fields").innerHTML.split(",");
	var fieldArray = [];
	var formObj = getObj(formName);
	var evalArrayAssoc = [];
	var evalArray = [];
	var evalArrayIdx = 0;
	var evalObj;
	var error;
	var valueFound;
	var i;
	var y;

	for (i = 0; i < reqFields.length; i++) {
		fieldArray[reqFields[i]] = 0;
	}

	for (i = 0; i < formObj.length; i++) {
		evalObj = formObj.elements[i];

		if(evalObj.name){
			for(y = 0; y < reqFields.length; y++){
				if(evalObj.name == reqFields[y]){
					if(!evalArrayAssoc[reqFields[y]]){
						evalArrayAssoc[reqFields[y]] = reqFields[y];
						evalArray[evalArrayIdx] = reqFields[y];
						evalArrayIdx++;
					}
				}
			}
		}
	}

	for (i = 0; i < evalArray.length; i++) {
		evalObj = document.getElementsByName(evalArray[i]);
		valueFound = 0;

		for(y = 0; y < evalObj.length; y++){
			if(evalObj[y].value !== ""){
				valueFound = 1;
			}
		}

		for(y = 0; y < evalObj.length; y++){
			if(valueFound === 0){
				evalObj[y].className += " invalid";
				error = true;
			} else {
				evalObj[y].className = evalObj[y].className.replace(" invalid", "");
			}
		}
	}

	if(error){
		alert("Error: Missing Required fields");
		return;
	}

	if(formClose == 1){
		getObj("i_save_close").value = "Y";
	}

	if(currTab){
		getObj("i_tab").value = removeNonNum(currTab.id);
	}

	formObj.submit();
}
function formReset(formName){
	clearUnload = true;
	formObj = getObj(formName);
	formObj.reset();
}
function aimLaunch(fieldID){
	var sn = getObj(fieldID).value;

	if(sn !== ""){
		location.href = "aim:goim?screenname=" + sn;
	}

}
function emailLaunch(fieldID){
	var email = getObj(fieldID).value;

	if(email !== ""){
		location.href = "mailto:" + email;
	}

}
function webLaunch(fieldID){
	var webpage = getObj(fieldID).value;

	if(webpage !== ""){
		window.open(webpage);
	}
}
function formatSSN(fieldID){
	var ssnField = getObj(fieldID);
	var ssn = ssnField.value.replace(/[^0-9]/g, "");
	var ssnLength = ssn.length;

	if(ssnLength != 9){
		return;
	} else {
		ssn = ssn.substr(0,3) + "-" + ssn.substr(3,2) + "-" + ssn.substr(5,4);
	}

	ssnField.value = ssn;
}
function formatPhone(fieldID){
	var phoneField = getObj(fieldID);
	var phone = phoneField.value.replace(/[^0-9]/g, "");
	var phoneLength = phone.length;
	switch(phoneLength){
		case 11:
			if(phone.substr(0,1) == 1){
				phone = "+1 (" + phone.substr(1,3) + ") " + phone.substr(4,3) + "-" + phone.substr(7,4);
			} else {
				phone = "(" + phone.substr(0,3) + ") " + phone.substr(3,3) + "-" + phone.substr(6,4) + " Ext. " + phone.substr(10,1);
			}
			break;
		case 10:
			phone = "(" + phone.substr(0,3) + ") " + phone.substr(3,3) + "-" + phone.substr(6,4);
			break;
		case 7:
			phone = phone.substr(0,3) + "-" + phone.substr(3,4);
			break;
		default:
			if (phoneLength > 11) {
				if(phone.substr(0,1) == 1){
					phone = "+1 (" + phone.substr(1,3) + ") " + phone.substr(4,3) + "-" + phone.substr(7,4) + " Ext. " + phone.substr(11);
				} else {
					phone = "(" + phone.substr(0,3) + ") " + phone.substr(3,3) + "-" + phone.substr(6,4) + " Ext. " + phone.substr(10);
				}
			}
			break;
	}
	phoneField.value = phone;
}

var autoCompOn = 0;
var autoObj;
var autoIdx;
var autoEvent = 0;
var autoCurr = 0;
var autoLen = 0;
var autoDiv = "";
var autoXML;

function autoComplete(event, obj, proc, len, idx){
	if(!event){ event = window.event;}
	autoval = obj.value;
	autoObj = obj;
	autoIdx = idx;
	var stopProc = 0;

	if(autoval === "" || autoval.length < len){
		popupClose();
		return;
	}

	switch(event.keyCode) {
		case 38: //up arrow
			autoRowSel("up");
			stopProc = 1;
			break;
		case 40: //down arrow
			autoRowSel("down");
			stopProc = 1;
			break;
		case 13: //enter
			autoSetVal();
			stopProc = 1;
			break;
	}
	
	if(stopProc == 1){ return; }

	xmlRequest(proc + "?i_val=" + autoval, "post", autoCompleteCallBack);

	if(autoCompOn === 0){
		popupClose();
	}
}

/****************************************************************
* autoCompleteGeneric
*----------------------------------------------------------------
* proc url callback will already have some parameters appended.
* This function could replace autoComplete(), but adding a
* separate function is safer than breaking the existing function.
*****************************************************************/
function autoCompleteGeneric(event, obj, proc, len, idx){
	if(!event){ event = window.event;}
	autoval = obj.value;
	autoObj = obj;
	autoIdx = idx;
	var stopProc = 0;
	
	// Check if proc callback already includes extra url parameters
	// so we can determine how to add i_val to url string
	var add_parm = "?";
	if (proc.indexOf("?") > 0) {
	    add_parm = "&";
	}
	
	if(autoval === "" || autoval.length < len){
		popupClose();
		return;
	}

	switch(event.keyCode) {
		case 38: //up arrow
			autoRowSel("up");
			stopProc = 1;
			break;
		case 40: //down arrow
			autoRowSel("down");
			stopProc = 1;
			break;
		case 13: //enter
			autoSetVal();
			stopProc = 1;
			break;
	}

	if(stopProc == 1){ return; }
	
	xmlRequest(proc + add_parm + "i_val=" + autoval, "post", autoCompleteCallBack);

	if(autoCompOn === 0){
		popupClose();
	}
} // end autoCompleteGeneric

function autoCompleteCallBack(ajaxResp){
	autoXML = ajaxResp[0];
	autoLen = autoXML.getElementsByTagName("autocomplete")[0].getAttribute("rows");
	var respRows = autoXML.getElementsByTagName("ac");
	var height, content;
	var lineHeight = 14;
	var win_size;
	var obj_loc;
	var x, y;	

	if(autoLen == "0"){
		popupClose();
		return;
	} else if(autoLen == 1){
		popupClose();
		autoObj.value = respRows[0].firstChild.nodeValue;
		return;
	} else if(autoLen > 10){
		height = (lineHeight * 10);
	} else {
		height = (lineHeight * autoLen);
	}

	// Determine visible frame size and object location
	win_size = getWindowSize();
	obj_loc = findPos(autoObj);
			
	// Default popup to appear below autocomplete field
	x = obj_loc[0] + 1;
	y = obj_loc[1] + 22;

    // If there is not enough room to display autocomplete below field
	// But there is enough room above, display it there instead
	if (((y + height) > win_size[1]) && 
		(obj_loc[1] > height)) {
        y = obj_loc[1] - height;
		// If popup is above field, we must close and redraw 
		// it in case autoLen has changed.
		if (popupOn === 1) {popupClose();}		
	}
		
	// Open popup if it is not already open	
	if(popupOn === 0){
		autoCompOn = 1;
		content = "<div id=\"autocompdiv\" ";
		content += "class=\"autocomp\" ";
		content += "onmousedown=\"autoEvent=1;\" onmouseup=\"autoEvent=0\" ";
		content += "style=\"width: " + (autoObj.offsetWidth - 2) + "px;\">&nbsp;</div>";
		
		popupOpen(y, x, content, 0);
	}

	autoDiv = getObj("autocompdiv");
	
	var rows = "";
	for (var i = 0; i < respRows.length; i++) {
		if(i === 0){
			rows += "<div onclick=\"autoClick(" + i + ");\" ";
			rows += "onmouseover=\"autoMouse(" + i + ");\" ";
			rows += "class=\"autoOn\">";
			rows += respRows[i].firstChild.nodeValue + "</div>";
		} else {
			rows += "<div onclick=\"autoClick(" + i + ");\" ";
			rows += "onmouseover=\"autoMouse(" + i + ");\" ";
			rows += "class=\"autoOff\">";
			rows += respRows[i].firstChild.nodeValue + "</div>";
		}
	}
	autoDiv.innerHTML = rows;
	autoDiv.style.height = height + "px";
	autoCurr = 0;
	return;
	popupSetSize();
}
function autoClick(id){
	autoCurr = id;
	autoSetVal();
}
function autoMouse(id){
	autoDiv.childNodes[autoCurr].className = "autoOff";
	autoDiv.childNodes[id].className = "autoOn";
	autoCurr = id;
}
function autoRowSel(dir){
	if(autoDiv !== ""){
		if (dir == "up"){
			if(autoCurr === 0){
				return;
			} else {
				autoDiv.childNodes[autoCurr].className = "autoOff";
				autoCurr = autoCurr - 1;
				autoDiv.childNodes[autoCurr].className = "autoOn";
			}
		} else {
			if(autoCurr + 1 == autoLen){
				return;
			} else {
				autoDiv.childNodes[autoCurr].className = "autoOff";
				autoCurr = autoCurr + 1;
				autoDiv.childNodes[autoCurr].className = "autoOn";
			}
		}
	}
}
function autoSetVal(){
	if(autoDiv){
	    // changed innerText to innerHTML for Firefox - J. Avila
		autoObj.value = autoDiv.childNodes[autoCurr].innerHTML;	
	}
	focus(autoObj);
	popupClose();
}
function autoBlur(){
	var val, hiddenField, respRows, hiddenVal, i;
	if(autoEvent === 0){
		popupClose();
		val = autoObj.value.toUpperCase();
		hiddenField = getObj("autoCompField_" + autoIdx);
		if(!autoXML){
			hiddenField.value = "";
			hiddenField.onchange();
			return;
		}
		respRows = autoXML.getElementsByTagName("ac");
		hiddenVal = "";

		for (i = 0; i < respRows.length; i++) {
			if(respRows[i].firstChild.nodeValue.toUpperCase() == val){
				autoObj.value = respRows[i].firstChild.nodeValue;
				hiddenVal = respRows[i].getAttribute("value");
			}
		}

		if(hiddenVal === ""){
			autoObj.value = "";
		}

		hiddenField.value = hiddenVal;
		hiddenField.onchange();

		autoCompOn = 0;
		autoObj = "";
		autoIdx = "";
		autoEvent = 0;
		autoCurr = 0;
		autoLen = 0;
		autoDiv = "";
		autoXML = "";
	}
}
function richEditComm(id, command){
	var editor = getObj("editor" + id);
	//if(editor.setActive()){ editor.setActive(); }
	document.execCommand(command, false, null);
}
var curr_priv_app = "";
function pa_rights(i_id) {
	var new_app = "app_" + i_id;
	if(curr_priv_app !== ""){
		getObj(curr_priv_app).style.display = "none";
	}
	curr_priv_app = new_app;
	getObj(new_app).style.display = "";
}

function button_ep(i_obj){
	var button_id = "epb_" + i_obj.value;
	var button = getObj(button_id);
	var reset_privs = 0;
	var coll;

	if(i_obj.checked){
		button.style.display = "";
		button.click();
	} else {
		button.style.display = "none";
		div_obj = getObj("app_" + i_obj.value);

		if (div_obj.style.display === ""){
			reset_privs = 1;
		}

		div_obj.style.display = "none";
		coll = div_obj.all.tags("INPUT");
		if (coll !== null) {
			for (i = 0; i < coll.length; i++) {
				coll[i].checked = false;
			}
		}

		if (reset_privs == 1) {
			coll = document.all.tags("BUTTON");
			if (coll !== null){
				for (i = 0; i < coll.length; i++) {
					if (coll[i].id.substr(0,4) == "epb_"){
						if (coll[i].style.display === ""){
							coll[i].click();
							return;
						}
					}
				}
			}
		}
	}
}

function teCalendarShow(){
	var teCalendar = document.getElementById("turbo-calendar");
	teCalendar.style.display = "";
}
var calXSL = "";
var calPopup = "";
var calCurr = "";
var calCurrClass = "";
var calButtonObj = "";
var calTarget = "";
var calDateMask = "";
var calToday = "";
var calDefaultStatus = "To choose a date, click on a day";

var calMonthArray1 = [];
calMonthArray1.January = 1;
calMonthArray1.February = 2;
calMonthArray1.March = 3;
calMonthArray1.April = 4;
calMonthArray1.May = 5;
calMonthArray1.June = 6;
calMonthArray1.July = 7;
calMonthArray1.August = 8;
calMonthArray1.September = 9;
calMonthArray1.October = 10;
calMonthArray1.November = 11;
calMonthArray1.December = 12;

var calMonthArray2 = [];
calMonthArray2[1] = "January";
calMonthArray2[2] = "February";
calMonthArray2[3] = "March";
calMonthArray2[4] = "April";
calMonthArray2[5] = "May";
calMonthArray2[6] = "June";
calMonthArray2[7] = "July";
calMonthArray2[8] = "August";
calMonthArray2[9] = "September";
calMonthArray2[10] = "October";
calMonthArray2[11] = "November";
calMonthArray2[12] = "December";

function calDayStatus(idArray){
	return calGetDayName(idArray[1]) + ", " + getObj("calbutton_3").innerHTML + " " + idArray[2] + ", " + getObj("calbutton_4").innerHTML;
}
function calPickDate(event){
	if(!event){ event = window.event;}
	var obj = eventSrc(event);
	var idArray = obj.id.split("_");
	var dateString = getObj("calbutton_3").innerHTML +" "+ idArray[2] +", "+ getObj("calbutton_4").innerHTML;
	calFormatDate(dateString);
}
function calSetToday(){
	var dateToday = getObj("calbutton_7").innerHTML.replace("Today: ", "");
	calFormatDate(dateToday);
}
function calFormatDate(dateString){
	var url = "te_calendar.p_calendar_format_date?i_date=" + dateString + "&i_mask=" + calDateMask;
	xmlRequest(url, "GET", calSetDate);
}
function calSetDate(ajaxResp){
	calTarget.value = ajaxResp[1];
	popupClose();
	calCloseAction();
}
function calChangeMonth(direction){
	var currMon = getObj("calbutton_3");
	var currIdx = calMonthArray1[currMon.innerHTML.replace(" ", "")];
	var prev;
	var next;
	var targetObj

	if(currIdx == 12){
		prev = 11;
		next = 1;
	} else if(currIdx == 1){
		prev = 12;
		next = 2;
	} else {
		prev = currIdx - 1;
		next = currIdx + 1;
	}

	if(direction == 1){
		currMon.innerHTML = calMonthArray2[prev];
		if(currIdx == 1){
			targetObj = getObj("calbutton_4");
			targetObj.innerHTML = parseInt(targetObj.innerHTML, 10) - 1;
		}
	} else {
		currMon.innerHTML = calMonthArray2[next];
		if(currIdx == 12){
			targetObj = getObj("calbutton_4");
			targetObj.innerHTML = parseInt(targetObj.innerHTML, 10) + 1;
		}
	}
}
function calGetDayName(idx){
	var dayofweek;
	switch(idx){
		case "1":
			dayofweek = "Sunday";
			break;
		case "2":
			dayofweek = "Monday";
			break;
		case "3":
			dayofweek = "Tuesday";
			break;
		case "4":
			dayofweek = "Wednesday";
			break;
		case "5":
			dayofweek = "Thursday";
			break;
		case "6":
			dayofweek = "Friday";
			break;
		case "7":
			dayofweek = "Saturday";
			break;
	}

	return dayofweek;
}
function calButtonOver(event){
	if(!event){ event = window.event;}
	var obj = eventSrc(event);
	var idArray = obj.id.split("_");
	var calstatus;

	switch(idArray[1]){
		case "1":
			calstatus = "Click to view previous year";
			break;
		case "2":
			calstatus = "Click to view previous month";
			break;
		case "3":
			calstatus = "Click to choose a month";
			break;
		case "4":
			calstatus = "Click to choose year";
			break;
		case "5":
			calstatus = "Click to view next month";
			break;
		case "6":
			calstatus = "Click to view next year";
			break;
		case "7":
			calstatus = "Click to see current month";
			break;
		case "8":
			calstatus = "Click to set date blank";
			break;
		case "9":
			calstatus = "Click to close calendar";
			break;
	}

	calStatus(calstatus);

	if(calButtonObj !== "" && calButtonObj != obj){
		calResetButtons();
	}

	calButtonObj = obj;
	obj.style.backgroundColor = "#EEEEEE";
	obj.title = calstatus;
}
function calButtonClick(event){
	if(!event){ event = window.event;}
	var obj = eventSrc(event);
	var targetObj;
	var idArray = obj.id.split("_");
	var calstatus;

	switch(idArray[1]){
		case "1":
			targetObj = getObj("calbutton_4");
			targetObj.innerHTML = parseInt(targetObj.innerHTML, 10) - 1;
			calRefresh();
			break;
		case "2":
			calstatus = "Click to view previous month";
			calChangeMonth(1);
			calRefresh();
			break;
		case "3":
			calstatus = "Click to choose a month";
			break;
		case "4":
			calstatus = "Click to choose year";
			break;
		case "5":
			calstatus = "Click to view next month";
			calChangeMonth(2);
			calRefresh();
			break;
		case "6":
			targetObj = getObj("calbutton_4");
			targetObj.innerHTML = parseInt(targetObj.innerHTML, 10) + 1;
			calRefresh();
			break;
		case "7":
			calstatus = "Click to see current month";
			calSetToday();
			break;
		case "8":
			calTarget.value = "";
			popupClose();
			calCloseAction();
			break;
		case "9":
			popupClose();
			calCloseAction();
			break;
	}
}
function calResetButtons(){
	calButtonObj.style.backgroundColor = "buttonface";
}
function calDaysOver(event){
	if(!event){ event = window.event;}
	var obj = eventSrc(event);
	var idArray = obj.id.split("_");

	calStatus(calGetDayName(idArray[1]));
}
function calMouseOver(event){
	if(!event){ event = window.event;}
	var obj = eventSrc(event);
	var idArray = obj.id.split("_");

	if(obj.className !== ""){

		if(calCurr !== "" && calCurr != obj){
			calCurr.className = calCurrClass;
		}

		if(obj.className == "calnull"){
			calCurr = "";
			calCurrClass = "";
			calStatus(calDefaultStatus);
		} else {
			calCurr = obj;
			calCurrClass = obj.className;
			obj.className = "caldayover";
			calStatus(calDayStatus(idArray));
			obj.title = "Day of Week: " + calGetDayName(idArray[1]) + "\n" + "Day: " + obj.innerHTML;
		}

	}
}
function calMouseOut(){
	if(calCurr !== ""){
		calCurr.className = calCurrClass;
	}
	calCurr = "";
	calCurrClass = "";
}

function calStatus(calstatus){
	getObj("calstatus").innerHTML = calstatus;
}
function calShow(objID, dateMask, event){
	calTarget = getObj(objID);
	if(calTarget.disabled){ return; }
	calDateMask = dateMask;
	var objDate = calTarget.value;
	xmlURL = "te_calendar.p_calendar_popup_xml?i_date=" + objDate + "&i_format=" + dateMask;
	xslURL = "te_calendar.p_calendar_popup_xsl";
	var pos = findPos(calTarget, event);
	var posTop = pos[1] - 260;
	var posLeft = pos[0] - 254;
	if(posLeft <= 0){ posLeft = 10;}
	if(posTop < 5){posTop = 5;}

	var ajaxResp = [];

	if(calXSL !== ""){
		ajaxResp = xslTransformLocalXSL(xmlURL, calXSL);
	} else {
		ajaxResp = xslTransform(xmlURL, xslURL);
		calXSL = ajaxResp[2];
	}

	popupOpen(posTop, posLeft, ajaxResp[0], 1);
}
function calRefresh(){
	var objDate = calTarget.value;
	var monthVal = getObj("calbutton_3").innerHTML + "-" + getObj("calbutton_4").innerHTML;
	xmlURL = "te_calendar.p_calendar_popup_xml?i_action=refresh&i_date=" + objDate + "&i_format=" + calDateMask + "&i_month=" + monthVal;
	var ajaxResp = xslTransformLocalXSL(xmlURL, calXSL);
	getObj("calbody").innerHTML = ajaxResp[0];
	popupSetSize();
}var currTab;

function unhideTab(id){
	getObj("tabbutton" + id).style.display = "";
}
function hideTab(id){
	getObj("tabbutton" + id).style.display = "none";
}
function tab(tabObj, action){
	var nodes = tabObj.childNodes;
	var cls;

	if(action === 0){
		tabClass(tabObj, "10");
		currTab = tabObj;
		getObj("tab" + removeNonNum(tabObj.id)).style.display = "";
		return;
	}

	if(action === 1 || action === 2){
		tabClass(tabObj, "11");

		if(action === 2){
			tabClass(tabObj, "10");
		}

		if(currTab && currTab != tabObj){
			tabClass(currTab, "00");
			getObj("tab" + removeNonNum(currTab.id)).style.display = "none";
		}
		currTab = tabObj;
		getObj("tab" + removeNonNum(tabObj.id)).style.display = "";
		return;
	}

	switch(nodes[0].className.substr(3, 2)){
		case "10":
			cls = "11";
		break;
		case "11":
			cls = "10";
		break;
		case "00":
			cls = "01";
		break;
		case "01":
			cls = "00";
		break;
	}

	tabClass(tabObj, cls);
}
function tabClass(tabObj, cls){
	var nodes = tabObj.childNodes;
	nodes[0].className = "tab" + cls + "a";
	nodes[1].className = "tab" + cls + "b";
	nodes[2].className = "tab" + cls + "c";
}

function journalEdit(jid){
    var url = "te_journal.p_edit?i_journal_key=" + jid + "&i_input_id=" + getObj("i_j_tmp_idx").value;
    xmlRequest(url, "post", journalEditCB);
}
function journalEditCB(ajaxResp){
    var jArray = ajaxResp[1].split("|");
    var sel = getObj("i_journal_class");
    
    getObj("i_j_id").value = jArray[0];
    getObj("i_journal_title").value = jArray[1];
    getObj("i_journal_body").value = jArray[3];
    getObj("i_j_fa_idx").value = jArray[5];
    
    for (var i=0; i < sel.length; i++) {
        if (sel[i].value == jArray[4]) {
            sel[i].selected = true;
        }
    }
    
    multiFileList(getObj("i_j_tmp_idx").value, getObj("i_j_fa_idx").value);
}
function journalSave(){
    var url = "te_journal.p_save";
    var args = "i_j_id=" + getObj("i_j_id").value;
    args += "&i_j_type=" + getObj("i_j_type").value;
    args += "&i_j_type_id=" + getObj("i_j_type_id").value;
    args += "&i_j_title=" + getObj("i_journal_title").value;
    args += "&i_j_body=" + getObj("i_journal_body").value;
    args += "&i_j_class=" + getObj("i_journal_class").value;
    args += "&i_j_fa_idx=" + getObj("i_j_fa_idx").value;
    args += "&i_j_tmp_idx=" + getObj("i_j_tmp_idx").value;
    
    ajaxReqPost(url, args, journalSaveCB);
}
function journalSaveCB(ajaxResp){
	var idx = getObj("i_j_tmp_idx").value;
    getObj("i_j_id").value = "";
    getObj("i_journal_title").value = "";
    getObj("i_journal_body").value = "";
    getObj("i_journal_class").value = "";
	getObj("i_j_fa_idx").value = "";
	getObj(idx).innerHTML = "";

	gridUpdate(getObj("i_j_grid_id").value, "refresh");
}
function journalNew(){
	journalSaveCB(null);
	multiFileCleanup(getObj("i_j_tmp_idx").value);
}
function journalDelete(){
	var url = "te_journal.p_delete?i_journal_key=" + getObj("i_j_id").value + "&i_input_id=" + getObj("i_j_tmp_idx").value;
	xmlRequest(url, "post", journalSaveCB);
}

function libraryEdit(lid){
    var url = "te_library.p_edit?i_library_id=" + lid;
    xmlRequest(url, "post", libraryEditCB);
}
function libraryEditCB(ajaxResp){
    var lArray = ajaxResp[1].split("|");
    var sel = getObj("i_library_id");
    
    getObj("i_app_id").value = lArray[0];
    getObj("i_l_type").value = lArray[1];
       getObj("i_l_id").value = lArray[2];
       getObj("i_file_nm").value = lArray[3];
    getObj("i_display_nm").value = lArray[4];
    getObj("i_description").value = lArray[5];    
}
function librarySave(){
    var url = "te_library.p_save";
    var args = "i_library_id=" + getObj("i_library_id").value;
    args += "&i_app_id=" + getObj("i_app_id").value;
    args += "&i_l_type=" + getObj("i_l_type").value;
    args += "&i_l_id=" + getObj("i_l_id").value;
    args += "&i_file_nm=" + getObj("i_file_nm").value;
    args += "&i_display_nm=" + getObj("i_display_nm").value;
    args += "&i_description=" + getObj("i_description").value;
    
    ajaxReqPost(url, args, librarySaveCB);
}
function librarySaveCB(ajaxResp){
    getObj("i_library_id").value = "";
    getObj("i_app_id").value = "";
	getObj("i_l_type").value = "";
	getObj("i_l_id").value = "";
	getObj("i_file_nm").value = "";
	getObj("i_display_nm").value = "";
	getObj("i_description").value = "";

	gridUpdate(getObj("i_l_grid_id").value, "refresh");
}
function libraryNew(){
	librarySaveCB(null);
}
function libraryDelete(){
	var url = "te_library.p_delete?i_library_id=" + getObj("i_library_id").value;
	xmlRequest(url, "post", librarySaveCB);
}

function taskEdit(tid){
    var url = "te_task.p_edit?i_task_key=" + tid + "&i_input_id=" + getObj("i_t_tmp_idx").value;
    xmlRequest(url, "post", taskEditCB);
}
function taskEditCB(ajaxResp){
    var jArray = ajaxResp[1].split("|");
    var sel = getObj("i_task_class");
    
    getObj("i_t_id").value = jArray[0];
    getObj("i_task_title").value = jArray[1];
    getObj("i_task_body").value = jArray[3];
    getObj("i_t_fa_idx").value = jArray[5];
    
    for (var i=0; i < sel.length; i++) {
        if (sel[i].value == jArray[4]) {
            sel[i].selected = true;
        }
    }
    
    multiFileList(getObj("i_t_tmp_idx").value, getObj("i_t_fa_idx").value);
}
function taskSave(){
    var url = "te_task.p_save";
    var args = "i_t_id=" + getObj("i_t_id").value;
    args += "&i_t_type=" + getObj("i_t_type").value;
    args += "&i_t_type_id=" + getObj("i_t_type_id").value;
    args += "&i_t_title=" + getObj("i_task_title").value;
    args += "&i_t_body=" + getObj("i_task_body").value;
    args += "&i_t_class=" + getObj("i_task_class").value;
    args += "&i_t_fa_idx=" + getObj("i_t_fa_idx").value;
    args += "&i_t_tmp_idx=" + getObj("i_t_tmp_idx").value;
    
    ajaxReqPost(url, args, taskSaveCB);
}
function taskSaveCB(ajaxResp){
    getObj("i_t_id").value = "";
    getObj("i_task_title").value = "";
    getObj("i_task_body").value = "";
    getObj("i_task_class").value = "";
	getObj("i_t_fa_idx").value = "";
	getObj("i_t_tmp_idx").value = "";

	gridUpdate(getObj("i_t_grid_id").value, "refresh");
}
function taskNew(){
	taskSaveCB(null);
	multiFileCleanup(getObj("i_t_tmp_idx").value);
}
function taskDelete(){
	var url = "te_task.p_delete?i_task_key=" + getObj("i_t_id").value + "&i_input_id=" + getObj("i_t_tmp_idx").value;
	xmlRequest(url, "post", taskSaveCB);
}

function LTrim(str){if(str==null){return null;}for(var i=0;str.charAt(i)==" ";i++);return str.substring(i,str.length);}
function RTrim(str){if(str==null){return null;}for(var i=str.length-1;str.charAt(i)==" ";i--);return str.substring(0,i+1);}
function Trim(str){return LTrim(RTrim(str));}
function LTrimAll(str){if(str==null){return str;}for(var i=0;str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t";i++);return str.substring(i,str.length);}
function RTrimAll(str){if(str==null){return str;}for(var i=str.length-1;str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t";i--);return str.substring(0,i+1);}
function TrimAll(str){return LTrimAll(RTrimAll(str));}
function isNull(val){return(val==null);}
function isBlank(val){if(val==null){return true;}for(var i=0;i<val.length;i++){if((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}}return true;}
function isInteger(val){if(isBlank(val)){return false;}for(var i=0;i<val.length;i++){if(!isDigit(val.charAt(i))){return false;}}return true;}
function isNumeric(val){return(parseFloat(val,10)==(val*1));}
function isArray(obj){return(typeof(obj.length)=="undefined")?false:true;}
function isDigit(num){if(num.length>1){return false;}var string="1234567890";if(string.indexOf(num)!=-1){return true;}return false;}
function setNullIfBlank(obj){if(isBlank(obj.value)){obj.value="";}}
function setFieldsToUpperCase(){for(var i=0;i<arguments.length;i++){arguments[i].value = arguments[i].value.toUpperCase();}}
function disallowBlank(obj){var msg=(arguments.length>1)?arguments[1]:"";var dofocus=(arguments.length>2)?arguments[2]:false;if(isBlank(getInputValue(obj))){if(!isBlank(msg)){alert(msg);}if(dofocus){if(isArray(obj) &&(typeof(obj.type)=="undefined")){obj=obj[0];}if(obj.type=="text"||obj.type=="textarea"||obj.type=="password"){obj.select();}obj.focus();}return true;}return false;}
function disallowModify(obj){var msg=(arguments.length>1)?arguments[1]:"";var dofocus=(arguments.length>2)?arguments[2]:false;if(getInputValue(obj)!=getInputDefaultValue(obj)){if(!isBlank(msg)){alert(msg);}if(dofocus){if(isArray(obj) &&(typeof(obj.type)=="undefined")){obj=obj[0];}if(obj.type=="text"||obj.type=="textarea"||obj.type=="password"){obj.select();}obj.focus();}setInputValue(obj,getInputDefaultValue(obj));return true;}return false;}
function commifyArray(obj,delimiter){if(typeof(delimiter)=="undefined" || delimiter==null){delimiter = ",";}var s="";if(obj==null||obj.length<=0){return s;}for(var i=0;i<obj.length;i++){s=s+((s=="")?"":delimiter)+obj[i].toString();}return s;}
function getSingleInputValue(obj,use_default,delimiter){switch(obj.type){case 'radio': case 'checkbox': return(((use_default)?obj.defaultChecked:obj.checked)?obj.value:null);case 'text': case 'hidden': case 'textarea': return(use_default)?obj.defaultValue:obj.value;case 'password': return((use_default)?null:obj.value);case 'select-one':
if(obj.options==null){return null;}if(use_default){var o=obj.options;for(var i=0;i<o.length;i++){if(o[i].defaultSelected){return o[i].value;}}return o[0].value;}if(obj.selectedIndex<0){return null;}return(obj.options.length>0)?obj.options[obj.selectedIndex].value:null;case 'select-multiple':
if(obj.options==null){return null;}var values=new Array();for(var i=0;i<obj.options.length;i++){if((use_default&&obj.options[i].defaultSelected)||(!use_default&&obj.options[i].selected)){values[values.length]=obj.options[i].value;}}return(values.length==0)?null:commifyArray(values,delimiter);}alert("FATAL ERROR: Field type "+obj.type+" is not supported for this function");return null;}
function getSingleInputText(obj,use_default,delimiter){switch(obj.type){case 'radio': case 'checkbox':     return "";case 'text': case 'hidden': case 'textarea': return(use_default)?obj.defaultValue:obj.value;case 'password': return((use_default)?null:obj.value);case 'select-one':
if(obj.options==null){return null;}if(use_default){var o=obj.options;for(var i=0;i<o.length;i++){if(o[i].defaultSelected){return o[i].text;}}return o[0].text;}if(obj.selectedIndex<0){return null;}return(obj.options.length>0)?obj.options[obj.selectedIndex].text:null;case 'select-multiple':
if(obj.options==null){return null;}var values=new Array();for(var i=0;i<obj.options.length;i++){if((use_default&&obj.options[i].defaultSelected)||(!use_default&&obj.options[i].selected)){values[values.length]=obj.options[i].text;}}return(values.length==0)?null:commifyArray(values,delimiter);}alert("FATAL ERROR: Field type "+obj.type+" is not supported for this function");return null;}
function setSingleInputValue(obj,value){switch(obj.type){case 'radio': case 'checkbox': if(obj.value==value){obj.checked=true;return true;}else{obj.checked=false;return false;}case 'text': case 'hidden': case 'textarea': case 'password': obj.value=value;return true;case 'select-one': case 'select-multiple':
var o=obj.options;for(var i=0;i<o.length;i++){if(o[i].value==value){o[i].selected=true;}else{o[i].selected=false;}}return true;}alert("FATAL ERROR: Field type "+obj.type+" is not supported for this function");return false;}
function getInputValue(obj,delimiter){var use_default=(arguments.length>2)?arguments[2]:false;if(isArray(obj) &&(typeof(obj.type)=="undefined")){var values=new Array();for(var i=0;i<obj.length;i++){var v=getSingleInputValue(obj[i],use_default,delimiter);if(v!=null){values[values.length]=v;}}return commifyArray(values,delimiter);}return getSingleInputValue(obj,use_default,delimiter);}
function getInputText(obj,delimiter){var use_default=(arguments.length>2)?arguments[2]:false;if(isArray(obj) &&(typeof(obj.type)=="undefined")){var values=new Array();for(var i=0;i<obj.length;i++){var v=getSingleInputText(obj[i],use_default,delimiter);if(v!=null){values[values.length]=v;}}return commifyArray(values,delimiter);}return getSingleInputText(obj,use_default,delimiter);}
function getInputDefaultValue(obj,delimiter){return getInputValue(obj,delimiter,true);}

/************************************************************************************
* isChanged - return true if the given field object has been changed since the
* page was loaded. NOTE: This does not work correctly for password fields. They
* have a default value of NULL with current value that is in hex encoding.
*------------------------------------------------------------------------------------
* function isChanged()
*************************************************************************************/
function isChanged(obj){
    return(getInputValue(obj) != getInputDefaultValue(obj));
}

function setInputValue(obj,value){var use_default=(arguments.length>1)?arguments[1]:false;if(isArray(obj)&&(typeof(obj.type)=="undefined")){for(var i=0;i<obj.length;i++){setSingleInputValue(obj[i],value);}}else{setSingleInputValue(obj,value);}}

/************************************************************************************
* isFormModified - return true if the given from has been modified since the page
* was loaded. The calling function may optionally provide a comma-separated list
* of field names to ignore. Hidden fields will be checked UNLESS they are in the
* ignore list. Password fields will always be ignored because the value is encoded.
*------------------------------------------------------------------------------------
* function isFormModified()
*************************************************************************************/
/*function isFormModified(theform,hidden_fields,ignore_fields){*/
function isFormModified(theform, ignore_fields){
    //if (hidden_fields==null){
	//    hidden_fields="";
	//}
	if (ignore_fields==null){
	    ignore_fields="";
	}
	
	//var hiddenFields=new Object();
	var ignoreFields=new Object();
	var i,field;
	//var hidden_fields_array=hidden_fields.split(',');
	
	//for (i=0;i<hidden_fields_array.length;i++){
	//    hiddenFields[Trim(hidden_fields_array[i])]=true;
	//}
	
	var ignore_fields_array=ignore_fields.split(',');
	
	for (i=0;i<ignore_fields_array.length;i++){
	    ignoreFields[Trim(ignore_fields_array[i])]=true;
	}
	for (i=0;i<theform.elements.length;i++){
	    var changed=false;
		var name=theform.elements[i].name;
		if (!isBlank(name)){
		    var type=theform.elements[i].type;
			// Ignore password fields. Default value is Null, current val is encrypted
			if (!ignoreFields[name] && type!="password"){
			    //if (type=="hidden"&&hiddenFields[name]){
				//    changed=isChanged(theform[name]);
				//} else if(type=="hidden"){
				//    changed=false;
				//} else{
				    changed=isChanged(theform[name]);
				//}
			}
		}
		if (changed){
		    return true;
		}
	}
	return false;
}

function intPopup(content, noClose){
    if(noClose){
        document.getElementById("interClose").style.display = "none";
    }
    var interContainer = document.getElementById("interContainer"); //reference interstitial container
    var interVeil = document.getElementById("interVeil"); //reference veil
    var interIframe = document.getElementById("popupIframe2");
    interContainer.style.display = "";
    interVeil.style.display = "";
    document.getElementById("interContent").innerHTML = content;
    var standardbody = document.body;
    var ie = document.all && !window.opera;

    var dom = document.getElementById;
    var scroll_top = (ie) ? standardbody.scrollTop : window.pageYOffset;
    var scroll_left = (ie) ? standardbody.scrollLeft : window.pageXOffset;
    var docwidth = standardbody.clientWidth;

    var docheight = standardbody.clientHeight
    var docheightcomplete = (standardbody.offsetHeight > standardbody.scrollHeight) ? standardbody.offsetHeight : standardbody.scrollHeight;
    var objwidth = interContainer.offsetWidth;
    var objheight = interContainer.offsetHeight;
    interIframe.style.display = "";
    interIframe.style.width = "100%";
    interIframe.style.height = "100%";
    interVeil.style.width = docwidth + "px"; //set up veil over page
    interVeil.style.height = (docheightcomplete == 0) ? "100%" : docheightcomplete + "px"; //set up veil over page
    interVeil.style.left = 0; //Position veil over page
    interVeil.style.top = 0; //Position veil over page
    interVeil.style.visibility = "visible"; //Show veil over page
    interContainer.style.left = docwidth/2 - objwidth/2 + "px"; //Position interstitial box

    var topposition = (docheight > objheight) ? scroll_top + docheight/2 - objheight/2 + "px" : scroll_top + 5 + "px"; //Position interstitial box
	interContainer.style.top = Math.floor(parseInt(topposition, 10)) + "px";
	interContainer.style.visibility = "visible"; //Show interstitial box;
}
function intPopupClose(){
	var interIframe = document.getElementById("popupIframe2");
	document.getElementById("interContent").innerHTML = "&nbsp;";
	document.getElementById("interContainer").style.display = "none";
	document.getElementById("interVeil").style.display = "none";
	interIframe.style.dispaly = "none";
    interIframe.style.width = "0px";
    interIframe.style.height = "0px";
}

