/******************************************************************************
    
    general JavaScript framework proposals/library
    (c) SchoolCenter : Eric Fehrenbacher 2006
    
******************************************************************************/

/* SchoolCenter namespace
/*{{{*/
var SC = {
	console : {
		log : function(str, obj) {
			if (window.console) {
				console.log(str, obj);
			}
		}
	}
};
/*}}}*/

/* jQuery namespace
/*{{{*/
//var jQuery;
if (typeof(jQuery) != "undefined") {
	$J = jQuery.noConflict();
}
/*}}}*/

/* Prototype mods
/*{{{*/
var Prototype;

/*{{{ add the hasOwnProperty() method for Safari/WebKit */
if (!Object.prototype.hasOwnProperty) {
	Object.prototype.hasOwnProperty = function(property) {
		try {
			var prototype = this.constructor.prototype;
			while (prototype) {
				if (prototype[property] == this[property]) {
					return false;
				}
				prototype = prototype.prototype;
			}
		} catch(e) {}
		return true;
	}
}
/* test case
Object.prototype.extend = function(object) {
	for (var property in object) {
		try {
			if (!this.prototype[property] && object.hasOwnProperty(property)) {
				this.prototype[property] = object[property];
			}
		} catch(e) {}
	}
}
*/
/*}}}*/

// if the siblings accessor does not exist add the sibling methods
if (!Element.recursivelyCollect) {
	Object.extend(Element, {
		recursivelyCollect : function(element, property) {/*{{{*/
			element = $(element);
			var elements = [];
			while (element = element[property]) {
				if (element.nodeType == 1) {
					elements.push(Element.extend(element));
				}
			}
			return elements;
		},/*}}}*/
		previousSiblings: function(element) {/*{{{*/
			return $(element).recursivelyCollect('previousSibling');
		},/*}}}*/
		nextSiblings: function(element) {/*{{{*/
			return $(element).recursivelyCollect('nextSibling');
		},/*}}}*/
		siblings: function(element) {/*{{{*/
			element = $(element);
			return element.previousSiblings().reverse().concat(element.nextSiblings());
		}/*}}}*/
	});
	SC.console.log('added', 'recuresivelyCollect, siblings, nextSiblings, previousSiblings');
}

// makes sure getDimensions, getWidth, and getHeight are available
if (!Element.getWidth) {
	Object.extend(Element, {
		getDimensions: function(element) {/*{{{*/
			element = $(element);
			var display = $(element).getStyle('display');
			if (display != 'none' && display != null) {// Safari bug
				return {width: element.offsetWidth, height: element.offsetHeight};
			}
			// All *Width and *Height properties give 0 on elements with display none,
			// so enable the element temporarily
			var els = element.style;
			var originalVisibility = els.visibility;
			var originalPosition = els.position;
			var originalDisplay = els.display;
			els.visibility = 'hidden';
			els.position = 'absolute';
			els.display = 'block';
			var originalWidth = element.clientWidth;
			var originalHeight = element.clientHeight;
			els.display = originalDisplay;
			els.position = originalPosition;
			els.visibility = originalVisibility;
			return {width: originalWidth, height: originalHeight};
		},/*}}}*/
		getHeight: function(element) {/*{{{*/
			return $(element).getDimensions().height;
		},/*}}}*/
		getWidth: function(element) {/*{{{*/
			return $(element).getDimensions().width;
		}/*}}}*/
	});
	SC.console.log('added', 'getDimensions, getHeight, getWidth');
}

// sc mods to getStyle and setStyle
// these are incorporated in 1.5 official, but are provided here as a fallback in the case that 1.5 official is not installed
// once proto1.5 is fully published this inclusion can be removed permanently
if (Prototype.Version != '1.5.0') {
	Object.extend(Element, {
		getStyle : function (element, style) {/*{{{*/
			element = $(element);
			if (['float','cssFloat'].include(style))
			  style = (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat');
			style = style.camelize();
			var value = element.style[style];
			if (!value) {
			  if (document.defaultView && document.defaultView.getComputedStyle) {
				var css = document.defaultView.getComputedStyle(element, null);
				value = css ? css[style] : null;
			  } else if (element.currentStyle) {
				value = element.currentStyle[style];
			  }
			}

			if((value == 'auto') && ['width','height'].include(style) && (element.getStyle('display') != 'none'))
			  value = element['offset'+style.capitalize()] + 'px';

			if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
			  if (Element.getStyle(element, 'position') == 'static') value = 'auto';
			if(style == 'opacity') {
			  if(value) return parseFloat(value);
			  if(value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
				if(value[1]) return parseFloat(value[1]) / 100;
			  return 1.0;
			}
			return value == 'auto' ? null : value;
		},/*}}}*/
		setStyle : function(element, style) {/*{{{*/
			element = $(element);
			for (var name in style) {
			  var value = style[name];
			  if(name == 'opacity') {
				if (value == 1) {
				  value = (/Gecko/.test(navigator.userAgent) &&
					!/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 0.999999 : 1.0;
				  if(/MSIE/.test(navigator.userAgent) && !window.opera)
					element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'');
				} else if(value == '') {
				  if(/MSIE/.test(navigator.userAgent) && !window.opera)
					element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'');
				} else {
				  if(value < 0.00001) value = 0;
				  if(/MSIE/.test(navigator.userAgent) && !window.opera)
					element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'') +
					  'alpha(opacity='+value*100+')';
				}
			  } else if(['float','cssFloat'].include(name)) name = (typeof element.style.styleFloat != 'undefined') ? 'styleFloat' : 'cssFloat';
			  element.style[name.camelize()] = value;
			}
			return element;
		}/*}}}*/
	});
	SC.console.log('added', 'getStyle, setStyle');
}

// adds in a few custom methods to the Element object
Object.extend(Element, {/*{{{*/
	truncateChildren : function(element) {/*{{{*/
		var element = $(element);
        while (element.hasChildNodes()) {
        	element.removeChild(element.firstChild);
        }
	},/*}}}*/
	nextObject : function(element) {/*{{{*/
		var n = $(element);
		do n = n.nextSibling;
		while (n && n.nodeType != 1);
		return n;
	},/*}}}*/
	previousObject : function(element) {/*{{{*/
		var p = $(element);
		do p = p.previousSibling;
		while (p && p.nodeType != 1);
		return p;
	},/*}}}*/
	scrollable: function(element) {/*{{{*/
        element = $(element);
        return ((element.scrollHeight > element.offsetHeight) || (element.scrollWidth > element.offsetWidth));
	},/*}}}*/
    getStyleAbsolute : function(element, style) {/*{{{*/
        do {
            style_found = Element.getStyle(element, style);
            element = element.parentNode;
        } while (isNull(style_found) && element);
        return style_found;
    }/*}}}*/
});/*}}}*/

Object.extend(Array.prototype, {/*{{{*/
	inArray : function(needle) {
		if (needle == '') {
			return false;
		} else {
			var i;
			for (i = 0; i < this.length; i++) {
				if (this[i] == needle) {
					return true;
				}
			}
			return false;
		}
	}
});/*}}}*/
Object.extend(String.prototype, {/*{{{*/
	properizeFromUnderCaps : function() {/*{{{*/
		var str_list = this.split('_');
		var str_len  = str_list.length;
		var fromUndaString = '';
		for (var i = 0; i < str_len; i++) {
			str_word = str_list[i].toLowerCase();
			fromUndaString += str_word.charAt(0).toUpperCase() + str_word.substring(1) + ' ';
		}
		fromUndaString = fromUndaString.substr(0, (fromUndaString.length - 1));
		return fromUndaString;
	},/*}}}*/
	replaceSpaces : function() {/*{{{*/
		var str_list = this.split(' ');
		var str_len  = str_list.length;
		var fromUndaString = '';
		for (var i = 0; i < str_len; i++) {
			str_word = str_list[i].toLowerCase();
			fromUndaString += str_word.charAt(0).toUpperCase() + str_word.substring(1) + '_';
		}
		fromUndaString = fromUndaString.substr(0, (fromUndaString.length - 1));
		return fromUndaString;
	},/*}}}*/
	escapeRE : function() {/*{{{*/
		return this.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
	},/*}}}*/
	trim : function() {/*{{{*/
		return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
	},/*}}}*/
	entityify : function() {/*{{{*/
		return this.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
	},/*}}}*/
	quote : function() {/*{{{*/
		var c, i, l = this.length, o = '"';
		for (i = 0; i < l; i += 1) {
			c = this.charAt(i);
			if (c >= ' ') {
				if (c == '\\' || c == '"') {
					o += '\\';
				}
				o += c;
			} else {
				switch (c) {
				case '\b':
					o += '\\b';
					break;
				case '\f':
					o += '\\f';
					break;
				case '\n':
					o += '\\n';
					break;
				case '\r':
					o += '\\r';
					break;
				case '\t':
					o += '\\t';
					break;
				default:
					c = c.charCodeAt();
					o += '\\u00' + Math.floor(c / 16).toString(16) +
						(c % 16).toString(16);
				}
			}
		}
		return o + '"';
	},/*}}}*/
	supplant : function(o) {/*{{{*/
		/*{{{
		This does variable substitution on the string. It scans through the string
		looking for expressions enclosed in { } braces. If an expression is found, use
		it as a key on the object, and if the key has a string value or number value,
		it is substituted for the bracket expression and it repeats. This is useful
		for automatically fixing URLs. So

			param = {domain: 'schoolcenter.com', images: 'http://images.{domain}/'};
			url   = "{images}logo.gif" . supplant(param);

		produces a url containing "http://images.schoolcenter.com/logo.gif".
		}}}*/
		var i, j, s = this, v;
		for (;;) {
			i = s.lastIndexOf('{');
			if (i < 0) {
				break;
			}
			j = s.indexOf('}', i);
			if (i + 1 >= j) {
				break;
			}
			v = o[s.substring(i + 1, j)];
			if (!isString(v) && !isNumber(v)) {
				break;
			}
			s = s.substring(0, i) + v + s.substring(j + 1);
		}
		return s;
	},/*}}}*/
	simpleEmailAddressVerification : function() {/*{{{*/
		var str_expression = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		return (str_expression.test(this));
	},/*}}}*/
	checkPhoneNumber : function() {/*{{{*/
		var str_expression = /([0-9][0-9][0-9][(-.][0-9][0-9][0-9][0-9][0-9][0-9][0-9])/;
		return (str_expression.test(this));
	}/*}}}*/
});
/*{{{ callbacks */
checkEmail = function(str_email) { return str_email.simpleEmailAddressVerification() };
/*}}}*/
/*}}}*/
Object.extend(Event, {/*{{{*/
    type : function(event) {/*{{{*/
        return event.type;
    },/*}}}*/
    whichKey : function(event) {/*{{{*/
        return event.which ? event.which : event.keyCode;
    },/*}}}*/
    keyIs : function(event, key) {/*{{{*/
        return (Event.whichKey(event) == key) ? true : false;
    }/*}}}*/
});
/*}}}*/
Object.extend(PeriodicalExecuter, {/*{{{*/
	registerCallback : function() {/*{{{*/
		this.int_interval = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
	},/*}}}*/
	stop : function() {/*{{{*/
		clearInterval(this.int_interval);
	}/*}}}*/
});
/*}}}*/

/*}}}*/

/* SchoolCenter
/*{{{*/

/* dimensions
/*{{{*/

/* getAbsolutes(incDiv, stopPoint)
/*{{{
returns the absolute x,y of objects top, left
used by the colorpicker
*/
getAbsolutes = function(incDiv, stopPoint) {
	var objRef = $(incDiv);
	var x      = 0;
	var y      = 0;
	if (objRef.offsetParent) {
		if (objRef.tagName != 'BODY') {
			stopParent :
			while (objRef.offsetParent) {
				x += objRef.clientLeft ? objRef.clientLeft : objRef.offsetLeft;
				y += objRef.clientTop ? objRef.clientTop : objRef.offsetTop;
				objRef = objRef.offsetParent;
				if (objRef.id == stopPoint) {
					break stopParent;
				}
			}
		}
	} else {
		if (objRef.x) {
			x += objRef.x;
		}
		if (objRef.y) {
			y += objRef.y;
		}
	}
	return [x,y];
};
JS_getAbsolutes = function(incDiv, stopPoint) { return getAbsolutes(incDiv, stopPoint); } // dereferenced
/*}}}*/

/* getWindowWidth()
/*{{{*/
getWindowWidth = function() {
	if (window.innerWidth) {
		return window.innerWidth;
	} else if (document.body.parentElement && document.body.parentElement.clientWidth) {
		return document.body.parentElement.clientWidth;
	} else if (document.body && document.body.clientWidth) {
		return document.body.clientWidth;
	}
	return 0;
};/*}}}*/

/* getWindowHeight()
/*{{{
returns the available content height space in browser window
*/
getWindowHeight = function() {
	if (window.innerHeight) {
		return window.innerHeight;
	} else if (document.body.parentElement && document.body.parentElement.clientHeight) {
		return document.body.parentElement.clientHeight;
	} else if (document.body && document.body.clientHeight) {
		return document.body.clientHeight;
	}
	return 0;
};/*}}}*/

/* getScrollWidth()
/*{{{*/
getScrollWidth = function() {
   var w = window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft;
   return w ? w : 0;
};/*}}}*/

/* getScrollHeight()
/*{{{*/
getScrollHeight = function() {
   var h = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;    
   return h ? h : 0;
};/*}}}*/

/* getScrolls()
/*{{{*/
getScrolls = function() {
    var scrOfX = 0, scrOfY = 0;
    if (typeof(window.pageYOffset) == 'number') {
        // Netscape compliant
        int_vert = window.pageYOffset;
        int_side = window.pageXOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        // DOM compliant
        int_vert = document.body.scrollTop;
        int_side = document.body.scrollLeft;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        // IE6 standards compliant mode
        int_vert = document.documentElement.scrollTop;
        int_side = document.documentElement.scrollLeft;
    }
    return [int_side, int_vert];
};/*}}}*/

/* getScreenDims()
/*{{{*/
getScreenDims = function() {
	return [(window.screen.width ? window.screen.width : 550), (window.screen.height ? window.screen.height : 720)];
};/*}}}*/

/* getContentDims()
/*{{{*/
getContentDims = function() {
    var myWidth = 0, myHeight = 0;
    if (isNumber(window.innerWidth)) {
        // Non-IE
        int_width  = window.innerWidth;
        int_height = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        // IE 6+ in 'standards compliant mode'
        int_width  = document.documentElement.clientWidth;
        int_height = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        // IE 4 compatible
        int_width  = document.body.clientWidth;
        int_height = document.body.clientHeight;
    }
    return [int_width, int_height];
};/*}}}*/

/*}}}*/

/* colorpicker
/*{{{
*** DEPRECATE
*/


/* getHeight(incDiv)
/*{{{*/
getHeight = function(incDiv) {
	var objRef = $(incDiv);
	var result = 0;
	if (objRef.offsetHeight) {
		result = objRef.offsetHeight;
	} else if (objRef.clip && objRef.clip.height) {
		result = objRef.clip.height;
	} else if (objRef.style && objRef.style.pixelHeight) {
		result = objRef.style.pixelHeight;
	}
	return parseInt(result);
};
JS_getHeight = function(incDiv) { return getHeight(incDiv); }
/*}}}*/

/* setFloat(incObj, dir)
/*{{{
allows us to set floats easily on DOM nodes
used by the colorpicker
*/
setFloat = function(incObj, dir) {
	var objRef = $(incObj);
	var dir    = dir ? dir : 'left'
	if (objRef) {
		with (objRef.style) {
			if (document.all) {
				styleFloat = dir;
			} else {
				cssFloat = dir;
			}
		}
	}
};
JS_setFloat = function(incObj, dir) { setFloat(incObj, dir); } // dereferenced
/*}}}*/

/* utilities, browsr
/*{{{
it is being used by the colorpicker and maybe 1 or 2 other things
we need to get this out of our code it is a hack
depends : browserCheck()
*/
var browsr;
utilities = function() {
	browsr = new browserCheck();
};/*}}}*/

/*}}}*/

/* typing
/*{{{*/

var obj_browser = null;
var browsr = null;
var browserCheck = function() {
	if (!isNull(obj_browser)) {
		return obj_browser;
	}
	
	var ua = navigator.userAgent;
	var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");

	if (document.images) {
		this.id      = 'browser detection';
		this.agent   = navigator.userAgent.toLowerCase();
		this.version = navigator.appVersion;
		this.major   = parseInt(this.version);
		this.minor   = parseFloat(this.version);
		this.CSS     = (document.body && document.body.style) ? true : false;
		this.W3C     = (this.CSS && document.getElementById) ? true : false;
		this.IE      = (this.agent.indexOf('msie') != -1) ? true : false;
		this.IE3     = (this.IE && (this.major  < 4));
		this.IE4     = (this.IE && (this.major == 4) && (this.agent.indexOf('msie 5.0') == -1));
		this.IE4CSS  = (this.IE4 && this.CSS && document.all) ? true : false;
		this.IE5     = (this.IE && (this.major == 4) && (this.agent.indexOf('msie 5.0') != -1));
		this.IE55    = (this.IE && (this.major == 4) && (this.agent.indexOf('msie 5.5') != -1));
		this.IE6     = (this.IE && (this.agent.indexOf('msie 6.0') != -1) );
		this.IE7     = (this.IE && (this.agent.indexOf('msie 7.0') != -1) );
		this.IE6CSS  = (document.compatMode && (document.compatMode.indexOf('CSS1') >= 0)) ? true : false;
		this.Win2k   = (this.agent.indexOf('nt 5.0') != -1) ? true : false;
		this.WinXP   = (this.agent.indexOf('nt 5.1') != -1) ? true : false;
		this.WIN     = (this.WinXP || this.Win2k) ? true : false;
		this.MOZ     = (this.agent.indexOf('gecko') != -1) ? true : false;
		this.NS      = ((this.agent.indexOf('mozilla') != -1) &&	((this.agent.indexOf('spoofer')  ==   -1) && (this.agent.indexOf('compatible') == -1)));
		this.NS4     = (this.NS && (this.major == 4));
		this.NS6     = (this.NS && (this.major >= 5));
		this.SAFARI  = (this.agent.indexOf('safari') != -1) ? true : false;
		this.CAMINO  = (this.agent.indexOf('camino') != -1) ? true : false;
		/* #CorpTicket: 48171 - Toolbar Display Flaw - modified by chuckc on 4/29/2009 */
		this.FF      = (this.agent.indexOf('firefox') != -1) ? true : false;
		this.FF2     = (this.agent.indexOf('firefox/2') != -1) ? true : false;
		this.FF3     = (this.agent.indexOf('firefox/3') != -1) ? true : false;
		this.IE8	 = (this.IE && re.exec(ua) != null && parseFloat(RegExp.$1) == '8') ? true : false;
	}
	obj_browser = this;
	browsr = this;
	return this;
};

isAlien = function(a) {
   return isObject(a) && (typeof a.constructor != 'function');
};

isArray = function(a) {
	return isObject(a) && (a.constructor == Array);
};

isBoolean = function(a) {
	return (typeof a == 'boolean');
};

isEmpty = function(o) {
	var i, v;
	if (isObject(o)) {
		for (i in o) {
			v = o[i];
			if (isUndefined(v) && isFunction(v)) {
				return false;
			}
		}
	}
	return true;
};

isNull = function(a) {
	return (typeof a == 'object') && !a;
};

isNumber = function(a) {
	return (typeof a == 'number') && isFinite(a);
};

isObject = function(a) {
	return (a && (typeof a == 'object')) || isFunction(a);
};

isString = function(a) {
	return (typeof a == 'string');
};

isUndefined = function(a) {
	return (typeof a == 'undefined');
};

isFunction = function(a) {
	return (typeof a == 'function');
};

/*}}}*/

/* cookies
/*{{{*/

/* setCookie(name, value, expires, path, domain, secure)
/*{{{
name - name of the cookie
value - value of the cookie
[expires] - expiration date of the cookie (defaults to end of current session)
[path] - path for which the cookie is valid (defaults to path of calling document)
[domain] - domain for which the cookie is valid (defaults to domain of calling document)
[secure] - Boolean value indicating if the cookie transmission requires a secure transmission
* an argument defaults when it is assigned null as a placeholder
* a null placeholder is not required for trailing omitted arguments
*/
function setCookie(name, value, expires, path, domain, secure) {
    var value   = escape(value);
    var expires = expires ? '; expires=' + expires.toUTCString() : '';
    var path    = path ? '; path=' + path : '';
    var domain  = domain ? '; domain=' + domain : '';
    var secure  = secure ? '; secure' : '';
    var cookie  = name + '=' + value + expires + path + domain + secure;
    document.cookie = cookie;
};/*}}}*/

/* getCookie(name)
/*{{{
name - name of the desired cookie
* return string containing value of specified cookie or null if cookie does not exist
*/
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + '=';
    var begin = dc.indexOf('; ' + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(';', begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
};/*}}}*/

/* deleteCookie(name, path, domain)
/*{{{
name - name of the cookie
[path] - path of the cookie (must be same as path used to create cookie)
[domain] - domain of the cookie (must be same as domain used to create cookie)
* path and domain default if assigned null or omitted if no explicit argument proceeds
*/
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + '=' + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + '; expires=Thu, 01-Jan-70 00:00:01 GMT';
    }
};/*}}}*/

/*}}}*/

/* dates
/*{{{*/
getTime = function() {/*{{{*/
	// returns the time
	var objTime = new Date();
	var hours   = objTime.getHours();
	var minutes = objTime.getMinutes();
	var seconds = objTime.getSeconds();
	var strSuff = 'am';
	if (hours >= 12) {strSuff = 'pm'; hours = hours - 12;}
	if (hours == 0) {hours = 12;}
	if (hours <= 9) {hours = '0' + hours;}
	if (minutes <= 9) {minutes = '0' + minutes;}
	if (seconds <= 9) {seconds = '0' + seconds;}
	return [hours,minutes,seconds,strSuff];
};
// legacy call-backs
JS_getTime = function() { return getTime(); }
/*}}}*/
getDate = function() {/*{{{*/
	// returns the date
	var objDate = new Date();
	var year    = objDate.getFullYear();
	var month   = objDate.getMonth();
	var day     = objDate.getDate();
	if (month <= 9) {month = '0' + month;}
	if (day <= 9) {day = '0' + day;}
	return [day,month,year];
};
// legacy call-backs
JS_getDate = function() { return getDate(); }
/*}}}*/
setDate = function(thisForm, thisInputField, thisDay, thisMonth, thisYear) {/*{{{*/
    theField = eval('document.' + thisForm + '.' + thisInputField);
    theField.value = thisMonth + '/' + thisDay + '/' + thisYear;
    theField.focus();
}
// legacy call-backs
applyDate = function(thisForm, thisInputField, thisDay, thisMonth, thisYear) { 
	setDate(thisForm, thisInputField, thisDay, thisMonth, thisYear); 
}
JS_applyDate = function(thisForm, thisInputField, thisDay, thisMonth, thisYear) { setDate(thisForm, thisInputField, thisDay, thisMonth, thisYear); }
/*}}}*/
niceDate = function(form, inputField, inputField2, returnInfo, returnWhat, altField, bit_bypass_warning_message) {/*{{{*/
    thisForm  = eval('document.' + form);
    thisInput = eval('document.' + form + '.' + inputField);
    thisDate  = thisInput.value;
    if ((!thisDate.length > 0) && (altField != '') && (altField != null) && (altField != 'undefined')) {
        thisInputAlt = eval('document.' + form + '.' + altField);
        thisDate  = thisInputAlt.value;
    }
    if (thisDate != '') {
        strRegExp = new RegExp('\/');
        var month     = thisDate.substr(0, thisDate.search(strRegExp));
		month = (month.length != 2) ? '0' + month : month;
        thisDate  = thisDate.substr(thisDate.search(strRegExp) + 1);
        var day       = thisDate.substr(0, thisDate.search(strRegExp));
        day       = (day.length != 2) ? '0' + day : day;
        var year      = thisDate.substr(thisDate.search(strRegExp) + 1);		
		
		if (year.length != 4) {
			if (year > 60) {
				year = '19' + year.substr(year.length - 2, 1).concat(year.substr(year.length - 1, 1));
			} else {
				year = '20' + year.substr(year.length - 2, 1).concat(year.substr(year.length - 1, 1));
			}
		}

		if (!bit_bypass_warning_message) {
			if ((year < 1970) || (year > 2038)) {
				alert('The date must be between 01/01/1970 and 01/01/2038.');
			}
		}
		
        if (returnInfo) {
            switch (returnWhat) {
                case 'month' :
                    return month;
                    break;
                case 'day' :
                    return day;
                    break;
                case 'year' :
                    return year;
                    break;
            }
        } else {
            thisInput.value = month + '/' + day + '/' + year;
            if (inputField2) {
                thisInput2 = eval('document.' + form + '.' + inputField2);
                thisInput2.value = month + '/' + day + '/' + year;
            }
        }
    }
};
// legacy call-backs
JS_niceDate = function(form, inputField, inputField2, returnInfo, returnWhat, altField, bit_bypass_warning_message) { return niceDate(form, inputField, inputField2, returnInfo, returnWhat, altField, bit_bypass_warning_message); };
/*}}}*/
/*}}}*/

/* address/location
/*{{{*/

/* modifyLocation(obj_modify)
/*{{{*/
var modifyLocation = function(obj_modify) {

	str_location = location.href.toString();

	arr_location = str_location.split('?');

	str_base_url = arr_location[0];

	arr_location = arr_location[1].split('&');

	str_query_string = '';

	for (i = 0; i < arr_location.length; i++) {
		arr_tmp = arr_location[i].split('=');
		
		if (!isUndefined(obj_modify[arr_tmp[0]])) {
			str_query_string += arr_tmp[0] + '=' + obj_modify[arr_tmp[0]] + '&';
			obj_modify[arr_tmp[0]] = null;
		} else {
			str_query_string += arr_location[i] + '&';
		}
	}

	obj_modify = $H(obj_modify);

	obj_modify.each(function(arr_link) {
			if (arr_link[1] != null) {
				str_query_string = arr_link[0] + '=' + arr_link[1] + '&' + str_query_string;
			}
		}
	);

	str_query_string = str_query_string.substring(0, (str_query_string.length - 1));

	str_location = str_base_url + '?' + str_query_string;
	
	location.href = str_location;

};/*}}}*/

/* modifyObjectLocation(obj_modify, bit_return, obj_target)
/*{{{*/
var modifyObjectLocation = function(obj_modify, bit_return, obj_target) {

	if (!obj_target) {
		obj_target = window;
	}

	str_location = obj_target.location.href.toString();

	arr_location = str_location.split('?');

	str_base_url = arr_location[0];

	arr_location = arr_location[1].split('&');

	str_query_string = '';

	for (i = 0; i < arr_location.length; i++) {
		arr_tmp = arr_location[i].split('=');
		
		if (!isUndefined(obj_modify[arr_tmp[0]])) {
			str_query_string += arr_tmp[0] + '=' + obj_modify[arr_tmp[0]] + '&';
			obj_modify[arr_tmp[0]] = null;
		} else {
			str_query_string += arr_location[i] + '&';
		}
	}

	obj_modify = $H(obj_modify);

	obj_modify.each(function(arr_link) {
			if (arr_link[1] != null) {
				str_query_string = arr_link[0] + '=' + arr_link[1] + '&' + str_query_string;
			}
		}
	);

	str_query_string = str_query_string.substring(0, (str_query_string.length - 1));

	str_location = str_base_url + '?' + str_query_string;
	
	if (bit_return) {
		return str_location;
	} else {
		obj_target.location.href = str_location;
	}

};/*}}}*/

/* requestParser()
/*{{{
gets query string vars
USAGE
	arr_get_vars = requestParser();
    value = arr_get_vars[key];
*/
requestParser = function() {
    obj_request = {};
    separator   = ',';
    query       = '' + this.location;
    query       = query.substring((query.indexOf('?')) + 1);
    if (query.length < 1) {
        return false;
    }
    keypairs = {};
    numKP    = 1;
    while (query.indexOf('&') > -1) {
        keypairs[numKP] = query.substring(0,query.indexOf('&'));
        query           = query.substring((query.indexOf('&')) + 1);
        numKP++;
    }
    keypairs[numKP] = query;
    for (i in keypairs) {
        if (!keypairs[i].hasOwnProperty()) {
            if (keypairs[i] != '') {
                keyName  = keypairs[i].substring(0,keypairs[i].indexOf('='));
                keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
                while (keyValue.indexOf('+') > -1) {
                    keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
                }
                keyValue = unescape(keyValue);
                if (obj_request[keyName]) {
                    obj_request[keyName] = obj_request[keyName] + separator + keyValue;
                } else {
                    obj_request[keyName] = keyValue;
                }
            }
        }
    }
    return obj_request;
};/*}}}*/

/* requestSearch()
/*{{{
allows searching the location
USAGE
    value = requestSearch(key)
*/
requestSearch = function(key) {
    var str_regex   = "[\\?&]" + key + "=([^&#]*)";
    var obj_regex   = new RegExp(str_regex);
    var str_url     = window.location.href;
    var obj_results = obj_regex.exec(str_url);
    return (obj_results == null) ? '' : obj_results[1];
};/*}}}*/

/*}}}*/

/* events
/*{{{*/

/* handleTextInputKeypress = function(obj_parent, obj_event, str_button_id)
/*{{{*/
var handleTextInputKeypress = function(obj_parent, obj_event, str_button_id) {

	var int_keycode = 0;
	var obj_anchor_button = document.getElementById(str_button_id);
	
	if (obj_event.keyCode) {
		int_keycode = obj_event.keyCode;
	} else  {
		int_keycode = obj_event;    
	}

	if (int_keycode == 13) { // Enter Key
		if (obj_anchor_button) {
			if (obj_parent.onblur) {
				obj_parent.onblur();
				obj_parent.onblur = function() {};
			}
			//if (obj_anchor_button.onclick) obj_anchor_button.onclick();
			//location.href = obj_anchor_button.href;
			
			setTimeout("location.href = \"" + obj_anchor_button.href + "\";", 200)
		}
		return false;
	}  
	return true;
}/*}}}*/

/* setEvent(evnt, cancel_bubble, cancel_default)
/*{{{
used to handle a reference to an object for an event (X-Browser)
this is only used by the colorpicker. it should be removed and 
the colorpicker should be updated to use the prototypes built in
methods for this
*/
setEvent = function(evnt, cancel_bubble, cancel_default) {
	ref_evt = (evnt) ? evnt : ((event) ? event : null);
	if (ref_evt) {
		this.target_element = eventTarget(ref_evt);
        this.dimension_x    = eventX(ref_evt);
        this.dimension_y    = eventY(ref_evt);
		if (cancel_bubble) {
			if (document.stopPropagation) {
				ref_evt.stopPropagation();
			} else {
				ref_evt.cancelBubble = true;
			}
		}
		if (cancel_default) {
			if (ref_evt.preventDefault) {
				ref_evt.preventDefault();
			} else {
				ref_evt.keyCode     = 0;
				ref_evt.returnValue = false;
			}
		}
		return true;
	} else {
		return false;
	}
};
/*}}}*/

/*}}}*/

/* casting
/*{{{*/

/* str2int conversion
/*{{{*/
int2px = function(int_value) {/*{{{*/
	// takes an integer and appends 'px' to the end
	return int_value + 'px';
}
// legacy call-backs
px = function(int_value) { return int2px(int_value); };
/*}}}*/
px2int = function(str_value) {/*{{{*/
	// returns an integer value from a string value representing a dimension (20px = 20)
	if (isString(str_value)) {
		return parseInt(str_value.replace('px',''))
	} else {
		return str_value;
	}
};
// legacy call-backs
pxToInt   = function(incVal) { return px2int(incVal); }
px2Int    = function(incVal) { return px2int(incVal); }
JS_px2Int = function(incVal) { return px2int(incVal); }
/*}}}*/
pt2int = function(str_value) {/*{{{*/
	// returns an integer value from a string value representing a dimension (20px = 20)
	if (isString(str_value)) {
		return parseInt(str_value.replace('pt',''))
	} else {
		return str_value;
	}
}; /* }}} */
/*}}}*/

/* rgb2hex
/*{{{*/
function toHex(N) {
    if (N == null) {
        return '00';
    }
    N = parseInt(N);
    if (N == 0 || isNaN(N)) {
        return '00';
    }
    N = Math.max(0,N);
    N = Math.min(N,255);
    N = Math.round(N);
    return ('0123456789ABCDEF' . charAt((N - N % 16) / 16) + '0123456789ABCDEF' . charAt(N % 16));
}

function rgb2hex(str) {
    if (str.indexOf('rgb') == -1) {
        return str;
    }
    str = str.replace('rgb', '');
    str = str.replace('(', '');
    str = str.replace(')', '');
    str = str.replace(' ', '');
    str = str.replace(' ', '');
    var temp = new Array();
    temp = str.split(',');
    var r = temp[0];
    var g = temp[1];
    var b = temp[2];
    return '#' + toHex(r) + toHex(g) + toHex(b);
}
/*}}}*/

/* util_color_blur()
/*{{{
custom color blur function
takes any number of hex codes and finds their blurred match
*/
util_color_blur = function() {
	var arr_arguments     = arguments;
	var int_arguments     = arr_arguments.length;
	var int_iterator      = 0;
	var int_iterator_step = 0;
	var int_radix         = 16;
	var int_color_mix     = 0;
	var arr_rgb           = [];
	var int_rgb_split     = 3;
	var arr_colors        = [];
	var arr_color_mix     = [];
	var arr_steps         = [];
	var str_color         = '';
	for (int_iterator = 0; int_iterator < int_arguments; int_iterator++) {
		// check args for pound(#) character and remove if exists
		arr_colors[int_iterator] = (arr_arguments[int_iterator].substr(0,1) == '#') ? arr_arguments[int_iterator].substring(1) : arr_arguments[int_iterator];
		// check for 3 or 6 digit hex code
		arr_steps[int_iterator]  = (arr_colors[int_iterator].length > 3) ? 2 : 1;
	}
	for (int_iterator = 0; int_iterator < int_rgb_split; int_iterator++) {
		for (int_iterator_step = 0; int_iterator_step < int_arguments; int_iterator_step++) {
			int_step_mix   = parseInt(arr_colors[int_iterator_step].substr((arr_steps[int_iterator_step] * int_iterator), arr_steps[int_iterator_step]), int_radix);
			int_color_mix += ((arr_steps[int_iterator_step] != 2) ? ((int_radix * int_step_mix) + int_step_mix) : int_step_mix) * 50;
		}
		arr_rgb[int_iterator] = Math.floor(int_color_mix / 100);
		int_color_mix         = 0;
	}
	for (int_iterator = 0; int_iterator < int_rgb_split; int_iterator++) {
		str_color += arr_rgb[int_iterator].toString(int_radix);
	}
	return str_color;
};
/* }}} */

/*}}}*/

/* toggles
/*{{{*/


/* toggle_Display(incObj, incSwitch, doReturn)
/*{{{*/
toggle_Display = function(incObj, incSwitch, doReturn) {
	var obj       = $(incObj);
	var objSwitch = incSwitch ? incSwitch : 'block';
	if (obj) {
		obj.style.display = incSwitch ? (obj.style.display = objSwitch) : ((obj.style.display == objSwitch) ? 'none' : objSwitch);
		if (doReturn) {
			return obj.style.display;
		}
	}
};
JS_toggle_Display = function(incObj, incSwitch, doReturn) { return toggle_Display(incObj, incSwitch, doReturn); };
hideDiv           = function(name) { return toggle_Display(name); };
/*}}}*/

/* toggle_Visibility(incObj, incSwitch)
/*{{{*/
toggle_Visibility = function(incObj, incSwitch) {
	var obj       = $(incObj);
	var objSwitch = incSwitch ? incSwitch : 'visible';
	obj.style.visibility = (obj.style.visibility == objSwitch) ? 'hidden' : objSwitch;
};/*}}}*/

/*}}}*/

/* packages
/*{{{*/

/* nativeBrowserObjects {}
/*{{{
this is used to remove certain browser objects like select boxes
when custom objects are not able to flow over the top of them
sure there is a better way(dom iframe then overlay with menu)
*/
var nativeBrowserObjects = {
    list : {
        initial : ['select', 'object', 'embed'],
        actual : []
    },
    state : {
        initial : 'visible',
        actual : null
    },
    getState : function(var_state) {
        var state;
        if (isNull(var_state)) {
            state = (this.state.actual == 'visible') ? 'hidden' : 'visible';
        } else if (isNumber(var_state)) {
            state = (var_state > 1) ? 'visible' : 'hidden';
        } else {
            state = ((var_state == 'visible') || (var_state == 'hidden')) ? var_state : null;
        }
        return state;
    },
    toggle : function(var_state) {
        this.state.actual = this.getState(var_state);
        if (this.list.actual.length == 0) {
			this.list.actual = this.list.initial;
		}
        if (!isNull(this.state.actual)) {
            for (i = 0; i < this.list.actual.length; i++) {
                var str_item = this.list.actual[i];
                // EJF:2007.01.15:32421
                // this was added to prevent headers from disapearing on menu flyouts
                // unfortunately this will prevent page content(flash, movies, etc.) from being disabled as well, which could render menus useless
                // this is only done in logged out mode
                //if (((str_item == 'object') || (str_item == 'embed')) && (int_user_id == '0')) {
                //    continue;
                //}
                var arr_nodes = document.getElementsByTagName(str_item);
                for (j = 0; j < arr_nodes.length; j++) {
                    arr_nodes[j].style.visibility = this.state.actual;
                }
            }
        }
    },
    show : function() {
        this.toggle('visible');
    },
    hide : function() {
        this.list.actual = (arguments.length > 0) ? arguments : this.list.initial;
        this.toggle('hidden');
    }
};
// legacy call-backs
toggle_nativeBrowserObjects = function(bit_state) { nativeBrowserObjects.toggle(bit_state); };
JS_swapSelects = function(bit_state) { nativeBrowserObjects.toggle(bit_state); };
/*}}}*/

/* Url {}
/*{{{
URL encode / decode
http://www.webtoolkit.info/
*/
var Url = {
    // public method for url encoding
    encode : function (string) {
        return escape(this._utf8_encode(string));
    },
    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },
    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";
        for (var n = 0; n < string.length; n++) {
            var c = string.charCodeAt(n);
            if (c < 128) {
                utftext += String.fromCharCode(c);
            } else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            } else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }
        }
        return utftext;
    },
    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;
        while ( i < utftext.length ) {
            c = utftext.charCodeAt(i);
            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            } else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            } else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }
        }
        return string;
    }
};/*}}}*/

/* EditWin {}
/*{{{
global space, required so that iframes have a way to reference the active edit window
this may eventually become am array if we need more than 1(one) instance of the edit window open
*/
var str_edit_win_name;
var int_push_edit_win_height;

var EditWin = {
	EditFrame             : null,
	str_edit_win_title    : 'edit-win',
	str_edit_win_name     : '',
	int_edit_win_id       : 0,
	str_wait_message      : 'Loading Edit Window',
	str_default_tab       : 'edit-win-tab-general',
	bit_resize            : true,
	obj_dimensions : {/*{{{*/
		scrollbar : 20,
		int_top   : 25,
		int_left  : 20,
		width     : 450,
		height    : 300
	},/*}}}*/
	set_args : function(arguments) {/*{{{*/
		if (isObject(arguments)) {
			this.obj_dimensions.width    = arguments.width || this.obj_dimensions.width;
			this.obj_dimensions.height   = arguments.height || this.obj_dimensions.height;
			this.obj_dimensions.int_top  = arguments.top || this.obj_dimensions.int_top;
			this.obj_dimensions.int_left = arguments.left || this.obj_dimensions.int_left;
		}
		/* for (i in this.obj_dimensions) { alert(i + ':' + this.obj_dimensions[i]); } */
	},/*}}}*/
	set_window_title : function(str) {/*{{{*/
		return str.properizeFromUnderCaps(isEmpty(str) ? 'EDIT_WINDOW' : str);
	},/*}}}*/
	set_window_name : function(str) {/*{{{*/
        str = str.replace(/-/g, '');
        str = str.replaceSpaces(isEmpty(str) ? 'EDIT_WINDOW' : str);
		return str;
	},/*}}}*/
	create : function(str_edit_content_src, str_window_title, arguments) {/*{{{*/
		//this.set_ids(1);
		this.str_edit_win_name = str_edit_win_name;
		this.set_args(arguments);
		var str_window_name  = this.set_window_name(str_window_title);
//alert(str_window_name);
		var str_window_title = this.set_window_title(str_window_title);
		var obj_arguments    = this.obj_dimensions;
		var str_arguments    = 'resizable=1,status=0,toolbar=0,location=0,menubar=0,scrollbars=1,';
		
		for (i in obj_arguments) {			
			if (i == 'int_top') {
				str_text = 'top';
			} else if (i == 'int_left') {
				str_text = 'left';
			} else {
				str_text = i;
			}			
			if (i != 'scrollbar') {
				str_arguments += str_text + '=' + obj_arguments[i] + ',';			
			}
		}
		str_arguments = str_arguments.substr(0, (str_arguments.length - 1));
//alert('str_arguments (post) : ' + str_arguments);
//alert('str_edit_content_src : ' + str_edit_content_src);
//alert('str_window_name : ' + str_window_name);
		win = window.open(str_edit_content_src, str_window_name, str_arguments);
//alert(typeof win);
		win.focus();
		return win;
	},/*}}}*/
	resize : function(incLookup, incAddon, reFocus) {/*{{{*/
		if (!this.bit_resize) {
			return false;
		}

		var bit_do_resize = 0;
		var int_curr_width = $J(window).width();
		var int_curr_height = $J(window).height();
		
		var int_new_width = $J("#edit-win-tab-content-container").width();
		var int_new_height = $J("body").height();
		
		if (int_new_width != int_curr_width) {
			bit_do_resize = 1;
			int_new_width += 15;
		}

		if (int_new_height != int_curr_height) {
			bit_do_resize = 1;
			int_new_height += 120;
		}

		if (bit_do_resize) {

			if (int_new_width < 600) {
				int_new_width = 600;
			}

			window.resizeTo(int_new_width, int_new_height);
		}

	},/*}}}*/
	submit : function() {/*{{{*/
	    if (top.EditWin.EditFrame) {
		    this.resize(true);
		    obj_content_container = $(str_edit_win_name).childNodes[1];
		    obj_content_container.insertBefore(this.waitframe('Saving your data'), obj_content_container.firstChild);
		}
	},/*}}}*/
	close : function(reload, url) {/*{{{*/
		//alert('being called from inside the EditWin class');
		self.close();
		if (reload) {
			opener.location.reload();
		}
	}/*}}}*/
	/*waitframe : function(msg) {/*{{{*//*
		var str_message = msg ? msg : this.str_wait_message;
		obj_wait_frame = document.createElement('div');
		obj_wait_frame.id = this.str_edit_win_title + '-wait-' + this.int_edit_win_id;
		Element.setStyle(obj_wait_frame, {'width':'100%', 'height':'100%', 'background-color':'#EFEFEF', 'text-align':'center', 'vertical-align':'middle'});
		obj_table = obj_wait_frame.appendChild(document.createElement('table'));
		Element.setStyle(obj_table, {'width':'100%', 'height':'100%'});
		obj_tbody = obj_table.appendChild(document.createElement('tbody'));
		obj_row = obj_tbody.appendChild(document.createElement('tr'));
		obj_cell = obj_row.appendChild(document.createElement('td'));
		Element.setStyle(obj_cell, {'width':'100%', 'height':'100%', 'font-weight':'bold'});
		obj_cell.setAttribute('align', 'center');
		obj_cell.setAttribute('valign', 'middle');
		obj_wait_image = obj_cell.appendChild(obj_image_wait);
		obj_wait_image.setAttribute('align', 'middle');
		Element.setStyle(obj_wait_image, {'padding':'0px 2px'});
		obj_cell.appendChild(document.createTextNode(str_message));
		obj_wait_frame.appendChild(obj_table);
		return obj_wait_frame;
	},/*}}}*/
};/*}}}*/

/* Tabs {}
/*{{{
used to activate and deactivate the tabs in edit windows
*/
var Tabs = {
    prefix  : 'edit-win-tab-',
	current : {},
	initial : function() {/*{{{*/
		str_master_container             = 'edit-win-tab-content-container';
		bit_master_container_exists      = $(str_master_container) ? true : false;
		if (!bit_master_container_exists) {
			//alert("An error has occured. Please contact Support.\n\nThe tab container is not wrapped around the content.");
			//alert('this window needs the tab container wrapped around it\'s content for resizing to work correctly');
		}
		str_default_tab_container        = getCookie('EditWinTab');
		bit_default_tab_container_exists = $(str_default_tab_container + '-container') ? true : false;
		if (bit_default_tab_container_exists) {
			// great, the tab from the cookie exists
			element_id = str_default_tab_container;
		} else {
			// the default tab from the cookie doesnt exist in this window
			// find the tabs on the page
			var arr_tab_containers = document.getElementsByClassName('edit-win-options');
			if (arr_tab_containers.length > 0) {
				element_id = arr_tab_containers[0].id.replace('-container','');
			} else {
				element_id = str_master_container.replace('-container','');
			}
		}
		return element_id;
	},/*}}}*/
	prep : function() {/*{{{*/
		element_id = this.initial();
		if (!isString(element_id)) {
			element_id = self.str_default_tab;
		}
		Tabs.swap_tabs(element_id);
	},/*}}}*/
	toggle : function(selected_element) {/*{{{*/
	    obj_selected_element = $(selected_element);
		if (isObject(obj_selected_element)) {
			element_id = obj_selected_element.id;
		} else if (getCookie('EditWinTab')) {
			element_id = getCookie('EditWinTab');
		} else {
			element_id = self.str_default_tab;
		}	
		this.set_cookie(element_id);
	    if (!(obj_selected_element.href.length > 0)) {
		    Tabs.swap_tabs(element_id);
		    EditWin.resize();
		}
	},/*}}}*/
	//### v8.0 Framework B 4.3.1(ticket#129) - Default to first Tab in all popups - Changed by SAS 5-29-08
	//### added the unset_cookie to be able to unset the tab cookie
	//### added set_cookie_temp to be able to get past imageresize unsetting the tab on the way back to main edit wins from image upload/resize
	set_cookie : function(selected_element) {/*{{{*/
		//alert('Setting Cookie:' + selected_element);
		setCookie('EditWinTab', selected_element, '', '/');
	},/*}}}*/
	set_cookie_temp : function() {/*{{{*/
		//alert('Setting TEMP cookie');
		setCookie('EditWinTab_TEMP', getCookie('EditWinTab'), '', '/');
	},/*}}}*/
	unset_cookie : function() {/*{{{*/
		//alert('UN-Setting cookie');
		setCookie('EditWinTab', '', '', '/');
	},/*}}}*/

	swap_tabs : function(selected_element) {/*{{{*/
		//alert("Default : " + EditWin.str_default_tab + "\nSelected: " + selected_element);
		element_id       = !$(selected_element) ? EditWin.str_default_tab : selected_element;
		selected_tab     = $(element_id);
		selected_element = $(element_id + '-container');
		this.current = selected_element;
		$A(document.getElementsByClassName('edit-win-options')).each(function(obj) {
			Element.setStyle(obj, {'display':'none'});
		});
		Element.removeClassName(document.getElementsByClassName('selected-tab', $('edit-win-tabs-container'))[0], 'selected-tab');
		Element.setStyle(selected_element, {'display':'block'});
		Element.addClassName(selected_tab, 'selected-tab');
	}/*}}}*/
}/*}}}*/

/* Button {}
/*{{{*/
var Button = {
	bit_forget_tab_cookie : 1,
	set : function(form, obj) {
		obj_form        = $(form);
		obj_input       = document.createElement('input');
		obj_input.name  = 'form_action';
		obj_input.type  = 'hidden';
		obj_input.value = obj;
		obj_form.appendChild(obj_input);
	},
	add : function(obj, name) {
		obj_form        = $(obj).form;
		obj_input       = document.createElement('input');
		obj_input.id    = name;
		obj_input.name  = name;
		obj_input.type  = 'hidden';
		obj_input.value = 1;
		obj_form.appendChild(obj_input);
	},
	prep : function(obj) {
		obj_orig    = $(obj);
		obj_form    = obj_orig.form;
		action_name = 'form_action';
		if (obj_form) {
			if (obj_orig) {
				obj_orig.name = action_name;
			} else {
				action       = document.createElement('input');
				action.name  = action_name;
				action.type  = 'hidden';
				action.value = obj;
				obj_form.appendChild(action);
			}
		}
	},
    disable : function(str_button) {
        // EJF:2007.01.12:29882
        // this takes a partial classname in the form of 'skin-button-NAME'
        // which is then used to locate a single button on a page and disable it completely
        // call with a simple Button.disable('done'); || Button.disable('save');
		// This was adding a 5-30 second lag time when opening the ACE.  MRP, 2007.01.13
        // EJF:2007.01.15:32434
        // fixed by looking for button name specifically instead of classname
        // if the button name is not found in the form 'doNAME_anchor' then we exit
        obj = $('do' + str_button + '_anchor');
        if (isObject(obj)) {
            Element.removeClassName(obj, 'skin-button-' + str_button );
            Element.addClassName(obj, 'skin-button-' + str_button + '-grayed');
            obj.setAttribute('href', 'javascript://');
        }
    },
	click : function(obj, form) {
		//### v8.0 Framework B 4.3.1(ticket#129) - Default to first Tab in all popups - Changed by SAS 5-29-08
		//### unset cookie when any buttons are clicked except these(for now)
		if((obj != 'dosave') && (obj != 'dorecur')&& (obj != 'dosavenew') && (obj != 'doupload') && (obj != '')){	
			if (this.bit_forget_tab_cookie) {
				//alert('Click, unsetting cookie!');
				Tabs.unset_cookie();
			}
		}
		var str_temp_win_tab = getCookie('EditWinTab_TEMP');
		if(str_temp_win_tab){
			//alert('Click, toggling cookie');
			setCookie('EditWinTab', getCookie('EditWinTab_TEMP'), '', '/');
			setCookie('EditWinTab_TEMP', '', '', '/');
		}
		if (form) {
			var obj_form = $(form);
			if (eval('obj_form.' + obj)) {
				obj_form.submit();
			}
		} else {
			var obj_target = $(obj);
			if (obj_target && obj_target.form) {
				obj_target.form.submit();
			}
		}
	},
	close : function() {
		opener.focus();
		opener.location.reload();
		window.close();
	}
};/*}}}*/

/*}}}*/

/*}}}*/

/* stuff that needs to be gotten rid of
/*{{{*/

/* getReference(incObj, incType)
/*{{{
*** DEPRECATE
*/
getReference = function(incObj, incType) {
	// can take a string or object
	// can reference objects by frame location
	// can reference objects by tag, name, or id
	var version = -1; //version checker for ie
	if (browsr.IE) {
		var ua = navigator.userAgent;
	    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
	    if (re.exec(ua) != null) {
			  version = parseFloat( RegExp.$1 );
		}
	}

	if (incObj && typeof incObj == 'object') {
		return incObj;
	}

	incType  = incType ? incType : null;
	objRef   = document;

	// CorpTicket:49789 - in IE8 it need to skip this or it will cause problems for expanding nav - changed by BIrons on Aug 27, 2009
	if (objRef.all && !(browsr.IE && version == 8)) {
		return (incType == 'tagName') ? objRef.all.tags(incObj) : objRef.all.item(incObj);
	} else if (objRef.getElementById) {
		return (incType == 'tagName') ? objRef.getElementsByTagName(incObj) : objRef.getElementById(incObj);
	} else {
		return false;
	}
};
JS_getReference = function(incObj, incType, incFrame) { return getReference(incObj, incType, incFrame); } // 
getRef = function(incObj, incType, incFrame) { return getReference(incObj, incType, incFrame); } // 
/*}}}*/

/* JS_status(incContent)
/*{{{*/
JS_status = function(incContent) {
	top.status = incContent ? incContent : '';
    return true;
};/*}}}*/

/*}}}*/


