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

// these are set in here so that we can append methods as prototypes to the
// actual Prototype Objects, this way when we ditch IE5 we don't have to
// rewrite all of our calls

if (!window.Element) {
    var Element = new Object();
}
var Position = new Object();
var Form = new Object();

SC = {
	console : {
		log : function(str, obj) {
			if (window.console) {
				console.log(str, obj);
			}
		}
	}
}

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;
	}
}

String.prototype.toArray = function() {
    return this.split('');
};

var $A = Array.from = function(iterable) {
    if (!iterable) {
        return [];
    }
    if (iterable.toArray) {
        return iterable.toArray();
    } else {
        var results = [];
        for (var i = 0; i < iterable.length; i++) {
            results.push(iterable[i]);
        }
        return results;
    }
};

Function.prototype.bind = function() {
    var __method = this;
    var args     = $A(arguments);
    var object   = args.shift();
    return function() {
        return __method.apply(object, args.concat($A(arguments)));
    }
};

/* Trying to hack around the prototype dependencies... */
/* PROTOTYPE HACKS {{{ */

Position['reDrawScreen'] = function() {
    // Bug #23081 - Top Nav Not Working in Safari; RGB; 30-Aug-2006
    // Force a redraw of the window to display menus despite Safari bug.
    if (navigator.appVersion.match(/Konqueror|Safari|KHTML/i)) {
        window.resizeTo(self.outerWidth + 1, self.outerHeight);
        window.resizeTo(self.outerWidth - 1, self.outerHeight);
    }
};

Form['getInputs'] = function(form, typeName, name) {
    form = $(form);
    var inputs = form.getElementsByTagName('input');
    if (!typeName && !name) {
        return inputs;
    }
    var matchingInputs = new Array();
    for (var i = 0; i < inputs.length; i++) {
        var input = inputs[i];
        if ((typeName && input.type != typeName) || (name && input.name != name)) {
            continue;
        }
        matchingInputs.push(input);
    }
    return matchingInputs;
};

Element['truncateChildren'] = function(element) {
	var element = $(element);
	while (element.hasChildNodes()) {
		element.removeChild(element.firstChild);
	}
}

Element['removeClassName'] = function(id, class_name) {
	/*
	str_name = id.className;
	int_start = str_name.indexOf(class_name);
	int_end = int_start + class_name.length;
	id.className = str_name.slice(int_start, int_end);
	*/
	str_name = id.className;
	int_index = str_name.indexOf(class_name);
	id.className = str_name.substr(0, int_index) + str_name.substr(int_index + class_name.length);
}
removeClassName = function(id, class_name) { Element.removeClassName(id, class_name); };

Element['addClassName'] = function(id, class_name) {
    if (id) {
		//alert(id.id + ' : ' + class_name);
		
		var str_name = '';
		str_name = id.className;
		id.className = str_name + " " + class_name;
	}
}
addClassName = function(id, class_name) { Element.addClassName(id, class_name); };

Element['getStyle'] = function(element, style) {
    element = $(element);
    var value = element.style[style.camelize()];
    if (!value) {
      if (document.defaultView && document.defaultView.getComputedStyle) {
        var css = document.defaultView.getComputedStyle(element, null);
        value = css ? css.getPropertyValue(style) : null;
      } else if (element.currentStyle) {
        value = element.currentStyle[style.camelize()];
      }
    }

    return ((value == 'auto') ? null : value);
}
Element['setStyle'] = function(element, style) {
    element = $(element);
    for (name in style) {
        if (name.indexOf('float') != -1) {
            if (element.style.cssFloat != undefined) {
                element.style.cssFloat = style[name];
            } else {
                element.style.styleFloat = style[name];
            }
        } else {
            element.style[name.camelize()] = style[name];
        }
    }
}
Element['getStyleAbsolute'] = function(element, style) {
    do {
        style_found = Element.getStyle(element, style);
        element = element.parentNode;
    } while (isNull(style_found) && element);
    return style_found;
}
Element['scrollable'] = function(element) {
        element = $(element);
        return ((element.scrollHeight > element.offsetHeight) || (element.scrollWidth > element.offsetWidth));
}

Element['cleanWhitespace'] = function(element) {
	element = $(element);
	if (element) {
		for (var i = 0; i < element.childNodes.length; i++) {
			var node = element.childNodes[i];
			if ((node.nodeType == 3) && !/\S/.test(node.nodeValue)) {
				node.parentNode.removeChild(node);
			}
		}
	}
}
cleanWhitespace = function(element) { Element.cleanWhitespace(element); }

String.prototype.camelize = function() {
    var oStringList = this.split('-');
    if (oStringList.length == 1) return oStringList[0];

    var camelizedString = this.indexOf('-') == 0
      ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1)
      : oStringList[0];

    for (var i = 1, len = oStringList.length; i < len; i++) {
      var s = oStringList[i];
      camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
    }

    return camelizedString;
}

Position['realOffset'] = function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.scrollTop  || 0;
      valueL += element.scrollLeft || 0;
      element = element.parentNode;
    } while (element);
    return [valueL, valueT];
};

Position['cumulativeOffset'] = function(element) {
	
	var valueT = 0, valueL = 0;
	
	do {
		valueT += element.offsetTop  || 0;
		valueL += element.offsetLeft || 0;
		element = element.offsetParent;
	} while (element);
	
	return [valueL, valueT];
	
};
cumulativeOffset = function(element) { return Position.cumulativeOffset(element); }

Position['positionedOffset'] = function(element) {
	var valueT = 0, valueL = 0;
	do {
		valueT += element.offsetTop  || 0;
		valueL += element.offsetLeft || 0;
		element = element.offsetParent;
		if (element) {
			p = Element.getStyle(element, 'position');
			if (p == 'relative' || p == 'absolute') {
				break;
			}
		}
	} while (element);
	return [valueL, valueT];
};

function $$(selector) {/*{{{*/
  // Attempt to fail gracefully in lesser browsers
  if (!document.getElementsByTagName) {
    return new Array();
  }
  // Split selector in to tokens
  var tokens = selector.split(' ');
  var currentContext = new Array(document);
  for (var i = 0; i < tokens.length; i++) {
    token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
    if (token.indexOf('#') > -1) {
      // Token is an ID selector
      var bits = token.split('#');
      var tagName = bits[0];
      var id = bits[1];
      var element = document.getElementById(id);
	  if (!element) {
		return new Array();
	  }
      if (tagName && element.nodeName.toLowerCase() != tagName) {
        // tag with that ID not found, return false
        return new Array();
      }
      // Set currentContext to contain just this element
      currentContext = new Array(element);
      continue; // Skip to next token
    }
    if (token.indexOf('.') > -1) {
      // Token contains a class selector
      var bits = token.split('.');
      var tagName = bits[0];
      var className = bits[1];
      if (!tagName) {
        tagName = '*';
      }
      // Get elements matching tag, filter them for class selector
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        if (tagName == '*') {
            elements = getAllChildren(currentContext[h]);
        } else {
            elements = currentContext[h].getElementsByTagName(tagName);
        }
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      continue; // Skip to next token
    }
    // Code to deal with attribute selectors
    if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
      var tagName = RegExp.$1;
      var attrName = RegExp.$2;
      var attrOperator = RegExp.$3;
      var attrValue = RegExp.$4;
      if (!tagName) {
        tagName = '*';
      }
      // Grab all of the tagName elements within current context
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        if (tagName == '*') {
            elements = getAllChildren(currentContext[h]);
        } else {
            elements = currentContext[h].getElementsByTagName(tagName);
        }
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      var checkFunction; // This function will be used to filter the elements
      switch (attrOperator) {
        case '=': // Equality
          checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
          break;
        case '~': // Match one of space seperated words 
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
          break;
        case '|': // Match start with value followed by optional hyphen
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
          break;
        case '^': // Match starts with value
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
          break;
        case '$': // Match ends with value - fails with "Warning" in Opera 7
          checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
          break;
        case '*': // Match ends with value
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
          break;
        default :
          // Just test for existence of attribute
          checkFunction = function(e) { return e.getAttribute(attrName); };
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (checkFunction(found[k])) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
      continue; // Skip to next token
    }
    
    if (!currentContext[0]){
    	return;
    }
    
    // If we get here, token is JUST an element (not a class or ID selector)
    tagName = token;
    var found = new Array;
    var foundCount = 0;
    for (var h = 0; h < currentContext.length; h++) {
      var elements = currentContext[h].getElementsByTagName(tagName);
      for (var j = 0; j < elements.length; j++) {
        found[foundCount++] = elements[j];
      }
    }
    currentContext = found;
  }
  return currentContext;
};

function getAllChildren(e) {
  // Returns all children of element. Workaround required for IE5/Windows. Ugh.
  return e.all ? e.all : e.getElementsByTagName('*');
}

/*
function $$() {
	return $A(arguments).map(function(expression) {
		return expression.strip().split(/\s+/).inject([null], function(results, expr) {
			var selector = new Selector(expr);
			return results.map(selector.findElements.bind(selector)).flatten();
		});
	}).flatten();
}
*/

/*}}}*/

/* }}} */

/*===========================================================================*/
/* SchoolCenter */
/*==========================================================================*/
/*===========================================================================*/
/* MIGRATED */
/*===========================================================================*/
/*

String.prototype.replaceSpaces = function(str) {
	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;
}
*/

/*
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
/*}}}*/
/*
pulled from lib_dimensions
*//*{{{ window dimension methods */
getScreenDims = function() {
	return [(window.screen.width ? window.screen.width : 550), (window.screen.height ? window.screen.height : 720)];
}
getWindowWidth = function() {
	if (window.innerWidth) {
		//alert('getWindowWidth : window.innerWidth\nouterWidth : ' + window.outerWidth);
		return window.innerWidth;
	} else if (document.body.parentElement && document.body.parentElement.clientWidth) {
		//alert('getWindowWidth : document.body.parentElement.clientWidth');
		return document.body.parentElement.clientWidth;
	} else if (document.body && document.body.clientWidth) {
		//alert('getWindowWidth : document.body.clientWidth');
		return document.body.clientWidth;
	}
	//alert('getWindowWidth : 0');
	return 0;
};
// 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;
};
getContentDims = function() {
    var myWidth = 0, myHeight = 0;
    if (typeof(window.innerWidth) == 'number') {
        // 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];
};
/*}}}*/
/*
allows us to set floats easily on DOM nodes
used by the colorpicker
*/
function setFloat(incObj, dir) { Element.setStyle(incObj, {'float':dir}); }
function JS_setFloat(incObj, dir) { Element.setStyle(incObj, {'float':dir}); }
/*
These functions add much needed bitwise cast checking
*/
/*{{{ Type Checking */
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');
};
/*}}}*/
/*
checks browser types
it is a good policy to not use this to determine the browser
we should be using feature detection instead
*/
/*
// OLD
var browserCheck = function() {
	if (document.images) {
		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));
	}
};
*/

// NEW
var obj_browser = null;
var browsr = null;
var browserCheck = function() {
	if (!isNull(obj_browser)) {
		return obj_browser;
	}
	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;
	}
	obj_browser = this;
	browsr = this;
	return this;
};


/*
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;
	}
};
/*}}}*/

Element.extend = function(element) {
  if (!element) return;

  if (!element._extended && element.tagName && element != window) {
    var methods = Element.Methods;
    for (property in methods) {
      var value = methods[property];
      if (typeof value == 'function')
        element[property] = value.bind(null, element);
    }
  }

  element._extended = true;
  return element;
}
/* $()
/*{{{*/
function $(element) {
	if (arguments.length > 1) {
		for (var i = 0, elements = [], length = arguments.length; i < length; i++) {
			elements.push($(arguments[i]));
		}
		return elements;
	}
	if (typeof element == 'string') {
		element = document.getElementById(element);
	}
	return Element.extend(element);
};
getReference = $;
JS_getReference = $;
getRef = $;
/*}}}*/

/*
this is legacy
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;
browsr = new browserCheck();
utilities = function() {
	//alert('made it to loader');
	// setup the browser checks
	browsr = new browserCheck();
};

/*
used to toggle the display style value
*/
toggle_Display = function(incObj, incSwitch, doReturn) {/*{{{*/
	var obj       = document.getElementById(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;
		}
	}
};
// legacy call-backs

JS_toggle_Display = function(incObj, incSwitch, doReturn) { return toggle_Display(incObj, incSwitch, doReturn); };
hideDiv           = function(name) { return toggle_Display(name); };
/*}}}*/
/*
used to toggle the visibility style value
*/
toggle_Visibility = function(incObj, incSwitch) {/*{{{*/
	var obj       = document.getElementById(incObj);
	var objSwitch = incSwitch ? incSwitch : 'visible';
	obj.style.visibility = (obj.style.visibility == objSwitch) ? 'hidden' : objSwitch;
};
/*}}}*/
/*
cookie functions
*//*{{{*/
/*
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.toGMTString() : '';
    var path    = path ? '; path=' + path : '';
    var domain  = domain ? '; domain=' + domain : '';
    var secure  = secure ? '; secure' : '';
    var cookie  = name + '=' + value + expires + path + domain + secure;
    //alert(cookie);
    document.cookie = cookie;
}
/*
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));
}
/*
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';
    }
}
/*}}}*/
/*
returns the rendered height of an element
legacy code
used by colorpicker
should be replaced by the prototype getHeight method
*/
Element['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);
};
function getHeight(incDiv) { return Element.getHeight(incDiv); };
function JS_getHeight(incDiv) { return getHeight(incDiv); } // dereferenced
/*}}}*/
/*
moved from lib_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); };
/*}}}*/
/*===========================================================================*/
/* NEWLY CREATED */
/*===========================================================================*/
/*
string functions to help strip and build colors and fonts
*/
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;
	}
}; /* }}} */
// 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) {/*{{{*/
		if (isEmpty(str)) {
			return 'EDIT_WINDOW';
		}
		var str_list = str.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;
		//return str.properizeFromUnderCaps(isEmpty(str) ? 'EDIT_WINDOW' : str);
	},/*}}}*/
	set_window_name : function(str) {/*{{{*/
		//if (isEmpty(str)) {
		if (!str) {
			return 'EDIT_WINDOW';
		}
		var str_list = str.split(' ');
	    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;
		//return str.replaceSpaces(isEmpty(str) ? 'EDIT_WINDOW' : 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,statusbar=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));
		win = window.open(str_edit_content_src, str_window_name, str_arguments);
		win.focus();
		return win;
	},/*}}}*/
	resize : function(incLookup, incAddon, reFocus) {/*{{{*/
		if (!this.bit_resize) {
			return false;
		}
		str_mark                 = incLookup;
		obj_resize_mark          = document.getElementById(str_mark) || document.getElementById('br');
		int_dim_scroll           = 20;
		int_dim_title            = 24;
		int_dim_status           = 30;
		arr_chrome_dims          = [0, int_dim_title + int_dim_status];
		arr_marker_dims_tmp_orig = cumulativeOffset(document.getElementById('br'));
		arr_marker_dims_tmp      = cumulativeOffset(obj_resize_mark);
		//arr_marker_dims          = [arr_marker_dims_tmp[0] + 10, arr_marker_dims_tmp[1] + 2];
		int_orig_width = arr_marker_dims_tmp_orig[0] + 10;
		if (str_mark == 'br2') {
			arr_marker_dims = [int_orig_width, arr_marker_dims_tmp[1] + 2];
		} else {
			arr_marker_dims = [int_orig_width, arr_marker_dims_tmp[1] + 2];
		}
		arr_screen_dims          = getScreenDims();
		arr_window_dims          = [getWindowWidth(), getWindowHeight()];
		arr_maximum_dims         = [(arr_screen_dims[0] - 100), (arr_screen_dims[1] - 100)];
		arr_new_dims             = [(arr_marker_dims[0] + arr_chrome_dims[0]), (arr_marker_dims[1] + arr_chrome_dims[1])];
		arr_original_dims        = arr_new_dims;
		// get container heights, make sure to check if they exist before trying to get their dimensions
		str_element_header       = 'edit-win-header-image-container';
		int_dim_header_height    = document.getElementById(str_element_header) ? px2int(Element.getHeight(str_element_header)) : 0;
		str_element_tabbar       = 'edit-win-tabs';
		int_dim_tabbar_height    = document.getElementById(str_element_tabbar) ? px2int(Element.getHeight(str_element_tabbar)) : 0;
		str_element_buttonbar    = 'edit-win-buttons';
		int_dim_buttonbar_height = document.getElementById(str_element_buttonbar) ? (px2int(Element.getHeight(str_element_buttonbar)) + 5) : 0;
		// add dims from non scrollable elements
		int_dim_non_scrollable   = int_dim_header_height + int_dim_tabbar_height + int_dim_buttonbar_height;
		
		// get width of active element
		bit_exceeded_width       = false;
		int_exceeded_width       = 0;
		
		// get height of active element
		str_current_tab          = Tabs.initial() + '-container';
		// the var 'int_dim_content_height' below is where the buttons are
		// getting messed up in FireFox pre 1.5, there is a 16px difference
		// between the versions in how the height is being calculated.
		// We can do one of two things...
		//	1) catch major/minor version and hardcode a px modification
		//	2) patch prototype to account for the difference
		int_dim_content_height   = px2int(Element.getHeight(str_current_tab));
		bit_exceeded_height      = (int_dim_content_height > arr_marker_dims[1]) ? true : false;
		int_exceeded_height      = bit_exceeded_height ? (int_dim_content_height - arr_marker_dims[1]) : 0;
		
		int_loop_count           = 0;
		do {
		    int_loop_count++;
			// check height
			int_scroll_horizontal = bit_exceeded_width ? int_dim_scroll : 0;
			int_exceeded_height   = bit_exceeded_height ? (int_exceeded_height + 1) : int_exceeded_height;
			arr_new_dims[1]       = (arr_new_dims[1] ? arr_new_dims[1] : (arr_marker_dims[1] + arr_chrome_dims[1])) + int_scroll_horizontal - int_exceeded_height;
			bit_exceeded_height   = (arr_new_dims[1] > arr_maximum_dims[1]) ? true : false;
			arr_new_dims[1]       = bit_exceeded_height ? (arr_new_dims[1] - (arr_new_dims[1] - arr_maximum_dims[1])) : arr_new_dims[1];
			// check width
			int_scroll_vertical   = bit_exceeded_height ? 0 : 0;
			int_exceeded_width    = bit_exceeded_width ? (int_exceeded_width + 1) : int_exceeded_width;
			arr_new_dims[0]       = (arr_new_dims[0] ? arr_new_dims[0] : (arr_marker_dims[0] + arr_chrome_dims[0])) + int_scroll_vertical - int_exceeded_width;
			bit_exceeded_width    = (arr_new_dims[0] > arr_maximum_dims[0]) ? true : false;
			arr_new_dims[0]       = bit_exceeded_width ? (arr_new_dims[0] - (arr_new_dims[0] - arr_maximum_dims[0])) : arr_new_dims[0];			
		} while (bit_exceeded_width || bit_exceeded_height);
		/*
		// horizontal adjustments
		// NEEDS ATTENTION : not ready yet
		$$.getElementById('div.edit-win-options').each(function(obj) {
			Element.setStyle(obj, {'width':'auto'});
		});
		int_new_content_width  = arr_new_dims[0] - (arr_chrome_dims[0] + int_dim_scroll);
		*/
		// vertical adjustments
		// NEEDS ATTENTION
		// there are content height differences between FireFox 1.0.X and 1.5.X
		// there are also some height differences(causing vertical scrollbars on the content area) in IE
		int_new_content_height = arr_new_dims[1] - (int_dim_non_scrollable + arr_chrome_dims[1]);
		// may need a little more vertical space added for IE, for some reason its always about 2 px off vertically
		//Element.setStyle(document.getElementById(str_current_tab), {'height':px(int_new_content_height), 'overflow':'auto'});
		set_style_element = document.getElementById(str_current_tab);
		set_style_element.style.height = int2px(int_new_content_height);
		set_style_element.style.overflow = "auto";

		var int_height_offset = 0;
		if (browsr.IE7) {
			int_height_offset = 30;
		}

		if (int_push_edit_win_height > 0) {
			int_height_offset += int_push_edit_win_height;
		}

		window.resizeTo(arr_new_dims[0], arr_new_dims[1] + int_height_offset);

		/*{{{
		// OLD
		winWidth         = 0;
		winHeight        = 0;
		doc_width        = 1;
		doc_height       = 1;
		min_width        = 175;
		min_height       = 175;
		//screen_dims      = getScreenDims();
		screen_dims      = [getWindowWidth(), getWindowHeight()];
		// maximum allowed width of window
		max_width        = screen_dims[0] - 100;
		// maximum allowed height of window
		max_height       = screen_dims[1] - 100;
		content_too_tall = false;
		content_too_wide = false;
		incLookup        = incLookup ? incLookup : 'br';
		mark_point       = document.getElementById(incLookup);
		reFocus          = !reFocus ? 0 : 1;
		incAddon         = incAddon ? incAddon : 0;
		passNum          = 0;
		
        if (document.body.clienWidth) {
			test_height  = document.body.clientHeight + 200;
			test_width   = document.body.clientWidth + 200;
			window.resizeTo(test_width,test_height);
			
			temp_height  = document.body.clientHeight;
			temp_width   = document.body.clientWidth;
			window.resizeTo(test_height,test_height);
			
			trim_height  = test_height - temp_height;
			trim_width   = test_width - temp_width;
			scroll_width = temp_height - document.body.clientHeight;
        } else {
			scroll_width = 20;
			trim_height  = window.outerHeight - window.innerHeight;
			trim_width   = window.outerWidth - window.innerWidth;
        }
		
		do {
			doc_height += parseInt(mark_point.offsetTop);
			doc_width  += parseInt(mark_point.offsetLeft);
			mark_point  = mark_point.offsetParent;
		} while (mark_point);
		
		do {
			passNum++;
			winHeight        = (winHeight ? winHeight : (doc_height + trim_height)) + (content_too_wide ? scroll_width : 0) - (content_too_tall ? content_too_tall : 0);
			content_too_tall = (winHeight > max_height) ? (content_too_tall + 1) : false;
			winHeight        = (content_too_tall) ? (winHeight - (winHeight - max_height)) : winHeight;
			winWidth         = (winWidth ? winWidth : (doc_width + trim_width)) + (content_too_tall ? scroll_width : 0) - (content_too_wide ? content_too_wide : 0);
			content_too_wide = (winWidth > max_width) ? (content_too_wide + 1) : false;
			winWidth         = (content_too_wide) ? (winWidth - (winWidth - max_width)) : winWidth;
		} while (content_too_wide || content_too_tall);
		
		winHeight = (((winHeight < min_height) ? min_height : winHeight)) + incAddon;
		winWidth  = ((winWidth < min_width) ? min_width : winWidth) + 25 + incAddon;
		
		window.resizeTo(winWidth, winHeight);
		
		if (reFocus) {
			window.focus();
        }
		}}}*/
	},/*}}}*/
	submit : function() {/*{{{*/
		/*
	    if (top.EditWin.EditFrame) {
		    this.resize(true);
		    obj_content_container = document.getElementById(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;
	},/*}}}*/
};/*}}}*/
/*
New Tabs class
used to activate and deactivate the tabs in edit windows
also takes care of loading the ACE
*/
var Tabs = {/*{{{*/
    prefix  : 'edit-win-tab-',
	current : {},
	initial : function() {/*{{{*/
		str_master_container             = 'edit-win-tab-content-container';
		bit_master_container_exists      = document.getElementById(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 = document.getElementById(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 = $$('div.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 = document.getElementById(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();
		}
	},/*}}}*/
	set_cookie : function(selected_element) {/*{{{*/
		setCookie('EditWinTab', selected_element, '', '/');
	},/*}}}*/
	swap_tabs : function(selected_element) {/*{{{*/
		element_id       = !document.getElementById(selected_element) ? EditWin.str_default_tab : selected_element;
		selected_tab     = document.getElementById(element_id);
		selected_element = document.getElementById(element_id + '-container');
		this.current = selected_element;
		
		arr_win_options = $$('div.edit-win-options');
		for (var b = 0; b < arr_win_options.length; b++) {
			obj = arr_win_options[b];
			obj.style.display = "none";
		}
		arr_tab_container = $$('ul#edit-win-tabs-container li a');
		for (var c = 0; c < arr_tab_container.length; c++) {
			obj = arr_tab_container[c];
			removeClassName(obj, 'selected-tab');
		}
		selected_element.style.display = 'block';
		addClassName(selected_tab, 'selected-tab');
		//addClassName(selected_element, 'selected-tab');
	}/*}}}*/
}/*}}}*/
/*
this will be dept when IE5 is gone so no comments, see sc_proposals.js
*/
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 == '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 (!isNull(this.state.actual)) {
            for (i = 0; i < this.list.actual.length; i++) {
                str_item = this.list.actual[i];
                if (((str_item == 'object') || (str_item == 'embed')) && (int_user_id == '0')) {
                    continue;
                }
                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-back
toggle_nativeBrowserObjects = function(bit_state) { nativeBrowserObjects.toggle(bit_state); };
JS_swapSelects = function(bit_state) { nativeBrowserObjects.toggle(bit_state); };
/*}}}*/
/*
button submission class
*/
var Button = {/*{{{*/
	set : function(str_form, var_value) {
		var obj_form    = document.getElementById(str_form) || str_form;
		var obj_input   = document.createElement('input');
		obj_input.name  = 'form_action';
		obj_input.type  = 'hidden';
		obj_input.value = var_value;
		obj_form.appendChild(obj_input);
	},
	add : function(str_target_id, str_name) {
		var obj_form    = document.getElementById(str_target_id).form;
		var obj_input   = document.createElement('input');
		obj_input.id    = str_name;
		obj_input.name  = str_name;
		obj_input.type  = 'hidden';
		obj_input.value = 1;
		obj_form.appendChild(obj_input);
	},
	prep : function(obj) {
		obj_orig    = document.getElementById(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) {
		if (form) {
			var obj_form = document.getElementById(form);
			if (eval('obj_form.' + obj)) {
				obj_form.submit();
			}
		} else {
			var obj_target = document.getElementById(obj);
			if (obj_target && obj_target.form) {
				obj_target.form.submit();
			}
		}
	},
	close : function() {
		opener.focus();
		opener.location.reload();
		window.close();
	}
};/*}}}*/
/*
methods to help modify the location attribute
*/
var handleTextInputKeypress = function(obj_parent, obj_event, str_button_id) {/*{{{*/

	var int_keycode = 0;
	var obj_anchor_button = document.getElementById(str_button_id);
	
	obj_event = obj_event ? obj_event : window.event;
	
	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;
		}
		return false;
	}  
	return true;
}/*}}}*/

function checkEmail(str_email) {
	var str_expression = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return (str_expression.test(str_email));
}
