

//Begin jcore

// JavaScript Document

/**
 * jCoreAPI
 * Javascript Library
 */

var jCoreAPI = function () {

};

/**
 * jCoreAPI Global Variables
 */

/**
 * debug<Boolean (default = true)> If true, allows jCoreAPI.alert to display alerts popup, otherwise do not.
 * Each instance of jCoreAPI has "debug". This allows for global control eg. jCoreAPI.debug = true|false 
 * and individual instance control eg. jcore.debug = true|false.
 * 
 * @seejCoreAPI.functions.alerts
 */
jCoreAPI.debug = true;

/**
 * jCoreAPI Global Constants
 */

/**
 * jCoreAPI Global Functions
 * Functions can be shared by multiple objects or applied to 
 * jCoreAPI's prototype before jCoreAPI gets instantiated.
 * 
 * @see jCoreAPI.init
 */

jCoreAPI.functions = {

/**
 * alert
 * Makes use of jCoreAPI.debug and instance.debug.
 * If jCoreAPI.debug = false, then alerts will not display.
 * If jCoreAPI.debug = true and instance.debug = false, then alerts 
 * called by instance will not display but all others with debug = true would.
 * If jCoreAPI.debug = true and instance.debug = true, then alerts 
 * for instance and jCoreAPI will display.
 * 
 * @parammessage<String> Message to send to standard window.alert().
 */
alert: function (message/*:String*/)/*:void*/ {
if (jCoreAPI.debug && this.debug) window.alert(message);
}, 

/**
 * forEach
 * 
 * @parammethod<Function (required)>
 * @paramscope<Object (optional)>
 */
forEach: function (method/*:Function*//*, scope:Object*/)/*:void*/ {

if (typeof method != "function") new jCoreAPI.prototype.Error({caller: "jCoreAPI.Object.forEach", message: "\"method\"" + " parameter " + method + " is not a Function"});

for (var property in this) {
if (this.prototype == undefined || !this.prototype[property])
method.call((arguments[1] ? arguments[1] : null), this[property], property, this);
}

/*
if (this.length) {

var size = this.length;
for (var property = 0; property < size; property++) {
method.call((arguments[1] ? arguments[1] : null), this[property], property, this);
}

} else {

for (var property in this) {
if (this.prototype == undefined || !this.prototype[property])
method.call((arguments[1] ? arguments[1] : null), this[property], property, this);
}

}
*/
}, 

/**
 * hasOwnProperty
 * Matches parameter against object's property with the same name if it exists.
 * 
 * @paramname<String> Name of the property
 * 
 * @return<Boolean> If object contains property, true, otherwise false.
 */
hasOwnProperty: Object.prototype.hasOwnProperty, 

HTMLOutput: function () {
var dom = new jCoreAPI.prototype.DOM();
dom.set("div", {id: "_HTMLOutput", innerHTML: "Rendered HTML Output: " + "<textArea style='width: 100%; height: 300px; display: block;'>" + (dom.fragment.outerHTML || dom.fragment.innerHTML) + "</textArea>"}).appendChild("body");
}, 

/**
 * isPrototypeOf
 * Checks prototype chain of object for "reference" parameter.
 * 
 * @paramreference<Object> Object to check against prototype chain.
 * 
 * @return<Boolean> If true, "reference" is a property of the prototype chain, otherwise false.
 */
isPrototypeOf: Object.prototype.isPrototypeOf, 

/**
 * jumpToAnchor
 * 
 * @paramtarget<String>
 * @paramhistory<Boolean>
 */
jumpToAnchor: function (target/*:String*/, history/*:Boolean*/)/*:Boolean*/ {
if (this.hasJumped == undefined) this.hasJumped = false;
else if (this.hasJumped) return true;

if (history == undefined) history = true;

/* Jump to anchor if it exists */
if (window.location.hash) {
var hash = window.location.hash.split("#").pop();
var anchorItem = (document.anchors[hash] == undefined) ? document.getElementById(hash) : document.anchors[hash];

if (anchorItem && !this.hasJumped) {
if (history) window.location.hash = (target != undefined) ? target : window.location.hash;
else window.location.replace((target != undefined) ? window.location.pathname + window.location.search + "#" + target : window.location.hash);

this.hasJumped = true;
return true;
}
}
}, 

/**
 * propertyIsEnumerable
 * Checks if object is available for looping actions.
 * 
 * @paramname<String>
 * 
 * @return<Boolean (default = true)> If true, the property will be availble 
 * for "forEach" or tested against in for..in loops.
 */
propertyIsEnumerable: function (name/*:String*/)/*:Boolean*/ {
if (this[name].isEnum == undefined) this[name].isEnum = true;
return this[name].isEnum;
}, 

/**
 * setPropertyIsEnumerable
 * 
 * @paramname<String>
 * @paramisEnum<Boolean>
 */
setPropertyIsEnumerable: function (name/*:String*/, isEnum/*:Boolean*/)/*:void*/ {
this[name].isEnum = isEnum != undefined ? isEnum : true;
}, 

/**
 * toString
 * 
 * @return<String> Object type.
 */
toString: function ()/*:String*/ { return "[jCoreAPI]" }, 

/**
 * valueOf
 * 
 * @return<Object> Object reference.
 */
valueOf: Object.prototype.valueOf

};

/**
 * jCoreAPI Global Events
 * Events can be shared by multiple objects or applied to 
 * jCoreAPI's prototype before jCoreAPI gets instantiated.
 * 
 * @see jCoreAPI.init
 */

jCoreAPI.events = {

Event: {

/**
 * Event
 */
constructor: function (target, createArray) {
if (target.broadcastMessage != undefined) delete target.broadcastEvent;
target.addListener = this.Event.addListener;
target.removeListener = this.Event.removeListener;
if (createArray) target.__listeners = new Array();
}, 

prototype: {

__listeners: new Array(), 

addEventListener: function () {

}, 

broadcastEvent: function () {

}, 

removeEventListener: function () {

}

}

}, 

Error: {

/**
 * Error
 * 
 * @paramfault<Object> Contains properties caller and message
 *fault.caller<String> Function or Class that the error occured in.
 *fault.message<String> Feedback text explaining the error.
 * 
 * @seejCoreAPI.functions.alert
 * @seejCoreAPI.core.Object
 */
constructor: function (fault/*:Object*/)/*:void*/ {
var err;
this.faultResult = new jCoreAPI.prototype.Object({caller: "undefined", message: "undefined"});
this.faultResult.forEach(function (element, property, object) { object[property] = fault[property]; });
err = new Error("WARNING : " + "Caller: " + this.faultResult.caller + "; " + "Message: " + this.faultResult.message + ";");
jCoreAPI.prototype.alert(err.message);
throw err;
}, 

prototype: {

}

}

};

/**
 * jCoreAPI Global Classes
 */

jCoreAPI.classes = {

DOM: {

/**
 * DOM
 */
constructor: function (target/*:String*/, caseSensitive/*:Boolean*/)/*:Array*/ {

/*
if (target) {
this.get(target, caseSensitive);
} else {
var array = Array.apply(this);
for (var i in jCoreAPI.prototype.DOM.prototype) if (!array[i]) array[i] = jCoreAPI.prototype.DOM.prototype[i];
return array;
}
*/
/*
var array = Array.apply(this);
for (var i in jCoreAPI.prototype.DOM.prototype) if (!array[i]) array[i] = jCoreAPI.prototype.DOM.prototype[i];
return target ? this.get(target, caseSensitive) : array;
*/
//var array = target ? this.get(target, caseSensitive) : Array.apply(this);

var array = Array.apply(this), fragment = [];

for (var i in jCoreAPI.prototype.DOM.prototype) if (!array[i]) array[i] = jCoreAPI.prototype.DOM.prototype[i];

fragment = this.get(target, caseSensitive)[0];

if (fragment) array.fragment = fragment;

return array;

}, 

prototype: {

fragment: document.getElementsByTagName("html")[0], 

/**
 * Gets all HTML elements with an id
 * dom.get("@id");
 */
 
 /**
 * Gets HTML elements with an id of "content"
 * dom.get("@id == content");
 */
 
 /**
 * Gets HTML elements with an id that doesn't equal "content"
 * dom.get("@id == content");
 */

get: function (target/*:String*/, caseSensitive/*:Boolean*/, DOMContext/*:DOM|Boolean*/)/*:DOM*/ {

var classPointer = this, elements = [];

if (typeof target === "string" && !DOMContext) {

this.clear();

var cs = !caseSensitive ? "i" : "", 
attExpr = {
name: new RegExp(/(?:@)(\w*|[*])/gi), 
value: eval("/(?=\\w|-|@).*/g" + cs)
}, 
nodeList, 
attName, 
attValue, 
operator, 
size = 0;

if (/@/.test(target)) {

//@AttributeName, @*
attName = attExpr.name.exec(target);

//*, node, node.node...
nodeList = RegExp.leftContext.substring(0, RegExp.leftContext.length - 1);

// string, string string, 0-9
attValue = attExpr.value.exec(RegExp.rightContext);

//<, >, <=, >=, !=, ==, *(contains string)
operator = !attValue ? "" : RegExp.leftContext;

elements = this.getElement(nodeList);

//* operator means attribute contains "attValue" string
if (operator != "" && (/[*]/).test(operator)) {

var attExpr = "/\\b" + attValue + "\\b/g" + cs
//Test for attribute matching for each item in "elements"
elements.forEach(function (element, property, object) {
//Match whole word in attribute
if (eval(attExpr).test(classPointer.getAttribute(element, attName[1]))) {
classPointer.push(element);
}
});

} else {

elements.forEach(function (element, property, object) {
var attrib = classPointer.getAttribute(element, attName[1]);
if (attrib && operator == "") {
if (attrib) classPointer.push(attrib);
} else {
if (attrib && eval("'" + attrib + "'" + (operator) + "'" + attValue + "'")) classPointer.push(element);
}
});

}

} else {
elements = this.getElement(target);
this.push.apply(this, elements);
}
} else if (typeof target === "string" && DOMContext) {

DOMContext = DOMContext.length ? DOMContext : this;

DOMContext.forEach(function (element, property, object) {
var dom = new jCoreAPI.prototype.DOM();
dom.fragment = element;
elements.push.apply(elements, dom.get(target, caseSensitive));
});

this.clear();
this.push.apply(this, elements);

}

return this;

}, 

getElement: function (target, fragment, test) {

var result = [], 
fragment = fragment || this.fragment;

if (typeof target === "string" && target != "") {

var classPointer = this, 
descendantExpr = //,
descendant = [], 
nodeList = [], 
index = 0, 
children = [], 
size = 0, 
list = [], 
nodeName = "", 
wildcard = false;

//Replace .. with ." "(space) to denote descendant access
target = new RegExp(/\.\./gi).test(target) ? target.replace(new RegExp(/\.\./gi), ". ") : target;

//Expression looks for " "(space) or ." "(space) at the beginning of target
descendantExpr = new RegExp(/^(?:\s|.\s)([\w\[\]0-9|*]*(?=\.|$))/gi);

//Creates an array if search items are found. Used "nodeList", "index", and "chidren" creation
descendant = descendantExpr.exec(target);
if (descendant) descendant[0] = descendant[0].replace(/\[/gi, "\\[");
 
//Creates array of nodes to match
nodeList = descendant ? target.replace(eval("/" + descendant[0] + "/"), descendant[1]).split(".") : target.split(".");

//If accessing an index [0-9] of result array
index = new RegExp(/(?:\[)(\d*)/g).exec(nodeList[0]);

//Object containing elements to search through
children = descendant ? index ? new Array(fragment.getElementsByTagName(RegExp.leftContext)[index[1]]) : fragment.getElementsByTagName(descendant[1]) : fragment.childNodes;
size = children.length;

//Node name to match to elements in "children"
nodeName = index ? RegExp.leftContext : nodeList[0];

//Matches any element in "children" if * exists
wildcard = new RegExp(/[*]/).test(nodeName) || false;

for (var i = 0; i < size; i++) {
//alert("--"+nodeName + " = " + children[i].nodeName + " = " + eval("/" + nodeName + "/gi"));
if (wildcard) {
if (children[i].nodeType == 1) list.push(children[i]);
} else if (eval("/" + nodeName + "/gi").test(children[i].nodeName)) {
list.push(children[i]);
}
}

if (nodeList.length > 1) {

nodeList.splice(0, 1);

if (index) {
this.push.apply(result, this.getElement(nodeList.join("."), list[index[1]]));
} else {
list.forEach(function (element, property, object) {
classPointer.push.apply(result, classPointer.getElement(nodeList.join("."), element));
});
}

} else {
return list;
}

} else {
result.push(this.fragment);
}

if (result.length > 1 && nodeList.length == 1) {
index = new RegExp(/(?:\[)(\d*)/g).exec(nodeList[0]);
if (index) result.splice(0, result.length, result[index[1]]);
}

return result;
}, 

element: function () {

}, 

/**
 * Internal use
 */

getAttribute: function (element, name) {
return element.getAttribute ? element.getAttribute(name) : element[name];
}, 

attribute: function (name) {
var result = [];
this.forEach(function (element, property, object) {
result.push(element.getAttribute ? element.getAttribute(name) : element[name]);
});
return result;
}, 

set: function (name, attributes) {
//alert(name + " = " + attributes);
var newElement = document.createElement(name), 
attribs = new jCoreAPI.prototype.Object(attributes);

attribs.forEach(function (element, property, object) {
if ((/innerHTML/gi).test(property) && !(/fieldset|form|input/gi).test(newElement)) {
newElement.innerHTML = element;
} else {
var attrib = document.createAttribute(property);
attrib.value = element;
newElement.setAttributeNode(attrib);
}
});

var dom = new jCoreAPI.prototype.DOM();
dom.push(newElement);
return dom;
}, 

appendChild: function (target/*:String*/, caseSensitive/*:Boolean*/) {

var classPointer = this, elements = new jCoreAPI.prototype.DOM().get(target, caseSensitive);
elements.forEach(function (element, property, object) {
element.appendChild(classPointer[0]);
});

}, 

/**
 * parseFromString
 * Converts an XML formatted String to an XML object.
 * 
 * @paraminput<String (required)>
 * 
 * @return<XML>
 */
parseFromString: function (input/*:String*/)/*:XML*/ {
var obj = new Object();

if (window.ActiveXObject) {
// code for IE.
try {
obj = new ActiveXObject("Microsoft.XMLDOM");
obj.async = "false";
obj.loadXML(input);
} catch (err) {
var e = new jCoreAPI.prototype.Error({caller: "jCoreAPI.DOM.parseFromString", message: " Microsoft.XMLDOM: String to XML failed." + err.message});
}

} else {
// code for Mozilla, Firefox, Opera, etc.
try {
var parser = new DOMParser();
obj = parser.parseFromString(input, "text/xml");
} catch (err) {
var e = new jCoreAPI.prototype.Error({caller: "jCoreAPI.DOM.parseFromString", message: " DOMParser: String to XML failed." + err.message});
}
}

return obj;
}, 

text: function () {
var result = [];
this.forEach(function (element, property, object) {
result.push(element.innerHTML ? element.innerHTML : element.value);
});
return result;
}

}

}

};

/**
 * jCoreAPI Core Classes
 */

jCoreAPI.core = {

Array: {

/**
 * Array
 * Creates a reference to built-in Array object then extends its prototype.
 * All arrays whether created by new Array(); or new jCoreAPI.Array()
 * will contain the following methods.
 */
constructor: Array, 

prototype: {

/**
 * clear
 * Removes all items stored in array.
 * 
 * @return<Array> Contains the orginal array with all stored data removed.
 */
clear: function ()/*:Array*/ {
return this.splice(0, this.length);
}, 

/**
 * every
 * Calls a function for every element of the array until false is returned.
 * 
 * @parammethod<Function (required)>
 * @paramscope<Object (optional)>
 * 
 * @return<Boolean> If condition of supplied method is met, true, otherwise false.
 */
every: function (method/*:Function*//*, scope:Object*/)/*:Boolean*/ {
if (typeof method != "function") new jCoreAPI.prototype.Error({caller: "jCoreAPI.Array.every", message: "\"method\"" + " parameter " + method + " is not a Function"});
var size = this.length, scope = arguments[1];
for (var index = 0; index < size; index++) {
if (index in this && !method.call(scope, this[index], index, this))
return false;
}
return true;
}, 

/**
 * filter
 * Creates an array with each element which evaluates true in the function provided.
 * 
 * @parammethod<Function (required)>
 * @paramscope<Object (optional)>
 * 
 * @return<Array> Contains a new array of each element that 
 * met the condition of the supplied method.
 */
filter: function (method/*:Function*//*, scope:Object*/)/*:Array*/ {
if (typeof method != "function") new jCoreAPI.prototype.Error({caller: "jCoreAPI.Array.filter", message: "\"method\"" + " parameter " + method + " is not a Function"});
var size = this.length, scope = arguments[1], result = new Array(), value;
for (var index = 0; index < size; index++) {
value = this[index];
if (method.call(scope, value, index, this))
result[result.length] = value;
}
return result;
}, 

/**
 * forEach
 * Executes a specified function on each element of an Array.
 * 
 * @parammethod<Function (required)>
 * @paramscope<Object (optional)>
 */
forEach: function (method/*:Function*//*, scope:Object*/)/*:void*/ {
if (typeof method != "function") new jCoreAPI.prototype.Error({caller: "jCoreAPI.Array.forEach", message: "\"method\"" + " parameter " + method + " is not a Function"});
var size = this.length, scope = arguments[1];
for (var index = 0; index < size; index++)
method.call(scope, this[index], index, this);
}, 

/**
 * indexOf
 * Searches the Array for specific elements.
 * 
 * @paramelement<String>
 * @paramstart<Number (optional)>
 * 
 * @return<Number> First accurancy of the supplied search string.
 */
indexOf: function (element/*:String*//*, start:Number*/)/*:Number*/ {
var size = this.length, start = Number(arguments[1]) || 0;
start = (start < 0) ? Math.ceil(start) : Math.floor(start);
if (start < 0) start += size;
for (var start = 0; start < size; start++) {
if (start in this && this[start] === element) return start;
}
return -1;
}, 

// TODO:
/**
 * lastIndexOf
 * Searches the Array for specific elements.
 */
//lastIndexOf: Array.prototype.lastIndexOf, 

// TODO:
/**
 * map
 * Creates a new array with the result of calling the specified 
 * function on each element of the Array.
 */
//map: Array.prototype.map, 

// TODO:
/**
 * some
 * Passes each element through the supplied function until “true” is returned.
 */
//some: Array.prototype.some, 

// TODO:
/**
 * toSource
 * Returns the “source code” of the array.
 */
//toSource: Array.prototype.toSource, 

/**
 * clone
 * Creates a complete copy of an array without reference to the orginal.
 * 
 * @return<Array> Completely new clone of the original array.
 * 
 * @usageArray.clone()
 */
clone: function ()/*:Array*/ {
return this.slice();
}, 

/**
 * randomize
 * Utilizes Array.clone, sorts the new array in a random order then returns the new array.
 * 
 * @return<Array>Completely new clone of the original array after operation.
 * 
 * @usageArray.randomize()
 * 
 * @seeArray.clone
 */
randomize: function ()/*:Array*/ {
var result = new Array();
result = this.clone();
result = result.sort(function (){ return (Math.round(Math.random()) - 0.5); });
return result;
}

}

}, 

Object: {

/**
 * Object
 * Base object that all other classes inherit.
 */
constructor: function (/*Object (optional)*/)/*:void*/ {
if (arguments[0]) for (var property in arguments[0]) this[property] = arguments[0][property];
}, 

prototype: {

/**
 * Methods inherited from jCoreAPI.functions
 * @see jCoreAPI.functions
 */
hasOwnProperty: jCoreAPI.functions.hasOwnProperty, 
isPrototypeOf: jCoreAPI.functions.isPrototypeOf, 
propertyIsEnumerable: jCoreAPI.functions.propertyIsEnumerable, 
setPropertyIsEnumerable: jCoreAPI.functions.setPropertyIsEnumerable, 
toString: function () { return "[jCoreAPI Object]" }, 
valueOf: jCoreAPI.functions.valueOf, 
forEach: jCoreAPI.functions.forEach, 

/**
 * Methods inherited from jCoreAPI.classes.Event
 * @see jCoreAPI.classes.Event
 */
__listeners: jCoreAPI.events.Event.prototype.__listeners, 
addEventListener: jCoreAPI.events.Event.prototype.addEventListener, 
broadcastEvent: jCoreAPI.events.Event.prototype.broadcastEvent, 
removeEventListener: jCoreAPI.events.Event.prototype.removeEventListener

}

}
};

/**
 * implementation<Object> 
 * 
 */
jCoreAPI.implementation = {
PROFILE: { name: "jCoreAPI", version: 0.6 }, 
features: [], 

/**
 * hasFeature
 * 
 * Checks root object's "library" object for existence of class package.
 * If "library" does not exist, this creates a "library" object on the root.
 * If class package exists, an error is thrown using jCoreAPI.Error.
 * @paramroot<Object>
 * @parampackage<String>
 * @return<Boolean>
 * 
 * @see jCoreAPI.core.Error
 */
hasFeature: function (root/*:Object*/, package/*:String*/)/*:Boolean*/ {
if (root.implementation.features[root.implementation.PROFILE.name + "." + package]) {
new jCoreAPI.prototype.Error({caller: root.implementation.PROFILE.name + ".implementation.hasFeature", message: "Package definition " + root.implementation.PROFILE.name + "." + package + " already exists."});
return false;
} else {
root.implementation.features[root.implementation.PROFILE.name + "." + package] = true;
root.implementation.features[root.implementation.features.length] = root.implementation.PROFILE.name + "." + package;
return true;
}
}, 

/**
 * evaluate
 * 
 * @paramroot<Object>
 * @parampackage<String>
 * @return<Object>
 * 
 * @see jCoreAPI.core.Error
 */
evaluate: function (root/*:Object*/, package/*:String*/)/*:Object*/ {
this.hasFeature(root, package);
var pkg = package ? package.split(".") : [], obj = {name: "", parent: {}}, err = {caller: root.implementation.PROFILE.name + ".Class.evaluate", message: "Invalid root or package definition."};
obj.name = pkg[pkg.length - 1];
obj.parent = root;

if (pkg.length > 1 || !root) {
err.message = "\"" + pkg[0] + "\"" + " does not exist in definition package " + root.implementation.PROFILE.name + "." + package;
root = !root[pkg[0]] ? false : root[pkg[0]];
var size = pkg.length - 1;
for (var items = 1; items < size; items++) {
err.message = "\"" + pkg[items] + "\"" + " does not exist in definition package " + root.implementation.PROFILE.name + "." + package;
root = !root[pkg[items]] ? false : root[pkg[items]];
}
if (!root) new jCoreAPI.prototype.Error(err);
obj.parent = root;
} else if (pkg.length == 0) {
new jCoreAPI.prototype.Error(err);
}
return obj;
}, 

/**
 * copy
 * 
 * @paramtarget<Class>
 * @paramsource<Object>
 * @paramexculde<String|RegExp>
 */
copyToPrototype: function (target/*:Class*/, source/*:Object*/, enumerable/*:Boolean*/, exclude/*:String|RegExp*/)/*:void*/ {
var base = source.prototype ? source.prototype : source;
var exclude = exclude ? (typeof exclude === "string" ? new RegExp(exclude) : exclude) : (/ /);
for (var property in base) {
if (!(/constructor/.test(property)) && !(exclude.test(property))) {
jCoreAPI.implementation.addToPrototype(target, property, base[property], false);
}
}
}, 

/**
 * addToPrototype
 * 
 * @paramtarget<Class>
 * @paramproperty<String>
 * @paramvalue<Array|Class|Function|Object|String|*>
 * @paramenumerable<Boolean>
 */
addToPrototype: function (target/*:Class*/, property/*:String*/, value/*:**/, enumerable/*:Boolean*/)/*:void*/ {
target.prototype[property] = value;
target.prototype[property].isEnum = enumerable ? enumerable : true;
}

};

/**
 * Class
 * Creates a class on the calling object from supplied parameters, "definition" and "attributes". 
 * 
 * @paramdefinition<Object>
 * definition.package<String>
 * definition.extend <jCoreAPI Class|Object|Array|String|etc. (optional)> 
 * 
 * @paramattributes<Object>
 * attributes.constructor<Function (required)>
 * attributes.prototype<Object> Contains any number of methods and/or properties the Class requires.
 * 
 * @paramintrinsic<Boolean (default = false)> If true, does not receive properties from jCoreAPI.Object or the Functions __super__, 
 * __root__, __parent__, valueOf, and toString, otherwise false and may receive those properties.
 * 
 * @usage
 * jCoreAPI.Class({package: "Name", extend: Object}, {
 * constructor: function () {
 * // required
 * }, 
 * prototype: {
 * // optional
 * }
 * })
 */
jCoreAPI.Class = function (definition, attributes/*, intrinsic*/) {
var obj = {name: "", parent: ""};

/* Test and evaluate class package availability */
obj = this.implementation.evaluate(this, definition.package);

/* Class creation */
obj.parent[obj.name] = attributes.constructor;
obj.parent[obj.name].prototype = obj.parent[obj.name];

/* Inheritance */
if (definition.extend) obj.parent[obj.name].prototype = new definition.extend;
/* Copy jCoreAPI.Object properties to class object's prototype if class not extended */
else if (!arguments[2]) this.implementation.copyToPrototype(obj.parent[obj.name], jCoreAPI.prototype.Object, false, (/prototype|toString|valueOf/));

/* Copy attributes.prototype properties to class object's prototype */
if (attributes.prototype) this.implementation.copyToPrototype(obj.parent[obj.name], attributes.prototype, false, obj.name);

/* Helper functions */
if (!arguments[2]) {
this.implementation.addToPrototype(obj.parent[obj.name], "__super__", definition.extend ? definition.extend : jCoreAPI.prototype.Object, false);
this.implementation.addToPrototype(obj.parent[obj.name], "__root__", this, false);
this.implementation.addToPrototype(obj.parent[obj.name], "__parent__", obj.parent, false);
this.implementation.addToPrototype(obj.parent[obj.name], "valueOf", function () { return obj.parent[obj.name] }, false);
this.implementation.addToPrototype(obj.parent[obj.name], "toString", function () { return "[object " + obj.name + "]" }, false);
}

/* Re-define constructor incase it was lost during inheritance */
obj.parent[obj.name].prototype.constructor = obj.parent[obj.name];
};

/**
 * prototype<Object>
 */
jCoreAPI.prototype = {
PROFILE: jCoreAPI.implementation.PROFILE, 
debug: true, 
implementation: jCoreAPI.implementation, 

/** 
 * Global Functions
 * This creates a short cut to jCoreAPI's global functions
 * that will be shared by each of it's instances.
 * 
 * @see jCoreAPI.functions
 */
alert: jCoreAPI.functions.alert, 
forEach: jCoreAPI.functions.forEach, 
HTMLOutput: jCoreAPI.functions.HTMLOutput, 
jumpToAnchor: jCoreAPI.functions.jumpToAnchor, 
toString: jCoreAPI.functions.toString, 

/** 
 * Class creator
 * This allows an instance of jCoreAPI to utilize the 
 * class creator jCoreAPI.Class
 * 
 * @see jCoreAPI.Class
 */
Class: jCoreAPI.Class

};

/**
 * init
 * Initializes jCoreAPI by adding base classes then cleans up extra methods.
 * To add classes to jCoreAPI from this call, use jCoreAPI.Class.
 * 
 * @seejCoreAPI.Class
 */
jCoreAPI.init = function () {
/* Add classes to the prototype of jCoreAPI making them available to each instance of jCoreAPI */
jCoreAPI.Class({package: "prototype.Array"}, jCoreAPI.core.Array, true);
jCoreAPI.Class({package: "prototype.Object"}, jCoreAPI.core.Object, true);
jCoreAPI.Class({package: "prototype.Error"}, jCoreAPI.events.Error);
jCoreAPI.Class({package: "prototype.DOM", extend: jCoreAPI.prototype.Array}, jCoreAPI.classes.DOM, true);

/* Clean up method to prevent multiple/accidental executions */
delete this.init;
};

jCoreAPI.init();

//Begin object class

//Begin class class
/**
* Create Class
* @usage
var ClassName = Class.create();
ClassName.prototype = {
initialize: function () {

}
}

var name = new ClassName();
*/
/*
var Class = {
create: function () {
return function () {
this.initialize.apply(this, arguments);
}
}
}
*/

function Class (name) {

Class.copyMethods(name, Class);
if (name.prototype != undefined) {
name.prototype.superclass = Function();
}
return name;
}

Class.copyMethods = function (target, container) {

for (var items in container) {
if (container[items] instanceof Function) {
target[items] = container[items];
}
}

}

Class.extend = function (name) {

if (name.prototype == undefined) {
//this.prototype = name;

this.copyMethods(this.prototype, name);
this.prototype.superclass = function () {
return name;
};

this.copyMethods(this.prototype.superclass, name);
this.prototype.contructor = this;

} else {
this.prototype = name.prototype;

this.prototype.superclass = function () {

if (arguments.length == 0) {
return new name();
} else if (arguments.length == 1) {
return new name(arguments[0]);
} else {
return name.apply(this, arguments);
}

};

this.copyMethods(this.prototype.superclass, name.prototype);
this.prototype.contructor = this;
}
}

//begin broadcaster class

function Broadcaster () {

}

Class(Broadcaster);

Broadcaster.prototype._listeners = new Array();

Broadcaster.initialize = function (o, dontCreateArray) {
if (o.broadcastMessage != undefined) delete o.broadcastMessage;
o.addListener = Broadcaster.prototype.addListener;
o.removeListener = Broadcaster.prototype.removeListener;
if (!dontCreateArray) o._listeners = new Array();
}

Broadcaster.prototype.addListener = function (o) {
this.removeListener (o);

if (this.broadcastMessage == undefined) {
this.broadcastMessage = Broadcaster.prototype.broadcastMessage;
}
return this._listeners.push(o);
}

Broadcaster.prototype.removeListener = function (o) {
var a = this._listeners;
var i = a.length;
while (i--) {
if (a[i] == o) {
a.splice (i, 1);
if (!a.length) this.broadcastMessage = undefined;
return true;
}
}
return false;
}

Broadcaster.prototype.broadcastMessage = function () {
var e = String(Array.prototype.slice.call(arguments).shift());
var a = this._listeners.concat();
var l = a.length;

for (var i=0; i<l; i++) {
a[i][e].apply(a[i], arguments);
}
}

//begin UADetector class
/**
 * Same logic as before. Have removed some detection capabilities in an effort
 * to reduce reliance on browser detection in general.
 * 
 * If there is a particualr detection you feel you need please file a ticket
 * with the request or add the detection yourself with the exact reason you
 * need said detection. Hopefully we'll be able to keep the number of
 * detection utility functions to a minimum in favor of behavioral testing.
 * 
 * This may also be the place for very common behavioral functions.
 * 
 */

function UADetector () {

}

Class(UADetector);

UADetector.prototype.getAgent = function () {
return navigator.userAgent.toLowerCase();
}

// detect platform
UADetector.prototype.isMac = function (userAgent) {
var agent = userAgent || this.getAgent();
return agent.match(/mac/i);
}

UADetector.prototype.isWin = function (userAgent) {
var agent = userAgent || this.getAgent();
return agent.match(/win/i);
}

UADetector.prototype.isWin2k = function (userAgent) {
var agent = userAgent || this.getAgent();
return this.isWin(agent) && (agent.match(/nt\s*5/i));
}

UADetector.prototype.isWinVista = function (userAgent) {
var agent = userAgent || this.getAgent();
return this.isWin(agent) && (agent.match(/nt\s*6/i));
}

// detect browser
UADetector.prototype.isWebKit = function (userAgent) {
var agent = userAgent || this.getAgent();
return agent.match(/AppleWebKit/i);
}

UADetector.prototype.isOpera = function (userAgent) {
var agent = userAgent || this.getAgent();
return agent.match(/opera/i);
}

UADetector.prototype.isIE = function (userAgent) {
var agent = userAgent || this.getAgent();
return agent.match(/msie/i);
}

UADetector.prototype.isIEStrict = function (userAgent) {
var agent = userAgent || this.getAgent();
return agent.match(/msie/i) && !this.isOpera(agent);
}

UADetector.prototype.getIEVer = function (userAgent) {
var agent = userAgent || this.getAgent();
return this.isIE(agent) && Number(agent.match(/\s[0-9]/i));
}

UADetector.prototype.isFirefox = function (userAgent) {
var agent = userAgent || this.getAgent();
return agent.match(/firefox/i);
}

UADetector.prototype.isiPhone = function (userAgent) {
var agent = userAgent || this.getAgent();
return agent.match(/iPhone/i);
}

// itunes compabibility
UADetector.prototype.isiTunesOK = function (userAgent) {
var agent = userAgent || this.getAgent();
return this.isMac(agent) || this.isWin2k(agent);
}

UADetector.prototype.isQTInstalled = function () {

var qtInstalled = false;

if(navigator.plugins && navigator.plugins.length) {

for(var i=0; i < navigator.plugins.length; i++ ) {

var plugin = navigator.plugins[i];

if(plugin.name.indexOf("QuickTime") > -1) { 
qtInstalled = true; 
}
}
} else {
qtObj = false; //global variable written to by vbscript for ie
execScript('on error resume next: qtObj = IsObject(CreateObject("QuickTimeCheckObject.QuickTimeCheck.1"))','VBScript');
qtInstalled = qtObj;
}

return qtInstalled;
}

UADetector.prototype.getQTVersion = function () {

var version = "0";

if (navigator.plugins && navigator.plugins.length) {
for (var i = 0; i < navigator.plugins.length; i++) {

var plugin = navigator.plugins[i];

//Match: QuickTime Plugin X.Y.Z
var match = plugin.name.match(/quicktime\D*([\.\d]*)/i);
if (match && match[1]) {
version = match[1];
}
}
} else {
ieQTVersion = null; //global for vbscript to write to

execScript('on error resume next: ieQTVersion = (Hex(CreateObject("QuickTimeCheckObject.QuickTimeCheck.1").QuickTimeVersion)/1000000)','VBScript');

if (ieQTVersion) {
//only grab the major version: 7.xyz => 7
version = (ieQTVersion +"").split(/\./)[0];
}
}

return version;
}

UADetector.prototype.isQTCompatible = function (required, actual) {

function areCompatible(required, actual) {

var requiredValue = parseInt(required[0])
if (isNaN(requiredValue)) {
requiredValue = 0;
}

var actualValue = parseInt(actual[0])
if (isNaN(actualValue)) {
actualValue = 0;
}

if (requiredValue == actualValue) {
if (required.length > 1) {
return areCompatible(required.slice(1), actual.slice(1));
} else {
return true;
}
} else if (requiredValue < actualValue) {
return true;
} else {
return false;
}
}

var expectedVersion = required.split(/\./);
var actualVersion = actual ? actual.split(/\./) : this.getQTVersion().split(/\./);

return areCompatible(expectedVersion, actualVersion);

}

UADetector.prototype.isValidQTAvailable = function (required) {
return this.isQTInstalled() && this.isQTCompatible(required)
}

//begin Sequence class

function Sequence (target, type, span, spacer, usePixels, resize) {

var classPointer = this;

this.target = (typeof target == "object") ? target : document.getElementById(target);

this.type = (type == undefined || type == "") ? "horiz" : type;

this.spacer = (spacer == undefined || spacer == "") ? {col: 0, row: 0} : spacer;
this.spacer.col = (spacer.col == undefined) ? 0 : Number(spacer.col);
this.spacer.row = (spacer.row == undefined) ? 0 : Number(spacer.row);

this.usePixels = (this.type == "vertHoriz") ? false : usePixels;

this.resize = (resize == undefined) ? false : resize;

this.collection = new Array();

for (var item = 0; item < this.target.childNodes.length; item++) {
if (this.target.childNodes[item].nodeType == 1) {
this.colWidth = (this.target.childNodes[item].clientWidth > this.colWidth) ? this.target.childNodes[item].clientWidth : this.colWidth;
this.collection.push(this.target.childNodes[item]);
}
}

if (span.value == undefined || span.value == "" || span.value == 0 || span.value == "auto") {

if (this.type == "vertHoriz") {
this.span.value = Math.ceil((this.collection.length) / (Math.floor(this.target.clientWidth / this.colWidth))) 
} else {
this.span.value = (this.type == "horiz") ? this.target.clientWidth : this.target.clientHeight;
}

} else {
if (this.type == "vertHoriz") {
this.span.value = Math.ceil((this.collection.length) / (Math.floor(span.value / this.colWidth))) 
} else {
this.span.value = Number(span.value);
}
}

//this.span.value = (this.type == "vertHoriz") ? Math.ceil((this.collection.length) / (Math.floor(this.target.clientWidth / this.colWidth))) : this.span.value;

//this.span.min = (span.min == undefined) ? this.span.value : span.min;
//this.span.max = (span.max == undefined) ? (this.type == "horiz") ? this.target.clientWidth : this.target.clientHeight : span.max;

this.span.min = span.min;
this.span.max = span.max;

//this.targetWidth = this.target.clientWidth;

this.run(this.resize);

window.onresize = function () {
/*if (classPointer.resize && classPointer.targetWidth != classPointer.target.clientWidth) {
classPointer.targetWidth = classPointer.target.clientWidth;
classPointer.run(true);
}*/
classPointer.run(classPointer.resize);
}

}

Class(Sequence);

Sequence.prototype.colWidth = 0;
Sequence.prototype.colNumber = 0;
Sequence.prototype.colTotal = 0;
Sequence.prototype.rowNumber = 0;
Sequence.prototype.rowTotal = 0;
Sequence.prototype.currItem = new Object();
Sequence.prototype.prevItem = new Object();
Sequence.prototype.xRel = 0;
Sequence.prototype.yRel = 0;
Sequence.prototype.targetWidth = 0;

Sequence.prototype.collection = new Array();
Sequence.prototype.target = new String();
Sequence.prototype.type = new String();
Sequence.prototype.span = new Object();
Sequence.prototype.spacer = new Object();
Sequence.prototype.usePixels = true;
Sequence.prototype.resize = false;

Sequence.prototype.colBlock = 0;
Sequence.prototype.rowBlock = 0;
Sequence.prototype.count = 1;

Sequence.prototype.run = function (onresize) {

if (onresize) {

switch(this.type) {
case "vertHoriz" :
this.span.value = Math.ceil((this.collection.length) / (Math.floor(this.target.clientWidth / this.colWidth)));
if (this.span.min != undefined && this.span.min > this.span.value) this.span.value = this.span.min;
if (this.span.max != undefined && this.span.max < this.span.value) this.span.value = this.span.max;
this.span.value = Math.ceil((this.collection.length) / (Math.ceil(this.collection.length / this.span.value)));
break;

case "vert" :
if (this.usePixels) this.span.value = this.target.clientHeight;
if (this.span.min != undefined && this.span.min > this.span.value) this.span.value = this.span.min;
if (this.span.max != undefined && this.span.max < this.span.value) this.span.value = this.span.max;
break;

case "horiz" :
if (this.usePixels) this.span.value = this.target.clientWidth;
if (this.span.min != undefined && this.span.min > this.span.value) this.span.value = this.span.min;
if (this.span.max != undefined && this.span.max < this.span.value) this.span.value = this.span.max;
break;

}

}

this.colNumber = (this.type == "horiz") ? 0 : 1;
this.colTotal = 0;
this.rowNumber = 0;
this.rowTotal = 0;

this.xRel = 0;
this.yRel = 0;

this.colBlock = 0;
this.rowBlock = 0;
this.count = 1;

for (var item = 0; item < this.collection.length; item++) {
this.currItem = this.collection[item];

if (this.colWidth > 0) {
var pl = (window.getComputedStyle) ? window.getComputedStyle(this.collection[item], null).getPropertyValue("padding-left") : this.collection[item].currentStyle.paddingLeft;
var pr = (window.getComputedStyle) ? window.getComputedStyle(this.collection[item], null).getPropertyValue("padding-right") : this.collection[item].currentStyle.paddingRight;
this.currItem.style.width = (this.colWidth - (Number(pl.replace("px", "")) + Number(pr.replace("px", ""))))+ "px";
}

this.currItem.style.position = "absolute";
this.currItem.style.left = "0px";
this.currItem.style.top = "0px";
}

for (var item = 0; item < this.collection.length; item++) {

this.currItem = this.collection[item];

this.currItem._width = this.currItem.clientWidth;
this.currItem._height = this.currItem.clientHeight;
this.currItem._x = (window.getComputedStyle) ? window.getComputedStyle(this.currItem, null).getPropertyValue("left") : this.currItem.currentStyle.left;
this.currItem._x = Number(this.currItem._x.replace("px", ""));
this.currItem._y = (window.getComputedStyle) ? window.getComputedStyle(this.currItem, null).getPropertyValue("top") : this.currItem.currentStyle.top;
this.currItem._y = Number(this.currItem._y.replace("px", ""));

if (item > 0) {

this.prevItem = this.collection[item - 1];

this.prevItem._width = this.prevItem.clientWidth;
this.prevItem._height = this.prevItem.clientHeight;
this.prevItem._x = (window.getComputedStyle) ? window.getComputedStyle(this.prevItem, null).getPropertyValue("left") : this.prevItem.currentStyle.left;
this.prevItem._x = Number(this.prevItem._x.replace("px", ""));
this.prevItem._y = (window.getComputedStyle) ? window.getComputedStyle(this.prevItem, null).getPropertyValue("top") : this.prevItem.currentStyle.top;
this.prevItem._y = Number(this.prevItem._y.replace("px", ""));

var yPos = (isNaN(this.prevItem._y + this.prevItem._height + this.spacer.row)) ? this.currItem._y : this.prevItem._y + this.prevItem._height + this.spacer.row;
var yRow = (isNaN(this.prevItem._y)) ? this.currItem._y : this.prevItem._y;

var xPos = (isNaN(this.prevItem._x + this.prevItem._width + this.spacer.col)) ? this.currItem._x : this.prevItem._x + this.prevItem._width + this.spacer.col;
var xCol = (isNaN(this.prevItem._x)) ? this.currItem._x : this.prevItem._x;

if (this.colBlock < this.prevItem._x + this.prevItem._width + this.spacer.col) {
this.colBlock = this.prevItem._x + this.prevItem._width + this.spacer.col;
}

if (this.rowBlock < this.prevItem._y + this.prevItem._height + this.spacer.row) {
this.rowBlock = this.prevItem._y + this.prevItem._height + this.spacer.row;
}

if (this.count > this.span.value) {
this.count = 2;
} else {
this.count++
}

switch(this.type) {
case "vertHoriz" :
case "vert" :
this.currItem._y = yPos;

if (this.span.value > 0) {

if (this.usePixels && (yPos + this.currItem._height) > this.span.value || !this.usePixels && this.count > this.span.value) {
this.currItem._y = this.collection[0]._y;
this.currItem.style.top = this.currItem._y + "px";

this.currItem._x = this.colBlock;
this.currItem.style.left = this.currItem._x + "px";

this.colNumber++;
this.rowNumber = 1;
}

if (this.usePixels && (yPos + this.currItem._height) < this.span.value || !this.usePixels && this.count <= this.span.value) {
this.currItem._y = yPos;
this.currItem.style.top = this.currItem._y + "px";

this.currItem._x = xCol;
this.currItem.style.left = this.currItem._x + "px";

this.rowNumber++

var targetHeight = this.currItem._y + this.currItem._height;
if (this.colNumber < 2) {
this.target.style.height = targetHeight + "px";
}

}

}

break;

case "horiz" :
this.currItem._x = xPos;

if (this.span.value > 0) {

if (this.usePixels && (xPos + this.currItem._width) >= this.span.value || !this.usePixels && this.count > this.span.value) {
this.currItem._y = this.rowBlock;
this.currItem.style.top = this.currItem._y + "px";

this.currItem._x = this.collection[0]._x;
this.currItem.style.left = this.currItem._x + "px";

this.colNumber = 1;
this.rowNumber++;

var targetHeight = this.currItem._y + this.currItem._height;
if (this.colNumber < 2) {
this.target.style.height = targetHeight + "px";
}

}

if (this.usePixels && (xPos + this.currItem._width) <= this.span.value || !this.usePixels && this.count <= this.span.value) {

this.currItem._y = yRow;
this.currItem.style.top = this.currItem._y + "px";

this.currItem._x = xPos;
this.currItem.style.left = this.currItem._x + "px";

this.colNumber++;
}

}

break;

}
}
}

this.colTotal = this.colNumber;
this.rowTotal = this.rowNumber;

}

//begin URLRequest class

function URLRequest (url) {
this.contentType = "";
this.data = {};
this.method = "GET";
this.requestHeaders = [];
this.url = "";

this.url = url;
}

//begin URLRequestHeader class

function URLRequestHeader (name, value) {
this.name = "";
this.value = "";

this.name = name;
this.value = value;
}

//begin URLLoader class

function URLLoader (target, callback) {

this.target = {};
this.callback = {args: [], name: undefined, scope: null};

this.XHR = {target: {}, callback: {}};
this.request = {method: "GET", url: null};
this.insertion = "replace";
this.islocal = false;

this.target = (typeof target == "object") ? target : document.getElementById(target);

for (var items in callback) this.callback[items] = callback[items];

//this.XHR = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
//this.XHR.target = this.target;
//this.XHR.callback = this.callback;

//Try to create XMLHttpRequest object
if (window.ActiveXObject) {
try {
this.XHR = new ActiveXObject("Microsoft.XMLHTTP");
} catch (error) {
//TODO
}
} else {
try {
this.XHR = new XMLHttpRequest();
this.XHR.target = this.target;
this.XHR.callback = this.callback;
} catch (error) {
//TODO
}
}

};

URLLoader.prototype = {

load: function (URLRequest) {

// Class instance
var classPointer = this;

if (typeof URLRequest == "string") this.request.url = URLRequest;
else this.request = URLRequest;

if (this.request.url) {
// File to load
this.XHR.open(this.request.method, this.request.url, true);

// Listen for state change
this.XHR.onreadystatechange = function () {
classPointer.httpStatus(classPointer.XHR);
}

this.setAllRequestHeaders();

try {
this.XHR.send(null);
} catch (error) {
//TODO
}

}

},

refresh: function (interval) {

// Class instance
var classPointer = this;

if (typeof interval == "number") {
var timedEvent = setInterval(function () { classPointer.load(classPointer.request); }, interval);
} else {
this.load(this.request);
}

},

setAllRequestHeaders: function () {

if (!this.request.requestHeaders)
return false;

for (var items = 0; items < this.request.requestHeaders.length; items++)
this.XHR.setRequestHeader(this.request.requestHeaders[items].name, this.request.requestHeaders[items].value);

return true;

},

httpStatus: function (response) {

//Test if page is loaded from local file system
this.islocal = new RegExp(/[file:]|[C:]/i).test(document.location.toString());

if (response.readyState == 4) {

if (response.status == 200 || this.islocal) {

// response.target: This will be used by FireFox, Mozilla, etc.
// this.target: This will be used by IE5 and above
var target = (response.target != undefined) ? response.target : this.target;
var callback = (response.callback != undefined) ? response.callback : this.callback;
var insertion = (response.insertion != undefined) ? response.insertion : this.insertion;
var xml = {};
var text = "";

if (target) {

try {
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = "false";
xml.loadXML(response.responseText.toString());
} catch (error) {
try {
xml = document.implementation.createDocument("", "", null);
xml.async = "false";
xml = (response.responseXML == null) ? xml.load(response.responseText.toString()) : response.responseXML;

} catch (error) {
//TODO
}
}

text = response.responseText;

if (target.innerHTML == undefined) {
target.TXT = text;
target.XML = xml;
target.JSON = "";//TODO
} else {

switch (insertion) {

case "append" :
target.innerHTML = container.innerHTML + text;
break;

case "prepend" :
target.innerHTML = text + container.innerHTML;
break;

case "replace" :
default :
target.innerHTML = text;
break;

}

}

}

if (callback.name) callback.name.apply(callback.scope, callback.args);

}

}

}

};
//begin CSSManager class

function CSSManager () {

}

Class(CSSManager);

CSSManager.addClassName = function (target, name) {

var expr = eval("/\\s?" + name + "$|\\b" + name + "\\s/gi");
var hasClassName = new RegExp(expr).test(target.className);

if (target.className == "" && target.className == undefined) {
target.className = name;
return true;
} else if (!hasClassName) {
target.className = target.className + " " + name;
return true;
}

return false;

}

CSSManager.removeClassName = function (target, name) {

if (target.className == "") return false;

var expr = eval("/\\s?" + name + "$|\\b" + name + "\\s/gi");
var hasClassName = new RegExp(expr).test(target.className);
if (hasClassName) target.className = target.className.replace(expr, "");

}

CSSManager.testClassName = function (target, name) {

if (target.className == "") return false;

var expr = eval("/\\s?" + name + "$|\\b" + name + "\\s/gi");
var hasClassName = new RegExp(expr).test(target.className);
return hasClassName;

}

//begin Menu class

function Menu (target, props) {

this.addListener(this);

if (target == undefined) return;

this.target = (typeof target == "object") ? target : document.getElementById(target);

if (props != undefined) {
this.properties.evt = (props.evt == undefined) ? this.properties.evt : props.evt;
this.properties.type = (props.type == undefined) ? this.properties.type : props.type;
this.properties.autoHide = (props.autoHide == undefined) ? this.properties.autoHide : props.autoHide;
}

this.evtTarget = (this.userAgent.isIEStrict()) ? "srcElement" : "target";

CSSManager.addClassName(this.target, this.className);
CSSManager.addClassName(this.target, this.properties.type);

this.onfocus();
if (this.properties.autoHide) this.autoHide();

var classPointer = this;
var evtMouse = (this.userAgent.isIEStrict()) ? this.properties.evt : "event";

this.target[this.properties.evt] = function (evtMouse) {
classPointer.showHide((classPointer.userAgent.isIEStrict()) ? event : evtMouse);
}

}

Class(Menu);
Broadcaster.initialize(Menu.prototype, false);

Menu.prototype.target = new Object();
Menu.prototype.properties = {evt: "onmousedown", type: "", autoHide: true};
Menu.prototype.currFocus = new Object();
Menu.prototype.prevFocus = new Object();
Menu.prototype.evtTarget = new Object();
Menu.prototype.className = "menu-list";
Menu.prototype.userAgent = new UADetector();

Menu.prototype.onShow = new Function;
Menu.prototype.onHide = new Function;

Menu.prototype.show = function (target) {

this.currFocus = target;

CSSManager.removeClassName(target, "hide");
CSSManager.addClassName(target, "active");

var sibling = Menu.getPreviousSibling(target);
var alink = new Object();

if (sibling.nodeName.toLowerCase() == "a") {
alink = sibling;
} else {
alink = sibling.getElementsByTagName("a").item(0);
}

CSSManager.addClassName(alink, "active");

this.broadcastMessage("onShow", this, target);

}

Menu.prototype.hide = function (target) {

if (target.nodeName) {
CSSManager.addClassName(target, "hide");
CSSManager.removeClassName(target, "active");

var sibling = Menu.getPreviousSibling(target);
var alink = new Object();

if (sibling.nodeName.toLowerCase() == "a") {
alink = sibling;
} else {
alink = sibling.getElementsByTagName("a").item(0);
}

CSSManager.removeClassName(alink, "active");
}

this.broadcastMessage("onHide", this, target);

}

Menu.prototype.showHide = function (evt) {

var nodeMatch = new Object();
nodeMatch.bool = false;
var node = new Object();

if (evt[this.evtTarget].tagName.toLowerCase() == "a") {

nodeMatch = Menu.hasParentNode(this.target, evt[this.evtTarget], "dt");

} else {

var alink = Menu.hasParentNode(this.target, evt[this.evtTarget], "a");

if (alink.bool) nodeMatch = Menu.hasParentNode(this.target, alink.node, "dt");

}

if (nodeMatch.bool) {
node = Menu.getNextSibling(nodeMatch.node, 1);
} else {
node = Menu.getNextSibling(evt[this.evtTarget], 1);
}

if (CSSManager.testClassName(node, "hide")) {
this.hide(this.currFocus);
this.show(node);
}

}

Menu.prototype.autoHide = function () {

var classPointer = this;

this.target.onmouseout = function (evt) {

var evt = (classPointer.userAgent.isIEStrict()) ? event : evt;
var currItem = (classPointer.userAgent.isIEStrict()) ? evt.toElement : evt.relatedTarget;
var children = new Array();

if (currItem == this || currItem == undefined) return;

if (currItem.tagName == null || currItem.tagName.toLowerCase() == "html" || currItem.tagName.toLowerCase() == "body") {
classPointer.hide(classPointer.currFocus);
} else {
children = this.getElementsByTagName( currItem.nodeName);
for (var items = 0; items < children.length; items++) {
if (children[items] == currItem) return true;
}

classPointer.hide(classPointer.currFocus);
}

}
}

Menu.prototype.onfocus = function (evt) {

//if (this.properties.evt != "onmouseover") return;

var classPointer = this;

if (this.userAgent.isIEStrict()) {
this.target.onfocusin = function (onfocusin) {

var evt = event;
var currItem = evt.srcElement;

var target = Menu.parentNodeWithAttributeValue(classPointer.target, currItem, "className", "hide");

if (target.bool) {
classPointer.hide(classPointer.currFocus);
classPointer.show(target.node);
} else {
classPointer.showHide(evt);
}

//classPointer.showHide(event);
}

this.target.onfocusout = function (onfocusout) {

var evt = event;
var currItem = evt.toElement;
var children = new Array();

if (currItem == this) return;

if (currItem == null || currItem.tagName == null || currItem.tagName.toLowerCase() == "html" || currItem.tagName.toLowerCase() == "body") {
classPointer.hide(classPointer.currFocus);
} else {
children = this.getElementsByTagName( currItem.nodeName);
for (var items = 0; items < children.length; items++) {
if (children[items] == currItem) return true;
}

classPointer.hide(classPointer.currFocus);
}

}
} else {
this.target.onfocus = function (evt) {

var currItem = evt.explicitOriginalTarget;

var target = Menu.parentNodeWithAttributeValue(classPointer.target, currItem, "className", "hide");
if (target.bool) {
classPointer.hide(classPointer.currFocus);
classPointer.show(target.node);
} else {
classPointer.showHide(evt);
}

}
this.target.onblur = function (evt) {

var currItem = evt.explicitOriginalTarget;
var children = new Array();

if (currItem == this) return;

if (currItem == null || currItem.tagName == null || currItem == evt.target || currItem.tagName.toLowerCase() == "html" || currItem.tagName.toLowerCase() == "body") {
classPointer.hide(classPointer.currFocus);
} else {
children = this.getElementsByTagName( currItem.nodeName);
for (var items = 0; items < children.length; items++) {
if (children[items] == currItem) return true;
}

classPointer.hide(classPointer.currFocus);
}

}
}

}

Menu.hasParentNode = function (root, target, name) {

var node = target;
var result = new Object();
result.bool = false;

while (node.parentNode != undefined && node.parentNode != root) {
node = node.parentNode;
if (node.nodeType == 1 && node.tagName.toLowerCase() == name) {
result.bool = true;
break;
}
}

result.node = node;

return result;

}

Menu.parentNodeWithAttributeValue = function (root, target, name, value) {

var node = target;
var result = new Object();
result.bool = false;

while (node.parentNode != undefined && node.parentNode != root) {
node = node.parentNode;
if (node.nodeType == 1) {
if ((name == "className" && CSSManager.testClassName(node, value)) || node[name] == value) {
result.bool = true;
break;
}
}
}

result.node = node;

return result;

}

Menu.getNextSibling = function (target, type) {

var node = target;
var nodeType = (type == undefined) ? 1 : type;

while (node.nextSibling != undefined) {
node = node.nextSibling;
if (node.nodeType == nodeType) break;
}

return node;

}

Menu.getPreviousSibling = function (target, type) {

var node = target;
var nodeType = (type == undefined) ? 1 : type;

while (node.previousSibling != undefined) {
node = node.previousSibling;
if (node.nodeType == nodeType) break;
}

return node;

}


//Begin Toolbar
<!--
var tb;
/* jCoreAPI instance */
var jcore = new jCoreAPI();
/* Global debug boolean, if false, does not display alerts created by jCoreAPI or any of its instances */
jCoreAPI.debug = true;
/* Local instance of debug boolean, if false, does not display any alerts created by this instance */
//jcore.debug = true;
/**
 * Class creation using jCoreAPI
 */
jcore.Class({package: "Toolbar"}, {
constructor: function () {
//this._sid = this.getQueryString("sid");
//Init information here
this._hostName = window.location.hostname;
var dom = new jcore.DOM();
//Get the toolbar div
var divObj = dom.get("..div.@id == dvToolbar");
//add div after script if it does not exist
if (typeof divObj[0] == 'undefined'){
document.write("<div id='dvToolbar'>initializing toolbar...</div>");
divObj = dom.get("..div.@id == dvToolbar");
}
//divObj[0].style.opacity = 0;
divObj[0].style.display = 'none';
//build base content Will be generated by backend scripts
divObj[0].innerHTML = '<div id="@toolbar-module"><div id="@toolbar-panel-brand" class="@toolbar-contents"><dl class="@toolbar-menu-panel"><dt id="@toolbar-brand" tabindex="0"><a href="javascript:void(0);" title="Arlington County Commuter Services (ACCS)"><span>Arlington County Commuter Services (ACCS)</span></a></dt><dd id="@toolbar-menu-family" class="@toolbar-menu hide"><!-- dynamic content --><h5>Get Around Arlington Car-Free</h5><ul id="@toolbar-menu-family_list"><li><a href="http://www.carfreediet.com/">Arlington\'s Car-Free Diet</a></li><li><a href="http://www.commuterpage.com/art/">Arlington Transit - ART</a></li><li><a href="http://www.walkarlington.com/about/index.html">WALKArlington.com</a></li><li><a href="http://www.BikeArlington.com">BikeArlington.com</a></li><li><a href="http://www.ArlingtonTransportationPartners.com">Arlington Transportation Partners</a></li><li><a href="http://www.commuterpage.com/stores.htm">The Commuter Store</a></li><li><a href="http://www.commuterpage.com/iRide/">iRide - Transit information for Teens</a></li></ul><h5>Transportation Options for the Washington, DC Area</h5><ul id="@toolbar-menu-family_list"><li><a href="http://www.CommuterPage.com">CommuterPage.com</a></li><li><a href="http://www.CommuterDirect.com">CommuterDirect.com</a></li></ul><h5>Blogs</h5><ul id="@toolbar-menu-family_list"><li><a href="http://www.commuterpageblog.com/">CommuterPageBlog</a></li><li><a href="http://www.arlingtontransitblog.com/">Arlington Transit Blog</a></li><li><a href="http://www.carfreedietblog.com/">Arlington\'s Car-Free Diet Blog</a></li></ul></dd></dl></div><div id="@toolbar-panel" class="@toolbar-contents"><dl class="@toolbar-menu-panel"><dt tabindex="0"><a href="javascript: void(0);" title=""><sup id="@toolbar-alertCount"></sup>Transit Alerts</a></dt><dd id="@toolbar-menu-alerts" class="@toolbar-menu hide"><!-- dynamic content --><dl><dt>loading...</dt><dd><ul style="position: relative;"><li>February 19, 2010</li></ul></dd></dl></dd><dt tabindex="0"><a href="javascript: void(0);" title="Share">Share</a></dt><dd id="@toolbar-menu-share" class="@toolbar-menu hide"><!-- dynamic content --><ul><li><a href="javascript:tb.submitIt(\'blinklist\');"><img src="http://www.commuterpage.com/webtoolbar/images/icon_blinklist.png" alt="Blink List" title="Blink List" /><span>Blink List</span></a></li><li><a href="javascript:tb.submitIt(\'delicious\');"><img src="http://www.commuterpage.com/webtoolbar/images/icon_delicious.png" alt="Del.icio.us" title="Del.icio.us" /><span>Del.icio.us</span></a></li><li><a href="javascript:tb.submitIt(\'digg\');"><img src="http://www.commuterpage.com/webtoolbar/images/icon_digg.png" alt="Digg" title="Digg" /><span>Digg</span></a></li><li><a href="javascript:tb.submitIt(\'facebook\');"><img src="http://www.commuterpage.com/webtoolbar/images/icon_facebook.gif" alt="Facebook" title="Facebook" /><span>Facebook</span></a></li><li><a href="javascript:tb.submitIt(\'google\');"><img src="http://www.commuterpage.com/webtoolbar/images/icon_google.png" alt="Google" title="Google" /><span>Google</span></a></li><li><a href="javascript:tb.submitIt(\'reddit\');"><img src="http://www.commuterpage.com/webtoolbar/images/icon_reddit.gif" alt="Reddit" title="Reddit" /><span>Reddit</span></a></li><li><a href="javascript:tb.submitIt(\'stumbleupon\');"><img src="http://www.commuterpage.com/webtoolbar/images/icon_stumbleupon.png" alt="StumbleUpon" title="StumbleUpon" /><span>StumbleUpon</span></a></li><li><a href="javascript:tb.submitIt(\'technorati\');"><img src="http://www.commuterpage.com/webtoolbar/images/icon_technorati.png" alt="Technorati" title="Technorati" /><span>Technorati</span></a></li><li><a href="javascript:tb.submitIt(\'twitter\');"><img src="http://www.commuterpage.com/webtoolbar/images/icon_twitter.png" alt="Twitter" title="Twitter" /><span>Twitter</span></a></li><li><a href="javascript:tb.submitIt(\'live\');"><img src="http://www.commuterpage.com/webtoolbar/images/icon_microsoftlive.gif" alt="Windows Live" title="Windows Live" /><span>Windows Live</span></a></li><li><a href="javascript:tb.submitIt(\'yahoo\');"><img src="http://www.commuterpage.com/webtoolbar/images/icon_yahoo.png" alt="Yahoo" title="Yahoo" /><span>Yahoo</span></a></li></ul></dd><dt tabindex="0"><a href="javascript: void(0);" title="Help">Help</a></dt><dd id="@toolbar-menu-help" class="@toolbar-menu hide"><!-- dynamic content --><ul></ul></dd><dt tabindex="0"><a href="javascript: void(0);" title="">Printer Friendly</a></dt><dd id="@toolbar-menu-printerFriendly" class="@toolbar-menu hide"><ul><li><a href="/shared/tasks/CreateDocument.cfm?viewtype=print" target="_print" title="">Print Preview</a></li><li><a href="/shared/tasks/CreateDocument.cfm?viewtype=pdf" target="_pdf" title="">Create PDF</a></li></ul></dd></dl><form action="/search-results/" id="@toolbar-search" name="toolbar-search"><fieldset><span class="@toolbar-search-field"><span> <input type="hidden" name="cx" value="012373782381364114505:l60n1ymhjby" /> <input type="hidden" name="cof" value="FORID:9" /> <input type="hidden" name="ie" value="UTF-8" /> <input type="text" name="q" size="31" value="search" onfocus="if(this.value==\'search\'){this.value=\'\';}" /> <input type="hidden" name="sa" value="Search"/> </span></span></fieldset></form><script type="text/javascript" src="http://www.google.com/jsapi"></script><script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script><script type="text/javascript" src="http://www.google.com/coop/cse/t13n?form=cse-search-box&amp;t13n_langs=en"></script><script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en"></script></div><div id="@toolbar-message" class="@toolbar-contents" style="display: none;"><!-- dynamic content --><p><a href="javascript: void(0);"></a></p></div></div> ';
this._brandMenu = new Menu("@toolbar-panel-brand", { evt: "onmousedown", type: "dropdown", autoHide: true });
this._panel = document.getElementById("@toolbar-panel");
this._panelMenu = new Menu(this._panel.getElementsByTagName("dl")[0], { evt: "onmousedown", type: "dropdown", autoHide: true });

//Set custom site help links;
this.setHelp();
this.setSearch();

//check for alerts
this.getAlerts();
this._updateInterval = setInterval("tb.getAlerts();", 360000);
//divObj[0].style.opacity = 1;
divObj[0].style.display = 'block';

/*
var toolbarBrandMenu = this._brandMenu;
var toolbarPanelMenu = this._panelMenu;

var toolbarLinks = divObj[0].getElementsByTagName("a");

for (var index = 0, len = toolbarLinks.length; index < len; index++) {

if (toolbarLinks[index].onclick == undefined && toolbarLinks[index].href != "javascript: void(0);") {

toolbarLinks[index].onclick = function(evt) {
toolbarBrandMenu.hide(toolbarBrandMenu.currFocus);
toolbarPanelMenu.hide(toolbarPanelMenu.currFocus);
}

}

}
*/
}, 
prototype: {
//add methods for tooblar class
_sid: "",
_alerts: "",
_alertsCount: 0,
_updater: new Object(),
//Contains reference to alerts with high alert status
_highAlerts: new Object(),

_brandMenu: new Object(),
_panel: new Object(),
_panelMenu: new Object(),
_updateInterval: new Object(),
_hostName: "",

/**
 * Adds the toolbars CSS if needed
 * toString
 * Builds out the toolbar
 * 
 * @paraminput<String (required)>
 * 
 * @return<XML>
 */
addCss: function() {

//Check to see if css exists.
// if not, add it
var dom = new jcore.DOM();
if (dom.get("head.link.@href==http://www.arlingtontransportationpartners.com/shared/css/toolbar.css").length == 0){
dom.set("link", {href: "http://www.arlingtontransportationpartners.com/shared/css/toolbar.css", rel:"stylesheet", media:"all", type:"text/css"}).appendChild("head");
}

},

/**
 * Deprecated and moved into the init constructor
 * toString
 * Builds out the toolbar
 * 
 * @paraminput<String (required)>
 * 
 * @return<XML>
 */
toString: function () {
//Init information here
var dom = new jcore.DOM();
//Get the toolbar div
var divObj = dom.get("body.div.@id == dvToolbar");
//build base content
divObj[0].innerHTML = "Test output, this will come from cf toolbar build process";
},

/**
* clearHighAlerts
* Used to Clear the high alerts bar
* What if there is more than one alert?
*
*/
clearAlerts: function (){
var dom = new jcore.DOM();
var objAlerts = Object();
objAlerts = dom.get("..dd.@id == @toolbar-menu-alerts");
objAlerts.innerHTML = "There are no alerts at this time.";
},

//Should I create an alerts class that on constructing will do an intial check of service?
getAlerts: function () {
var strAlerts = new String;
var dom = new jcore.DOM();
dom.set("script", { src: "http://www.arlingtontransportationpartners.com/shared/services/utility.cfc?method=feedToJson&callback=tb.alertHandler&url=http://www.arlingtontransportationpartners.com/shared/services/news.cfc?method=GetAllAlerts", id: "cstest", type: "text/javascript" }).appendChild("head");

},

/**
* clearHighAlerts
* Used to Clear the high alerts bar
* What if there is more than one alert?
*
*/
clearHighAlerts: function (){
var dom = new jcore.DOM();
var objAlerts = Object();
objAlerts = dom.get("..div.@id == @toolbar-message");
objAlerts[0].innerHTML = "";
objAlerts[0].setAttribute("class", "@toolbar-contents hide");
},

/**
* addHighAlert
* Used to display high alerts bar below the toolbar
* What if there is more than one alert?
*
*/
addHighAlert: function (objItem /*rss item object*/){
var dom = new jcore.DOM();
var objAlerts = Object();
objAlerts = dom.get("..div.@id == @toolbar-message");
objAlerts[0].innerHTML += "<p><a href='"+ objItem.link.text + "' title='"+ objItem.title.text + "' target='_blank'>"+ objItem.title.text + "</a></p>";
objAlerts[0].setAttribute("class", "@toolbar-contents");
},

updateCountDisplay: function(intVal){
var objAlertCount = dom.get("..sup.@id == @toolbar-alertCount");
if (intVal == undefined){
objAlertCount[0].innerHTML = (parseInt(this._alertsCount) !=0 ? this._alertsCount : '');
if (objAlertCount[0].innerHTML == '') objAlertCount[0].style.display = 'none';
}else{
objAlertCount[0].innerHTML = (parseInt(intVal) != 0 ? intVal : '');
if (objAlertCount[0].innerHTML != '') objAlertCount[0].style.display = 'inline';
}
},

/**
* createAlert
* Creates an html formatted alert from an object and returns the html string
* What if there is more than one alert?
* @param input <object (required)>
*
* @return<html string>
*
*/
createAlert: function(strTitle, strDesc, strLink, isHigh)/*htmlString*/{
//parse object and create html alert
var dom = new jcore.DOM();
//<li><a href="#" target="_new">Blue Line - Equipment Problem. 10 minute delay</a></li>

var strNew = "";

if (strLink.length == 0){
strNew = "<li>" + strTitle + "</li>";
} else {
strNew = "<li><a href='" + strLink + "' title='"+ strTitle +"' target='_new'>" + strTitle + "</a></li>";
}

return strNew;

},

/**
* getQueryString
* Finds a value in the pages querystring
* 
* @paramval<string (required)>
* 
* @return <string>
*/
getQueryString: function (val/*string*/)/*string*/{
var objRegex = new RegExp("[?&]"+val+"=([^&#]*)");
var qs = objRegex.exec(window.location.href);
if(qs == null){
return "";
}else{
return qs[1];
}
},

loadXMLDoc: function (url, returnProcess, cache) {
req = this.GetXmlHttpObject();
if (req != null) {
req.returnProcess = returnProcess;
req.onreadystatechange = this.processReqChange;
req.open("GET", url, true);
req.setRequestHeader("Content-Type", "text/html");
//req.setRequestHeader('Cache-Control', 'max-age=60')
req.send("");
}
},

GetXmlHttpObject: function() {
var xmlHttp = null;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
}
catch (e) {
// Internet Explorer
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
},

alertHandler: function(obj) {

this._alerts = eval(obj);
/* sample json response

returnFunctionName({"rss":{"text":"","attributes":{"version":2.0},"channel":[{"text":"","attributes":{},"title":{"text":"Metrorail Disruptions","attributes":{}},"link":{"text":"http://www.arlingtontransportationpartners.com/shared/services/news.cfc?method=GetMetroRailAlerts","attributes":{}},"description":{"text":"Active rail disruptions","attributes":{}},"lastBuildDate":{"text":"Thu, 07 May 2009 05:07:27 GMT","attributes":{}},"item":{"text":"","attributes":{},"title":{"text":"There are no reported Metrorail disruptions at this time.","attributes":{}},"description":{"text":"There are no reported Metrorail disruptions at this time.","attributes":{}},"link":{"text":"http://www.wmata.com/rider_tools/metro_service_status/rail_bus.cfm?nocache","attributes":{}},"pubDate":{"text":"Thu, 07 May 2009 05:05:00 GMT","attributes":{}},"localDate":{"text":"Thu, May 07, 2009 1:05 AM","attributes":{}}}},{"text":"","attributes":{},"title":{"text":"Metrobus Disruptions","attributes":{}},"link":{"text":"http://www.arlingtontransportationpartners.com/shared/services/news.cfc?method=GetMetroBusAlerts","attributes":{}},"description":{"text":"Active bus disruptions","attributes":{}},"lastBuildDate":{"text":"Thu, 07 May 2009 05:07:27 GMT","attributes":{}},"item":{"text":"","attributes":{},"title":{"text":"There are no reported Metrobus disruptions at this time.","attributes":{}},"description":{"text":"There are no reported Metrobus disruptions at this time.","attributes":{}},"link":{"text":"http://www.wmata.com/rider_tools/metro_service_status/rail_bus.cfm?nocache","attributes":{}},"pubDate":{"text":"Thu, 07 May 2009 05:05:00 GMT","attributes":{}},"localDate":{"text":"Thu, May 07, 2009 1:05 AM","attributes":{}}}},{"text":"","attributes":{},"title":{"text":"ART Disruptions","attributes":{}},"link":{"text":"http://www.arlingtontransportationpartners.com/shared/services/news.cfc?method=GetARTAlerts","attributes":{}},"description":{"text":"Active bus disruptions","attributes":{}},"lastBuildDate":{"text":"Thu, 07 May 2009 05:07:27 GMT","attributes":{}},"item":{"text":"","attributes":{},"title":{"text":"Chad is testing the alerts","attributes":{}},"description":{"text":"Chad is testing the alerts, there will be several random messages like this.","attributes":{}},"link":{"text":"http://www.commuterpage.com/art/alert.cfm?id=1531","attributes":{}},"pubDate":{"text":"2009-05-06 01:43:00.0","attributes":{}},"localDate":{"text":"Tue, May 05, 2009 9:43 PM","attributes":{}},"urgent":{"text":"1","attributes":{}}}}]}})

*/

//Clear the alerts bar
this.clearAlerts();
this.clearHighAlerts();
//clear high alerts
//loop over results
// createAlert from each item and build strAlerts along the way

var intChannelCount = this._alerts.rss.channel.length;
var intItemCount = 0
var alertList = new String;
var isUrgent = "0";
//Loop over Channels
alertList = "<dl>";
for (var i=0; i<intChannelCount;i++){
alertList += "<dt>" + this._alerts.rss.channel[i].title.text + "</dt><dd><ul style='position: relative;'>";
//Loop over items and createAlert: function(strTitle, strDesc, strLink, isHigh)/*htmlString*/{

if (this._alerts.rss.channel[i].item.length == undefined){
if (this._alerts.rss.channel[i].item.urgent != undefined){
isUrgent = this._alerts.rss.channel[i].item.urgent.text;
}else{isUrgent = "false";}
alertList += this.createAlert(this._alerts.rss.channel[i].item.title.text,
this._alerts.rss.channel[i].item.description.text,
this._alerts.rss.channel[i].item.link.text,
isUrgent);

if((this._alerts.rss.channel[i].item.title.text.indexOf("is operating normally") == -1) && (this._alerts.rss.channel[i].item.title.text.indexOf("There are no reported") == -1)){
intItemCount++;
}
if (isUrgent == "1"){this.addHighAlert(this._alerts.rss.channel[i].item);};
}else{

for (var j=0; j<this._alerts.rss.channel[i].item.length;j++){

if (this._alerts.rss.channel[i].item[j].urgent != undefined){isUrgent = this._alerts.rss.channel[i].item[j].urgent.text;}else{isUrgent = "false";}
alertList += this.createAlert(this._alerts.rss.channel[i].item[j].title.text,
this._alerts.rss.channel[i].item[j].description.text,
this._alerts.rss.channel[i].item[j].link.text,
isUrgent);

if((this._alerts.rss.channel[i].item[j].title.text.indexOf("ART is operating normally") == -1) && (this._alerts.rss.channel[i].item[j].title.text.indexOf("There are no reported") == -1)){
intItemCount++;
}
};
}
alertList += "</ul></dd>";
};
alertList += "</dl>";
this._alertsCount = intItemCount;
this.updateCountDisplay();
//Desired output
/*
<dd id="@toolbar-menu-alerts" class="gadget-transit_alerts">
<dl>
<dt>Metrorail Alerts</dt>
<dd>
<ul>
<li><a href="#" target="_new">Red Line - Woodley Park Station is Closed</a></li>
<li><a href="#" target="_new">Blue Line - Equipment Problem. 10 minute delay</a></li>
</ul>
</dd>

<dt>Metrobus Alerts</dt>
<dd>
<ul>
<li>No Alerts at This Time</li>
</ul>
</dd>

<dt>Art Alerts</dt>
<dd>
<ul>
<li><a href="#" target="_new">ART 51</a> - 5 minute delay</li>
</ul>
</dd>
</dl>
</dd>
*/

// Set alerts to strAlerts
// find dd @toolbar-menu-alerts
var objAlerts = dom.get("..dd.@id == @toolbar-menu-alerts");
strAlerts = alertList;
objAlerts[0].innerHTML = strAlerts;

},

setHelp: function () {
var dHelp = new String;
dHelp = '<ul>'
sid = this._hostName;
/*
Switch format in coldfusion bulding
loop over sites in query and build out js script

case '{siteid}' :{
cfinclude site links
break;
}
*/
switch(sid){
case 'www.arlingtontransportationpartners.com' :{

dHelp += '<li><a href="/pages/about/contact-us/" target="_blank">Contact Us</a></li>'
break;
}
case 'www.bikearlington.com' :{

dHelp += '<li><a href="/pages/about/contact-us/" target="_blank">Contact</a></li>'
break;
}
default:{
dHelp += '<li><a href="javascript: void(0);" target="_blank">FAQs</a></li>'
}
}


dHelp += "</ul>";
var dom = new jcore.DOM();
dom.get("..dd.@id == @toolbar-menu-help")[0].innerHTML = dHelp;
},

setSearch: function (){
//Load in urls from all sites hosted in cms, 
//read search url from site settings
//set form submit url to search url

var sUrl = new String;
var sCx = new String;
var sCof = new String;
//Set sUrl in template

switch(sid){
case 'www.arlingtontransportationpartners.com' :{
sUrl = '/search-results/';
sCx = '012373782381364114505:l60n1ymhjby';
sCof = 'FORID:9';
break;
}
case 'www.bikearlington.com' :{
sUrl = '/pages/search-results/';
sCx = '007572961896628131619:ic7ref_kuq4';
sCof = 'FORID:11';
break;
}
default:{
sUrl = 'http://www.commuterpage.com/search.cfm';
}
}

var dom = new jcore.DOM();
dom.get("..form.@id == @toolbar-search")[0].action = sUrl;
dom.get("..form.@id == @toolbar-search")[0].cx.value = sCx;
dom.get("..form.@id == @toolbar-search")[0].cof.value = sCof;

},

submitIt: function(site){
var siteString;
if (site == "blinklist")
{siteString = "http://blinklist.com/index.php?Action=Blink/addblink.php&url="+window.location.href+"&Title="+window.top.document.title;}
if (site == "delicious")
{siteString = "http://del.icio.us/post?url="+window.location.href+"&title="+window.top.document.title;}
if (site == "digg")
{siteString = "http://digg.com/submit?phase=2&url="+window.location.href;}
if (site == "facebook")
{siteString = "http://www.facebook.com/sharer.php?u="+window.location.href+"&t="+window.top.document.title;}
if (site == "furl")
{siteString = "http://furl.net/storeIt.jsp?t="+window.top.document.title+"&u="+window.location.href;}
if (site == "goloco")
{siteString = "http://apps.facebook.com/igoloco/facebook_home";}
if (site == "google")
{siteString = "http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk="+window.location.href+"&amp;title="+window.top.document.title;}
if (site == "myaol")
{siteString = "http://favorites.my.aol.com/ffclient/webroot/0.2.1/src/html/addBookmarkDialog.html?url="+window.location.href+"&title="+window.top.document.title;}
if (site == "nuride")
{siteString = "http://www.nuride.com/nuride/Public/Overview.jsp";}
if (site == "reddit")
{siteString = "http://reddit.com/submit?url="+window.location.href+"&title="+window.top.document.title;}
if (site == "stumbleupon")
{siteString = "http://www.stumbleupon.com/submit?url="+window.location.href+"&title="+window.top.document.title;}
if (site == "technorati")
{siteString = "http://technorati.com/cosmos/search.html?url="+window.location.href;}
if (site == "live")
{siteString = "https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url="+window.location.href+"&title="+window.top.document.title;}
if (site == "yahoo")
{siteString = "http://myweb2.search.yahoo.com/myresults/bookmarklet?u="+window.location.href+"&amp;t="+window.top.document.title;}
if (site == "twitter")
{siteString = "http://www.commuterpage.com/shared/functions/twitter/TwitterStatus.cfm?rawURL="+window.location.href+"&amp;t="+window.top.document.title;}
// Launch a new window with the submission
window.open(siteString,'addthis','scrollbars=yes,menubar=yes,width=620,height=400,resizable=yes,toolbar=yes,location=yes,status=yes');
}
}

});


/**
 * Class implementation
 * Instance of new class and adding properties to it
 */

var dom = new jcore.DOM();
if (dom.get("head.link.@href==http://www.arlingtontransportationpartners.com/shared/css/toolbar.css").length == 0){
dom.set("link", {href: "http://www.arlingtontransportationpartners.com/shared/css/toolbar.css", rel:"stylesheet", media:"all", type:"text/css"}).appendChild("head");
}

function init(){
//if (typeof(tb)=='undefined'){
//tb = new jcore.Toolbar();
//}
}
if (typeof(tb)=='undefined'){
tb = new jcore.Toolbar();
}
if (window.addEventListener) window.addEventListener ("load",init,false);

-->

