/*!
 * jQuery JavaScript Library v1.3.2
 * http://jquery.com/
 *
 * Copyright (c) 2009 John Resig
 * Dual licensed under the MIT and GPL licenses.
 * http://docs.jquery.com/License
 *
 * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
 * Revision: 6246
 */
(function(){

var 
	// Will speed up references to window, and allows munging its name.
	window = this,
	// Will speed up references to undefined, and allows munging its name.
	undefined,
	// Map over jQuery in case of overwrite
	_jQuery = window.jQuery,
	// Map over the $ in case of overwrite
	_$ = window.$,

	jQuery = window.jQuery = window.$ = function( selector, context ) {
		// The jQuery object is actually just the init constructor 'enhanced'
		return new jQuery.fn.init( selector, context );
	},

	// A simple way to check for HTML strings or ID strings
	// (both of which we optimize for)
	quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,
	// Is it a simple selector
	isSimple = /^.[^:#\[\.,]*$/;

jQuery.fn = jQuery.prototype = {
	init: function( selector, context ) {
		// Make sure that a selection was provided
		selector = selector || document;

		// Handle $(DOMElement)
		if ( selector.nodeType ) {
			this[0] = selector;
			this.length = 1;
			this.context = selector;
			return this;
		}
		// Handle HTML strings
		if ( typeof selector === "string" ) {
			// Are we dealing with HTML string or an ID?
			var match = quickExpr.exec( selector );

			// Verify a match, and that no context was specified for #id
			if ( match && (match[1] || !context) ) {

				// HANDLE: $(html) -> $(array)
				if ( match[1] )
					selector = jQuery.clean( [ match[1] ], context );

				// HANDLE: $("#id")
				else {
					var elem = document.getElementById( match[3] );

					// Handle the case where IE and Opera return items
					// by name instead of ID
					if ( elem && elem.id != match[3] )
						return jQuery().find( selector );

					// Otherwise, we inject the element directly into the jQuery object
					var ret = jQuery( elem || [] );
					ret.context = document;
					ret.selector = selector;
					return ret;
				}

			// HANDLE: $(expr, [context])
			// (which is just equivalent to: $(content).find(expr)
			} else
				return jQuery( context ).find( selector );

		// HANDLE: $(function)
		// Shortcut for document ready
		} else if ( jQuery.isFunction( selector ) )
			return jQuery( document ).ready( selector );

		// Make sure that old selector state is passed along
		if ( selector.selector && selector.context ) {
			this.selector = selector.selector;
			this.context = selector.context;
		}

		return this.setArray(jQuery.isArray( selector ) ?
			selector :
			jQuery.makeArray(selector));
	},

	// Start with an empty selector
	selector: "",

	// The current version of jQuery being used
	jquery: "1.3.2",

	// The number of elements contained in the matched element set
	size: function() {
		return this.length;
	},

	// Get the Nth element in the matched element set OR
	// Get the whole matched element set as a clean array
	get: function( num ) {
		return num === undefined ?

			// Return a 'clean' array
			Array.prototype.slice.call( this ) :

			// Return just the object
			this[ num ];
	},

	// Take an array of elements and push it onto the stack
	// (returning the new matched element set)
	pushStack: function( elems, name, selector ) {
		// Build a new jQuery matched element set
		var ret = jQuery( elems );

		// Add the old object onto the stack (as a reference)
		ret.prevObject = this;

		ret.context = this.context;

		if ( name === "find" )
			ret.selector = this.selector + (this.selector ? " " : "") + selector;
		else if ( name )
			ret.selector = this.selector + "." + name + "(" + selector + ")";

		// Return the newly-formed element set
		return ret;
	},

	// Force the current matched set of elements to become
	// the specified array of elements (destroying the stack in the process)
	// You should use pushStack() in order to do this, but maintain the stack
	setArray: function( elems ) {
		// Resetting the length to 0, then using the native Array push
		// is a super-fast way to populate an object with array-like properties
		this.length = 0;
		Array.prototype.push.apply( this, elems );

		return this;
	},

	// Execute a callback for every element in the matched set.
	// (You can seed the arguments with an array of args, but this is
	// only used internally.)
	each: function( callback, args ) {
		return jQuery.each( this, callback, args );
	},

	// Determine the position of an element within
	// the matched set of elements
	index: function( elem ) {
		// Locate the position of the desired element
		return jQuery.inArray(
			// If it receives a jQuery object, the first element is used
			elem && elem.jquery ? elem[0] : elem
		, this );
	},

	attr: function( name, value, type ) {
		var options = name;

		// Look for the case where we're accessing a style value
		if ( typeof name === "string" )
			if ( value === undefined )
				return this[0] && jQuery[ type || "attr" ]( this[0], name );

			else {
				options = {};
				options[ name ] = value;
			}

		// Check to see if we're setting style values
		return this.each(function(i){
			// Set all the styles
			for ( name in options )
				jQuery.attr(
					type ?
						this.style :
						this,
					name, jQuery.prop( this, options[ name ], type, i, name )
				);
		});
	},

	css: function( key, value ) {
		// ignore negative width and height values
		if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 )
			value = undefined;
		return this.attr( key, value, "curCSS" );
	},

	text: function( text ) {
		if ( typeof text !== "object" && text != null )
			return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );

		var ret = "";

		jQuery.each( text || this, function(){
			jQuery.each( this.childNodes, function(){
				if ( this.nodeType != 8 )
					ret += this.nodeType != 1 ?
						this.nodeValue :
						jQuery.fn.text( [ this ] );
			});
		});

		return ret;
	},

	wrapAll: function( html ) {
		if ( this[0] ) {
			// The elements to wrap the target around
			var wrap = jQuery( html, this[0].ownerDocument ).clone();

			if ( this[0].parentNode )
				wrap.insertBefore( this[0] );

			wrap.map(function(){
				var elem = this;

				while ( elem.firstChild )
					elem = elem.firstChild;

				return elem;
			}).append(this);
		}

		return this;
	},

	wrapInner: function( html ) {
		return this.each(function(){
			jQuery( this ).contents().wrapAll( html );
		});
	},

	wrap: function( html ) {
		return this.each(function(){
			jQuery( this ).wrapAll( html );
		});
	},

	append: function() {
		return this.domManip(arguments, true, function(elem){
			if (this.nodeType == 1)
				this.appendChild( elem );
		});
	},

	prepend: function() {
		return this.domManip(arguments, true, function(elem){
			if (this.nodeType == 1)
				this.insertBefore( elem, this.firstChild );
		});
	},

	before: function() {
		return this.domManip(arguments, false, function(elem){
			this.parentNode.insertBefore( elem, this );
		});
	},

	after: function() {
		return this.domManip(arguments, false, function(elem){
			this.parentNode.insertBefore( elem, this.nextSibling );
		});
	},

	end: function() {
		return this.prevObject || jQuery( [] );
	},

	// For internal use only.
	// Behaves like an Array's method, not like a jQuery method.
	push: [].push,
	sort: [].sort,
	splice: [].splice,

	find: function( selector ) {
		if ( this.length === 1 ) {
			var ret = this.pushStack( [], "find", selector );
			ret.length = 0;
			jQuery.find( selector, this[0], ret );
			return ret;
		} else {
			return this.pushStack( jQuery.unique(jQuery.map(this, function(elem){
				return jQuery.find( selector, elem );
			})), "find", selector );
		}
	},

	clone: function( events ) {
		// Do the clone
		var ret = this.map(function(){
			if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
				// IE copies events bound via attachEvent when
				// using cloneNode. Calling detachEvent on the
				// clone will also remove the events from the orignal
				// In order to get around this, we use innerHTML.
				// Unfortunately, this means some modifications to
				// attributes in IE that are actually only stored
				// as properties will not be copied (such as the
				// the name attribute on an input).
				var html = this.outerHTML;
				if ( !html ) {
					var div = this.ownerDocument.createElement("div");
					div.appendChild( this.cloneNode(true) );
					html = div.innerHTML;
				}

				return jQuery.clean([html.replace(/ jQuery\d+="(?:\d+|null)"/g, "").replace(/^\s*/, "")])[0];
			} else
				return this.cloneNode(true);
		});

		// Copy the events from the original to the clone
		if ( events === true ) {
			var orig = this.find("*").andSelf(), i = 0;

			ret.find("*").andSelf().each(function(){
				if ( this.nodeName !== orig[i].nodeName )
					return;

				var events = jQuery.data( orig[i], "events" );

				for ( var type in events ) {
					for ( var handler in events[ type ] ) {
						jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
					}
				}

				i++;
			});
		}

		// Return the cloned set
		return ret;
	},

	filter: function( selector ) {
		return this.pushStack(
			jQuery.isFunction( selector ) &&
			jQuery.grep(this, function(elem, i){
				return selector.call( elem, i );
			}) ||

			jQuery.multiFilter( selector, jQuery.grep(this, function(elem){
				return elem.nodeType === 1;
			}) ), "filter", selector );
	},

	closest: function( selector ) {
		var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null,
			closer = 0;

		return this.map(function(){
			var cur = this;
			while ( cur && cur.ownerDocument ) {
				if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) {
					jQuery.data(cur, "closest", closer);
					return cur;
				}
				cur = cur.parentNode;
				closer++;
			}
		});
	},

	not: function( selector ) {
		if ( typeof selector === "string" )
			// test special case where just one selector is passed in
			if ( isSimple.test( selector ) )
				return this.pushStack( jQuery.multiFilter( selector, this, true ), "not", selector );
			else
				selector = jQuery.multiFilter( selector, this );

		var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType;
		return this.filter(function() {
			return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector;
		});
	},

	add: function( selector ) {
		return this.pushStack( jQuery.unique( jQuery.merge(
			this.get(),
			typeof selector === "string" ?
				jQuery( selector ) :
				jQuery.makeArray( selector )
		)));
	},

	is: function( selector ) {
		return !!selector && jQuery.multiFilter( selector, this ).length > 0;
	},

	hasClass: function( selector ) {
		return !!selector && this.is( "." + selector );
	},

	val: function( value ) {
		if ( value === undefined ) {			
			var elem = this[0];

			if ( elem ) {
				if( jQuery.nodeName( elem, 'option' ) )
					return (elem.attributes.value || {}).specified ? elem.value : elem.text;
				
				// We need to handle select boxes special
				if ( jQuery.nodeName( elem, "select" ) ) {
					var index = elem.selectedIndex,
						values = [],
						options = elem.options,
						one = elem.type == "select-one";

					// Nothing was selected
					if ( index < 0 )
						return null;

					// Loop through all the selected options
					for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
						var option = options[ i ];

						if ( option.selected ) {
							// Get the specifc value for the option
							value = jQuery(option).val();

							// We don't need an array for one selects
							if ( one )
								return value;

							// Multi-Selects return an array
							values.push( value );
						}
					}

					return values;				
				}

				// Everything else, we just grab the value
				return (elem.value || "").replace(/\r/g, "");

			}

			return undefined;
		}

		if ( typeof value === "number" )
			value += '';

		return this.each(function(){
			if ( this.nodeType != 1 )
				return;

			if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) )
				this.checked = (jQuery.inArray(this.value, value) >= 0 ||
					jQuery.inArray(this.name, value) >= 0);

			else if ( jQuery.nodeName( this, "select" ) ) {
				var values = jQuery.makeArray(value);

				jQuery( "option", this ).each(function(){
					this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
						jQuery.inArray( this.text, values ) >= 0);
				});

				if ( !values.length )
					this.selectedIndex = -1;

			} else
				this.value = value;
		});
	},

	html: function( value ) {
		return value === undefined ?
			(this[0] ?
				this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g, "") :
				null) :
			this.empty().append( value );
	},

	replaceWith: function( value ) {
		return this.after( value ).remove();
	},

	eq: function( i ) {
		return this.slice( i, +i + 1 );
	},

	slice: function() {
		return this.pushStack( Array.prototype.slice.apply( this, arguments ),
			"slice", Array.prototype.slice.call(arguments).join(",") );
	},

	map: function( callback ) {
		return this.pushStack( jQuery.map(this, function(elem, i){
			return callback.call( elem, i, elem );
		}));
	},

	andSelf: function() {
		return this.add( this.prevObject );
	},

	domManip: function( args, table, callback ) {
		if ( this[0] ) {
			var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(),
				scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ),
				first = fragment.firstChild;

			if ( first )
				for ( var i = 0, l = this.length; i < l; i++ )
					callback.call( root(this[i], first), this.length > 1 || i > 0 ?
							fragment.cloneNode(true) : fragment );
		
			if ( scripts )
				jQuery.each( scripts, evalScript );
		}

		return this;
		
		function root( elem, cur ) {
			return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ?
				(elem.getElementsByTagName("tbody")[0] ||
				elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
				elem;
		}
	}
};

// Give the init function the jQuery prototype for later instantiation
jQuery.fn.init.prototype = jQuery.fn;

function evalScript( i, elem ) {
	if ( elem.src )
		jQuery.ajax({
			url: elem.src,
			async: false,
			dataType: "script"
		});

	else
		jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );

	if ( elem.parentNode )
		elem.parentNode.removeChild( elem );
}

function now(){
	return +new Date;
}

jQuery.extend = jQuery.fn.extend = function() {
	// copy reference to target object
	var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;

	// Handle a deep copy situation
	if ( typeof target === "boolean" ) {
		deep = target;
		target = arguments[1] || {};
		// skip the boolean and the target
		i = 2;
	}

	// Handle case when target is a string or something (possible in deep copy)
	if ( typeof target !== "object" && !jQuery.isFunction(target) )
		target = {};

	// extend jQuery itself if only one argument is passed
	if ( length == i ) {
		target = this;
		--i;
	}

	for ( ; i < length; i++ )
		// Only deal with non-null/undefined values
		if ( (options = arguments[ i ]) != null )
			// Extend the base object
			for ( var name in options ) {
				var src = target[ name ], copy = options[ name ];

				// Prevent never-ending loop
				if ( target === copy )
					continue;

				// Recurse if we're merging object values
				if ( deep && copy && typeof copy === "object" && !copy.nodeType )
					target[ name ] = jQuery.extend( deep, 
						// Never move original objects, clone them
						src || ( copy.length != null ? [ ] : { } )
					, copy );

				// Don't bring in undefined values
				else if ( copy !== undefined )
					target[ name ] = copy;

			}

	// Return the modified object
	return target;
};

// exclude the following css properties to add px
var	exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
	// cache defaultView
	defaultView = document.defaultView || {},
	toString = Object.prototype.toString;

jQuery.extend({
	noConflict: function( deep ) {
		window.$ = _$;

		if ( deep )
			window.jQuery = _jQuery;

		return jQuery;
	},

	// See test/unit/core.js for details concerning isFunction.
	// Since version 1.3, DOM methods and functions like alert
	// aren't supported. They return false on IE (#2968).
	isFunction: function( obj ) {
		return toString.call(obj) === "[object Function]";
	},

	isArray: function( obj ) {
		return toString.call(obj) === "[object Array]";
	},

	// check if an element is in a (or is an) XML document
	isXMLDoc: function( elem ) {
		return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" ||
			!!elem.ownerDocument && jQuery.isXMLDoc( elem.ownerDocument );
	},

	// Evalulates a script in a global context
	globalEval: function( data ) {
		if ( data && /\S/.test(data) ) {
			// Inspired by code by Andrea Giammarchi
			// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
			var head = document.getElementsByTagName("head")[0] || document.documentElement,
				script = document.createElement("script");

			script.type = "text/javascript";
			if ( jQuery.support.scriptEval )
				script.appendChild( document.createTextNode( data ) );
			else
				script.text = data;

			// Use insertBefore instead of appendChild  to circumvent an IE6 bug.
			// This arises when a base node is used (#2709).
			head.insertBefore( script, head.firstChild );
			head.removeChild( script );
		}
	},

	nodeName: function( elem, name ) {
		return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
	},

	// args is for internal usage only
	each: function( object, callback, args ) {
		var name, i = 0, length = object.length;

		if ( args ) {
			if ( length === undefined ) {
				for ( name in object )
					if ( callback.apply( object[ name ], args ) === false )
						break;
			} else
				for ( ; i < length; )
					if ( callback.apply( object[ i++ ], args ) === false )
						break;

		// A special, fast, case for the most common use of each
		} else {
			if ( length === undefined ) {
				for ( name in object )
					if ( callback.call( object[ name ], name, object[ name ] ) === false )
						break;
			} else
				for ( var value = object[0];
					i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}
		}

		return object;
	},

	prop: function( elem, value, type, i, name ) {
		// Handle executable functions
		if ( jQuery.isFunction( value ) )
			value = value.call( elem, i );

		// Handle passing in a number to a CSS property
		return typeof value === "number" && type == "curCSS" && !exclude.test( name ) ?
			value + "px" :
			value;
	},

	className: {
		// internal only, use addClass("class")
		add: function( elem, classNames ) {
			jQuery.each((classNames || "").split(/\s+/), function(i, className){
				if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) )
					elem.className += (elem.className ? " " : "") + className;
			});
		},

		// internal only, use removeClass("class")
		remove: function( elem, classNames ) {
			if (elem.nodeType == 1)
				elem.className = classNames !== undefined ?
					jQuery.grep(elem.className.split(/\s+/), function(className){
						return !jQuery.className.has( classNames, className );
					}).join(" ") :
					"";
		},

		// internal only, use hasClass("class")
		has: function( elem, className ) {
			return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;
		}
	},

	// A method for quickly swapping in/out CSS properties to get correct calculations
	swap: function( elem, options, callback ) {
		var old = {};
		// Remember the old values, and insert the new ones
		for ( var name in options ) {
			old[ name ] = elem.style[ name ];
			elem.style[ name ] = options[ name ];
		}

		callback.call( elem );

		// Revert the old values
		for ( var name in options )
			elem.style[ name ] = old[ name ];
	},

	css: function( elem, name, force, extra ) {
		if ( name == "width" || name == "height" ) {
			var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];

			function getWH() {
				val = name == "width" ? elem.offsetWidth : elem.offsetHeight;

				if ( extra === "border" )
					return;

				jQuery.each( which, function() {
					if ( !extra )
						val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
					if ( extra === "margin" )
						val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0;
					else
						val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
				});
			}

			if ( elem.offsetWidth !== 0 )
				getWH();
			else
				jQuery.swap( elem, props, getWH );

			return Math.max(0, Math.round(val));
		}

		return jQuery.curCSS( elem, name, force );
	},

	curCSS: function( elem, name, force ) {
		var ret, style = elem.style;

		// We need to handle opacity special in IE
		if ( name == "opacity" && !jQuery.support.opacity ) {
			ret = jQuery.attr( style, "opacity" );

			return ret == "" ?
				"1" :
				ret;
		}

		// Make sure we're using the right name for getting the float value
		if ( name.match( /float/i ) )
			name = styleFloat;

		if ( !force && style && style[ name ] )
			ret = style[ name ];

		else if ( defaultView.getComputedStyle ) {

			// Only "float" is needed here
			if ( name.match( /float/i ) )
				name = "float";

			name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();

			var computedStyle = defaultView.getComputedStyle( elem, null );

			if ( computedStyle )
				ret = computedStyle.getPropertyValue( name );

			// We should always get a number back from opacity
			if ( name == "opacity" && ret == "" )
				ret = "1";

		} else if ( elem.currentStyle ) {
			var camelCase = name.replace(/\-(\w)/g, function(all, letter){
				return letter.toUpperCase();
			});

			ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];

			// From the awesome hack by Dean Edwards
			// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291

			// If we're not dealing with a regular pixel number
			// but a number that has a weird ending, we need to convert it to pixels
			if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {
				// Remember the original values
				var left = style.left, rsLeft = elem.runtimeStyle.left;

				// Put in the new values to get a computed value out
				elem.runtimeStyle.left = elem.currentStyle.left;
				style.left = ret || 0;
				ret = style.pixelLeft + "px";

				// Revert the changed values
				style.left = left;
				elem.runtimeStyle.left = rsLeft;
			}
		}

		return ret;
	},

	clean: function( elems, context, fragment ) {
		context = context || document;

		// !context.createElement fails in IE with an error but returns typeof 'object'
		if ( typeof context.createElement === "undefined" )
			context = context.ownerDocument || context[0] && context[0].ownerDocument || document;

		// If a single string is passed in and it's a single tag
		// just do a createElement and skip the rest
		if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) {
			var match = /^<(\w+)\s*\/?>$/.exec(elems[0]);
			if ( match )
				return [ context.createElement( match[1] ) ];
		}

		var ret = [], scripts = [], div = context.createElement("div");

		jQuery.each(elems, function(i, elem){
			if ( typeof elem === "number" )
				elem += '';

			if ( !elem )
				return;

			// Convert html string into DOM nodes
			if ( typeof elem === "string" ) {
				// Fix "XHTML"-style tags in all browsers
				elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
					return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
						all :
						front + "></" + tag + ">";
				});

				// Trim whitespace, otherwise indexOf won't work as expected
				var tags = elem.replace(/^\s+/, "").substring(0, 10).toLowerCase();

				var wrap =
					// option or optgroup
					!tags.indexOf("<opt") &&
					[ 1, "<select multiple='multiple'>", "</select>" ] ||

					!tags.indexOf("<leg") &&
					[ 1, "<fieldset>", "</fieldset>" ] ||

					tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
					[ 1, "<table>", "</table>" ] ||

					!tags.indexOf("<tr") &&
					[ 2, "<table><tbody>", "</tbody></table>" ] ||

				 	// <thead> matched above
					(!tags.indexOf("<td") || !tags.indexOf("<th")) &&
					[ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] ||

					!tags.indexOf("<col") &&
					[ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||

					// IE can't serialize <link> and <script> tags normally
					!jQuery.support.htmlSerialize &&
					[ 1, "div<div>", "</div>" ] ||

					[ 0, "", "" ];

				// Go to html and back, then peel off extra wrappers
				div.innerHTML = wrap[1] + elem + wrap[2];

				// Move to the right depth
				while ( wrap[0]-- )
					div = div.lastChild;

				// Remove IE's autoinserted <tbody> from table fragments
				if ( !jQuery.support.tbody ) {

					// String was a <table>, *may* have spurious <tbody>
					var hasBody = /<tbody/i.test(elem),
						tbody = !tags.indexOf("<table") && !hasBody ?
							div.firstChild && div.firstChild.childNodes :

						// String was a bare <thead> or <tfoot>
						wrap[1] == "<table>" && !hasBody ?
							div.childNodes :
							[];

					for ( var j = tbody.length - 1; j >= 0 ; --j )
						if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length )
							tbody[ j ].parentNode.removeChild( tbody[ j ] );

					}

				// IE completely kills leading whitespace when innerHTML is used
				if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) )
					div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
				
				elem = jQuery.makeArray( div.childNodes );
			}

			if ( elem.nodeType )
				ret.push( elem );
			else
				ret = jQuery.merge( ret, elem );

		});

		if ( fragment ) {
			for ( var i = 0; ret[i]; i++ ) {
				if ( jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
					scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
				} else {
					if ( ret[i].nodeType === 1 )
						ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
					fragment.appendChild( ret[i] );
				}
			}
			
			return scripts;
		}

		return ret;
	},

	attr: function( elem, name, value ) {
		// don't set attributes on text and comment nodes
		if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
			return undefined;

		var notxml = !jQuery.isXMLDoc( elem ),
			// Whether we are setting (or getting)
			set = value !== undefined;

		// Try to normalize/fix the name
		name = notxml && jQuery.props[ name ] || name;

		// Only do all the following if this is a node (faster for style)
		// IE elem.getAttribute passes even for style
		if ( elem.tagName ) {

			// These attributes require special treatment
			var special = /href|src|style/.test( name );

			// Safari mis-reports the default selected property of a hidden option
			// Accessing the parent's selectedIndex property fixes it
			if ( name == "selected" && elem.parentNode )
				elem.parentNode.selectedIndex;

			// If applicable, access the attribute via the DOM 0 way
			if ( name in elem && notxml && !special ) {
				if ( set ){
					// We can't allow the type property to be changed (since it causes problems in IE)
					if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
						throw "type property can't be changed";

					elem[ name ] = value;
				}

				// browsers index elements by id/name on forms, give priority to attributes.
				if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) )
					return elem.getAttributeNode( name ).nodeValue;

				// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
				// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
				if ( name == "tabIndex" ) {
					var attributeNode = elem.getAttributeNode( "tabIndex" );
					return attributeNode && attributeNode.specified
						? attributeNode.value
						: elem.nodeName.match(/(button|input|object|select|textarea)/i)
							? 0
							: elem.nodeName.match(/^(a|area)$/i) && elem.href
								? 0
								: undefined;
				}

				return elem[ name ];
			}

			if ( !jQuery.support.style && notxml &&  name == "style" )
				return jQuery.attr( elem.style, "cssText", value );

			if ( set )
				// convert the value to a string (all browsers do this but IE) see #1070
				elem.setAttribute( name, "" + value );

			var attr = !jQuery.support.hrefNormalized && notxml && special
					// Some attributes require a special call on IE
					? elem.getAttribute( name, 2 )
					: elem.getAttribute( name );

			// Non-existent attributes return null, we normalize to undefined
			return attr === null ? undefined : attr;
		}

		// elem is actually elem.style ... set the style

		// IE uses filters for opacity
		if ( !jQuery.support.opacity && name == "opacity" ) {
			if ( set ) {
				// IE has trouble with opacity if it does not have layout
				// Force it by setting the zoom level
				elem.zoom = 1;

				// Set the alpha filter to set the opacity
				elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +
					(parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
			}

			return elem.filter && elem.filter.indexOf("opacity=") >= 0 ?
				(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':
				"";
		}

		name = name.replace(/-([a-z])/ig, function(all, letter){
			return letter.toUpperCase();
		});

		if ( set )
			elem[ name ] = value;

		return elem[ name ];
	},

	trim: function( text ) {
		return (text || "").replace( /^\s+|\s+$/g, "" );
	},

	makeArray: function( array ) {
		var ret = [];

		if( array != null ){
			var i = array.length;
			// The window, strings (and functions) also have 'length'
			if( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval )
				ret[0] = array;
			else
				while( i )
					ret[--i] = array[i];
		}

		return ret;
	},

	inArray: function( elem, array ) {
		for ( var i = 0, length = array.length; i < length; i++ )
		// Use === because on IE, window == document
			if ( array[ i ] === elem )
				return i;

		return -1;
	},

	merge: function( first, second ) {
		// We have to loop this way because IE & Opera overwrite the length
		// expando of getElementsByTagName
		var i = 0, elem, pos = first.length;
		// Also, we need to make sure that the correct elements are being returned
		// (IE returns comment nodes in a '*' query)
		if ( !jQuery.support.getAll ) {
			while ( (elem = second[ i++ ]) != null )
				if ( elem.nodeType != 8 )
					first[ pos++ ] = elem;

		} else
			while ( (elem = second[ i++ ]) != null )
				first[ pos++ ] = elem;

		return first;
	},

	unique: function( array ) {
		var ret = [], done = {};

		try {

			for ( var i = 0, length = array.length; i < length; i++ ) {
				var id = jQuery.data( array[ i ] );

				if ( !done[ id ] ) {
					done[ id ] = true;
					ret.push( array[ i ] );
				}
			}

		} catch( e ) {
			ret = array;
		}

		return ret;
	},

	grep: function( elems, callback, inv ) {
		var ret = [];

		// Go through the array, only saving the items
		// that pass the validator function
		for ( var i = 0, length = elems.length; i < length; i++ )
			if ( !inv != !callback( elems[ i ], i ) )
				ret.push( elems[ i ] );

		return ret;
	},

	map: function( elems, callback ) {
		var ret = [];

		// Go through the array, translating each of the items to their
		// new value (or values).
		for ( var i = 0, length = elems.length; i < length; i++ ) {
			var value = callback( elems[ i ], i );

			if ( value != null )
				ret[ ret.length ] = value;
		}

		return ret.concat.apply( [], ret );
	}
});

// Use of jQuery.browser is deprecated.
// It's included for backwards compatibility and plugins,
// although they should work to migrate away.

var userAgent = navigator.userAgent.toLowerCase();

// Figure out what browser is being used
jQuery.browser = {
	version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
	safari: /webkit/.test( userAgent ),
	opera: /opera/.test( userAgent ),
	msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
	mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
};

jQuery.each({
	parent: function(elem){return elem.parentNode;},
	parents: function(elem){return jQuery.dir(elem,"parentNode");},
	next: function(elem){return jQuery.nth(elem,2,"nextSibling");},
	prev: function(elem){return jQuery.nth(elem,2,"previousSibling");},
	nextAll: function(elem){return jQuery.dir(elem,"nextSibling");},
	prevAll: function(elem){return jQuery.dir(elem,"previousSibling");},
	siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},
	children: function(elem){return jQuery.sibling(elem.firstChild);},
	contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}
}, function(name, fn){
	jQuery.fn[ name ] = function( selector ) {
		var ret = jQuery.map( this, fn );

		if ( selector && typeof selector == "string" )
			ret = jQuery.multiFilter( selector, ret );

		return this.pushStack( jQuery.unique( ret ), name, selector );
	};
});

jQuery.each({
	appendTo: "append",
	prependTo: "prepend",
	insertBefore: "before",
	insertAfter: "after",
	replaceAll: "replaceWith"
}, function(name, original){
	jQuery.fn[ name ] = function( selector ) {
		var ret = [], insert = jQuery( selector );

		for ( var i = 0, l = insert.length; i < l; i++ ) {
			var elems = (i > 0 ? this.clone(true) : this).get();
			jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
			ret = ret.concat( elems );
		}

		return this.pushStack( ret, name, selector );
	};
});

jQuery.each({
	removeAttr: function( name ) {
		jQuery.attr( this, name, "" );
		if (this.nodeType == 1)
			this.removeAttribute( name );
	},

	addClass: function( classNames ) {
		jQuery.className.add( this, classNames );
	},

	removeClass: function( classNames ) {
		jQuery.className.remove( this, classNames );
	},

	toggleClass: function( classNames, state ) {
		if( typeof state !== "boolean" )
			state = !jQuery.className.has( this, classNames );
		jQuery.className[ state ? "add" : "remove" ]( this, classNames );
	},

	remove: function( selector ) {
		if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
			// Prevent memory leaks
			jQuery( "*", this ).add([this]).each(function(){
				jQuery.event.remove(this);
				jQuery.removeData(this);
			});
			if (this.parentNode)
				this.parentNode.removeChild( this );
		}
	},

	empty: function() {
		// Remove element nodes and prevent memory leaks
		jQuery(this).children().remove();

		// Remove any remaining nodes
		while ( this.firstChild )
			this.removeChild( this.firstChild );
	}
}, function(name, fn){
	jQuery.fn[ name ] = function(){
		return this.each( fn, arguments );
	};
});

// Helper function used by the dimensions and offset modules
function num(elem, prop) {
	return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0;
}
var expando = "jQuery" + now(), uuid = 0, windowData = {};

jQuery.extend({
	cache: {},

	data: function( elem, name, data ) {
		elem = elem == window ?
			windowData :
			elem;

		var id = elem[ expando ];

		// Compute a unique ID for the element
		if ( !id )
			id = elem[ expando ] = ++uuid;

		// Only generate the data cache if we're
		// trying to access or manipulate it
		if ( name && !jQuery.cache[ id ] )
			jQuery.cache[ id ] = {};

		// Prevent overriding the named cache with undefined values
		if ( data !== undefined )
			jQuery.cache[ id ][ name ] = data;

		// Return the named cache data, or the ID for the element
		return name ?
			jQuery.cache[ id ][ name ] :
			id;
	},

	removeData: function( elem, name ) {
		elem = elem == window ?
			windowData :
			elem;

		var id = elem[ expando ];

		// If we want to remove a specific section of the element's data
		if ( name ) {
			if ( jQuery.cache[ id ] ) {
				// Remove the section of cache data
				delete jQuery.cache[ id ][ name ];

				// If we've removed all the data, remove the element's cache
				name = "";

				for ( name in jQuery.cache[ id ] )
					break;

				if ( !name )
					jQuery.removeData( elem );
			}

		// Otherwise, we want to remove all of the element's data
		} else {
			// Clean up the element expando
			try {
				delete elem[ expando ];
			} catch(e){
				// IE has trouble directly removing the expando
				// but it's ok with using removeAttribute
				if ( elem.removeAttribute )
					elem.removeAttribute( expando );
			}

			// Completely remove the data cache
			delete jQuery.cache[ id ];
		}
	},
	queue: function( elem, type, data ) {
		if ( elem ){
	
			type = (type || "fx") + "queue";
	
			var q = jQuery.data( elem, type );
	
			if ( !q || jQuery.isArray(data) )
				q = jQuery.data( elem, type, jQuery.makeArray(data) );
			else if( data )
				q.push( data );
	
		}
		return q;
	},

	dequeue: function( elem, type ){
		var queue = jQuery.queue( elem, type ),
			fn = queue.shift();
		
		if( !type || type === "fx" )
			fn = queue[0];
			
		if( fn !== undefined )
			fn.call(elem);
	}
});

jQuery.fn.extend({
	data: function( key, value ){
		var parts = key.split(".");
		parts[1] = parts[1] ? "." + parts[1] : "";

		if ( value === undefined ) {
			var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);

			if ( data === undefined && this.length )
				data = jQuery.data( this[0], key );

			return data === undefined && parts[1] ?
				this.data( parts[0] ) :
				data;
		} else
			return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
				jQuery.data( this, key, value );
			});
	},

	removeData: function( key ){
		return this.each(function(){
			jQuery.removeData( this, key );
		});
	},
	queue: function(type, data){
		if ( typeof type !== "string" ) {
			data = type;
			type = "fx";
		}

		if ( data === undefined )
			return jQuery.queue( this[0], type );

		return this.each(function(){
			var queue = jQuery.queue( this, type, data );
			
			 if( type == "fx" && queue.length == 1 )
				queue[0].call(this);
		});
	},
	dequeue: function(type){
		return this.each(function(){
			jQuery.dequeue( this, type );
		});
	}
});/*!
 * Sizzle CSS Selector Engine - v0.9.3
 *  Copyright 2009, The Dojo Foundation
 *  Released under the MIT, BSD, and GPL Licenses.
 *  More information: http://sizzlejs.com/
 */
(function(){

var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,
	done = 0,
	toString = Object.prototype.toString;

var Sizzle = function(selector, context, results, seed) {
	results = results || [];
	context = context || document;

	if ( context.nodeType !== 1 && context.nodeType !== 9 )
		return [];
	
	if ( !selector || typeof selector !== "string" ) {
		return results;
	}

	var parts = [], m, set, checkSet, check, mode, extra, prune = true;
	
	// Reset the position of the chunker regexp (start from head)
	chunker.lastIndex = 0;
	
	while ( (m = chunker.exec(selector)) !== null ) {
		parts.push( m[1] );
		
		if ( m[2] ) {
			extra = RegExp.rightContext;
			break;
		}
	}

	if ( parts.length > 1 && origPOS.exec( selector ) ) {
		if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
			set = posProcess( parts[0] + parts[1], context );
		} else {
			set = Expr.relative[ parts[0] ] ?
				[ context ] :
				Sizzle( parts.shift(), context );

			while ( parts.length ) {
				selector = parts.shift();

				if ( Expr.relative[ selector ] )
					selector += parts.shift();

				set = posProcess( selector, set );
			}
		}
	} else {
		var ret = seed ?
			{ expr: parts.pop(), set: makeArray(seed) } :
			Sizzle.find( parts.pop(), parts.length === 1 && context.parentNode ? context.parentNode : context, isXML(context) );
		set = Sizzle.filter( ret.expr, ret.set );

		if ( parts.length > 0 ) {
			checkSet = makeArray(set);
		} else {
			prune = false;
		}

		while ( parts.length ) {
			var cur = parts.pop(), pop = cur;

			if ( !Expr.relative[ cur ] ) {
				cur = "";
			} else {
				pop = parts.pop();
			}

			if ( pop == null ) {
				pop = context;
			}

			Expr.relative[ cur ]( checkSet, pop, isXML(context) );
		}
	}

	if ( !checkSet ) {
		checkSet = set;
	}

	if ( !checkSet ) {
		throw "Syntax error, unrecognized expression: " + (cur || selector);
	}

	if ( toString.call(checkSet) === "[object Array]" ) {
		if ( !prune ) {
			results.push.apply( results, checkSet );
		} else if ( context.nodeType === 1 ) {
			for ( var i = 0; checkSet[i] != null; i++ ) {
				if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
					results.push( set[i] );
				}
			}
		} else {
			for ( var i = 0; checkSet[i] != null; i++ ) {
				if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
					results.push( set[i] );
				}
			}
		}
	} else {
		makeArray( checkSet, results );
	}

	if ( extra ) {
		Sizzle( extra, context, results, seed );

		if ( sortOrder ) {
			hasDuplicate = false;
			results.sort(sortOrder);

			if ( hasDuplicate ) {
				for ( var i = 1; i < results.length; i++ ) {
					if ( results[i] === results[i-1] ) {
						results.splice(i--, 1);
					}
				}
			}
		}
	}

	return results;
};

Sizzle.matches = function(expr, set){
	return Sizzle(expr, null, null, set);
};

Sizzle.find = function(expr, context, isXML){
	var set, match;

	if ( !expr ) {
		return [];
	}

	for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
		var type = Expr.order[i], match;
		
		if ( (match = Expr.match[ type ].exec( expr )) ) {
			var left = RegExp.leftContext;

			if ( left.substr( left.length - 1 ) !== "\\" ) {
				match[1] = (match[1] || "").replace(/\\/g, "");
				set = Expr.find[ type ]( match, context, isXML );
				if ( set != null ) {
					expr = expr.replace( Expr.match[ type ], "" );
					break;
				}
			}
		}
	}

	if ( !set ) {
		set = context.getElementsByTagName("*");
	}

	return {set: set, expr: expr};
};

Sizzle.filter = function(expr, set, inplace, not){
	var old = expr, result = [], curLoop = set, match, anyFound,
		isXMLFilter = set && set[0] && isXML(set[0]);

	while ( expr && set.length ) {
		for ( var type in Expr.filter ) {
			if ( (match = Expr.match[ type ].exec( expr )) != null ) {
				var filter = Expr.filter[ type ], found, item;
				anyFound = false;

				if ( curLoop == result ) {
					result = [];
				}

				if ( Expr.preFilter[ type ] ) {
					match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );

					if ( !match ) {
						anyFound = found = true;
					} else if ( match === true ) {
						continue;
					}
				}

				if ( match ) {
					for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
						if ( item ) {
							found = filter( item, match, i, curLoop );
							var pass = not ^ !!found;

							if ( inplace && found != null ) {
								if ( pass ) {
									anyFound = true;
								} else {
									curLoop[i] = false;
								}
							} else if ( pass ) {
								result.push( item );
								anyFound = true;
							}
						}
					}
				}

				if ( found !== undefined ) {
					if ( !inplace ) {
						curLoop = result;
					}

					expr = expr.replace( Expr.match[ type ], "" );

					if ( !anyFound ) {
						return [];
					}

					break;
				}
			}
		}

		// Improper expression
		if ( expr == old ) {
			if ( anyFound == null ) {
				throw "Syntax error, unrecognized expression: " + expr;
			} else {
				break;
			}
		}

		old = expr;
	}

	return curLoop;
};

var Expr = Sizzle.selectors = {
	order: [ "ID", "NAME", "TAG" ],
	match: {
		ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
		CLASS: /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
		NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,
		ATTR: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
		TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,
		CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
		POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
		PSEUDO: /:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/
	},
	attrMap: {
		"class": "className",
		"for": "htmlFor"
	},
	attrHandle: {
		href: function(elem){
			return elem.getAttribute("href");
		}
	},
	relative: {
		"+": function(checkSet, part, isXML){
			var isPartStr = typeof part === "string",
				isTag = isPartStr && !/\W/.test(part),
				isPartStrNotTag = isPartStr && !isTag;

			if ( isTag && !isXML ) {
				part = part.toUpperCase();
			}

			for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
				if ( (elem = checkSet[i]) ) {
					while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}

					checkSet[i] = isPartStrNotTag || elem && elem.nodeName === part ?
						elem || false :
						elem === part;
				}
			}

			if ( isPartStrNotTag ) {
				Sizzle.filter( part, checkSet, true );
			}
		},
		">": function(checkSet, part, isXML){
			var isPartStr = typeof part === "string";

			if ( isPartStr && !/\W/.test(part) ) {
				part = isXML ? part : part.toUpperCase();

				for ( var i = 0, l = checkSet.length; i < l; i++ ) {
					var elem = checkSet[i];
					if ( elem ) {
						var parent = elem.parentNode;
						checkSet[i] = parent.nodeName === part ? parent : false;
					}
				}
			} else {
				for ( var i = 0, l = checkSet.length; i < l; i++ ) {
					var elem = checkSet[i];
					if ( elem ) {
						checkSet[i] = isPartStr ?
							elem.parentNode :
							elem.parentNode === part;
					}
				}

				if ( isPartStr ) {
					Sizzle.filter( part, checkSet, true );
				}
			}
		},
		"": function(checkSet, part, isXML){
			var doneName = done++, checkFn = dirCheck;

			if ( !part.match(/\W/) ) {
				var nodeCheck = part = isXML ? part : part.toUpperCase();
				checkFn = dirNodeCheck;
			}

			checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
		},
		"~": function(checkSet, part, isXML){
			var doneName = done++, checkFn = dirCheck;

			if ( typeof part === "string" && !part.match(/\W/) ) {
				var nodeCheck = part = isXML ? part : part.toUpperCase();
				checkFn = dirNodeCheck;
			}

			checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
		}
	},
	find: {
		ID: function(match, context, isXML){
			if ( typeof context.getElementById !== "undefined" && !isXML ) {
				var m = context.getElementById(match[1]);
				return m ? [m] : [];
			}
		},
		NAME: function(match, context, isXML){
			if ( typeof context.getElementsByName !== "undefined" ) {
				var ret = [], results = context.getElementsByName(match[1]);

				for ( var i = 0, l = results.length; i < l; i++ ) {
					if ( results[i].getAttribute("name") === match[1] ) {
						ret.push( results[i] );
					}
				}

				return ret.length === 0 ? null : ret;
			}
		},
		TAG: function(match, context){
			return context.getElementsByTagName(match[1]);
		}
	},
	preFilter: {
		CLASS: function(match, curLoop, inplace, result, not, isXML){
			match = " " + match[1].replace(/\\/g, "") + " ";

			if ( isXML ) {
				return match;
			}

			for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
				if ( elem ) {
					if ( not ^ (elem.className && (" " + elem.className + " ").indexOf(match) >= 0) ) {
						if ( !inplace )
							result.push( elem );
					} else if ( inplace ) {
						curLoop[i] = false;
					}
				}
			}

			return false;
		},
		ID: function(match){
			return match[1].replace(/\\/g, "");
		},
		TAG: function(match, curLoop){
			for ( var i = 0; curLoop[i] === false; i++ ){}
			return curLoop[i] && isXML(curLoop[i]) ? match[1] : match[1].toUpperCase();
		},
		CHILD: function(match){
			if ( match[1] == "nth" ) {
				// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
				var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
					match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" ||
					!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);

				// calculate the numbers (first)n+(last) including if they are negative
				match[2] = (test[1] + (test[2] || 1)) - 0;
				match[3] = test[3] - 0;
			}

			// TODO: Move to normal caching system
			match[0] = done++;

			return match;
		},
		ATTR: function(match, curLoop, inplace, result, not, isXML){
			var name = match[1].replace(/\\/g, "");
			
			if ( !isXML && Expr.attrMap[name] ) {
				match[1] = Expr.attrMap[name];
			}

			if ( match[2] === "~=" ) {
				match[4] = " " + match[4] + " ";
			}

			return match;
		},
		PSEUDO: function(match, curLoop, inplace, result, not){
			if ( match[1] === "not" ) {
				// If we're dealing with a complex expression, or a simple one
				if ( match[3].match(chunker).length > 1 || /^\w/.test(match[3]) ) {
					match[3] = Sizzle(match[3], null, null, curLoop);
				} else {
					var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
					if ( !inplace ) {
						result.push.apply( result, ret );
					}
					return false;
				}
			} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
				return true;
			}
			
			return match;
		},
		POS: function(match){
			match.unshift( true );
			return match;
		}
	},
	filters: {
		enabled: function(elem){
			return elem.disabled === false && elem.type !== "hidden";
		},
		disabled: function(elem){
			return elem.disabled === true;
		},
		checked: function(elem){
			return elem.checked === true;
		},
		selected: function(elem){
			// Accessing this property makes selected-by-default
			// options in Safari work properly
			elem.parentNode.selectedIndex;
			return elem.selected === true;
		},
		parent: function(elem){
			return !!elem.firstChild;
		},
		empty: function(elem){
			return !elem.firstChild;
		},
		has: function(elem, i, match){
			return !!Sizzle( match[3], elem ).length;
		},
		header: function(elem){
			return /h\d/i.test( elem.nodeName );
		},
		text: function(elem){
			return "text" === elem.type;
		},
		radio: function(elem){
			return "radio" === elem.type;
		},
		checkbox: function(elem){
			return "checkbox" === elem.type;
		},
		file: function(elem){
			return "file" === elem.type;
		},
		password: function(elem){
			return "password" === elem.type;
		},
		submit: function(elem){
			return "submit" === elem.type;
		},
		image: function(elem){
			return "image" === elem.type;
		},
		reset: function(elem){
			return "reset" === elem.type;
		},
		button: function(elem){
			return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON";
		},
		input: function(elem){
			return /input|select|textarea|button/i.test(elem.nodeName);
		}
	},
	setFilters: {
		first: function(elem, i){
			return i === 0;
		},
		last: function(elem, i, match, array){
			return i === array.length - 1;
		},
		even: function(elem, i){
			return i % 2 === 0;
		},
		odd: function(elem, i){
			return i % 2 === 1;
		},
		lt: function(elem, i, match){
			return i < match[3] - 0;
		},
		gt: function(elem, i, match){
			return i > match[3] - 0;
		},
		nth: function(elem, i, match){
			return match[3] - 0 == i;
		},
		eq: function(elem, i, match){
			return match[3] - 0 == i;
		}
	},
	filter: {
		PSEUDO: function(elem, match, i, array){
			var name = match[1], filter = Expr.filters[ name ];

			if ( filter ) {
				return filter( elem, i, match, array );
			} else if ( name === "contains" ) {
				return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0;
			} else if ( name === "not" ) {
				var not = match[3];

				for ( var i = 0, l = not.length; i < l; i++ ) {
					if ( not[i] === elem ) {
						return false;
					}
				}

				return true;
			}
		},
		CHILD: function(elem, match){
			var type = match[1], node = elem;
			switch (type) {
				case 'only':
				case 'first':
					while (node = node.previousSibling)  {
						if ( node.nodeType === 1 ) return false;
					}
					if ( type == 'first') return true;
					node = elem;
				case 'last':
					while (node = node.nextSibling)  {
						if ( node.nodeType === 1 ) return false;
					}
					return true;
				case 'nth':
					var first = match[2], last = match[3];

					if ( first == 1 && last == 0 ) {
						return true;
					}
					
					var doneName = match[0],
						parent = elem.parentNode;
	
					if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
						var count = 0;
						for ( node = parent.firstChild; node; node = node.nextSibling ) {
							if ( node.nodeType === 1 ) {
								node.nodeIndex = ++count;
							}
						} 
						parent.sizcache = doneName;
					}
					
					var diff = elem.nodeIndex - last;
					if ( first == 0 ) {
						return diff == 0;
					} else {
						return ( diff % first == 0 && diff / first >= 0 );
					}
			}
		},
		ID: function(elem, match){
			return elem.nodeType === 1 && elem.getAttribute("id") === match;
		},
		TAG: function(elem, match){
			return (match === "*" && elem.nodeType === 1) || elem.nodeName === match;
		},
		CLASS: function(elem, match){
			return (" " + (elem.className || elem.getAttribute("class")) + " ")
				.indexOf( match ) > -1;
		},
		ATTR: function(elem, match){
			var name = match[1],
				result = Expr.attrHandle[ name ] ?
					Expr.attrHandle[ name ]( elem ) :
					elem[ name ] != null ?
						elem[ name ] :
						elem.getAttribute( name ),
				value = result + "",
				type = match[2],
				check = match[4];

			return result == null ?
				type === "!=" :
				type === "=" ?
				value === check :
				type === "*=" ?
				value.indexOf(check) >= 0 :
				type === "~=" ?
				(" " + value + " ").indexOf(check) >= 0 :
				!check ?
				value && result !== false :
				type === "!=" ?
				value != check :
				type === "^=" ?
				value.indexOf(check) === 0 :
				type === "$=" ?
				value.substr(value.length - check.length) === check :
				type === "|=" ?
				value === check || value.substr(0, check.length + 1) === check + "-" :
				false;
		},
		POS: function(elem, match, i, array){
			var name = match[2], filter = Expr.setFilters[ name ];

			if ( filter ) {
				return filter( elem, i, match, array );
			}
		}
	}
};

var origPOS = Expr.match.POS;

for ( var type in Expr.match ) {
	Expr.match[ type ] = RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
}

var makeArray = function(array, results) {
	array = Array.prototype.slice.call( array );

	if ( results ) {
		results.push.apply( results, array );
		return results;
	}
	
	return array;
};

// Perform a simple check to determine if the browser is capable of
// converting a NodeList to an array using builtin methods.
try {
	Array.prototype.slice.call( document.documentElement.childNodes );

// Provide a fallback method if it does not work
} catch(e){
	makeArray = function(array, results) {
		var ret = results || [];

		if ( toString.call(array) === "[object Array]" ) {
			Array.prototype.push.apply( ret, array );
		} else {
			if ( typeof array.length === "number" ) {
				for ( var i = 0, l = array.length; i < l; i++ ) {
					ret.push( array[i] );
				}
			} else {
				for ( var i = 0; array[i]; i++ ) {
					ret.push( array[i] );
				}
			}
		}

		return ret;
	};
}

var sortOrder;

if ( document.documentElement.compareDocumentPosition ) {
	sortOrder = function( a, b ) {
		var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
		if ( ret === 0 ) {
			hasDuplicate = true;
		}
		return ret;
	};
} else if ( "sourceIndex" in document.documentElement ) {
	sortOrder = function( a, b ) {
		var ret = a.sourceIndex - b.sourceIndex;
		if ( ret === 0 ) {
			hasDuplicate = true;
		}
		return ret;
	};
} else if ( document.createRange ) {
	sortOrder = function( a, b ) {
		var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
		aRange.selectNode(a);
		aRange.collapse(true);
		bRange.selectNode(b);
		bRange.collapse(true);
		var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
		if ( ret === 0 ) {
			hasDuplicate = true;
		}
		return ret;
	};
}

// Check to see if the browser returns elements by name when
// querying by getElementById (and provide a workaround)
(function(){
	// We're going to inject a fake input element with a specified name
	var form = document.createElement("form"),
		id = "script" + (new Date).getTime();
	form.innerHTML = "<input name='" + id + "'/>";

	// Inject it into the root element, check its status, and remove it quickly
	var root = document.documentElement;
	root.insertBefore( form, root.firstChild );

	// The workaround has to do additional checks after a getElementById
	// Which slows things down for other browsers (hence the branching)
	if ( !!document.getElementById( id ) ) {
		Expr.find.ID = function(match, context, isXML){
			if ( typeof context.getElementById !== "undefined" && !isXML ) {
				var m = context.getElementById(match[1]);
				return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
			}
		};

		Expr.filter.ID = function(elem, match){
			var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
			return elem.nodeType === 1 && node && node.nodeValue === match;
		};
	}

	root.removeChild( form );
})();

(function(){
	// Check to see if the browser returns only elements
	// when doing getElementsByTagName("*")

	// Create a fake element
	var div = document.createElement("div");
	div.appendChild( document.createComment("") );

	// Make sure no comments are found
	if ( div.getElementsByTagName("*").length > 0 ) {
		Expr.find.TAG = function(match, context){
			var results = context.getElementsByTagName(match[1]);

			// Filter out possible comments
			if ( match[1] === "*" ) {
				var tmp = [];

				for ( var i = 0; results[i]; i++ ) {
					if ( results[i].nodeType === 1 ) {
						tmp.push( results[i] );
					}
				}

				results = tmp;
			}

			return results;
		};
	}

	// Check to see if an attribute returns normalized href attributes
	div.innerHTML = "<a href='#'></a>";
	if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
			div.firstChild.getAttribute("href") !== "#" ) {
		Expr.attrHandle.href = function(elem){
			return elem.getAttribute("href", 2);
		};
	}
})();

if ( document.querySelectorAll ) (function(){
	var oldSizzle = Sizzle, div = document.createElement("div");
	div.innerHTML = "<p class='TEST'></p>";

	// Safari can't handle uppercase or unicode characters when
	// in quirks mode.
	if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
		return;
	}
	
	Sizzle = function(query, context, extra, seed){
		context = context || document;

		// Only use querySelectorAll on non-XML documents
		// (ID selectors don't work in non-HTML documents)
		if ( !seed && context.nodeType === 9 && !isXML(context) ) {
			try {
				return makeArray( context.querySelectorAll(query), extra );
			} catch(e){}
		}
		
		return oldSizzle(query, context, extra, seed);
	};

	Sizzle.find = oldSizzle.find;
	Sizzle.filter = oldSizzle.filter;
	Sizzle.selectors = oldSizzle.selectors;
	Sizzle.matches = oldSizzle.matches;
})();

if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){
	var div = document.createElement("div");
	div.innerHTML = "<div class='test e'></div><div class='test'></div>";

	// Opera can't find a second classname (in 9.6)
	if ( div.getElementsByClassName("e").length === 0 )
		return;

	// Safari caches class attributes, doesn't catch changes (in 3.2)
	div.lastChild.className = "e";

	if ( div.getElementsByClassName("e").length === 1 )
		return;

	Expr.order.splice(1, 0, "CLASS");
	Expr.find.CLASS = function(match, context, isXML) {
		if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
			return context.getElementsByClassName(match[1]);
		}
	};
})();

function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
	var sibDir = dir == "previousSibling" && !isXML;
	for ( var i = 0, l = checkSet.length; i < l; i++ ) {
		var elem = checkSet[i];
		if ( elem ) {
			if ( sibDir && elem.nodeType === 1 ){
				elem.sizcache = doneName;
				elem.sizset = i;
			}
			elem = elem[dir];
			var match = false;

			while ( elem ) {
				if ( elem.sizcache === doneName ) {
					match = checkSet[elem.sizset];
					break;
				}

				if ( elem.nodeType === 1 && !isXML ){
					elem.sizcache = doneName;
					elem.sizset = i;
				}

				if ( elem.nodeName === cur ) {
					match = elem;
					break;
				}

				elem = elem[dir];
			}

			checkSet[i] = match;
		}
	}
}

function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
	var sibDir = dir == "previousSibling" && !isXML;
	for ( var i = 0, l = checkSet.length; i < l; i++ ) {
		var elem = checkSet[i];
		if ( elem ) {
			if ( sibDir && elem.nodeType === 1 ) {
				elem.sizcache = doneName;
				elem.sizset = i;
			}
			elem = elem[dir];
			var match = false;

			while ( elem ) {
				if ( elem.sizcache === doneName ) {
					match = checkSet[elem.sizset];
					break;
				}

				if ( elem.nodeType === 1 ) {
					if ( !isXML ) {
						elem.sizcache = doneName;
						elem.sizset = i;
					}
					if ( typeof cur !== "string" ) {
						if ( elem === cur ) {
							match = true;
							break;
						}

					} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
						match = elem;
						break;
					}
				}

				elem = elem[dir];
			}

			checkSet[i] = match;
		}
	}
}

var contains = document.compareDocumentPosition ?  function(a, b){
	return a.compareDocumentPosition(b) & 16;
} : function(a, b){
	return a !== b && (a.contains ? a.contains(b) : true);
};

var isXML = function(elem){
	return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" ||
		!!elem.ownerDocument && isXML( elem.ownerDocument );
};

var posProcess = function(selector, context){
	var tmpSet = [], later = "", match,
		root = context.nodeType ? [context] : context;

	// Position selectors must be done after the filter
	// And so must :not(positional) so we move all PSEUDOs to the end
	while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
		later += match[0];
		selector = selector.replace( Expr.match.PSEUDO, "" );
	}

	selector = Expr.relative[selector] ? selector + "*" : selector;

	for ( var i = 0, l = root.length; i < l; i++ ) {
		Sizzle( selector, root[i], tmpSet );
	}

	return Sizzle.filter( later, tmpSet );
};

// EXPOSE
jQuery.find = Sizzle;
jQuery.filter = Sizzle.filter;
jQuery.expr = Sizzle.selectors;
jQuery.expr[":"] = jQuery.expr.filters;

Sizzle.selectors.filters.hidden = function(elem){
	return elem.offsetWidth === 0 || elem.offsetHeight === 0;
};

Sizzle.selectors.filters.visible = function(elem){
	return elem.offsetWidth > 0 || elem.offsetHeight > 0;
};

Sizzle.selectors.filters.animated = function(elem){
	return jQuery.grep(jQuery.timers, function(fn){
		return elem === fn.elem;
	}).length;
};

jQuery.multiFilter = function( expr, elems, not ) {
	if ( not ) {
		expr = ":not(" + expr + ")";
	}

	return Sizzle.matches(expr, elems);
};

jQuery.dir = function( elem, dir ){
	var matched = [], cur = elem[dir];
	while ( cur && cur != document ) {
		if ( cur.nodeType == 1 )
			matched.push( cur );
		cur = cur[dir];
	}
	return matched;
};

jQuery.nth = function(cur, result, dir, elem){
	result = result || 1;
	var num = 0;

	for ( ; cur; cur = cur[dir] )
		if ( cur.nodeType == 1 && ++num == result )
			break;

	return cur;
};

jQuery.sibling = function(n, elem){
	var r = [];

	for ( ; n; n = n.nextSibling ) {
		if ( n.nodeType == 1 && n != elem )
			r.push( n );
	}

	return r;
};

return;

window.Sizzle = Sizzle;

})();
/*
 * A number of helper functions used for managing events.
 * Many of the ideas behind this code originated from
 * Dean Edwards' addEvent library.
 */
jQuery.event = {

	// Bind an event to an element
	// Original by Dean Edwards
	add: function(elem, types, handler, data) {
		if ( elem.nodeType == 3 || elem.nodeType == 8 )
			return;

		// For whatever reason, IE has trouble passing the window object
		// around, causing it to be cloned in the process
		if ( elem.setInterval && elem != window )
			elem = window;

		// Make sure that the function being executed has a unique ID
		if ( !handler.guid )
			handler.guid = this.guid++;

		// if data is passed, bind to handler
		if ( data !== undefined ) {
			// Create temporary function pointer to original handler
			var fn = handler;

			// Create unique handler function, wrapped around original handler
			handler = this.proxy( fn );

			// Store data in unique handler
			handler.data = data;
		}

		// Init the element's event structure
		var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}),
			handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){
				// Handle the second event of a trigger and when
				// an event is called after a page has unloaded
				return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
					jQuery.event.handle.apply(arguments.callee.elem, arguments) :
					undefined;
			});
		// Add elem as a property of the handle function
		// This is to prevent a memory leak with non-native
		// event in IE.
		handle.elem = elem;

		// Handle multiple events separated by a space
		// jQuery(...).bind("mouseover mouseout", fn);
		jQuery.each(types.split(/\s+/), function(index, type) {
			// Namespaced event handlers
			var namespaces = type.split(".");
			type = namespaces.shift();
			handler.type = namespaces.slice().sort().join(".");

			// Get the current list of functions bound to this event
			var handlers = events[type];
			
			if ( jQuery.event.specialAll[type] )
				jQuery.event.specialAll[type].setup.call(elem, data, namespaces);

			// Init the event handler queue
			if (!handlers) {
				handlers = events[type] = {};

				// Check for a special event handler
				// Only use addEventListener/attachEvent if the special
				// events handler returns false
				if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem, data, namespaces) === false ) {
					// Bind the global event handler to the element
					if (elem.addEventListener)
						elem.addEventListener(type, handle, false);
					else if (elem.attachEvent)
						elem.attachEvent("on" + type, handle);
				}
			}

			// Add the function to the element's handler list
			handlers[handler.guid] = handler;

			// Keep track of which events have been used, for global triggering
			jQuery.event.global[type] = true;
		});

		// Nullify elem to prevent memory leaks in IE
		elem = null;
	},

	guid: 1,
	global: {},

	// Detach an event or set of events from an element
	remove: function(elem, types, handler) {
		// don't do events on text and comment nodes
		if ( elem.nodeType == 3 || elem.nodeType == 8 )
			return;

		var events = jQuery.data(elem, "events"), ret, index;

		if ( events ) {
			// Unbind all events for the element
			if ( types === undefined || (typeof types === "string" && types.charAt(0) == ".") )
				for ( var type in events )
					this.remove( elem, type + (types || "") );
			else {
				// types is actually an event object here
				if ( types.type ) {
					handler = types.handler;
					types = types.type;
				}

				// Handle multiple events seperated by a space
				// jQuery(...).unbind("mouseover mouseout", fn);
				jQuery.each(types.split(/\s+/), function(index, type){
					// Namespaced event handlers
					var namespaces = type.split(".");
					type = namespaces.shift();
					var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");

					if ( events[type] ) {
						// remove the given handler for the given type
						if ( handler )
							delete events[type][handler.guid];

						// remove all handlers for the given type
						else
							for ( var handle in events[type] )
								// Handle the removal of namespaced events
								if ( namespace.test(events[type][handle].type) )
									delete events[type][handle];
									
						if ( jQuery.event.specialAll[type] )
							jQuery.event.specialAll[type].teardown.call(elem, namespaces);

						// remove generic event handler if no more handlers exist
						for ( ret in events[type] ) break;
						if ( !ret ) {
							if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem, namespaces) === false ) {
								if (elem.removeEventListener)
									elem.removeEventListener(type, jQuery.data(elem, "handle"), false);
								else if (elem.detachEvent)
									elem.detachEvent("on" + type, jQuery.data(elem, "handle"));
							}
							ret = null;
							delete events[type];
						}
					}
				});
			}

			// Remove the expando if it's no longer used
			for ( ret in events ) break;
			if ( !ret ) {
				var handle = jQuery.data( elem, "handle" );
				if ( handle ) handle.elem = null;
				jQuery.removeData( elem, "events" );
				jQuery.removeData( elem, "handle" );
			}
		}
	},

	// bubbling is internal
	trigger: function( event, data, elem, bubbling ) {
		// Event object or event type
		var type = event.type || event;

		if( !bubbling ){
			event = typeof event === "object" ?
				// jQuery.Event object
				event[expando] ? event :
				// Object literal
				jQuery.extend( jQuery.Event(type), event ) :
				// Just the event type (string)
				jQuery.Event(type);

			if ( type.indexOf("!") >= 0 ) {
				event.type = type = type.slice(0, -1);
				event.exclusive = true;
			}

			// Handle a global trigger
			if ( !elem ) {
				// Don't bubble custom events when global (to avoid too much overhead)
				event.stopPropagation();
				// Only trigger if we've ever bound an event for it
				if ( this.global[type] )
					jQuery.each( jQuery.cache, function(){
						if ( this.events && this.events[type] )
							jQuery.event.trigger( event, data, this.handle.elem );
					});
			}

			// Handle triggering a single element

			// don't do events on text and comment nodes
			if ( !elem || elem.nodeType == 3 || elem.nodeType == 8 )
				return undefined;
			
			// Clean up in case it is reused
			event.result = undefined;
			event.target = elem;
			
			// Clone the incoming data, if any
			data = jQuery.makeArray(data);
			data.unshift( event );
		}

		event.currentTarget = elem;

		// Trigger the event, it is assumed that "handle" is a function
		var handle = jQuery.data(elem, "handle");
		if ( handle )
			handle.apply( elem, data );

		// Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
		if ( (!elem[type] || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
			event.result = false;

		// Trigger the native events (except for clicks on links)
		if ( !bubbling && elem[type] && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type == "click") ) {
			this.triggered = true;
			try {
				elem[ type ]();
			// prevent IE from throwing an error for some hidden elements
			} catch (e) {}
		}

		this.triggered = false;

		if ( !event.isPropagationStopped() ) {
			var parent = elem.parentNode || elem.ownerDocument;
			if ( parent )
				jQuery.event.trigger(event, data, parent, true);
		}
	},

	handle: function(event) {
		// returned undefined or false
		var all, handlers;

		event = arguments[0] = jQuery.event.fix( event || window.event );
		event.currentTarget = this;
		
		// Namespaced event handlers
		var namespaces = event.type.split(".");
		event.type = namespaces.shift();

		// Cache this now, all = true means, any handler
		all = !namespaces.length && !event.exclusive;
		
		var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");

		handlers = ( jQuery.data(this, "events") || {} )[event.type];

		for ( var j in handlers ) {
			var handler = handlers[j];

			// Filter the functions by class
			if ( all || namespace.test(handler.type) ) {
				// Pass in a reference to the handler function itself
				// So that we can later remove it
				event.handler = handler;
				event.data = handler.data;

				var ret = handler.apply(this, arguments);

				if( ret !== undefined ){
					event.result = ret;
					if ( ret === false ) {
						event.preventDefault();
						event.stopPropagation();
					}
				}

				if( event.isImmediatePropagationStopped() )
					break;

			}
		}
	},

	props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),

	fix: function(event) {
		if ( event[expando] )
			return event;

		// store a copy of the original event object
		// and "clone" to set read-only properties
		var originalEvent = event;
		event = jQuery.Event( originalEvent );

		for ( var i = this.props.length, prop; i; ){
			prop = this.props[ --i ];
			event[ prop ] = originalEvent[ prop ];
		}

		// Fix target property, if necessary
		if ( !event.target )
			event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either

		// check if target is a textnode (safari)
		if ( event.target.nodeType == 3 )
			event.target = event.target.parentNode;

		// Add relatedTarget, if necessary
		if ( !event.relatedTarget && event.fromElement )
			event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;

		// Calculate pageX/Y if missing and clientX/Y available
		if ( event.pageX == null && event.clientX != null ) {
			var doc = document.documentElement, body = document.body;
			event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
			event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0);
		}

		// Add which for key events
		if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) )
			event.which = event.charCode || event.keyCode;

		// Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
		if ( !event.metaKey && event.ctrlKey )
			event.metaKey = event.ctrlKey;

		// Add which for click: 1 == left; 2 == middle; 3 == right
		// Note: button is not normalized, so don't use it
		if ( !event.which && event.button )
			event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));

		return event;
	},

	proxy: function( fn, proxy ){
		proxy = proxy || function(){ return fn.apply(this, arguments); };
		// Set the guid of unique handler to the same of original handler, so it can be removed
		proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++;
		// So proxy can be declared as an argument
		return proxy;
	},

	special: {
		ready: {
			// Make sure the ready event is setup
			setup: bindReady,
			teardown: function() {}
		}
	},
	
	specialAll: {
		live: {
			setup: function( selector, namespaces ){
				jQuery.event.add( this, namespaces[0], liveHandler );
			},
			teardown:  function( namespaces ){
				if ( namespaces.length ) {
					var remove = 0, name = RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
					
					jQuery.each( (jQuery.data(this, "events").live || {}), function(){
						if ( name.test(this.type) )
							remove++;
					});
					
					if ( remove < 1 )
						jQuery.event.remove( this, namespaces[0], liveHandler );
				}
			}
		}
	}
};

jQuery.Event = function( src ){
	// Allow instantiation without the 'new' keyword
	if( !this.preventDefault )
		return new jQuery.Event(src);
	
	// Event object
	if( src && src.type ){
		this.originalEvent = src;
		this.type = src.type;
	// Event type
	}else
		this.type = src;

	// timeStamp is buggy for some events on Firefox(#3843)
	// So we won't rely on the native value
	this.timeStamp = now();
	
	// Mark it as fixed
	this[expando] = true;
};

function returnFalse(){
	return false;
}
function returnTrue(){
	return true;
}

// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
jQuery.Event.prototype = {
	preventDefault: function() {
		this.isDefaultPrevented = returnTrue;

		var e = this.originalEvent;
		if( !e )
			return;
		// if preventDefault exists run it on the original event
		if (e.preventDefault)
			e.preventDefault();
		// otherwise set the returnValue property of the original event to false (IE)
		e.returnValue = false;
	},
	stopPropagation: function() {
		this.isPropagationStopped = returnTrue;

		var e = this.originalEvent;
		if( !e )
			return;
		// if stopPropagation exists run it on the original event
		if (e.stopPropagation)
			e.stopPropagation();
		// otherwise set the cancelBubble property of the original event to true (IE)
		e.cancelBubble = true;
	},
	stopImmediatePropagation:function(){
		this.isImmediatePropagationStopped = returnTrue;
		this.stopPropagation();
	},
	isDefaultPrevented: returnFalse,
	isPropagationStopped: returnFalse,
	isImmediatePropagationStopped: returnFalse
};
// Checks if an event happened on an element within another element
// Used in jQuery.event.special.mouseenter and mouseleave handlers
var withinElement = function(event) {
	// Check if mouse(over|out) are still within the same parent element
	var parent = event.relatedTarget;
	// Traverse up the tree
	while ( parent && parent != this )
		try { parent = parent.parentNode; }
		catch(e) { parent = this; }
	
	if( parent != this ){
		// set the correct event type
		event.type = event.data;
		// handle event if we actually just moused on to a non sub-element
		jQuery.event.handle.apply( this, arguments );
	}
};
	
jQuery.each({ 
	mouseover: 'mouseenter', 
	mouseout: 'mouseleave'
}, function( orig, fix ){
	jQuery.event.special[ fix ] = {
		setup: function(){
			jQuery.event.add( this, orig, withinElement, fix );
		},
		teardown: function(){
			jQuery.event.remove( this, orig, withinElement );
		}
	};			   
});

jQuery.fn.extend({
	bind: function( type, data, fn ) {
		return type == "unload" ? this.one(type, data, fn) : this.each(function(){
			jQuery.event.add( this, type, fn || data, fn && data );
		});
	},

	one: function( type, data, fn ) {
		var one = jQuery.event.proxy( fn || data, function(event) {
			jQuery(this).unbind(event, one);
			return (fn || data).apply( this, arguments );
		});
		return this.each(function(){
			jQuery.event.add( this, type, one, fn && data);
		});
	},

	unbind: function( type, fn ) {
		return this.each(function(){
			jQuery.event.remove( this, type, fn );
		});
	},

	trigger: function( type, data ) {
		return this.each(function(){
			jQuery.event.trigger( type, data, this );
		});
	},

	triggerHandler: function( type, data ) {
		if( this[0] ){
			var event = jQuery.Event(type);
			event.preventDefault();
			event.stopPropagation();
			jQuery.event.trigger( event, data, this[0] );
			return event.result;
		}		
	},

	toggle: function( fn ) {
		// Save reference to arguments for access in closure
		var args = arguments, i = 1;

		// link all the functions, so any of them can unbind this click handler
		while( i < args.length )
			jQuery.event.proxy( fn, args[i++] );

		return this.click( jQuery.event.proxy( fn, function(event) {
			// Figure out which function to execute
			this.lastToggle = ( this.lastToggle || 0 ) % i;

			// Make sure that clicks stop
			event.preventDefault();

			// and execute the function
			return args[ this.lastToggle++ ].apply( this, arguments ) || false;
		}));
	},

	hover: function(fnOver, fnOut) {
		return this.mouseenter(fnOver).mouseleave(fnOut);
	},

	ready: function(fn) {
		// Attach the listeners
		bindReady();

		// If the DOM is already ready
		if ( jQuery.isReady )
			// Execute the function immediately
			fn.call( document, jQuery );

		// Otherwise, remember the function for later
		else
			// Add the function to the wait list
			jQuery.readyList.push( fn );

		return this;
	},
	
	live: function( type, fn ){
		var proxy = jQuery.event.proxy( fn );
		proxy.guid += this.selector + type;

		jQuery(document).bind( liveConvert(type, this.selector), this.selector, proxy );

		return this;
	},
	
	die: function( type, fn ){
		jQuery(document).unbind( liveConvert(type, this.selector), fn ? { guid: fn.guid + this.selector + type } : null );
		return this;
	}
});

function liveHandler( event ){
	var check = RegExp("(^|\\.)" + event.type + "(\\.|$)"),
		stop = true,
		elems = [];

	jQuery.each(jQuery.data(this, "events").live || [], function(i, fn){
		if ( check.test(fn.type) ) {
			var elem = jQuery(event.target).closest(fn.data)[0];
			if ( elem )
				elems.push({ elem: elem, fn: fn });
		}
	});

	elems.sort(function(a,b) {
		return jQuery.data(a.elem, "closest") - jQuery.data(b.elem, "closest");
	});
	
	jQuery.each(elems, function(){
		if ( this.fn.call(this.elem, event, this.fn.data) === false )
			return (stop = false);
	});

	return stop;
}

function liveConvert(type, selector){
	return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join(".");
}

jQuery.extend({
	isReady: false,
	readyList: [],
	// Handle when the DOM is ready
	ready: function() {
		// Make sure that the DOM is not already loaded
		if ( !jQuery.isReady ) {
			// Remember that the DOM is ready
			jQuery.isReady = true;

			// If there are functions bound, to execute
			if ( jQuery.readyList ) {
				// Execute all of them
				jQuery.each( jQuery.readyList, function(){
					this.call( document, jQuery );
				});

				// Reset the list of functions
				jQuery.readyList = null;
			}

			// Trigger any bound ready events
			jQuery(document).triggerHandler("ready");
		}
	}
});

var readyBound = false;

function bindReady(){
	if ( readyBound ) return;
	readyBound = true;

	// Mozilla, Opera and webkit nightlies currently support this event
	if ( document.addEventListener ) {
		// Use the handy event callback
		document.addEventListener( "DOMContentLoaded", function(){
			document.removeEventListener( "DOMContentLoaded", arguments.callee, false );
			jQuery.ready();
		}, false );

	// If IE event model is used
	} else if ( document.attachEvent ) {
		// ensure firing before onload,
		// maybe late but safe also for iframes
		document.attachEvent("onreadystatechange", function(){
			if ( document.readyState === "complete" ) {
				document.detachEvent( "onreadystatechange", arguments.callee );
				jQuery.ready();
			}
		});

		// If IE and not an iframe
		// continually check to see if the document is ready
		if ( document.documentElement.doScroll && window == window.top ) (function(){
			if ( jQuery.isReady ) return;

			try {
				// If IE is used, use the trick by Diego Perini
				// http://javascript.nwbox.com/IEContentLoaded/
				document.documentElement.doScroll("left");
			} catch( error ) {
				setTimeout( arguments.callee, 0 );
				return;
			}

			// and execute any waiting functions
			jQuery.ready();
		})();
	}

	// A fallback to window.onload, that will always work
	jQuery.event.add( window, "load", jQuery.ready );
}

jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
	"mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," +
	"change,select,submit,keydown,keypress,keyup,error").split(","), function(i, name){

	// Handle event binding
	jQuery.fn[name] = function(fn){
		return fn ? this.bind(name, fn) : this.trigger(name);
	};
});

// Prevent memory leaks in IE
// And prevent errors on refresh with events like mouseover in other browsers
// Window isn't included so as not to unbind existing unload events
jQuery( window ).bind( 'unload', function(){ 
	for ( var id in jQuery.cache )
		// Skip the window
		if ( id != 1 && jQuery.cache[ id ].handle )
			jQuery.event.remove( jQuery.cache[ id ].handle.elem );
}); 
(function(){

	jQuery.support = {};

	var root = document.documentElement,
		script = document.createElement("script"),
		div = document.createElement("div"),
		id = "script" + (new Date).getTime();

	div.style.display = "none";
	div.innerHTML = '   <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>';

	var all = div.getElementsByTagName("*"),
		a = div.getElementsByTagName("a")[0];

	// Can't get basic test support
	if ( !all || !all.length || !a ) {
		return;
	}

	jQuery.support = {
		// IE strips leading whitespace when .innerHTML is used
		leadingWhitespace: div.firstChild.nodeType == 3,
		
		// Make sure that tbody elements aren't automatically inserted
		// IE will insert them into empty tables
		tbody: !div.getElementsByTagName("tbody").length,
		
		// Make sure that you can get all elements in an <object> element
		// IE 7 always returns no results
		objectAll: !!div.getElementsByTagName("object")[0]
			.getElementsByTagName("*").length,
		
		// Make sure that link elements get serialized correctly by innerHTML
		// This requires a wrapper element in IE
		htmlSerialize: !!div.getElementsByTagName("link").length,
		
		// Get the style information from getAttribute
		// (IE uses .cssText insted)
		style: /red/.test( a.getAttribute("style") ),
		
		// Make sure that URLs aren't manipulated
		// (IE normalizes it by default)
		hrefNormalized: a.getAttribute("href") === "/a",
		
		// Make sure that element opacity exists
		// (IE uses filter instead)
		opacity: a.style.opacity === "0.5",
		
		// Verify style float existence
		// (IE uses styleFloat instead of cssFloat)
		cssFloat: !!a.style.cssFloat,

		// Will be defined later
		scriptEval: false,
		noCloneEvent: true,
		boxModel: null
	};
	
	script.type = "text/javascript";
	try {
		script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
	} catch(e){}

	root.insertBefore( script, root.firstChild );
	
	// Make sure that the execution of code works by injecting a script
	// tag with appendChild/createTextNode
	// (IE doesn't support this, fails, and uses .text instead)
	if ( window[ id ] ) {
		jQuery.support.scriptEval = true;
		delete window[ id ];
	}

	root.removeChild( script );

	if ( div.attachEvent && div.fireEvent ) {
		div.attachEvent("onclick", function(){
			// Cloning a node shouldn't copy over any
			// bound event handlers (IE does this)
			jQuery.support.noCloneEvent = false;
			div.detachEvent("onclick", arguments.callee);
		});
		div.cloneNode(true).fireEvent("onclick");
	}

	// Figure out if the W3C box model works as expected
	// document.body must exist before we can do this
	jQuery(function(){
		var div = document.createElement("div");
		div.style.width = div.style.paddingLeft = "1px";

		document.body.appendChild( div );
		jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
		document.body.removeChild( div ).style.display = 'none';
	});
})();

var styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat";

jQuery.props = {
	"for": "htmlFor",
	"class": "className",
	"float": styleFloat,
	cssFloat: styleFloat,
	styleFloat: styleFloat,
	readonly: "readOnly",
	maxlength: "maxLength",
	cellspacing: "cellSpacing",
	rowspan: "rowSpan",
	tabindex: "tabIndex"
};
jQuery.fn.extend({
	// Keep a copy of the old load
	_load: jQuery.fn.load,

	load: function( url, params, callback ) {
		if ( typeof url !== "string" )
			return this._load( url );

		var off = url.indexOf(" ");
		if ( off >= 0 ) {
			var selector = url.slice(off, url.length);
			url = url.slice(0, off);
		}

		// Default to a GET request
		var type = "GET";

		// If the second parameter was provided
		if ( params )
			// If it's a function
			if ( jQuery.isFunction( params ) ) {
				// We assume that it's the callback
				callback = params;
				params = null;

			// Otherwise, build a param string
			} else if( typeof params === "object" ) {
				params = jQuery.param( params );
				type = "POST";
			}

		var self = this;

		// Request the remote document
		jQuery.ajax({
			url: url,
			type: type,
			dataType: "html",
			data: params,
			complete: function(res, status){
				// If successful, inject the HTML into all the matched elements
				if ( status == "success" || status == "notmodified" )
					// See if a selector was specified
					self.html( selector ?
						// Create a dummy div to hold the results
						jQuery("<div/>")
							// inject the contents of the document in, removing the scripts
							// to avoid any 'Permission Denied' errors in IE
							.append(res.responseText.replace(/<script(.|\s)*?\/script>/g, ""))

							// Locate the specified elements
							.find(selector) :

						// If not, just inject the full result
						res.responseText );

				if( callback )
					self.each( callback, [res.responseText, status, res] );
			}
		});
		return this;
	},

	serialize: function() {
		return jQuery.param(this.serializeArray());
	},
	serializeArray: function() {
		return this.map(function(){
			return this.elements ? jQuery.makeArray(this.elements) : this;
		})
		.filter(function(){
			return this.name && !this.disabled &&
				(this.checked || /select|textarea/i.test(this.nodeName) ||
					/text|hidden|password|search/i.test(this.type));
		})
		.map(function(i, elem){
			var val = jQuery(this).val();
			return val == null ? null :
				jQuery.isArray(val) ?
					jQuery.map( val, function(val, i){
						return {name: elem.name, value: val};
					}) :
					{name: elem.name, value: val};
		}).get();
	}
});

// Attach a bunch of functions for handling common AJAX events
jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){
	jQuery.fn[o] = function(f){
		return this.bind(o, f);
	};
});

var jsc = now();

jQuery.extend({
  
	get: function( url, data, callback, type ) {
		// shift arguments if data argument was ommited
		if ( jQuery.isFunction( data ) ) {
			callback = data;
			data = null;
		}

		return jQuery.ajax({
			type: "GET",
			url: url,
			data: data,
			success: callback,
			dataType: type
		});
	},

	getScript: function( url, callback ) {
		return jQuery.get(url, null, callback, "script");
	},

	getJSON: function( url, data, callback ) {
		return jQuery.get(url, data, callback, "json");
	},

	post: function( url, data, callback, type ) {
		if ( jQuery.isFunction( data ) ) {
			callback = data;
			data = {};
		}

		return jQuery.ajax({
			type: "POST",
			url: url,
			data: data,
			success: callback,
			dataType: type
		});
	},

	ajaxSetup: function( settings ) {
		jQuery.extend( jQuery.ajaxSettings, settings );
	},

	ajaxSettings: {
		url: location.href,
		global: true,
		type: "GET",
		contentType: "application/x-www-form-urlencoded",
		processData: true,
		async: true,
		/*
		timeout: 0,
		data: null,
		username: null,
		password: null,
		*/
		// Create the request object; Microsoft failed to properly
		// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
		// This function can be overriden by calling jQuery.ajaxSetup
		xhr:function(){
			return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
		},
		accepts: {
			xml: "application/xml, text/xml",
			html: "text/html",
			script: "text/javascript, application/javascript",
			json: "application/json, text/javascript",
			text: "text/plain",
			_default: "*/*"
		}
	},

	// Last-Modified header cache for next request
	lastModified: {},

	ajax: function( s ) {
		// Extend the settings, but re-extend 's' so that it can be
		// checked again later (in the test suite, specifically)
		s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));

		var jsonp, jsre = /=\?(&|$)/g, status, data,
			type = s.type.toUpperCase();

		// convert data if not already a string
		if ( s.data && s.processData && typeof s.data !== "string" )
			s.data = jQuery.param(s.data);

		// Handle JSONP Parameter Callbacks
		if ( s.dataType == "jsonp" ) {
			if ( type == "GET" ) {
				if ( !s.url.match(jsre) )
					s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?";
			} else if ( !s.data || !s.data.match(jsre) )
				s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
			s.dataType = "json";
		}

		// Build temporary JSONP function
		if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) {
			jsonp = "jsonp" + jsc++;

			// Replace the =? sequence both in the query string and the data
			if ( s.data )
				s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
			s.url = s.url.replace(jsre, "=" + jsonp + "$1");

			// We need to make sure
			// that a JSONP style response is executed properly
			s.dataType = "script";

			// Handle JSONP-style loading
			window[ jsonp ] = function(tmp){
				data = tmp;
				success();
				complete();
				// Garbage collect
				window[ jsonp ] = undefined;
				try{ delete window[ jsonp ]; } catch(e){}
				if ( head )
					head.removeChild( script );
			};
		}

		if ( s.dataType == "script" && s.cache == null )
			s.cache = false;

		if ( s.cache === false && type == "GET" ) {
			var ts = now();
			// try replacing _= if it is there
			var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2");
			// if nothing was replaced, add timestamp to the end
			s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : "");
		}

		// If data is available, append data to url for get requests
		if ( s.data && type == "GET" ) {
			s.url += (s.url.match(/\?/) ? "&" : "?") + s.data;

			// IE likes to send both get and post data, prevent this
			s.data = null;
		}

		// Watch for a new set of requests
		if ( s.global && ! jQuery.active++ )
			jQuery.event.trigger( "ajaxStart" );

		// Matches an absolute URL, and saves the domain
		var parts = /^(\w+:)?\/\/([^\/?#]+)/.exec( s.url );

		// If we're requesting a remote document
		// and trying to load JSON or Script with a GET
		if ( s.dataType == "script" && type == "GET" && parts
			&& ( parts[1] && parts[1] != location.protocol || parts[2] != location.host )){

			var head = document.getElementsByTagName("head")[0];
			var script = document.createElement("script");
			script.src = s.url;
			if (s.scriptCharset)
				script.charset = s.scriptCharset;

			// Handle Script loading
			if ( !jsonp ) {
				var done = false;

				// Attach handlers for all browsers
				script.onload = script.onreadystatechange = function(){
					if ( !done && (!this.readyState ||
							this.readyState == "loaded" || this.readyState == "complete") ) {
						done = true;
						success();
						complete();

						// Handle memory leak in IE
						script.onload = script.onreadystatechange = null;
						head.removeChild( script );
					}
				};
			}

			head.appendChild(script);

			// We handle everything using the script element injection
			return undefined;
		}

		var requestDone = false;

		// Create the request object
		var xhr = s.xhr();

		// Open the socket
		// Passing null username, generates a login popup on Opera (#2865)
		if( s.username )
			xhr.open(type, s.url, s.async, s.username, s.password);
		else
			xhr.open(type, s.url, s.async);

		// Need an extra try/catch for cross domain requests in Firefox 3
		try {
			// Set the correct header, if data is being sent
			if ( s.data )
				xhr.setRequestHeader("Content-Type", s.contentType);

			// Set the If-Modified-Since header, if ifModified mode.
			if ( s.ifModified )
				xhr.setRequestHeader("If-Modified-Since",
					jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );

			// Set header so the called script knows that it's an XMLHttpRequest
			xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");

			// Set the Accepts header for the server, depending on the dataType
			xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
				s.accepts[ s.dataType ] + ", */*" :
				s.accepts._default );
		} catch(e){}

		// Allow custom headers/mimetypes and early abort
		if ( s.beforeSend && s.beforeSend(xhr, s) === false ) {
			// Handle the global AJAX counter
			if ( s.global && ! --jQuery.active )
				jQuery.event.trigger( "ajaxStop" );
			// close opended socket
			xhr.abort();
			return false;
		}

		if ( s.global )
			jQuery.event.trigger("ajaxSend", [xhr, s]);

		// Wait for a response to come back
		var onreadystatechange = function(isTimeout){
			// The request was aborted, clear the interval and decrement jQuery.active
			if (xhr.readyState == 0) {
				if (ival) {
					// clear poll interval
					clearInterval(ival);
					ival = null;
					// Handle the global AJAX counter
					if ( s.global && ! --jQuery.active )
						jQuery.event.trigger( "ajaxStop" );
				}
			// The transfer is complete and the data is available, or the request timed out
			} else if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) {
				requestDone = true;

				// clear poll interval
				if (ival) {
					clearInterval(ival);
					ival = null;
				}

				status = isTimeout == "timeout" ? "timeout" :
					!jQuery.httpSuccess( xhr ) ? "error" :
					s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? "notmodified" :
					"success";

				if ( status == "success" ) {
					// Watch for, and catch, XML document parse errors
					try {
						// process the data (runs the xml through httpData regardless of callback)
						data = jQuery.httpData( xhr, s.dataType, s );
					} catch(e) {
						status = "parsererror";
					}
				}

				// Make sure that the request was successful or notmodified
				if ( status == "success" ) {
					// Cache Last-Modified header, if ifModified mode.
					var modRes;
					try {
						modRes = xhr.getResponseHeader("Last-Modified");
					} catch(e) {} // swallow exception thrown by FF if header is not available

					if ( s.ifModified && modRes )
						jQuery.lastModified[s.url] = modRes;

					// JSONP handles its own success callback
					if ( !jsonp )
						success();
				} else
					jQuery.handleError(s, xhr, status);

				// Fire the complete handlers
				complete();

				if ( isTimeout )
					xhr.abort();

				// Stop memory leaks
				if ( s.async )
					xhr = null;
			}
		};

		if ( s.async ) {
			// don't attach the handler to the request, just poll it instead
			var ival = setInterval(onreadystatechange, 13);

			// Timeout checker
			if ( s.timeout > 0 )
				setTimeout(function(){
					// Check to see if the request is still happening
					if ( xhr && !requestDone )
						onreadystatechange( "timeout" );
				}, s.timeout);
		}

		// Send the data
		try {
			xhr.send(s.data);
		} catch(e) {
			jQuery.handleError(s, xhr, null, e);
		}

		// firefox 1.5 doesn't fire statechange for sync requests
		if ( !s.async )
			onreadystatechange();

		function success(){
			// If a local callback was specified, fire it and pass it the data
			if ( s.success )
				s.success( data, status );

			// Fire the global callback
			if ( s.global )
				jQuery.event.trigger( "ajaxSuccess", [xhr, s] );
		}

		function complete(){
			// Process result
			if ( s.complete )
				s.complete(xhr, status);

			// The request was completed
			if ( s.global )
				jQuery.event.trigger( "ajaxComplete", [xhr, s] );

			// Handle the global AJAX counter
			if ( s.global && ! --jQuery.active )
				jQuery.event.trigger( "ajaxStop" );
		}

		// return XMLHttpRequest to allow aborting the request etc.
		return xhr;
	},

	handleError: function( s, xhr, status, e ) {
		// If a local callback was specified, fire it
		if ( s.error ) s.error( xhr, status, e );

		// Fire the global callback
		if ( s.global )
			jQuery.event.trigger( "ajaxError", [xhr, s, e] );
	},

	// Counter for holding the number of active queries
	active: 0,

	// Determines if an XMLHttpRequest was successful or not
	httpSuccess: function( xhr ) {
		try {
			// IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
			return !xhr.status && location.protocol == "file:" ||
				( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223;
		} catch(e){}
		return false;
	},

	// Determines if an XMLHttpRequest returns NotModified
	httpNotModified: function( xhr, url ) {
		try {
			var xhrRes = xhr.getResponseHeader("Last-Modified");

			// Firefox always returns 200. check Last-Modified date
			return xhr.status == 304 || xhrRes == jQuery.lastModified[url];
		} catch(e){}
		return false;
	},

	httpData: function( xhr, type, s ) {
		var ct = xhr.getResponseHeader("content-type"),
			xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
			data = xml ? xhr.responseXML : xhr.responseText;

		if ( xml && data.documentElement.tagName == "parsererror" )
			throw "parsererror";
			
		// Allow a pre-filtering function to sanitize the response
		// s != null is checked to keep backwards compatibility
		if( s && s.dataFilter )
			data = s.dataFilter( data, type );

		// The filter can actually parse the response
		if( typeof data === "string" ){

			// If the type is "script", eval it in global context
			if ( type == "script" )
				jQuery.globalEval( data );

			// Get the JavaScript object, if JSON is used.
			if ( type == "json" )
				data = window["eval"]("(" + data + ")");
		}
		
		return data;
	},

	// Serialize an array of form elements or a set of
	// key/values into a query string
	param: function( a ) {
		var s = [ ];

		function add( key, value ){
			s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value);
		};

		// If an array was passed in, assume that it is an array
		// of form elements
		if ( jQuery.isArray(a) || a.jquery )
			// Serialize the form elements
			jQuery.each( a, function(){
				add( this.name, this.value );
			});

		// Otherwise, assume that it's an object of key/value pairs
		else
			// Serialize the key/values
			for ( var j in a )
				// If the value is an array then the key names need to be repeated
				if ( jQuery.isArray(a[j]) )
					jQuery.each( a[j], function(){
						add( j, this );
					});
				else
					add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] );

		// Return the resulting serialization
		return s.join("&").replace(/%20/g, "+");
	}

});
var elemdisplay = {},
	timerId,
	fxAttrs = [
		// height animations
		[ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
		// width animations
		[ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
		// opacity animations
		[ "opacity" ]
	];

function genFx( type, num ){
	var obj = {};
	jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function(){
		obj[ this ] = type;
	});
	return obj;
}

jQuery.fn.extend({
	show: function(speed,callback){
		if ( speed ) {
			return this.animate( genFx("show", 3), speed, callback);
		} else {
			for ( var i = 0, l = this.length; i < l; i++ ){
				var old = jQuery.data(this[i], "olddisplay");
				
				this[i].style.display = old || "";
				
				if ( jQuery.css(this[i], "display") === "none" ) {
					var tagName = this[i].tagName, display;
					
					if ( elemdisplay[ tagName ] ) {
						display = elemdisplay[ tagName ];
					} else {
						var elem = jQuery("<" + tagName + " />").appendTo("body");
						
						display = elem.css("display");
						if ( display === "none" )
							display = "block";
						
						elem.remove();
						
						elemdisplay[ tagName ] = display;
					}
					
					jQuery.data(this[i], "olddisplay", display);
				}
			}

			// Set the display of the elements in a second loop
			// to avoid the constant reflow
			for ( var i = 0, l = this.length; i < l; i++ ){
				this[i].style.display = jQuery.data(this[i], "olddisplay") || "";
			}
			
			return this;
		}
	},

	hide: function(speed,callback){
		if ( speed ) {
			return this.animate( genFx("hide", 3), speed, callback);
		} else {
			for ( var i = 0, l = this.length; i < l; i++ ){
				var old = jQuery.data(this[i], "olddisplay");
				if ( !old && old !== "none" )
					jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
			}

			// Set the display of the elements in a second loop
			// to avoid the constant reflow
			for ( var i = 0, l = this.length; i < l; i++ ){
				this[i].style.display = "none";
			}

			return this;
		}
	},

	// Save the old toggle function
	_toggle: jQuery.fn.toggle,

	toggle: function( fn, fn2 ){
		var bool = typeof fn === "boolean";

		return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
			this._toggle.apply( this, arguments ) :
			fn == null || bool ?
				this.each(function(){
					var state = bool ? fn : jQuery(this).is(":hidden");
					jQuery(this)[ state ? "show" : "hide" ]();
				}) :
				this.animate(genFx("toggle", 3), fn, fn2);
	},

	fadeTo: function(speed,to,callback){
		return this.animate({opacity: to}, speed, callback);
	},

	animate: function( prop, speed, easing, callback ) {
		var optall = jQuery.speed(speed, easing, callback);

		return this[ optall.queue === false ? "each" : "queue" ](function(){
		
			var opt = jQuery.extend({}, optall), p,
				hidden = this.nodeType == 1 && jQuery(this).is(":hidden"),
				self = this;
	
			for ( p in prop ) {
				if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
					return opt.complete.call(this);

				if ( ( p == "height" || p == "width" ) && this.style ) {
					// Store display property
					opt.display = jQuery.css(this, "display");

					// Make sure that nothing sneaks out
					opt.overflow = this.style.overflow;
				}
			}

			if ( opt.overflow != null )
				this.style.overflow = "hidden";

			opt.curAnim = jQuery.extend({}, prop);

			jQuery.each( prop, function(name, val){
				var e = new jQuery.fx( self, opt, name );

				if ( /toggle|show|hide/.test(val) )
					e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
				else {
					var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
						start = e.cur(true) || 0;

					if ( parts ) {
						var end = parseFloat(parts[2]),
							unit = parts[3] || "px";

						// We need to compute starting value
						if ( unit != "px" ) {
							self.style[ name ] = (end || 1) + unit;
							start = ((end || 1) / e.cur(true)) * start;
							self.style[ name ] = start + unit;
						}

						// If a +=/-= token was provided, we're doing a relative animation
						if ( parts[1] )
							end = ((parts[1] == "-=" ? -1 : 1) * end) + start;

						e.custom( start, end, unit );
					} else
						e.custom( start, val, "" );
				}
			});

			// For JS strict compliance
			return true;
		});
	},

	stop: function(clearQueue, gotoEnd){
		var timers = jQuery.timers;

		if (clearQueue)
			this.queue([]);

		this.each(function(){
			// go in reverse order so anything added to the queue during the loop is ignored
			for ( var i = timers.length - 1; i >= 0; i-- )
				if ( timers[i].elem == this ) {
					if (gotoEnd)
						// force the next step to be the last
						timers[i](true);
					timers.splice(i, 1);
				}
		});

		// start the next in the queue if the last step wasn't forced
		if (!gotoEnd)
			this.dequeue();

		return this;
	}

});

// Generate shortcuts for custom animations
jQuery.each({
	slideDown: genFx("show", 1),
	slideUp: genFx("hide", 1),
	slideToggle: genFx("toggle", 1),
	fadeIn: { opacity: "show" },
	fadeOut: { opacity: "hide" }
}, function( name, props ){
	jQuery.fn[ name ] = function( speed, callback ){
		return this.animate( props, speed, callback );
	};
});

jQuery.extend({

	speed: function(speed, easing, fn) {
		var opt = typeof speed === "object" ? speed : {
			complete: fn || !fn && easing ||
				jQuery.isFunction( speed ) && speed,
			duration: speed,
			easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
		};

		opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
			jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;

		// Queueing
		opt.old = opt.complete;
		opt.complete = function(){
			if ( opt.queue !== false )
				jQuery(this).dequeue();
			if ( jQuery.isFunction( opt.old ) )
				opt.old.call( this );
		};

		return opt;
	},

	easing: {
		linear: function( p, n, firstNum, diff ) {
			return firstNum + diff * p;
		},
		swing: function( p, n, firstNum, diff ) {
			return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
		}
	},

	timers: [],

	fx: function( elem, options, prop ){
		this.options = options;
		this.elem = elem;
		this.prop = prop;

		if ( !options.orig )
			options.orig = {};
	}

});

jQuery.fx.prototype = {

	// Simple function for setting a style value
	update: function(){
		if ( this.options.step )
			this.options.step.call( this.elem, this.now, this );

		(jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );

		// Set display property to block for height/width animations
		if ( ( this.prop == "height" || this.prop == "width" ) && this.elem.style )
			this.elem.style.display = "block";
	},

	// Get the current size
	cur: function(force){
		if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) )
			return this.elem[ this.prop ];

		var r = parseFloat(jQuery.css(this.elem, this.prop, force));
		return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
	},

	// Start an animation from one number to another
	custom: function(from, to, unit){
		this.startTime = now();
		this.start = from;
		this.end = to;
		this.unit = unit || this.unit || "px";
		this.now = this.start;
		this.pos = this.state = 0;

		var self = this;
		function t(gotoEnd){
			return self.step(gotoEnd);
		}

		t.elem = this.elem;

		if ( t() && jQuery.timers.push(t) && !timerId ) {
			timerId = setInterval(function(){
				var timers = jQuery.timers;

				for ( var i = 0; i < timers.length; i++ )
					if ( !timers[i]() )
						timers.splice(i--, 1);

				if ( !timers.length ) {
					clearInterval( timerId );
					timerId = undefined;
				}
			}, 13);
		}
	},

	// Simple 'show' function
	show: function(){
		// Remember where we started, so that we can go back to it later
		this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
		this.options.show = true;

		// Begin the animation
		// Make sure that we start at a small width/height to avoid any
		// flash of content
		this.custom(this.prop == "width" || this.prop == "height" ? 1 : 0, this.cur());

		// Start by showing the element
		jQuery(this.elem).show();
	},

	// Simple 'hide' function
	hide: function(){
		// Remember where we started, so that we can go back to it later
		this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
		this.options.hide = true;

		// Begin the animation
		this.custom(this.cur(), 0);
	},

	// Each step of an animation
	step: function(gotoEnd){
		var t = now();

		if ( gotoEnd || t >= this.options.duration + this.startTime ) {
			this.now = this.end;
			this.pos = this.state = 1;
			this.update();

			this.options.curAnim[ this.prop ] = true;

			var done = true;
			for ( var i in this.options.curAnim )
				if ( this.options.curAnim[i] !== true )
					done = false;

			if ( done ) {
				if ( this.options.display != null ) {
					// Reset the overflow
					this.elem.style.overflow = this.options.overflow;

					// Reset the display
					this.elem.style.display = this.options.display;
					if ( jQuery.css(this.elem, "display") == "none" )
						this.elem.style.display = "block";
				}

				// Hide the element if the "hide" operation was done
				if ( this.options.hide )
					jQuery(this.elem).hide();

				// Reset the properties, if the item has been hidden or shown
				if ( this.options.hide || this.options.show )
					for ( var p in this.options.curAnim )
						jQuery.attr(this.elem.style, p, this.options.orig[p]);
					
				// Execute the complete function
				this.options.complete.call( this.elem );
			}

			return false;
		} else {
			var n = t - this.startTime;
			this.state = n / this.options.duration;

			// Perform the easing function, defaults to swing
			this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
			this.now = this.start + ((this.end - this.start) * this.pos);

			// Perform the next step of the animation
			this.update();
		}

		return true;
	}

};

jQuery.extend( jQuery.fx, {
	speeds:{
		slow: 600,
 		fast: 200,
 		// Default speed
 		_default: 400
	},
	step: {

		opacity: function(fx){
			jQuery.attr(fx.elem.style, "opacity", fx.now);
		},

		_default: function(fx){
			if ( fx.elem.style && fx.elem.style[ fx.prop ] != null )
				fx.elem.style[ fx.prop ] = fx.now + fx.unit;
			else
				fx.elem[ fx.prop ] = fx.now;
		}
	}
});
if ( document.documentElement["getBoundingClientRect"] )
	jQuery.fn.offset = function() {
		if ( !this[0] ) return { top: 0, left: 0 };
		if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] );
		var box  = this[0].getBoundingClientRect(), doc = this[0].ownerDocument, body = doc.body, docElem = doc.documentElement,
			clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
			top  = box.top  + (self.pageYOffset || jQuery.boxModel && docElem.scrollTop  || body.scrollTop ) - clientTop,
			left = box.left + (self.pageXOffset || jQuery.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
		return { top: top, left: left };
	};
else 
	jQuery.fn.offset = function() {
		if ( !this[0] ) return { top: 0, left: 0 };
		if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] );
		jQuery.offset.initialized || jQuery.offset.initialize();

		var elem = this[0], offsetParent = elem.offsetParent, prevOffsetParent = elem,
			doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
			body = doc.body, defaultView = doc.defaultView,
			prevComputedStyle = defaultView.getComputedStyle(elem, null),
			top = elem.offsetTop, left = elem.offsetLeft;

		while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
			computedStyle = defaultView.getComputedStyle(elem, null);
			top -= elem.scrollTop, left -= elem.scrollLeft;
			if ( elem === offsetParent ) {
				top += elem.offsetTop, left += elem.offsetLeft;
				if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.tagName)) )
					top  += parseInt( computedStyle.borderTopWidth,  10) || 0,
					left += parseInt( computedStyle.borderLeftWidth, 10) || 0;
				prevOffsetParent = offsetParent, offsetParent = elem.offsetParent;
			}
			if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" )
				top  += parseInt( computedStyle.borderTopWidth,  10) || 0,
				left += parseInt( computedStyle.borderLeftWidth, 10) || 0;
			prevComputedStyle = computedStyle;
		}

		if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" )
			top  += body.offsetTop,
			left += body.offsetLeft;

		if ( prevComputedStyle.position === "fixed" )
			top  += Math.max(docElem.scrollTop, body.scrollTop),
			left += Math.max(docElem.scrollLeft, body.scrollLeft);

		return { top: top, left: left };
	};

jQuery.offset = {
	initialize: function() {
		if ( this.initialized ) return;
		var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, rules, prop, bodyMarginTop = body.style.marginTop,
			html = '<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';

		rules = { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' };
		for ( prop in rules ) container.style[prop] = rules[prop];

		container.innerHTML = html;
		body.insertBefore(container, body.firstChild);
		innerDiv = container.firstChild, checkDiv = innerDiv.firstChild, td = innerDiv.nextSibling.firstChild.firstChild;

		this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
		this.doesAddBorderForTableAndCells = (td.offsetTop === 5);

		innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative';
		this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);

		body.style.marginTop = '1px';
		this.doesNotIncludeMarginInBodyOffset = (body.offsetTop === 0);
		body.style.marginTop = bodyMarginTop;

		body.removeChild(container);
		this.initialized = true;
	},

	bodyOffset: function(body) {
		jQuery.offset.initialized || jQuery.offset.initialize();
		var top = body.offsetTop, left = body.offsetLeft;
		if ( jQuery.offset.doesNotIncludeMarginInBodyOffset )
			top  += parseInt( jQuery.curCSS(body, 'marginTop',  true), 10 ) || 0,
			left += parseInt( jQuery.curCSS(body, 'marginLeft', true), 10 ) || 0;
		return { top: top, left: left };
	}
};


jQuery.fn.extend({
	position: function() {
		var left = 0, top = 0, results;

		if ( this[0] ) {
			// Get *real* offsetParent
			var offsetParent = this.offsetParent(),

			// Get correct offsets
			offset       = this.offset(),
			parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset();

			// Subtract element margins
			// note: when an element has margin: auto the offsetLeft and marginLeft 
			// are the same in Safari causing offset.left to incorrectly be 0
			offset.top  -= num( this, 'marginTop'  );
			offset.left -= num( this, 'marginLeft' );

			// Add offsetParent borders
			parentOffset.top  += num( offsetParent, 'borderTopWidth'  );
			parentOffset.left += num( offsetParent, 'borderLeftWidth' );

			// Subtract the two offsets
			results = {
				top:  offset.top  - parentOffset.top,
				left: offset.left - parentOffset.left
			};
		}

		return results;
	},

	offsetParent: function() {
		var offsetParent = this[0].offsetParent || document.body;
		while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static') )
			offsetParent = offsetParent.offsetParent;
		return jQuery(offsetParent);
	}
});


// Create scrollLeft and scrollTop methods
jQuery.each( ['Left', 'Top'], function(i, name) {
	var method = 'scroll' + name;
	
	jQuery.fn[ method ] = function(val) {
		if (!this[0]) return null;

		return val !== undefined ?

			// Set the scroll offset
			this.each(function() {
				this == window || this == document ?
					window.scrollTo(
						!i ? val : jQuery(window).scrollLeft(),
						 i ? val : jQuery(window).scrollTop()
					) :
					this[ method ] = val;
			}) :

			// Return the scroll offset
			this[0] == window || this[0] == document ?
				self[ i ? 'pageYOffset' : 'pageXOffset' ] ||
					jQuery.boxModel && document.documentElement[ method ] ||
					document.body[ method ] :
				this[0][ method ];
	};
});
// Create innerHeight, innerWidth, outerHeight and outerWidth methods
jQuery.each([ "Height", "Width" ], function(i, name){

	var tl = i ? "Left"  : "Top",  // top or left
		br = i ? "Right" : "Bottom", // bottom or right
		lower = name.toLowerCase();

	// innerHeight and innerWidth
	jQuery.fn["inner" + name] = function(){
		return this[0] ?
			jQuery.css( this[0], lower, false, "padding" ) :
			null;
	};

	// outerHeight and outerWidth
	jQuery.fn["outer" + name] = function(margin) {
		return this[0] ?
			jQuery.css( this[0], lower, false, margin ? "margin" : "border" ) :
			null;
	};
	
	var type = name.toLowerCase();

	jQuery.fn[ type ] = function( size ) {
		// Get window width or height
		return this[0] == window ?
			// Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
			document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] ||
			document.body[ "client" + name ] :

			// Get document width or height
			this[0] == document ?
				// Either scroll[Width/Height] or offset[Width/Height], whichever is greater
				Math.max(
					document.documentElement["client" + name],
					document.body["scroll" + name], document.documentElement["scroll" + name],
					document.body["offset" + name], document.documentElement["offset" + name]
				) :

				// Get or set width or height on the element
				size === undefined ?
					// Get width or height on the element
					(this.length ? jQuery.css( this[0], type ) : null) :

					// Set the width or height on the element (default to pixels if value is unitless)
					this.css( type, typeof size === "string" ? size : size + "px" );
	};

});
})();

// JS/jqUI/new/ui.core.js
/*! Copyright (c) 2008 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Version: 1.0.3
 * Requires jQuery 1.1.3+
 * Docs: http://docs.jquery.com/Plugins/livequery
 */

(function($) {
	
$.extend($.fn, {
	livequery: function(type, fn, fn2) {
		var self = this, q;
		
		// Handle different call patterns
		if ($.isFunction(type))
			fn2 = fn, fn = type, type = undefined;
			
		// See if Live Query already exists
		$.each( $.livequery.queries, function(i, query) {
			if ( self.selector == query.selector && self.context == query.context &&
				type == query.type && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) )
					// Found the query, exit the each loop
					return (q = query) && false;
		});
		
		// Create new Live Query if it wasn't found
		q = q || new $.livequery(this.selector, this.context, type, fn, fn2);
		
		// Make sure it is running
		q.stopped = false;
		
		// Run it immediately for the first time
		q.run();
		
		// Contnue the chain
		return this;
	},
	
	expire: function(type, fn, fn2) {
		var self = this;
		
		// Handle different call patterns
		if ($.isFunction(type))
			fn2 = fn, fn = type, type = undefined;
			
		// Find the Live Query based on arguments and stop it
		$.each( $.livequery.queries, function(i, query) {
			if ( self.selector == query.selector && self.context == query.context && 
				(!type || type == query.type) && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !this.stopped )
					$.livequery.stop(query.id);
		});
		
		// Continue the chain
		return this;
	}
});

$.livequery = function(selector, context, type, fn, fn2) {
	this.selector = selector;
	this.context  = context || document;
	this.type     = type;
	this.fn       = fn;
	this.fn2      = fn2;
	this.elements = [];
	this.stopped  = false;
	
	// The id is the index of the Live Query in $.livequery.queries
	this.id = $.livequery.queries.push(this)-1;
	
	// Mark the functions for matching later on
	fn.$lqguid = fn.$lqguid || $.livequery.guid++;
	if (fn2) fn2.$lqguid = fn2.$lqguid || $.livequery.guid++;
	
	// Return the Live Query
	return this;
};

$.livequery.prototype = {
	stop: function() {
		var query = this;
		
		if ( this.type )
			// Unbind all bound events
			this.elements.unbind(this.type, this.fn);
		else if (this.fn2)
			// Call the second function for all matched elements
			this.elements.each(function(i, el) {
				query.fn2.apply(el);
			});
			
		// Clear out matched elements
		this.elements = [];
		
		// Stop the Live Query from running until restarted
		this.stopped = true;
	},
	
	run: function() {
		// Short-circuit if stopped
		if ( this.stopped ) return;
		var query = this;
		
		var oEls = this.elements,
			els  = $(this.selector, this.context),
			nEls = els.not(oEls);
		
		// Set elements to the latest set of matched elements
		this.elements = els;
		
		if (this.type) {
			// Bind events to newly matched elements
			nEls.bind(this.type, this.fn);
			
			// Unbind events to elements no longer matched
			if (oEls.length > 0)
				$.each(oEls, function(i, el) {
					if ( $.inArray(el, els) < 0 )
						$.event.remove(el, query.type, query.fn);
				});
		}
		else {
			// Call the first function for newly matched elements
			nEls.each(function() {
				query.fn.apply(this);
			});
			
			// Call the second function for elements no longer matched
			if ( this.fn2 && oEls.length > 0 )
				$.each(oEls, function(i, el) {
					if ( $.inArray(el, els) < 0 )
						query.fn2.apply(el);
				});
		}
	}
};

$.extend($.livequery, {
	guid: 0,
	queries: [],
	queue: [],
	running: false,
	timeout: null,
	
	checkQueue: function() {
		if ( $.livequery.running && $.livequery.queue.length ) {
			var length = $.livequery.queue.length;
			// Run each Live Query currently in the queue
			while ( length-- )
				$.livequery.queries[ $.livequery.queue.shift() ].run();
		}
	},
	
	pause: function() {
		// Don't run anymore Live Queries until restarted
		$.livequery.running = false;
	},
	
	play: function() {
		// Restart Live Queries
		$.livequery.running = true;
		// Request a run of the Live Queries
		$.livequery.run();
	},
	
	registerPlugin: function() {
		$.each( arguments, function(i,n) {
			// Short-circuit if the method doesn't exist
			if (!$.fn[n]) return;
			
			// Save a reference to the original method
			var old = $.fn[n];
			
			// Create a new method
			$.fn[n] = function() {
				// Call the original method
				var r = old.apply(this, arguments);
				
				// Request a run of the Live Queries
				$.livequery.run();
				
				// Return the original methods result
				return r;
			}
		});
	},
	
	run: function(id) {
		if (id != undefined) {
			// Put the particular Live Query in the queue if it doesn't already exist
			if ( $.inArray(id, $.livequery.queue) < 0 )
				$.livequery.queue.push( id );
		}
		else
			// Put each Live Query in the queue if it doesn't already exist
			$.each( $.livequery.queries, function(id) {
				if ( $.inArray(id, $.livequery.queue) < 0 )
					$.livequery.queue.push( id );
			});
		
		// Clear timeout if it already exists
		if ($.livequery.timeout) clearTimeout($.livequery.timeout);
		// Create a timeout to check the queue and actually run the Live Queries
		$.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
	},
	
	stop: function(id) {
		if (id != undefined)
			// Stop are particular Live Query
			$.livequery.queries[ id ].stop();
		else
			// Stop all Live Queries
			$.each( $.livequery.queries, function(id) {
				$.livequery.queries[ id ].stop();
			});
	}
});

// Register core DOM manipulation methods
$.livequery.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'empty', 'remove');

// Run Live Queries when the Document is ready
$(function() { $.livequery.play(); });


// Save a reference to the original init method
var init = $.prototype.init;

// Create a new init method that exposes two new properties: selector and context
$.prototype.init = function(a,c) {
	// Call the original init and save the result
	var r = init.apply(this, arguments);
	
	// Copy over properties if they exist already
	if (a && a.selector)
		r.context = a.context, r.selector = a.selector;
		
	// Set properties
	if ( typeof a == 'string' )
		r.context = c || document, r.selector = a;
	
	// Return the result
	return r;
};

// Give the init function the jQuery prototype for later instantiation (needed after Rev 4091)
$.prototype.init.prototype = $.prototype;
	
})(jQuery);
// JS/jqUI/new/ui.resizable.js
// Farbtastic 1.2

jQuery.fn.farbtastic = function (callback) {
  $.farbtastic(this, callback);
  return this;
};

jQuery.farbtastic = function (container, callback) {
  var container = $(container).get(0);
  return container.farbtastic || (container.farbtastic = new jQuery._farbtastic(container, callback));
}

jQuery._farbtastic = function (container, callback) {
  // Store farbtastic object
  var fb = this;

  // Insert markup
  $(container).html('<div class="uiFarbtastic"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>');
  var e = $('.uiFarbtastic', container);
  fb.wheel = $('.wheel', container).get(0);
  // Dimensions
  fb.radius = 84;
  fb.square = 100;
  fb.width = 194;

  // Fix background PNGs in IE6
  if (navigator.appVersion.match(/MSIE [0-6]\./)) {
    $('*', e).each(function () {
      if (this.currentStyle.backgroundImage != 'none') {
        var image = this.currentStyle.backgroundImage;
        image = this.currentStyle.backgroundImage.substring(5, image.length - 2);
        $(this).css({
          'backgroundImage': 'none',
          'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
        });
      }
    });
  }

  /**
   * Link to the given element(s) or callback.
   */
  fb.linkTo = function (callback) {
    // Unbind previous nodes
    if (typeof fb.callback == 'object') {
      $(fb.callback).unbind('keyup', fb.updateValue);
    }

    // Reset color
    fb.color = null;

    // Bind callback or elements
    if (typeof callback == 'function') {
      fb.callback = callback;
    }
    else if (typeof callback == 'object' || typeof callback == 'string') {
      fb.callback = $(callback);
      fb.callback.bind('keyup', fb.updateValue);
      if (fb.callback.get(0).value) {
        fb.setColor(fb.callback.get(0).value);
      }
    }
    return this;
  }
  fb.updateValue = function (event) {
    if (this.value && this.value != fb.color) {
      fb.setColor(this.value);
    }
  }

  /**
   * Change color with HTML syntax #123456
   */
  fb.setColor = function (color) {
    var unpack = fb.unpack(color);
    if (fb.color != color && unpack) {
      fb.color = color;
      fb.rgb = unpack;
      fb.hsl = fb.RGBToHSL(fb.rgb);
      fb.updateDisplay();
    }
    return this;
  }

  /**
   * Change color with HSL triplet [0..1, 0..1, 0..1]
   */
  fb.setHSL = function (hsl) {
    fb.hsl = hsl;
    fb.rgb = fb.HSLToRGB(hsl);
    fb.color = fb.pack(fb.rgb);
    fb.updateDisplay();
    return this;
  }

  /////////////////////////////////////////////////////

  /**
   * Retrieve the coordinates of the given event relative to the center
   * of the widget.
   */
  fb.widgetCoords = function (event) {
    var x, y;
    var el = event.target || event.srcElement;
    var reference = fb.wheel;

    if (typeof event.offsetX != 'undefined') {
      // Use offset coordinates and find common offsetParent
      var pos = { x: event.offsetX, y: event.offsetY };

      // Send the coordinates upwards through the offsetParent chain.
      var e = el;
      while (e) {
        e.mouseX = pos.x;
        e.mouseY = pos.y;
        pos.x += e.offsetLeft;
        pos.y += e.offsetTop;
        e = e.offsetParent;
      }

      // Look for the coordinates starting from the wheel widget.
      var e = reference;
      var offset = { x: 0, y: 0 }
      while (e) {
        if (typeof e.mouseX != 'undefined') {
          x = e.mouseX - offset.x;
          y = e.mouseY - offset.y;
          break;
        }
        offset.x += e.offsetLeft;
        offset.y += e.offsetTop;
        e = e.offsetParent;
      }

      // Reset stored coordinates
      e = el;
      while (e) {
        e.mouseX = undefined;
        e.mouseY = undefined;
        e = e.offsetParent;
      }
    }
    else {
      // Use absolute coordinates
      var pos = fb.absolutePosition(reference);
      x = (event.pageX || 0*(event.clientX + $('html').get(0).scrollLeft)) - pos.x;
      y = (event.pageY || 0*(event.clientY + $('html').get(0).scrollTop)) - pos.y;
    }
    // Subtract distance to middle
    return { x: x - fb.width / 2, y: y - fb.width / 2 };
  }

  /**
   * Mousedown handler
   */
  fb.mousedown = function (event) {
    // Capture mouse
    if (!document.dragging) {
      $(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup);
      document.dragging = true;
    }

    // Check which area is being dragged
    var pos = fb.widgetCoords(event);
    fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square;

    // Process
    fb.mousemove(event);
    return false;
  }

  /**
   * Mousemove handler
   */
  fb.mousemove = function (event) {
    // Get coordinates relative to color picker center
    var pos = fb.widgetCoords(event);

    // Set new HSL parameters
    if (fb.circleDrag) {
      var hue = Math.atan2(pos.x, -pos.y) / 6.28;
      if (hue < 0) hue += 1;
      fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]);
    }
    else {
      var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5));
      var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5));
      fb.setHSL([fb.hsl[0], sat, lum]);
    }
    return false;
  }

  /**
   * Mouseup handler
   */
  fb.mouseup = function () {
    // Uncapture mouse
    $(document).unbind('mousemove', fb.mousemove);
    $(document).unbind('mouseup', fb.mouseup);
    document.dragging = false;
  }

  /**
   * Update the markers and styles
   */
  fb.updateDisplay = function () {
    // Markers
    var angle = fb.hsl[0] * 6.28;
    $('.h-marker', e).css({
      left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px',
      top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px'
    });

    $('.sl-marker', e).css({
      left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px',
      top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px'
    });

    // Saturation/Luminance gradient
    $('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5])));

    // Linked elements or callback
    if (typeof fb.callback == 'object') {
      // Set background/foreground color
      $(fb.callback).css({
        backgroundColor: fb.color,
        color: fb.hsl[2] > 0.5 ? '#000' : '#fff'
      });

      // Change linked value
      $(fb.callback).each(function() {
        if (this.value && this.value != fb.color) {
          this.value = fb.color;
        }
      });
    }
    else if (typeof fb.callback == 'function') {
      fb.callback.call(fb, fb.color);
    }
  }

  /**
   * Get absolute position of element
   */
  fb.absolutePosition = function (el) {
    var r = { x: el.offsetLeft, y: el.offsetTop };
    // Resolve relative to offsetParent
    if (el.offsetParent) {
      var tmp = fb.absolutePosition(el.offsetParent);
      r.x += tmp.x;
      r.y += tmp.y;
    }
    return r;
  };

  /* Various color utility functions */
  fb.pack = function (rgb) {
    var r = Math.round(rgb[0] * 255);
    var g = Math.round(rgb[1] * 255);
    var b = Math.round(rgb[2] * 255);
    return '#' + (r < 16 ? '0' : '') + r.toString(16) +
           (g < 16 ? '0' : '') + g.toString(16) +
           (b < 16 ? '0' : '') + b.toString(16);
  }

  fb.unpack = function (color) {
    if (color.length == 7) {
      return [parseInt('0x' + color.substring(1, 3)) / 255,
        parseInt('0x' + color.substring(3, 5)) / 255,
        parseInt('0x' + color.substring(5, 7)) / 255];
    }
    else if (color.length == 4) {
      return [parseInt('0x' + color.substring(1, 2)) / 15,
        parseInt('0x' + color.substring(2, 3)) / 15,
        parseInt('0x' + color.substring(3, 4)) / 15];
    }
  }

  fb.HSLToRGB = function (hsl) {
    var m1, m2, r, g, b;
    var h = hsl[0], s = hsl[1], l = hsl[2];
    m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s;
    m1 = l * 2 - m2;
    return [this.hueToRGB(m1, m2, h+0.33333),
        this.hueToRGB(m1, m2, h),
        this.hueToRGB(m1, m2, h-0.33333)];
  }

  fb.hueToRGB = function (m1, m2, h) {
    h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
    if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
    if (h * 2 < 1) return m2;
    if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
    return m1;
  }

  fb.RGBToHSL = function (rgb) {
    var min, max, delta, h, s, l;
    var r = rgb[0], g = rgb[1], b = rgb[2];
    min = Math.min(r, Math.min(g, b));
    max = Math.max(r, Math.max(g, b));
    delta = max - min;
    l = (min + max) / 2;
    s = 0;
    if (l > 0 && l < 1) {
      s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
    }
    h = 0;
    if (delta > 0) {
      if (max == r && max != g) h += (g - b) / delta;
      if (max == g && max != b) h += (2 + (b - r) / delta);
      if (max == b && max != r) h += (4 + (r - g) / delta);
      h /= 6;
    }
    return [h, s, l];
  }

  // Install mousedown handler (the others are set on the document on-demand)
  $('*', e).mousedown(fb.mousedown);

    // Init color
  fb.setColor('#000000');

  // Set linked elements/callback
  if (callback) {
    fb.linkTo(callback);
  }
}
// JS/jqUI/new/ui.draggable.js
/* SWFObject v2.1 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();
// JS/jqUI/new/ui.droppable.js
////////////////////////////////////////////////////////////////////////////////
//
//  STRINGDATA
//  Copyright 2009 StringData, s.r.o.
//  All Rights Reserved.
//
//  NOTICE: Stringdata permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

var AS2Brige = {
    //--------------------------------------------------------------------------
    //
    //  Variables
    //
    //--------------------------------------------------------------------------

    lastIds: null,

    //--------------------------------------------------------------------------
    //
    //  Methods
    //
    //--------------------------------------------------------------------------

    initialize: function()
    {
        return true;
    },

    register: function(ids)
    {
        // lastIds slouzi soucasne jako zamek aby se nemohli zkrizit
        // dva pozadavky
        if (this.lastIds)
            return false;

        this.lastIds = ids;

        return true;
    },

    consumeIds: function()
    {
        var ids = this.lastIds;
        this.lastIds = null;

        return ids;
    },

    call: function(flashId, callback, args)
    {
        var flash = document.getElementById(flashId);
        return flash[callback].apply(flash, args);
    }
}
// JS/jqUI/new/ui.selectable.js
UIExt = {
	PasteCleanup : function( html, bRemoveStyles, bIgnoreFont ){
		var PasteCleanupKeepsStructure = true;
		
		html = html.replace(/<o:p>\s*<\/o:p>/g, '');
		html = html.replace(/<o:p>[\s\S]*?<\/o:p>/g, '&nbsp;');
	
		// Remove mso-xxx styles.
		html = html.replace( /\s*mso-[^:]+:[^;"]+;?/gi, '' );
	
		// Remove margin styles.
		html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, '' );
		html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" );
		html = html.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, '' );
		html = html.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" );
		html = html.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" );
		html = html.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" );
		html = html.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" );
		html = html.replace( /\s*tab-stops:[^;"]*;?/gi, '' );
		html = html.replace( /\s*tab-stops:[^"]*/gi, '' );
	
		// Remove FONT face attributes.
		if ( bIgnoreFont )
		{
			html = html.replace( /\s*face="[^"]*"/gi, '' );
			html = html.replace( /\s*face=[^ >]*/gi, '' );
	
			html = html.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, '' );
		}
	
		// Remove Class attributes
		html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3");
	
		// Remove styles.
		if ( bRemoveStyles )
			html = html.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" );
	
		// Remove style, meta and link tags
		html = html.replace( /<STYLE[^>]*>[\s\S]*?<\/STYLE[^>]*>/gi, '' );
		html = html.replace( /<(?:META|LINK)[^>]*>\s*/gi, '' );

		// Remove empty styles.
		html =  html.replace( /\s*style="\s*"/gi, '' );
		html = html.replace( /<SPAN\s*[^>]*>\s*&nbsp;\s*<\/SPAN>/gi, '&nbsp;' );
		html = html.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' );
	
		// Remove Lang attributes
		html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3");
		html = html.replace( /<SPAN\s*>([\s\S]*?)<\/SPAN>/gi, '$1' );
		html = html.replace( /<FONT\s*>([\s\S]*?)<\/FONT>/gi, '$1' );
	
		// Remove XML elements and declarations
		html = html.replace(/<\\?\?xml[^>]*>/gi, '' );
	
		// Remove w: tags with contents.
		html = html.replace( /<w:[^>]*>[\s\S]*?<\/w:[^>]*>/gi, '' );
	
		// Remove Tags with XML namespace declarations: <o:p><\/o:p>
		html = html.replace(/<\/?\w+:[^>]*>/gi, '' );
	
		// Remove comments [SF BUG-1481861].
		html = html.replace(/<\!--[\s\S]*?-->/g, '' );
		html = html.replace( /<(U|I|STRIKE)>&nbsp;<\/\1>/g, '&nbsp;' );
		html = html.replace( /<H\d>\s*<\/H\d>/gi, '' );
	
		// Remove "display:none" tags.
		html = html.replace( /<(\w+)[^>]*\sstyle="[^"]*DISPLAY\s?:\s?none[\s\S]*?<\/\1>/ig, '' );
	
		// Remove language tags
		html = html.replace( /<(\w[^>]*) language=([^ |>]*)([^>]*)/gi, "<$1$3");
	
		// Remove onmouseover and onmouseout events (from MS Word comments effect)
		html = html.replace( /<(\w[^>]*) onmouseover="([^\"]*)"([^>]*)/gi, "<$1$3");
		html = html.replace( /<(\w[^>]*) onmouseout="([^\"]*)"([^>]*)/gi, "<$1$3");
		
		if ( PasteCleanupKeepsStructure )
		{
			// The original <Hn> tag send from Word is something like this: <Hn style="margin-top:0px;margin-bottom:0px">
			html = html.replace( /<H(\d)([^>]*)>/gi, '<h$1>' );
	
			// Word likes to insert extra <font> tags, when using MSIE. (Wierd).
			html = html.replace( /<(H\d)><FONT[^>]*>([\s\S]*?)<\/FONT><\/\1>/gi, '<$1>$2<\/$1>' );
			html = html.replace( /<(H\d)><EM>([\s\S]*?)<\/EM><\/\1>/gi, '<$1>$2<\/$1>' );
		}
		else
		{
			html = html.replace( /<H1([^>]*)>/gi, '<div$1><b><font size="6">' );
			html = html.replace( /<H2([^>]*)>/gi, '<div$1><b><font size="5">' );
			html = html.replace( /<H3([^>]*)>/gi, '<div$1><b><font size="4">' );
			html = html.replace( /<H4([^>]*)>/gi, '<div$1><b><font size="3">' );
			html = html.replace( /<H5([^>]*)>/gi, '<div$1><b><font size="2">' );
			html = html.replace( /<H6([^>]*)>/gi, '<div$1><b><font size="1">' );
	
			html = html.replace( /<\/H\d>/gi, '<\/font><\/b><\/div>' );
	
			// Transform <P> to <DIV>
			var re = new RegExp( '(<P)([^>]*>[\\s\\S]*?)(<\/P>)', 'gi' );	// Different because of a IE 5.0 error
			html = html.replace( re, '<div$2<\/div>' );
	
			// Remove empty tags (three times, just to be sure).
			// This also removes any empty anchor
			html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' );
			html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' );
			html = html.replace( /<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '' );
		}
		return html ;
	},
	toSafeChars : function(newString, sMode) {
		if(typeof bMode == "undefined") bMode = "all";
		

		var badChars =	"áâäăąçćčďđéëęěíîĺľłńňóôöőŕřśşšţťúüůűýźżž";
		var goodChars =	"aaaaacccddeeeeiilllnnoooorrsssttuuuuyzzz";
		
		badChars = badChars + badChars.toUpperCase();
		goodChars = goodChars + goodChars.toUpperCase();
		
		
		// space and hyphens removal
		if(bMode != "diacritics"){
			var re = new RegExp("[ \f\n\r\t]", "g");
			newString = newString.replace(re, "_");
		}
		// diacritics
		var re = new RegExp("[^A-Za-z0-9_]", "g");
		
		if(bMode != "diacritics"){
			var replaceChars = function(a, b, c) {
			
				// special characters
				if (
					(a == "\\")	||
					(a == "\^")
				)
				{return "_";}

				var re = new RegExp("[" + a + "]");
				var charPosition = badChars.search(re);
				return (charPosition > -1) ? goodChars.charAt(charPosition) : "_";
			
			};
		}
		
		newString = newString.replace(re, replaceChars);
		
		// clear begining and end
		var re = new RegExp("_{2,}", "g");
		newString = newString.replace(re, "_");

		var re = new RegExp("^_|_$", "g");
		newString = newString.replace(re, "");
		
		return newString;
	}
}
// JS/jqUI/new/ui.sortable.js
;jQuery.ui||(function($){var _remove=$.fn.remove,isFF2=$.browser.mozilla&&(parseFloat($.browser.version)<1.9);$.ui={version:"1.7.2",plugin:{add:function(module,option,set){var proto=$.ui[module].prototype;for(var i in set){proto.plugins[i]=proto.plugins[i]||[];proto.plugins[i].push([option,set[i]]);}},call:function(instance,name,args){var set=instance.plugins[name];if(!set||!instance.element[0].parentNode){return;}
for(var i=0;i<set.length;i++){if(instance.options[set[i][0]]){set[i][1].apply(instance.element,args);}}}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b);},hasScroll:function(el,a){if($(el).css('overflow')=='hidden'){return false;}
var scroll=(a&&a=='left')?'scrollLeft':'scrollTop',has=false;if(el[scroll]>0){return true;}
el[scroll]=1;has=(el[scroll]>0);el[scroll]=0;return has;},isOverAxis:function(x,reference,size){return(x>reference)&&(x<(reference+size));},isOver:function(y,x,top,left,height,width){return $.ui.isOverAxis(y,top,height)&&$.ui.isOverAxis(x,left,width);},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};if(isFF2){var attr=$.attr,removeAttr=$.fn.removeAttr,ariaNS="http://www.w3.org/2005/07/aaa",ariaState=/^aria-/,ariaRole=/^wairole:/;$.attr=function(elem,name,value){var set=value!==undefined;return(name=='role'?(set?attr.call(this,elem,name,"wairole:"+value):(attr.apply(this,arguments)||"").replace(ariaRole,"")):(ariaState.test(name)?(set?elem.setAttributeNS(ariaNS,name.replace(ariaState,"aaa:"),value):attr.call(this,elem,name.replace(ariaState,"aaa:"))):attr.apply(this,arguments)));};$.fn.removeAttr=function(name){return(ariaState.test(name)?this.each(function(){this.removeAttributeNS(ariaNS,name.replace(ariaState,""));}):removeAttr.call(this,name));};}
$.fn.extend({remove:function(){$("*",this).add(this).each(function(){$(this).triggerHandler("remove");});return _remove.apply(this,arguments);},enableSelection:function(){return this.attr('unselectable','off').css('MozUserSelect','').unbind('selectstart.ui');},disableSelection:function(){return this.attr('unselectable','on').css('MozUserSelect','none').bind('selectstart.ui',function(){return false;});},scrollParent:function(){var scrollParent;if(($.browser.msie&&(/(static|relative)/).test(this.css('position')))||(/absolute/).test(this.css('position'))){scrollParent=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test($.curCSS(this,'position',1))&&(/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));}).eq(0);}else{scrollParent=this.parents().filter(function(){return(/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));}).eq(0);}
return(/fixed/).test(this.css('position'))||!scrollParent.length?$(document):scrollParent;}});$.extend($.expr[':'],{data:function(elem,i,match){return!!$.data(elem,match[3]);},focusable:function(element){var nodeName=element.nodeName.toLowerCase(),tabIndex=$.attr(element,'tabindex');return(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:'a'==nodeName||'area'==nodeName?element.href||!isNaN(tabIndex):!isNaN(tabIndex))&&!$(element)['area'==nodeName?'parents':'closest'](':hidden').length;},tabbable:function(element){var tabIndex=$.attr(element,'tabindex');return(isNaN(tabIndex)||tabIndex>=0)&&$(element).is(':focusable');}});function getter(namespace,plugin,method,args){function getMethods(type){var methods=$[namespace][plugin][type]||[];return(typeof methods=='string'?methods.split(/,?\s+/):methods);}
var methods=getMethods('getter');if(args.length==1&&typeof args[0]=='string'){methods=methods.concat(getMethods('getterSetter'));}
return($.inArray(method,methods)!=-1);}
$.widget=function(name,prototype){var namespace=name.split(".")[0];name=name.split(".")[1];$.fn[name]=function(options){var isMethodCall=(typeof options=='string'),args=Array.prototype.slice.call(arguments,1);if(isMethodCall&&options.substring(0,1)=='_'){return this;}
if(isMethodCall&&getter(namespace,name,options,args)){var instance=$.data(this[0],name);return(instance?instance[options].apply(instance,args):undefined);}
return this.each(function(){var instance=$.data(this,name);(!instance&&!isMethodCall&&$.data(this,name,new $[namespace][name](this,options))._init());(instance&&isMethodCall&&$.isFunction(instance[options])&&instance[options].apply(instance,args));});};$[namespace]=$[namespace]||{};$[namespace][name]=function(element,options){var self=this;this.namespace=namespace;this.widgetName=name;this.widgetEventPrefix=$[namespace][name].eventPrefix||name;this.widgetBaseClass=namespace+'-'+name;this.options=$.extend({},$.widget.defaults,$[namespace][name].defaults,$.metadata&&$.metadata.get(element)[name],options);this.element=$(element).bind('setData.'+name,function(event,key,value){if(event.target==element){return self._setData(key,value);}}).bind('getData.'+name,function(event,key){if(event.target==element){return self._getData(key);}}).bind('remove',function(){return self.destroy();});};$[namespace][name].prototype=$.extend({},$.widget.prototype,prototype);$[namespace][name].getterSetter='option';};$.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass+'-disabled'+' '+this.namespace+'-state-disabled').removeAttr('aria-disabled');},option:function(key,value){var options=key,self=this;if(typeof key=="string"){if(value===undefined){return this._getData(key);}
options={};options[key]=value;}
$.each(options,function(key,value){self._setData(key,value);});},_getData:function(key){return this.options[key];},_setData:function(key,value){this.options[key]=value;if(key=='disabled'){this.element
[value?'addClass':'removeClass'](this.widgetBaseClass+'-disabled'+' '+
this.namespace+'-state-disabled').attr("aria-disabled",value);}},enable:function(){this._setData('disabled',false);},disable:function(){this._setData('disabled',true);},_trigger:function(type,event,data){var callback=this.options[type],eventName=(type==this.widgetEventPrefix?type:this.widgetEventPrefix+type);event=$.Event(event);event.type=eventName;if(event.originalEvent){for(var i=$.event.props.length,prop;i;){prop=$.event.props[--i];event[prop]=event.originalEvent[prop];}}
this.element.trigger(event,data);return!($.isFunction(callback)&&callback.call(this.element[0],event,data)===false||event.isDefaultPrevented());}};$.widget.defaults={disabled:false};$.ui.mouse={_mouseInit:function(){var self=this;this.element.bind('mousedown.'+this.widgetName,function(event){return self._mouseDown(event);}).bind('click.'+this.widgetName,function(event){if(self._preventClickEvent){self._preventClickEvent=false;event.stopImmediatePropagation();return false;}});if($.browser.msie){this._mouseUnselectable=this.element.attr('unselectable');this.element.attr('unselectable','on');}
this.started=false;},_mouseDestroy:function(){this.element.unbind('.'+this.widgetName);($.browser.msie&&this.element.attr('unselectable',this._mouseUnselectable));},_mouseDown:function(event){event.originalEvent=event.originalEvent||{};if(event.originalEvent.mouseHandled){return;}
(this._mouseStarted&&this._mouseUp(event));this._mouseDownEvent=event;var self=this,btnIsLeft=(event.which==1),elIsCancel=(typeof this.options.cancel=="string"?$(event.target).parents().add(event.target).filter(this.options.cancel).length:false);if(!btnIsLeft||elIsCancel||!this._mouseCapture(event)){return true;}
this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){self.mouseDelayMet=true;},this.options.delay);}
if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=(this._mouseStart(event)!==false);if(!this._mouseStarted){event.preventDefault();return true;}}
this._mouseMoveDelegate=function(event){return self._mouseMove(event);};this._mouseUpDelegate=function(event){return self._mouseUp(event);};$(document).bind('mousemove.'+this.widgetName,this._mouseMoveDelegate).bind('mouseup.'+this.widgetName,this._mouseUpDelegate);($.browser.safari||event.preventDefault());event.originalEvent.mouseHandled=true;return true;},_mouseMove:function(event){if($.browser.msie&&!event.button){return this._mouseUp(event);}
if(this._mouseStarted){this._mouseDrag(event);return event.preventDefault();}
if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,event)!==false);(this._mouseStarted?this._mouseDrag(event):this._mouseUp(event));}
return!this._mouseStarted;},_mouseUp:function(event){$(document).unbind('mousemove.'+this.widgetName,this._mouseMoveDelegate).unbind('mouseup.'+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(event.target==this._mouseDownEvent.target);this._mouseStop(event);}
return false;},_mouseDistanceMet:function(event){return(Math.max(Math.abs(this._mouseDownEvent.pageX-event.pageX),Math.abs(this._mouseDownEvent.pageY-event.pageY))>=this.options.distance);},_mouseDelayMet:function(event){return this.mouseDelayMet;},_mouseStart:function(event){},_mouseDrag:function(event){},_mouseStop:function(event){},_mouseCapture:function(event){return true;}};$.ui.mouse.defaults={cancel:null,distance:1,delay:0};})(jQuery);
// JS/jqUI/new/ui.core.js

(function($){$.widget("ui.resizable",$.extend({},$.ui.mouse,{_init:function(){var self=this,o=this.options;this.element.addClass("ui-resizable");$.extend(this,{_aspectRatio:!!(o.aspectRatio),aspectRatio:o.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:o.helper||o.ghost||o.animate?o.helper||'ui-resizable-helper':null});if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)){if(/relative/.test(this.element.css('position'))&&$.browser.opera)
this.element.css({position:'relative',top:'auto',left:'auto'});this.element.wrap($('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:this.element.css('position'),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css('top'),left:this.element.css('left')}));this.element=this.element.parent().data("resizable",this.element.data('resizable'));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle=this.originalElement.css('resize');this.originalElement.css('resize','none');this._proportionallyResizeElements.push(this.originalElement.css({position:'static',zoom:1,display:'block'}));this.originalElement.css({margin:this.originalElement.css('margin')});this._proportionallyResize();}
this.handles=o.handles||(!$('.ui-resizable-handle',this.element).length?"e,s,se":{n:'.ui-resizable-n',e:'.ui-resizable-e',s:'.ui-resizable-s',w:'.ui-resizable-w',se:'.ui-resizable-se',sw:'.ui-resizable-sw',ne:'.ui-resizable-ne',nw:'.ui-resizable-nw'});if(this.handles.constructor==String){if(this.handles=='all')this.handles='n,e,s,w,se,sw,ne,nw';var n=this.handles.split(",");this.handles={};for(var i=0;i<n.length;i++){var handle=$.trim(n[i]),hname='ui-resizable-'+handle;var axis=$('<div class="ui-resizable-handle '+hname+'"></div>');if(/sw|se|ne|nw/.test(handle))axis.css({zIndex:++o.zIndex});if('se'==handle){axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se');};this.handles[handle]='.ui-resizable-'+handle;this.element.append(axis);}}
this._renderAxis=function(target){target=target||this.element;for(var i in this.handles){if(this.handles[i].constructor==String)
this.handles[i]=$(this.handles[i],this.element).show();if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var axis=$(this.handles[i],this.element),padWrapper=0;padWrapper=/sw|ne|nw|se|n|s/.test(i)?axis.outerHeight():axis.outerWidth();var padPos=['padding',/ne|nw|n/.test(i)?'Top':/se|sw|s/.test(i)?'Bottom':/^e$/.test(i)?'Right':'Left'].join("");target.css(padPos,padWrapper);this._proportionallyResize();}
if(!$(this.handles[i]).length)
continue;}};this._renderAxis(this.element);this._handles=$('.ui-resizable-handle',this.element).disableSelection();this._handles.mouseover(function(){if(!self.resizing){if(this.className)
var axis=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);self.axis=axis&&axis[1]?axis[1]:'se';}});if(o.autoHide){this._handles.hide();$(this.element).addClass("ui-resizable-autohide").hover(function(){$(this).removeClass("ui-resizable-autohide");self._handles.show();},function(){if(!self.resizing){$(this).addClass("ui-resizable-autohide");self._handles.hide();}});}
this._mouseInit();},destroy:function(){this._mouseDestroy();var _destroy=function(exp){$(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();};if(this.elementIsWrapper){_destroy(this.element);var wrapper=this.element;wrapper.parent().append(this.originalElement.css({position:wrapper.css('position'),width:wrapper.outerWidth(),height:wrapper.outerHeight(),top:wrapper.css('top'),left:wrapper.css('left')})).end().remove();}
this.originalElement.css('resize',this.originalResizeStyle);_destroy(this.originalElement);},_mouseCapture:function(event){var handle=false;for(var i in this.handles){if($(this.handles[i])[0]==event.target)handle=true;}
return this.options.disabled||!!handle;},_mouseStart:function(event){var o=this.options,iniPos=this.element.position(),el=this.element;this.resizing=true;this.documentScroll={top:$(document).scrollTop(),left:$(document).scrollLeft()};if(el.is('.ui-draggable')||(/absolute/).test(el.css('position'))){el.css({position:'absolute',top:iniPos.top,left:iniPos.left});}
if($.browser.opera&&(/relative/).test(el.css('position')))
el.css({position:'relative',top:'auto',left:'auto'});this._renderProxy();var curleft=num(this.helper.css('left')),curtop=num(this.helper.css('top'));if(o.containment){curleft+=$(o.containment).scrollLeft()||0;curtop+=$(o.containment).scrollTop()||0;}
this.offset=this.helper.offset();this.position={left:curleft,top:curtop};this.size=this._helper?{width:el.outerWidth(),height:el.outerHeight()}:{width:el.width(),height:el.height()};this.originalSize=this._helper?{width:el.outerWidth(),height:el.outerHeight()}:{width:el.width(),height:el.height()};this.originalPosition={left:curleft,top:curtop};this.sizeDiff={width:el.outerWidth()-el.width(),height:el.outerHeight()-el.height()};this.originalMousePosition={left:event.pageX,top:event.pageY};this.aspectRatio=(typeof o.aspectRatio=='number')?o.aspectRatio:((this.originalSize.width/this.originalSize.height)||1);var cursor=$('.ui-resizable-'+this.axis).css('cursor');$('body').css('cursor',cursor=='auto'?this.axis+'-resize':cursor);el.addClass("ui-resizable-resizing");this._propagate("start",event);return true;},_mouseDrag:function(event){var el=this.helper,o=this.options,props={},self=this,smp=this.originalMousePosition,a=this.axis;var dx=(event.pageX-smp.left)||0,dy=(event.pageY-smp.top)||0;var trigger=this._change[a];if(!trigger)return false;var data=trigger.apply(this,[event,dx,dy]),ie6=$.browser.msie&&$.browser.version<7,csdif=this.sizeDiff;if(this._aspectRatio||event.shiftKey)
data=this._updateRatio(data,event);data=this._respectSize(data,event);this._propagate("resize",event);el.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!this._helper&&this._proportionallyResizeElements.length)
this._proportionallyResize();this._updateCache(data);this._trigger('resize',event,this.ui());return false;},_mouseStop:function(event){this.resizing=false;var o=this.options,self=this;if(this._helper){var pr=this._proportionallyResizeElements,ista=pr.length&&(/textarea/i).test(pr[0].nodeName),soffseth=ista&&$.ui.hasScroll(pr[0],'left')?0:self.sizeDiff.height,soffsetw=ista?0:self.sizeDiff.width;var s={width:(self.size.width-soffsetw),height:(self.size.height-soffseth)},left=(parseInt(self.element.css('left'),10)+(self.position.left-self.originalPosition.left))||null,top=(parseInt(self.element.css('top'),10)+(self.position.top-self.originalPosition.top))||null;if(!o.animate)
this.element.css($.extend(s,{top:top,left:left}));self.helper.height(self.size.height);self.helper.width(self.size.width);if(this._helper&&!o.animate)this._proportionallyResize();}
$('body').css('cursor','auto');this.element.removeClass("ui-resizable-resizing");this._propagate("stop",event);if(this._helper)this.helper.remove();return false;},_updateCache:function(data){var o=this.options;this.offset=this.helper.offset();if(isNumber(data.left))this.position.left=data.left;if(isNumber(data.top))this.position.top=data.top;if(isNumber(data.height))this.size.height=data.height;if(isNumber(data.width))this.size.width=data.width;},_updateRatio:function(data,event){var o=this.options,cpos=this.position,csize=this.size,a=this.axis;if(data.height)data.width=(csize.height*this.aspectRatio);else if(data.width)data.height=(csize.width/this.aspectRatio);if(a=='sw'){data.left=cpos.left+(csize.width-data.width);data.top=null;}
if(a=='nw'){data.top=cpos.top+(csize.height-data.height);data.left=cpos.left+(csize.width-data.width);}
return data;},_respectSize:function(data,event){var el=this.helper,o=this.options,pRatio=this._aspectRatio||event.shiftKey,a=this.axis,ismaxw=isNumber(data.width)&&o.maxWidth&&(o.maxWidth<data.width),ismaxh=isNumber(data.height)&&o.maxHeight&&(o.maxHeight<data.height),isminw=isNumber(data.width)&&o.minWidth&&(o.minWidth>data.width),isminh=isNumber(data.height)&&o.minHeight&&(o.minHeight>data.height);if(isminw)data.width=o.minWidth;if(isminh)data.height=o.minHeight;if(ismaxw)data.width=o.maxWidth;if(ismaxh)data.height=o.maxHeight;var dw=this.originalPosition.left+this.originalSize.width,dh=this.position.top+this.size.height;var cw=/sw|nw|w/.test(a),ch=/nw|ne|n/.test(a);if(isminw&&cw)data.left=dw-o.minWidth;if(ismaxw&&cw)data.left=dw-o.maxWidth;if(isminh&&ch)data.top=dh-o.minHeight;if(ismaxh&&ch)data.top=dh-o.maxHeight;var isNotwh=!data.width&&!data.height;if(isNotwh&&!data.left&&data.top)data.top=null;else if(isNotwh&&!data.top&&data.left)data.left=null;return data;},_proportionallyResize:function(){var o=this.options;if(!this._proportionallyResizeElements.length)return;var element=this.helper||this.element;for(var i=0;i<this._proportionallyResizeElements.length;i++){var prel=this._proportionallyResizeElements[i];if(!this.borderDif){var b=[prel.css('borderTopWidth'),prel.css('borderRightWidth'),prel.css('borderBottomWidth'),prel.css('borderLeftWidth')],p=[prel.css('paddingTop'),prel.css('paddingRight'),prel.css('paddingBottom'),prel.css('paddingLeft')];this.borderDif=$.map(b,function(v,i){var border=parseInt(v,10)||0,padding=parseInt(p[i],10)||0;return border+padding;});}
if($.browser.msie&&!(!($(element).is(':hidden')||$(element).parents(':hidden').length)))
continue;prel.css({height:(element.height()-this.borderDif[0]-this.borderDif[2])||0,width:(element.width()-this.borderDif[1]-this.borderDif[3])||0});};},_renderProxy:function(){var el=this.element,o=this.options;this.elementOffset=el.offset();if(this._helper){this.helper=this.helper||$('<div style="overflow:hidden;"></div>');var ie6=$.browser.msie&&$.browser.version<7,ie6offset=(ie6?1:0),pxyoffset=(ie6?2:-1);this.helper.addClass(this._helper).css({width:this.element.outerWidth()+pxyoffset,height:this.element.outerHeight()+pxyoffset,position:'absolute',left:this.elementOffset.left-ie6offset+'px',top:this.elementOffset.top-ie6offset+'px',zIndex:++o.zIndex});this.helper.appendTo("body").disableSelection();}else{this.helper=this.element;}},_change:{e:function(event,dx,dy){return{width:this.originalSize.width+dx};},w:function(event,dx,dy){var o=this.options,cs=this.originalSize,sp=this.originalPosition;return{left:sp.left+dx,width:cs.width-dx};},n:function(event,dx,dy){var o=this.options,cs=this.originalSize,sp=this.originalPosition;return{top:sp.top+dy,height:cs.height-dy};},s:function(event,dx,dy){return{height:this.originalSize.height+dy};},se:function(event,dx,dy){return $.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[event,dx,dy]));},sw:function(event,dx,dy){return $.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[event,dx,dy]));},ne:function(event,dx,dy){return $.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[event,dx,dy]));},nw:function(event,dx,dy){return $.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[event,dx,dy]));}},_propagate:function(n,event){$.ui.plugin.call(this,n,[event,this.ui()]);(n!="resize"&&this._trigger(n,event,this.ui()));},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition};}}));$.extend($.ui.resizable,{version:"1.7.2",eventPrefix:"resize",defaults:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,cancel:":input,option",containment:false,delay:0,distance:1,ghost:false,grid:false,handles:"e,s,se",helper:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1000}});$.ui.plugin.add("resizable","alsoResize",{start:function(event,ui){var self=$(this).data("resizable"),o=self.options;_store=function(exp){$(exp).each(function(){$(this).data("resizable-alsoresize",{width:parseInt($(this).width(),10),height:parseInt($(this).height(),10),left:parseInt($(this).css('left'),10),top:parseInt($(this).css('top'),10)});});};if(typeof(o.alsoResize)=='object'&&!o.alsoResize.parentNode){if(o.alsoResize.length){o.alsoResize=o.alsoResize[0];_store(o.alsoResize);}
else{$.each(o.alsoResize,function(exp,c){_store(exp);});}}else{_store(o.alsoResize);}},resize:function(event,ui){var self=$(this).data("resizable"),o=self.options,os=self.originalSize,op=self.originalPosition;var delta={height:(self.size.height-os.height)||0,width:(self.size.width-os.width)||0,top:(self.position.top-op.top)||0,left:(self.position.left-op.left)||0},_alsoResize=function(exp,c){$(exp).each(function(){var el=$(this),start=$(this).data("resizable-alsoresize"),style={},css=c&&c.length?c:['width','height','top','left'];$.each(css||['width','height','top','left'],function(i,prop){var sum=(start[prop]||0)+(delta[prop]||0);if(sum&&sum>=0)
style[prop]=sum||null;});if(/relative/.test(el.css('position'))&&$.browser.opera){self._revertToRelativePosition=true;el.css({position:'absolute',top:'auto',left:'auto'});}
el.css(style);});};if(typeof(o.alsoResize)=='object'&&!o.alsoResize.nodeType){$.each(o.alsoResize,function(exp,c){_alsoResize(exp,c);});}else{_alsoResize(o.alsoResize);}},stop:function(event,ui){var self=$(this).data("resizable");if(self._revertToRelativePosition&&$.browser.opera){self._revertToRelativePosition=false;el.css({position:'relative'});}
$(this).removeData("resizable-alsoresize-start");}});$.ui.plugin.add("resizable","animate",{stop:function(event,ui){var self=$(this).data("resizable"),o=self.options;var pr=self._proportionallyResizeElements,ista=pr.length&&(/textarea/i).test(pr[0].nodeName),soffseth=ista&&$.ui.hasScroll(pr[0],'left')?0:self.sizeDiff.height,soffsetw=ista?0:self.sizeDiff.width;var style={width:(self.size.width-soffsetw),height:(self.size.height-soffseth)},left=(parseInt(self.element.css('left'),10)+(self.position.left-self.originalPosition.left))||null,top=(parseInt(self.element.css('top'),10)+(self.position.top-self.originalPosition.top))||null;self.element.animate($.extend(style,top&&left?{top:top,left:left}:{}),{duration:o.animateDuration,easing:o.animateEasing,step:function(){var data={width:parseInt(self.element.css('width'),10),height:parseInt(self.element.css('height'),10),top:parseInt(self.element.css('top'),10),left:parseInt(self.element.css('left'),10)};if(pr&&pr.length)$(pr[0]).css({width:data.width,height:data.height});self._updateCache(data);self._propagate("resize",event);}});}});$.ui.plugin.add("resizable","containment",{start:function(event,ui){var self=$(this).data("resizable"),o=self.options,el=self.element;var oc=o.containment,ce=(oc instanceof $)?oc.get(0):(/parent/.test(oc))?el.parent().get(0):oc;if(!ce)return;self.containerElement=$(ce);if(/document/.test(oc)||oc==document){self.containerOffset={left:0,top:0};self.containerPosition={left:0,top:0};self.parentData={element:$(document),left:0,top:0,width:$(document).width(),height:$(document).height()||document.body.parentNode.scrollHeight};}
else{var element=$(ce),p=[];$(["Top","Right","Left","Bottom"]).each(function(i,name){p[i]=num(element.css("padding"+name));});self.containerOffset=element.offset();self.containerPosition=element.position();self.containerSize={height:(element.innerHeight()-p[3]),width:(element.innerWidth()-p[1])};var co=self.containerOffset,ch=self.containerSize.height,cw=self.containerSize.width,width=($.ui.hasScroll(ce,"left")?ce.scrollWidth:cw),height=($.ui.hasScroll(ce)?ce.scrollHeight:ch);self.parentData={element:ce,left:co.left,top:co.top,width:width,height:height};}},resize:function(event,ui){var self=$(this).data("resizable"),o=self.options,ps=self.containerSize,co=self.containerOffset,cs=self.size,cp=self.position,pRatio=self._aspectRatio||event.shiftKey,cop={top:0,left:0},ce=self.containerElement;if(ce[0]!=document&&(/static/).test(ce.css('position')))cop=co;if(cp.left<(self._helper?co.left:0)){self.size.width=self.size.width+(self._helper?(self.position.left-co.left):(self.position.left-cop.left));if(pRatio)self.size.height=self.size.width/o.aspectRatio;self.position.left=o.helper?co.left:0;}
if(cp.top<(self._helper?co.top:0)){self.size.height=self.size.height+(self._helper?(self.position.top-co.top):self.position.top);if(pRatio)self.size.width=self.size.height*o.aspectRatio;self.position.top=self._helper?co.top:0;}
self.offset.left=self.parentData.left+self.position.left;self.offset.top=self.parentData.top+self.position.top;var woset=Math.abs((self._helper?self.offset.left-cop.left:(self.offset.left-cop.left))+self.sizeDiff.width),hoset=Math.abs((self._helper?self.offset.top-cop.top:(self.offset.top-co.top))+self.sizeDiff.height);var isParent=self.containerElement.get(0)==self.element.parent().get(0),isOffsetRelative=/relative|absolute/.test(self.containerElement.css('position'));if(isParent&&isOffsetRelative)woset-=self.parentData.left;if(woset+self.size.width>=self.parentData.width){self.size.width=self.parentData.width-woset;if(pRatio)self.size.height=self.size.width/self.aspectRatio;}
if(hoset+self.size.height>=self.parentData.height){self.size.height=self.parentData.height-hoset;if(pRatio)self.size.width=self.size.height*self.aspectRatio;}},stop:function(event,ui){var self=$(this).data("resizable"),o=self.options,cp=self.position,co=self.containerOffset,cop=self.containerPosition,ce=self.containerElement;var helper=$(self.helper),ho=helper.offset(),w=helper.outerWidth()-self.sizeDiff.width,h=helper.outerHeight()-self.sizeDiff.height;if(self._helper&&!o.animate&&(/relative/).test(ce.css('position')))
$(this).css({left:ho.left-cop.left-co.left,width:w,height:h});if(self._helper&&!o.animate&&(/static/).test(ce.css('position')))
$(this).css({left:ho.left-cop.left-co.left,width:w,height:h});}});$.ui.plugin.add("resizable","ghost",{start:function(event,ui){var self=$(this).data("resizable"),o=self.options,cs=self.size;self.ghost=self.originalElement.clone();self.ghost.css({opacity:.25,display:'block',position:'relative',height:cs.height,width:cs.width,margin:0,left:0,top:0}).addClass('ui-resizable-ghost').addClass(typeof o.ghost=='string'?o.ghost:'');self.ghost.appendTo(self.helper);},resize:function(event,ui){var self=$(this).data("resizable"),o=self.options;if(self.ghost)self.ghost.css({position:'relative',height:self.size.height,width:self.size.width});},stop:function(event,ui){var self=$(this).data("resizable"),o=self.options;if(self.ghost&&self.helper)self.helper.get(0).removeChild(self.ghost.get(0));}});$.ui.plugin.add("resizable","grid",{resize:function(event,ui){var self=$(this).data("resizable"),o=self.options,cs=self.size,os=self.originalSize,op=self.originalPosition,a=self.axis,ratio=o._aspectRatio||event.shiftKey;o.grid=typeof o.grid=="number"?[o.grid,o.grid]:o.grid;var ox=Math.round((cs.width-os.width)/(o.grid[0]||1))*(o.grid[0]||1),oy=Math.round((cs.height-os.height)/(o.grid[1]||1))*(o.grid[1]||1);if(/^(se|s|e)$/.test(a)){self.size.width=os.width+ox;self.size.height=os.height+oy;}
else if(/^(ne)$/.test(a)){self.size.width=os.width+ox;self.size.height=os.height+oy;self.position.top=op.top-oy;}
else if(/^(sw)$/.test(a)){self.size.width=os.width+ox;self.size.height=os.height+oy;self.position.left=op.left-ox;}
else{self.size.width=os.width+ox;self.size.height=os.height+oy;self.position.top=op.top-oy;self.position.left=op.left-ox;}}});var num=function(v){return parseInt(v,10)||0;};var isNumber=function(value){return!isNaN(parseInt(value,10));};})(jQuery);
// JS/jqUI/new/ui.resizable.js

(function($){$.widget("ui.draggable",$.extend({},$.ui.mouse,{_init:function(){if(this.options.helper=='original'&&!(/^(?:r|a|f)/).test(this.element.css("position")))
this.element[0].style.position='relative';(this.options.addClasses&&this.element.addClass("ui-draggable"));(this.options.disabled&&this.element.addClass("ui-draggable-disabled"));this._mouseInit();},destroy:function(){if(!this.element.data('draggable'))return;this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable"
+" ui-draggable-dragging"
+" ui-draggable-disabled");this._mouseDestroy();},_mouseCapture:function(event){var o=this.options;if(this.helper||o.disabled||$(event.target).is('.ui-resizable-handle'))
return false;this.handle=this._getHandle(event);if(!this.handle)
return false;return true;},_mouseStart:function(event){var o=this.options;this.helper=this._createHelper(event);this._cacheHelperProportions();if($.ui.ddmanager)
$.ui.ddmanager.current=this;this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};$.extend(this.offset,{click:{left:event.pageX-this.offset.left,top:event.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(event);this.originalPageX=event.pageX;this.originalPageY=event.pageY;if(o.cursorAt)
this._adjustOffsetFromHelper(o.cursorAt);if(o.containment)
this._setContainment();this._trigger("start",event);this._cacheHelperProportions();if($.ui.ddmanager&&!o.dropBehaviour)
$.ui.ddmanager.prepareOffsets(this,event);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(event,true);return true;},_mouseDrag:function(event,noPropagation){this.position=this._generatePosition(event);this.positionAbs=this._convertPositionTo("absolute");if(!noPropagation){var ui=this._uiHash();this._trigger('drag',event,ui);this.position=ui.position;}
if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+'px';if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+'px';if($.ui.ddmanager)$.ui.ddmanager.drag(this,event);return false;},_mouseStop:function(event){var dropped=false;if($.ui.ddmanager&&!this.options.dropBehaviour)
dropped=$.ui.ddmanager.drop(this,event);if(this.dropped){dropped=this.dropped;this.dropped=false;}
if((this.options.revert=="invalid"&&!dropped)||(this.options.revert=="valid"&&dropped)||this.options.revert===true||($.isFunction(this.options.revert)&&this.options.revert.call(this.element,dropped))){var self=this;$(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){self._trigger("stop",event);self._clear();});}else{this._trigger("stop",event);this._clear();}
return false;},_getHandle:function(event){var handle=!this.options.handle||!$(this.options.handle,this.element).length?true:false;$(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==event.target)handle=true;});return handle;},_createHelper:function(event){var o=this.options;var helper=$.isFunction(o.helper)?$(o.helper.apply(this.element[0],[event])):(o.helper=='clone'?this.element.clone():this.element);if(!helper.parents('body').length)
helper.appendTo((o.appendTo=='parent'?this.element[0].parentNode:o.appendTo));if(helper[0]!=this.element[0]&&!(/(fixed|absolute)/).test(helper.css("position")))
helper.css("position","absolute");return helper;},_adjustOffsetFromHelper:function(obj){if(obj.left!=undefined)this.offset.click.left=obj.left+this.margins.left;if(obj.right!=undefined)this.offset.click.left=this.helperProportions.width-obj.right+this.margins.left;if(obj.top!=undefined)this.offset.click.top=obj.top+this.margins.top;if(obj.bottom!=undefined)this.offset.click.top=this.helperProportions.height-obj.bottom+this.margins.top;},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var po=this.offsetParent.offset();if(this.cssPosition=='absolute'&&this.scrollParent[0]!=document&&$.ui.contains(this.scrollParent[0],this.offsetParent[0])){po.left+=this.scrollParent.scrollLeft();po.top+=this.scrollParent.scrollTop();}
if((this.offsetParent[0]==document.body)||(this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=='html'&&$.browser.msie))
po={top:0,left:0};return{top:po.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:po.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)};},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var p=this.element.position();return{top:p.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:p.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()};}else{return{top:0,left:0};}},_cacheMargins:function(){this.margins={left:(parseInt(this.element.css("marginLeft"),10)||0),top:(parseInt(this.element.css("marginTop"),10)||0)};},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};},_setContainment:function(){var o=this.options;if(o.containment=='parent')o.containment=this.helper[0].parentNode;if(o.containment=='document'||o.containment=='window')this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,$(o.containment=='document'?document:window).width()-this.helperProportions.width-this.margins.left,($(o.containment=='document'?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!(/^(document|window|parent)$/).test(o.containment)&&o.containment.constructor!=Array){var ce=$(o.containment)[0];if(!ce)return;var co=$(o.containment).offset();var over=($(ce).css("overflow")!='hidden');this.containment=[co.left+(parseInt($(ce).css("borderLeftWidth"),10)||0)+(parseInt($(ce).css("paddingLeft"),10)||0)-this.margins.left,co.top+(parseInt($(ce).css("borderTopWidth"),10)||0)+(parseInt($(ce).css("paddingTop"),10)||0)-this.margins.top,co.left+(over?Math.max(ce.scrollWidth,ce.offsetWidth):ce.offsetWidth)-(parseInt($(ce).css("borderLeftWidth"),10)||0)-(parseInt($(ce).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,co.top+(over?Math.max(ce.scrollHeight,ce.offsetHeight):ce.offsetHeight)-(parseInt($(ce).css("borderTopWidth"),10)||0)-(parseInt($(ce).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top];}else if(o.containment.constructor==Array){this.containment=o.containment;}},_convertPositionTo:function(d,pos){if(!pos)pos=this.position;var mod=d=="absolute"?1:-1;var o=this.options,scroll=this.cssPosition=='absolute'&&!(this.scrollParent[0]!=document&&$.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,scrollIsRootNode=(/(html|body)/i).test(scroll[0].tagName);return{top:(pos.top
+this.offset.relative.top*mod
+this.offset.parent.top*mod
-($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollTop():(scrollIsRootNode?0:scroll.scrollTop()))*mod)),left:(pos.left
+this.offset.relative.left*mod
+this.offset.parent.left*mod
-($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollLeft():scrollIsRootNode?0:scroll.scrollLeft())*mod))};},_generatePosition:function(event){var o=this.options,scroll=this.cssPosition=='absolute'&&!(this.scrollParent[0]!=document&&$.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,scrollIsRootNode=(/(html|body)/i).test(scroll[0].tagName);if(this.cssPosition=='relative'&&!(this.scrollParent[0]!=document&&this.scrollParent[0]!=this.offsetParent[0])){this.offset.relative=this._getRelativeOffset();}
var pageX=event.pageX;var pageY=event.pageY;if(this.originalPosition){if(this.containment){if(event.pageX-this.offset.click.left<this.containment[0])pageX=this.containment[0]+this.offset.click.left;if(event.pageY-this.offset.click.top<this.containment[1])pageY=this.containment[1]+this.offset.click.top;if(event.pageX-this.offset.click.left>this.containment[2])pageX=this.containment[2]+this.offset.click.left;if(event.pageY-this.offset.click.top>this.containment[3])pageY=this.containment[3]+this.offset.click.top;}
if(o.grid){var top=this.originalPageY+Math.round((pageY-this.originalPageY)/o.grid[1])*o.grid[1];pageY=this.containment?(!(top-this.offset.click.top<this.containment[1]||top-this.offset.click.top>this.containment[3])?top:(!(top-this.offset.click.top<this.containment[1])?top-o.grid[1]:top+o.grid[1])):top;var left=this.originalPageX+Math.round((pageX-this.originalPageX)/o.grid[0])*o.grid[0];pageX=this.containment?(!(left-this.offset.click.left<this.containment[0]||left-this.offset.click.left>this.containment[2])?left:(!(left-this.offset.click.left<this.containment[0])?left-o.grid[0]:left+o.grid[0])):left;}}
return{top:(pageY
-this.offset.click.top
-this.offset.relative.top
-this.offset.parent.top
+($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollTop():(scrollIsRootNode?0:scroll.scrollTop())))),left:(pageX
-this.offset.click.left
-this.offset.relative.left
-this.offset.parent.left
+($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollLeft():scrollIsRootNode?0:scroll.scrollLeft())))};},_clear:function(){this.helper.removeClass("ui-draggable-dragging");if(this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval)this.helper.remove();this.helper=null;this.cancelHelperRemoval=false;},_trigger:function(type,event,ui){ui=ui||this._uiHash();$.ui.plugin.call(this,type,[event,ui]);if(type=="drag")this.positionAbs=this._convertPositionTo("absolute");return $.widget.prototype._trigger.call(this,type,event,ui);},plugins:{},_uiHash:function(event){return{helper:this.helper,position:this.position,absolutePosition:this.positionAbs,offset:this.positionAbs};}}));$.extend($.ui.draggable,{version:"1.7.2",eventPrefix:"drag",defaults:{addClasses:true,appendTo:"parent",axis:false,cancel:":input,option",connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,delay:0,distance:1,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false}});$.ui.plugin.add("draggable","connectToSortable",{start:function(event,ui){var inst=$(this).data("draggable"),o=inst.options,uiSortable=$.extend({},ui,{item:inst.element});inst.sortables=[];$(o.connectToSortable).each(function(){var sortable=$.data(this,'sortable');if(sortable&&!sortable.options.disabled){inst.sortables.push({instance:sortable,shouldRevert:sortable.options.revert});sortable._refreshItems();sortable._trigger("activate",event,uiSortable);}});},stop:function(event,ui){var inst=$(this).data("draggable"),uiSortable=$.extend({},ui,{item:inst.element});$.each(inst.sortables,function(){if(this.instance.isOver){this.instance.isOver=0;inst.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert)this.instance.options.revert=true;this.instance._mouseStop(event);this.instance.options.helper=this.instance.options._helper;if(inst.options.helper=='original')
this.instance.currentItem.css({top:'auto',left:'auto'});}else{this.instance.cancelHelperRemoval=false;this.instance._trigger("deactivate",event,uiSortable);}});},drag:function(event,ui){var inst=$(this).data("draggable"),self=this;var checkPos=function(o){var dyClick=this.offset.click.top,dxClick=this.offset.click.left;var helperTop=this.positionAbs.top,helperLeft=this.positionAbs.left;var itemHeight=o.height,itemWidth=o.width;var itemTop=o.top,itemLeft=o.left;return $.ui.isOver(helperTop+dyClick,helperLeft+dxClick,itemTop,itemLeft,itemHeight,itemWidth);};$.each(inst.sortables,function(i){this.instance.positionAbs=inst.positionAbs;this.instance.helperProportions=inst.helperProportions;this.instance.offset.click=inst.offset.click;if(this.instance._intersectsWith(this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=$(self).clone().appendTo(this.instance.element).data("sortable-item",true);this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return ui.helper[0];};event.target=this.instance.currentItem[0];this.instance._mouseCapture(event,true);this.instance._mouseStart(event,true,true);this.instance.offset.click.top=inst.offset.click.top;this.instance.offset.click.left=inst.offset.click.left;this.instance.offset.parent.left-=inst.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=inst.offset.parent.top-this.instance.offset.parent.top;inst._trigger("toSortable",event);inst.dropped=this.instance.element;inst.currentItem=inst.element;this.instance.fromOutside=inst;}
if(this.instance.currentItem)this.instance._mouseDrag(event);}else{if(this.instance.isOver){this.instance.isOver=0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance._trigger('out',event,this.instance._uiHash(this.instance));this.instance._mouseStop(event,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();if(this.instance.placeholder)this.instance.placeholder.remove();inst._trigger("fromSortable",event);inst.dropped=false;}};});}});$.ui.plugin.add("draggable","cursor",{start:function(event,ui){var t=$('body'),o=$(this).data('draggable').options;if(t.css("cursor"))o._cursor=t.css("cursor");t.css("cursor",o.cursor);},stop:function(event,ui){var o=$(this).data('draggable').options;if(o._cursor)$('body').css("cursor",o._cursor);}});$.ui.plugin.add("draggable","iframeFix",{start:function(event,ui){var o=$(this).data('draggable').options;$(o.iframeFix===true?"iframe":o.iframeFix).each(function(){$('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1000}).css($(this).offset()).appendTo("body");});},stop:function(event,ui){$("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this);});}});$.ui.plugin.add("draggable","opacity",{start:function(event,ui){var t=$(ui.helper),o=$(this).data('draggable').options;if(t.css("opacity"))o._opacity=t.css("opacity");t.css('opacity',o.opacity);},stop:function(event,ui){var o=$(this).data('draggable').options;if(o._opacity)$(ui.helper).css('opacity',o._opacity);}});$.ui.plugin.add("draggable","scroll",{start:function(event,ui){var i=$(this).data("draggable");if(i.scrollParent[0]!=document&&i.scrollParent[0].tagName!='HTML')i.overflowOffset=i.scrollParent.offset();},drag:function(event,ui){var i=$(this).data("draggable"),o=i.options,scrolled=false;if(i.scrollParent[0]!=document&&i.scrollParent[0].tagName!='HTML'){if(!o.axis||o.axis!='x'){if((i.overflowOffset.top+i.scrollParent[0].offsetHeight)-event.pageY<o.scrollSensitivity)
i.scrollParent[0].scrollTop=scrolled=i.scrollParent[0].scrollTop+o.scrollSpeed;else if(event.pageY-i.overflowOffset.top<o.scrollSensitivity)
i.scrollParent[0].scrollTop=scrolled=i.scrollParent[0].scrollTop-o.scrollSpeed;}
if(!o.axis||o.axis!='y'){if((i.overflowOffset.left+i.scrollParent[0].offsetWidth)-event.pageX<o.scrollSensitivity)
i.scrollParent[0].scrollLeft=scrolled=i.scrollParent[0].scrollLeft+o.scrollSpeed;else if(event.pageX-i.overflowOffset.left<o.scrollSensitivity)
i.scrollParent[0].scrollLeft=scrolled=i.scrollParent[0].scrollLeft-o.scrollSpeed;}}else{if(!o.axis||o.axis!='x'){if(event.pageY-$(document).scrollTop()<o.scrollSensitivity)
scrolled=$(document).scrollTop($(document).scrollTop()-o.scrollSpeed);else if($(window).height()-(event.pageY-$(document).scrollTop())<o.scrollSensitivity)
scrolled=$(document).scrollTop($(document).scrollTop()+o.scrollSpeed);}
if(!o.axis||o.axis!='y'){if(event.pageX-$(document).scrollLeft()<o.scrollSensitivity)
scrolled=$(document).scrollLeft($(document).scrollLeft()-o.scrollSpeed);else if($(window).width()-(event.pageX-$(document).scrollLeft())<o.scrollSensitivity)
scrolled=$(document).scrollLeft($(document).scrollLeft()+o.scrollSpeed);}}
if(scrolled!==false&&$.ui.ddmanager&&!o.dropBehaviour)
$.ui.ddmanager.prepareOffsets(i,event);}});$.ui.plugin.add("draggable","snap",{start:function(event,ui){var i=$(this).data("draggable"),o=i.options;i.snapElements=[];$(o.snap.constructor!=String?(o.snap.items||':data(draggable)'):o.snap).each(function(){var $t=$(this);var $o=$t.offset();if(this!=i.element[0])i.snapElements.push({item:this,width:$t.outerWidth(),height:$t.outerHeight(),top:$o.top,left:$o.left});});},drag:function(event,ui){var inst=$(this).data("draggable"),o=inst.options;var d=o.snapTolerance;var x1=ui.offset.left,x2=x1+inst.helperProportions.width,y1=ui.offset.top,y2=y1+inst.helperProportions.height;for(var i=inst.snapElements.length-1;i>=0;i--){var l=inst.snapElements[i].left,r=l+inst.snapElements[i].width,t=inst.snapElements[i].top,b=t+inst.snapElements[i].height;if(!((l-d<x1&&x1<r+d&&t-d<y1&&y1<b+d)||(l-d<x1&&x1<r+d&&t-d<y2&&y2<b+d)||(l-d<x2&&x2<r+d&&t-d<y1&&y1<b+d)||(l-d<x2&&x2<r+d&&t-d<y2&&y2<b+d))){if(inst.snapElements[i].snapping)(inst.options.snap.release&&inst.options.snap.release.call(inst.element,event,$.extend(inst._uiHash(),{snapItem:inst.snapElements[i].item})));inst.snapElements[i].snapping=false;continue;}
if(o.snapMode!='inner'){var ts=Math.abs(t-y2)<=d;var bs=Math.abs(b-y1)<=d;var ls=Math.abs(l-x2)<=d;var rs=Math.abs(r-x1)<=d;if(ts)ui.position.top=inst._convertPositionTo("relative",{top:t-inst.helperProportions.height,left:0}).top-inst.margins.top;if(bs)ui.position.top=inst._convertPositionTo("relative",{top:b,left:0}).top-inst.margins.top;if(ls)ui.position.left=inst._convertPositionTo("relative",{top:0,left:l-inst.helperProportions.width}).left-inst.margins.left;if(rs)ui.position.left=inst._convertPositionTo("relative",{top:0,left:r}).left-inst.margins.left;}
var first=(ts||bs||ls||rs);if(o.snapMode!='outer'){var ts=Math.abs(t-y1)<=d;var bs=Math.abs(b-y2)<=d;var ls=Math.abs(l-x1)<=d;var rs=Math.abs(r-x2)<=d;if(ts)ui.position.top=inst._convertPositionTo("relative",{top:t,left:0}).top-inst.margins.top;if(bs)ui.position.top=inst._convertPositionTo("relative",{top:b-inst.helperProportions.height,left:0}).top-inst.margins.top;if(ls)ui.position.left=inst._convertPositionTo("relative",{top:0,left:l}).left-inst.margins.left;if(rs)ui.position.left=inst._convertPositionTo("relative",{top:0,left:r-inst.helperProportions.width}).left-inst.margins.left;}
if(!inst.snapElements[i].snapping&&(ts||bs||ls||rs||first))
(inst.options.snap.snap&&inst.options.snap.snap.call(inst.element,event,$.extend(inst._uiHash(),{snapItem:inst.snapElements[i].item})));inst.snapElements[i].snapping=(ts||bs||ls||rs||first);};}});$.ui.plugin.add("draggable","stack",{start:function(event,ui){var o=$(this).data("draggable").options;var group=$.makeArray($(o.stack.group)).sort(function(a,b){return(parseInt($(a).css("zIndex"),10)||o.stack.min)-(parseInt($(b).css("zIndex"),10)||o.stack.min);});$(group).each(function(i){this.style.zIndex=o.stack.min+i;});this[0].style.zIndex=o.stack.min+group.length;}});$.ui.plugin.add("draggable","zIndex",{start:function(event,ui){var t=$(ui.helper),o=$(this).data("draggable").options;if(t.css("zIndex"))o._zIndex=t.css("zIndex");t.css('zIndex',o.zIndex);},stop:function(event,ui){var o=$(this).data("draggable").options;if(o._zIndex)$(ui.helper).css('zIndex',o._zIndex);}});})(jQuery);
// JS/jqUI/new/ui.draggable.js

(function($){$.widget("ui.droppable",{_init:function(){var o=this.options,accept=o.accept;this.isover=0;this.isout=1;this.options.accept=this.options.accept&&$.isFunction(this.options.accept)?this.options.accept:function(d){return d.is(accept);};this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight};$.ui.ddmanager.droppables[this.options.scope]=$.ui.ddmanager.droppables[this.options.scope]||[];$.ui.ddmanager.droppables[this.options.scope].push(this);(this.options.addClasses&&this.element.addClass("ui-droppable"));},destroy:function(){var drop=$.ui.ddmanager.droppables[this.options.scope];for(var i=0;i<drop.length;i++)
if(drop[i]==this)
drop.splice(i,1);this.element.removeClass("ui-droppable ui-droppable-disabled").removeData("droppable").unbind(".droppable");},_setData:function(key,value){if(key=='accept'){this.options.accept=value&&$.isFunction(value)?value:function(d){return d.is(value);};}else{$.widget.prototype._setData.apply(this,arguments);}},_activate:function(event){var draggable=$.ui.ddmanager.current;if(this.options.activeClass)this.element.addClass(this.options.activeClass);(draggable&&this._trigger('activate',event,this.ui(draggable)));},_deactivate:function(event){var draggable=$.ui.ddmanager.current;if(this.options.activeClass)this.element.removeClass(this.options.activeClass);(draggable&&this._trigger('deactivate',event,this.ui(draggable)));},_over:function(event){var draggable=$.ui.ddmanager.current;if(!draggable||(draggable.currentItem||draggable.element)[0]==this.element[0])return;if(this.options.accept.call(this.element[0],(draggable.currentItem||draggable.element))){if(this.options.hoverClass)this.element.addClass(this.options.hoverClass);this._trigger('over',event,this.ui(draggable));}},_out:function(event){var draggable=$.ui.ddmanager.current;if(!draggable||(draggable.currentItem||draggable.element)[0]==this.element[0])return;if(this.options.accept.call(this.element[0],(draggable.currentItem||draggable.element))){if(this.options.hoverClass)this.element.removeClass(this.options.hoverClass);this._trigger('out',event,this.ui(draggable));}},_drop:function(event,custom){var draggable=custom||$.ui.ddmanager.current;if(!draggable||(draggable.currentItem||draggable.element)[0]==this.element[0])return false;var childrenIntersection=false;this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function(){var inst=$.data(this,'droppable');if(inst.options.greedy&&$.ui.intersect(draggable,$.extend(inst,{offset:inst.element.offset()}),inst.options.tolerance)){childrenIntersection=true;return false;}});if(childrenIntersection)return false;if(this.options.accept.call(this.element[0],(draggable.currentItem||draggable.element))){if(this.options.activeClass)this.element.removeClass(this.options.activeClass);if(this.options.hoverClass)this.element.removeClass(this.options.hoverClass);this._trigger('drop',event,this.ui(draggable));return this.element;}
return false;},ui:function(c){return{draggable:(c.currentItem||c.element),helper:c.helper,position:c.position,absolutePosition:c.positionAbs,offset:c.positionAbs};}});$.extend($.ui.droppable,{version:"1.7.2",eventPrefix:'drop',defaults:{accept:'*',activeClass:false,addClasses:true,greedy:false,hoverClass:false,scope:'default',tolerance:'intersect'}});$.ui.intersect=function(draggable,droppable,toleranceMode){if(!droppable.offset)return false;var x1=(draggable.positionAbs||draggable.position.absolute).left,x2=x1+draggable.helperProportions.width,y1=(draggable.positionAbs||draggable.position.absolute).top,y2=y1+draggable.helperProportions.height;var l=droppable.offset.left,r=l+droppable.proportions.width,t=droppable.offset.top,b=t+droppable.proportions.height;switch(toleranceMode){case'fit':return(l<x1&&x2<r&&t<y1&&y2<b);break;case'intersect':return(l<x1+(draggable.helperProportions.width/2)&&x2-(draggable.helperProportions.width/2)<r&&t<y1+(draggable.helperProportions.height/2)&&y2-(draggable.helperProportions.height/2)<b);break;case'pointer':var draggableLeft=((draggable.positionAbs||draggable.position.absolute).left+(draggable.clickOffset||draggable.offset.click).left),draggableTop=((draggable.positionAbs||draggable.position.absolute).top+(draggable.clickOffset||draggable.offset.click).top),isOver=$.ui.isOver(draggableTop,draggableLeft,t,l,droppable.proportions.height,droppable.proportions.width);return isOver;break;case'touch':return((y1>=t&&y1<=b)||(y2>=t&&y2<=b)||(y1<t&&y2>b))&&((x1>=l&&x1<=r)||(x2>=l&&x2<=r)||(x1<l&&x2>r));break;default:return false;break;}};$.ui.ddmanager={current:null,droppables:{'default':[]},prepareOffsets:function(t,event){var m=$.ui.ddmanager.droppables[t.options.scope];var type=event?event.type:null;var list=(t.currentItem||t.element).find(":data(droppable)").andSelf();droppablesLoop:for(var i=0;i<m.length;i++){if(m[i].options.disabled||(t&&!m[i].options.accept.call(m[i].element[0],(t.currentItem||t.element))))continue;for(var j=0;j<list.length;j++){if(list[j]==m[i].element[0]){m[i].proportions.height=0;continue droppablesLoop;}};m[i].visible=m[i].element.css("display")!="none";if(!m[i].visible)continue;m[i].offset=m[i].element.offset();m[i].proportions={width:m[i].element[0].offsetWidth,height:m[i].element[0].offsetHeight};if(type=="mousedown")m[i]._activate.call(m[i],event);}},drop:function(draggable,event){var dropped=false;$.each($.ui.ddmanager.droppables[draggable.options.scope],function(){if(!this.options)return;if(!this.options.disabled&&this.visible&&$.ui.intersect(draggable,this,this.options.tolerance))
dropped=this._drop.call(this,event);if(!this.options.disabled&&this.visible&&this.options.accept.call(this.element[0],(draggable.currentItem||draggable.element))){this.isout=1;this.isover=0;this._deactivate.call(this,event);}});return dropped;},drag:function(draggable,event){if(draggable.options.refreshPositions)$.ui.ddmanager.prepareOffsets(draggable,event);$.each($.ui.ddmanager.droppables[draggable.options.scope],function(){if(this.options.disabled||this.greedyChild||!this.visible)return;var intersects=$.ui.intersect(draggable,this,this.options.tolerance);var c=!intersects&&this.isover==1?'isout':(intersects&&this.isover==0?'isover':null);if(!c)return;var parentInstance;if(this.options.greedy){var parent=this.element.parents(':data(droppable):eq(0)');if(parent.length){parentInstance=$.data(parent[0],'droppable');parentInstance.greedyChild=(c=='isover'?1:0);}}
if(parentInstance&&c=='isover'){parentInstance['isover']=0;parentInstance['isout']=1;parentInstance._out.call(parentInstance,event);}
this[c]=1;this[c=='isout'?'isover':'isout']=0;this[c=="isover"?"_over":"_out"].call(this,event);if(parentInstance&&c=='isout'){parentInstance['isout']=0;parentInstance['isover']=1;parentInstance._over.call(parentInstance,event);}});}};})(jQuery);
// JS/jqUI/new/ui.droppable.js

(function($){$.widget("ui.selectable",$.extend({},$.ui.mouse,{_init:function(){var self=this;this.element.addClass("ui-selectable");this.dragged=false;var selectees;this.refresh=function(){selectees=$(self.options.filter,self.element[0]);selectees.each(function(){var $this=$(this);var pos=$this.offset();$.data(this,"selectable-item",{element:this,$element:$this,left:pos.left,top:pos.top,right:pos.left+$this.outerWidth(),bottom:pos.top+$this.outerHeight(),startselected:false,selected:$this.hasClass('ui-selected'),selecting:$this.hasClass('ui-selecting'),unselecting:$this.hasClass('ui-unselecting')});});};this.refresh();this.selectees=selectees.addClass("ui-selectee");this._mouseInit();this.helper=$(document.createElement('div')).css({border:'1px dotted black'}).addClass("ui-selectable-helper");},destroy:function(){this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();},_mouseStart:function(event){var self=this;this.opos=[event.pageX,event.pageY];if(this.options.disabled)
return;var options=this.options;this.selectees=$(options.filter,this.element[0]);this._trigger("start",event);$(options.appendTo).append(this.helper);this.helper.css({"z-index":100,"position":"absolute","left":event.clientX,"top":event.clientY,"width":0,"height":0});if(options.autoRefresh){this.refresh();}
this.selectees.filter('.ui-selected').each(function(){var selectee=$.data(this,"selectable-item");selectee.startselected=true;if(!event.metaKey){selectee.$element.removeClass('ui-selected');selectee.selected=false;selectee.$element.addClass('ui-unselecting');selectee.unselecting=true;self._trigger("unselecting",event,{unselecting:selectee.element});}});$(event.target).parents().andSelf().each(function(){var selectee=$.data(this,"selectable-item");if(selectee){selectee.$element.removeClass("ui-unselecting").addClass('ui-selecting');selectee.unselecting=false;selectee.selecting=true;selectee.selected=true;self._trigger("selecting",event,{selecting:selectee.element});return false;}});},_mouseDrag:function(event){var self=this;this.dragged=true;if(this.options.disabled)
return;var options=this.options;var x1=this.opos[0],y1=this.opos[1],x2=event.pageX,y2=event.pageY;if(x1>x2){var tmp=x2;x2=x1;x1=tmp;}
if(y1>y2){var tmp=y2;y2=y1;y1=tmp;}
this.helper.css({left:x1,top:y1,width:x2-x1,height:y2-y1});this.selectees.each(function(){var selectee=$.data(this,"selectable-item");if(!selectee||selectee.element==self.element[0])
return;var hit=false;if(options.tolerance=='touch'){hit=(!(selectee.left>x2||selectee.right<x1||selectee.top>y2||selectee.bottom<y1));}else if(options.tolerance=='fit'){hit=(selectee.left>x1&&selectee.right<x2&&selectee.top>y1&&selectee.bottom<y2);}
if(hit){if(selectee.selected){selectee.$element.removeClass('ui-selected');selectee.selected=false;}
if(selectee.unselecting){selectee.$element.removeClass('ui-unselecting');selectee.unselecting=false;}
if(!selectee.selecting){selectee.$element.addClass('ui-selecting');selectee.selecting=true;self._trigger("selecting",event,{selecting:selectee.element});}}else{if(selectee.selecting){if(event.metaKey&&selectee.startselected){selectee.$element.removeClass('ui-selecting');selectee.selecting=false;selectee.$element.addClass('ui-selected');selectee.selected=true;}else{selectee.$element.removeClass('ui-selecting');selectee.selecting=false;if(selectee.startselected){selectee.$element.addClass('ui-unselecting');selectee.unselecting=true;}
self._trigger("unselecting",event,{unselecting:selectee.element});}}
if(selectee.selected){if(!event.metaKey&&!selectee.startselected){selectee.$element.removeClass('ui-selected');selectee.selected=false;selectee.$element.addClass('ui-unselecting');selectee.unselecting=true;self._trigger("unselecting",event,{unselecting:selectee.element});}}}});return false;},_mouseStop:function(event){var self=this;this.dragged=false;var options=this.options;$('.ui-unselecting',this.element[0]).each(function(){var selectee=$.data(this,"selectable-item");selectee.$element.removeClass('ui-unselecting');selectee.unselecting=false;selectee.startselected=false;self._trigger("unselected",event,{unselected:selectee.element});});$('.ui-selecting',this.element[0]).each(function(){var selectee=$.data(this,"selectable-item");selectee.$element.removeClass('ui-selecting').addClass('ui-selected');selectee.selecting=false;selectee.selected=true;selectee.startselected=true;self._trigger("selected",event,{selected:selectee.element});});this._trigger("stop",event);this.helper.remove();return false;}}));$.extend($.ui.selectable,{version:"1.7.2",defaults:{appendTo:'body',autoRefresh:true,cancel:":input,option",delay:0,distance:0,filter:'*',tolerance:'touch'}});})(jQuery);
// JS/jqUI/new/ui.selectable.js

(function($){$.widget("ui.sortable",$.extend({},$.ui.mouse,{_init:function(){var o=this.options;this.containerCache={};this.element.addClass("ui-sortable");this.refresh();this.floating=this.items.length?(/left|right/).test(this.items[0].item.css('float')):false;this.offset=this.element.offset();this._mouseInit();},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this._mouseDestroy();for(var i=this.items.length-1;i>=0;i--)
this.items[i].item.removeData("sortable-item");},_mouseCapture:function(event,overrideHandle){if(this.reverting){return false;}
if(this.options.disabled||this.options.type=='static')return false;this._refreshItems(event);var currentItem=null,self=this,nodes=$(event.target).parents().each(function(){if($.data(this,'sortable-item')==self){currentItem=$(this);return false;}});if($.data(event.target,'sortable-item')==self)currentItem=$(event.target);if(!currentItem)return false;if(this.options.handle&&!overrideHandle){var validHandle=false;$(this.options.handle,currentItem).find("*").andSelf().each(function(){if(this==event.target)validHandle=true;});if(!validHandle)return false;}
this.currentItem=currentItem;this._removeCurrentsFromItems();return true;},_mouseStart:function(event,overrideHandle,noActivation){var o=this.options,self=this;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(event);this._cacheHelperProportions();this._cacheMargins();this.scrollParent=this.helper.scrollParent();this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.helper.css("position","absolute");this.cssPosition=this.helper.css("position");$.extend(this.offset,{click:{left:event.pageX-this.offset.left,top:event.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(event);this.originalPageX=event.pageX;this.originalPageY=event.pageY;if(o.cursorAt)
this._adjustOffsetFromHelper(o.cursorAt);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]};if(this.helper[0]!=this.currentItem[0]){this.currentItem.hide();}
this._createPlaceholder();if(o.containment)
this._setContainment();if(o.cursor){if($('body').css("cursor"))this._storedCursor=$('body').css("cursor");$('body').css("cursor",o.cursor);}
if(o.opacity){if(this.helper.css("opacity"))this._storedOpacity=this.helper.css("opacity");this.helper.css("opacity",o.opacity);}
if(o.zIndex){if(this.helper.css("zIndex"))this._storedZIndex=this.helper.css("zIndex");this.helper.css("zIndex",o.zIndex);}
if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!='HTML')
this.overflowOffset=this.scrollParent.offset();this._trigger("start",event,this._uiHash());if(!this._preserveHelperProportions)
this._cacheHelperProportions();if(!noActivation){for(var i=this.containers.length-1;i>=0;i--){this.containers[i]._trigger("activate",event,self._uiHash(this));}}
if($.ui.ddmanager)
$.ui.ddmanager.current=this;if($.ui.ddmanager&&!o.dropBehaviour)
$.ui.ddmanager.prepareOffsets(this,event);this.dragging=true;this.helper.addClass("ui-sortable-helper");this._mouseDrag(event);return true;},_mouseDrag:function(event){this.position=this._generatePosition(event);this.positionAbs=this._convertPositionTo("absolute");if(!this.lastPositionAbs){this.lastPositionAbs=this.positionAbs;}
if(this.options.scroll){var o=this.options,scrolled=false;if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!='HTML'){if((this.overflowOffset.top+this.scrollParent[0].offsetHeight)-event.pageY<o.scrollSensitivity)
this.scrollParent[0].scrollTop=scrolled=this.scrollParent[0].scrollTop+o.scrollSpeed;else if(event.pageY-this.overflowOffset.top<o.scrollSensitivity)
this.scrollParent[0].scrollTop=scrolled=this.scrollParent[0].scrollTop-o.scrollSpeed;if((this.overflowOffset.left+this.scrollParent[0].offsetWidth)-event.pageX<o.scrollSensitivity)
this.scrollParent[0].scrollLeft=scrolled=this.scrollParent[0].scrollLeft+o.scrollSpeed;else if(event.pageX-this.overflowOffset.left<o.scrollSensitivity)
this.scrollParent[0].scrollLeft=scrolled=this.scrollParent[0].scrollLeft-o.scrollSpeed;}else{if(event.pageY-$(document).scrollTop()<o.scrollSensitivity)
scrolled=$(document).scrollTop($(document).scrollTop()-o.scrollSpeed);else if($(window).height()-(event.pageY-$(document).scrollTop())<o.scrollSensitivity)
scrolled=$(document).scrollTop($(document).scrollTop()+o.scrollSpeed);if(event.pageX-$(document).scrollLeft()<o.scrollSensitivity)
scrolled=$(document).scrollLeft($(document).scrollLeft()-o.scrollSpeed);else if($(window).width()-(event.pageX-$(document).scrollLeft())<o.scrollSensitivity)
scrolled=$(document).scrollLeft($(document).scrollLeft()+o.scrollSpeed);}
if(scrolled!==false&&$.ui.ddmanager&&!o.dropBehaviour)
$.ui.ddmanager.prepareOffsets(this,event);}
this.positionAbs=this._convertPositionTo("absolute");if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+'px';if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+'px';for(var i=this.items.length-1;i>=0;i--){var item=this.items[i],itemElement=item.item[0],intersection=this._intersectsWithPointer(item);if(!intersection)continue;if(itemElement!=this.currentItem[0]&&this.placeholder[intersection==1?"next":"prev"]()[0]!=itemElement&&!$.ui.contains(this.placeholder[0],itemElement)&&(this.options.type=='semi-dynamic'?!$.ui.contains(this.element[0],itemElement):true)){this.direction=intersection==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(item)){this._rearrange(event,item);}else{break;}
this._trigger("change",event,this._uiHash());break;}}
this._contactContainers(event);if($.ui.ddmanager)$.ui.ddmanager.drag(this,event);this._trigger('sort',event,this._uiHash());this.lastPositionAbs=this.positionAbs;return false;},_mouseStop:function(event,noPropagation){if(!event)return;if($.ui.ddmanager&&!this.options.dropBehaviour)
$.ui.ddmanager.drop(this,event);if(this.options.revert){var self=this;var cur=self.placeholder.offset();self.reverting=true;$(this.helper).animate({left:cur.left-this.offset.parent.left-self.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:cur.top-this.offset.parent.top-self.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){self._clear(event);});}else{this._clear(event,noPropagation);}
return false;},cancel:function(){var self=this;if(this.dragging){this._mouseUp();if(this.options.helper=="original")
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");else
this.currentItem.show();for(var i=this.containers.length-1;i>=0;i--){this.containers[i]._trigger("deactivate",null,self._uiHash(this));if(this.containers[i].containerCache.over){this.containers[i]._trigger("out",null,self._uiHash(this));this.containers[i].containerCache.over=0;}}}
if(this.placeholder[0].parentNode)this.placeholder[0].parentNode.removeChild(this.placeholder[0]);if(this.options.helper!="original"&&this.helper&&this.helper[0].parentNode)this.helper.remove();$.extend(this,{helper:null,dragging:false,reverting:false,_noFinalSort:null});if(this.domPosition.prev){$(this.domPosition.prev).after(this.currentItem);}else{$(this.domPosition.parent).prepend(this.currentItem);}
return true;},serialize:function(o){var items=this._getItemsAsjQuery(o&&o.connected);var str=[];o=o||{};$(items).each(function(){var res=($(o.item||this).attr(o.attribute||'id')||'').match(o.expression||(/(.+)[-=_](.+)/));if(res)str.push((o.key||res[1]+'[]')+'='+(o.key&&o.expression?res[1]:res[2]));});return str.join('&');},toArray:function(o){var items=this._getItemsAsjQuery(o&&o.connected);var ret=[];o=o||{};items.each(function(){ret.push($(o.item||this).attr(o.attribute||'id')||'');});return ret;},_intersectsWith:function(item){var x1=this.positionAbs.left,x2=x1+this.helperProportions.width,y1=this.positionAbs.top,y2=y1+this.helperProportions.height;var l=item.left,r=l+item.width,t=item.top,b=t+item.height;var dyClick=this.offset.click.top,dxClick=this.offset.click.left;var isOverElement=(y1+dyClick)>t&&(y1+dyClick)<b&&(x1+dxClick)>l&&(x1+dxClick)<r;if(this.options.tolerance=="pointer"||this.options.forcePointerForContainers||(this.options.tolerance!="pointer"&&this.helperProportions[this.floating?'width':'height']>item[this.floating?'width':'height'])){return isOverElement;}else{return(l<x1+(this.helperProportions.width/2)&&x2-(this.helperProportions.width/2)<r&&t<y1+(this.helperProportions.height/2)&&y2-(this.helperProportions.height/2)<b);}},_intersectsWithPointer:function(item){var isOverElementHeight=$.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,item.top,item.height),isOverElementWidth=$.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,item.left,item.width),isOverElement=isOverElementHeight&&isOverElementWidth,verticalDirection=this._getDragVerticalDirection(),horizontalDirection=this._getDragHorizontalDirection();if(!isOverElement)
return false;return this.floating?(((horizontalDirection&&horizontalDirection=="right")||verticalDirection=="down")?2:1):(verticalDirection&&(verticalDirection=="down"?2:1));},_intersectsWithSides:function(item){var isOverBottomHalf=$.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,item.top+(item.height/2),item.height),isOverRightHalf=$.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,item.left+(item.width/2),item.width),verticalDirection=this._getDragVerticalDirection(),horizontalDirection=this._getDragHorizontalDirection();if(this.floating&&horizontalDirection){return((horizontalDirection=="right"&&isOverRightHalf)||(horizontalDirection=="left"&&!isOverRightHalf));}else{return verticalDirection&&((verticalDirection=="down"&&isOverBottomHalf)||(verticalDirection=="up"&&!isOverBottomHalf));}},_getDragVerticalDirection:function(){var delta=this.positionAbs.top-this.lastPositionAbs.top;return delta!=0&&(delta>0?"down":"up");},_getDragHorizontalDirection:function(){var delta=this.positionAbs.left-this.lastPositionAbs.left;return delta!=0&&(delta>0?"right":"left");},refresh:function(event){this._refreshItems(event);this.refreshPositions();},_connectWith:function(){var options=this.options;return options.connectWith.constructor==String?[options.connectWith]:options.connectWith;},_getItemsAsjQuery:function(connected){var self=this;var items=[];var queries=[];var connectWith=this._connectWith();if(connectWith&&connected){for(var i=connectWith.length-1;i>=0;i--){var cur=$(connectWith[i]);for(var j=cur.length-1;j>=0;j--){var inst=$.data(cur[j],'sortable');if(inst&&inst!=this&&!inst.options.disabled){queries.push([$.isFunction(inst.options.items)?inst.options.items.call(inst.element):$(inst.options.items,inst.element).not(".ui-sortable-helper"),inst]);}};};}
queries.push([$.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):$(this.options.items,this.element).not(".ui-sortable-helper"),this]);for(var i=queries.length-1;i>=0;i--){queries[i][0].each(function(){items.push(this);});};return $(items);},_removeCurrentsFromItems:function(){var list=this.currentItem.find(":data(sortable-item)");for(var i=0;i<this.items.length;i++){for(var j=0;j<list.length;j++){if(list[j]==this.items[i].item[0])
this.items.splice(i,1);};};},_refreshItems:function(event){this.items=[];this.containers=[this];var items=this.items;var self=this;var queries=[[$.isFunction(this.options.items)?this.options.items.call(this.element[0],event,{item:this.currentItem}):$(this.options.items,this.element),this]];var connectWith=this._connectWith();if(connectWith){for(var i=connectWith.length-1;i>=0;i--){var cur=$(connectWith[i]);for(var j=cur.length-1;j>=0;j--){var inst=$.data(cur[j],'sortable');if(inst&&inst!=this&&!inst.options.disabled){queries.push([$.isFunction(inst.options.items)?inst.options.items.call(inst.element[0],event,{item:this.currentItem}):$(inst.options.items,inst.element),inst]);this.containers.push(inst);}};};}
for(var i=queries.length-1;i>=0;i--){var targetData=queries[i][1];var _queries=queries[i][0];for(var j=0,queriesLength=_queries.length;j<queriesLength;j++){var item=$(_queries[j]);item.data('sortable-item',targetData);items.push({item:item,instance:targetData,width:0,height:0,left:0,top:0});};};},refreshPositions:function(fast){if(this.offsetParent&&this.helper){this.offset.parent=this._getParentOffset();}
for(var i=this.items.length-1;i>=0;i--){var item=this.items[i];if(item.instance!=this.currentContainer&&this.currentContainer&&item.item[0]!=this.currentItem[0])
continue;var t=this.options.toleranceElement?$(this.options.toleranceElement,item.item):item.item;if(!fast){item.width=t.outerWidth();item.height=t.outerHeight();}
var p=t.offset();item.left=p.left;item.top=p.top;};if(this.options.custom&&this.options.custom.refreshContainers){this.options.custom.refreshContainers.call(this);}else{for(var i=this.containers.length-1;i>=0;i--){var p=this.containers[i].element.offset();this.containers[i].containerCache.left=p.left;this.containers[i].containerCache.top=p.top;this.containers[i].containerCache.width=this.containers[i].element.outerWidth();this.containers[i].containerCache.height=this.containers[i].element.outerHeight();};}},_createPlaceholder:function(that){var self=that||this,o=self.options;if(!o.placeholder||o.placeholder.constructor==String){var className=o.placeholder;o.placeholder={element:function(){var el=$(document.createElement(self.currentItem[0].nodeName)).addClass(className||self.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];if(!className)
el.style.visibility="hidden";return el;},update:function(container,p){if(className&&!o.forcePlaceholderSize)return;if(!p.height()){p.height(self.currentItem.innerHeight()-parseInt(self.currentItem.css('paddingTop')||0,10)-parseInt(self.currentItem.css('paddingBottom')||0,10));};if(!p.width()){p.width(self.currentItem.innerWidth()-parseInt(self.currentItem.css('paddingLeft')||0,10)-parseInt(self.currentItem.css('paddingRight')||0,10));};}};}
self.placeholder=$(o.placeholder.element.call(self.element,self.currentItem));self.currentItem.after(self.placeholder);o.placeholder.update(self,self.placeholder);},_contactContainers:function(event){for(var i=this.containers.length-1;i>=0;i--){if(this._intersectsWith(this.containers[i].containerCache)){if(!this.containers[i].containerCache.over){if(this.currentContainer!=this.containers[i]){var dist=10000;var itemWithLeastDistance=null;var base=this.positionAbs[this.containers[i].floating?'left':'top'];for(var j=this.items.length-1;j>=0;j--){if(!$.ui.contains(this.containers[i].element[0],this.items[j].item[0]))continue;var cur=this.items[j][this.containers[i].floating?'left':'top'];if(Math.abs(cur-base)<dist){dist=Math.abs(cur-base);itemWithLeastDistance=this.items[j];}}
if(!itemWithLeastDistance&&!this.options.dropOnEmpty)
continue;this.currentContainer=this.containers[i];itemWithLeastDistance?this._rearrange(event,itemWithLeastDistance,null,true):this._rearrange(event,null,this.containers[i].element,true);this._trigger("change",event,this._uiHash());this.containers[i]._trigger("change",event,this._uiHash(this));this.options.placeholder.update(this.currentContainer,this.placeholder);}
this.containers[i]._trigger("over",event,this._uiHash(this));this.containers[i].containerCache.over=1;}}else{if(this.containers[i].containerCache.over){this.containers[i]._trigger("out",event,this._uiHash(this));this.containers[i].containerCache.over=0;}}};},_createHelper:function(event){var o=this.options;var helper=$.isFunction(o.helper)?$(o.helper.apply(this.element[0],[event,this.currentItem])):(o.helper=='clone'?this.currentItem.clone():this.currentItem);if(!helper.parents('body').length)
$(o.appendTo!='parent'?o.appendTo:this.currentItem[0].parentNode)[0].appendChild(helper[0]);if(helper[0]==this.currentItem[0])
this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")};if(helper[0].style.width==''||o.forceHelperSize)helper.width(this.currentItem.width());if(helper[0].style.height==''||o.forceHelperSize)helper.height(this.currentItem.height());return helper;},_adjustOffsetFromHelper:function(obj){if(obj.left!=undefined)this.offset.click.left=obj.left+this.margins.left;if(obj.right!=undefined)this.offset.click.left=this.helperProportions.width-obj.right+this.margins.left;if(obj.top!=undefined)this.offset.click.top=obj.top+this.margins.top;if(obj.bottom!=undefined)this.offset.click.top=this.helperProportions.height-obj.bottom+this.margins.top;},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var po=this.offsetParent.offset();if(this.cssPosition=='absolute'&&this.scrollParent[0]!=document&&$.ui.contains(this.scrollParent[0],this.offsetParent[0])){po.left+=this.scrollParent.scrollLeft();po.top+=this.scrollParent.scrollTop();}
if((this.offsetParent[0]==document.body)||(this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=='html'&&$.browser.msie))
po={top:0,left:0};return{top:po.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:po.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)};},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var p=this.currentItem.position();return{top:p.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:p.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()};}else{return{top:0,left:0};}},_cacheMargins:function(){this.margins={left:(parseInt(this.currentItem.css("marginLeft"),10)||0),top:(parseInt(this.currentItem.css("marginTop"),10)||0)};},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};},_setContainment:function(){var o=this.options;if(o.containment=='parent')o.containment=this.helper[0].parentNode;if(o.containment=='document'||o.containment=='window')this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,$(o.containment=='document'?document:window).width()-this.helperProportions.width-this.margins.left,($(o.containment=='document'?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!(/^(document|window|parent)$/).test(o.containment)){var ce=$(o.containment)[0];var co=$(o.containment).offset();var over=($(ce).css("overflow")!='hidden');this.containment=[co.left+(parseInt($(ce).css("borderLeftWidth"),10)||0)+(parseInt($(ce).css("paddingLeft"),10)||0)-this.margins.left,co.top+(parseInt($(ce).css("borderTopWidth"),10)||0)+(parseInt($(ce).css("paddingTop"),10)||0)-this.margins.top,co.left+(over?Math.max(ce.scrollWidth,ce.offsetWidth):ce.offsetWidth)-(parseInt($(ce).css("borderLeftWidth"),10)||0)-(parseInt($(ce).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,co.top+(over?Math.max(ce.scrollHeight,ce.offsetHeight):ce.offsetHeight)-(parseInt($(ce).css("borderTopWidth"),10)||0)-(parseInt($(ce).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top];}},_convertPositionTo:function(d,pos){if(!pos)pos=this.position;var mod=d=="absolute"?1:-1;var o=this.options,scroll=this.cssPosition=='absolute'&&!(this.scrollParent[0]!=document&&$.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,scrollIsRootNode=(/(html|body)/i).test(scroll[0].tagName);return{top:(pos.top
+this.offset.relative.top*mod
+this.offset.parent.top*mod
-($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollTop():(scrollIsRootNode?0:scroll.scrollTop()))*mod)),left:(pos.left
+this.offset.relative.left*mod
+this.offset.parent.left*mod
-($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollLeft():scrollIsRootNode?0:scroll.scrollLeft())*mod))};},_generatePosition:function(event){var o=this.options,scroll=this.cssPosition=='absolute'&&!(this.scrollParent[0]!=document&&$.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,scrollIsRootNode=(/(html|body)/i).test(scroll[0].tagName);if(this.cssPosition=='relative'&&!(this.scrollParent[0]!=document&&this.scrollParent[0]!=this.offsetParent[0])){this.offset.relative=this._getRelativeOffset();}
var pageX=event.pageX;var pageY=event.pageY;if(this.originalPosition){if(this.containment){if(event.pageX-this.offset.click.left<this.containment[0])pageX=this.containment[0]+this.offset.click.left;if(event.pageY-this.offset.click.top<this.containment[1])pageY=this.containment[1]+this.offset.click.top;if(event.pageX-this.offset.click.left>this.containment[2])pageX=this.containment[2]+this.offset.click.left;if(event.pageY-this.offset.click.top>this.containment[3])pageY=this.containment[3]+this.offset.click.top;}
if(o.grid){var top=this.originalPageY+Math.round((pageY-this.originalPageY)/o.grid[1])*o.grid[1];pageY=this.containment?(!(top-this.offset.click.top<this.containment[1]||top-this.offset.click.top>this.containment[3])?top:(!(top-this.offset.click.top<this.containment[1])?top-o.grid[1]:top+o.grid[1])):top;var left=this.originalPageX+Math.round((pageX-this.originalPageX)/o.grid[0])*o.grid[0];pageX=this.containment?(!(left-this.offset.click.left<this.containment[0]||left-this.offset.click.left>this.containment[2])?left:(!(left-this.offset.click.left<this.containment[0])?left-o.grid[0]:left+o.grid[0])):left;}}
return{top:(pageY
-this.offset.click.top
-this.offset.relative.top
-this.offset.parent.top
+($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollTop():(scrollIsRootNode?0:scroll.scrollTop())))),left:(pageX
-this.offset.click.left
-this.offset.relative.left
-this.offset.parent.left
+($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollLeft():scrollIsRootNode?0:scroll.scrollLeft())))};},_rearrange:function(event,i,a,hardRefresh){a?a[0].appendChild(this.placeholder[0]):i.item[0].parentNode.insertBefore(this.placeholder[0],(this.direction=='down'?i.item[0]:i.item[0].nextSibling));this.counter=this.counter?++this.counter:1;var self=this,counter=this.counter;window.setTimeout(function(){if(counter==self.counter)self.refreshPositions(!hardRefresh);},0);},_clear:function(event,noPropagation){this.reverting=false;var delayedTriggers=[],self=this;if(!this._noFinalSort&&this.currentItem[0].parentNode)this.placeholder.before(this.currentItem);this._noFinalSort=null;if(this.helper[0]==this.currentItem[0]){for(var i in this._storedCSS){if(this._storedCSS[i]=='auto'||this._storedCSS[i]=='static')this._storedCSS[i]='';}
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");}else{this.currentItem.show();}
if(this.fromOutside&&!noPropagation)delayedTriggers.push(function(event){this._trigger("receive",event,this._uiHash(this.fromOutside));});if((this.fromOutside||this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0])&&!noPropagation)delayedTriggers.push(function(event){this._trigger("update",event,this._uiHash());});if(!$.ui.contains(this.element[0],this.currentItem[0])){if(!noPropagation)delayedTriggers.push(function(event){this._trigger("remove",event,this._uiHash());});for(var i=this.containers.length-1;i>=0;i--){if($.ui.contains(this.containers[i].element[0],this.currentItem[0])&&!noPropagation){delayedTriggers.push((function(c){return function(event){c._trigger("receive",event,this._uiHash(this));};}).call(this,this.containers[i]));delayedTriggers.push((function(c){return function(event){c._trigger("update",event,this._uiHash(this));};}).call(this,this.containers[i]));}};};for(var i=this.containers.length-1;i>=0;i--){if(!noPropagation)delayedTriggers.push((function(c){return function(event){c._trigger("deactivate",event,this._uiHash(this));};}).call(this,this.containers[i]));if(this.containers[i].containerCache.over){delayedTriggers.push((function(c){return function(event){c._trigger("out",event,this._uiHash(this));};}).call(this,this.containers[i]));this.containers[i].containerCache.over=0;}}
if(this._storedCursor)$('body').css("cursor",this._storedCursor);if(this._storedOpacity)this.helper.css("opacity",this._storedOpacity);if(this._storedZIndex)this.helper.css("zIndex",this._storedZIndex=='auto'?'':this._storedZIndex);this.dragging=false;if(this.cancelHelperRemoval){if(!noPropagation){this._trigger("beforeStop",event,this._uiHash());for(var i=0;i<delayedTriggers.length;i++){delayedTriggers[i].call(this,event);};this._trigger("stop",event,this._uiHash());}
return false;}
if(!noPropagation)this._trigger("beforeStop",event,this._uiHash());this.placeholder[0].parentNode.removeChild(this.placeholder[0]);if(this.helper[0]!=this.currentItem[0])this.helper.remove();this.helper=null;if(!noPropagation){for(var i=0;i<delayedTriggers.length;i++){delayedTriggers[i].call(this,event);};this._trigger("stop",event,this._uiHash());}
this.fromOutside=false;return true;},_trigger:function(){if($.widget.prototype._trigger.apply(this,arguments)===false){this.cancel();}},_uiHash:function(inst){var self=inst||this;return{helper:self.helper,placeholder:self.placeholder||$([]),position:self.position,absolutePosition:self.positionAbs,offset:self.positionAbs,item:self.currentItem,sender:inst?inst.element:null};}}));$.extend($.ui.sortable,{getter:"serialize toArray",version:"1.7.2",eventPrefix:"sort",defaults:{appendTo:"parent",axis:false,cancel:":input,option",connectWith:false,containment:false,cursor:'auto',cursorAt:false,delay:0,distance:1,dropOnEmpty:true,forcePlaceholderSize:false,forceHelperSize:false,grid:false,handle:false,helper:"original",items:'> *',opacity:false,placeholder:false,revert:false,scroll:true,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1000}});})(jQuery);
// JS/jqUI/new/ui.sortable.js

(function($){$.widget("ui.slider",$.extend({},$.ui.mouse,{_init:function(){var self=this,o=this.options;this._keySliding=false;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider"
+" ui-slider-"+this.orientation
+" ui-widget"
+" ui-widget-content"
+" ui-corner-all");this.range=$([]);if(o.range){if(o.range===true){this.range=$('<div></div>');if(!o.values)o.values=[this._valueMin(),this._valueMin()];if(o.values.length&&o.values.length!=2){o.values=[o.values[0],o.values[0]];}}else{this.range=$('<div></div>');}
this.range.appendTo(this.element).addClass("ui-slider-range");if(o.range=="min"||o.range=="max"){this.range.addClass("ui-slider-range-"+o.range);}
this.range.addClass("ui-widget-header");}
if($(".ui-slider-handle",this.element).length==0)
$('<a href="#"></a>').appendTo(this.element).addClass("ui-slider-handle");if(o.values&&o.values.length){while($(".ui-slider-handle",this.element).length<o.values.length)
$('<a href="#"></a>').appendTo(this.element).addClass("ui-slider-handle");}
this.handles=$(".ui-slider-handle",this.element).addClass("ui-state-default"
+" ui-corner-all");this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(event){event.preventDefault();}).hover(function(){if(!o.disabled){$(this).addClass('ui-state-hover');}},function(){$(this).removeClass('ui-state-hover');}).focus(function(){if(!o.disabled){$(".ui-slider .ui-state-focus").removeClass('ui-state-focus');$(this).addClass('ui-state-focus');}else{$(this).blur();}}).blur(function(){$(this).removeClass('ui-state-focus');});this.handles.each(function(i){$(this).data("index.ui-slider-handle",i);});this.handles.keydown(function(event){var ret=true;var index=$(this).data("index.ui-slider-handle");if(self.options.disabled)
return;switch(event.keyCode){case $.ui.keyCode.HOME:case $.ui.keyCode.END:case $.ui.keyCode.UP:case $.ui.keyCode.RIGHT:case $.ui.keyCode.DOWN:case $.ui.keyCode.LEFT:ret=false;if(!self._keySliding){self._keySliding=true;$(this).addClass("ui-state-active");self._start(event,index);}
break;}
var curVal,newVal,step=self._step();if(self.options.values&&self.options.values.length){curVal=newVal=self.values(index);}else{curVal=newVal=self.value();}
switch(event.keyCode){case $.ui.keyCode.HOME:newVal=self._valueMin();break;case $.ui.keyCode.END:newVal=self._valueMax();break;case $.ui.keyCode.UP:case $.ui.keyCode.RIGHT:if(curVal==self._valueMax())return;newVal=curVal+step;break;case $.ui.keyCode.DOWN:case $.ui.keyCode.LEFT:if(curVal==self._valueMin())return;newVal=curVal-step;break;}
self._slide(event,index,newVal);return ret;}).keyup(function(event){var index=$(this).data("index.ui-slider-handle");if(self._keySliding){self._stop(event,index);self._change(event,index);self._keySliding=false;$(this).removeClass("ui-state-active");}});this._refreshValue();},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider"
+" ui-slider-horizontal"
+" ui-slider-vertical"
+" ui-slider-disabled"
+" ui-widget"
+" ui-widget-content"
+" ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy();},_mouseCapture:function(event){var o=this.options;if(o.disabled)
return false;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();var position={x:event.pageX,y:event.pageY};var normValue=this._normValueFromMouse(position);var distance=this._valueMax()-this._valueMin()+1,closestHandle;var self=this,index;this.handles.each(function(i){var thisDistance=Math.abs(normValue-self.values(i));if(distance>thisDistance){distance=thisDistance;closestHandle=$(this);index=i;}});if(o.range==true&&this.values(1)==o.min){closestHandle=$(this.handles[++index]);}
this._start(event,index);self._handleIndex=index;closestHandle.addClass("ui-state-active").focus();var offset=closestHandle.offset();var mouseOverHandle=!$(event.target).parents().andSelf().is('.ui-slider-handle');this._clickOffset=mouseOverHandle?{left:0,top:0}:{left:event.pageX-offset.left-(closestHandle.width()/2),top:event.pageY-offset.top
-(closestHandle.height()/2)
-(parseInt(closestHandle.css('borderTopWidth'),10)||0)
-(parseInt(closestHandle.css('borderBottomWidth'),10)||0)
+(parseInt(closestHandle.css('marginTop'),10)||0)};normValue=this._normValueFromMouse(position);this._slide(event,index,normValue);return true;},_mouseStart:function(event){return true;},_mouseDrag:function(event){var position={x:event.pageX,y:event.pageY};var normValue=this._normValueFromMouse(position);this._slide(event,this._handleIndex,normValue);return false;},_mouseStop:function(event){this.handles.removeClass("ui-state-active");this._stop(event,this._handleIndex);this._change(event,this._handleIndex);this._handleIndex=null;this._clickOffset=null;return false;},_detectOrientation:function(){this.orientation=this.options.orientation=='vertical'?'vertical':'horizontal';},_normValueFromMouse:function(position){var pixelTotal,pixelMouse;if('horizontal'==this.orientation){pixelTotal=this.elementSize.width;pixelMouse=position.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0);}else{pixelTotal=this.elementSize.height;pixelMouse=position.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0);}
var percentMouse=(pixelMouse/pixelTotal);if(percentMouse>1)percentMouse=1;if(percentMouse<0)percentMouse=0;if('vertical'==this.orientation)
percentMouse=1-percentMouse;var valueTotal=this._valueMax()-this._valueMin(),valueMouse=percentMouse*valueTotal,valueMouseModStep=valueMouse%this.options.step,normValue=this._valueMin()+valueMouse-valueMouseModStep;if(valueMouseModStep>(this.options.step/2))
normValue+=this.options.step;return parseFloat(normValue.toFixed(5));},_start:function(event,index){var uiHash={handle:this.handles[index],value:this.value()};if(this.options.values&&this.options.values.length){uiHash.value=this.values(index);uiHash.values=this.values();}
this._trigger("start",event,uiHash);},_slide:function(event,index,newVal){var handle=this.handles[index];if(this.options.values&&this.options.values.length){var otherVal=this.values(index?0:1);if((this.options.values.length==2&&this.options.range===true)&&((index==0&&newVal>otherVal)||(index==1&&newVal<otherVal))){newVal=otherVal;}
if(newVal!=this.values(index)){var newValues=this.values();newValues[index]=newVal;var allowed=this._trigger("slide",event,{handle:this.handles[index],value:newVal,values:newValues});var otherVal=this.values(index?0:1);if(allowed!==false){this.values(index,newVal,(event.type=='mousedown'&&this.options.animate),true);}}}else{if(newVal!=this.value()){var allowed=this._trigger("slide",event,{handle:this.handles[index],value:newVal});if(allowed!==false){this._setData('value',newVal,(event.type=='mousedown'&&this.options.animate));}}}},_stop:function(event,index){var uiHash={handle:this.handles[index],value:this.value()};if(this.options.values&&this.options.values.length){uiHash.value=this.values(index);uiHash.values=this.values();}
this._trigger("stop",event,uiHash);},_change:function(event,index){var uiHash={handle:this.handles[index],value:this.value()};if(this.options.values&&this.options.values.length){uiHash.value=this.values(index);uiHash.values=this.values();}
this._trigger("change",event,uiHash);},value:function(newValue){if(arguments.length){this._setData("value",newValue);this._change(null,0);}
return this._value();},values:function(index,newValue,animated,noPropagation){if(arguments.length>1){this.options.values[index]=newValue;this._refreshValue(animated);if(!noPropagation)this._change(null,index);}
if(arguments.length){if(this.options.values&&this.options.values.length){return this._values(index);}else{return this.value();}}else{return this._values();}},_setData:function(key,value,animated){$.widget.prototype._setData.apply(this,arguments);switch(key){case'disabled':if(value){this.handles.filter(".ui-state-focus").blur();this.handles.removeClass("ui-state-hover");this.handles.attr("disabled","disabled");}else{this.handles.removeAttr("disabled");}
case'orientation':this._detectOrientation();this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue(animated);break;case'value':this._refreshValue(animated);break;}},_step:function(){var step=this.options.step;return step;},_value:function(){var val=this.options.value;if(val<this._valueMin())val=this._valueMin();if(val>this._valueMax())val=this._valueMax();return val;},_values:function(index){if(arguments.length){var val=this.options.values[index];if(val<this._valueMin())val=this._valueMin();if(val>this._valueMax())val=this._valueMax();return val;}else{return this.options.values;}},_valueMin:function(){var valueMin=this.options.min;return valueMin;},_valueMax:function(){var valueMax=this.options.max;return valueMax;},_refreshValue:function(animate){var oRange=this.options.range,o=this.options,self=this;if(this.options.values&&this.options.values.length){var vp0,vp1;this.handles.each(function(i,j){var valPercent=(self.values(i)-self._valueMin())/(self._valueMax()-self._valueMin())*100;var _set={};_set[self.orientation=='horizontal'?'left':'bottom']=valPercent+'%';$(this).stop(1,1)[animate?'animate':'css'](_set,o.animate);if(self.options.range===true){if(self.orientation=='horizontal'){(i==0)&&self.range.stop(1,1)[animate?'animate':'css']({left:valPercent+'%'},o.animate);(i==1)&&self.range[animate?'animate':'css']({width:(valPercent-lastValPercent)+'%'},{queue:false,duration:o.animate});}else{(i==0)&&self.range.stop(1,1)[animate?'animate':'css']({bottom:(valPercent)+'%'},o.animate);(i==1)&&self.range[animate?'animate':'css']({height:(valPercent-lastValPercent)+'%'},{queue:false,duration:o.animate});}}
lastValPercent=valPercent;});}else{var value=this.value(),valueMin=this._valueMin(),valueMax=this._valueMax(),valPercent=valueMax!=valueMin?(value-valueMin)/(valueMax-valueMin)*100:0;var _set={};_set[self.orientation=='horizontal'?'left':'bottom']=valPercent+'%';this.handle.stop(1,1)[animate?'animate':'css'](_set,o.animate);(oRange=="min")&&(this.orientation=="horizontal")&&this.range.stop(1,1)[animate?'animate':'css']({width:valPercent+'%'},o.animate);(oRange=="max")&&(this.orientation=="horizontal")&&this.range[animate?'animate':'css']({width:(100-valPercent)+'%'},{queue:false,duration:o.animate});(oRange=="min")&&(this.orientation=="vertical")&&this.range.stop(1,1)[animate?'animate':'css']({height:valPercent+'%'},o.animate);(oRange=="max")&&(this.orientation=="vertical")&&this.range[animate?'animate':'css']({height:(100-valPercent)+'%'},{queue:false,duration:o.animate});}}}));$.extend($.ui.slider,{getter:"value values",version:"1.7.2",eventPrefix:"slide",defaults:{animate:false,delay:0,distance:0,max:100,min:0,orientation:'horizontal',range:false,step:1,value:0,values:null}});})(jQuery);
// JS/jqUI/new/ui.slider.js

(function($){$.fn.charLimit=function(options){var defaults={limit:30,speed:"normal",descending:true}
var o=$.extend(defaults,options);return this.each(function(i){var obj=$(this);if(obj.next().hasClass("countBox"))obj.next().remove();obj.after('<span class="countBox" style="display:none;padding:1px 2px;font-size: 13px;border:1px solid #aaa;"></span>');function countChars(){var value=(o.descending)?o.limit-obj.val().length:obj.val().length;$(obj).next().text(value);}
countChars();obj.keydown(function(e){if(obj.val().length>=o.limit&&e.keyCode!="8"&&e.keyCode!="9"&&e.keyCode!="46")
e.preventDefault();countChars();}).keyup(function(e){if(obj.val().length>=o.limit){obj.val(obj.val().substr(0,o.limit))}
countChars();}).focus(function(){$(this).next().fadeIn(o.speed);countChars();}).blur(function(){$(this).next().fadeOut(o.speed);});});}})(jQuery);
// JS/Plugins/jquery.charlimit.js
;(function($){$.extend($.fn,{swapClass:function(c1,c2){var c1Elements=this.filter('.'+c1);this.filter('.'+c2).removeClass(c2).addClass(c1);c1Elements.removeClass(c1).addClass(c2);return this;},replaceClass:function(c1,c2){return this.filter('.'+c1).removeClass(c1).addClass(c2).end();},hoverClass:function(className){className=className||"hover";return this.hover(function(){$(this).addClass(className);},function(){$(this).removeClass(className);});},heightToggle:function(animated,callback){animated?this.animate({height:"toggle"},animated,callback):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();if(callback)
callback.apply(this,arguments);});},heightHide:function(animated,callback){if(animated){this.animate({height:"hide"},animated,callback);}else{this.hide();if(callback)
this.each(callback);}},prepareBranches:function(settings){if(!settings.prerendered){this.filter(":last-child:not(ul)").addClass(CLASSES.last);this.filter((settings.collapsed?"":"."+CLASSES.closed)+":not(."+CLASSES.open+")").find(">ul").hide();}
return this.filter(":has(>ul)");},applyClasses:function(settings,toggler){this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(event){toggler.apply($(this).next());}).add($("a",this)).hoverClass();if(!settings.prerendered){this.filter(":has(>ul:hidden)").addClass(CLASSES.expandable).replaceClass(CLASSES.last,CLASSES.lastExpandable);this.not(":has(>ul:hidden)").addClass(CLASSES.collapsable).replaceClass(CLASSES.last,CLASSES.lastCollapsable);this.prepend("<div class=\""+CLASSES.hitarea+"\"/>").find("div."+CLASSES.hitarea).each(function(){var classes="";$.each($(this).parent().attr("class").split(" "),function(){classes+=this+"-hitarea ";});$(this).addClass(classes);});}
this.find("div."+CLASSES.hitarea).click(toggler);},treeview:function(settings){settings=$.extend({cookieId:"treeview"},settings);if(settings.add){return this.trigger("add",[settings.add]);}
if(settings.toggle){var callback=settings.toggle;settings.toggle=function(){return callback.apply($(this).parent()[0],arguments);};}
function treeController(tree,control){function handler(filter){return function(){toggler.apply($("div."+CLASSES.hitarea,tree).filter(function(){return filter?$(this).parent("."+filter).length:true;}));return false;};}
$("a:eq(0)",control).click(handler(CLASSES.collapsable));$("a:eq(1)",control).click(handler(CLASSES.expandable));$("a:eq(2)",control).click(handler());}
function toggler(){$(this).parent().find(">.hitarea").swapClass(CLASSES.collapsableHitarea,CLASSES.expandableHitarea).swapClass(CLASSES.lastCollapsableHitarea,CLASSES.lastExpandableHitarea).end().swapClass(CLASSES.collapsable,CLASSES.expandable).swapClass(CLASSES.lastCollapsable,CLASSES.lastExpandable).find(">ul").heightToggle(settings.animated,settings.toggle);if(settings.unique){$(this).parent().siblings().find(">.hitarea").replaceClass(CLASSES.collapsableHitarea,CLASSES.expandableHitarea).replaceClass(CLASSES.lastCollapsableHitarea,CLASSES.lastExpandableHitarea).end().replaceClass(CLASSES.collapsable,CLASSES.expandable).replaceClass(CLASSES.lastCollapsable,CLASSES.lastExpandable).find(">ul").heightHide(settings.animated,settings.toggle);}}
function serialize(){function binary(arg){return arg?1:0;}
var data=[];branches.each(function(i,e){data[i]=$(e).is(":has(>ul:visible)")?1:0;});$.cookie(settings.cookieId,data.join(""));}
function deserialize(){var stored=$.cookie(settings.cookieId);if(stored){var data=stored.split("");branches.each(function(i,e){$(e).find(">ul")[parseInt(data[i])?"show":"hide"]();});}}
this.addClass("treeview");var branches=this.find("li").prepareBranches(settings);switch(settings.persist){case"cookie":var toggleCallback=settings.toggle;settings.toggle=function(){serialize();if(toggleCallback){toggleCallback.apply(this,arguments);}};deserialize();break;case"location":var current=this.find("a").filter(function(){return this.href.toLowerCase()==location.href.toLowerCase();});if(current.length){current.addClass("selected").parents("ul, li").add(current.next()).show();}
break;}
branches.applyClasses(settings,toggler);if(settings.control){treeController(this,settings.control);$(settings.control).show();}
return this.bind("add",function(event,branches){$(branches).prev().removeClass(CLASSES.last).removeClass(CLASSES.lastCollapsable).removeClass(CLASSES.lastExpandable).find(">.hitarea").removeClass(CLASSES.lastCollapsableHitarea).removeClass(CLASSES.lastExpandableHitarea);$(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings,toggler);});}});var CLASSES=$.fn.treeview.classes={open:"open",closed:"closed",expandable:"expandable",expandableHitarea:"expandable-hitarea",lastExpandableHitarea:"lastExpandable-hitarea",collapsable:"collapsable",collapsableHitarea:"collapsable-hitarea",lastCollapsableHitarea:"lastCollapsable-hitarea",lastCollapsable:"lastCollapsable",lastExpandable:"lastExpandable",last:"last",hitarea:"hitarea"};$.fn.Treeview=$.fn.treeview;})(jQuery)
// JS/Plugins/jquery.treeview.js
;(function($){function load(settings,root,child,container){$.getJSON(settings.url,{root:root},function(response){function createNode(parent){var current=$("<li/>").attr("id",this.id||"").html("<span value=\""+(this.path||"")+"\" path=\""+(this.path||"")+"\">"+this.text+"</span>").appendTo(parent);if(this.classes){current.children("span").addClass(this.classes);}
if(this.expanded){current.addClass("open");}
if(this.hasChildren||this.children&&this.children.length){var branch=$("<ul/>").appendTo(current);if(this.hasChildren){current.addClass("hasChildren");createNode.call({text:"placeholder",id:"placeholder",children:[]},branch);}
if(this.children&&this.children.length){$.each(this.children,createNode,[branch])}}}
$.each(response,createNode,[child]);$(container).treeview({add:child});});}
var proxied=$.fn.treeview;$.fn.treeview=function(settings){if(!settings.url){return proxied.apply(this,arguments);}
var container=this;load(settings,"source",this,container);var userToggle=settings.toggle;return proxied.call(this,$.extend({},settings,{collapsed:true,toggle:function(){var $this=$(this);if($this.hasClass("hasChildren")){var childList=$this.removeClass("hasChildren").find("ul");childList.empty();load(settings,this.id,childList,container);}
if(userToggle){userToggle.apply(this,arguments);}}}));};})(jQuery)
// JS/Plugins/jquery.treeview.async.js

jQuery.tableDnD={currentTable:null,dragObject:null,mouseOffset:null,oldY:0,build:function(options){this.each(function(){this.tableDnDConfig=jQuery.extend({onDragStyle:null,onDropStyle:null,onDragClass:"tDnD_whileDrag",onDrop:null,onDragStart:null,scrollAmount:5,serializeRegexp:/[^\-]*$/,serializeParamName:null,dragHandle:null},options||{});jQuery.tableDnD.makeDraggable(this);});jQuery(document).bind('mousemove',jQuery.tableDnD.mousemove).bind('mouseup',jQuery.tableDnD.mouseup);return this;},makeDraggable:function(table){var config=table.tableDnDConfig;if(table.tableDnDConfig.dragHandle){var cells=jQuery("td."+table.tableDnDConfig.dragHandle,table);cells.each(function(){jQuery(this).mousedown(function(ev){jQuery.tableDnD.dragObject=this.parentNode;jQuery.tableDnD.currentTable=table;jQuery.tableDnD.mouseOffset=jQuery.tableDnD.getMouseOffset(this,ev);if(config.onDragStart){config.onDragStart(table,this);}
return false;});})}else{var rows=jQuery("tr",table);rows.each(function(){var row=jQuery(this);if(!row.hasClass("nodrag")){row.mousedown(function(ev){if(ev.target.tagName=="TD"){jQuery.tableDnD.dragObject=this;jQuery.tableDnD.currentTable=table;jQuery.tableDnD.mouseOffset=jQuery.tableDnD.getMouseOffset(this,ev);if(config.onDragStart){config.onDragStart(table,this);}
return false;}})}});}},updateTables:function(){this.each(function(){if(this.tableDnDConfig){jQuery.tableDnD.makeDraggable(this);}})},mouseCoords:function(ev){if(ev.pageX||ev.pageY){return{x:ev.pageX,y:ev.pageY};}
return{x:ev.clientX+document.body.scrollLeft-document.body.clientLeft,y:ev.clientY+document.body.scrollTop-document.body.clientTop};},getMouseOffset:function(target,ev){ev=ev||window.event;var docPos=this.getPosition(target);var mousePos=this.mouseCoords(ev);return{x:mousePos.x-docPos.x,y:mousePos.y-docPos.y};},getPosition:function(e){var left=0;var top=0;if(e.offsetHeight==0){e=e.firstChild;}
while(e.offsetParent){left+=e.offsetLeft;top+=e.offsetTop;e=e.offsetParent;}
left+=e.offsetLeft;top+=e.offsetTop;return{x:left,y:top};},mousemove:function(ev){if(!jQuery.tableDnD||jQuery.tableDnD.dragObject==null){return;}
var dragObj=jQuery(jQuery.tableDnD.dragObject);var config=jQuery.tableDnD.currentTable.tableDnDConfig;var mousePos=jQuery.tableDnD.mouseCoords(ev);var y=mousePos.y-jQuery.tableDnD.mouseOffset.y;var yOffset=window.pageYOffset;if(document.all){if(typeof document.compatMode!='undefined'&&document.compatMode!='BackCompat'){yOffset=document.documentElement.scrollTop;}
else if(typeof document.body!='undefined'){yOffset=document.body.scrollTop;}}
if(mousePos.y-yOffset<config.scrollAmount){window.scrollBy(0,-config.scrollAmount);}else{var windowHeight=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight;if(windowHeight-(mousePos.y-yOffset)<config.scrollAmount){window.scrollBy(0,config.scrollAmount);}}
if(y!=jQuery.tableDnD.oldY){var movingDown=y>jQuery.tableDnD.oldY;jQuery.tableDnD.oldY=y;if(config.onDragClass){dragObj.addClass(config.onDragClass);}else{dragObj.css(config.onDragStyle);}
var currentRow=jQuery.tableDnD.findDropTargetRow(dragObj,y);if(currentRow){if(movingDown&&jQuery.tableDnD.dragObject!=currentRow){jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject,currentRow.nextSibling);}else if(!movingDown&&jQuery.tableDnD.dragObject!=currentRow){jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject,currentRow);}}}
return false;},findDropTargetRow:function(draggedRow,y){var rows=jQuery.tableDnD.currentTable.rows;for(var i=0;i<rows.length;i++){var row=rows[i];var rowY=this.getPosition(row).y;var rowHeight=parseInt(row.offsetHeight)/2;if(row.offsetHeight==0){rowY=this.getPosition(row.firstChild).y;rowHeight=parseInt(row.firstChild.offsetHeight)/2;}
if((y>rowY-rowHeight)&&(y<(rowY+rowHeight))){if(row==draggedRow){return null;}
var config=jQuery.tableDnD.currentTable.tableDnDConfig;if(config.onAllowDrop){if(config.onAllowDrop(draggedRow,row)){return row;}else{return null;}}else{var nodrop=jQuery(row).hasClass("nodrop");if(!nodrop){return row;}else{return null;}}
return row;}}
return null;},mouseup:function(e){if(jQuery.tableDnD.currentTable&&jQuery.tableDnD.dragObject){var droppedRow=jQuery.tableDnD.dragObject;var config=jQuery.tableDnD.currentTable.tableDnDConfig;if(config.onDragClass){jQuery(droppedRow).removeClass(config.onDragClass);}else{jQuery(droppedRow).css(config.onDropStyle);}
jQuery.tableDnD.dragObject=null;if(config.onDrop){config.onDrop(jQuery.tableDnD.currentTable,droppedRow);}
jQuery.tableDnD.currentTable=null;}},serialize:function(){if(jQuery.tableDnD.currentTable){return jQuery.tableDnD.serializeTable(jQuery.tableDnD.currentTable);}else{return"Error: No Table id set, you need to set an id on your table and every row";}},serializeTable:function(table){var result="";var tableId=table.id;var rows=table.rows;for(var i=0;i<rows.length;i++){if(result.length>0)result+="&";var rowId=rows[i].id;if(rowId&&rowId&&table.tableDnDConfig&&table.tableDnDConfig.serializeRegexp){rowId=rowId.match(table.tableDnDConfig.serializeRegexp)[0];}
result+=tableId+'[]='+rowId;}
return result;},serializeTables:function(){var result="";this.each(function(){result+=jQuery.tableDnD.serializeTable(this);});return result;}}
jQuery.fn.extend({tableDnD:jQuery.tableDnD.build,tableDnDUpdate:jQuery.tableDnD.updateTables,tableDnDSerialize:jQuery.tableDnD.serializeTables});
// JS/jquery.tablednd_0_5.js

DateInput=(function($){function DateInput(el,opts){if(typeof(opts)!="object")opts={};$.extend(this,DateInput.DEFAULT_OPTS,opts);this.input=$(el);this.bindMethodsToObj("show","hide","hideIfClickOutside","selectDate","prevMonth","nextMonth");this.build();this.selectDate();this.hide();};DateInput.DEFAULT_OPTS={month_names:["January","February","March","April","May","June","July","August","September","October","November","December"],short_month_names:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],short_day_names:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],start_of_week:1};DateInput.prototype={build:function(){this.monthNameSpan=$('<span class="month_name"></span>');var monthNav=$('<p class="month_nav"></p>').append($('<a href="#" class="prev">&laquo;</a>').click(this.prevMonth)," ",this.monthNameSpan," ",$('<a href="#" class="next">&raquo;</a>').click(this.nextMonth));var tableShell="<table><thead><tr>";$(this.adjustDays(this.short_day_names)).each(function(){tableShell+="<th>"+this+"</th>";});tableShell+="</tr></thead><tbody></tbody></table>";this.dateSelector=this.rootLayers=$('<div class="date_selector"></div>').css({display:"none",position:"absolute",zIndex:1000}).append(monthNav,tableShell).appendTo(document.body);if($.browser.msie&&$.browser.version<7){this.ieframe=$('<iframe class="date_selector_ieframe" frameborder="0" src="#"></iframe>').css({position:"absolute",display:"none",zIndex:999}).insertBefore(this.dateSelector);this.rootLayers=this.rootLayers.add(this.ieframe);};this.tbody=$("tbody",this.dateSelector);this.input.change(this.bindToObj(function(){this.selectDate();}));},selectMonth:function(date){this.currentMonth=date;var rangeStart=this.rangeStart(date),rangeEnd=this.rangeEnd(date);var numDays=this.daysBetween(rangeStart,rangeEnd);var dayCells="";for(var i=0;i<=numDays;i++){var currentDay=new Date(rangeStart.getFullYear(),rangeStart.getMonth(),rangeStart.getDate()+i);if(this.isFirstDayOfWeek(currentDay))dayCells+="<tr>";if(currentDay.getMonth()==date.getMonth()){dayCells+='<td date="'+this.dateToString(currentDay)+'"><a href="#">'+currentDay.getDate()+'</a></td>';}else{dayCells+='<td class="unselected_month" date="'+this.dateToString(currentDay)+'">'+currentDay.getDate()+'</td>';};if(this.isLastDayOfWeek(currentDay))dayCells+="</tr>";};this.monthNameSpan.empty().append(this.monthName(date)+" "+date.getFullYear());this.tbody.empty().append(dayCells);$("a",this.tbody).click(this.bindToObj(function(event){this.selectDate(this.stringToDate($(event.target).parent().attr("date")));this.hide();return false;}));$("td[date="+this.dateToString(new Date())+"]",this.tbody).addClass("today");},selectDate:function(date){if(typeof(date)=="undefined"){date=this.stringToDate(this.input.val());};if(date){this.selectedDate=date;this.selectMonth(date);var stringDate=this.dateToString(date);$('td[date='+stringDate+']',this.tbody).addClass("selected");if(this.input.val()!=stringDate){this.input.val(stringDate).change();};}else{this.selectMonth(new Date());};},show:function(){alert("show");this.rootLayers.css("display","block");this.setPosition();this.input.unbind("click",this.show);$([window,document.body]).click(this.hideIfClickOutside);},hide:function(){alert("hide");this.rootLayers.css("display","none");$([window,document.body]).unbind("click",this.hideIfClickOutside);this.input.click(this.show);},hideIfClickOutside:function(event){if(event.target!=this.input[0]&&!this.insideSelector(event)){this.hide();};},stringToDate:function(string){var matches;if(matches=string.match(/^(\d{1,2}) ([^\s]+) (\d{4,4})$/)){return new Date(matches[3],this.shortMonthNum(matches[2]),matches[1]);}else{return null;};},dateToString:function(date){return date.getDate()+" "+this.short_month_names[date.getMonth()]+" "+date.getFullYear();},setPosition:function(){var offset=this.input.offset();this.rootLayers.css({top:offset.top+this.input.outerHeight(),left:offset.left});if(this.ieframe){this.ieframe.css({width:this.dateSelector.outerWidth(),height:this.dateSelector.outerHeight()});};},moveMonthBy:function(amount){this.selectMonth(new Date(this.currentMonth.setMonth(this.currentMonth.getMonth()+amount)));},prevMonth:function(){this.moveMonthBy(-1);return false;},nextMonth:function(){this.moveMonthBy(1);return false;},monthName:function(date){return this.month_names[date.getMonth()];},insideSelector:function(event){var offset=this.dateSelector.offset();offset.right=offset.left+this.dateSelector.outerWidth();offset.bottom=offset.top+this.dateSelector.outerHeight();return event.pageY<offset.bottom&&event.pageY>offset.top&&event.pageX<offset.right&&event.pageX>offset.left;},bindToObj:function(fn){var self=this;return function(){return fn.apply(self,arguments)};},bindMethodsToObj:function(){for(var i=0;i<arguments.length;i++){this[arguments[i]]=this.bindToObj(this[arguments[i]]);};},indexFor:function(array,value){for(var i=0;i<array.length;i++){if(value==array[i])return i;};},monthNum:function(month_name){return this.indexFor(this.month_names,month_name);},shortMonthNum:function(month_name){return this.indexFor(this.short_month_names,month_name);},shortDayNum:function(day_name){return this.indexFor(this.short_day_names,day_name);},daysBetween:function(start,end){start=Date.UTC(start.getFullYear(),start.getMonth(),start.getDate());end=Date.UTC(end.getFullYear(),end.getMonth(),end.getDate());return(end-start)/86400000;},changeDayTo:function(to,date,direction){var difference=direction*(Math.abs(date.getDay()-to-(direction*7))%7);return new Date(date.getFullYear(),date.getMonth(),date.getDate()+difference);},rangeStart:function(date){return this.changeDayTo(this.start_of_week,new Date(date.getFullYear(),date.getMonth()),-1);},rangeEnd:function(date){return this.changeDayTo((this.start_of_week-1)%7,new Date(date.getFullYear(),date.getMonth()+1,0),1);},isFirstDayOfWeek:function(date){return date.getDay()==this.start_of_week;},isLastDayOfWeek:function(date){return date.getDay()==(this.start_of_week-1)%7;},adjustDays:function(days){var newDays=[];for(var i=0;i<days.length;i++){newDays[i]=days[(i+this.start_of_week)%7];};return newDays;}};$.fn.date_input=function(opts){return this.each(function(){new DateInput(this,opts);});};$.date_input={initialize:function(opts){$("input.date_input").date_input(opts);}};return DateInput;})(jQuery);$.extend(DateInput.DEFAULT_OPTS,{stringToDate:function(string){var matches;if(matches=string.match(/^(\d{4,4})-(\d{2,2})-(\d{2,2})$/)){return new Date(matches[1],matches[2]-1,matches[3]);}else{return null;};},dateToString:function(date){var month=(date.getMonth()+1).toString();var dom=date.getDate().toString();if(month.length==1)month="0"+month;if(dom.length==1)dom="0"+dom;return date.getFullYear()+"-"+month+"-"+dom;}});
// JS/jquery.date_input.js

(function($){$.event.special.mousewheel={setup:function(){var handler=$.event.special.mousewheel.handler;if($.browser.mozilla)
$(this).bind('mousemove.mousewheel',function(event){$.data(this,'mwcursorposdata',{pageX:event.pageX,pageY:event.pageY,clientX:event.clientX,clientY:event.clientY});});if(this.addEventListener)
this.addEventListener(($.browser.mozilla?'DOMMouseScroll':'mousewheel'),handler,false);else
this.onmousewheel=handler;},teardown:function(){var handler=$.event.special.mousewheel.handler;$(this).unbind('mousemove.mousewheel');if(this.removeEventListener)
this.removeEventListener(($.browser.mozilla?'DOMMouseScroll':'mousewheel'),handler,false);else
this.onmousewheel=function(){};$.removeData(this,'mwcursorposdata');},handler:function(event){var args=Array.prototype.slice.call(arguments,1);event=$.event.fix(event||window.event);$.extend(event,$.data(this,'mwcursorposdata')||{});var delta=0,returnValue=true;if(event.wheelDelta)delta=event.wheelDelta/120;if(event.detail)delta=-event.detail/3;if($.browser.opera)delta=-event.wheelDelta;event.data=event.data||{};event.type="mousewheel";args.unshift(delta);args.unshift(event);return $.event.handle.apply(this,args);}};$.fn.extend({mousewheel:function(fn){return fn?this.bind("mousewheel",fn):this.trigger("mousewheel");},unmousewheel:function(fn){return this.unbind("mousewheel",fn);}});})(jQuery);
// JS/jquery.mousewheel.js

(function(jQuery){var self=null;jQuery.fn.autogrow=function()
{return this.each(function(){new jQuery.autogrow(this);});};jQuery.autogrow=function(e)
{this.interval=null;this.textarea=jQuery(e);var self=this;this.textarea.bind('keyup',function(){var self=$(this);var fromTop=self.scrollTop();if(fromTop>0)self.animate({height:(self.height()+fromTop+20)+'px'},100);})}})(jQuery);
// JS/jquery.autogrow.js

jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}expires='; expires='+date.toUTCString();}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}return cookieValue;}};
// JS/jquery.cookie.min.js

if(typeof BW!="object")var BW={};BW.initialize=function(){BW.Locale.load();BW.oTitle=$("head title");UI.Targets.RDF.init();UI.History.init();UI.Events.init(document);UI.Comments.behavior();UI.Windows.init();}
BW.setTitle=function(str){if(typeof str!="string"||str==""){str=BW.Config.title;}else{str=BW.Config.title+" - "+str;}
document.title=str;if(!$.browser.msie&&!$.browser.version<7)BW.oTitle.text(str);}
BW.Browser={ShowInfo:function(){if($.cookie("message_view")!="hide"){if($.browser.msie&&$.browser.version<7){BW.Browser.Warning("<div style='border: 1px solid #F7941D; background: #FEEFDA; text-align: center; clear: both; height: 75px; position: relative;'><div style='position: absolute; right: 3px; top: 3px; font-family: courier new; font-weight: bold;'><a href='#' id='hideMessage'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-cornerx.jpg' style='border: none;' alt='Close this notice'/></a></div><div style='width: 640px; margin: 0 auto; text-align: left; padding: 0; overflow: hidden; color: black;'><div style='width: 75px; float: left;'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-warning.jpg' alt='Warning!'/></div><div style='width: 275px; float: left; font-family: Arial, sans-serif;'><div style='font-size: 14px; font-weight: bold; margin-top: 12px;'>"+BW.Locale.get('You are using an outdated browser')+"</div><div style='font-size: 12px; margin-top: 6px; line-height: 12px;'>"+BW.Locale.get('For a better experience using this site, please upgrade to a modern web browser.')+"</div></div><div style='width: 75px; float: left;'><a href='http://www.firefox.com' target='_blank'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-firefox.jpg' style='border: none;' alt='Get Firefox 3.5'/></a></div><div style='width: 75px; float: left;'><a href='http://www.browserforthebetter.com/download.html' target='_blank'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-ie8.jpg' style='border: none;' alt='Get Internet Explorer 8'/></a></div><div style='width: 73px; float: left;'><a href='http://www.apple.com/safari/download/' target='_blank'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-safari.jpg' style='border: none;' alt='Get Safari 4'/></a></div><div style='float: left;'><a href='http://www.google.com/chrome' target='_blank'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-chrome.jpg' style='border: none;' alt='Get Google Chrome'/></a></div></div></div>");}else if(navigator.appVersion.indexOf("Windows CE")>0){}else if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPod/i))){}else if(!(($.browser.mozilla)||($.browser.msie&&$.browser.version>=7))){}}
$("#hideMessage").click(function(){$("#uiBrowserWarning").slideUp();$.cookie("message_view","hide",{expires:32});});},Warning:function(sMessage){$("#uiBrowserWarning").prepend(sMessage).show();},Redirect:function(){}}
BW.Error={oCodes:{},get:function(nCode){return BW.Locale.get(nCode);}}
BW.Notify={init:function(){this.dNotifyMessages=$("#uiNotifyMessages");this.dNotifyMessagesCount=$("SPAN",this.dNotifyMessages);this.dNotifyMessages.click(function(){var node=$(this);node.css("background-position","0px 0px");$("SPAN",node).html("Inbox");node.blur();});this.start();this.dispatcher();},start:function(){this.timer=setInterval(BW.Notify.check,BW.Config.PING_INTERVAL);this.check();},stop:function(){clearInterval(this.timer);},check:function(){$.get(BW.Config.ROOTURI+'mvc/Communication/Messages/UnreadMessages',{"_display":"xml"},function(data){if($("system user",$(data)).attr("id")==$("#uiNotifyMessages").attr("userid")){var messages=$("message",$(data));BW.Notify.newMessages(messages);}
else top.location.href=BW.Config.ROOTURI+"mvc/User/Index/LoggedOff";});},newMessages:function(messages){var text="new messages.";var newestMessage="";for(var i=0;i<messages.length;i++){newestMessage+=$("fullname",messages.eq(i)).text()+": "+$("subject",messages.eq(i)).text()+"<br/>";}
switch(messages.length){case 1:text="new message.";break;case 0:text="No unread messages.";break;}
if(messages.length>0)this.dNotifyMessages.css("background-position","0px -30px");else this.dNotifyMessages.css("background-position","0px 0px");this.dNotifyMessagesCount.html(messages.length+" "+text+newestMessage);},aEvents:[],register:function(sName,sType,sUri,fFunction,oDependency){this.aEvents.push({sName:sName,sType:sType,sUri:sUri,fFunction:fFunction,oDependency:oDependency})
this.dispatcher();},unregister:function(oEvent){for(var i=0;i<BW.Notify.aEvents.length;i++){if(BW.Notify.aEvents[i]===oEvent){BW.Notify.aEvents.splice(i,1);return;}}},dispatcher:function(){if(typeof this.eEvent!="undefined")clearInterval(this.eEvent);this.eEvent=setInterval(BW.Notify.touchServer,2000);},touchServer:function(){if(BW.Notify.aEvents.length==0)return clearInterval(BW.Notify.eEvent)
for(var i=0;i<BW.Notify.aEvents.length;i++){if(!$(BW.Notify.aEvents[i].oDependency).is('*')){BW.Notify.unregister(BW.Notify.aEvents[i]);i--;}else{var oEvent=BW.Notify.aEvents[i];$.getJSON(BW.Notify.aEvents[i].sUri,{},function(data){oEvent.fFunction(data,oEvent);});}}}};BW.Forms={aForm:[{ID:false}],add:function(oForm){for(var i=0;i<this.aForm.length;i++){if(this.aForm[i].ID==oForm.ID)return this.aForm[i]=oForm;}
return this.aForm.push(oForm);},find:function(sId){for(var i=0;i<this.aForm.length;i++){if(this.aForm[i].ID==sId)return i;}
return false;},get:function(sId){var nIndex=this.find(sId);if(nIndex>0)return this.aForm[nIndex];else return false;},remove:function(sId){var nIndex=this.find(sId);if(nIndex>0){alert("Removing form...");this.aForm.splice(nIndex,1);return true;}else{return false;}}}
BW.Locale={phrase:{},get:function(sString){if(typeof this.phrase[sString]=="string")return this.phrase[sString];else return sString;},load:function(){$.get(BW.Config.ROOTURI+"mvc/General/Index/ClientSidePhrases?unique="+UI.Utils.randomString(5),function(data){var phrases=$(data).find("phrase");phrases.each(function(i){var node=$(this);BW.Locale.phrase[node.attr("id")]=node.text();});BW.Browser.ShowInfo();});}}
BW.Regexp={alpha:{type:"alpha",regexp:/^[a-z ._-]+$/i,msg:"This field accepts alphabetic characters only."},alphanum:{type:"alphanum",regexp:/^[a-z0-9 ._-]+$/i,msg:"This field accepts alphanumeric characters only."},integer:{type:"integer",regexp:/^[-+]?\d+$/,msg:"Please enter a valid integer."},real:{type:"real",regexp:/^[-+]?\d*\.?\d+$/,msg:"Please enter a valid number."},date:{type:"date",regexp:/^(19|20)\d\d[- /.](0[1-9]|1[012])[-/.](0[1-9]|[12][0-9]|3[01])$/,msg:"Please enter a valid date (YYYY-MM-DD)."},time:{type:"time",regexp:/^([01][0-9]|2[0-3]):[0-5][0-9]$/,msg:"Please enter valid 24 hour time (e.g. 14:30) "},email:{type:"email",regexp:/^[a-z0-9._%-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i,msg:"Please enter a valid email."},phone:{type:"phone",regexp:/^[\d\s ().-]+$/,msg:"Please enter a valid phone."},password:{type:"password",regexp:/^.{5,}$/,msg:"Good password has at least 5 characters."},url:{type:"url",regexp:/^(http|https|ftp)\:\/\/[a-z0-9\-\.]+\.[a-z]{2,3}(:[a-z0-9]*)?\/?([a-z0-9\-\._\?\,\'\/\\\+&amp;%\$#\=~])*$/i,msg:"Please enter a valid url."}}
// JS/BW.js

BW.require=window.require=function(scriptName,callback,context){function durl(sc){var su=sc;if(sc&&sc.substring(0,4)=="url("){su=sc.substring(4,sc.length-1);}
var r=BW.require.registered[su];return(!r&&(!BW.require.__durls||!BW.require.__durls[su])&&sc&&sc.length>4&&sc.substring(0,4)=="url(");}
var a=-1;var scriptNames=new Array();if(typeof(scriptName)!="string"&&scriptName.length){var _scriptNames=scriptName;for(var s=0;s<_scriptNames.length;s++){if(BW.require.registered[_scriptNames[s]]||durl(_scriptNames[s])){scriptNames.push(_scriptNames[s]);}}
scriptName=scriptNames[0];a=1;}else{while(typeof(arguments[++a])=="string"){if(BW.require.registered[scriptName]||durl(scriptName)){scriptNames.push(arguments[a]);}}}
callback=arguments[a];context=arguments[++a];if(scriptNames.length>1){var cb=callback;callback=function(){using(scriptNames,cb,context);}}
var reg=BW.require.registered[scriptName];if(!BW.require.__durls)BW.require.__durls={};if(durl(scriptName)&&scriptName.substring(0,4)=="url("){scriptName=scriptName.substring(4,scriptName.length-1);if(!BW.require.__durls[scriptName]){scriptNames[0]=scriptName;BW.require.register(scriptName,true,scriptName);reg=BW.require.registered[scriptName];var callbackQueue=BW.require.prototype.getCallbackQueue(scriptName);var cbitem=new BW.require.prototype.CallbackItem(function(){BW.require.__durls[scriptName]=true;});callbackQueue.push(cbitem);callbackQueue.push(new BW.require.prototype.CallbackItem(callback,context));callback=undefined;context=undefined;}}
if(reg){for(var r=reg.requirements.length-1;r>=0;r--){if(BW.require.registered[reg.requirements[r].name]){using(reg.requirements[r].name,function(){using(scriptName,callback,context);},context);return;}}
for(var u=0;u<reg.urls.length;u++){if(u==reg.urls.length-1){if(callback){BW.require.load(reg.name,reg.urls[u],reg.remote,reg.asyncWait,new BW.require.prototype.CallbackItem(callback,context));}else{BW.require.load(reg.name,reg.urls[u],reg.remote,reg.asyncWait);}}else{BW.require.load(reg.name,reg.urls[u],reg.remote,reg.asyncWait);}}}else{var cb=callback;if(cb){cb.call(context);}}}
BW.require.prototype={CallbackItem:function(_callback,_context){this.callback=_callback;this.context=_context;this.invoke=function(){if(this.context)this.callback.call(this.context);else this.callback();};},Registration:function(_name,_version,_remote,_asyncWait,_urls){this.name=_name;var a=0;var arg=arguments[++a];var v=true;if(typeof(arg)=="string"){for(var c=0;c<arg.length;c++){if("1234567890.".indexOf(arg.substring(c))==-1){v=false;break;}}
if(v){this.version=arg;arg=arguments[++a];}else{this.version="1.0.0";}}
if(arg&&typeof(arg)=="boolean"){this.remote=arg;arg=arguments[++a];}else{this.remote=false;}
if(arg&&typeof(arg)=="number"){this.asyncWait=_asyncWait;}else{this.asyncWait=0;}
this.urls=new Array();if(arg&&arg.length&&typeof(arg)!="string"){this.urls=arg;}else{for(a=a;a<arguments.length;a++){if(arguments[a]&&typeof(arguments[a])=="string"){this.urls.push(arguments[a]);}}}
this.requirements=new Array();this.requires=function(resourceName,minimumVersion){if(!minimumVersion)minimumVersion="1.0.0";this.requirements.push({name:resourceName,minVersion:minimumVersion});return this;}
this.register=function(name,version,remote,asyncWait,urls){return BW.require.register(name,version,remote,asyncWait,urls);}
return this;},register:function(name,version,remote,asyncWait,urls){var reg;if(typeof(name)=="object"){reg=name;reg=new BW.require.prototype.Registration(reg.name,reg.version,reg.remote,reg.asyncWait,urls);}else{reg=new BW.require.prototype.Registration(name,version,remote,asyncWait,urls);}
if(!BW.require.registered)BW.require.registered={};if(BW.require.registered[name]&&window.console){window.console.log("Warning: Resource named \""+name+"\" was already registered with BW.require.register(); overwritten.");}
BW.require.registered[name]=reg;return reg;},wait:0,defaultAsyncWait:250,getCallbackQueue:function(scriptUrl){if(!BW.require.__callbackQueue){BW.require.__callbackQueue={};}
var callbackQueue=BW.require.__callbackQueue[scriptUrl];if(!callbackQueue){callbackQueue=BW.require.__callbackQueue[scriptUrl]=new Array();}
return callbackQueue;},load:function(scriptName,scriptUrl,remote,asyncWait,cb){if(asyncWait==undefined)asyncWait=BW.require.wait;if(remote&&asyncWait==0)asyncWait=BW.require.defaultAsyncWait;if(!BW.require.loadedScripts)BW.require.loadedScripts=new Array();var callbackQueue=BW.require.prototype.getCallbackQueue(scriptUrl);callbackQueue.push(new BW.require.prototype.CallbackItem(function(){BW.require.loadedScripts.push(BW.require.registered[scriptName]);BW.require.registered[scriptName]=undefined;},null));if(cb){callbackQueue.push(cb);if(callbackQueue.length>2)return;}
if(remote){BW.require.srcScript(scriptUrl,asyncWait,callbackQueue);}else{var xhr;if(window.XMLHttpRequest)
xhr=new XMLHttpRequest();else if(window.ActiveXObject){xhr=new ActiveXObject("Microsoft.XMLHTTP");}
xhr.onreadystatechange=function(){if(xhr.readyState==4&&xhr.status==200){BW.require.injectScript(xhr.responseText,scriptName);if(callbackQueue){for(var q=0;q<callbackQueue.length;q++){callbackQueue[q].invoke();}}
BW.require.__callbackQueue[scriptUrl]=undefined;}};if(asyncWait>0||callbackQueue.length>1){xhr.open("GET",scriptUrl,true);}else{xhr.open("GET",scriptUrl,false);}
xhr.send(null);}},genScriptNode:function(){var scriptNode=document.createElement("script");scriptNode.setAttribute("type","text/javascript");scriptNode.setAttribute("language","JavaScript");return scriptNode;},srcScript:function(scriptUrl,asyncWait,callbackQueue){var scriptNode=BW.require.prototype.genScriptNode();scriptNode.setAttribute("src",scriptUrl);if(callbackQueue){var execQueue=function(){BW.require.__callbackQueue[scriptUrl]=undefined;for(var q=0;q<callbackQueue.length;q++){callbackQueue[q].invoke();}
callbackQueue=new Array();}
scriptNode.onload=scriptNode.onreadystatechange=function(){if((!scriptNode.readyState)||scriptNode.readyState=="loaded"||scriptNode.readyState=="complete"||scriptNode.readyState==4&&scriptNode.status==200){if(asyncWait>0){setTimeout(execQueue,asyncWait);}
else{execQueue();}}};}
var headNode=document.getElementsByTagName("head")[0];headNode.appendChild(scriptNode);},injectScript:function(scriptText,scriptName){var scriptNode=BW.require.prototype.genScriptNode();try{scriptNode.setAttribute("name",scriptName);}catch(err){}
scriptNode.text=scriptText;var headNode=document.getElementsByTagName("head")[0];headNode.appendChild(scriptNode);}};BW.require.register=BW.require.prototype.register;BW.require.load=BW.require.prototype.load;BW.require.wait=BW.require.prototype.wait;BW.require.defaultAsyncWait=BW.require.prototype.defaultAsyncWait;BW.require.srcScript=BW.require.prototype.srcScript;BW.require.injectScript=BW.require.prototype.injectScript;
// JS/BW.require.js

UI=new Object();UI.Utils=new Object();UI.Targets=new Object();UI.Controls=new Object();UI.Message=new Object();UI.Targets.include=function(oEle){var dAtag=$(oEle);var dRel="";href=$.trim(dAtag.attr("href"));if(typeof dAtag.attr("rel")=="string"&&dAtag.attr("rel")!=""){dRel=$(dAtag.attr("rel"));}
if(dAtag.is("once")&&dRel!=""&&$(dRel).html()!="")return;if(dAtag.is(".homepage")&&location.href.indexOf("#")!=-1&&location.href.indexOf("#")<location.href.length-1){href=location.href.replace(/#/i,"");if(dAtag.not(".nohistory").length>0){UI.History.add(href,dRel);UI.Targets.RDF.check(href);}}
var href=(href.indexOf("?")<0)?href+"?_display=include":href+"&_display=include";$.get(href,function(data){if(dRel!=""){UI.Targets.place(data,dRel,false);}else{dAtag.before(data);}
dAtag.remove();});}
UI.Targets.RDF={oCurrent:null,init:function(){this.dHead=$("head");var lnk=$("link[title=RDF]",this.dHead);if(typeof lnk!="undefined"){this.oCurrent={};this.oCurrent.link=lnk;}},add:function(sUri){this.remove();this.oCurrent={};sUri=sUri.slice(0,sUri.indexOf("?"));this.oCurrent.link=$('<link rel="alternate" type="application/rdf+xml" title="RDF" href="'+sUri+'?RDF" />').appendTo(this.dHead);this.oCurrent.anchor=$('<a rel="meta" type="application/rdf+xml" href="'+sUri+'?RDF" target="_blank"><img src="'+BW.Config.ROOTURI+'Hive/Media/Images/rdf.png"/></a>').appendTo("#uiSemantic");},remove:function(){$("#uiSemantic").html("");if(this.oCurrent!=null){this.oCurrent.link.remove();this.oCurrent=null;}},check:function(sUri){if(sUri.indexOf("oes")>-1){this.add(sUri);}else{this.remove();}}}
UI.Targets.load=function(sUri,sEle,oTrigger,bNoHistory,sMode,foCallback,foObject){var bAdd=false;oTrigger=(typeof oTrigger=="undefined"||oTrigger==null)?$(sEle):$(oTrigger);if(sUri==""||sUri.indexOf("#")==0||typeof sUri=="undefined")return false;else if(sUri.indexOf("javascript:")>-1){var script=sUri.replace(/javascript:/,"").replace(/\?_display=include/,"");try{eval(script)}
catch(er){};return false;}
switch(sMode){case"include":sUri=(sUri.indexOf("?")>-1)?sUri+"&_display=include":sUri+"?_display=include";break;}
if(typeof sEle=="string"){if(sEle==""||typeof sEle=="undefined")sEle=".uiWebMain";if(sEle.indexOf("ADD")==0){bAdd=true;sEle=sEle.substr(3);}else if(sEle=="REFRESH"){sEle=".uiWebMain";}
if(oTrigger){var oContext=UI.Targets.proximity(sEle,oTrigger.get(0));}else{var oContext=$(sEle);}}else{oContext=sEle;}
var dTarget={oEle:(oTrigger.is(".replaceTarget"))?oContext.parent():oContext,bAdd:bAdd}
if(!bAdd){dTarget.oLoader=new UI.Targets.Disable(dTarget.oEle);}else{}
if(!bNoHistory&&(!bAdd&&oTrigger.not(".nohistory").length>0)){UI.History.add(sUri,oContext);UI.Targets.RDF.check(sUri);}else if(!bNoHistory&&(bAdd&&oTrigger.not(".nohistory").length>0)){UI.History.addAdditional(sUri,"ADD"+sEle);}
var ffCallback=foCallback;var ffObject=foObject;$.get(sUri,function(data){var fCallback=UI.Targets.callback(oTrigger);if(!dTarget.bAdd){if(!fCallback(data,oTrigger)){UI.Targets.place(data,dTarget.oEle.eq(0),false);dTarget.oLoader.hide();}}else{if(!fCallback(data,oTrigger)){UI.Targets.place(data,dTarget.oEle.eq(0),true);}}
if(typeof ffCallback=="function"){if(typeof ffObject=="object")
ffCallback.apply(ffObject);else ffCallback();}});}
UI.Targets.callback=function(oTrigger,fFunc){if(typeof fFunc!="function"){if(oTrigger.attr("oncallback")!=''){eval("fFunc = function(data, oTrigger){"+oTrigger.attr("oncallback")+"}");}else{fFunc=function(){return true;};};}
return function(data,oTrigger){if(typeof fFunc=="function")return fFunc(data,oTrigger);};}
UI.Targets.proximity=function(sEle,dTrigger){var node=dTrigger.parentNode;if(node.tagName=="BODY"){return $(sEle,$(node));}else if(node.className.indexOf("uiArea")>-1){if($(node).is(sEle))var oEle=$(node);else var oEle=$(sEle,$(node));if(oEle.length==0){return this.proximity(sEle,node);}else{return oEle;}}else{return this.proximity(sEle,node);}}
UI.Targets.place=function(data,oEle,bAdd,bReplace){var oEle=$(oEle);if(bAdd){var node=$(data).appendTo(oEle);}else{if(bReplace){oEle.replaceWith($(data));}else{var node=oEle.html(data);}
if(typeof oEle.data("disabled")!="undefined"){if(oEle.children("*:not(.uiMessage)").length==0){oEle.append(oEle.data("disabled").dOriginal)}
oEle.removeData("disabled");}
BW.setTitle(oEle.children("[title]").eq(0).attr("title"));oEle.children("[title]").eq(0).removeAttr("title");}
UI.Targets.focus(oEle);}
UI.Targets.focus=function(oEle){var doc=$(document)
var offset=oEle.offset().top;if(doc.scrollTop()>offset)
doc.scrollTop(offset)}
UI.Targets.replaceWith=function(data,oEle,bAdd){var oEle=$(oEle);oEle.replaceWith(data);}
UI.Targets.bind=function(node){node.bind("click",{uri:$.trim(node.attr("href")),target:node.attr("rel")},function(event){var node=$(this);if(typeof event.data.uri=="undefined")return false;var href=event.data.uri+(event.data.uri.indexOf("?")<0?"?":"&")+"_display=include";if(node.is(".toggle")){if(node.is(".targetOpened")){$(event.data.target).hide();node.removeClass("targetOpened");}else{$(event.data.target).show();node.addClass("targetOpened");if(!node.is(".targetLoaded")){node.addClass("targetLoaded");UI.Targets.load(href,event.data.target,this);}}}
else if(node.is(".flag")){$.get(event.data.uri,function(){window.location.href=window.location.href.replace("#","");});return false;}
else{UI.Targets.load(href,event.data.target,this);}
node.blur();return false;});}
UI.Select={act:[],selected:function(sPath){for(var i=0;i<this.act.length;i++){this.act[i](sPath);}},onSelect:function(fn){this.act.push(fn);}}
UI.Targets.Disable=function(oEle,bHideOnly){this.dom=$(oEle);if(this.dom.is(":hidden")){var tab=this.dom.parents(".uiTab");if(tab.parent().html()!=null){var head=tab.data("tabhead");var offset=head.offset().top;$(document).scrollTop(offset);tab.addClass("loaded");$("A",head).click();}}
this.bHideOnly=(bHideOnly)?true:false;this.oOffset=this.dom.offset();this.dDisabler=$('<div class="loading"></div>');this.dDisabler.attr("id",UI.Utils.randomString());this.show();}
UI.Targets.Disable.prototype.show=function(){var nHeight=(this.dom.height()>350)?350:this.dom.height();nHeight=(nHeight<32)?32:nHeight;this.dDisabler.css({width:this.dom.width(),height:nHeight});this.dOriginal=this.dom.clone(true);this.dom.data("disabled",this);if(!this.bHideOnly)this.dom.html("").append(this.dDisabler);else this.dom.append(this.dDisabler);return this;}
UI.Targets.Disable.prototype.hide=function(){this.dDisabler.remove();return this;}
UI.Events={rules:{keyup:[],keydown:[]},scopes:[],init:function(scope){if(typeof scope=="undefined")var scope=document;this.scopes.push(scope);this.start();},addRule:function(bindTo,rule_options,fn){bindTo=bindTo.toLowerCase();options={key:false,priority:5,bubble:true,ctrlKey:false,shiftKey:false,altKey:false,element:false}
if(typeof rule_options!="object"&&typeof rule_options!="function")rule_options={key:rule_options}
$.extend(options,rule_options);if(options.key){options.key=this.mapKeys(options.key);this.rules[bindTo].push({key:options.key,priority:options.priority,bubble:options.bubble,fn:fn,ctrlKey:options.ctrlKey,shiftKey:options.shiftKey,altKey:options.altKey});this.rules[bindTo].sort(function(a,b){return a.priority-b.priority;})}},removeRule:function(boundTo,sName){for(var i=0;i<this.rules[boundTo].length;i++){if(this.rules[boundTo][i].name==sName){this.rules[boundTo].splice(i,1);break;}}},trigger:function(sEvent){var frame=true;if(sEvent!="keyup"&&sEvent!="keydown")return;for(var i=0;i<this.rules[sEvent].length;i++){var evt=this.rules[sEvent][i];if(this.checkKey(evt.key)){if(evt.ctrlKey==null)evt.ctrlKey=this.event.ctrlKey;if(evt.shiftKey==null)evt.shiftKey=this.event.shiftKey;if(evt.ctrlKey==this.event.ctrlKey&&evt.shiftKey==this.event.shiftKey){evt.fn(this);if(evt.bubble==false){frame=false;this.cancel();break;}}}}
if(frame){if(this.sMode!="lower"&&!(top===self)&&parent.UI)frame=parent.UI.Events.frame(this.event,sEvent,"upper");if(this.sMode!="upper"&&frame){for(var i=0;i<self.length;i++){if(self[i].UI){frame=self[i].UI.Events.frame(this.event,sEvent,"lower");}
if(!frame)break;}}}
return frame;},frame:function(event,sType,mode){this.sMode=mode;this.event=event;this.trigger(sType);},checkKey:function(key){if(typeof key=="number"&&(this.event.which==key))return true;else if(key){for(var i=0;i<key.length;i++){if(this.event.which==key[i])return true;}
return false;}},keyUp:function(event){UI.Events.event=event;UI.Events.trigger("keyup");},keyDown:function(event){UI.Events.event=event;UI.Events.trigger("keydown");},start:function(){$.each(this.scopes,function(i,n){$(n).bind("keyup",UI.Events.keyUp);$(n).bind("keydown",UI.Events.keyDown);});},restart:function(){this.stop();this.start();},stop:function(){$.each(this.scopes,function(i,n){$(n).unbind("keyup");$(n).unbind("keydown");});},cancel:function(){if(this.event){this.event.stopPropagation();this.event.preventDefault();this.event.cancelBubble=true;}},mapKeys:function(keys){if(typeof keys=="string")return this.map[keys];else{var keyCodes=[];for(var i=0;i<keys.length;i++){keyCodes.push(this.map[keys[i]]);}
return keyCodes;}},map:{"backspace":8,"tab":9,"enter":13,"shift":16,"ctrl":17,"alt":18,"esc":27,"space":32,"pageup":33,"pagedown":34,"home":36,"left":37,"up":38,"right":39,"down":40,"insert":45,"delete":46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,"@":64,"a":65,"b":66,"c":67,"d":68,"e":69,"f":70,"g":71,"h":72,"i":73,"j":74,"k":75,"l":76,"m":77,"n":78,"o":79,"p":80,"q":81,"r":82,"s":83,"t":84,"u":85,"v":86,"w":87,"x":88,"y":89,"z":90,"start":91,"f1":112,"f2":113,"f3":114,"f4":115,"f5":116,"f6":117,"f7":118,"f8":119,"f9":120,"f10":121,"f11":122,"f12":123}}
UI.Utils={countProperties:function(obj){var count=0;for(var k in obj)if(obj.hasOwnProperty(k))count++;return count;},randomString:function(nLength){var sChars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";var nChars=(typeof nLength=="number")?nLength:10;var sResult='';for(var i=0;i<nChars;i++){var nResult=Math.floor(Math.random()*sChars.length);sResult+=sChars.substring(nResult,nResult+1);}
return"_"+sResult;},merge:function(obj1,obj2){for(var property in obj2){if(!obj1.hasOwnProperty(property)){obj1[property]=obj2[property];}}
return obj1;},isArray:function(aArray){if(typeof aArray.length==='number'&&!(aArray.propertyIsEnumerable('length'))&&typeof aArray.splice==='function')return true;else return false;},ARRAY:{toSource:function(aArray){var str="[";for(var i=0;i<aArray.length;i++){if(i==aArray.length-1){str+="'"+aArray[i]+"'";}else{str+="'"+aArray[i]+"',";}}
str+="]";return str;},fromSource:function(sString){var aArray=new Array();if(sString==null)return aArray;return sString.slice(2,-2).split("','");}},JSON:{toXML:function(json){var xml="";for(var prop in json){if(prop.charAt(0)!="@"&&prop.charAt(0)!="#"){if(typeof json[prop]!="string"&&typeof json[prop]=="object"){if(typeof json[prop].length==='number'&&!(json[prop].propertyIsEnumerable('length'))&&typeof json[prop].splice==='function'){for(var i=0;i<json[prop].length;i++){var attrs="";var contents="";for(var desc in json[prop][i]){if(desc.charAt(0)=="@"&&desc.indexOf("@_moz")<0){attrs+=' '+desc.slice(1)+'="'+json[prop][i][desc]+'"';}else if(desc.charAt(0)=="#"){contents+=json[prop][i][desc];}}
xml+='<'+prop+attrs+'>'+this.toXML(json[prop][i])+contents+'</'+prop+'>';}}else{var attrs="";var contents="";for(var desc in json[prop]){if(desc.charAt(0)=="@"&&desc.indexOf("@_moz")<0){attrs+=' '+desc.slice(1)+'="'+json[prop][desc]+'"';}else if(desc.charAt(0)=="#"){contents+=json[prop][desc].replace(/& /g,"&amp;");}}
xml+='<'+prop+attrs+'>'+this.toXML(json[prop])+contents+'</'+prop+'>';}}}}
var details=function(){return[attrs,content];}
return xml;},toString:function(json){var str=" { \n";for(var prop in json){if(prop.charAt(0)!="@"&&prop.charAt(0)!="#"){if(typeof json[prop]!="string"&&typeof json[prop]=="object"){str+="\t"+prop+" : "+this.toString(json[prop])+" , \n";}else{str+="\t"+prop+" : "+json[prop]+" , \n";}}}
str+=" } \n";return str;}},XML:{serialize:function(node){if(typeof XMLSerializer!="undefined")
return(new XMLSerializer()).serializeToString(node);else if(node.xml)return node.xml;}},trim:function(str,chars){return this.ltrim(this.rtrim(str,chars),chars);},ltrim:function(str,chars){chars=chars||"\\s";return str.replace(new RegExp("^["+chars+"]+","g"),"");},rtrim:function(str,chars){chars=chars||"\\s";return str.replace(new RegExp("["+chars+"]+$","g"),"");},getObjectTypeFromUri:function(sUri){var sExt=sUri.substr(sUri.lastIndexOf(".")+1);if(sExt=="")return false;sExt=sExt.charAt(0).toUpperCase()+sExt.substr(1).toLowerCase();return"Object"+sExt;},getObjectTypeFromMime:function(sType){var sExt=sType.substr(sType.lastIndexOf("/")+1);if(sExt=="")return false;sExt=sExt.charAt(0).toUpperCase()+sExt.substr(1).toLowerCase();sExt=this.fixMimeTypeExt(sExt);return"Object"+sExt;},fixMimeTypeExt:function(sStr){if(sStr.indexOf("excel")>-1)return"Xls";if(sStr.indexOf("word")>-1)return"Doc";if(sStr.indexOf("powerpoint")>-1)return"Ppt";if(sStr.indexOf("java")>-1)return"Jar";if(sStr.indexOf("postscript")>-1)return"Eps";if(sStr.indexOf("jpeg")>-1||sStr.indexOf("jpe")>-1)return"Jpg";if(sStr.indexOf("plain")>-1)return"Txt";if(sStr.indexOf("shockwave")>-1)return"Swf";if(sStr.indexOf("msvideo")>-1)return"Avi";if(sStr.indexOf("mpeg")>-1)return"Mpg";if(sStr.indexOf("quicktime")>-1)return"Mov";if(sStr.indexOf("vrml")>-1)return"Vrml";return sStr;},buildPath:function(ele,path){var visiblePath=(path)?path:"";var tmp=ele.text();if(tmp=="Users"){return"Users"+visiblePath;}else{visiblePath="/"+tmp+visiblePath;return this.buildPath(ele.parent().parent().prev(),visiblePath);}}}
$.extend(UI.Utils,UIExt);UI.Status=function(node){this.node=node;this.mode=(node.attr("rel")=="community")?"Community":"User";var status=this.node.html();if(!status)
status="Type your current status here...";this.status=status;this.statusEle=$(".uiStatus");this.statusField=$(".changeTxt2Input",this.statusEle);this.statusInput=$(".changeInput2Txt",this.statusEle);this.saveStatus=$("#saveStatus",this.statusEle);this.stornoStatus=$("#stornoStatus",this.statusEle);this.init(status);}
UI.Status.prototype.init=function(status){this.behavior();}
UI.Status.prototype.behavior=function(){var self=this;var editableMode=false;this.saveStatus.click(function(event){store()});$("TEXTAREA",this.statusInput).keypress(function(event){if(event.keyCode==13){store();}});this.stornoStatus.click(function(event){store("restore")});var editButton=$(".uiStatusLink A",this.node.parent());var self=this;editButton.hover(function(){self.statusField.addClass("hover")},function(){self.statusField.removeClass("hover")});this.statusField.hover(function(){editButton.addClass("hover");},function(){editButton.removeClass("hover");})
$("#editStatus,.changeTxt2Input",this.statusEle).click(function(event){editableMode=true;self.statusField.removeClass("hover");editButton.removeClass("hover");showHide();$("TEXTAREA",self.statusInput).val("").focus();});var self=this;var store=function(restore){editableMode=false;showHide();var newStatus=$("TEXTAREA",self.statusInput).val();if(newStatus&&newStatus!=""&&!restore){self.statusField.html(newStatus)
self.status=newStatus;$.get(BW.Config.ROOTURI+"mvc/"+self.mode+"/Manage/StatusSave?status="+newStatus,function(data){});}
self.statusField.removeClass("hidden");}
var showHide=function(){$("#editStatus",self.statusEle).toggleClass("hidden");self.statusField.toggleClass("hidden");self.statusInput.toggleClass("hidden");}}
// JS/UI.js

if(typeof UI!="object")UI={};if(typeof UI.Controls!="object")UI.Controls={};UI.Controls.Validation=function(oFormField){this.oInput=oFormField;this.aRules=new Array();this.aError=new Array();this.isRequired=false;this.isMasked=false;this.sMask=new Object;this.sValidationIdentifier=/\buiFormValidate\w*\b/gi;this.setup();}
UI.Controls.Validation.prototype.setup=function(){var className=this.oInput.dInput.get(0).className;var sResult;while((sResult=this.sValidationIdentifier.exec(className))!=null){this.aRules=$.merge(this.aRules,eval(className.substr(this.sValidationIdentifier.lastIndex)));}
for(var i=0;i<this.aRules.length;i++){switch(this.aRules[i]){case"required":this.isRequired=true;this.sMask.msg="";this.oInput.dom.addClass("required");break;case"mask":this.isMasked=true;this.sMask.type="mask";this.sMask.regexp=new RegExp(this.oInput.dInput.attr("alt").slice(1,-1));this.sMask.msg=this.oInput.dInput.attr("title");break;case"unity":this.unifyWith=this.oInput.dInput.attr("rel");break;default:if(!this.isMasked&&BW.Regexp.hasOwnProperty(this.aRules[i])){this.isMasked=true;this.sMask=BW.Regexp[this.aRules[i]];}
break;}}};UI.Controls.Validation.prototype.validate=function(){this.aError=new Array();if(this.unifyWith&&!this.unity())return false;return(this.require()&&this.mask())?true:false;};UI.Controls.Validation.prototype.require=function(){if(this.isRequired){if(this.oInput.dInput.val()!=""){if(this.oInput.bEmptyValue&&this.oInput.dInput.val()==this.oInput.sDefaultValue){this.aError.push(501);return false;}else{return true;}}else{this.aError.push(501);return false;}}else{return true;}};UI.Controls.Validation.prototype.mask=function(){if(this.isMasked&&this.sMask!=""&&this.oInput.dInput.val()!=""){if(this.sMask.regexp.test(this.oInput.dInput.val())){return true;}else{this.aError.push(502);return false;}}else{return true;}};UI.Controls.Validation.prototype.unity=function(){if(this.unifyWith){if(this.oInput.dInput.val()==$(this.unifyWith,this.oInput.oForm.dom).val())return true;else{this.aError.push(503);return false;}}else{return true;}}
UI.Controls.Validation.prototype.getErrorDescription=function(){var sResult="";for(var i=0;i<this.aError.length;i++){var sMsg=(typeof this.sMask.msg!="undefined")?this.sMask.msg:"";sResult+=BW.Error.get(this.aError[i])+" "+sMsg;}
return sResult;};UI.Controls.Form=function(oEle){this.dom=$(oEle);this.dom.data("control",this);this.bHistory=(this.dom.is(".history"))?true:false;this.beforeSubmit=this.dom.attr("onsubmit");this.sMode="xmlhttp";this.aFields=new Array();this.aControls=new Array();this.ID=this.dom.attr("id");this.sAction=this.dom.attr("action");this.bSubmit=(this.dom.is(".noajax"))?false:true;this.submitMode=(typeof this.dom.attr("target")!="undefined")?this.dom.attr("target"):false;this.dTargetAdd=false;this.dTargetReplace=false;if(typeof this.dom.attr("rel")!="undefined"){this.sEle=this.dom.attr("rel");if(this.sEle.indexOf("ADD")==0){this.dTargetAdd=true;this.sEle=this.sEle.substr(3);}
if(this.dom.hasClass("replaceTarget"))
this.dTarget=$(this.sEle).parent();else
this.dTarget=$(this.sEle);}else{this.dTarget=this.dom;this.dTargetReplace=true;}
this.preventSubmit=this.dom.is(".nosubmit");var oForm=this;$(".uiFormElement",this.dom).each(function(i){var node=$(this);if($('.uiFormField',node).is(".uiInputSlide")){oForm.aFields.push(new UI.Controls.Form.InputSlide(node,oForm));}else if($('.uiFormField',node).is(".uiInputHtml")){oForm.aFields.push(new UI.Controls.Form.InputHtml(node,oForm));}else if($('.uiFormField',node).is(".uiInputCaptcha")){oForm.aFields.push(new UI.Controls.Form.InputCaptcha(node,oForm));}else if($('.uiFormField',node).is(".uiInputDatePicker")){oForm.aFields.push(new UI.Controls.Form.InputDatePicker(node,oForm));}else if($('.uiFormField',node).is(".uiInputTimePicker")){oForm.aFields.push(new UI.Controls.Form.InputTimePicker(node,oForm));}else if($('.uiFormField',node).is(".uiInputFolderPicker")){oForm.aFields.push(new UI.Controls.Form.InputFolderPicker(node,oForm));}else{oForm.aFields.push(new UI.Controls.Form.Input(node,oForm));}});$(".uiFormControl",this.dom).each(function(){oForm.aControls.push(new UI.Controls.Form.Control($(this),oForm));});$(".uiFormGroup",this.dom).each(function(){new UI.Controls.Form.Group($(this),oForm);});$(".uiFormGroupRemove",this.dom).bind("click",{controller:this},function(event){var href=$(this).attr("href");var group=$(this).parent().parent();$.get(href+"&_display=xml",{},function(data){var message=$("message",$(data)).eq(0)
if(message.attr("code")==1){group.remove();}
new UI.Controls.Modal(options={type:"Alert",message:message.text()});});return false;});if(this.bSubmit){this.dom.bind("submit",{controller:this},function(event){return false;});}
this.dom.bind("reset",{controller:this},function(event){return false;});};UI.Controls.Form.prototype.submit=function(bAsync,fCallback){if(this.bChallenge){var form=this;$.getJSON(BW.Config.ROOTURI+"mvc/User/Index/CreateChallenge",null,function(data){form.sChallenge=data.challenge;form.submitData(bAsync,fCallback);})}else{this.submitData(bAsync,fCallback);}}
UI.Controls.Form.prototype.submitData=function(bAsync,fCallback){if(this.validate()){var submittingCls='submitting';function makeAvail4Submit(frm)
{return function()
{frm.removeClass(submittingCls);};}
if(this.dom.hasClass(submittingCls)){return false;}
this.dom.addClass('submitting');setTimeout(makeAvail4Submit(this.dom),2000);if(this.preventSubmit)return true;if(!this.submitMode){for(var i=0;i<this.aFields.length;i++){this.aFields[i].submit();}
if(this.sAction.indexOf("http")<0){this.sAction=BW.Config.ROOTURI+"/"+this.sAction;}
switch(this.sMode){case"iframe":this.sTargetId=UI.Utils.randomString();$(document.body).append('<iframe class="hidden" id="'+this.sTargetId+'" name="'+this.sTargetId+'"></iframe>');this.dom.append('<input type="Hidden" value="iframe" name="_display" />');this.dom.append('<input type="Hidden" value="'+this.ID+'" name="_formid" />');this.dom.attr("target",this.sTargetId);this.dom.get(0).submit();if(typeof bAsync=="undefined")this.oDisabler=new UI.Targets.Disable(this.dTarget,true);this.dom.hide();break;default:var params={_formid:this.ID,_display:"include"};$(".uiFormField",this.dom).each(function(nI){var dInput=$(this);if(dInput.attr("type")=="checkbox"){params[$(this).attr('id')]=(dInput.is(":checked"))?1:0;}else if(dInput.attr("type")=="radio"){if(dInput.is(":checked")){params[$(this).attr('id')]=dInput.val();}}
else{params[dInput.attr('id')]=dInput.val();}
var obj=dInput.data("control");if(typeof obj=="object"&&obj.bClearOnSubmit){if(obj.bEmptyValue)dInput.val(obj.sDefaultValue)
else dInput.val("");}});if(this.bHistory){var sParams="?";for(var param in params){if(param!="_display"){sParams+=param+"="+params[param]+"&";}}
UI.History.add(this.sAction+sParams,this.sEle);}
var form=this;switch(this.dom.attr("method")){case"get":$.get(this.sAction,params,function(data){form.response(data,bAsync,fCallback);});break;default:$.post(this.sAction,params,function(data){form.response(data,bAsync,fCallback);});break;}
if(typeof bAsync=="undefined"&&!this.dTargetAdd)this.oDisabler=new UI.Targets.Disable(this.dTarget);break;}}else{this.dom.submit();}
this.cleanup();}else{new UI.Controls.Modal({type:"Error",message:BW.Error.get(500)});}};UI.Controls.Form.prototype.response=function(data,bAsync,fCallback){if(typeof bAsync!="undefined"){if(bAsync!=true&&bAsync!=false){var dTarget=$(bAsync);if(typeof dTarget!="undefined"){dTarget.html($(".uiMessage",$(data)).text());}}
if(typeof fCallback=="function"){fCallback(data);}
return;}
if(typeof this.oDisabler!="undefined")this.oDisabler.hide();if(this.dom.attr("id")=="NewImage"){this.dTargetAdd=(data.indexOf('<iframe')==-1);}
if(this.dTargetReplace){UI.Targets.replaceWith(data,this.dTarget,this.dTargetAdd);}else{UI.Targets.place(data,this.dTarget,this.dTargetAdd);}
if(this.sMode=="iframe"){}}
UI.Controls.Form.prototype.reset=function(){for(var i=0;i<this.aFields.length;i++){this.aFields[i].reset();}};UI.Controls.Form.prototype.cancel=function(){this.cleanup();};UI.Controls.Form.prototype.cleanup=function(){if(UI.Tooltip&&typeof UI.Tooltip.remove=="function"){UI.Tooltip.remove();}};UI.Controls.Form.prototype.validate=function(){var bResultStatus=true;for(var i=0;i<this.aFields.length;i++){if(!this.aFields[i].dInput.is(".uiDisabled")){if(this.aFields[i].dInput.is(".uiWYSIWYG"))this.aFields[i].oEditor.update();if(!this.aFields[i].validate())bResultStatus=false;}}
return bResultStatus;};UI.Controls.Form.Control=function(dEle,oForm){this.dom=$(dEle);this.oForm=(typeof oForm=="object")?oForm:false;this.dom.data('form',this.oForm);this.dom.data('control',this);if($.browser=="msie"&&$.browser.version>6.0){}else{if(typeof BW!="undefined"&&BW.Config.tooltips&&(this.dom.is(".tooltip")))
UI.Tooltip.bind(this.dom);}
switch(this.dom.attr("type")){case"submit":if(this.oForm.bSubmit){this.dom.bind("click",{controller:this},function(event){var rel=$(this).attr("rel");return event.data.controller.oForm.submit(rel);});}
break;case"reset":this.dom.bind("click",{controller:this},function(event){return event.data.controller.oForm.reset();});break;case"cancel":this.dom.bind("click",{controller:this},function(event){return event.data.controller.oForm.cancel();});break;}}
UI.Controls.Form.Input=function(dEle,oForm){this.mapObjects(dEle,oForm);this.behaviour();}
UI.Controls.Form.Input.prototype.mapObjects=function(dEle,oForm){this.dom=$(dEle);this.bError=false;this.oForm=(typeof oForm=="object")?oForm:false;this.dContainer=$(".uiFormInput",this.dom);this.dInput=$(".uiFormField",this.dom);if(this.dInput.is(".uiFormFieldChallenge"))this.oForm.bChallenge=true;this.bClearOnSubmit=(this.dInput.is(".clear"))?true:false;if(this.dInput.is("textarea")){}
this.dInput.data('form',this.oForm);this.dInput.data('control',this);this.sValue=this.dInput.val();this.type=this.dInput.attr("type");this.ID=this.dInput.attr("id");this.bEmptyValue=(this.dInput.is(".uiFormValueOnEmpty"))?true:false;this.sDefaultValue=(this.bEmptyValue)?this.dInput.attr("title"):"";if(this.bEmptyValue&&this.dInput.val()=="")
this.dInput.val(this.sDefaultValue);this.oRules=new UI.Controls.Validation(this);if(this.dInput.attr("type")=="file"){this.oForm.sMode="iframe";}};UI.Controls.Form.Input.prototype.behaviour=function(){if(!this.dInput.hasClass("uiReadonly")){this.dInput.bind("focus",{controller:this},function(event){var node=$(this);var type=node.attr("type");if(UI.Tooltip&&type!="checkbox"&&type!="radio")UI.Tooltip.formfield(node);event.data.controller.focus();if(event.data.controller.dInput.val()==event.data.controller.sDefaultValue)event.data.controller.dInput.val("");}).bind("blur",{controller:this},function(event){event.data.controller.blur();if(event.data.controller.dInput.val()=="")event.data.controller.dInput.val(event.data.controller.sDefaultValue);});$(".importRadioBox INPUT[type='radio']",this.dContainer).bind('change',{controller:this},function(event){var value=$("INPUT:radio:checked",$(this).parent()).val();event.data.controller.dInput.val(value);});}};UI.Controls.Form.Input.prototype.focus=function(){this.dom.addClass("focus");};UI.Controls.Form.Input.prototype.blur=function(){this.validate();this.dom.removeClass("focus");};UI.Controls.Form.Input.prototype.reset=function(){if(this.bEmptyValue){this.dInput.val(this.sDefaultValue);}else{this.dInput.val(this.dInput.attr("value"));}
this.removeError();};UI.Controls.Form.Input.prototype.validate=function(bForceError){var bResult=this.oRules.validate();this.removeError();if(!bResult||bForceError){this.addError();}
if(bForceError)bResult=false;return bResult;};UI.Controls.Form.Input.prototype.submit=function(){if(this.oForm.bChallenge&&this.dInput.is(".uiFormFieldChallenge")){var pass=this.dInput.val();this.dInput.val(hex_hmac_md5(hex_md5(pass),this.oForm.sChallenge));}
if(this.dInput.is(".md5")){var val=this.dInput.val();this.dInput.val(hex_md5(val));}};UI.Controls.Form.Input.prototype.addError=function(){this.bError=true;this.dom.addClass("errors");this.dom.append('<span class="uiErrorMessage">'+this.oRules.getErrorDescription()+'</span>');};UI.Controls.Form.Input.prototype.removeError=function(){this.dom.removeClass("errors");$("SPAN.uiErrorMessage",this.dom).remove();};UI.Controls.Form.InputSlide=function(dEle,oForm){this.sInstanceID=UI.Utils.randomString(10);this.mapObjects(dEle,oForm);this.render();}
$.extend(UI.Controls.Form.InputSlide.prototype,UI.Controls.Form.Input.prototype);$.extend(UI.Controls.Form.InputSlide.prototype,{editor:false,validate:function(){return this.update();},render:function(){this.registerTemplates();var pos=this.dInput.position();var width=this.dInput.width();var height=this.dInput.height();if(typeof window.frames['uiWysiwyg'+this.ID]!="undefined")delete window.frames['uiWysiwyg'+this.ID];this.WYSIWYG=$('<iframe src="'+BW.Config.ROOTURI+'mvc/General/Editor/EditSlide" class="uiInputSlide" name="uiWysiwyg'+this.ID+this.sInstanceID+'" id="uiWysiwyg'+this.ID+this.sInstanceID+'" scrolling="No" frameborder="0"></iframe>').appendTo(this.dInput.parent());this.dInput.hide();this.WYSIWYG.css({left:pos.left,top:pos.top,width:width-2,height:height-2});UI.Controls.Form.InputSlide[this.sInstanceID]=this;this.waiting=setInterval('UI.Controls.Form.InputSlide.'+this.sInstanceID+'.bindEditor()',200);},insert:function(data){this.dInput.val(data);if(this.editor&&this.editor.slideRendered)this.editor.render(data);},update:function(){if(this.editor){var content=this.editor.update();if(content){this.dInput.val(content);}
return true;}
return true;},bindEditor:function(){if(window.frames['uiWysiwyg'+this.ID+this.sInstanceID]&&window.frames['uiWysiwyg'+this.ID+this.sInstanceID].WAX&&window.frames['uiWysiwyg'+this.ID+this.sInstanceID].WAX.Editor.Canvas.Workspace){clearInterval(this.waiting);this.editor=window.frames['uiWysiwyg'+this.ID+this.sInstanceID].WAX.Editor.registerCallback(this);if(this.template){this.editor.setTemplate(this.template);this.template=false;}
return true;}
return false;},template:false,registerTemplates:function(){$(".slideTemplate").bind("click",{self:this},function(event){var name=$(this).attr("id");event.data.self.setTemplate(name.substring(4));$(".uiFormControl.next").click();});},setTemplate:function(sTpl){this.template=sTpl;if(this.editor&&typeof this.editor.Canvas!="undefined"&&this.editor.Canvas.Workspace){this.editor.setTemplate(this.template);this.template=false;}}});UI.Controls.Form.InputHtml=function(dEle,oForm){this.mapObjects(dEle,oForm);this.eDocument=null;this.editableHTML=false;this.options={minHeight:200,disabled:false}
this.sInstanceID="Wysiwyg";this.css='<style>*{margin:0;padding:0;}BODY{font-size: 13px; font-family: Arial, Helvetica, sans-serif;}A{color:#006699;}UL,OL{margin-left: 25px;}IMG{margin:2px 6px;}.editableHTML{padding:4px 8px;background:#f4f4f4;}UL UL,UL UL UL{list-style-type:disc;}</style>';this.regExp=($.browser.msie)?/<br class=removeThis>/gi:/<br class="removeThis">/gi;this.render();this.behavior();};$.extend(UI.Controls.Form.InputHtml.prototype,UI.Controls.Form.Input.prototype,{render:function(){var content=this.sValue;var wrapper=$('<div class="uiWEditorContainer"></div>').css("height",this.options.minHeight+"px");var iframe=$("<iframe></iframe>").attr({'id':this.ID+this.sInstanceID,'src':'javascript:void(0);','frameBorder':0,'scrolling':'auto','class':'uiWEditor'}).css({width:'100%'}).data("control",this);this.dInput.hide().after(iframe);editor=document.getElementById(this.ID+this.sInstanceID);$(editor).wrap(wrapper);this.wrapper=$(editor).parent();this.editor=editor.contentWindow;this.editor.document.designMode="on";this.editor.document.open();this.editor.document.write('<html><head>'+this.css+'</head><body>'+content+'</body></html>');this.editor.document.close();if($(this.editor.document.body).height()>this.options.minHeight){this.wrapper.height($(this.editor.document.body).height());}else{this.wrapper.height(this.options.minHeight);}
$(editor).css({height:"100%"});return true;},behavior:function(){var editor=this.editor;var eDocument=editor.document;var self=this;var pasteFunction=function(){if($.browser.msie)var curRange=eDocument.selection.createRange();var pasteForm='<div id="pasteFromWord"><form><fieldset><ol><li class="uiFormElement"><label for="pasteIt">Paste text <small><b>(Ctrl+v)</b></small>:</label> <span class="uiFormInput"><iframe id="pasteIt" src="javascript:void(0);" scrolling="auto" frameBorder="0" style="width:520px; height:100%;border:1px solid #eee;margin-left:8px;"></iframe></span></li>';if(!self.editableHTML)pasteForm+='<li class="uiFormElement"><label for="pasteWithStyles">Paste with styles</label><span class="uiFormInput"><input id="pasteWithStyles" class="uiFormField" type="radio" name="pasteMode" checked="checked" value="pasteWithStyles" /></span></li><li class="uiFormElement"><label for="pasteWithoutStyles">Paste without styles</label><span class="uiFormInput"><input id="pasteWithoutStyles" class="uiFormField" type="radio" name="pasteMode" value="pasteWithoutStyles" /></span></li>';pasteForm+='<li class="uiFormElement"><label for="pasteText">Paste text only</label><span class="uiFormInput"><input id="pasteText" class="uiFormField" type="radio" name="pasteMode" value="pasteText"';if(self.editableHTML)pasteForm+=' checked="checked"';pasteForm+='/></span></li></ol></fieldset><fieldset><ol><li class="uiFormControls"><button class="uiFormControl" type="submit" id="PasteOK"><span>OK</span></button><button class="uiFormControl" id="PasteCancel" type="button"><span>Cancel</span></button></li></ol></fieldset></form></div>';var o={width:540,height:520,close:function(){editor.focus();}}
var pasteDialog=new UI.Window(o);pasteDialog.setContent($(pasteForm));var pasteEditor=document.getElementById("pasteIt");var wrapper=$('<div class="uiWEditorContainer"></div>').css("height","320px");$(pasteEditor).wrap(wrapper);var wrapper=$(pasteEditor).parent();var pasteEditor=pasteEditor.contentWindow;pasteEditor.document.designMode="on";pasteEditor.document.open();pasteEditor.document.write('<html><head>'+self.css+'</head><body></body></html>');pasteEditor.document.close();$("#PasteOK").click(function(){var content=pasteEditor.document.body;if($("#pasteText").attr("checked"))content=$(content).text().replace(/>/g,"&gt;").replace(/</g,"&lt;");else if($("#pasteWithStyles").attr("checked"))content=UIExt.PasteCleanup(content.innerHTML);else content=UIExt.PasteCleanup(content.innerHTML,true);editor.focus();if($.browser.msie)
curRange.pasteHTML(content);else
eDocument.execCommand("inserthtml",false,content);pasteDialog.close();});$("#PasteCancel").click(function(){pasteDialog.close();});}
$(".uiWEditorToolbar .wAction",this.dContainer).each(function(i){var command=$(this).attr("class").replace("wAction ","");var value=null;var func=null;switch(command){case"forecolor":var o=$(this).offset();var options={name:"forecolor",top:o.top,left:o.left}
func=function(){UI.ColorPicker.edit(options,function(color){eDocument.execCommand(command,false,color);editor.focus();});}
break;case"specialchars":var o=$(this).offset();var options={name:"specialchars",top:o.top,left:o.left}
func=function(){UI.CharMap.init(options,function(char){if($.browser.msie)
command="paste";else
command="inserthtml";value=char;eDocument.execCommand(command,false,value);editor.focus();});}
break;case"createlink":func=function(){var o={width:340,height:200,close:function(){editor.focus();}}
if($.browser.msie){var currentRange=eDocument.selection.createRange();var selectedTxt=currentRange.text;}
else
var selectedTxt=editor.getSelection();var linkForm=$('<form class="uiForm"><fieldset><ol><li class="uiFormElement required"><label for="linkURL">URL:</label> <span class="uiFormInput"><input type="text" class="uiFormField uiFormValidate[\'required\',\'url\']" id="linkURL" value="http://" /></span></li><li class="uiFormElement required"><label for="linkTitle">Link Title</label><span class="uiFormInput"><input type="text" class="uiFormField uiFormValidate[\'requiried\',\'alphanum\']" id="linkTitle" value="'+selectedTxt+'" /></span></li><li class="uiFormElement"><label for="linkTarget">Target</label><span class="uiFormInput"><select class="uiFormField" id="linkTarget"><option value="_blank">New Window ( _blank )</option><option value="_top">Actual Window ( _top )</option></select></span></li></ol></fieldset><fieldset><ol><li class="uiFormControls"><button class="uiFormControl" id="LinkOK" type="submit"><span>OK</span></button></li></ol></fieldset></form>');var linkDialog=new UI.Window(o);linkDialog.setContent(linkForm);$("#LinkOK").click(function(){var linkTitle=$("#linkTitle").val();var linkURL=$("#linkURL").val();var target=$("#linkTarget").val();if(linkURL===null||linkURL.search(BW.Regexp.url.regexp)<0||!linkTitle||linkTitle==""||linkTitle.search(BW.Regexp.alphanum.regexp)<0){return;}else{var linkNode='<a href='+linkURL+' target="'+target+'">'+linkTitle+'</a>';editor.focus();if($.browser.msie)
currentRange.pasteHTML(linkNode);else
eDocument.execCommand("inserthtml",false,linkNode);linkDialog.close();}});}
break;case"insertimage":func=function(){if($.browser.msie)var curRange=eDocument.selection.createRange();var imgForm=$('<div id="imgDialog"><form class="uiForm"><fieldset><ol><li class="uiFormElement required"><label for="imgURL">URL:</label> <span class="uiFormInput"><input type="text" class="uiFormField uiFormValidate[\'required\',\'url\']" id="imgURL" value="http://" /></span></li><li class="uiFormElement"><label for="imgAlt">Alternantive text</label> <span class="uiFormInput"><input type="text" class="uiFormField uiFormValidate[\'alphanum\']" id="imgAlt" value="" /></span></li><li class="uiFormElement"><label for="imgAlignment">Alignment</label> <span class="uiFormInput"><select class="uiFormField" id="imgAlignment"><option value="">No alignment</option><option value="left">Left</option><option value="right">Right</option></select></span></li></ol></fieldset><fieldset><ol><li class="uiFormControls"><button class="uiFormControl" id="imgBrowse" type="button"><span>Data Manager</span></button><button class="uiFormControl" type="submit" id="ImgOK"><span>OK</span></button></li></ol></fieldset></form><div class="viewBrowser targetList"></div></div>');var o={width:460,height:240,close:function(){editor.focus();}}
var imageDialog=new UI.Window(o);imageDialog.setContent(imgForm);var dialog=$("#imgDialog");$("#ImgOK").click(function(){var imgURL=$("#imgURL").val();var align=$("#imgAlignment").val();var alt=$("#imgAlt").val();if(imgURL===null||imgURL.search(BW.Regexp.url.regexp)<0){return;}else{var img='<img src='+imgURL+' align="'+align+'" alt="'+alt+'" />';editor.focus();if($.browser.msie)
curRange.pasteHTML(img);else
eDocument.execCommand("inserthtml",false,img);imageDialog.close();}});$("#imgBrowse").click(function(){$.get(BW.Config.ROOTURI+"mvc/Object/Manage/Index?mode=up&act=browse&types=[ObjectFolder,ObjectCategory,ObjectImage]&_display=include",function(data){$("FORM",dialog).hide();dialog.parent().parent().width("620px").height("500px");$(".viewBrowser",dialog).html(data)});UI.Select.selected.select=function(data){$(".viewBrowser",dialog).html("");dialog.parent().parent().width("460px").height("240px");$("FORM",dialog).show();$("#imgURL",dialog).val(BW.Config.ROOTURI+"oes/"+data);}});}
break;case"fontsize":$(this).change(function(){value=$(this).val();eDocument.execCommand(command,false,value);editor.focus();$(this).val("default");});return;break;case"fontname":$(this).change(function(){value=$(this).val();eDocument.execCommand(command,false,value);editor.focus();$(this).val("default");});return;break;case"editHTML":func=function(){if(!self.editableHTML){self.editableHTML=true;eDocument.body.className="editableHTML";var originalHtml=eDocument.body.innerHTML;var html=originalHtml;eDocument.body.innerHTML=html.replace(/>/g,"&gt;").replace(/</g,'<br class="removeThis">&lt;').replace(/<br class="removeThis">/i,"");self.wrapper.parent().append('<div class="htmlControls uiFormControls"><button class="uiButton storeHTML">OK</button><button class="uiButton restoreHTML">Storno</button></div>');var setHtmlMode=function(ele){self.editableHTML=false;eDocument.body.className="";$(ele).parent().remove();}
$(".storeHTML",self.wrapper.parent()).click(function(){setHtmlMode(this);var newHtml=eDocument.body.innerHTML;eDocument.body.innerHTML=newHtml.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(self.regExp,"");self.adaptHeight();});$(".restoreHTML",self.wrapper.parent()).click(function(){setHtmlMode(this);eDocument.body.innerHTML=originalHtml;});}}
break;case"pasteWord":func=pasteFunction;break;}
$(this).click(function(event){event.preventDefault();event.stopPropagation();if(func!==null&&typeof func=="function")
func();else
eDocument.execCommand(command,false,value);editor.focus();return false;});});$(eDocument).keydown(function(event){if((event.keyCode==13||event.keyCode==8||event.keyCode==46)&&($(this.body).height()>=self.options.minHeight)&&(!self.editableHTML)){self.adaptHeight();}
if(event.keyCode==17){self.ctrl=true;}
if(event.keyCode==86&&self.ctrl){event.preventDefault();self.dInput.focus();pasteFunction();self.ctrl=false;}});$(eDocument).keyup(function(event){if(event.keyCode==86);self.ctrl=false;});},showBlogPreview:function(ele){var Subject=$("#Subject").val();var Abstract=this.getContent(document.getElementById("AbstractWysiwyg").contentWindow.document.body);var Body=this.getContent(document.getElementById("BodyBlogWysiwyg").contentWindow.document.body);var output=$('<div class="uiBlog"><ul><li><div class="blogPost blogDetail" style="margin:10px!important"><h4><span>'+Subject+'</span></h4><div class="blogText"><p>'+UIExt.PasteCleanup(Abstract)+'</p><p>'+UIExt.PasteCleanup(Body)+'</p></div></div></li></ul></div>');var oWindow=new UI.Window({width:618,title:Subject,modal:true,resizable:false,content:output});return false;},adaptHeight:function(){$(this.wrapper).height($(this.editor.document.body).height());},getContent:function(bodyEle){if(bodyEle.className=="editableHTML")
return getXHTML(bodyEle.innerHTML.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(this.regExp,""));else
return getXHTML(bodyEle.innerHTML)},validate:function(){return this.update();},update:function(){var content=this.getContent(this.editor.document.body);if(typeof content=="undefined"||content==""){this.addError();return false;}else{this.removeError();var outputHTML=getXHTML(content);this.dInput.val(UIExt.PasteCleanup(outputHTML));return true;}}});UI.Controls.Form.InputCaptcha=function(dEle,oForm){this.mapObjects(dEle,oForm);this.behaviour();this.dCaptcha=$(".uiCaptchaImage",this.dContainer);var captchaInput=this;$(".icRefresh",this.dContainer.parent()).click(function(){$(".uiCaptchaImage",$(this).parent().parent()).attr("src",BW.Config.ROOTURI+"mvc/General/Captcha/Create?"+UI.Utils.randomString(5));captchaInput.dInput.val('').focus();captchaInput.dInput.valid=false;});captchaInput.dInput.keyup(function(){if(captchaInput.dInput.val().length>=4)
captchaInput.checkCaptcha();});};$.extend(UI.Controls.Form.InputCaptcha.prototype,UI.Controls.Form.Input.prototype);UI.Controls.Form.InputCaptcha.prototype.validate=function(param)
{if(this.valid)return true;else return UI.Controls.Form.Input.prototype.validate.call(this,[param]);};UI.Controls.Form.InputCaptcha.prototype.checkCaptcha=function()
{var captcha=this;$.get(BW.Config.ROOTURI+"mvc/General/Captcha/Validate",{code:this.dInput.val(),prefix:""},function(data)
{if(data=="TRUE"){captcha.removeError();captcha.valid=true;captcha.validate();}else{captcha.valid=false;captcha.validate(true);}});};UI.Controls.Form.InputCaptcha.prototype.blur=function(){if(!this.validate)
this.checkCaptcha();this.dom.removeClass("focus");};UI.Controls.Form.InputTimePicker=function(dEle,oForm){this.mapObjects(dEle,oForm);this.behaviour();this.bindMethodsToObj("hideIfClickOutside","selectHours","selectMinutes");this.build();this.time=this.dInput.val().split(":");};$.extend(UI.Controls.Form.InputTimePicker.prototype,UI.Controls.Form.Input.prototype,{behaviour:function(){this.dInput.bind("focus",{controller:this},function(event){event.data.controller.focus();if(event.data.controller.dInput.val()==event.data.controller.sDefaultValue)event.data.controller.dInput.val("");}).bind("blur",{controller:this},function(event){event.data.controller.blur(true);if(event.data.controller.dInput.val()=="")event.data.controller.dInput.val(event.data.controller.sDefaultValue);});},build:function(){this.timeSelector=this.rootLayers=$('<div class="uiTimePicker"></div>').css({display:"none",position:"absolute",zIndex:1000}).append($('<table><tr><th colspan="4">'+BW.Locale.get("Hours")+'</th><th class="colon" rowspan="7">:</th><th colspan="4">'+BW.Locale.get("Minutes")+'</th></tr><tr><td><a href="#">00</a></td><td><a href="#">06</a></td><td><a href="#">12</a></td><td><a href="#">18</a></td><td><a href="#" class="mins">00</a></td><td><a href="#" class="mins">30</a></td></tr><tr><td><a href="#">01</a></td><td><a href="#">07</a></td><td><a href="#">13</a></td><td><a href="#">19</a></td><td><a href="#" class="mins">05</a></td><td><a href="#" class="mins">35</a></td></tr><tr><td><a href="#">02</a></td><td><a href="#">08</a></td><td><a href="#">14</a></td><td><a href="#">20</a></td><td><a href="#" class="mins">10</a></td><td><a href="#" class="mins">40</a></td></tr><tr><td><a href="#">03</a></td><td><a href="#">09</a></td><td><a href="#">15</a></td><td><a href="#">21</a></td><td><a href="#" class="mins">15</a></td><td><a href="#" class="mins">45</a></td></tr><tr><td><a href="#">04</a></td><td><a href="#">10</a></td><td><a href="#">16</a></td><td><a href="#">22</a></td><td><a href="#" class="mins">20</a></td><td><a href="#" class="mins">50</a></td></tr><tr><td><a href="#">05</a></td><td><a href="#">11</a></td><td><a href="#">17</a></td><td><a href="#">23</a></td><td><a href="#" class="mins">25</a></td><td><a href="#" class="mins">55</a></td></tr></table>')).appendTo(this.dContainer);$("TD A",this.rootLayers).bind("click",{self:this},function(event){var field=$(this);if(field.is(".mins")){event.data.self.selectMinutes(field.text());}else{event.data.self.selectHours(field.text());}
return false;});if($.browser.msie&&$.browser.version<7){this.ieframe=$('<iframe class="uiDatePicker_ieframe" frameborder="0" src="#"></iframe>').css({position:"absolute",display:"none",zIndex:999}).insertBefore(this.timeSelector);this.rootLayers=this.rootLayers.add(this.ieframe);};},selectHours:function(hour){this.time[0]=hour;this.update();},selectMinutes:function(min){this.time[1]=min;this.update();},update:function(){this.dInput.val(this.time.join(":"));},focus:function(){this.dom.addClass("focus");this.rootLayers.css("display","block");this.setPosition();this.dInput.unbind("focus",this.focus);$([window,document.body]).click(this.hideIfClickOutside);},blur:function(bKeepOn){if(!bKeepOn){this.rootLayers.css("display","none");$([window,document.body]).unbind("focus",this.hideIfClickOutside);this.dInput.focus(this.focus);this.dom.removeClass("focus");}
this.validate();},hideIfClickOutside:function(event){if(event.target!=this.dInput[0]&&!this.insideSelector(event)){this.blur();};},setPosition:function(){var offset=this.dInput.offset();this.rootLayers.css({"margin-top":this.dInput.outerHeight()});if(this.ieframe){this.ieframe.css({width:this.timeSelector.outerWidth(),height:this.timeSelector.outerHeight()});};this.offset=this.timeSelector.offset();this.offset.right=this.offset.left+this.timeSelector.outerWidth();this.offset.bottom=this.offset.top+this.timeSelector.outerHeight();},bindToObj:function(fn){var self=this;return function(){return fn.apply(self,arguments)};},bindMethodsToObj:function(){for(var i=0;i<arguments.length;i++){this[arguments[i]]=this.bindToObj(this[arguments[i]]);};},insideSelector:function(event){return event.pageY<this.offset.bottom&&event.pageY>this.offset.top&&event.pageX<this.offset.right&&event.pageX>this.offset.left;}});UI.Controls.Form.InputDatePicker=function(dEle,oForm){this.mapObjects(dEle,oForm);this.behaviour();this.bindMethodsToObj("focus","blur","hideIfClickOutside","selectDate","prevMonth","nextMonth");this.build();this.selectDate();this.blur();};$.extend(UI.Controls.Form.InputDatePicker.prototype,UI.Controls.Form.Input.prototype);$.extend(UI.Controls.Form.InputDatePicker.prototype,{behaviour:function(){this.dInput.bind("focus",{controller:this},function(event){event.data.controller.focus();if(event.data.controller.dInput.val()==event.data.controller.sDefaultValue)event.data.controller.dInput.val("");}).bind("blur",{controller:this},function(event){event.data.controller.blur(true);if(event.data.controller.dInput.val()=="")event.data.controller.dInput.val(event.data.controller.sDefaultValue);});},month_names:["January","February","March","April","May","June","July","August","September","October","November","December"],short_month_names:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],short_day_names:["Su","Mo","Tu","We","Th","Fr","Sa"],start_of_week:1,blur:function(bKeepOn){if(!bKeepOn){this.rootLayers.css("display","none");$([window,document.body]).unbind("focus",this.hideIfClickOutside);this.dInput.focus(this.focus);this.dom.removeClass("focus");}
this.validate();},focus:function(){this.dom.addClass("focus");this.rootLayers.css("display","block");this.setPosition();this.dInput.unbind("focus",this.focus);$([window,document.body]).click(this.hideIfClickOutside);},build:function(){this.monthNameSpan=$('<div class="uiDateMonthName"></div>');var monthNav=$('<p class="uiDateMonthNav"></p>').append($('<a href="javascript:void(0)" class="uiDatePrev">&laquo;</a>')).append(this.monthNameSpan).append($('<a href="javascript:void(0)" class="uiDateNext">&raquo;</a>'));var tableShell="<table><thead><tr>";$(this.adjustDays(this.short_day_names)).each(function(){tableShell+="<th>"+this+"</th>";});tableShell+="</tr></thead><tbody></tbody></table>";this.dateSelector=this.rootLayers=$('<div class="uiDatePicker"></div>').css({display:"none",position:"absolute",zIndex:1000}).append(monthNav,tableShell).appendTo(this.dContainer);if($.browser.msie&&$.browser.version<7){this.ieframe=$('<iframe class="uiDatePicker_ieframe" frameborder="0" src="#"></iframe>').css({position:"absolute",display:"none",zIndex:999}).insertBefore(this.dateSelector);this.rootLayers=this.rootLayers.add(this.ieframe);};$(".uiDatePrev",this.dateSelector).bind("click",{self:this},function(event){event.data.self.prevMonth();});$(".uiDateNext",this.dateSelector).bind("click",{self:this},function(event){event.data.self.nextMonth();});this.tbody=$("tbody",this.dateSelector);this.dInput.change(this.bindToObj(function(){this.selectDate();}));},selectMonth:function(date){this.currentMonth=date;var rangeStart=this.rangeStart(date),rangeEnd=this.rangeEnd(date);var numDays=this.daysBetween(rangeStart,rangeEnd);var dayCells="";for(var i=0;i<=numDays;i++){var currentDay=new Date(rangeStart.getFullYear(),rangeStart.getMonth(),rangeStart.getDate()+i);if(this.isFirstDayOfWeek(currentDay))dayCells+="<tr>";if(currentDay.getMonth()==date.getMonth()){dayCells+='<td date="'+this.dateToString(currentDay)+'"><a href="#">'+currentDay.getDate()+'</a></td>';}else{dayCells+='<td class="uiDateUnselectedMonth" date="'+this.dateToString(currentDay)+'">'+currentDay.getDate()+'</td>';};if(this.isLastDayOfWeek(currentDay))dayCells+="</tr>";};this.monthNameSpan.empty().append(this.monthName(date)+" "+date.getFullYear());this.tbody.empty().append(dayCells);$("a",this.tbody).click(this.bindToObj(function(event){this.selectDate(this.stringToDate($(event.target).parent().attr("date")));this.blur();return false;}));$("td[date="+this.dateToString(new Date())+"]",this.tbody).addClass("uiDateToday");},selectDate:function(date){if(typeof(date)=="undefined"){date=this.stringToDate(this.dInput.val());};if(date){this.selectedDate=date;this.selectMonth(date);var stringDate=this.dateToString(date);$('td[date='+stringDate+']',this.tbody).addClass("uiDateSelected");if(this.dInput.val()!=stringDate){this.dInput.val(stringDate).change();};}else{this.selectMonth(new Date());};},hideIfClickOutside:function(event){if(event.target!=this.dInput[0]&&!this.insideSelector(event)){this.blur();};},stringToDate:function(string){var matches;if(matches=string.match(/^(\d{4,4})-(\d{2,2})-(\d{2,2})$/)){return new Date(matches[1],matches[2]-1,matches[3]);}else{return null;};},dateToString:function(date){var month=(date.getMonth()+1).toString();var dom=date.getDate().toString();if(month.length==1)month="0"+month;if(dom.length==1)dom="0"+dom;return date.getFullYear()+"-"+month+"-"+dom;},setPosition:function(){var offset=this.dInput.offset();this.rootLayers.css({"margin-top":this.dInput.outerHeight()});if(this.ieframe){this.ieframe.css({width:this.dateSelector.outerWidth(),height:this.dateSelector.outerHeight()});};this.offset=this.dateSelector.offset();this.offset.right=this.offset.left+this.dateSelector.outerWidth();this.offset.bottom=this.offset.top+this.dateSelector.outerHeight();},moveMonthBy:function(amount){this.selectMonth(new Date(this.currentMonth.setMonth(this.currentMonth.getMonth()+amount)));},prevMonth:function(){this.moveMonthBy(-1);return false;},nextMonth:function(){this.moveMonthBy(1);return false;},monthName:function(date){return BW.Locale.get(this.month_names[date.getMonth()]);},insideSelector:function(event){return event.pageY<this.offset.bottom&&event.pageY>this.offset.top&&event.pageX<this.offset.right&&event.pageX>this.offset.left;},bindToObj:function(fn){var self=this;return function(){return fn.apply(self,arguments)};},bindMethodsToObj:function(){for(var i=0;i<arguments.length;i++){this[arguments[i]]=this.bindToObj(this[arguments[i]]);};},indexFor:function(array,value){for(var i=0;i<array.length;i++){if(value==array[i])return i;};},monthNum:function(month_name){return this.indexFor(this.month_names,month_name);},shortMonthNum:function(month_name){return this.indexFor(this.short_month_names,month_name);},shortDayNum:function(day_name){return this.indexFor(this.short_day_names,day_name);},daysBetween:function(start,end){start=Date.UTC(start.getFullYear(),start.getMonth(),start.getDate());end=Date.UTC(end.getFullYear(),end.getMonth(),end.getDate());return(end-start)/86400000;},changeDayTo:function(to,date,direction){var difference=direction*(Math.abs(date.getDay()-to-(direction*7))%7);return new Date(date.getFullYear(),date.getMonth(),date.getDate()+difference);},rangeStart:function(date){return this.changeDayTo(this.start_of_week,new Date(date.getFullYear(),date.getMonth()),-1);},rangeEnd:function(date){return this.changeDayTo((this.start_of_week-1)%7,new Date(date.getFullYear(),date.getMonth()+1,0),1);},isFirstDayOfWeek:function(date){return date.getDay()==this.start_of_week;},isLastDayOfWeek:function(date){return date.getDay()==(this.start_of_week-1)%7;},adjustDays:function(days){var newDays=[];for(var i=0;i<days.length;i++){newDays[i]=days[(i+this.start_of_week)%7];};return newDays;}});UI.Controls.Form.InputFolderPicker=function(dEle,oForm){$(".alreadyAtBottom").remove();this.dFolderTree=$(".uiFolderTree").treeview({persist:'cookie',url:'/mvc/Object/Index/GetChildFolders?_display=json'});this.mapObjects(dEle,oForm);this.behaviour();this.bindMethodsToObj("focus","blur","hideIfClickOutside");this.blur();};$.extend(UI.Controls.Form.InputFolderPicker.prototype,UI.Controls.Form.Input.prototype);$.extend(UI.Controls.Form.InputFolderPicker.prototype,{behaviour:function(){this.dInput.bind("focus",{controller:this},function(event){event.data.controller.focus();if(event.data.controller.dInput.val()==event.data.controller.sDefaultValue)event.data.controller.dInput.val("");}).bind("blur",{controller:this},function(event){event.data.controller.blur(true);if(event.data.controller.dInput.val()=="")event.data.controller.dInput.val(event.data.controller.sDefaultValue);});},bindToObj:function(fn){var self=this;return function(){return fn.apply(self,arguments)};},bindMethodsToObj:function(){for(var i=0;i<arguments.length;i++){this[arguments[i]]=this.bindToObj(this[arguments[i]]);};},hideIfClickOutside:function(event){if(event.target!=this.dInput[0]&&$(event.target).parents(".uiFolderTree").length==0){this.blur();};},insideSelector:function(event){return event.pageY<this.offset.bottom&&event.pageY>this.offset.top&&event.pageX<this.offset.right&&event.pageX>this.offset.left;},blur:function(bKeepOn){if(!bKeepOn){$([window,document.body]).unbind("click",this.hideIfClickOutside);this.dInput.focus(this.focus);this.dom.removeClass("focus");this.dFolderTree.slideUp();}
this.validate();},focus:function(){var offset=this.dInput.offset();this.dFolderTree.css({position:"absolute",left:offset.left,top:(offset.top+this.dInput.outerHeight()),width:this.dInput.outerWidth()}).show().appendTo(document.body).addClass("alreadyAtBottom");this.offset=this.dFolderTree.offset();this.dom.addClass("focus");if(this.dInput.$events&&this.dInput.$events['focus'])this.dInput.unbind("focus",this.focus);$([window,document.body]).click(this.hideIfClickOutside);}});$(".selectable").live("click",function(){$("#folderPath").val($(this).attr("path"));$(".selectable").removeClass("selected");$(this).addClass("selected");$("option[value="+$(this).attr("value")+"]",$("#folder")).attr("selected","selected");});UI.Controls.Form.Group=function(dGroup,oForm,oOptions){this.dom=dGroup;this.oForm=oForm;this.sID=this.dom.attr("id");this.dAdd=$(".uiFormGroupAdd[rel='"+this.sID+"']",this.oForm.dom);this.aItems=new Array();this.nItemCount=$("#rightsmanager_maxid",oForm).val();this.options={target:"after",copyvalues:false};jQuery.extend(this.options,oOptions);if(typeof this.dom.attr("rel")!="undefined")this.options.target=this.dom.attr("rel");if(this.options.target!="after"||this.options.target!="before"){this.dTarget=$(this.options.target);}
switch(this.options.target){case"before":this.dItems=(this.dom.is("tbody"))?this.dom.insertBefore(this.dom):$('<span class="uiFormGroupItems"></span>').insertBefore(this.dom);break;case"after":this.dItems=(this.dom.is("tbody"))?this.dom.parent():$('<span class="uiFormGroupItems"></span>').insertAfter(this.dom);break;default:this.dItems=(this.dom.is("tbody"))?this.dom.appendTo(this.dTarget):$('<span class="uiFormGroupItems"></span>').appendTo(this.dTarget);break;}
this.dAdd.bind("click",{controller:this},function(event){event.data.controller.Add();});}
UI.Controls.Form.Group.prototype.Add=function(){var dNewItem=this.dom.clone(true).appendTo(this.dItems);dNewItem.removeClass("hidden");this.aItems.push(dNewItem);var nItemCount=parseInt($("#rightsmanager_maxid",this.oForm).val())+1;$("#rightsmanager_maxid",this.oForm).val(nItemCount);var oGroup=this;$(".uiFormField",dNewItem).each(function(){var dField=$(this);dField.attr("id",dField.attr("id")+"_"+nItemCount);dField.attr("name",dField.attr("name")+"_"+nItemCount);if(!oGroup.options.copyvalue){dField.not("select").val('');}});$(".uiFormElement",dNewItem).each(function(){oGroup.oForm.aFields.push(new UI.Controls.Form.Input($(this),oGroup.oForm));});$(".uiFormGroupRemove",dNewItem).bind("click",{controller:this},function(event){event.data.controller.Remove(dNewItem);});};UI.Controls.Form.Group.prototype.Remove=function(dItem){dItem.remove();}
// JS/UI.forms.js

if(typeof UI!="object")UI={};if(typeof UI.Controls!="object")UI.Controls={};UI.History={root:BW.Config.ROOTURI,additional:new Array(),init:function(){this.inLocation=location.href;this.currentLocation=location.href;this.parseURI();this.crossroad();this.timer();},parseURI:function(){if(this.inLocation.indexOf("#")>-1){this.requestAjax=this.inLocation.split("#")[1];this.inLocation=this.inLocation.split("#")[0];}else{this.requestAjax=false;}
this.request=this.inLocation.substr(this.root.length);if(this.request==""||this.request=="/")this.request=false;},parseHistory:function(uri){return uri.split("#")[1];},crossroad:function(){if(this.request){this.redirect();}else if(this.requestAjax){this.sync();}},redirect:function(){location.replace(this.root+"#"+this.request);},sync:function(){},timer:function(){this.interval=setInterval(UI.History.watch,500);},watch:function(){if(UI.History.currentLocation==location.href)return;else{UI.History.currentLocation=location.href;if(UI.History.userTriggered){UI.History.userTriggered=false;}else{UI.History.currentLocation=location.href;var history=UI.History.find(UI.History.parseHistory(location.href),true);if(history){var sUri=(history.path)?UI.History.root+history.path:UI.History.root;if(sUri==BW.Config.ROOTURI)sUri+='mvc/User/Public/MyPage';var uri=sUri+(sUri.indexOf("?")<0?"?":"&")+"_display=include";UI.History.additional=history.additional;$(history.rel).load(uri,{},function(){UI.Targets.RDF.check(sUri);});}}}},userTriggered:false,history:[],currentPosition:0,add:function(path,rel){path=(path.indexOf("http://")>-1)?path.substr(UI.History.root.length):path;path=path.replace(/\?_display=include/,"").replace(/\&_display=include/,"").replace(/\?tabs=false/,"").replace(/\&tabs=false/,"");this.userTriggered=true;location.href="#"+path;this.history.unshift({path:path,rel:rel,time:new Date(),additional:new Array()});this.currentPosition=0;},addAdditional:function(path,rel){if(UI.History.history.length>0){UI.History.history[0].additional.push({path:path,rel:rel});}},find:function(path,bRemove){for(var i=0;i<UI.History.history.length;i++){if(UI.History.history[i].path==path){UI.History.currentPosition=i;var step=UI.History.history[i];if(bRemove){UI.History.history.splice(i,1);}
return step;}}
return{path:path,rel:$(".uiWebMain")};}}
UI.Categories={rootCategory:102,baseCategories:"10000, 10033, 10111, 10147, 10177, 10252, 10325, 10402, 10480, 10557",searched:[],parents:[],init:function(mode){$("#Categories").val(this.searched+",");$.ajax({type:"GET",url:BW.Config.ROOTURI+"mvc/Object/Browse?parent="+this.rootCategory+"&navigator=false&_display=include",success:function(data){$("#newCategoriesWrapper").html(data.replace('class="childUL"','id="newCategories"'));$("#newCategories input").remove();if(mode=="metadata")
UI.Categories.unicateParents();}});},unicateParents:function(){var uParents="";var temp=[];for(var i=0;i<this.parents.length;i++){temp=this.parents[i].split(",");for(var j=1;j<temp.length;j++){if(uParents.indexOf(temp[j])==-1)
uParents+=temp[j]+",";}}
var parents=uParents.split(",");parents.pop();parents.sort();this.showCategories(parents);},showCategories:function(parents){var rootEle=$("li[rel="+parents[0]+"]",$("#newCategories"));if(rootEle.next().hasClass("childUL")==false){var path=BW.Config.ROOTURI+"mvc/Object/Browse?parent="+parents[0]+"&navigator=false&_display=include";$.get(path,function(data){rootEle.after(data);$(".eIcon",rootEle).addClass("collapsed");parents.shift();if(parents.length>0)
UI.Categories.showCategories(parents);else
UI.Categories.checkInputs();});}},checkInputs:function(){for(var i=0;i<this.searched.length;i++){$("input[value="+this.searched[i]+"]").attr("checked","checked");}},liveInit:function(liEle){if(liEle.attr("parent")=="true"){$(".expander",liEle).click(function(){var href=$(this).parent().attr("href");var aCat=$(this).parent().attr("rel");var actual=$(this).parent();if(actual.next().attr("class")!="childUL"){$.ajax({type:"GET",url:href+"&navigator=false&_display=include",success:function(msg){if(UI.Categories.baseCategories.indexOf(aCat)!=-1){$("#newCategories .childUL").remove();$(".eIcon").removeClass("collapsed");$("#Categories").val("");}
actual.after(msg);$(".eIcon",actual).addClass("collapsed");}});}else if(actual.next().attr("class")=="childUL"&&actual.next().css("display")=="block"){actual.next().slideUp();$(".eIcon",actual).removeClass("collapsed");}else if(actual.next().attr("class")=="childUL"&&actual.next().css("display")=="none"){actual.next().slideDown();$(".eIcon",actual).addClass("collapsed");}});}
$(":checkbox",liEle).click(function(){var value=$(this).val();if($("#Categories").val().indexOf(value)==-1||$("#Categories").val()==""){var n=$("input:checked","#newCategories").length;if(n>3){$(this).attr("checked","");new UI.Controls.Modal(options={type:"Message",message:BW.Locale.get("You can check max. 3 categories.")});}
else{$("#Categories").val($("#Categories").val()+value+",");}}else if($("#Categories").val().indexOf(value)!=-1){var new_val=$("#Categories").val().replace(value+",","");$("#Categories").val(new_val);}});}}
UI.Navigator={aMenus:[],aMenuActive:null,init:function(soEle){this.oContainer=$(soEle);this.oMain=$(".uiNavigatorMain",this.oContainer);this.oSlider=$(".uiNavigatorSlider",this.oContainer);this.oScroller=$(".uiScroller",this.oContainer);this.oBackButton=$(".uiNavigatorSlideBack",this.oContainer);this.oActions=$('.uiNavigatorActions',this.oContainer);this.oMenus=$(".uiMenuList",this.oSlider);this.iPosition=0;this.iMenuWidth=290;this.iMenuHeight=this.oMain.height();this.mainMinimized=false;this.behaviour(this.oMain);this.oBackButton.click(function(){UI.Navigator.prev();});for(var i=0;i<this.oMenus.length;i++){this.registerMenu(this.oMenus.eq(i));}},behaviour:function(scope){$("A",scope).click(function(){var node=$(this);if(node.is(".uiTarget"))return false;if(node.is(".children"))UI.Navigator.next(node);UI.Navigator.getCurrent(node);UI.Navigator.load(node);return false;});},scroll:function(sDirection,oEle){var menu=this.aMenus[oEle.attr("id")];if(sDirection=="up"){menu.scroll=menu.scroll-31;}else if(sDirection=="down"){menu.scroll=menu.scroll+31;}
if(menu.scroll>15){menu.scroll=15;}else if(menu.scroll<(15-(menu.length-9)*31)){menu.scroll=(15-(menu.length-9)*31);}
menu.dom.stop().css({top:menu.scroll});},next:function(oEle){var menuid=oEle.parent().parent().parent().attr("id");if(menuid==this.aMenuActive)return;if(menuid=="MainCategoryMenu"){this.maxMain();}else if(menuid!="MainCategoryMenu"&&!this.mainMinimized){this.minMain();this.aMenuActive=parseInt(menuid);}
else{this.iPosition=this.iPosition-this.iMenuWidth;this.oScroller.animate({left:this.iPosition});this.aMenuActive=parseInt(menuid);}},prev:function(oEle){if(this.mainMinimized&&this.iPosition==0){this.maxMain();this.aMenuActive=null;}else if(this.iPosition<0){this.iPosition=this.iPosition+this.iMenuWidth;this.oScroller.animate({left:this.iPosition});this.aMenuActive--;}},minMain:function(){this.mainMinimized=true;this.oBackButton.show();this.oMain.animate({width:66});this.oSlider.animate({left:66,width:580});},maxMain:function(){this.mainMinimized=false;this.aMenuActive=null;this.oMain.animate({width:356});this.oSlider.animate({left:356,width:290});this.oBackButton.hide();},registerMenu:function(oMenu){oMenuUL=$("UL",oMenu);oMenu.attr("id",this.aMenus.length);var oItems=$("LI",oMenuUL);this.behaviour(oMenu);this.aMenus.push({dom:oMenuUL,scroll:15,items:oItems,length:oItems.length});var height=oMenuUL.height();if(height>this.iMenuHeight){oMenu.append('<div class="uiScrollUp"></div><div class="uiScrollDown"></div>');oMenuUL.css("top",15);$(".uiScrollDown",oMenu).bind("mousedown",{self:this,target:oMenu},function(event){event.data.self.scroll("up",event.data.target);return false;});$(".uiScrollUp",oMenu).bind("mousedown",{self:this,target:oMenu},function(event){event.data.self.scroll("down",event.data.target);return false;});oMenu.mousewheel(function(event,delta){targ=$(this);if(delta>0)UI.Navigator.scroll("down",targ);else if(delta<0)UI.Navigator.scroll("up",targ);event.stopPropagation();event.preventDefault();return false;});}},getCurrent:function(oEle){if(!oEle.parent().is(".current")){var clicked=oEle.parent();var list=oEle.parent().parent().children();for(var i=0;i<list.length;i++){var node=list.eq(i);if(node.get(0)===clicked.get(0)){node.addClass("current");var menu=this.aMenus[list.parent().attr("id")];if(typeof menu!="undefined"){if(oEle.is(".children"))this.setCurrent(menu,oEle.parent());}}else{node.removeClass("current");}}}},setCurrent:function(oMenu,oItem){clearTimeout(this.loadme);oMenu.current=oItem;},load:function(oEle){var href=oEle.attr("href");if(typeof href!="undefined"){if(oEle.is(".children")){this.drawMenu(href);}else{this.clearLowerMenus();this.resetActions();var newactions=$('<div class="uiMenuActions"><div class="uiContents"></div></div>');this.oActions.append(newactions);$(".uiContents",newactions).load(href+"&navigator=true&_display=include");}}},drawMenu:function(href){this.clearLowerMenus(true);var newmenu=$('<div class="uiMenuList">...Loading...</div>');this.oScroller.append(newmenu);newmenu.load(href+"&navigator=true&_display=include",{},function(){UI.Navigator.registerMenu(newmenu);});},clearLowerMenus:function(bChildren){if(bChildren&&this.aMenuActive==null){this.oScroller.html("").css("left",0);this.aMenus.splice(0,this.aMenus.length);this.resetActions(true);return;}
if(!bChildren&&this.aMenuActive==null)this.maxMain();var offset=(!bChildren)?2:1;for(var i=(parseInt(this.aMenuActive)+offset);i<this.aMenus.length;i++){this.aMenus[i].dom.parent().remove();}
this.aMenus.splice(this.aMenuActive+offset,i);this.resetActions(true);},resetActions:function(howto){this.oActions.children().not(".howto").remove();if(howto)$(".howto",this.oActions).show();else $(".howto",this.oActions).hide();}}
UI.Glossary={init:function(){},languages:'<ul class="languageList"><li><a href="javascript:void(0)">Currently unavailable</a></li></ul>',show:function(ele){this.close();if(typeof ele=="string"){this.sTerm=ele;}else{this.dTrigger=$(ele);var tmpTitle=this.dTrigger.attr("title");if(typeof tmpTitle!="undefined"&&tmpTitle!="")this.sTerm=tmpTitle;else this.sTerm=jQuery.trim(this.dTrigger.text());}
this.loadTerm();},close:function(){$("#uiGlossary").remove();},source:function(sTitle,aDefinition,bAlternatives){var output='<div id="uiGlossary" class="uiModalMedium uiIcon64"><div class="uiModalTop"><h4 class="uiModalTitle">'+sTitle;output+='</h4><a href="#" class="uiModalClose"></a><div class="cleaner"></div><div class="uiContent selected uiIcon48">';for(var i=0;i<aDefinition.length;i++){output+='<div class="text icTerm">'+aDefinition[i]+'</div>';}
output+='</div><ul class="uiHeading"><li class="uiTab active"><span>Glossary</span>';if(bAlternatives){output+='<a href="#" class="actionAlternatives">Show alternatives</a></li>';}
output+='<li class="uiModalLink" id="uiGlossaryWiktionaryLink"><a href="http://'+BW.Config.lang+'.wiktionary.org/wiki/'+this.sTerm+'" target="_blank">wiktionary</a></li>';output+='<li class="uiModalLink" id="uiGlossaryWikiLink"><a href="http://'+BW.Config.lang+'.wikipedia.org/wiki/'+this.sTerm+'" target="_blank">wikipedia</a></li>';output+='<li class="uiModalLink uiLanguages"><a href="javascript:void(0)" class="language">Translate to</a>'+UI.Glossary.languages+'</li>';output+='</ul><br class="cleaner"/></div><div class="uiModalBottom"></div><div class="uiIcon icGlossary"></div></div>';return output;},loaded:function(data){this.glossary=$(data);var definition=new Array();$("definition",this.glossary).each(function(i){definition.push($(this).html());});var bAlternatives=($("term",this.glossary).attr("list")!="full")?true:false;this.glossaryWindow=$(this.source(this.sTerm,definition,bAlternatives)).appendTo($(document.body));this.checkWikipedia();this.checkWiktionary();$(".uiModalClose",this.glossaryWindow).click(function(){UI.Glossary.close();return false;});$(".uiLanguages",this.glossaryWindow).hover(function(){$("ul",$(this)).slideDown();},function(){$("ul",$(this)).slideUp();});this.glossaryWindow.draggable();var left=parseInt(($(document).width()-this.glossaryWindow.width())/2);this.glossaryWindow.css({left:left,top:100});},translation:function(){UI.Glossary.languages='<ul class="languageList uiIcon16">';for(l in google.language.Languages){var lng=l.toLowerCase();if(lng!="unknown"){var lngCode=google.language.Languages[l];if(google.language.isTranslatable(lngCode)){UI.Glossary.languages+='<li><a onclick="UI.Glossary.translate(\''+lngCode+'\')" class="'+lngCode+'Flag">'+lng+'</a></li>';}}}
UI.Glossary.languages+="</ul>";},translate:function(code){UI.Glossary.currentTranslation=code;google.language.translate(this.sTerm,BW.Config.lang,code,UI.Glossary.viewTranslation);},viewTranslation:function(result){$("#uiGlossary .uiContent").append('<div class="text '+UI.Glossary.currentTranslation+'Flag"><em>Translation: </em><strong>'+result.translation+'</strong> <span>(<a href="http://www.google.com/translate_t" target="_blank">by Google</a>)</span></div>');},loadTerm:function(){$.get(BW.Config.ROOTURI+"mvc/Glossary/Index/Index?__display=off&term="+this.sTerm,function(data){UI.Glossary.loaded(data);});},checkWiktionary:function(){$("#uiGlossaryWiktionaryLink").show();},checkWikipedia:function(){$("#wikipediaChecker").remove();var url='http://en.wikipedia.org/w/api.php?action=opensearch&search='+this.sTerm+'&format=json&callback=UI.Glossary.setWikipedia';var elem=document.createElement('script');elem.setAttribute('src',url);elem.setAttribute('id','wikipediaChecker');elem.setAttribute('type','text/javascript');document.getElementsByTagName('head')[0].appendChild(elem);return false;},setWikipedia:function(data){if(data[0].toLowerCase()==this.sTerm.toLowerCase())$("#uiGlossaryWikiLink").show();else $("#uiGlossaryWikiLink").hide();},bind:function(node){node.bind("click",function(){UI.Glossary.show(node)}).append('<img src="'+BW.Config.ROOTURI+'Hive/Media/Icons/Default/08/Glossary.png" border=0/>');}}
UI.Tooltip={place:function(node){this.remove();var height=node.outerHeight()+25;if(node.is(".tooltip")||node.is(".uiFormField")){var text=node.attr("title");if(text==""&&!node.is("SELECT")&&!node.is("TEXTAREA"))text=node.text();}else{var text=node.children("SPAN").eq(0).html();}
if(typeof text!="undefined"&&text!=""){var pos=node.offset();var page=$(document.body);var orientation=(pos.top<50)?"top":"bottom";orientation+=((pos.left-page.offset().left)>(page.width()-220))?" right":" left";this.tooltip=$('<div id="uiTooltip" class="uiModalSmall uiTooltip '+orientation+' uiIcon32"><div class="uiModalTop"><div class="uiModalContent">'+text+'</div></div><div class="uiModalBottom"></div><div class="uiModalArrow"></div></div>').appendTo(document.body);height+=(orientation.indexOf("top")==-1)?this.tooltip.height()-25:0;var top=pos.top-height;var left=pos.left-20;if(pos.top<height&&pos.left+230>$("BODY").width()){top=pos.top+height;left=pos.left-200;}
else if(pos.top<height){top=pos.top+height;}
else if(pos.left+230>$("BODY").width()){left=pos.left-200;}
this.tooltip.css({top:top,left:left});$(document).bind("mousedown",UI.Tooltip.remove);}},remove:function(){if(UI.Tooltip.tooltip){UI.Tooltip.tooltip.remove();$(document).unbind("mousedown",UI.Tooltip.remove);}},bind:function(node){node.hover(function(){UI.Tooltip.place(node);},function(){UI.Tooltip.remove();});},formfield:function(node){UI.Tooltip.place(node);node.bind("blur",function(){UI.Tooltip.remove();});}}
UI.Controls.Modal=function(options){if(UI.Controls.Modal.stack.state&&options.type!="Message"){UI.Controls.Modal.stack.wait.push(options);}else{UI.Controls.Modal.current=this;$.extend(this.options,options);this.render();}};UI.Controls.Modal.prototype={options:{type:"Alert",message:"",goto:false,path:false,action:null,trigger:null},render:function(){if(this.options.type=="Message"){var message=$('<div class="uiModalMessage hidden"><div class="uiModalText">'+this.options.message+'</div><div class="uiIcon icMessage"></div></div>').appendTo("#uiModalGrowl")
message.fadeIn()
message.click(function(){$(this).slideUp(500,function(){$(this).remove();});});var timeout=setTimeout(function(){message.slideUp(500,function(){$(this).remove();});},BW.Config.MESSAGE_TIMEOUT+500);}else{var modal='<div class="uiModalWindow uiIcon128 modal'+this.options.type+'" id="uiModal"><div class="uiDisabler"></div><div class="uiModal"><div class="uiModalMessage">';modal+=this.options.message;if(this.options.type=="File")
modal+=' <input type="text" id="modalFile" class="modalFile" value="" />';modal+='</div><div class="uiControls"><ol><li class="uiFormControls">';modal+=this.renderButtons();modal+='</li></ol></div><div class="uiIcon ic'+this.options.type+'"></div></div></div>';var doc=$(document.body);this.oModal=$(modal).appendTo(doc);this.oModal.css({"height":$(window).height(),"top":$(window).scrollTop()});this.behaviour();$(".uiModal",this.oModal).fadeIn();this.state=true;}},renderButtons:function(type){if(typeof type=="undefined")var type=this.options.type;var buttons="";switch(type){case"Confirm":buttons+='<button type="button" class="uiFormControl orange actionModalConfirm">'+BW.Locale.get("OK")+'</button>';buttons+='<button type="button" class="uiFormControl gray actionModalClose">'+BW.Locale.get("Close")+'</button>';break;case"File":buttons+='<button type="button" class="uiFormControl orange actionModalFileConfirm">'+BW.Locale.get("OK")+'</button>';buttons+='<button type="button" class="uiFormControl gray actionModalClose">'+BW.Locale.get("Close")+'</button>';break;case"Alert":buttons='<button type="button" class="uiFormControl orange actionModalConfirm">'+BW.Locale.get("OK")+'</button>';break;case"OK":buttons='<button type="button" class="uiFormControl orange actionModalClose">'+BW.Locale.get("OK")+'</button>';break;default:break;}
if(type=="Message"||type=="Error"||type=="Warning"){buttons+="<span>("+BW.Locale.get("MessageSmallText")+")</span>";}
return buttons;},behaviour:function(){$(".actionModalConfirm",this.oModal).bind("click",{self:this},function(event){event.data.self.confirm();});$(".actionModalFileConfirm",this.oModal).bind("click",{self:this},function(event){event.data.self.confirmFile();});$(".actionModalClose",this.oModal).bind("click",{self:this},function(event){event.data.self.close();});if(this.options.type=="Message"||this.options.type=="Error"||this.options.type=="Warning"){var oDisabler=$(".uiDisabler",this.oModal);oDisabler.css("background-color","transparent");oDisabler.bind("click",{self:this},function(event){event.data.self.close();});UI.Controls.Modal.stack.timer=setTimeout("UI.Controls.Modal.current.close()",BW.Config.MESSAGE_TIMEOUT);$(".uiModal",this.oModal).bind("mouseover",{self:this},function(event){clearTimeout(UI.Controls.Modal.stack.timer);$(".uiFormControls",event.data.self.oModal).html(event.data.self.renderButtons("OK"));$(this).unbind("mouseover");}).bind("click",{self:this},function(event){event.data.self.close();});}},close:function(){if($("#uiModal"))$("#uiModal").remove();if(UI.Controls.Modal.stack.timer)clearTimeout(UI.Controls.Modal.stack.timer);UI.Controls.Modal.stack.state=false;if(UI.Controls.Modal.stack.wait.length>0){var current=UI.Controls.Modal.stack.wait.shift();this.show(current);UI.Controls.Modal.stack.done.push(current);}},confirm:function(){if(typeof this.options.goto=="object"){UI.Targets.load(this.options.goto.uri,this.options.goto.ele,this.options.trigger);this.close();}else if(typeof this.options.action=='function'){this.close();this.options.action();if(this.options.trigger!=null)this.options.trigger.remove();}else{if(this.options.trigger!=null)this.options.trigger.remove();this.close();}},confirmFile:function(){$.ajax({type:"GET",url:this.options.path,error:function(XMLHttpRequest,textStatus,errorThrown){new window.parent.UI.Controls.Modal(options={type:"Alert",message:textStatus});},success:function(data){var xml=$(data);new window.parent.UI.Controls.Modal(options={type:"Message",message:$("message",xml).text()});}});this.close();}}
UI.Controls.Modal.stack={state:false,wait:[],done:[]}
UI.Controls.PlayerTrigger=function(sID){return $("#PlayerID_"+sID).data('control');}
UI.Controls.Player=function(oEle){this.dPlayer=$(oEle);this.dPlayer.data('control',this);this.dAttachments=false;if(typeof WaxPlayerHtml=="function"){this.startHtmlPlayer();}else{this.startPlayer();}
this.aAttachments=[];this.aSlideHistory=[];}
UI.Controls.Player.prototype={startPlayer:function(){var body=$(".WaxPlayerHtmlContainer",this.dPlayer);var uri=$(".WaxPlayerHtmlPlayButton",body).attr("href").replace(/\?CheckScenarioXml/,'');var rootURI=BW.Config.ROOTURI;var locale=(BW.Config.locale=="en_US"||BW.Config.locale=="cs_CZ")?BW.Config.locale:"en_US";var flashvars={localeChain:locale,resourceModuleURLs:rootURI+"WAXPlayer/locale/"+locale+".swf",waxconfiguri:rootURI+"mvc/General/Index/waxConfig",xmlFile:uri,version:$('#training-version').attr('value'),id:body.attr("id").replace(/WaxPlayer_/i,"")}
if($('#tmpkey').attr('value')){flashvars.tmpkey=$('#tmpkey').attr('value');}
var params={wmode:"opaque",quality:"high",allowfullscreen:"true",allowscriptaccess:"sameDomain"}
var id="waxplayer";var attributes={id:id,name:id};swfobject.embedSWF(body.attr("rel"),body.attr("id"),"100%","100%","10.0.0",false,flashvars,params,attributes);},startHtmlPlayer:function(){new WaxPlayerHtml($(".WaxPlayerHtml",this.dPlayer));},aAttachments:[],addAttachment:function(sTitle,sUri,sType){this.showAttachments();if(this.checkUri(sUri)){if(typeof sType=="undefined")sType=UI.Utils.getObjectTypeFromUri(sUri);else sType=UI.Utils.getObjectTypeFromMime(sType);if(sUri.indexOf("http://")<0)sUri=BW.Config.ROOTURI+"oes/"+sUri;this.dAttachments.append('<li><a target="_blank" href="'+sUri+'" class="uiIcon ic'+sType+'">'+sTitle+'</a></li>');}},showAttachments:function(){if(!this.dAttachments){this.dTabs=$(".uiTabs",this.dPlayer.parent())
this.dTab=$('<div class="uiTab attachmentsTab nonremovable focus"><h3 class="uiTitle icAttachments nohistory">Attachments</h3><div class="uiTrainingAttachments"><ul class="uiIcon16 uiIconLeft"></ul><div class="gfxPaperClip"></div></div></div>').appendTo(this.dTabs);this.dAttachments=$(".uiTrainingAttachments UL",this.dTabs);}else{this.dTabs.data("controller").focusTab(this.dTab.attr("id"));}},checkUri:function(sUri){for(var i=0;i<this.aAttachments.length;i++){if(this.aAttachments[i]==sUri)return false;}
this.aAttachments.push(sUri);return true;},aSlideHistory:[],setActiveSlide:function(sTitle,sUri,nSlideNumber){this.aSlideHistory.push({slidenumber:nSlideNumber,title:sTitle,uri:sUri});}}
UI.Controls.Wizard=function(dEle){this.dom=$(dEle);this.dProgress=$(".uiNavigation li",this.dom);this.count=this.dProgress.length;this.current=1;this.prevButton=$(".uiWizardButtons .previous",this.dom);this.nextButton=$(".uiWizardButtons .next",this.dom)
$(".uiNavigation li a",this.dom).bind("click",{controller:this},function(event){event.data.controller.showStep($(this).attr("title"));$(this).attr("href","javascript:void(0)");this.blur();});this.prevButton.bind("click",{controller:this},function(event){event.data.controller.showPrevious();$(this).attr("href","javascript:void(0)");this.blur();});this.nextButton.bind("click",{controller:this},function(event){event.data.controller.showNext();$(this).attr("href","javascript:void(0)");this.blur();});$(".uiStep:not(.uiStep1)",this.dom).css({height:0,overflow:"hidden"});}
UI.Controls.Wizard.prototype.showStep=function(nStep){if(!this.validatePreviousSteps(nStep)){return false;}
var nStep=parseInt(nStep);if(nStep>0&&nStep<=this.count){$(".uiStep"+this.current,this.dom).css({height:"auto",overflow:"auto"}).hide();$(".uiStep"+nStep,this.dom).css({height:"auto",overflow:"auto"}).show();this.current=nStep;if(this.current>1){this.prevButton.show();}else{this.prevButton.hide();}
if(this.current==this.count){this.nextButton.hide();}else{this.nextButton.show();}
this.setProgress();}}
UI.Controls.Wizard.prototype.showNext=function(){if(this.current==this.count){}else{if(this.current<this.count)this.showStep(this.current+1);}}
UI.Controls.Wizard.prototype.showPrevious=function(){if(this.current>1)this.showStep(this.current-1);}
UI.Controls.Wizard.prototype.setProgress=function(){var nStep=this.current;this.dProgress.each(function(){$(this).removeClass("done").removeClass("lastDone").removeClass("current");if(nStep==$(this).children("A").attr("title")){$(this).addClass("current");}else if(nStep-1==$(this).children("A").attr("title")){$(this).addClass("lastDone");}else if(nStep-1>$(this).children("A").attr("title")){$(this).addClass("done");}});}
UI.Controls.Wizard.prototype.validatePreviousSteps=function(nStep){for(var i=1;i<nStep;i++){if(!this.validateStep(i)){new UI.Controls.Modal({type:"Error",message:BW.Error.get(504)});this.showStep(i);return false;}}
return true;}
UI.Controls.Wizard.prototype.validateStep=function(nStep){var area=$(".uiStep"+nStep,this.dom);var fields=$(".uiFormField",area);var result=true;fields.each(function(i){if(!$(this).data("control").validate())result=false;});return result;}
UI.Controls.Tags=function(oEle){this.dEle=$(oEle);this.dInput=$(".uiFormField",this.dEle);this.dSuggest=$(".uiTagSuggest",this.dEle);this.sMatchUri=this.dEle.attr("rel");this.sCurrentSearch="";this.aData=new Array();this.aUsedTags=new Array();this.oWaiter=false;this.iCurrentSuggestion=0;this.dInput.bind("keydown",{self:this},function(event){if(event.keyCode==13){event.data.self.UseTag(event.data.self.iCurrentSuggestion);event.data.self.oWaiter=setTimeout(function(){event.data.self.dInput.get(0).focus();},20);return false;}else if(event.keyCode==8||event.keyCode==46){event.data.self.ClearTags();event.data.self.Search();}else if(event.keyCode==39){if(event.data.self.iCurrentSuggestion+1<event.data.self.aData.length){$($(".uiTagTip",event.data.self.dSuggest).get(event.data.self.iCurrentSuggestion++)).removeClass("current");$($(".uiTagTip",event.data.self.dSuggest).get(event.data.self.iCurrentSuggestion)).addClass("current");}}else if(event.keyCode==37){if(event.data.self.iCurrentSuggestion-1>-1){$($(".uiTagTip",event.data.self.dSuggest).get(event.data.self.iCurrentSuggestion--)).removeClass("current");$($(".uiTagTip",event.data.self.dSuggest).get(event.data.self.iCurrentSuggestion)).addClass("current");}}});this.dInput.bind("keyup",{self:this},function(event){if(event.keyCode==32){event.data.self.ClearTags();event.data.self.setUsedTags();}
else event.data.self.Search();});}
UI.Controls.Tags.prototype.Search=function(){this.oWaiter=clearTimeout();var sSearchString="";var sValue=this.dInput.val();var iCurrentTag=sValue.lastIndexOf(" ");if(iCurrentTag>1)sSearchString=sValue.substr(iCurrentTag+1);else sSearchString=sValue;if(sSearchString.length>2&&this.sCurrentSearch!=sSearchString){this.sCurrentSearch=sSearchString;if(this.aData.length>2){var j=0;var aFilteredData=new Array();dbg="";for(var i=0;i<this.aData.length;i++){if(this.aData[i].substr(0,sSearchString.length)==sSearchString){aFilteredData[j]=this.aData[i];j++;}else{}}
this.aData=aFilteredData;if(this.aData.length>0)this.DrawTags();else this.ClearTags();}
else{this.SearchOnServer(sSearchString);}}}
UI.Controls.Tags.prototype.SearchOnServer=function(sSearchString){var taghinter=this;$.get(this.sMatchUri,{search:sSearchString},function(data){taghinter.Suggest(data);});}
UI.Controls.Tags.prototype.Suggest=function(sData){if(sData.indexOf("[")==0){this.aData=eval(sData);}else{this.aData=eval("["+sData+"]");}
var aNewData=new Array();for(var i=0;i<this.aData.length;i++){if(this.removeUsed(this.aData[i]))aNewData.push(this.aData[i]);}
this.aData=aNewData;this.DrawTags();}
UI.Controls.Tags.prototype.removeUsed=function(sTxt){for(var i=0;i<this.aUsedTags.length;i++){if(this.aUsedTags[i]==sTxt)return false;}
return true;}
UI.Controls.Tags.prototype.setUsedTags=function(){this.aUsedTags=this.dInput.val().split(" ");}
UI.Controls.Tags.prototype.DrawTags=function(){this.dSuggest.html("");for(var i=0;i<this.aData.length;i++){var className=(i==0)?"uiTagTip current":"uiTagTip";if(typeof this.aData[i]=="string"){var dTag=$('<a class="'+className+'">'+this.aData[i]+'</a>').appendTo(this.dSuggest);}else{var sTag='<a class="'+className+'">'
var iLoopRun=0;for(var item in this.aData[i]){sTag+=this.aData[i][item]+" ";if(iLoopRun==0){this.oItemName=item;sTag+="(";}
iLoopRun++;}
sTag+=')</a>';dTag=$(sTag).appendTo(this.dSuggest);}
dTag.bind("click",{controller:this,index:i},function(event){event.data.controller.UseTag(event.data.index);});}}
UI.Controls.Tags.prototype.UseTag=function(siTag){if(this.aData.length==0)return;var tag=""
if(typeof siTag=="number"){if(typeof this.aData[siTag]=="string"){tag=this.aData[siTag];}else{tag=this.aData[siTag][this.oItemName];}
this.aData.splice(siTag,1);}else{}
var sValue=this.dInput.val();sValue=sValue.substr(0,sValue.lastIndexOf(" "));if(sValue.length>1)sValue+=" ";this.dInput.val(sValue+tag+" ");this.ClearTags();this.setUsedTags();}
UI.Controls.Tags.prototype.ClearTags=function(){this.dSuggest.html(" ");this.sCurrentSearch="";this.iCurrentSuggestion=0;this.aData=new Array();}
UI.Controls.Carousel=function(dEle){this.dom=$(dEle);this.dScroller=$(".uiScroller",this.dom);this.nWidth=$(".uiScroll",this.dom).width()+6;this.nLeft=0;nItemWidth=0;$("LI",this.dScroller).each(function(){var e=$(this);nItemWidth+=parseInt(e.css("marginLeft"))+e.width()+parseInt(e.css("marginRight"));});this.nItemWidth=nItemWidth;$(".previous",this.dom).bind("click",{controller:this},function(event){$(this).attr("href","javascript:void(0)");event.data.controller.moveLeft();});$(".next",this.dom).bind("click",{controller:this},function(event){$(this).attr("href","javascript:void(0)");event.data.controller.moveRight();});}
UI.Controls.Carousel.prototype.moveBy=function(nScroll){var nPosition=this.nLeft+parseInt(nScroll);if(nPosition>0){this.nLeft=0;}else if((this.nItemWidth+nPosition)<0){}else{this.nLeft=nPosition;}
$(this.dScroller).animate({left:this.nLeft},500);}
UI.Controls.Carousel.prototype.moveLeft=function(){this.moveBy(this.nWidth);}
UI.Controls.Carousel.prototype.moveRight=function(){this.moveBy("-"+this.nWidth);}
UI.Controls.Tab={add:function(oEle){this.dTab=oEle;if(this.dTab.parent().data("controller")){this.dTab.parent().data("controller").newTab(this.dTab);}}}
UI.Controls.Tab.Tabs=function(oEle){this.dTabs=$(oEle);this.dTabs.data("controller",this);this.sHeadPosition=(this.dTabs.is(".bottomHead"))?"bottom":"top";this.ID="Tabs_"+UI.Utils.randomString(5);this.dTabs.attr("id",this.ID);this.singleTabMode=$(oEle).hasClass("singleTabs");this.setHead();this.aTabs=new Array();this.aHeads=new Array();this.aIds=new Array();this.iCurrent=0;}
UI.Controls.Tab.Tabs.prototype={newTab:function(oEle){var addTab=true;var oHead=$(".uiTitle",oEle).eq(0);var id=(this.singleTabMode)?oHead.html().replace(/\s+/g,"_"):this.ID+"_"+this.aHeads.length;if(this.singleTabMode&&typeof this.aIds.indexOf=="function"&&this.aIds.indexOf(id)!=-1){if(id=="Edit_Slide"){this.closeTab(id);}else{$(".uiTab:last").remove();this.focusTab(id);addTab=false;}}
if(addTab){this.aTabs.push(oEle);this.addHead(oEle,oHead,id);if(oEle.is(".focus")){this.iCurrent=this.aTabs.length-1;oEle.removeClass("focus");this.focusTab(this.aTabs[this.iCurrent].attr("id"));}}},setHead:function(){this.dTabHeads=$(".uiTabHeads ul",this.dTabs);if(this.dTabHeads.length==0){if(this.sHeadPosition=="bottom"){var dHeadCont=$('<div class="uiTabHeads uiNavigation"><div class="uiTabHeadsBorder"></div><ul></ul>').appendTo(this.dTabs);}else{var dHeadCont=$('<div class="uiTabHeads uiNavigation"><div class="uiTabHeadsBorder"></div><ul></ul>').prependTo(this.dTabs);}
this.bTabHeads=$("ul",dHeadCont);}},addHead:function(oTab,oHead,oId){var sremovable="nonremovable";var sclose="";var sHead=oHead.html();var sClass=oHead.attr("class");var sTabId=oId;oHead.remove();var sLoadUri=(oHead.is("A"))?oHead.attr("href"):null;var bNoHistory=(oHead.is("A:not(.nohistory)"))?false:true;if(sLoadUri!=null){sLoadUri=sLoadUri+(sLoadUri.indexOf("?")<0?"?":"&")+"_display=include&tabs=false";}
if(!$(oTab).is(".nonremovable")){sremovable="";sclose='<a href="javascript:void(0)" class="uiIcon icClose" rel="'+sTabId+'"><span>Close</span></a>'}
var headHTML='<li class="uiIcon16 '+sremovable+'"><a href="javascript:void(0)" class="uiTabHead '+sClass+'" rel="'+sTabId+'"><span>'+sHead+'</span></a>'+sclose+'</li>';oTab.attr("id",sTabId);var oHead=$(headHTML).appendTo(this.bTabHeads);this.aHeads.push(oHead);this.aIds.push(sTabId);var focusIt=$(".uiTabHead",oHead);focusIt.bind("click",{self:this},function(event){var node=$(this);event.data.self.focusTab(node.attr("rel"),sLoadUri,bNoHistory);this.blur();return false;});var closeIt=$(".icClose",oHead);closeIt.bind("click",{self:this},function(event){event.data.self.closeTab($(this).attr("rel"));this.blur();return false;});oTab.data("tabhead",oHead);},focusTab:function(sID,sLoadUri,bNoHistory){for(var i=0;i<this.aTabs.length;i++){if(sID==this.aTabs[i].attr("id")){this.iCurrent=i;this.aTabs[i].show();this.aHeads[i].addClass("current");if(sLoadUri!=null&&!this.aTabs[i].is(".loaded")){UI.Targets.load(sLoadUri,this.aTabs[i],null,bNoHistory)
this.aTabs[i].addClass("loaded");}}else{this.aTabs[i].hide();this.aHeads[i].removeClass("current");}}},closeTab:function(sID){for(var i=0;i<this.aTabs.length;i++){if(sID==this.aTabs[i].attr("id")){this.aTabs[i].remove();this.aHeads[i].remove();this.aTabs.splice(i,i+1);this.aHeads.splice(i,i+1);this.aIds.splice(i,i+1);break;}}
this.iCurrent=0;$("A",this.aHeads[this.iCurrent]).click();}}
UI.Controls.Tree=function(options){this.options={selectable:false,sortable:false}
$.extend(this.options,options);this.init();}
UI.Controls.Tree.prototype={init:function(){this.oContainer=$(this.options.container);this.oBranches=$("li.uiTreeItem",this.oContainer);this.oBranches.each(function(i){var node=$(this);node.children("A").wrap('<div class="uiTreeSort"><div class="uiDraggable"></div></div>');if(node.hasClass("uiTreeFolder")){$(this).prepend('<div class="uiExpander"></div>').append('<div class="uiTreeSort insertAfter"></div>');}});if(this.options.update)this.markNodes();this.behaviour();$("LI LI LI UL.uiTreeNodes",this.oContainer).slideUp();$("LI LI LI",this.oContainer).addClass("collapsed")},behaviour:function(){$(".uiExpander",this.oContainer).bind("click",function(event){var node=$(this).parent();var branch=$("UL.uiTreeNodes",node).eq(0);if(node.hasClass("collapsed")){branch.slideDown();node.removeClass("collapsed");}else{branch.slideUp();node.addClass("collapsed");}});if(this.options.sortable)this.sortable();},sortable:function(){this.oContainer.sortable({items:'.uiTreeItem',hoverClass:'droppablePlaceHere',animated:true,constructor:this,stop:function(ev,ui){ui.options.constructor.update("inserAfter",$(ui.item.prev()[0]).children(0).attr("npath"),$(ui.item).children(0).attr("npath"));ui.options.constructor.markNodes();return false;}});},removeDroppables:function(){},update:function(mode,insertAfter,move){if(typeof insertAfter=="undefined")insertAfter=-1;if(this.options.update){var thisTree=this;$.post(this.options.update+"&_display=include",{mode:mode,insertAfter:insertAfter,move:move},function(data){thisTree.markNodes();new UI.Controls.Modal({type:"Message",message:"Tree Changes were successfully saved."});});}},markNodes:function(oNode,level){if(typeof oNode=="undefined"){oNode=$("ul.uiTreeNodes",this.oContainer).eq(0);level="";}
var nodes=oNode.children("li.uiTreeItem");for(var i=0;i<nodes.length;i++){nodes.eq(i).children(0).attr("npath",level+"/"+i);this.markNodes($("ul.uiTreeNodes",nodes.eq(i)).eq(0),level+"/"+i)}}}
UI.Controls.SelectArea=function(oEle){var dContainer=$(oEle);var img=$("img",dContainer);this.output=$("input",dContainer);var selection=$(".uiCropSelection",dContainer);selection.get(0).controller=this;this.options={width:419,height:313,selX:1,selY:1,selWidth:100,selHeight:100};selection.Resizable({minWidth:1,minHeight:1,maxWidth:this.options.width,maxHeight:this.options.height,minTop:1,minLeft:1,maxRight:this.options.width,maxBottom:this.options.height,dragHandle:true,onDrag:function(x,y)
{this.controller.options.selX=x;this.controller.options.selY=y;this.controller.update();},handlers:{se:'.uiHandleResizeSE',e:'.uiHandleResizeE',ne:'.uiHandleResizeNE',n:'.uiHandleResizeN',nw:'.uiHandleResizeNW',w:'.uiHandleResizeW',sw:'.uiHandleResizeSW',s:'.uiHandleResizeS'},onResize:function(size,position){this.style.backgroundPosition='-'+(position.left-50)+'px -'+(position.top-50)+'px';this.controller.options.selWidth=size.width;this.controller.options.selHeight=size.height;this.controller.update();}});}
UI.Controls.SelectArea.prototype.update=function(){this.output.val(this.options.selX+","+this.options.selY+","+this.options.selWidth+","+this.options.selHeight);}
UI.Controls.ImageFrame={close:function(uri){$(".uiWebMain").load(uri);}}
UI.Controls.Filter=function(oEle){this.oContainer=$(oEle);this.bind();}
UI.Controls.Filter.prototype={aItems:[],iLength:0,bind:function(){this.oItems=$(".uiFilterItem",this.oContainer);this.aItems=new Array();for(var i=0;i<this.oItems.length;i++){var searchString=UI.Utils.toSafeChars($(".uiFilterText",this.oItems[i]).text().toLowerCase(),"diacritics");this.aItems[i]={oItem:this.oItems.eq(i),sString:searchString}}
this.oField=$(".uiFilterField",this.oContainer);this.oField.bind("keyup",{self:this},function(event){event.data.self.filter(this.value)})
this.oClear=$(".uiFilterClear",this.oContainer);this.oClear.bind("click",{self:this},function(event){event.data.self.clear();})
this.iLength=this.aItems.length;},filter:function(sValue){sValue=$.trim(UI.Utils.toSafeChars(sValue.toLowerCase(),"diacritics"));if(sValue=="")return this.clear();this.oClear.addClass("active");for(var i=0;i<this.iLength;i++){if(this.aItems[i].sString.indexOf(sValue)>-1){this.aItems[i].oItem.slideDown();}else{this.aItems[i].oItem.slideUp();}}},clear:function(){this.oItems.slideDown();this.oClear.removeClass("active");this.oField.val("").focus();}}
UI.Comments={newThread:function(form,target,append)
{form.hide();var node=form.eq(form.length-1).clone();if(append)
target.append(node);else
target.prepend(node);node.addClass("someReply").wrap('<li class="uiCommentNode"></li>');$(".body",node).show();node.slideDown();$(".uiCommentsWarning").slideUp();return node;},newReply:function(trigger,action)
{$(".uiCommentsThread .someReply").parent().remove();$(".uiComments .someReply").parent().slideUp().remove();var ele=trigger.parent().parent().parent().parent(".uiCommentNodeMain").siblings("ul");if(ele.html()==null){var ele=trigger.parent().parent().parent().parent(".uiCommentNodeMain").after("<ul></ul>");}
if(action=="abuse"){$.get($(trigger).attr("href")+"&_display=include",function(data){var node=$('<li class="uiCommentNode"><div class="someReply">'+data+'</div></li>');ele.prepend(node);});}
else{var node=this.newThread($(".uiComments .uiForm"),ele);var call=trigger.attr("href");var parent=call.substr(call.indexOf("commentid=")+10);$("#CommentParent",node).val(parent);}},behavior:function()
{$(".uiComments #expandAll").live("click",function(){$(".uiCommentHide").show();});$(".uiComments #collapseAll").live("click",function(){$(".uiCommentBranch .uiCommentHide").hide();});$(".uiCommentBranch .uiCommentArrow").livequery(function(){$(this).addClass("arrowBuried");});$(".uiCommentNode .uiCommentLeft").livequery(function(){var widthNode=$(this).closest(".uiCommentNode").width();var width=widthNode-225
$(this).css("width",width+"px");});$(".uiAddComment #CommentEditor").live("click",function()
{$(this).closest(".uiCommentNodeMain").toggleClass("orangeComment");});$(".uiCommentNode .uiCommentArrow").live("click",function()
{$(this).toggleClass("arrowBuried");$(".uiCommentBody",$(this).parent()).toggle();$(".uiCommentHide",$(this).parent()).toggle();$(this).blur;});$(".uiComments .actionReply").live("click",function()
{UI.Comments.newReply($(this));return false;});$(".uiCommentsThread .actionReportAbuse").live("click",function()
{UI.Comments.newReply($(this),"abuse");return false;});var newThreadStarted=false;$(".uiComments .actionAddThread").live("click",function()
{if(!newThreadStarted){UI.Comments.newThread($(".uiAddComment",$(this).parent()),$(".uiCommentsThread"),true);newThreadStarted=true;}
$(this).hide();return false;});$(".uiCommentsThread .actionCancelComment,.uiCommentsThread .actionClose").live("click",function()
{var ele=$(this).parent().parent().parent().parent().parent().parent().remove();newThreadStarted=false;$(".uiCommentsWarning").slideDown();});$(".uiCommentsThread .actionSubmit").live("click",function()
{$(".actionAddThread").show();newThreadStarted=false;return false;});}};UI.Modal={count:0,get:function(width,height,sTitle){dOverlay=$("#uiOverlayMaster").clone(true).insertAfter($("#uiWebPage"));dOverlay.attr("id","UI_modal_"+this.count++);if(typeof sTitle!='undefined')$(".uiOverlayTitle",dOverlay).html(sTitle);var frame=$(window);var scrolltop=frame.scrollTop();var left=parseInt((frame.width()-width)/2);var top=parseInt((frame.height()-100-32-height-40)/2)+100+32;dOverlay.css({top:top+scrolltop,left:left,height:height,width:width})
$(".top",dOverlay).css({width:width+20});$(".bottom",dOverlay).css({width:width+20});$(".left",dOverlay).css({height:height+20});$(".right",dOverlay).css({height:height+20});dOverlay.draggable({handle:".drag"});dOverlay.click(function(){$(".uiOverlay").css("z-index",9000);$(this).css("z-index",9001);});$(".actionCloseOverlay",dOverlay).bind("click",{trigger:UI.Modal,modal:dOverlay},function(event){event.data.trigger.close(event.data.modal);});return dOverlay;},popup:function(options){if(!options.uri&&options.trigger){options.uri=$(options.trigger).attr("href");}
this.open(options);return false;},open:function(options){var opt={width:500,height:500,title:"Modal Window",content:"content should be inserted here",uri:false,behaviour:function(self,modal){$(".actionCloseOverlay",modal).bind("click",{trigger:self,modal:modal},function(event){event.data.trigger.close(event.data.modal.parent());});}}
$.extend(opt,options);var dModal=this.get(opt.width,opt.height,opt.title);dContent=$(".uiOverlayContent",dModal);dContent.css({height:opt.height-25,width:"100%",overflow:"auto"})
var self=this;if(opt.uri){var href=opt.uri+(opt.uri.indexOf("?")<0?"?":"&")+"_display=include";dContent.load(href,{},function(){opt.behaviour(self,dContent)});}else{dContent.html(opt.content);opt.behaviour(dContent);}
dModal.show();return dModal;},close:function(modal){modal.remove();},wPopup:function(options){var top=parseInt(options.top)+20;var left=parseInt(options.left);var dOverlay=$('<div class="wPopup"><div class="uiOverlayContent"></div></div>');dOverlay.css({"position":"absolute","top":top+"px","left":left+"px"}).insertAfter($("#uiWebPage"));var addTimeout=function(delay){if(!delay)
delay=1500;return setTimeout(function(){dOverlay.slideUp(function(){$(this).remove()});},delay);}
var removeTimeout=function(timer){if(timer)
clearTimeout(timer);}
var timer=null;timer=addTimeout(2500);dOverlay.mouseout(function(){removeTimeout(timer);timer=addTimeout();});dOverlay.mouseover(function(){removeTimeout(timer);});return dOverlay;}}
UI.Windows={init:function(){this.dDisabler=$("#uiModalOverall");this.dTaskBar=$("#uiTaskBar");this.dDisabler.data("controller",this);},aWindows:{},aModals:{},add:function(oWin){this.aWindows[oWin.options.id]=oWin;if(oWin.options.modal){this.modalOn(oWin.options.id);}
if(oWin.options.taskbar&&!oWin.options.modal){this.addToTaskbar(oWin.options.id);}},modalOn:function(sWin){this.aModals[sWin]=true;this.aWindows[sWin].dOverlay.css("z-index",10000);if(this.aWindows[sWin].options.modal=="transparent"){this.dDisabler.fadeTo(0,0).show();}else{this.dDisabler.fadeTo(0,0.45).fadeIn();}},close:function(sWin){$("#"+sWin).remove();if(this.aWindows[sWin].options.modal&&UI.Utils.countProperties(this.aModals)<2){this.dDisabler.hide();}
if(this.aWindows[sWin].options.taskbar&&!this.aWindows[sWin].options.modal){this.removeFromTaskbar(sWin);}
delete this.aWindows[sWin];delete this.aModals[sWin];},addToTaskbar:function(sWin){this.aWindows[sWin].dTaskbar=$('<a class="uiIcon icWindow"><span>'+this.aWindows[sWin].options.title+'</span></a>').appendTo(this.dTaskBar).hide().slideDown("slow").bind("click",{win:this.aWindows[sWin]},function(event){if(event.data.win.dOverlay.css("display")=="block")event.data.win.dOverlay.hide();else event.data.win.dOverlay.show();})},removeFromTaskbar:function(sWin){this.aWindows[sWin].dTaskbar.unbind("click").slideUp("slow",function(){$(this).remove()});}}
UI.Window=function(oOptions){this.dOverlay=$("#uiOverlayMaster").clone();this.dContent=$(".uiOverlayContent",this.dOverlay);this.dContent.data("windowed",this);var dWindow=$(window);var width=oOptions.width;if(!width)width=((dWindow.width()-200)>950)?950:(dWindow.width()-200);if(!oOptions.height)var height=dWindow.height()-200;var left=Math.round(dWindow.width()/2)-Math.round(width/2);this.options={title:"Window",id:"Window_"+UI.Utils.randomString(),width:width,height:height,top:(100+$(window).scrollTop()),left:left,dock:false,modal:false,content:false,taskbar:true,draggable:true,iframe:false,resizable:true,minHeight:100,minWidth:100,close:null}
jQuery.extend(this.options,oOptions);this.init();}
UI.Window.prototype={init:function(){var self=this;UI.Windows.add(this);this.dOverlay.attr("id",this.options.id);if(this.options.draggable)this.dOverlay.draggable({handle:".drag"});if(this.options.resizable)this.dOverlay.resizable({minWidth:this.options.minWidth,minHeight:this.options.minHeight});this.dOverlay.css({position:"absolute",top:this.options.top,left:this.options.left,width:this.options.width,height:this.options.height});if(this.options.content){this.setContent(this.options.content);}
if(this.options.iframe){this.dContent.css("overflow","hidden");this.setContent('<iframe src="'+this.options.iframe+'" style="width: 100%; height: 100%;"></iframe>')}
this.dTitleBar=$("H3.uiTitle",this.dOverlay);this.dTitle=$(".uiOverlayTitle",this.dOverlay);this.setTitle();$(document.body).append(this.dOverlay);this.dOverlay.fadeIn("slow");this.behaviour();return this;},setContent:function(oEle){this.dContent.html("").append($(oEle)).css({});this.behaviour();return this;},setTitle:function(sTitle){if(typeof sTitle!="undefined")this.options.title=sTitle;else this.dTitle.text(this.options.title);},loadContent:function(sUri,fn){this.dContent.load(sUri,null,fn);},getContent:function(){return this.dContent;},close:function(){$(".uiKill",this.dContent).expire();$(".actionCloseOverlay",this.dOverlay).expire();UI.Windows.close(this.options.id);if(typeof this.options.close=="function")
this.options.close();},onResize:function(event,ui){if(typeof this.options.onresize=="function")this.options.onresize(event,ui);},behaviour:function(){var that=this;$(".actionCloseOverlay",this.dOverlay).livequery(function(){$(this).bind("click",{self:that},function(event){event.data.self.close();});});if(this.options.dock)$(".actionDockOverlay",this.dTitleBar).show().bind("click",{self:this},function(event){event.data.self.options.dock();});$(".uiKill",this.dContent).livequery(function(){var win=$(this).parent();if(win.is(".uiOverlayContent")){win.data("windowed").close();}});},adaptSize:function(){var dContent=this.dContent;var dOverlay=this.dOverlay
setTimeout(function(){var nContentHeight=dContent.children().outerHeight();if(dContent.innerHeight()>nContentHeight)dOverlay.height(nContentHeight);},200);}}
UI.Menu=function(options){this.container=$(".uiSelectable");this.oTrigger=options.trigger;if(this.oTrigger){this.loadFromUri=this.oTrigger.attr("href");this.oTrigger.attr("href","javascript:void(0)");this.menuHtml=$(".uiMenu",this.oTrigger).html();}
this.oTrigger.bind("click",{self:this},function(event){event.preventDefault();$('.dmObject').removeClass('addBg');$(this).parent().parent().addClass('addBg');var top=event.pageY;var left=event.pageX;var maxHeight=270;var offset=event.data.self.oTrigger.parent().parent().offset();var offsetLeft=$(".uiSelectable").width()-offset.left;if($(".uiManagerFavorites").css("display")!="none")
offsetLeft+=130;if(offsetLeft<84)
left-=160;if((event.pageY>($(window).scrollTop()+$(window).height())-maxHeight))
top-=160;if(event.data.self.oTrigger.parent().next().hasClass("optionsMenu")){event.data.self.oTrigger.parent().next().remove()
return false;}else{$(".optionsMenu").fadeOut("fast",function(){$(this).remove()});event.data.self.showMenu(top,left);return false;}});}
UI.Menu.prototype={showMenu:function(top,left){if(this.menuHtml!=null){alert("showing : "+this.menuHtml);}else if(this.loadFromUri){var menu=$('<ul class="optionsMenu uiIcon16"></ul>').css({"top":top+"px","left":left+"px"});$(document.body).append(menu);var refe=this;$.get(this.loadFromUri+"&_display=include",{self:this},function(data){$('.modeManager').html($(data));var list=$(".uiProfileLinks",data);$(".optionsMenu").html(list);$("*").bind("mouseup",function(){$(this).unbind("mouseup");$(".optionsMenu").fadeOut("fast");return false;});});return false;}}}
UI.Controls.ScenarioManager=function(table){this.table=$(table);this.sortUri=this.table.attr("href");this.scenario=this.sortUri.substring(this.sortUri.indexOf("scenario=")+9);this.makeSortable();$(".actionDuplicateSlide",this.table).bind("click",{self:this},function(event){event.data.self._duplicateSlide($(this))});$(".actionRemoveSlide",this.table).bind("click",{self:this},function(event){event.data.self._removeSlide($(this));return false;})}
UI.Controls.ScenarioManager.prototype={makeSortable:function(){var self=this;this.table.tableDnD({onDragClass:"dragged",onDrop:function(table,row){var rows=table.tBodies[0].rows;var prevNodeID=$(row).prev().attr("id");var insertAfter=(typeof prevNodeID!='undefined')?parseInt(prevNodeID.replace(/tableRow_/i,""))-1:-1;var move=parseInt(row.id.replace(/tableRow_/i,""))-1;var debugStr="Row dropped was "+move+"after row "+insertAfter;var uri=$(row).parent().parent().attr("href");$.post(uri+"&_display=include",{mode:"inserAfter",insertAfter:insertAfter,move:move},function(data){if(data.indexOf("code504")>-1){self.normalizeTable();new UI.Controls.Modal({type:"Message",message:BW.Locale.get("Training successfully reorganized.")});}else{new UI.Controls.Modal({type:"Error",message:BW.Locale.get("Error reorganizing training.")});}});}});},_removeSlide:function(clicked){var self=this;var node=clicked;var row=clicked.parent().parent();new UI.Controls.Modal({type:"Confirm",message:BW.Locale.get('Do you really want to remove this slide from the scenario?'),action:function(){$.get(BW.Config.ROOTURI+"mvc/Tutoring/Scenario/RemoveSlide?slide_index="+(parseInt(row.attr("id").replace(/tableRow_/i,""))+"&scenario="+self.scenario),{},function(data){row.remove();self.normalizeTable();});}});},_duplicateSlide:function(clicked){var node=clicked.parent().parent();var newnode=node.clone().addClass('slideNew').insertAfter(node);var inputs=$(".uiFormField",newnode);var idsufix="_new_"+UI.Utils.randomString(5);inputs.each(function(){var input=$(this);var id=input.attr("id");if(id.substring(0,id.lastIndexOf("_")+1)=="PlaceAfter_"){input.val(id.substring(id.lastIndexOf("_")+1));}
var newid=id.substring(0,id.lastIndexOf("_")+1)+idsufix;input.attr("rel",id.substring(id.lastIndexOf("_")+1));input.attr("id",newid);input.attr("name",newid);});$(".uiIntegrity .uiIcon",newnode).removeClass("icUnlocked").addClass("icMissing");$(".actionEditSlide",newnode).hide();$(".slideOrderNumber",newnode).html("");$(".actionRemoveSlide",newnode).bind("click",{self:this},function(event){event.data.self._tempRemove($(this));return false;});$(".actionDuplicateSlide",newnode).unbind('click').text(BW.Locale.get("Save")).removeClass("actionDuplicateSlide").addClass("actionSaveNewSlide").addClass("orange").bind("click",{self:this},function(event){event.data.self._saveSlide($(this))});inputs.eq(2).focus();},_tempRemove:function(button){var node=button.parent().parent().remove();return false;},_saveSlide:function(clicked){var node=clicked.parent().parent();var inputs=$(".uiFormField",node);var params={};params.scenario=this.scenario;params.placeAfter=inputs.eq(1).attr("rel");params.original=inputs.eq(0).val();params.title=inputs.eq(2).val();params.score=inputs.eq(3).val();params.correct=inputs.eq(4).is(":checked");params.difficulty=inputs.eq(5).val();params.sticky=inputs.eq(6).is(":checked");params._display="include";var self=this;$.post(BW.Config.ROOTURI+"mvc/Tutoring/Scenario/DuplicateSlide",params,function(data){self._serverResponse(data,node);});},_serverResponse:function(data,node){if(data.indexOf("code854")>-1){var rel=data.split('rel="')[1].split('"')[0];node.removeClass('slideNew').addClass('slideSaved');this.normalizeTable();$(".actionRemoveSlide",node).unbind('click',this._tempRemove)
$(".uiIntegrity .uiIcon",node).removeClass("icMissing").addClass("icManaged");UI.Targets.bind($(".actionEditSlide",node).unbind("click").attr("href",BW.Config.ROOTURI+"oes/"+rel+"?Edit&scenario="+this.scenario).slideDown());}else{node.remove();}
node.parent().parent().append($(data));this.makeSortable();},normalizeTable:function(){var updateNew=false;var substract=0;$("TBODY TR",this.table).each(function(i){var index=i;var row=$(this);if(row.is(".slideSaved")){updateNew=true;row.attr("id","tableRow_"+(index-substract+1));$(".slideOrderNumber",row).html((index-substract+1));$(".uiFormField",row).each(function(){var input=$(this);var id=input.attr("id");id=id.substring(0,id.lastIndexOf("_new_")+1)+(index-substract+1);input.attr("id",id).attr("name",id);});$(".actionSaveNewSlide",row).removeClass("orange").removeClass("actionSaveNewSlide").addClass("actionDuplicateSlide").unbind('click',this._saveSlide).click(this._duplicateSlide).text(BW.Locale.get("Duplicate"));row.removeClass("slideSaved");}else if(row.is(".slideNew")){if(updateNew){var input=$(this);var id=parseInt(input.attr("rel"));input.attr("rel",number+1);substract++;}}else{row.attr("id","tableRow_"+(index-substract+1));$(".slideOrderNumber",row).html((index-substract+1));$(".uiFormField",row).each(function(){var input=$(this);var id=input.attr("id");id=id.substring(0,id.lastIndexOf("_")+1)+(index-substract+1);input.attr("id",id).attr("name",id);});}});}}
UI.ColorPicker={dOverlay:null,dOverlayContent:null,open:function(){var html="";if(this.mode!=false&&typeof this.mode=="object"){this.dOverlay=UI.Modal.wPopup(this.mode);this.dOverlayContent=$(".uiOverlayContent",this.dOverlay);html+=this.createColorPalette()+'<div class="cleaner"></div>';this.dOverlayContent.html(html);var overlayContent=this.dOverlayContent;$('.uiColorPaletteColor',overlayContent).hover(function(){$(this).parent().css({backgroundColor:'#DDD'});},function(){$(this).parent().css({backgroundColor:'white'});}).bind("click",{self:this},function(event){event.preventDefault();event.stopPropagation();event.data.self.update(UI.ColorPicker.parseColorFromCSS($(this).css('backgroundColor')));event.data.self.close();return false;});}
else{this.dOverlay=UI.Modal.get(420,320,"Color Picker").show();var html='<form><div id="uiColorPicker"><div id="uiFarbtastic"><label for="uiColorPickerColor">Color:</label><input type="text" id="uiColorPickerColor" name="uiColorPickerColor" value="#123456" /><div id="uiColorPickerUI">HELLO</div></div>';var favorite='<div class="uiColorPickerFavoriteOverlay"><div class="uiColorPickerFavoriteColor"></div></div>';var num=8;for(var i=0;i<num;i++){html+=favorite;}
this.dOverlayContent=$(".uiOverlayContent",this.dOverlay);html+=this.createColorPalette()+'<div class="cleaner"></div>';html+='<ol><li class="uiFormControls"><button type="button" class="uiFormControl gray actionApply">Apply</button><button type="button" class="uiFormControl orange actionDone">OK</button></li></ol></div></form>';this.dOverlayContent.html(html);this.behavior();}},createColorPalette:function(){var psColors=['000000','444444','666666','999999','CCCCCC','EEEEEE','F3F3F3','FFFFFF','FF0000','FF9900','FFFF00','00FF00','00FFFF','0000FF','9900FF','FF00FF','F4CCCC','FCE5CD','FFF2CC','D9EAD3','D0E0E3','CFE2F3','D9D2E9','EAD1DC','EA9999','F9CB9C','FFE599','B6D7A8','A2C4C9','9FC5E8','B4A7D6','D5A6BD','E06666','F6B26B','FFD966','93C47D','76A5AF','6FA8DC','8E7CC3','C27BA0','CC0000','F1C232','F1C232','6AA84F','45818E','3D85C6','674EA7','A64D79','990000','B45F06','BF9000','38761D','134F5C','0B5394','351C75','741B47','660000','783F04','7F6000','274E13','0C343D','073763','20124D','4C1130'];var html='<div id="uiColorPalette">';for(var i in psColors){html+='<div class="uiColorPaletteOverlay"><a href="javascript:void(0);" style="background-color: #'+psColors[i]+'" class="uiColorPaletteColor"></a></div>';}
return html+'</div>';},parseColorFromCSS:function(color){if(color.indexOf("rgb")<0){if(color.indexOf("#")==0&&color.length==7)
return color;else
return"#FFFFFF";}
var rgb=color.match(/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/);return'#'+this.rgb2hex(parseInt(rgb[1]))+this.rgb2hex(parseInt(rgb[2]))+this.rgb2hex(parseInt(rgb[3]));},rgb2hex:function(rgb){var char="0123456789ABCDEF";return String(char.charAt(Math.floor(rgb/16)))+String(char.charAt(rgb-(Math.floor(rgb/16)*16)));},behavior:function(){var overlayContent=this.dOverlayContent;var cookieId='favoriteColors';$('.uiColorPickerFavoriteOverlay',overlayContent).bind("click",{},function()
{if($(this).hasClass('uiColorPickerFavoriteSelected')){$(this).removeClass('uiColorPickerFavoriteSelected');}else{$('.uiColorPickerFavoriteOverlay',overlayContent).removeClass('uiColorPickerFavoriteSelected');$(this).addClass('uiColorPickerFavoriteSelected');}
var favColor=$('.uiColorPickerFavoriteSelected .uiColorPickerFavoriteColor',overlayContent).css('backgroundColor');if(favColor){cPicker.setColor(UI.ColorPicker.parseColorFromCSS(favColor));}});var chooseColor=function(color)
{var colorInput=$('#uiColorPickerColor',overlayContent);if(colorInput.get(0)){colorInput.get(0).value=color;colorInput.css({backgroundColor:color,color:cPicker.hsl[2]>0.5?'#000':'#fff'});$('.uiColorPickerFavoriteSelected .uiColorPickerFavoriteColor',overlayContent).css({backgroundColor:color});var favoriteColors=[];$('.uiColorPickerFavoriteColor',overlayContent).each(function()
{favoriteColors.push(UI.ColorPicker.parseColorFromCSS($(this).css('backgroundColor')));});if($.browser.msie){var colorSource=UI.Utils.ARRAY.toSource(favoriteColors);}else{var colorSource=favoriteColors.toSource();}
$.cookie(cookieId,colorSource);}};var cPicker=$.farbtastic($('#uiColorPickerUI',overlayContent),chooseColor);$('#uiColorPickerColor',overlayContent).bind('keyup',cPicker.updateValue);var setFavoriteColors=function()
{if($.browser.msie){var colors=UI.Utils.ARRAY.fromSource($.cookie(cookieId));}else{var colors=eval($.cookie(cookieId));}
var i=0;$('.uiColorPickerFavoriteColor',overlayContent).each(function()
{if(colors&&colors[i]){$(this).css("background",colors[i++]);}});}();$('.uiColorPaletteColor',overlayContent).hover(function(){$(this).parent().css({backgroundColor:'#DDD'});},function(){$(this).parent().css({backgroundColor:'white'});}).bind("click",function()
{cPicker.setColor(UI.ColorPicker.parseColorFromCSS($(this).css('backgroundColor')));});cPicker.setColor(UI.ColorPicker.parseColorFromCSS($('.uiColorPickerFavoriteColor',overlayContent).eq(0).css('backgroundColor')));$('.actionDone',this.dOverlayContent).bind("click",{self:this},function(event){event.preventDefault();event.stopPropagation();event.data.self.update($('#uiColorPickerColor',event.data.self.dOverlayContent).val());event.data.self.close();return false;});$('.actionApply',this.dOverlayContent).bind("click",{self:this},function(event){event.data.self.update($('#uiColorPickerColor',event.data.self.dOverlayContent).val());});},close:function()
{this.dOverlay.remove();$('#uiModalOverall').hide();},edit:function(sMode,updateFunc){UI.ColorPicker.mode=sMode;UI.ColorPicker.updateFunc=updateFunc;UI.ColorPicker.open();},update:function(color){if(typeof UI.ColorPicker.updateFunc=="function")
UI.ColorPicker.updateFunc(color);}}
UI.Messages={init:function(mBox){this.mBox=mBox;this.behavior();},behavior:function(){$(".uiItemTableClick .item TD",this.mBox).each(function(){var itm=$(this).parent();if(!$(this).hasClass("itemCheck")){$(this).toggle(function(){itm.addClass("opened");if(itm.is(".unread")){itm.removeClass("unread");$(".icMessageUnread",itm).removeClass("icMessageUnread").addClass("icMessageRead");}
if($(".inboxThread",itm.next()).html()==""){$(".inboxThread",itm.next()).load(BW.Config.ROOTURI+itm.parent().attr("rel")+"/Thread",{_display:"include",parent:itm.attr("id").replace(/message_/i,"")},function(){$(".inboxThreads LI .item",$(this)).bind("click",{self:this},function(event){if(!$(".uiItemTableClick").hasClass("Sent")){$(".itemDetails",$(this).parent()).toggleClass("hidden");}});});}
itm.next().show();},function(){if(!$(".itemCheckbox",$(this).parent()).attr("checked"))
itm.removeClass("opened");itm.next().hide();});}else{$(this).children().click(function(){if(itm.parent().hasClass("checked"))
itm.parent().removeClass("checked");else
itm.parent().addClass("checked");});}});$(".messageAction",this.mBox).bind("click",{self:this},function(event){event.preventDefault();event.data.self.moveMessage(this);});$("#itemCheckAll",this.mBox).bind("click",{self:this},function(event){event.data.self.checkMessages(this,function(ele){return true});});$("#itemRead",this.mBox).bind("click",{self:this},function(event){event.data.self.checkMessages(this,function(ele){if(!$(ele).hasClass("unread"))return true;else return false;});});$("#itemUnread",this.mBox).bind("click",{self:this},function(event){event.data.self.checkMessages(this,function(ele){if($(ele).hasClass("unread"))return true;else return false;});});$(".markAsRead",this.mBox).bind("click",{self:this},function(event){var id="";$(".uiItemTableClick .item",event.data.self.mBox).each(function(i){if($(".itemCheckbox",$(this)).attr("checked")){if($(this).hasClass("unread")){$(this).removeClass("unread");$(".icMessageUnread",$(this)).removeClass("icMessageUnread").addClass("icMessageRead");id+=$(this).attr("id").replace("message_","")+",";}}});if(id&&id!="")$.get(BW.Config.ROOTURI+"mvc/Communication/Messages/MarkAsRead?id="+id.substr(0,id.length-1));});$(".markAsUnread",this.mBox).bind("click",{self:this},function(event){var id="";$(".uiItemTableClick .item",event.data.self.mBox).each(function(i){if($(".itemCheckbox",$(this)).attr("checked")){if(!$(this).is("unread")){$(this).addClass("unread");$(".icMessageRead",$(this)).removeClass("icMessageRead").addClass("icMessageUnread");id+=$(this).attr("id").replace("message_","")+",";}}});if(id&&id!="")$.get(BW.Config.ROOTURI+"mvc/Communication/Messages/MarkAsUnread?id="+id.substr(0,id.length-1));});},checkMessages:function(ele,condition){if($(ele).attr("checked")){$(".uiItemTableClick .item",this.mBox).each(function(i){if(condition(this)){$(this).parent().addClass("checked");$(".itemCheckbox",$(this)).attr("checked","checked");}});}else{$(".uiItemTableClick .item",this.mBox).each(function(i){if(condition(this)){$(this).parent().removeClass("checked");$(".itemCheckbox",$(this)).attr("checked","");}});}},moveMessage:function(ele){var txt=$(ele).attr("alt");var url=$(ele).attr("href");var id=[],idString="";$(".uiItemTableClick .checked",this.mBox).each(function(i){var cId=$(this).attr("id").replace("thread_","");id.push(cId);idString+=cId+",";});if(idString){var data=idString.substring(0,idString.lastIndexOf(","));if($(ele).hasClass("trash")){data+="&target=deleted";}else if($(ele).hasClass("restore")){data+="&target=restore";}
new window.parent.UI.Controls.Modal(options={type:"Confirm",message:txt,action:function(){$.ajax({type:"GET",url:url+"?id="+data,error:function(XMLHttpRequest,textStatus,errorThrown){new window.parent.UI.Controls.Modal({type:"Alert",message:textStatus});},success:function(data){for(var i=0;i<id.length;i++){$("#thread_"+id[i]).remove();}
$(".uiItemTableClick .item").each(function(i){$(this).attr("class","item")
if(i%2==0){$(this).addClass("odd");}else{$(this).addClass("even");}});}});}});}}}
UI.CharMap={init:function(options,updateFunc){this.options=options;this.updateFunc=updateFunc;this.render();this.behavior();},behavior:function(){$(".specialchar A",this.dOverlayContent).bind("click",{self:this},function(event){event.preventDefault();event.stopPropagation();event.data.self.update($(this,event.data.self.dOverlayContent).text());event.data.self.close();return false;});},update:function(char){if(typeof this.updateFunc=="function")
this.updateFunc(char);},close:function()
{this.dOverlay.remove();},render:function(){if(this.options!=false&&typeof this.options=="object"){this.dOverlay=UI.Modal.wPopup(this.options);}else{this.dOverlay=UI.Modal.get(520,400,"Special Chars").show();}
this.dOverlayContent=$(".uiOverlayContent",this.dOverlay);var html=this.getCharMap();this.dOverlayContent.html(html);},getCharMap:function(){var charsPerRow=17;var chars=0;var output='<div class="charmap">';var charmap=this.getArray();for(var i=0;i<charmap.length;i++){if(charmap[i][2]==true){chars++;output+='<div class="specialchar"><a href="javascript:void(0);">'+charmap[i][0]+'</a></div>';if(chars%charsPerRow==0)
output+='<br class="cleaner" />';}}
output+='</div>';return output;},getArray:function(){return[['&nbsp;','&#160;',true,'no-break space'],['&amp;','&#38;',true,'ampersand'],['&quot;','&#34;',true,'quotation mark'],['&cent;','&#162;',true,'cent sign'],['&euro;','&#8364;',true,'euro sign'],['&pound;','&#163;',true,'pound sign'],['&yen;','&#165;',true,'yen sign'],['&copy;','&#169;',true,'copyright sign'],['&reg;','&#174;',true,'registered sign'],['&trade;','&#8482;',true,'trade mark sign'],['&permil;','&#8240;',true,'per mille sign'],['&micro;','&#181;',true,'micro sign'],['&middot;','&#183;',true,'middle dot'],['&bull;','&#8226;',true,'bullet'],['&hellip;','&#8230;',true,'three dot leader'],['&prime;','&#8242;',true,'minutes / feet'],['&Prime;','&#8243;',true,'seconds / inches'],['&sect;','&#167;',true,'section sign'],['&para;','&#182;',true,'paragraph sign'],['&szlig;','&#223;',true,'sharp s / ess-zed'],['&lsaquo;','&#8249;',true,'single left-pointing angle quotation mark'],['&rsaquo;','&#8250;',true,'single right-pointing angle quotation mark'],['&laquo;','&#171;',true,'left pointing guillemet'],['&raquo;','&#187;',true,'right pointing guillemet'],['&lsquo;','&#8216;',true,'left single quotation mark'],['&rsquo;','&#8217;',true,'right single quotation mark'],['&ldquo;','&#8220;',true,'left double quotation mark'],['&rdquo;','&#8221;',true,'right double quotation mark'],['&sbquo;','&#8218;',true,'single low-9 quotation mark'],['&bdquo;','&#8222;',true,'double low-9 quotation mark'],['&lt;','&#60;',true,'less-than sign'],['&gt;','&#62;',true,'greater-than sign'],['&le;','&#8804;',true,'less-than or equal to'],['&ge;','&#8805;',true,'greater-than or equal to'],['&ndash;','&#8211;',true,'en dash'],['&mdash;','&#8212;',true,'em dash'],['&macr;','&#175;',true,'macron'],['&oline;','&#8254;',true,'overline'],['&curren;','&#164;',true,'currency sign'],['&brvbar;','&#166;',true,'broken bar'],['&uml;','&#168;',true,'diaeresis'],['&iexcl;','&#161;',true,'inverted exclamation mark'],['&iquest;','&#191;',true,'turned question mark'],['&circ;','&#710;',true,'circumflex accent'],['&tilde;','&#732;',true,'small tilde'],['&deg;','&#176;',true,'degree sign'],['&minus;','&#8722;',true,'minus sign'],['&plusmn;','&#177;',true,'plus-minus sign'],['&divide;','&#247;',true,'division sign'],['&frasl;','&#8260;',true,'fraction slash'],['&times;','&#215;',true,'multiplication sign'],['&sup1;','&#185;',true,'superscript one'],['&sup2;','&#178;',true,'superscript two'],['&sup3;','&#179;',true,'superscript three'],['&frac14;','&#188;',true,'fraction one quarter'],['&frac12;','&#189;',true,'fraction one half'],['&frac34;','&#190;',true,'fraction three quarters'],['&fnof;','&#402;',true,'function / florin'],['&int;','&#8747;',true,'integral'],['&sum;','&#8721;',true,'n-ary sumation'],['&infin;','&#8734;',true,'infinity'],['&radic;','&#8730;',true,'square root'],['&sim;','&#8764;',false,'similar to'],['&cong;','&#8773;',false,'approximately equal to'],['&asymp;','&#8776;',true,'almost equal to'],['&ne;','&#8800;',true,'not equal to'],['&equiv;','&#8801;',true,'identical to'],['&isin;','&#8712;',false,'element of'],['&notin;','&#8713;',false,'not an element of'],['&ni;','&#8715;',false,'contains as member'],['&prod;','&#8719;',true,'n-ary product'],['&and;','&#8743;',false,'logical and'],['&or;','&#8744;',false,'logical or'],['&not;','&#172;',true,'not sign'],['&cap;','&#8745;',true,'intersection'],['&cup;','&#8746;',false,'union'],['&part;','&#8706;',true,'partial differential'],['&forall;','&#8704;',false,'for all'],['&exist;','&#8707;',false,'there exists'],['&empty;','&#8709;',false,'diameter'],['&nabla;','&#8711;',false,'backward difference'],['&lowast;','&#8727;',false,'asterisk operator'],['&prop;','&#8733;',false,'proportional to'],['&ang;','&#8736;',false,'angle'],['&acute;','&#180;',true,'acute accent'],['&cedil;','&#184;',true,'cedilla'],['&ordf;','&#170;',true,'feminine ordinal indicator'],['&ordm;','&#186;',true,'masculine ordinal indicator'],['&dagger;','&#8224;',true,'dagger'],['&Dagger;','&#8225;',true,'double dagger'],['&Agrave;','&#192;',true,'A - grave'],['&Aacute;','&#193;',true,'A - acute'],['&Acirc;','&#194;',true,'A - circumflex'],['&Atilde;','&#195;',true,'A - tilde'],['&Auml;','&#196;',true,'A - diaeresis'],['&Aring;','&#197;',true,'A - ring above'],['&AElig;','&#198;',true,'ligature AE'],['&Ccedil;','&#199;',true,'C - cedilla'],['&Egrave;','&#200;',true,'E - grave'],['&Eacute;','&#201;',true,'E - acute'],['&Ecirc;','&#202;',true,'E - circumflex'],['&Euml;','&#203;',true,'E - diaeresis'],['&Igrave;','&#204;',true,'I - grave'],['&Iacute;','&#205;',true,'I - acute'],['&Icirc;','&#206;',true,'I - circumflex'],['&Iuml;','&#207;',true,'I - diaeresis'],['&ETH;','&#208;',true,'ETH'],['&Ntilde;','&#209;',true,'N - tilde'],['&Ograve;','&#210;',true,'O - grave'],['&Oacute;','&#211;',true,'O - acute'],['&Ocirc;','&#212;',true,'O - circumflex'],['&Otilde;','&#213;',true,'O - tilde'],['&Ouml;','&#214;',true,'O - diaeresis'],['&Oslash;','&#216;',true,'O - slash'],['&OElig;','&#338;',true,'ligature OE'],['&Scaron;','&#352;',true,'S - caron'],['&Ugrave;','&#217;',true,'U - grave'],['&Uacute;','&#218;',true,'U - acute'],['&Ucirc;','&#219;',true,'U - circumflex'],['&Uuml;','&#220;',true,'U - diaeresis'],['&Yacute;','&#221;',true,'Y - acute'],['&Yuml;','&#376;',true,'Y - diaeresis'],['&THORN;','&#222;',true,'THORN'],['&agrave;','&#224;',true,'a - grave'],['&aacute;','&#225;',true,'a - acute'],['&acirc;','&#226;',true,'a - circumflex'],['&atilde;','&#227;',true,'a - tilde'],['&auml;','&#228;',true,'a - diaeresis'],['&aring;','&#229;',true,'a - ring above'],['&aelig;','&#230;',true,'ligature ae'],['&ccedil;','&#231;',true,'c - cedilla'],['&egrave;','&#232;',true,'e - grave'],['&eacute;','&#233;',true,'e - acute'],['&ecirc;','&#234;',true,'e - circumflex'],['&euml;','&#235;',true,'e - diaeresis'],['&igrave;','&#236;',true,'i - grave'],['&iacute;','&#237;',true,'i - acute'],['&icirc;','&#238;',true,'i - circumflex'],['&iuml;','&#239;',true,'i - diaeresis'],['&eth;','&#240;',true,'eth'],['&ntilde;','&#241;',true,'n - tilde'],['&ograve;','&#242;',true,'o - grave'],['&oacute;','&#243;',true,'o - acute'],['&ocirc;','&#244;',true,'o - circumflex'],['&otilde;','&#245;',true,'o - tilde'],['&ouml;','&#246;',true,'o - diaeresis'],['&oslash;','&#248;',true,'o slash'],['&oelig;','&#339;',true,'ligature oe'],['&scaron;','&#353;',true,'s - caron'],['&ugrave;','&#249;',true,'u - grave'],['&uacute;','&#250;',true,'u - acute'],['&ucirc;','&#251;',true,'u - circumflex'],['&uuml;','&#252;',true,'u - diaeresis'],['&yacute;','&#253;',true,'y - acute'],['&thorn;','&#254;',true,'thorn'],['&yuml;','&#255;',true,'y - diaeresis'],['&Alpha;','&#913;',true,'Alpha'],['&Beta;','&#914;',true,'Beta'],['&Gamma;','&#915;',true,'Gamma'],['&Delta;','&#916;',true,'Delta'],['&Epsilon;','&#917;',true,'Epsilon'],['&Zeta;','&#918;',true,'Zeta'],['&Eta;','&#919;',true,'Eta'],['&Theta;','&#920;',true,'Theta'],['&Iota;','&#921;',true,'Iota'],['&Kappa;','&#922;',true,'Kappa'],['&Lambda;','&#923;',true,'Lambda'],['&Mu;','&#924;',true,'Mu'],['&Nu;','&#925;',true,'Nu'],['&Xi;','&#926;',true,'Xi'],['&Omicron;','&#927;',true,'Omicron'],['&Pi;','&#928;',true,'Pi'],['&Rho;','&#929;',true,'Rho'],['&Sigma;','&#931;',true,'Sigma'],['&Tau;','&#932;',true,'Tau'],['&Upsilon;','&#933;',true,'Upsilon'],['&Phi;','&#934;',true,'Phi'],['&Chi;','&#935;',true,'Chi'],['&Psi;','&#936;',true,'Psi'],['&Omega;','&#937;',true,'Omega'],['&alpha;','&#945;',true,'alpha'],['&beta;','&#946;',true,'beta'],['&gamma;','&#947;',true,'gamma'],['&delta;','&#948;',true,'delta'],['&epsilon;','&#949;',true,'epsilon'],['&zeta;','&#950;',true,'zeta'],['&eta;','&#951;',true,'eta'],['&theta;','&#952;',true,'theta'],['&iota;','&#953;',true,'iota'],['&kappa;','&#954;',true,'kappa'],['&lambda;','&#955;',true,'lambda'],['&mu;','&#956;',true,'mu'],['&nu;','&#957;',true,'nu'],['&xi;','&#958;',true,'xi'],['&omicron;','&#959;',true,'omicron'],['&pi;','&#960;',true,'pi'],['&rho;','&#961;',true,'rho'],['&sigmaf;','&#962;',true,'final sigma'],['&sigma;','&#963;',true,'sigma'],['&tau;','&#964;',true,'tau'],['&upsilon;','&#965;',true,'upsilon'],['&phi;','&#966;',true,'phi'],['&chi;','&#967;',true,'chi'],['&psi;','&#968;',true,'psi'],['&omega;','&#969;',true,'omega'],['&alefsym;','&#8501;',false,'alef symbol'],['&piv;','&#982;',false,'pi symbol'],['&real;','&#8476;',false,'real part symbol'],['&thetasym;','&#977;',false,'theta symbol'],['&upsih;','&#978;',false,'upsilon - hook symbol'],['&weierp;','&#8472;',false,'Weierstrass p'],['&image;','&#8465;',false,'imaginary part'],['&larr;','&#8592;',true,'leftwards arrow'],['&uarr;','&#8593;',true,'upwards arrow'],['&rarr;','&#8594;',true,'rightwards arrow'],['&darr;','&#8595;',true,'downwards arrow'],['&harr;','&#8596;',true,'left right arrow'],['&crarr;','&#8629;',false,'carriage return'],['&lArr;','&#8656;',false,'leftwards double arrow'],['&uArr;','&#8657;',false,'upwards double arrow'],['&rArr;','&#8658;',false,'rightwards double arrow'],['&dArr;','&#8659;',false,'downwards double arrow'],['&hArr;','&#8660;',false,'left right double arrow'],['&there4;','&#8756;',false,'therefore'],['&sub;','&#8834;',false,'subset of'],['&sup;','&#8835;',false,'superset of'],['&nsub;','&#8836;',false,'not a subset of'],['&sube;','&#8838;',false,'subset of or equal to'],['&supe;','&#8839;',false,'superset of or equal to'],['&oplus;','&#8853;',false,'circled plus'],['&otimes;','&#8855;',false,'circled times'],['&perp;','&#8869;',false,'perpendicular'],['&sdot;','&#8901;',false,'dot operator'],['&lceil;','&#8968;',true,'left ceiling'],['&rceil;','&#8969;',true,'right ceiling'],['&lfloor;','&#8970;',true,'left floor'],['&rfloor;','&#8971;',true,'right floor'],['&lang;','&#9001;',false,'left-pointing angle bracket'],['&rang;','&#9002;',false,'right-pointing angle bracket'],['&loz;','&#9674;',true,'lozenge'],['&spades;','&#9824;',true,'black spade suit'],['&clubs;','&#9827;',true,'black club suit'],['&hearts;','&#9829;',true,'black heart suit'],['&diams;','&#9830;',true,'black diamond suit'],['&ensp;','&#8194;',false,'en space'],['&emsp;','&#8195;',false,'em space'],['&thinsp;','&#8201;',false,'thin space'],['&zwnj;','&#8204;',false,'zero width non-joiner'],['&zwj;','&#8205;',false,'zero width joiner'],['&lrm;','&#8206;',false,'left-to-right mark'],['&rlm;','&#8207;',false,'right-to-left mark'],['&shy;','&#173;',false,'soft hyphen']];}}
UI.showHidePanels={panels:[[".actionToggleCategories",".uiNavigator"],[".actionToggleLanguage",".uiSearchLanguage"],[".actionToggleTags",".uiTagCloud"]],toggle:function(ele){var n=0;for(var i=0;i<this.panels.length;i++){$(this.panels[i][0]).css("background-position","0px 0px");$(this.panels[i][1]).slideUp();if(this.panels[i][0].indexOf($(ele).attr("class"))>-1)
n=i;}
if($(this.panels[n][1]).css("display")=="none"){$(this.panels[n][1]).slideDown();$(this.panels[n][0]).blur().css("background-position","0px -26px");$.cookie("cat_view",this.panels[n][1],{expires:32});}else{$.cookie("cat_view",null);}}}
UI.HighlightText=function(oEle,searchString){if(searchString=="["||searchString=="]")return;var textContainerNode=oEle.get(0);var searchTerms=searchString.split('|');for(var i in searchTerms){var regex=new RegExp(">([^<]*)?("+searchTerms[i]+")([^>]*)?<","ig");this.highlightTextNodes(textContainerNode,regex,i);}}
UI.HighlightText.prototype.highlightTextNodes=function(element,regex,termid){var tempinnerHTML=element.innerHTML;element.innerHTML=tempinnerHTML.replace(regex,'>$1<span class="highlighted term'+termid+'">$2</span>$3<');}
UI.LocationBar=function(node,newWidth){var minWidth=360;var node=$(node);var scroller=$("#locationItems",node);var items=scroller.children();var width=0;$("#location").width(minWidth+newWidth);items.each(function(){width+=$(this).outerWidth()+4;});var hiddenRight=width-(minWidth+newWidth);var hiddenLeft=0;scroller.css("margin-left","0px");var moveRight=function(){if(hiddenRight>0){hiddenRight-=4;hiddenLeft+=4;scroller.css("margin-left","-"+hiddenLeft+"px");}}
var moveLeft=function(){if(hiddenLeft>0){hiddenLeft-=4;hiddenRight+=4;scroller.css("margin-left","-"+hiddenLeft+"px");}}
var mover=null;$(".uiMoverRight").unbind("mouseenter mouseleave");$(".uiMoverRight").hover(function(){if(mover==null)mover=setInterval(moveRight,10);},function(){clearInterval(mover);mover=null;});$(".uiMoverLeft").unbind("mouseenter mouseleave");$(".uiMoverLeft").hover(function(){if(mover==null)mover=setInterval(moveLeft,10);},function(){clearInterval(mover);mover=null;});$(".uiLabel",node).click(function(){var self=$(this).parent();self.hide();$(".uiInputBar",self.parent()).show();});$(".uiInputBar .icClose",node).click(function(){var self=$(this).parent();self.hide();$("ul",self.parent()).show();});}
UI.Timezones={init:function(Ele,time){this.dom=Ele;this.GMT0=time.split(":");var dateId=Number(this.GMT0[1]+this.GMT0[2]+this.GMT0[3]+this.GMT0[4]+this.GMT0[5]);this.DST=(dateId>329015959&&dateId<1025025959)?"North":"South";this.marked=false;this.areas=[];this.behavior();},behavior:function(){var self=this;$("AREA",this.dom).each(function(i){self.areas.push(new self.timezonePart($(this),self));});},timezonePart:function(oEle,self){var attr=$(oEle).attr("href").split(",");$(oEle).attr("href","javascript:void(0)");var id=attr[0];if(attr[1]){var num=attr[1];var sign=(attr[1].charAt(0)=="W")?"-":"+";var val=attr[2];}
var DST=((attr[3]=="DST"&&self.DST=="North")||(attr[3]=="DST-S"&&self.DST=="South"))?1:0;$(oEle).hover(function(event){$(id).css("visibility","visible");UI.Timezones.showTime(num,sign,val,DST);$(this).click(function(event){UI.Timezones.showTime(num,sign,val,DST,"clicked");});},function(event){$(id).css("visibility","hidden");});},showTime:function(num,sign,val,DST,selectNew){var time=num.split(":");var h=parseFloat(time[0].substr(1,time[0].length));var hours=(sign=="+")?Number(this.GMT0[3])+h+DST:Number(this.GMT0[3])-h+DST;var minutes=Number(this.GMT0[4]);if(time[1]){minutes+=Number(time[1])
if(minutes>59){minutes-=60;hours+=1;}}
if(hours<0)hours+=24+hours;if(hours>23)hours-=24;if(minutes<10)minutes="0"+minutes;$("#time").html(hours+":"+minutes+":"+this.GMT0[5]+" <small>("+val+")</small>");if(selectNew&&typeof selectNew=="string"&&selectNew=="clicked"){$("#timezone").val(val).focus();}}}
// JS/UI.ext.js

var hexcase=0;var b64pad="";var chrsz=8;function hex_md5(s){return binl2hex(core_md5(str2binl(s),s.length*chrsz));}
function b64_md5(s){return binl2b64(core_md5(str2binl(s),s.length*chrsz));}
function str_md5(s){return binl2str(core_md5(str2binl(s),s.length*chrsz));}
function hex_hmac_md5(key,data){return binl2hex(core_hmac_md5(key,data));}
function b64_hmac_md5(key,data){return binl2b64(core_hmac_md5(key,data));}
function str_hmac_md5(key,data){return binl2str(core_hmac_md5(key,data));}
function md5_vm_test()
{return hex_md5("abc")=="900150983cd24fb0d6963f7d28e17f72";}
function core_md5(x,len)
{x[len>>5]|=0x80<<((len)%32);x[(((len+64)>>>9)<<4)+14]=len;var a=1732584193;var b=-271733879;var c=-1732584194;var d=271733878;for(var i=0;i<x.length;i+=16)
{var olda=a;var oldb=b;var oldc=c;var oldd=d;a=md5_ff(a,b,c,d,x[i+0],7,-680876936);d=md5_ff(d,a,b,c,x[i+1],12,-389564586);c=md5_ff(c,d,a,b,x[i+2],17,606105819);b=md5_ff(b,c,d,a,x[i+3],22,-1044525330);a=md5_ff(a,b,c,d,x[i+4],7,-176418897);d=md5_ff(d,a,b,c,x[i+5],12,1200080426);c=md5_ff(c,d,a,b,x[i+6],17,-1473231341);b=md5_ff(b,c,d,a,x[i+7],22,-45705983);a=md5_ff(a,b,c,d,x[i+8],7,1770035416);d=md5_ff(d,a,b,c,x[i+9],12,-1958414417);c=md5_ff(c,d,a,b,x[i+10],17,-42063);b=md5_ff(b,c,d,a,x[i+11],22,-1990404162);a=md5_ff(a,b,c,d,x[i+12],7,1804603682);d=md5_ff(d,a,b,c,x[i+13],12,-40341101);c=md5_ff(c,d,a,b,x[i+14],17,-1502002290);b=md5_ff(b,c,d,a,x[i+15],22,1236535329);a=md5_gg(a,b,c,d,x[i+1],5,-165796510);d=md5_gg(d,a,b,c,x[i+6],9,-1069501632);c=md5_gg(c,d,a,b,x[i+11],14,643717713);b=md5_gg(b,c,d,a,x[i+0],20,-373897302);a=md5_gg(a,b,c,d,x[i+5],5,-701558691);d=md5_gg(d,a,b,c,x[i+10],9,38016083);c=md5_gg(c,d,a,b,x[i+15],14,-660478335);b=md5_gg(b,c,d,a,x[i+4],20,-405537848);a=md5_gg(a,b,c,d,x[i+9],5,568446438);d=md5_gg(d,a,b,c,x[i+14],9,-1019803690);c=md5_gg(c,d,a,b,x[i+3],14,-187363961);b=md5_gg(b,c,d,a,x[i+8],20,1163531501);a=md5_gg(a,b,c,d,x[i+13],5,-1444681467);d=md5_gg(d,a,b,c,x[i+2],9,-51403784);c=md5_gg(c,d,a,b,x[i+7],14,1735328473);b=md5_gg(b,c,d,a,x[i+12],20,-1926607734);a=md5_hh(a,b,c,d,x[i+5],4,-378558);d=md5_hh(d,a,b,c,x[i+8],11,-2022574463);c=md5_hh(c,d,a,b,x[i+11],16,1839030562);b=md5_hh(b,c,d,a,x[i+14],23,-35309556);a=md5_hh(a,b,c,d,x[i+1],4,-1530992060);d=md5_hh(d,a,b,c,x[i+4],11,1272893353);c=md5_hh(c,d,a,b,x[i+7],16,-155497632);b=md5_hh(b,c,d,a,x[i+10],23,-1094730640);a=md5_hh(a,b,c,d,x[i+13],4,681279174);d=md5_hh(d,a,b,c,x[i+0],11,-358537222);c=md5_hh(c,d,a,b,x[i+3],16,-722521979);b=md5_hh(b,c,d,a,x[i+6],23,76029189);a=md5_hh(a,b,c,d,x[i+9],4,-640364487);d=md5_hh(d,a,b,c,x[i+12],11,-421815835);c=md5_hh(c,d,a,b,x[i+15],16,530742520);b=md5_hh(b,c,d,a,x[i+2],23,-995338651);a=md5_ii(a,b,c,d,x[i+0],6,-198630844);d=md5_ii(d,a,b,c,x[i+7],10,1126891415);c=md5_ii(c,d,a,b,x[i+14],15,-1416354905);b=md5_ii(b,c,d,a,x[i+5],21,-57434055);a=md5_ii(a,b,c,d,x[i+12],6,1700485571);d=md5_ii(d,a,b,c,x[i+3],10,-1894986606);c=md5_ii(c,d,a,b,x[i+10],15,-1051523);b=md5_ii(b,c,d,a,x[i+1],21,-2054922799);a=md5_ii(a,b,c,d,x[i+8],6,1873313359);d=md5_ii(d,a,b,c,x[i+15],10,-30611744);c=md5_ii(c,d,a,b,x[i+6],15,-1560198380);b=md5_ii(b,c,d,a,x[i+13],21,1309151649);a=md5_ii(a,b,c,d,x[i+4],6,-145523070);d=md5_ii(d,a,b,c,x[i+11],10,-1120210379);c=md5_ii(c,d,a,b,x[i+2],15,718787259);b=md5_ii(b,c,d,a,x[i+9],21,-343485551);a=safe_add(a,olda);b=safe_add(b,oldb);c=safe_add(c,oldc);d=safe_add(d,oldd);}
return Array(a,b,c,d);}
function md5_cmn(q,a,b,x,s,t)
{return safe_add(bit_rol(safe_add(safe_add(a,q),safe_add(x,t)),s),b);}
function md5_ff(a,b,c,d,x,s,t)
{return md5_cmn((b&c)|((~b)&d),a,b,x,s,t);}
function md5_gg(a,b,c,d,x,s,t)
{return md5_cmn((b&d)|(c&(~d)),a,b,x,s,t);}
function md5_hh(a,b,c,d,x,s,t)
{return md5_cmn(b^c^d,a,b,x,s,t);}
function md5_ii(a,b,c,d,x,s,t)
{return md5_cmn(c^(b|(~d)),a,b,x,s,t);}
function core_hmac_md5(key,data)
{var bkey=str2binl(key);if(bkey.length>16)bkey=core_md5(bkey,key.length*chrsz);var ipad=Array(16),opad=Array(16);for(var i=0;i<16;i++)
{ipad[i]=bkey[i]^0x36363636;opad[i]=bkey[i]^0x5C5C5C5C;}
var hash=core_md5(ipad.concat(str2binl(data)),512+data.length*chrsz);return core_md5(opad.concat(hash),512+128);}
function safe_add(x,y)
{var lsw=(x&0xFFFF)+(y&0xFFFF);var msw=(x>>16)+(y>>16)+(lsw>>16);return(msw<<16)|(lsw&0xFFFF);}
function bit_rol(num,cnt)
{return(num<<cnt)|(num>>>(32-cnt));}
function str2binl(str)
{var bin=Array();var mask=(1<<chrsz)-1;for(var i=0;i<str.length*chrsz;i+=chrsz)
bin[i>>5]|=(str.charCodeAt(i/chrsz)&mask)<<(i%32);return bin;}
function binl2str(bin)
{var str="";var mask=(1<<chrsz)-1;for(var i=0;i<bin.length*32;i+=chrsz)
str+=String.fromCharCode((bin[i>>5]>>>(i%32))&mask);return str;}
function binl2hex(binarray)
{var hex_tab=hexcase?"0123456789ABCDEF":"0123456789abcdef";var str="";for(var i=0;i<binarray.length*4;i++)
{str+=hex_tab.charAt((binarray[i>>2]>>((i%4)*8+4))&0xF)+
hex_tab.charAt((binarray[i>>2]>>((i%4)*8))&0xF);}
return str;}
function binl2b64(binarray)
{var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var str="";for(var i=0;i<binarray.length*4;i+=3)
{var triplet=(((binarray[i>>2]>>8*(i%4))&0xFF)<<16)|(((binarray[i+1>>2]>>8*((i+1)%4))&0xFF)<<8)|((binarray[i+2>>2]>>8*((i+2)%4))&0xFF);for(var j=0;j<4;j++)
{if(i*8+j*6>binarray.length*32)str+=b64pad;else str+=tab.charAt((triplet>>6*(3-j))&0x3F);}}
return str;}
// JS/md5.js

$(document).ready(function(){BW.initialize();if($.cookie("cat_view")!==null){var panels=UI.showHidePanels.panels;for(var i=0;i<panels.length;i++){if($.cookie("cat_view")==panels[i][1]){$(panels[i][1]).show();$(panels[i][0]).blur().css("background-position","0px -26px");}}}
$(".actionToggleCategories,.actionToggleLanguage,.actionToggleTags").live("click",function(){UI.showHidePanels.toggle(this);});$("#srchLangAll").click(function(){$(".uiSearchLanguage INPUT.selectLang, .uiSearchLanguage INPUT#srchLangFilter").attr("checked","");});$("#srchLangFilter, .uiSearchLanguage INPUT.selectLang").click(function(){$(".uiSearchLanguage INPUT#srchLangAll").attr("checked","");$(".uiSearchLanguage INPUT#srchLangFilter").attr("checked","checked");});$("#hideMessage").click(function(){$("#uiBrowserWarning").slideUp();$.cookie("message_view","hide",{expires:32});});$("#uiWebMessages").ajaxError(function(event,request,settings){UI.History.find(settings.url,true);new UI.Controls.Modal(options={type:"Error",message:"404 Error - Page you are trying to reach does not exist."});UI.Targets.load(BW.Config.ROOTURI+"mvc/User/Public/MyPage?_display=include",".uiWebMain",null,true);});});$(".uiTeleport").livequery(function(){var oNode=$(this);var sEle=oNode.attr("rel");var bAdd=false;if(typeof sEle!="string")return false;if(sEle==""||typeof sEle=="undefined")return false;if(sEle.indexOf("ADD")==0){bAdd=true;sEle=sEle.substr(3);}
var bReplace=(oNode.is(".replaceTarget"))?true:false;var oEle=$(sEle);UI.Targets.place(oNode.html(),oEle,bAdd,bReplace);});$('.uiWizard').livequery(function(){new UI.Controls.Wizard($(this));});$('.uiPlayer').livequery(function(){new UI.Controls.Player(this);});$('#uiNotifyMessages').livequery(function(){BW.Notify.init();});$('.uiModalShow').livequery(function(){var ele=$(this);var href=ele.attr("href");href=href+(href.indexOf("?")<0?"?":"&")+"_display=include";ele.attr("href","javascript:void(0)");ele.bind("click",function(){var options={type:"Alert",message:ele.attr("alt"),trigger:ele,goto:{uri:href,ele:ele.attr("rel")}}
if(ele.is(".actionConfirm")){options.type="Confirm";}else if(ele.is(".actionError")){options.type="Error";}else if(ele.is(".actionMessage")){options.type="Message";}
new UI.Controls.Modal(options);return false;});});$('A').livequery(function(){var node=$(this);if(node.is(".uiKill")){if(node.attr("rel")!=""){var node=UI.Targets.proximity(node.attr("rel"),node);node.slideUp("slow",function(){$(this).remove();});}else{node.parent().slideUp("slow",function(){$(this).remove();});}
return;}
if(node.is(".uiInclude")){UI.Targets.include(node);return;}
if($.browser=="msie"&&$.browser.version<7.0){}else{if(BW.Config.tooltips&&(node.is(".tooltip")||node.children("SPAN").eq(0).css("display")=="none")){UI.Tooltip.bind(node);}}
if(node.is(".uiTarget")){UI.Targets.bind(node);return;}
if(node.is(".glossary")){UI.Glossary.bind(node);return;}
if(node.is(".uiSubMenu")){new UI.Menu({trigger:node});return;}
if(node.is(".flag")){UI.Targets.bind(node);return;}
if(node.is(".jumpToLogIn")){$(this).click(function(){$("#sLoginEmail").focus();});return;}
if(node.is(".uiWindowed")){$(node).click(function(event){var node=$(this);var framed=(node.is(".framed"))?true:false;if(framed){var oWindow=new UI.Window({title:node.text(),modal:true,resizable:false,iframe:node.attr("href")});}else{var w,h;if(node.attr("dimensions")){var prop=node.attr("dimensions").split(",");w=Number(prop[0]);h=Number(prop[1]);}
var oWindow=new UI.Window({title:node.text(),modal:true,resizable:false,width:w,height:h});UI.Targets.load(node.attr("href"),oWindow.getContent(),false,true,"include",oWindow.adaptSize,oWindow);}
return false;});return;}
var href=node.attr("href")
if(typeof href=="string"&&href.indexOf("javascript")!=0&&href.indexOf(BW.Config.ROOTURI)==-1){node.attr("href",BW.Config.ROOTURI+"mvc/General/External/Index?uri="+href);}
return;});if(BW.Config.tooltips&&!($.browser=="msie"&&$.browser.version<7.0)){$(".tooltip:not(A)").livequery(function(){UI.Tooltip.bind($(this));});}
$('TABLE').livequery(function(){var node=$(this);if(node.is(".uiScenarioManager")){new UI.Controls.ScenarioManager(node);}});$('.uiMessage').livequery(function(){var ele=$(this);var options={type:"Message",message:ele.html(),trigger:ele}
if(ele.is(".uiMessageWarning")){options.type="Warning";}else if(ele.is(".uiMessageError")){options.type="Error";}
new UI.Controls.Modal(options);return false;});$("form.uiForm").livequery(function(){BW.Forms.add(new UI.Controls.Form($(this)));});$('.uiTag').livequery(function(){new UI.Controls.Tags(this);});$('.uiUnfold').livequery(function(){var oContainer=$(this);var unfold={one:$(".uiUnfoldPanel",oContainer).not(".hidden"),two:$(".uiUnfoldPanel.hidden",oContainer)}
$(".actionUnfold",unfold.one).bind("click",{unfold:unfold},function(event){event.data.unfold.one.slideUp();event.data.unfold.two.slideDown();});$(".actionUnfold",unfold.two).bind("click",{unfold:unfold},function(event){event.data.unfold.two.slideUp();event.data.unfold.one.slideDown();});});$("#MainCategoryMenu").livequery(function(){UI.Navigator.init($(this).parent());});$("#newCategories li").livequery(function(){UI.Categories.liveInit($(this));});$('.uiTabs').livequery(function(){new UI.Controls.Tab.Tabs($(this));});$('.uiTab').livequery(function(){UI.Controls.Tab.add($(this));});$(".uiFilter").livequery(function(){new UI.Controls.Filter($(this));})
$('.uiTreeView').livequery(function(){var node=$(this);var update=node.attr("href")
update=(update!="")?update:false;var options={container:node,update:update,sortable:false,selectable:false}
if(node.hasClass("draggable")){options.sortable=true;options.selectable=true;}
new UI.Controls.Tree(options);});$(".section").livequery(function(){var node=$(this);$(".body").hide();$("h3",node).click(function(){var body=$(this).next();if(body.css("display")=="none")body.show();else body.hide();});$(".toggleSection").unbind("click").show().click(function(){var node=$(this).parent();if(node.is(".opened")){$(".body",node).hide();node.removeClass("opened");}else{$(".body",node).show();node.addClass("opened");}});});$(".uiMessagesBox").livequery(function(){UI.Messages.init(this);});$("LI.Ticket").livequery(function(){var node=$(this);$(".icOk",node).parent().mouseup(function(){UI.Targets.load(BW.Config.ROOTURI+"mvc/User/Public/NewsFeed?tabs=false",node.parents(".uiTab").eq(0),$(this),true,'include');});$(".icDelete2",node).parent().mouseup(function(){UI.Targets.load(BW.Config.ROOTURI+"mvc/User/Public/NewsFeed?tabs=false",node.parents(".uiTab").eq(0),$(this),true,'include');});});$('li.navAccount').livequery(function(){var node=$(this);node.bind("click",{},function(event){$(this).addClass('hover');$("ul",this).animate({top:-32,height:300},500);if($.browser.msie&&$.browser.version<8){$(".uiNavigator .uiNavigatorActions").css({visibility:"hidden"});$(".uiNavigator").css({width:"647px"});}});node.hover(function(){},function(){$("ul",this).animate({top:0,height:32},500,function(){$(this).removeClass('hover');});if($.browser.msie&&$.browser.version<8){$(".uiNavigator .uiNavigatorActions").css({visibility:"visible"});$(".uiNavigator").css({width:"936px"});}});},function(){$(this).unbind('mouseover').unbind('mouseout');});$(".uiMenuQ .uiTabsHeading .uiTab").livequery(function(){var node=$(this);node.click(function(){node.blur();$(".uiTab").removeClass("active");node.addClass("active");$(".uiTabsSubmenu").hide().removeClass("selected");$("#"+node.attr("id")+"Show").slideDown()
return false;});});$("INPUT.uiSelectableText").livequery(function(){$(this).click(function(){this.select();})});$(".uiColumns").livequery(function(){var cols=$(".uiColumn",$(this));var maxheight=0;for(var i=0;i<cols.length;i++){var h=cols.eq(i).height();if(h>maxheight)maxheight=h;}
if(h>0){for(var i=0;i<cols.length;i++){cols.eq(i).height(maxheight);}}});$(".uiStatus .changeTxt2Input").livequery(function(){if($(this).is(".editable"))var status=new UI.Status($(this));});$('.cloneField').live('click',function(event){var prevEle=$(this).parent().parent().prev();var control=$(".uiFormField",prevEle).data("control");var newEle=prevEle.clone(false);var id=$('.uiFormField',newEle).attr('id');var newId=id.split("[");var newName;if(!newId[1]){$(".uiFormField",prevEle).attr({name:newId[0]+"[1]",id:newId[0]+"[1]"});newName=newId[0]+"[2]";}
else{newName=id.replace(/\b\[\d+/g,"["+(parseInt(newId[1])+1));}
$('.uiFormField',newEle).attr({name:newName,id:newName}).val("");if(!$('.uiFormField',newEle).next().is(".removeField")){$('.uiFormField',newEle).after('<a class="removeField" href="javascript:void(0)"><img src="/Hive/Media/Icons/Default/16/Remove.png"/>Remove</a>');}
$('LABEL',newEle).attr("for",newName);control.oForm.aFields.push(new UI.Controls.Form.Input(newEle,control.oForm));$(this).parent().parent().before(newEle);});$(".removeField").live("click",function(){$(this).parent().parent().remove();});
// JS/shmhmphrsh.js
