(function(){
		var YUI = YAHOO,
			util = YAHOO.util,
			lang = YAHOO.lang,
			YUD = util.Dom,
			Get = util.Get,
			Selector = util.Selector,
			JSON = lang.JSON,
			Connection = util.Connection;
			
			
YAHOO.namespace("Dashboard");

YAHOO.lang.augmentObject(YAHOO.Dashboard, {
	EVENTS: {
		"READY": new YAHOO.util.CustomEvent("onReady"),
		"CONNECTION_COMPLETE": new YAHOO.util.CustomEvent("connectComplete")
	},
	
	browser: YAHOO.env.ua,
	isIE: YAHOO.env.ua.ie,

	debug: true,
	
	getArray: function (a) {
		return Array.prototype.slice.call(a,0);
	},
	
	/*
	  Basic curry function.  Pass the function you want to curry and
	  the arguments you'd like to pass.  Pass the arguments as you
	  would to the function.
	 */
	curry: function () {
		var args = YAHOO.Dashboard.getArray(arguments),
			fn = args.shift();
			
		return function() {
			return fn.apply(f, args);
		};
	},
	
	partial: function () {
		var params = YAHOO.Dashboard.getArray(arguments);
		var fn = params.shift();
		
		if (!YAHOO.Dashboard.isOfType(fn, "function"))
			return function(){};
		
		return function () {
			var arg = 0, args = [], i = 0;
			
			do {
				args[i] = params[i];
				
				if (args[i] == undefined) {
					args[i] = arguments[arg++];
				}
				
				i++;
			} while (i < params.length || arg < arguments.length);
			
			return fn.apply(fn, args);
		};
	},
	
	alias: function (fn, aliases, callback) {
		YAHOO.Dashboard.forEach( aliases, function (name, args) {
			params = [fn];
			
			Array.prototype.push.apply(params, args||[]); 
			
			callback(name, YAHOO.Dashboard.partial.apply(fn, params)); 
		});
	},
	
	method: function (name, fn) {
		this[name] = fn;
		
		return this;
	},

	/*
	  Uses the curry pattern to call the specified function + arguments
	  at a timeout of 0 (or other int if passed as first argument)
	 */
	delay: function () {
		var args = YAHOO.Dashboard.getArray(arguments),
			i = isNaN(args[0]) ? 0 : args.shift();
			f = args.length > 1 ? dashboard.curry.apply(YAHOO.Dashboard, args) : args.shift();
		
		return setTimeout(f, i); 
	},

	/*
	  Make an object (or array) into a new array.  truncates the first
	  array and then fills it with the second array. Fastest way to give
	  array like properties to an object.
	 */
	makeArray: function (a1,a2) {
		a1.length = 0;
		
		a2 = YAHOO.Dashboard.isArray(a2) ? a2 : [a2];
		
		return YAHOO.Dashboard.merge(a1,a2);
	},

	/*
	  Merge two arrays (or an object and array) to form a single array
	 */
	merge: function (a1,a2) {
		a2 = YAHOO.Dashboard.isArray(a2) ? a2 : [a2];
		
		Array.prototype.push.apply(a1,a2);
		
		return a1;
	},  

	/*
	  Loop through an array performing a single function on each element
	 */
	forEach: function ( object, callback ) {
		if ( object == undefined ) {
			return;
		}
		
		if ( object.length == undefined ) {
			for ( var name in object )
				if ( callback.call( object[ name ], name, object[ name ] ) === false )
					break;
		} else
			for ( var i = 0, length = object.length, value = object[0]; 
				i < length && callback.call( value, value ) !== false; value = object[++i] ){}

		return object;
	},
	
	/*
	  Validates a given test variable against a type of 
	  variable (string, object, array, etc)
	 */
	isOfType: function (type, test) {
		switch (type) {
		case "array":
			return test != undefined && typeof test == "object" || /Array|Object/.test(test.constructor);
			
		case "string":
			return test != undefined && typeof test == "string";
			
		case "function":
			return test != undefined && !!test && typeof test != "string" && !test.nodeName && 
				test.constructor != Array && /function/i.test( test + "" );
		}
		
		return false;
	},
	
	isString: function (test) {
		return test != undefined && typeof test == "string";
	},
	
	isArray: function (test) {
		return test != undefined && typeof test == "object" || /Array|Object/.test(test.constructor);
	},
	
	isFunction: function (test) {
		return test != undefined && !!test && typeof test != "string" && !test.nodeName && 
			test.constructor != Array && /function/i.test( test + "" );
	},
	
	/*
	  String trimming, faster than the normal trim!
	 */
	trim: function (str) {
		str = str.replace(/^\s+/, '');
		
		for (var i = str.length - 1; i >= 0; i--) {
			if (/\S/.test(str.charAt(i))) {
				str = str.substring(0, i + 1);
				break;
			}
		}
		
		return str;
	},
	
	register: function (module) {
		if (module.namespace) {
			YAHOO.Dashboard[module.namespace] = module;
		}
	},
	
	/*
	  Inspired by Douglas Crockfords classical inheritance patterns.  Clones
	  an object by reference.  The child cannot modify the parent, but parent
	  can change to affect the child.
	 */
	extend: function (o) {
		var pupil = function(){};
		
		pupil.prototype = o || dashboard;
		
		return new pupil();
	},
	
	reload: function (url, full) {
		if (full) {
			top.location = location.protocol+"//"+location.hostname+location.pathname+"#"+url;
			top.location.reload();
			return;
		}
		
		Dashboard.History.navigate(url);
	},

	event: {
		add: function (el, type, method) {
			console.trace();
			YAHOO.util.Event.addListener(el, type, method);
		}
	},

	/*
	  Execute a JavaScript call.  Checks if Class exists and loads the
	  file if necessary.  After check (and/or load) comes the execution
	 */
	callStack: {},
	call: function (call) {
		return;
		var info = call.split("."), 
			args = YAHOO.Dashboard.getArray(arguments).slice(1),
			classname = info[0] || null,
			method    = info[1] || "",
			callStack = YAHOO.Dashboard.callStack;
			
		callStack[classname] = callStack[classname]||[];
		
		callStack[classname].push({method: method, args: args});
			
		Get.script( 
			"/js/modules/"+classname+".js", {
				onSuccess: function () {
					flushStack(classname);
				}
			});
		
		return this;
		
		function flushStack (name) {
			var stack = YAHOO.Dashboard.callStack[name];
			
			if (!YAHOO.Dashboard[name]) {
				return YAHOO.Dashboard.delay(400, flushStack, name);
			}
			
			while (stack && stack.length > 0) {
				var call = stack.shift();
				
				YAHOO.Dashboard[name][call.method].apply(YAHOO.Dashboard[name][call.method], call.args);
			}
		};
	}
});

/* create nickname for dashboard */
window.$D = window.dash = window.dash = window.dashboard = window.Dashboard = YAHOO.Dashboard;

})();
(function(){

/*
  Module that manipulates and maintains the DOM.  Gives ability to quickly
  manipulate via chaining and easy selector use.  Also minor XPath support.
 */
dashboard.dom = function () {
    var dash = dashboard;
    
    /*
      replaceHtml originally from http://blog.stevenlevithan.com/archives/faster-than-innerhtml 
     */
    var replaceHtml = function () {
        if (YAHOO.env.ua.ie > 0) {
            return function (node, html) {
                var oldEl = typeof node === "string" ? document.getElementById(node) : node;
                
                oldEl.innerHTML = html;
                return oldEl;
            }
        }
        
        return function (node, html) {
            var oldEl = typeof node === "string" ? document.getElementById(node) : node;
            
            var newEl = oldEl.cloneNode(false);
            newEl.innerHTML = html;
            oldEl.parentNode.replaceChild(newEl, oldEl);
            
            // Since we just removed the old element from the DOM, return a reference
            // to the new element, which can be used to restore variable references. 
            return newEl;
        }
    }();
    
    /*
      Evaluate JavaScript from HTML
     */
    var evalScript = function (data, container) {
        data = YAHOO.Dashboard.trim(data);
		
        if ( data ) {
            var head = document.getElementsByTagName("head")[0],
				script = DOM.create("script", {
					type: "text/javascript"
				});

            if ( YAHOO.env.ua.ie > 0 ) {
                script.text = data;
            }
            else {
                script.appendChild( document.createTextNode( data ) );
            }
            
            head.appendChild( script );
            
            try {
                head.removeChild( script );
            }
            catch (e) {
            }
        }  
    };
    
    /*
      Finds Script tags in node and evaluates them
     */
    var evalNode = function( node ) {
         var scripts = node.getElementsByTagName("script");
         
         YAHOO.Dashboard.forEach(scripts, function (el) {
             var script = jQuery.nodeName(el, "SCRIPT");
             
             if ( script ) {
                 if ( el.src ) {
                     Get.script( el.src );
                 }
                 else {
                     evalScript( el.text || el.textContent || el.innerHTML || "" );
                 }
                 
                 if ( el.parentNode ) {
                     el.parentNode.removeChild(el);
                 }
             }
             else if ( el.nodeType == 1 ) {
                 evalNode(el);
             }
         });
    };

    var dom = {
        namespace: "dom",
        
        /*
          Faster than innerHTML data replacement
         */
        html: function (node, html, runScript) {
            if (html == undefined) {
                return node.innerHTML;
            }
			
            var el = replaceHtml(node, html);
            
			
            if ( runScript ) {
				YAHOO.util.Dom.getElementsBy(
					function (script) {
						if (script) {
							if (script.src) {
								YAHOO.util.Get.script(script.src);
							}
							else {
								evalScript(script.text || script.textContent || script.innerHTML || "");
							}
						}
						
						if (script.parentNode) {
							script.parentNode.removeChild(script);
						}
					}, "script", el);
            }
			
            return el;
        },
        
        /*
          Create a HTML element with optional attributes and parent container
         */
        create: function (type, attr, win) {
            var w = win || window, d=w.document, n=d.createElement(type);

            for (var i in attr) {
				switch(i) {
				case "html":
					n.innerHTML = attr.html;
					break;
					
				case "value":
					n.value = attr.value;
					break;
					
				case "id":
					n.id = attr.id;
					break;
					
				default:
					n.setAttribute(i, attr[i]);
					break;
				}
            }
    
            return n;
        },
        
        whenReady: function () {
            for(var i = 0; i < arguments.length; i++) {
                YAHOO.util.Event.addListener(document, "contentReady", arguments[i]);
            }
        },
        
        get: function () {
            return dash.element.prototype.init(Array.prototype.slice.call(arguments), document);
        },
        
        xpath: function(expr) {
            return dash.element.prototype.init(expr, document);
        },
        
        evalScript: function (data) {
            return evalScript(data);
        },
        evalScripts: function (ref) {
            evalNode(ref);
        }
    };
    
    dash.register(dom);
    
    return dom;
}();

dashboard.element = function (els, d) {
    return new dashboard.element.prototype.init(els,d);
};

dashboard.element.prototype = {
    init: function (selector, d) {
        var s = selector || document;
        
        if (s.nodeType) {
            this[0] = s;
            this.length = 1;
        }
        else if ( s.constructor == Array ) {
            this.length = 0;
            var that = this;
            
            dash.forEach(s, function(el) {
                if (typeof el == "string") {
                    el = document.getElementById(el);
                }
                
                if (el) {
                    Array.prototype.push.call(that, el);
                }
                else {
                    this.length = 0;
                    return this;
                }
            });
        }
        else if ( typeof s == "string" ) {
            this[0] = document.getElementById(s);
            this.length = 1;
        }
        
        return this;
    },
    
    size: function () {
        return this.length || 0;
    },

    each: function (fn) {
        dash.forEach(this, fn);
        
        return this;
    },
    
    xpath: function (expr, node) {
        var elements = [];
        
        this.each( function (el) {
            node = node||document;
            
            var els = document.evaluate(expr, node, null, 0, null);
            
            while (el = els.iterateNext()) {
                elements.push(el);
            }
        });
        
        return dashboard.element(elements, document);
    },
    
    attr: function (prop, val) {
        this.each( function(el) {
             el[prop] = val;
        });
        
        return this;
    },
    
    getStyle: function (x, prop) {
        if (x.currentStyle) {
            y = x.currentStyle[prop];
        }
        else if (window.getComputedStyle) {
            y = document.defaultView.getComputedStyle(x, null).getPropertyValue(prop);
        }
        
        return y;
    },
    
    setStyle: function (prop, val) {
        this.each( function(el) {
            el.style[prop] = val;
        });
        
        return this;
    },

    hide: function () {
        this.setStyle("display", "none");
        return this;
    },

    show: function () {
        this.setStyle("display", "");
        return this;
    },
    
    on: function (type, fn) {
        this.each( function(el) {
            dash.event.add(el, type, fn);
        });
        
        return this;
    },
    
    css: function (o) {
        for (var prop in o) {
            this.setStyle(prop, o[prop]);
        }
        
        return this;
    },
    
    toggleClass: function (className) {
        var regex = new RegExp("\s*" + className, "i");
        
        this.each( function(el) {
            if (el.className.match(regex)) {
                el.className = el.className.replace(regex, "");
            }
            else {
                el.className += " " + className;
            }
        });
        
        return this;
    },
    
    addClass: function (className) {
        this.each( function(el) {
            el.className += ' '+className;
        });
        
        return this;
    },
    
    removeClass: function (name) {
        var regex = new RegExp("\s*"+name+"\s*", "gi");
        
        this.each( function(el) {
            el.className = el.className.replace(regex, "");
        });
        
        regex = null;
        
        return this;
    },
    
    withTags: function () {
        var tags = [], args = Array.prototype.slice.call(arguments);
        
        this.each(function(w) {
            if (w && w.nodeType == 1) {
                for (var i = 0; i < args.length; i++) {
                    var els = w.getElementsByTagName(args[i]);
                    
                    for (var x = 0; x < els.length; x++) {
                       tags.push(els[x]);
                    }
                }
            }
        });
        
        return dashboard.element(tags, document);
    },
    
    find: function (id) {
        var elements = [];
        
        this.each( function(el) {
            var elm = el.getElementById(id);
            
            if ( elm ) {
                elements.push(elm);
            };
        });
        
        return dashboard.element(elements, document);
    },
    
    walkTo: function (name, direction) {
        var elements = [],
            name = name.toUpperCase() || null;
        
        this.each( function(el) {
            while ( next = el[direction == "forward" ? "nextSibling" : "previousSibling"] ) {
                if ( name && name != next.nodeName.toUpperCase() ) {
                    el = next;
                }
                else {
                    elements.push(next);
                    break;
                }
            }
        });
        
        return dashboard.element(elements, document);
    },
    
    next: function (name) { return this.walkTo(name, "forward") },
    prev: function (name) { return this.walkTo(name, "backwards") },
    
    end: function () {
        return this.parent || this;
    },
    
    parent: function (el) {
        var elements = [];
        
        this.each( function(el) {
            if ( el.parentNode ) {
                elements.push(el.parentNode);
            }
        });
        
        return dashboard.element(elements, document);
    },
    
    html: function (str) {
        var els = [];
        
        this.each( function (el) {
            els.push( dash.dom.html(el, str, true) );
        });
        
        return dashboard.element(els, document);
    },
    
    maxWidth: function () {
        var width = 0, dom = this;
        
        var recursive = function (el) {
            var max = Math.max(el.offsetWidth, el.scrollWidth, el.clientWidth, parseInt(dom.getStyle(el, "width")));
            
            if ( width < max ) {
                width = max;
            }
        };
        
        this.each(function (el) {
            if (el.nodeType != 1) {
                return;
            }
            
            recursive(el);
            
            if (el.getElementsByTagName) {
                var children = el.getElementsByTagName("*");
                
                for (var i = 0; i < children.length; i++) {
                    recursive(children[i]);
                }
            }
        });
        
        return width;
    },
    
    minWidth: function () {
        var width = null;
        
        var recursive = function (el) {
            if (el.nodeType != 1) {
                return;
            }
            
            if (el.childNodes && el.childNodes.length > 0) {
                dash.forEach(el.childNodes, recursive);
            }
            
            if ( el.offsetWidth && width > el.offsetWidth ) {
                width = el.offsetWidth;
            }
        };
        
        this.each(recursive);
        
        return width;
    },
    
    maxHeight: function () {
        var height = 0, dom = this;
        
        var recursive = function (el) {
            var max = Math.max(el.offsetHeight, el.scrollHeight, el.clientHeight, parseInt(dom.getStyle(el, "height")));
            
            if ( height < max ) {
                height = max;
            }
        };
        
        this.each(function (el) {
            if (el.nodeType != 1) {
                return;
            }
            
            recursive(el);
            
            if (el.getElementsByTagName) {
                var children = el.getElementsByTagName("*");
                
                for (var i = 0; i < children.length; i++) {
                    recursive(children[i]);
                }
            }
        });
        
        return height;
    }
};

dashboard.element.prototype.init.prototype = dashboard.element.prototype;

if ( DOM == undefined ) {
    var DOM = window.DOM = dashboard.dom;
}

window.Dom = {};
YAHOO.lang.augmentObject(Dom, YAHOO.util.Dom);

Dom.html = DOM.html;

Dom.toggleClass = function (el, className) {
	Dom.batch(el, function (n) {
		if (Dom.hasClass(n, className))
			Dom.removeClass(n, className);
		else
			Dom.addClass(n, className);
	});
};

Dom.evalNodes = function (el) {
	return DOM.evalScripts(el);
};

Dom._attrAliases = {
	className: 'class',
	html: 'innerHTML'
};

Dom.create = function (type, attr, win) {
	var w = win || window, d=w.document, n=d.createElement(type);

	for (var i in attr) {
		if (attr[i]) {
			n.setAttribute(Dom._attrAliases[i] || i, attr[i]);
		}
	}
	
	if (attr.html) {
		n.innerHTML = attr.html
	}

	return n;
};

})();
(function(){
	var Event = YAHOO.util.Event,
		Get = YAHOO.util.Get,
		YUI = YAHOO;
		
/*
  Display module that handles the entire UI of the page.  You can register and
  unregister panes on the page that will either update on command or based
  on a configuration interval.
 */
var Display = {
	KNOWN_EVENTS: {
		changeContent: "changeContentEvent"
	},
	
	KNOWN_MODULES: {},
	
	CUSTOM_EVENTS: {},
	
	beforeUpdateEvent: new YAHOO.util.CustomEvent("beforeUpdate"),
	changeContentEvent: new YAHOO.util.CustomEvent("changeContent"),
	
	addListener: function (pane, type, method, scope, override) {
		if ( !( type in this.KNOWN_EVENTS ) ) {
			throw new Error("Unknown type of event '"+type+"'");
		}
		
		if (typeof pane == "string") {
			pane = { id: pane };
		}
		
		var events = this.CUSTOM_EVENTS;
		
		events[pane.id] = events[pane.id] || {},
		events[pane.id][type] = events[pane.id][type] || new YUI.util.CustomEvent(type);
		
		events[pane.id][type].subscribe(method, scope, override);
	},
	
	addPane: function (el) {
		var pane = null;
		
		if (typeof el === "string") {
			var n = document.getElementById(el);
			
			if (n && n.getAttribute && n.getAttribute("ref") == "pane") {
				pane = new DisplayPane(n, {cache: n.id != 'content'});
			}
		}
		else if ( el && el.nodeType ) {
			pane = new DisplayPane(el, {cache: n.id != 'content'});
		}
		
		if (pane) {
			pane.render();
			pane.show(1);
			
			Display.KNOWN_MODULES[pane.id] = pane;
		}
		
		return pane;
	},
	
	update: function (data) {
		Display.beforeUpdateEvent.fire(data);
		
		if (data.url) {
			return Dashboard.reload(data.url, !!data.full_reload);
		}
		
		if (data.namespace) {
			document.body.id = data.namespace || "home";	
		}
		
		if (data.title) {
			document.title = data.title;
		}
		
		if (data.css) {
			Get.css("/css/load.php?f="+data.css);
		}
		
		var exec = (function (data) {
			var p = {left: true, content: true};
			
			for (id in p) {
				pane = Display.get(id);
				pane.render();
				
				if (pane) {
					pane.setBody(data[id]);
					pane.show();
					
					if (Display.CUSTOM_EVENTS[id] && Display.CUSTOM_EVENTS[id].changeContent) {
						Display.CUSTOM_EVENTS[id].changeContent.fire(data[id]);
					}
					else {
						pane.changeContentEvent.fire(data[id]);
					}
				}
			}
			
			Display.changeContentEvent.fire();
		});
		
		if (data.javascript) {
			var loader = YAHOO.util.Get.script("/js/load.php?f="+data.javascript, {
				onSuccess: function () {
					exec(data);
				},
				onFailure: function () {
					exec(data);
				}
			});
			
			
		}
		else {
			exec(data);
		}
	},
	
	get: function (name) {
		return Display.KNOWN_MODULES[name] || Display.addPane(name);
	}
};

var DisplayPane = function(){
	if (arguments.length) {
		this.init.apply(this, arguments);
	}
};

DisplayPane.prototype = {
	init: function (el, config) {
		this.element = el;
		this.cfg = config || {};
		this.cache = {};
		this.id = el.id;
		
		
		this._findComponents();
		
		this.changeContentEvent = new YAHOO.util.CustomEvent('changeContent');
	},
	
	_findComponents: function () {
		var el = this.element;
		
		var children = Dom.getChildren(el);
		
		for (var i = 0; i < children.length; i++) {
			var child = children[i];
			
			if (Dom.hasClass(child, 'hd')) {
				this.header = child;
			}
			else if (Dom.hasClass(child, 'bd')) {
				this.body = child;
			}
		}
	},
	
	render: function () {
		
	},
	
	show: function (d) {
		var a = d ? 'display' : 'visibility',
			v = d ? 'block'   : 'visible';
		
		Dom.setStyle(this.element, a, v);
	},
	
	hide: function (d) {
		var a = d ? 'display' : 'visibility',
			v = d ? 'none'    : 'hidden';
		
		Dom.setStyle(this.element, a, v);
	},
	
	setBody: function (html) {
		if (this.cfg.cache) {
			if (this.cache.html == html) {
				return;
			}
			
			this.cache.html = html;
		}
		
		this._findComponents();
		
		this.body = DOM.html(this.body, html, true);
		
		this.changeContentEvent.fire(html);
	}
};

YAHOO.Dashboard.Display = Display;

})();
(function(){
	
	var Panel = YAHOO.widget.Panel,
		Connect = YAHOO.util.Connect,
		JSON = YAHOO.lang.JSON,
		current = null, /* Lightbox panel that is currently active */
		manager = new YAHOO.widget.OverlayManager(),
		guid = 1,
		connection = null,
		defaults = {
			url: false,
			size: {
				width: null, // auto
				height: null // auto
			}
		};
		
function setElementsVisibility(show) {
	var tags = [ "embed", "select" ];
	
	for (var i = 0; i < tags.length; i++) {
		Dom.getElementsBy(
			function (el) {
				if (!el.oldStyle) {
					el.oldStyle = Dom.getStyle(el, "display");
				}
				
				Dom.setStyle(el, "display", 
					show === false && el.oldStyle != "none" ?
					"none" : el.oldStyle || "block");
			}, tags[i]);
	}
}

var Lightbox = function (options) {
	this.options = YAHOO.lang.merge(defaults, options);
	
	this.panel = new Panel("lightbox_"+(++guid), {
			close: true,
			visible: false,
			draggable: true,
			modal: true,
			width: this.options.size.width,
			height: this.options.size.height
		});
	
	if (this.options.title) {
		this.panel.setHeader(this.options.title);
	}
	
	this.panel.setBody(" ");
	this.panel.render(document.body);
	
	this.panel.hideEvent.subscribe(this.hide, this, true);
	
	if (!manager.getActive()) {
		setElementsVisibility(false);
	}
	
	manager.register(this.panel);
	
	current = this.panel;
	
	this.panel.setBody(this.options.loadingText || " ");
	this.panel.center();
	
	
	if (this.options.url) {
		this.load(this.options.url);
		return;
	}
	
	if (this.options.content) {
		this.panel.setBody(this.options.content);
		this.panel.show();
		this.panel.center();
		return;
	}
}

Lightbox.prototype = {
	load: function (url) {
		if (this.connection) {
			this.abort();
		}
		
		var that = this;
		
		try {
			this.connection = Connect.asyncRequest("GET", url, {
					success: function (o) {
						var text = o.responseText,
							json = {};
							
						try {
							json = JSON.parse(text);
						}
						catch (e) {
							json.content = text;
						}
						
						that.panel.setBody(json.content);
						that.panel.show();
						that.panel.center();
					}
				});
		}
		catch (e) {
			if (url.match(/\.(jpg|gif|png|jpeg|tiff|bmp)$/i)) {
				that.panel.setBody(" ");
				
				var img = new Image();
				img.src = url;
				
				that.panel.appendToBody(img);
				that.panel.show();
				that.panel.center();
			}
		}
	},
	
	abort: function () {
		if (this.connection) {
			Connect.abort(this.connection);
			this.connection = null;
		}
	},
	
	hide: function () {
		this.panel.setBody(" ");
		
		current = manager.getActive();
		
		if (!!!current) {
			setElementsVisibility(true);
		}
	}
};

Lightbox.show = function (options) {
		
	return new Lightbox(options);
};
	
Lightbox.load = function (url) {
	if (current) {
		current.load(url);
	}
};
	
Lightbox.setBody = function (html) {
	current.setBody(html);
	current.show();
};
	
Lightbox.close = function () {
	current.hide();
};
	
Lightbox.abort = function () {
	if (connection) {
		Connect.abort(connection);
		connection = null;
	}
};
	
Lightbox.hide = function () {
	current.setBody(" ");
	
	current = manager.getActive();
	
	if (!!!current) {
		setElementsVisibility(true);
	}
};

window.Lightbox = window.lightbox = window.light = Dashboard.Lightbox = Lightbox;
		
})();
(function(){

var YUI = YAHOO,
	Connect = YUI.util.Connect,
	Dashboard = YUI.Dashboard,
	Dom = YUI.util.Dom,
	Event = YUI.util.Event,
	threads = {},
	uploadWindows = {};
	
function submitForm(form) {
	var method = form.getAttribute('method') || 'GET',
		action = form.getAttribute('action'),
		files  = Dom.getElementsBy(
			function (el) {
				return el.type === "file" && el.value > "";
			}, "input", form);
		
	/* kill any current requests for this form */
	Form.stop(form);
	
	YAHOO.util.Form.GLOBAL_CALLBACKS[form.id] = function(o) {
		var json = {
			argument: [form],
			json: o
		};
		
		requestComplete(json);
	};
	
	if (form.callback) {
		form.callback.value = "YAHOO.util.Form.GLOBAL_CALLBACKS."+form.id;
	}
	
	form.working = true;
	
	toggleButtons(form, true);
	
	Connect.setForm(form, files.length > 0 || form._jsonp);
	threads[form.id] = Connect.asyncRequest(method, action, {
		argument: [form],
		success: requestComplete,
		upload: requestComplete
	});
	
	if (files.length > 0) {
		var status = new UploadMonitor(form);
		
		uploadWindows[form.id] = status;
	}
};

function toggleButtons(form, showhide) {
	Dom.getElementsBy(
		function (el) {
			if (el.type == "submit") {
				el.disabled = showhide;
			}
		}, "button", form);	
};
	
function requestComplete(o) {
	var form = o.argument[0],
		text = o.responseText,
		json = o.json || {};
	
	toggleButtons(form, false);
		
	if (uploadWindows[form.id]) {
		uploadWindows[form.id].close();
		delete uploadWindows[form.id];
	}
		
	if (!Dom.inDocument(form)) {
		return;
	}
		
	if (o.responseText > "") {
		try {
			json = YAHOO.lang.JSON.parse(text);
		}
		catch (e) {
			json.content = text;
		}
	}
	delete threads[form.id];
	form.working = false;
	
	Form.fire('requestComplete', form, json);
};

function UploadMonitor(form) {
	this.form = form;
	this.fns = [];
	this.id = form.id;
	
	this.data = {
		percentage: 0,
		bytes_total: 0,
		bytes_uploaded: 0,
		est_sec: 0,
		speed_average: 0,
		files_uploaded: 0
	};
	
	this.panel = new YAHOO.widget.Panel(form.id+'_upload_monitor', {
			draggable: true,
			close: true,
			modal: false,
			visible: false,
			constraintoviewport: true
		});
	
	this.panel.hideEvent.subscribe(this.close, this, true);
	this.panel.setBody(" ");
	this.panel.setHeader(" ");
	this.panel.render(document.body);
	
	var that = this;
	this.connection = Connect.asyncRequest("GET", "/status/uploadBox", {
			success: function (o) {
				var text = o.responseText,
					json = {};
				
				try {
					json.content = YAHOO.lang.JSON.parse(text);
				}
				catch(e) {
					json.content = text;
				}
				
				that.panel.setHeader("Uploading...");
				that.panel.setBody(json.content);
				that.panel.render();
				that.panel.show();
				
				for ( var i = 0; i < that.fns.length; i++) {
					if (that.fns[i]) {
						try {
							YAHOO.lang.later(0, that.fns[i], that.fns[i]);
						}
						catch(e) {
						}
					}
				};
				
				that.fns = [];
				
				that.timer = YAHOO.lang.later( 1000, that, 'update', [], true );
			}
		});
}

UploadMonitor.prototype = {
	update: function () {
		if (!this.thread) {
			this.check();
		}
		
		var data = this.data;
		
		var els = {
			percentage: document.getElementById('percentage'),
			bytes_total: document.getElementById('bytes_total'),
			bytes_uploaded: document.getElementById('bytes_uploaded'),
			est_sec: document.getElementById('est_sec'),
			speed_average: document.getElementById('speed_average'),
			files_uploaded: document.getElementById('files_uploaded')
		};
		
		try {
			els.percentage.style.width   = data.percentage + "%";
			els.bytes_uploaded.innerHTML = data.bytes_uploaded;
			els.bytes_total.innerHTML    = data.bytes_total;
			els.est_sec.innerHTML        = data.est_sec;
			els.speed_average.innerHTML  = data.speed_average;
			els.files_uploaded.innerHTML = data.files_uploaded;
		}
		catch(e) {
			
		}
	},
	
	check: function () {
		this.uid = this.uid || this.form.UPLOAD_IDENTIFIER.value;
		
		if (this.thread) {
			return;
		}
		
		if (YAHOO.util.Connect.isCallInProgress(threads[this.id])) {
			var that = this;
			
			this.thread = Connect.asyncRequest("GET", "/status/upload/uid="+this.uid, {
					success: function (o) {
						that.thread = null;
						
						var text = o.responseText,
							json = o.json || {};
							
						if (o.responseText > "") {
							try {
								json = YAHOO.lang.JSON.parse(text);
							}
							catch (e) {
								return;
							}
						}
						
						that.data = {
							percentage: that.data.percentage > json.percentage ? 100 : json.percentage,
							bytes_total: Math.max(that.data.bytes_total, json.bytes_total) || 0,
							bytes_uploaded: Math.max(that.data.bytes_uploaded, json.bytes_uploaded) || 0,
							est_sec: json.est_sec || that.data.est_sec,
							speed_average: json.speed_average || that.data.speed_average,
							files_uploaded: json.files_uploaded || that.data.files_uploaded
						};
					}
				});
		}
		else {
			console.info("Upload failed?");
			this.close();
		}
	},
	
	ready: function (fn) {
		this.fns.push(fn);
	},
	
	abort: function () {
		
	},
	
	close: function () {
		console.info("Hide uploader");
		
		if (this.connection) {
			Connect.abort(this.connection);
			this.connection = null;
		}
		
		if (this.timer) {
			this.timer.cancel();
		}
		
		this.panel.hide();
	}
};
		
var Form = {
	KNOWN_EVENTS: {
		validateStart: "onValidationStart",
		validateSuccess: "onValidated",
		validateFailed: "onValidationFailed",
		submit: "onSubmit",
		requestComplete: "onRequestComplete"
	},
	
	GLOBAL_CALLBACKS: {},
	
	CUSTOM_EVENTS: {},
	
	validateStartEvent: new YUI.util.CustomEvent("validateStart", this),
	validateSuccessEvent: new YUI.util.CustomEvent("validateSuccess", this),
	validateFailedEvent: new YUI.util.CustomEvent("validateFailed", this),
	submitEvent: new YUI.util.CustomEvent("submit", this),
	requestCompleteEvent: new YUI.util.CustomEvent("requestComplete", this),
	
	validator: null,
	
	addListener: function (form, type, method, scope, override) {
		if ( !( type in this.KNOWN_EVENTS ) ) {
			throw new Error("Unknown type of event '"+type+"'");
		}
		
		if (typeof form == 'string') {
			throw new Error("Unknown form '"+form+"'");
		}
		
		if (!form.id) {
			form.id = Dom.generateId(form);
		}
		
		form.guid = form.id;
		
		var events = this.CUSTOM_EVENTS;
		
		events[form.guid] = events[form.guid] || {},
		events[form.guid][type] = events[form.guid][type] || new YUI.util.CustomEvent(type);
		
		events[form.guid][type].subscribe(method, scope, override);
	},
	
	removeListener: function (form, type, method) {
		if ( !form.guid || !(type in this.KNOWN_EVENTS) || !method ||
			 !this.CUSTOM_EVENTS[form.guid] || !this.CUSTOM_EVENTS[form.guid][type]) {
			return;
		}
		
		this.CUSTOM_EVENTS[form.guid][type].unsubscribe(method);
	},
	
	purgeListener: function (form, type) {
		if ( this.CUSTOM_EVENTS[form.id] &&
			 this.CUSTOM_EVENTS[form.id][type] ) {
			delete this.CUSTOM_EVENTS[form.id][type];
			this.CUSTOM_EVENTS[form.id][type] = new YUI.util.CustomEvent(type);
		}
	},
	
	fire: function (type, form) {
		var event = this._getEventList(form, type);
		
		if (event) {
			return event.fire.apply(event, Array.prototype.slice.call(arguments, 1));
		}
		
		return;
	},
	
	stop: function (form) {
		if (threads[form]) {
			try {
				Connect.abort(threads[form.id]);
			}
			catch (e) {
				
			}
			
			delete threads[form.id];
		}
	},
	
	_getEventList: function (form, type) {
		if ( form.id && this.CUSTOM_EVENTS[form.id] && 
			 this.CUSTOM_EVENTS[form.id][type]) {
			return this.CUSTOM_EVENTS[form.id][type];
		}
		
		if ( this[type+"Event"] ) {
			return this[type+"Event"];
		}
		
		return false;
	},
	
	_isFormField: function (el) {
		return el.tagName.match(/INPUT|BUTTON|SELECT|TEXTAREA/i);
	},
	
	submit: function (form) {
		// notify of validation starting
		this.fire("validateStart", form);
		
		// notify of validation result
		if ( YUI.lang.isFunction(this.validator) &&
			 this.validator.call(this.validator, form) === true ) {
			this.fire("validateSuccess", form);
		
			// notify of form submission
			if ( this.fire("submit", form) !== false ) {
				submitForm(form);
			}
			else {
				console.info("Failed submitting", form);
			}
		}
		else {
			this.fire("validateFailed", form);
		}
		
		return false;
	},
	
	clickHandler: function (evt) {
		var target = Event.getTarget(evt),
			form = target.tagName == "FORM" ? target : target.form || target.parentNode.form;
			
		Form.hijack(form);
	},
	
	hijack: function (form) {
		if (form && form.tagName == 'FORM' && form.$hijacked !== true) {
			form._onsubmit = form.onsubmit || function () {return false;};
			form.onsubmit = function (e) {
				if (form.working == true) {
					return form._onsubmit(e);
				}
				
				if (Form.submit(form)) {
					return form._onsubmit(e);
				}
				
				return false;
			};
			form._submit = form.submit || function(){return false;};
			form.submit = function (e) {
				if (form.working == true) {
					return form._submit(e);
				}
				
				if (Form.submit(form)) {
					return form._submit(e);
				}
				
				return false;
			};
			form.$hijacked = true;
			
			if (form.getAttribute('onsuccess') > "") {
				var fn = new Function('type', 'args', 'var result = args[0];'+form.getAttribute('onsuccess'));
				
				Form.addListener(form, 'requestComplete', fn, form, true);
			}
		}
	},
	
	verifySubmit: function (evt) {
		var form = Event.getTarget(evt);
		
		Event.stopEvent(evt);
		
		var result = Form.submit(form);
		
		if (form.onsubmit && YAHOO.lang.isFunction(form.submit)) {
			return;
		}
		
		return false;
	}
};

YAHOO.util.Form = Form;

Event.addListener(document, "click", Form.clickHandler);
Event.addListener(document, "submit", Form.clickHandler);

Form.requestCompleteEvent.subscribe(function(type, args) {
		YAHOO.Dashboard.Display.update(args[1]);
	});

var ValidateForm = function (form) {
	if (arguments.length === ValidateForm.length) {
		var f = new ValidateForm();
		
		return f.exec(form);
	}
};

ValidateForm.prototype = {
	checkFile: function (field) {
		var accept = field.getAttribute("accept")+"";
		
		if (accept.length > 0 && accept != 'null') {
			if (! field.fileTypes) {
				field.fileTypes = new RegExp("\.(" + accept.replace(/\s*,\s*/g,"|") + ")$", "i");
			}
			
			if (field.fileTypes && ! value.match(field.fileTypes)) {
				return false;
			}
		}
		
		return true;
	},
	
	checkField: function (field) {
		var r = true;
		
		// don't validate hidden fields
		if (field.type == "hidden") {
			return r;
		}
		
		if (field.type == "file" && true !== this.checkFile(field)) {
			r = "contains an invalid file type";
		}
		
		if (field.getAttribute("required") == "true" && !/.+/.test(field.value)) {
			r = "is a required field";
		}
		
		if (field.type == "file" && /.+/.test(field.value)) {
			this.hasFiles = true;
		}
		
		return r;
	},
	
	showErrorMessage: function (form, err) {
		var errmsg = document.createElement("div"),
			errs = document.createElement("ul");
		
		errmsg.className = "error-message formvalidator_result_failed";
		errmsg.appendChild(document.createTextNode("Please review the following errors"));
		
		Dom.removeClass(Dom.getElementsByClassName("required", "li", form), 'required');
		
		for (var i = 0; i < err.length; i++) {
			var e = err[i],
				row = this._getFieldsRow(e.el);
			
			// find the row label and get basic info (eg. name)
			var lbl = row.getElementsByTagName("label")[0],
				fname = lbl.textContent || lbl.innerText;
				
			// mark the row and add to err list
			row.className += " required";
			
			var li = document.createElement("li"),
				n = document.createElement("em");
			
			n.appendChild(document.createTextNode(fname));
			li.appendChild(n);
			li.appendChild(document.createTextNode(e.msg));
			
			errs.appendChild(li);
		}
		
		errmsg.appendChild(errs);
		
		var oldErrors = YAHOO.util.Dom.getElementsByClassName("formvalidator_result_failed");
		if (oldErrors.length > 0) {
			form.replaceChild(errmsg, oldErrors[0]);
		}
		else {
			form.insertBefore(errmsg, form.firstChild);
		}
		
		Dom.get(errmsg).scrollIntoView();
		
		form.normalize();
	},
	
	_getFieldsRow: function (f, type) {
		var s = new RegExp(type || "li", "i");
		
		while (f = f.parentNode) {
			if (f.nodeName.match(s)) {
				return f;
			}
		}
		
		return false;
	},
	
	exec: function (form) {
		var valid  = true,
			fields = form.elements,
			err = [];
			
		for (var i = 0; i < fields.length; i++) {
			var f = fields[i];
			
			if (f.nodeName == "LI") {
				f.className = "";
			}
			
			if (f.className == "error-message" && f.nodeName.match(/DIV/i)) {
				f.parentNode.removeChild(f);
			}
			
			if (f.nodeName.match(/INPUT|TEXTAREA|SELECT/i)) {
				var r = this.checkField(f);
				
				if (true !== r) {
					err.push({
						el: f,
						msg: r+""
					});
				}
			}
		}
		if (err.length > 0) {
			this.showErrorMessage(form, err);
			valid = false;
		}
		
		return valid;
	}
};


YAHOO.register("Form", YAHOO.util.Form, {version: "0.1", build: "1"});

YAHOO.util.Form.validator = ValidateForm;

window.Form = YAHOO.util.Form;

})();
(function(){
		
    var Dom = YAHOO.util.Dom,
        Event = YAHOO.util.Event;
	
var Content = {
	init: function (options) {
        if (!window.FCKeditor) {
            return;
        }
		
        var textarea = document.getElementById(options.id);
        
        if ( textarea.getAttribute("ref") == "wysiwyg" ) {
            return;
        }
        
        textarea.setAttribute("ref", "wysiwyg");
        
        var editor = new FCKeditor(options.id) ;
        
        editor.BasePath = "/js/fckeditor/";
        
        editor.Width = "100%";
        editor.Height = "400px";
        
        editor.Config["EditorAreaCSS"] = options.css;
        editor.Config["BaseHref"] = options.href || "";
        
        editor.ReplaceTextarea();
	}
};

Dashboard.Content = Content;

})();
(function(){
var Dashboard = YAHOO.Dashboard,
	Event = YAHOO.util.Event,
	CustomEvent = YAHOO.util.CustomEvent,
	Connect = YAHOO.util.Connect,
	JSON = YAHOO.lang.JSON,
	Dom = YAHOO.util.Dom;

/* =history
  Wrapper for ReallySimpleHistory library.  Just contains basic methods
  to make messing with RSH easier
 */
 
var History = function () {
	var _historyFrame = null,
		_historyFrameID = "historyFrame",
		
		_historyImage = null,
		_historyImageID = 'historyImage',
		
		_historyCallback = new Function(),
		
		_historyStack = [],
		
		_modules = {},
		
		_waitTime = 40,
		_lastHash = false,
		_lastFullHash = false,
		
		_initialized = false,
		
		_isIE = /*@cc_on!@*/false,
		_timer = null,
		
		_events = {
			hashChanged: new CustomEvent("hashChange"),
			dataChanged: new CustomEvent("dataChange")
		};
		
	Event.addListener(window, 'unload', function(){
			if (_timer) {
				_timer.cancel();
				_timer = null;
			}
		});
		
	function checkHash() {
		var o = getState(),
			hash = getHash();
			
		if ( _lastHash != o.hash ) {
			if (checkHash.fire !== false) {
				_events.hashChanged.fire(o.hash, o.data);
			}
			
			checkHash.fire = true;
		
			_lastHash = o.hash;
		}
		else if ( hash != _lastFullHash ) {
			console.info("Data changed");
			_events.dataChanged.fire(o.hash, o.data);
		}
		
		_lastFullHash = hash;
		
		_timer = YAHOO.lang.later(_waitTime, this, checkHash);
	};
	
	function getState() {
		var location = top.location.href+"", data = {};
		
		var s = location.indexOf("#");
			
		data.hash = s >= 0 ? location.substr(s + 1) : "";
		
		var d = data.hash.indexOf("|");
		
		if ( d >= 0 ) {
			data.data = unescape(data.hash.substr(d + 1));
			data.hash = data.hash.substr(0, d);
		}
		
		return data;
	};
	
	function getHash() {
		var i, href;
		
		href = top.location.href;
		i = href.indexOf("#");
		
		return i >= 0 ? href.substr(i + 1) : "";
	};
	
	var addHash = function(hash) {
		if (_isIE) {
			return function(hash) {
				document.getElementById(_historyFrameID).src = '/js/caprica/blank.html?h='+hash;
			}
		}
		else {
			return function(hash) {
				window.location.hash = hash;
			}
		}
	}();
	
	return {
		cfg: {
			forceHashURL: true,
			URLSeperator: '|'
		},
		
		dataChangeEvent: _events.dataChanged,
		
		navigate: function (hash, quiet) {
			if (hash == _lastHash) {
				_lastHash = null;
			}
			
			if (quiet === true) {
				_lastHash = hash;
			}
			
			addHash(hash);
		},
		
		addData: function (data) {
			if (typeof data != 'string') {
				data = JSON.stringify(data);
			}
			var o = getState();
			
			addHash(o.hash + History.cfg.URLSeperator + data);
		},
		
		register: function (name, method, state) {
			_events.hashChanged.subscribe(
				function () {
					console.info("target state", state);
					method.apply(method, arguments);
				});
			
			_modules[name] = {
				fn: method,
				state: state,
				name: name
			};
		},
		
		unregister: function (name) {
			
		},
		
		iframeLoaded: function (location) {
			window.location.hash = (location+"").split('?h=')[1]+"";
		},
		
		initialize: function () {
			if (_initialized) {
				// History has already been initialized
				return;
			}
			
			_historyFrame = document.getElementById(_historyFrameID);
			_historyImage = document.getElementById(_historyImageID);
			
			if (_historyImage) {
				if (!!!window.opera) {
					_historyImage.parentNode.removeChild(_historyImage);
				}
				else {
					_historyImage.src = "javascript:location.href='javascript:Dashboard.History.__checkHistory();';";
				}
			}
			
			checkHash();
			
			_initialized = true;
		},
		
		/*
		  Get the current hash/location
		 */
		getHash: function () {
			var i, href;
			
			href = top.location.href;
			i = href.indexOf("#");
			
			return i >= 0 ? href.substr(i + 1) : "";
		},
		
		getCurrentData: function () {
			return this.getCurrentState().data;
		},
		
		getCurrentState: function () {
			var state = getState();
			
			if (state.data && typeof state.data == 'string') {
				try {
					state.data = YAHOO.lang.JSON.parse(state.data);
				}
				catch(e) {
					state.data = {};
				}
			}
			
			return state;
		},
		
		/** private method used for Opera history checking **/
		__checkHistory: function () {
			checkHash();
		}
	};
}();

YAHOO.Dashboard.History = History;

})();
(function(){
	var Dashboard = YAHOO.Dashboard,
		Connect = YAHOO.util.Connect,
		History = Dashboard.History,
		Event = YAHOO.util.Event;
		
/* =navigation
  Module that provides all navigation methods.  Works with the history module
  to make a completely unobtrusive navigating experience.  Take this out and
  the entire site will work without Ajax.
 */
var Browser = function () {
	var thread = null,
		last_call = {
			location: ""
		},
		_initialized = false;
	
	Connect.initHeader("X-Requested-Response", "json", true);
	
	Connect.startEvent.subscribe(function(){
			Dom.setStyle("status_bar", "visibility", "visible");
		});
	Connect.completeEvent.subscribe(function(){
			Dom.setStyle("status_bar", "visibility", "hidden");
		});
		
    return {
		cfg: {
			forceHashURL: true,
			
			callback: {
				customevents: {
					onSuccess: function (ev, args) {
						var str = args[0].responseText, 
							json = {};
						
						try {
							json = YAHOO.lang.JSON.parse(str);
						}
						catch (e) {
							json.content = str;
						}
						
						Dashboard.Display.update(json);
						
						thread = null;
					},
					
					onAbort: function () {
						console.info("Killed request");
					}
				}
			}
		},
		
		/*
		  Event handler to capture links.  Allows entire page to be tagged only 
		  once with this handler and all children anchors will be tracked.  This 
		  means you don't need to set this handler every time the DOM is updated.
		 */
		intercept: function (e) {
			var link = Dom.get(Event.getTarget(e));
			
			if (link.tagName == "IMG") {
				link = link.parentNode;
			}
			
			if (link.tagName != "A") {
				return true;
			}
			
			// link is external
			if (link.hostname != location.hostname || link.className.match(/download/i)) {
				return true;
			}
			
			 // link is a hash
			if ( (link.hash != "" && link.hash != "#") || 
				 
				 // link has a different onclick event
				 typeof link.onclick == 'function' || 
				 String(link.onclick).match(/return fals/i)) {
			
				return false;
			}
			
			if (link.href.charAt(link.href.length-1) == "#") {
				return false;
			}
			
			Event.stopEvent(e);
			
			var h = link.pathname;
	
			History.navigate( h.substring(0,1) != "/" ? "/"+h : h );
			
			return false;
		},
		
		go: function (type, args) {
			var location = args[0],
				data = args[1],
				isEmpty = true;
			
			for (var i in data) {
				isEmpty = false;
			}
			
			if (location == undefined) {
				return;
			}
				
			if (thread) {
				try {
					Connect.abort(thread);
					thread = null;
				}
				catch(e) {
				}
			}
			
			Dashboard.Display.get("content").body.innerHTML = "Loading...";
			
			thread = Connect.asyncRequest("GET", location, Browser.cfg.callback);
		},
		
		init: function () {
			if (_initialized == true) {
				return true;
			}
			
			History.register('Browser', Browser.go);
			
			Event.addListener(document, "click", Browser.intercept, Browser, true);
			
			var o = History.getCurrentState();
			
			if ( Browser.cfg.forceHashURL === true && (o.hash == "" || o.hash == "#") && location.pathname != "/" ) {
				var l = document.location;
				
				top.location = location.protocol + "//" + 
							   location.hostname + "/#" + 
							   location.pathname;
				return;
			}
			
			History.initialize();
			
			if (o.hash == "") {
				History.navigate("/home");
			}
		}
	};
}();

Dashboard.Browser = Browser;

})();

Dashboard.Browser.init();
(function(){
var Event = YAHOO.util.Event,
	Display = YAHOO.Dashboard.Display,
	Form = YAHOO.util.Form,
	History = YAHOO.Dashboard.History,
	JSON = YAHOO.lang.JSON,
	thread = null,
	cached = {};


var List = {
	init: function () {
		var form = document.getElementById('manage_form'),
			select = Dom.get("filter_select");
		
		Form.hijack(form);
			
		Dom.getElementsBy(
			function (el) {
				if (el.htmlFor) {
					var id = el.parentNode.id;
					
					select.appendChild(
						DOM.create("option", {
							value: id,
							label: el.innerHTML,
							html: el.innerHTML
						}));
				}
			}, "label", "filters_available");
		
		select.normalize();
		
		cached = History.getCurrentState();
		
		cached.data = cached.data || {};
		
		if (cached.hash) {
			cached.hash.replace(/(^\/?.+?\/.+?\/|(.+?)=(.+?)&|(.+?)=(.+?)$)/g, function(f,s,a,v,la,lv) {
					
					if (la > "") {
						la = la.indexOf("[]") > 0 ? la : la + "[]";
						
						cached.data[la] = cached.data[la] || lv;
					}
					if (a > "") {
						a = a.indexOf("[]") > 0 ? a : a + "[]";
						
						cached.data[a] = cached.data[a] || v;
					}
			});
		}
		
		if (cached.data) {
			List.resetFilters(cached.data);
		}
		
		Event.addListener(select, "change", List.selectOnChange);
		
		Form.purgeListener(form, 'requestComplete');
		Form.addListener(form, "requestComplete", List.onRequestComplete);
		
		Form.purgeListener(form, 'submit');
		Form.addListener(form, "submit", List.onSubmit);
		
		if (Dom.get("current_filters").getElementsByTagName("li").length > 1) {
			Dom.removeClass('manage_form', 'hidden');
			Dom.addClass('toggle-filters', 'hidden');
		}
		
		form.submit();
	},
	
	exportCSV: function () {
		var form = document.getElementById("manage_form");
			
		var oldaction = form.action;
		form.action = form.action.replace("manage", "export");
		form.target = "_blank";
		if (form._submit) {
			form._submit();
		}
		else {
			form.submit();
		}
		
		form.action = oldaction;
		form.target = null;
	},
	
	onSubmit: function () {
		var form = document.getElementById('manage_form');
		
		Form.stop(form);
		
		YAHOO.Dashboard.History.addData(
			List.toJSONString());
		
		return true;
	},
	
	onRequestComplete: function (type, args) {
		var json = args[1];
		
		Dom.html('manage_list', json.content, true);
		
		return true;
	},
	
	onHistoryChange: function (evt, args) {
		var o = {
			state: args[0],
			data: args[1]
		};
		console.log(arguments);
		console.dir(cached);
		if (cached.hash != o.state) {
			return;
		}
		
		try {
			if (typeof o.data == 'string') {
				try {
					o.data = YAHOO.lang.JSON.parse(unescape(o.data));
				}
				catch (e) {
				}
			}
			
			var form = document.getElementById('manage_form'),
				submit = false;
			
			if (cached.data) {
				for (i in o.data) {
					if ( !( i in cached.data ) || cached.data[i] != o.data[i] ) {
						submit = true;
					}
				}
			}
			
			if (submit === true) {
				Form.stop(form);
				
				cached.data = o.data;
				
				List.resetFilters(o.data);
				
				Form.submit(form);
			}
		}
		catch (e) {
			console.dir(e);
		}
		
		return true;
	},
	
	resetFilters: function (filters) {
		List.removeAllFilters();
			
		for (name in filters) {
			if (name.indexOf("[]") != -1) {
				List.addFilter(name.replace("[]", ""), decodeURIComponent(filters[name]));
			}
		}
		
		if (filters.page) {
			Dom.get("page").value = filters.page;
		}
	},
	
	removeAllFilters: function () {
		var filters = Dom.get("current_filters"),
			items = filters.getElementsByTagName("li");
			
		for (var i = 1; i < items.length; i++) {
			filters.removeChild(items[i]);
		}
	},
	
	removeFilter: function (el) {
		var n = el;

		while ( n.tagName != 'LI' ) {
			n = n.parentNode;
		}
		
		n.parentNode.removeChild(n);
	},
	
	toPage: function (i) {
		Dom.get("page").value = i;
		
		document.getElementById("manage_form").submit();
	},
	
	toJSONString: function () {
		var data = {}, 
			form = Dom.get("manage_form");
		
		for (var i = 0; i < form.elements.length; i++) {
			var f = form.elements[i];
			
			if (f.name != "filters" && f.name && f.value > "") {
				data[f.name] = f.value;
			}
		}
		
		return JSON.stringify(data);
	},
	
	selectOnChange: function (e) {
		var t = Event.getTarget(e);
		
		List.addFilter(t.value);
		
		t.selectedIndex = 0;
	},
	
	addFilter: function (id, val) {
		var f = Dom.get(id);
		
		if (f) {
			var c = document.getElementById("current_filters"),
				currentfilters = c.getElementsByTagName("li"),
				li = document.createElement("li");
				
			if (currentfilters.length == 1) {
				currentfilters[0].style.display = "none";
			}
			
			li.innerHTML = f.innerHTML;
			
			c.appendChild(li);
			c.normalize();
			
			if (val) {
				Dom.getElementsBy(
					function (el) {
						if (el.tagName == "INPUT") {
							el.value = val;
							return;
						}
						
						if (el.tagName == "SELECT") {
							for (var i = 0; i < el.options.length; i++) {
								el.options[i].selected = el.options[i].value == val;
							};
							return;
						}
					}, "*", li);
			}
		}
	}
};

Display.addListener("content", "changeContent", function () {
		List.init();
	});

Dashboard.History.register('manage', List.onHistoryChange, "list");
Dashboard.History.dataChangeEvent.subscribe(List.onHistoryChange);

YAHOO.Dashboard.List = List;

})();
(function(){
		
var Event = YAHOO.util.Event,
	Dashboard = YAHOO.Dashboard;
	Display = Dashboard.Display,
	Anim = YAHOO.util.Anim;

var Menu = {
	activeItem: null,
	
	init: function () {
		Display.addListener('left', 'changeContent', Menu.initMenu);
	},
	
	initMenu: function () {
		var menu = document.getElementById('menu');
		
		if (menu.$listening !== true) {
			Event.addListener('menu', 'click', Menu.click);
		
			Menu.activeItem = Dom.getFirstChild('menu');
			
			Dom.addClass(Menu.activeItem, 'selected');
			
			menu.$listening = true;
		}
	},
	
	click: function (e) {
		var target = Dom.get(Event.getTarget(e));
		
		if (target.className == 'hd') {
			Menu.show(target.parentNode);
		}
	},
	
	show: function (item) {
		if ( Menu.activeItem == item ) {
			return;
		}
		
		if (Menu.activeItem) {
			Dom.removeClass(Menu.activeItem, 'selected');
		}
		
		Dom.addClass(item, 'selected');
		Menu.activeItem = item;
	}
};

YAHOO.Dashboard.Menu = Menu;

Menu.init();

})();
(function(){
		
var Graphs = {
	init: function () {
		Dashboard.Display.addListener('content', 'changeContent', Graphs.initGraph);
	},
	
	initGraph: function () {
		if (document.getElementById('flashchart')) {
			Graphs.setupDate();
			Graphs.refresh();
		}
	},
	
	refresh: function (format) {
		var str = "";
		
		$(".lines:checked").each(function () {
			str += "lines[]=" + $(this).val() + "&";
		});
		
		if ( $(".lines:checked").length == 0 ) {
			return alert("You need to have at least one graph type checked");
		};
		
		str += "start_date=" + $("#start_date").val() + "&";
		str += "end_date=" + $("#end_date").val() + "&";
		
		if ( format == "csv" ) {
			$("#flashchart").append(
				$("<iframe style='display:none;' src='/stats/reportData/?format=csv&_partial=true&"+str+"' />")
			);
		}
		else {
			YAHOO.Dashboard.Graphs.createChart({
				data: escape("/stats/reportData/_partial=true&"+str)	
			});
		};
	},
	
	setupDate: function () {
		var container = Dom.get('date_picker'),
			calendar = Dom.get('calendar'),
			start_date = Dom.get('start_date'),
			end_date = Dom.get('end_date');
			
		var startDate = new YAHOO.widget.Calendar("start_calendar", {
				MULTI_SELECT: false,
				maxdate: new Date()
			}),
		    endDate = new YAHOO.widget.Calendar("end_calendar", {
				MULTI_SELECT: false,
				maxdate: new Date()
			});
		
		endDate.select(
			end_date.value.substr(5,2) + "/" + end_date.value.substr(8) + "/" + end_date.value.substr(0,4));
		startDate.select(
			start_date.value.substr(5,2) + "/" + start_date.value.substr(8) + "/" + start_date.value.substr(0,4));
			
		startDate.selectEvent.subscribe(
			function(type,args,obj) {
				var dates = args[0];
				var date = dates[0];
				var year = date[0], month = date[1], day = date[2];
				
				date = startDate.toDate(date);
				date.setDate(date.getDate()+1);
				
				start_date.value = month + "/" + day + "/" + year;
				
				endDate.cfg.setProperty("mindate", date);
				endDate.render();
			});
			
		endDate.selectEvent.subscribe(
			function(type,args,obj) {
				var dates = args[0];
				var date = dates[0];
				var year = date[0], month = date[1], day = date[2];
				
				date = endDate.toDate(date);
				date.setDate(date.getDate()-1);
				
				end_date.value = month + "/" + day + "/" + year;
				
				startDate.cfg.setProperty("maxdate", date);
				startDate.render();
			});
		
		var date = new Date();
		
		date.setDate(endDate.getSelectedDates()[0].getDate() - 1);
		startDate.cfg.setProperty("maxdate", date);
		
		date = new Date();
		date.setDate(startDate.getSelectedDates()[0].getDate() + 1);
		endDate.cfg.setProperty("mindate", date);
		
		startDate.render();
		endDate.render();
	},
	
	createChart: function (options) {
		var color = Dom.getStyle(Dom.get('flashchart').parentNode, 'background-color');
		
		options = YAHOO.lang.merge({
			src: "/chart/charts.swf?bg="+color.replace('#','')+"&data=" + options.data,
			height: 200,
			width: "100%",
			id: "flash-chart"
		}, options );
		
		var so = new SWFObject(options.src, "ofc", options.width, options.height, "9");

		DOM.get("flashchart").html(so.getSWFHTML());
	}
};


YAHOO.Dashboard.Graphs = Graphs;
Graphs.init();

})();
(function(){
/**
 * SWFObject v1.5.1: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept == "undefined") var deconcept = {};
if(typeof deconcept.util == "undefined") deconcept.util = {};
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = {};
deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) {
	if (!document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = {};
	this.variables = {};
	this.attributes = [];
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if (!window.opera && document.all && this.installedVer.major > 7) {
		// only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
		// fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
		if (!deconcept.unloadSet) {
			deconcept.SWFObjectUtil.prepUnload = function() {
				__flash_unloadHandler = function(){};
				__flash_savedUnloadHandler = function(){};
				window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
			}
			window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
			deconcept.unloadSet = true;
		}
	}
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', false);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
	useExpressInstall: function(path) {
		this.xiSWFPath = !path ? "expressinstall.swf" : path;
		this.setAttribute('useExpressInstall', true);
	},
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name] || "";
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name] || "";
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = [];
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs[variablePairs.length] = key +"="+ variables[key];
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "PlugIn");
				this.setAttribute('swf', this.xiSWFPath);
			}
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ (this.getAttribute('style') || "") +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "ActiveX");
				this.setAttribute('swf', this.xiSWFPath);
			}
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ (this.getAttribute('style') || "") +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			// check to see if we need to do an express install
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			return true;
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
		}
		return false;
	}
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ // if Windows CE
		var axo = 1;
		var counter = 3;
		while(axo) {
			try {
				counter++;
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
//				document.write("player v: "+ counter);
				PlayerVersion = new deconcept.PlayerVersion([counter,0,0]);
			} catch (e) {
				axo = null;
			}
		}
	} else { // Win IE (non mobile)
		// do minor version lookup in IE, but avoid fp6 crashing issues
		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		}catch(e){
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
				PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
				axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
			} catch(e) {
				if (PlayerVersion.major == 6) {
					return PlayerVersion;
				}
			}
			try {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			} catch(e) {}
		}
		if (axo != null) {
			PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
	this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
	this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(param) {
		var q = document.location.search || document.location.hash;
		if (param == null) { return q; }
		if(q) {
			var pairs = q.substring(1).split("&");
			for (var i=0; i < pairs.length; i++) {
				if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
					return pairs[i].substring((pairs[i].indexOf("=")+1));
				}
			}
		}
		return "";
	}
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
	var objects = document.getElementsByTagName("OBJECT");
	for (var i = objects.length - 1; i >= 0; i--) {
		objects[i].style.display = 'none';
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = function(){};
			}
		}
	}
}
/* add document.getElementById if needed (mobile IE < 5) */
if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}

/* add some aliases for ease of use/backwards compatibility */
window.getQueryParamValue = deconcept.util.getRequestParameter;
window.FlashObject = deconcept.SWFObject; // for legacy support
window.SWFObject = deconcept.SWFObject;
})()
