///<reference path="jquery.intellisense.js" />
//<![CDATA[

/* Version 2.1.0
* Copyright (c) 2009 True Partners, LLC (wearetrue.com)
*
* 30 june 2009 14:10
* 
* requires jQuery 1.2
*/

if (window.Type == undefined) {
	Function.createDelegate = function(p_function, p_context) {
		return function() {
			if (arguments.length == 0) { p_function.apply(p_context); }
			else { return p_function.apply(p_context, arguments); } 
		} 
	}; Function.getTypeName = function(p_instance) { var cfn = p_instance.constructor; if (p_instance.constructor instanceof Function) { return p_instance.constructor.__typeName; } }; Function.getType = function(p_instance) {
		var cfn = p_instance.constructor; if (!cfn || (typeof (cfn) !== "function") || !cfn.__typeName || (cfn.__typeName === 'Object')) { return Object; }
		return cfn;
	}; Function.registerNamespace = function(p_name) {
		var t = window; var names = (p_name instanceof Array) ? p_name : p_name.split("."); for (var i = 0; i < names.length; i++) {
			if (!t[names[i]]) { t[names[i]] = {}; }
			t = t[names[i]];
		}
		return t;
	}; Function.prototype.register = function(p_typeName, p_baseType) {
		this.prototype.constructor = this; this.__typeName = p_typeName; if (p_baseType) { this.__baseType = p_baseType; this._prototyping = true; this._extendBase(); }
		if (!p_typeName || p_typeName == "") { throw new TrueException("InvalidParameter", "type name is required"); }
		var t = window; var names = p_typeName.split("."); var n = names.pop(); Function.registerNamespace(names); if (!t[n]) t[n] = this;
	}; Function.prototype.constructBase = function(p_instance, p_args) {
		if (this.__baseType) {
			if (!p_args) { this.__baseType.apply(p_instance); }
			else { this.__baseType.apply(p_instance, p_args); } 
		}
		return p_instance;
	}; Function.prototype.callBaseMethod = function(p_instance, p_name, p_args) {
		if (this.__baseType) {
			var method = this.__baseType.prototype[p_name]; if (method instanceof Function) {
				if (!p_args) { return method.apply(p_instance); }
				else { return method.apply(p_instance, p_args); } 
			} 
		} 
	}; Function.prototype._extendBase = function() {
		if (this._prototyping) {
			var baseType = this.__baseType; baseType._extendBase(); for (var p in baseType.prototype) { var v = baseType.prototype[p]; if (!this.prototype[p]) { this.prototype[p] = v; } }
			delete this._prototyping;
		} 
	}; Function.prototype.inheritsFrom = function Type$inheritsFrom(p_parentType) {
		var baseType = this.__baseType; while (baseType) {
			if (baseType === p_parentType) { return true; }
			baseType = baseType.__baseType;
		}
		return false;
	}; Function.prototype.isInstance = function(p_instance) { if (p_instance instanceof this) return true; var instanceType = Function.getType(p_instance); return (instanceType.inheritsFrom && instanceType.inheritsFrom(this)); }; var Type = window.Type = Function; if (!jQuery.ui) { var _remove = jQuery.fn.remove; jQuery.fn.remove = function() { $("*", this).add(this).trigger("remove"); return _remove.apply(this, arguments); }; }
	jQuery.getDeclaredTypes = function(p_el, p_prefix) {
		if (!p_el || !p_el.className) return []; var prefix = (p_prefix) ? p_prefix + "-" : ""; RegExp.lastIndex = 0; var re = new RegExp("(^|\\s)" + prefix + "(\\S*)", "g"); var r, c = p_el.className, results = []; while (r = re.exec(c)) {
			try { var type = eval(r[2]); if (typeof type == "function" && type.__typeName) { results.push(type); } }
			catch (err) { } 
		}
		return results;
	}; jQuery.fn.initTrueTypes = function(p_options) { var options = jQuery.extend({}, p_options); return this.each(function(p_i) { var types = jQuery.getDeclaredTypes(this, options.prefix); for (var i = 0; i < types.length; i++) { jQuery(this).attachTrueType({ type: types[i] }); } }); }; jQuery.fn.attachTrueType = function(p_options) {
		if (!p_options || !p_options.type || typeof (p_options.type) != "function") { return this; }
		return this.each(function(p_i) {
			if (!jQuery.data(this, "true.types")) { jQuery.data(this, "true.types", {}); }
			var tt = jQuery.data(this, "true.types"); if (!tt[p_options.type.__typeName]) { tt[p_options.type.__typeName] = p_options.instance || new p_options.type(this); } 
		});
	}; jQuery.fn.getTrueTypes = function(p_options) {
		var options = jQuery.extend({ typeName: "*" }, p_options); if (this.length == 1) { var tt = this.data("true.types"); if (tt) { return (options.typeName == "*") ? tt : tt[options.typeName]; } }
		return;
	}; jQuery.extend(jQuery.expr[":"], { trueType: function(a, i, m) {
		if (m[3]) { var tt = jQuery.data(a, "true.types"); return (tt && ((m[3] == "*") ? true : tt[m[3]] != undefined)); }
		return false;
	} 
	}); var True = Type.registerNamespace("True"); True.EventDispatcher = (function() {
		function __getHandlers(p_type) { this.__events = this.__events || {}; this.__events[p_type] = this.__events[p_type] || new Array(); return this.__events[p_type]; }; function __getHandlerIndex(p_type, p_handler, p_target) {
			var l = __getHandlers.apply(this, [p_type]); for (var i = 0; i < l.length; i++) { if (l[i].handler == p_handler && l[i].target == p_target) { return i; } }
			return -1;
		}; function __addHandler(p_type, p_hander, p_target) { if (p_type && p_hander) { var th = __getHandlers.apply(this, [p_type]); th.push({ handler: p_hander, target: p_target || window }); } }; function __add(p_type, p_hander, p_target) { if (__getHandlerIndex.apply(this, [p_type, p_hander, p_target]) == -1) { __addHandler.apply(this, [p_type, p_hander, p_target]); } }; function __remove(p_type, p_hander, p_target) { var i = __getHandlerIndex.apply(this, [p_type, p_hander, p_target || window]); if (i >= 0) { var h = __getHandlers.apply(this, [p_type]); h.splice(i, 1); } }; function __dispatch(p_type, p_args) {
			var h = __getHandlers.apply(this, [p_type]); if (p_args) { p_args.type = p_args.type || p_type; p_args.target = p_args.target || this }
			for (var i = 0; i < h.length; i++) { h[i].handler.apply(h[i].target, [p_args]); } 
		}; function __clear(p_type) { if (p_type == "*") this.__events = {}; else __getHandlers.apply(this, [p_type]) = []; }; function cfn() { }; cfn.__decorate = function(obj) { if (obj && !obj.addEventHandler) { obj.addEventHandler = __add; obj.removeEventHandler = __remove; obj.dispatchEvent = __dispatch; obj.clearEvent = __clear; } }; return cfn;
	})(); True.EventDispatcher.decorate = True.EventDispatcher.__decorate; True.EventDispatcher.register("True.EventDispatcher"); True.DOMUtil = function() { }; True.DOMUtil.getBounds = function(p_el) { var p = True.DOMUtil.getPosition(p_el); return { t: p.t, l: p.l, w: $.css(p_el, "width", true), h: $.css(p_el, "height", true) }; }; True.DOMUtil.getPosition = function(p_el) { return { t: $.css(p_el, "top", true), l: $.css(p_el, "left", true) }; }; True.DOMUtil.register("True.DOMUtil"); True.Template = function() { throw new Error('True.Template should not be instantiated.'); }; True.Template._cache = {}; True.Template.parse = function(p_str, p_data, p_log) {
		var err = ""; try {
			var func = True.Template._cache[p_str]; if (!func) {
				var strFunc = "var p=[],print=function(){p.push.apply(p,arguments);};" + "with(obj){p.push('" +
p_str.replace(/[\r\t\n]/g, " ").replace(/'(?=[^#]*#>)/g, "\t").split("'").join("\\'").split("\t").join("'").replace(/<#=(.+?)#>/g, "',$1,'").split("<#").join("');").split("#>").join("p.push('")
+ "');}return p.join('');"; if (p_log && console && console.log) { console.log(strFunc); }
				func = new Function("obj", strFunc); True.Template._cache[p_str] = func;
			}
			return func(p_data);
		} catch (e) { err = e.message; }
		return "< # ERROR: " + err + " # >";
	}; True.Template.register("True.Template"); True.AsyncIterator = function(p_array, p_function, p_options) { this.options = jQuery.extend({ chunkSize: 1, interval: 0, destructive: false }, p_options); this._array = p_array; this._function = p_function; this._currentIndex = (this.options.destructive) ? p_array.length - 1 : 0; this.canceled = false; }; True.AsyncIterator.prototype = { start: function() { this._process(); }, cancel: function() { this.canceled = true; }, _process: function() { setTimeout(Function.createDelegate(this._each, this), this.options.interval); }, _each: function() {
		var count = 0; while (!this.canceled && this._canAdvance() && count < this.options.chunkSize) { this._function(this._array[this._currentIndex], this._currentIndex, this); this._advance(); count++; }
		if (this.canceled && this.options.canceled) { this.options.canceled(this); }
		else if (this._isEnd() && this.options.complete) { this.options.complete(this); }
		else { this._process(); } 
	}, _isEnd: function() {
		if (this.options.destructive) { return this._array.length == 0; }
		else { return this._currentIndex >= this._array.length; } 
	}, _advance: function() { this._currentIndex = (this.options.destructive) ? this._currentIndex - 1 : this._currentIndex + 1; }, _canAdvance: function() {
		if (this.options.destructive) { return this._array.length > 0; }
		else { return this._currentIndex < this._array.length; } 
	} 
	}; True.AsyncIterator.register("True.AsyncIterator"); True.Behavior = (function() {
		function __rescope(p_this, p_func) { return function(e) { e.mouseLocation = True.Behavior.locateMouse(e); e.src = e.target || e.srcElement; return p_func.apply(p_this, [e]); }; }; function cfn(p_el) {
			this.element = p_el; this.jq = $(p_el); this.handlers = {}; for (var p in this) { if ((this[p] instanceof Function)) { var pSplit = p.split("_"); if (pSplit[0] == "handle") { this[p] = __rescope(this, this[p]); this.handlers[pSplit[1]] = this[p]; this.jq.bind(pSplit[1], this[p]); } } }
			this._removeDelegate = Function.createDelegate(this.dispose, this); this.jq.bind('remove', this._removeDelegate); this.init(); this.jq.attachTrueType({ type: Function.getType(this), instance: this });
		}; return cfn;
	})(); True.Behavior.locateMouse = function(e) {
		var posx = 0, posy = 0; if (e.pageX || e.pageY) { posx = e.pageX; posy = e.pageY; }
		else if (e.clientX || e.clientY) { var scrollTarget = (document.documentElement.scrollTop) ? document.documentElement : document.body; posx = e.clientX + scrollTarget.scrollLeft; posy = e.clientY + scrollTarget.scrollTop; }
		return { x: posx, y: posy };
	}; True.Behavior.prototype = { init: function() { True.Behavior.dispatchEvent("init-" + Function.getTypeName(this), { typeName: Function.getTypeName(this), target: this }); }, dispose: function() {
		this.jq.unbind('remove', this._removeDelegate); this.detachHandlers(); var tt = this.jq.data("true.types"); if (tt) { var tn = Function.getTypeName(this); if (tn) delete tt[tn]; }
		this.jq = this.element = undefined;
	}, detachHandlers: function() { for (var p in this.handlers) { this.jq.unbind(p, this.handlers[p]); } }, attachHandlers: function() { for (var p in this.handlers) { this.jq[p](this.handlers[p]); } }, hasClass: function(p_name, p_el) { return $(p_el || this.element).hasClass(p_name); } 
	}; True.EventDispatcher.decorate(True.Behavior); True.Behavior.register("True.Behavior"); True.Control = (function() {
		function cfn(p_el) { True.Control.constructBase(this, arguments); }; cfn.releaseDOM = function(e) {
			var a = e.attributes, i, l, n; if (a) { l = a.length; for (i = 0; i < l; i += 1) { n = a[i].name; if (typeof e[n] === 'function') { e[n] = null; } } }
			a = e.childNodes; if (a) { l = a.length; for (i = 0; i < l; i += 1) { cfn.releaseDOM(e.childNodes[i]); } } 
		}; return cfn;
	})(); True.Control.prototype = { dispose: function() {
		if (!this.__disposing) {
			this.__disposing = true; this.jq.find("*").unbind().end(); this.jq.find("*:trueType('*')").each(function(p_i) { var tt = $(this).getTrueTypes(); for (var p in tt) { if (tt[p].dispose) tt[p].dispose(); } }).end(); if ($.browser.msie && this.element != undefined) { True.Control.releaseDOM(this.element); }
			this.jq.remove(); True.Control.callBaseMethod(this, "dispose"); delete this.__disposing;
		} 
	} 
	}; True.Control.register("True.Control", True.Behavior); jQuery(document).ready(function() { jQuery("*", document.body).initTrueTypes(); });
}
//]]>