/*** default.js ***/

function yvSmileyReplaceText(ControlID, code) {
  ControlID.value = ControlID.value + ' ' + code;
}
;

/*** joms.jquery.js ***/

/*!
 * jQuery JavaScript Library v1.4.3
 * http://jquery.com/
 *
 * Copyright 2010, John Resig
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 * Copyright 2010, The Dojo Foundation
 * Released under the MIT, BSD, and GPL Licenses.
 *
 * Date: Thu Oct 14 23:10:06 2010 -0400
 */
(function( window, undefined ) {

// Use the correct document accordingly with window argument (sandbox)
var document = window.document;
var jomsQuery = (function() {

// Define a local copy of jQuery
var jomsQuery = function( selector, context ) {
		// The jQuery object is actually just the init constructor 'enhanced'
		return new jomsQuery.fn.init( selector, context );
	},

	// Map over jQuery in case of overwrite
	//_jQuery = window.jQuery,

	// Map over the $ in case of overwrite
	_$ = window.$,

	// A central reference to the root jQuery(document)
	rootjomsQuery,

	joms = window.joms = {
		extend: function(obj){
			this.jQuery.extend(this, obj);
		}
	},

	// joms.jQuery = window.jomsQuery,

	// A simple way to check for HTML strings or ID strings
	// (both of which we optimize for)
	quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,

	// Is it a simple selector
	isSimple = /^.[^:#\[\.,]*$/,

	// Check if a string has a non-whitespace character in it
	rnotwhite = /\S/,
	rwhite = /\s/,

	// Used for trimming whitespace
	trimLeft = /^\s+/,
	trimRight = /\s+$/,

	// Check for non-word characters
	rnonword = /\W/,

	// Check for digits
	rdigit = /\d/,

	// Match a standalone tag
	rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,

	// JSON RegExp
	rvalidchars = /^[\],:{}\s]*$/,
	rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
	rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
	rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,

	// Useragent RegExp
	rwebkit = /(webkit)[ \/]([\w.]+)/,
	ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
	rmsie = /(msie) ([\w.]+)/,
	rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,

	// Keep a UserAgent string for use with jQuery.browser
	userAgent = navigator.userAgent,

	// For matching the engine and version of the browser
	browserMatch,
	
	// Has the ready events already been bound?
	readyBound = false,
	
	// The functions to execute on DOM ready
	readyList = [],

	// The ready event handler
	DOMContentLoaded,

	// Save a reference to some core methods
	toString = Object.prototype.toString,
	hasOwn = Object.prototype.hasOwnProperty,
	push = Array.prototype.push,
	slice = Array.prototype.slice,
	trim = String.prototype.trim,
	indexOf = Array.prototype.indexOf,
	
	// [[Class]] -> type pairs
	class2type = {};

jomsQuery.fn = jomsQuery.prototype = {
	init: function( selector, context ) {
		var match, elem, ret, doc;

		// Handle $(""), $(null), or $(undefined)
		if ( !selector ) {
			return this;
		}

		// Handle $(DOMElement)
		if ( selector.nodeType ) {
			this.context = this[0] = selector;
			this.length = 1;
			return this;
		}
		
		// The body element only exists once, optimize finding it
		if ( selector === "body" && !context && document.body ) {
			this.context = document;
			this[0] = document.body;
			this.selector = "body";
			this.length = 1;
			return this;
		}

		// Handle HTML strings
		if ( typeof selector === "string" ) {
			// Are we dealing with HTML string or an ID?
			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] ) {
					doc = (context ? context.ownerDocument || context : document);

					// If a single string is passed in and it's a single tag
					// just do a createElement and skip the rest
					ret = rsingleTag.exec( selector );

					if ( ret ) {
						if ( jomsQuery.isPlainObject( context ) ) {
							selector = [ document.createElement( ret[1] ) ];
							jomsQuery.fn.attr.call( selector, context, true );

						} else {
							selector = [ doc.createElement( ret[1] ) ];
						}

					} else {
						ret = jomsQuery.buildFragment( [ match[1] ], [ doc ] );
						selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
					}
					
					return jomsQuery.merge( this, selector );
					
				// HANDLE: $("#id")
				} else {
					elem = document.getElementById( match[2] );

					// Check parentNode to catch when Blackberry 4.6 returns
					// nodes that are no longer in the document #6963
					if ( elem && elem.parentNode ) {
						// Handle the case where IE and Opera return items
						// by name instead of ID
						if ( elem.id !== match[2] ) {
							return rootjomsQuery.find( selector );
						}

						// Otherwise, we inject the element directly into the jQuery object
						this.length = 1;
						this[0] = elem;
					}

					this.context = document;
					this.selector = selector;
					return this;
				}

			// HANDLE: $("TAG")
			} else if ( !context && !rnonword.test( selector ) ) {
				this.selector = selector;
				this.context = document;
				selector = document.getElementsByTagName( selector );
				return jomsQuery.merge( this, selector );

			// HANDLE: $(expr, $(...))
			} else if ( !context || context.jomsQuery ) {
				return (context || rootjomsQuery).find( selector );

			// HANDLE: $(expr, context)
			// (which is just equivalent to: $(context).find(expr)
			} else {
				return jomsQuery( context ).find( selector );
			}

		// HANDLE: $(function)
		// Shortcut for document ready
		} else if ( jomsQuery.isFunction( selector ) ) {
			return rootjomsQuery.ready( selector );
		}

		if (selector.selector !== undefined) {
			this.selector = selector.selector;
			this.context = selector.context;
		}

		return jomsQuery.makeArray( selector, this );
	},

	// Start with an empty selector
	selector: "",

	// The current version of jQuery being used
	jquery: "1.4.3",
	jomsquery: "1.2.0",

	// The default length of a jQuery object is 0
	length: 0,

	// The number of elements contained in the matched element set
	size: function() {
		return this.length;
	},

	toArray: function() {
		return slice.call( this, 0 );
	},

	// 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 == null ?

			// Return a 'clean' array
			this.toArray() :

			// Return just the object
			( num < 0 ? this.slice(num)[ 0 ] : 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 = jomsQuery();

		if ( jomsQuery.isArray( elems ) ) {
			push.apply( ret, elems );
		
		} else {
			jomsQuery.merge( ret, 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;
	},

	// 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 jomsQuery.each( this, callback, args );
	},
	
	ready: function( fn ) {
		// Attach the listeners
		jomsQuery.bindReady();

		// If the DOM is already ready
		if ( jomsQuery.isReady ) {
			// Execute the function immediately
			fn.call( document, jomsQuery );

		// Otherwise, remember the function for later
		} else if ( readyList ) {
			// Add the function to the wait list
			readyList.push( fn );
		}

		return this;
	},
	
	eq: function( i ) {
		return i === -1 ?
			this.slice( i ) :
			this.slice( i, +i + 1 );
	},

	first: function() {
		return this.eq( 0 );
	},

	last: function() {
		return this.eq( -1 );
	},

	slice: function() {
		return this.pushStack( slice.apply( this, arguments ),
			"slice", slice.call(arguments).join(",") );
	},

	map: function( callback ) {
		return this.pushStack( jomsQuery.map(this, function( elem, i ) {
			return callback.call( elem, i, elem );
		}));
	},
	
	end: function() {
		return this.prevObject || jomsQuery(null);
	},

	// For internal use only.
	// Behaves like an Array's method, not like a jomsQuery method.
	push: push,
	sort: [].sort,
	splice: [].splice
};

// Give the init function the jomsQuery prototype for later instantiation
jomsQuery.fn.init.prototype = jomsQuery.fn;

jomsQuery.extend = jomsQuery.fn.extend = function() {
	// copy reference to target object
	var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy, copyIsArray;

	// 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" && !jomsQuery.isFunction(target) ) {
		target = {};
	}

	// extend jomsQuery 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 ( name in options ) {
				src = target[ name ];
				copy = options[ name ];

				// Prevent never-ending loop
				if ( target === copy ) {
					continue;
				}

				// Recurse if we're merging plain objects or arrays
				if ( deep && copy && ( jomsQuery.isPlainObject(copy) || (copyIsArray = jomsQuery.isArray(copy)) ) ) {
					if ( copyIsArray ) {
						copyIsArray = false;
						clone = src && jomsQuery.isArray(src) ? src : [];

					} else {
						clone = src && jomsQuery.isPlainObject(src) ? src : {};
					}

					// Never move original objects, clone them
					target[ name ] = jomsQuery.extend( deep, clone, copy );

				// Don't bring in undefined values
				} else if ( copy !== undefined ) {
					target[ name ] = copy;
				}
			}
		}
	}

	// Return the modified object
	return target;
};

jomsQuery.extend({
	noConflict: function() {
		if( typeof(_$) != 'undefined' )
		{
			window.$ = _$;
		}
		return jomsQuery;
	},

	restorejQuery: function() {
		window.jQuery = _jQuery;
		return jomsQuery.noConflict();	
	},

	replacejQuery: function() {
		// For jQuery loaded before jomsQuery
		if (window.jQuery!=undefined)
		{
			// Import any DOMReady events attached to it
			jomsQuery.readyList.concat(window.jQuery.readyList);
			window.jQuery.readyList = null;
		}
		window.jQuery = jomsQuery;
		
		// For jQuery loaded after jomsQuery
		jomsQuery(document).ready(function()
		{
			// Look for the jomsquery signature.
			// If it doesn't exist, jomsQuery has been overidden.
			if (jQuery.fn.jomsquery==undefined)
			{
				// Allow any DOMReady events attached to it to
				// execute before we replace them with jomsQuery.
				if (!jQuery.isReady || jQuery.readyList !=null)
					jQuery.ready();

				_jQuery = jQuery;
				window.jQuery = jomsQuery;
			}
		});
	},

	includejQuery: function() {
		if (window.jQuery==undefined)
		{
			window.jQuery = jomsQuery;
		}

		// If jomsQuery is overriden by other jQuery loaded after us,
		// we'll let them take over, but we'll need to execute any
		// DOMReady events that were attached to us.
		jomsQuery(document).ready(function()
		{
			if (jQuery.fn.jomsquery==undefined)
			{
				if (!jomsQuery.isReady || jomsQuery.readyList !=null)
					jomsQuery.ready();
			}
		});
	},
	
	// Is the DOM ready to be used? Set to true once it occurs.
	isReady: false,

	// A counter to track how many items to wait for before
	// the ready event fires. See #6781
	readyWait: 1,
	
	// Handle when the DOM is ready
	ready: function( wait ) {
		// A third-party is pushing the ready event forwards
		if ( wait === true ) {
			jomsQuery.readyWait--;
		}

		// Make sure that the DOM is not already loaded
		if ( !jomsQuery.readyWait || (wait !== true && !jomsQuery.isReady) ) {
			// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
			if ( !document.body ) {
				return setTimeout( jomsQuery.ready, 1 );
			}

			// Remember that the DOM is ready
			jomsQuery.isReady = true;

			// If a normal DOM Ready event fired, decrement, and wait if need be
			if ( wait !== true && --jomsQuery.readyWait > 0 ) {
				return;
			}

			// If there are functions bound, to execute
			if ( readyList ) {
				// Execute all of them
				var fn, i = 0;
				while ( (fn = readyList[ i++ ]) ) {
					fn.call( document, jomsQuery );
				}

				// Reset the list of functions
				readyList = null;
			}

			// Trigger any bound ready events
			if ( jomsQuery.fn.triggerHandler ) {
				jomsQuery( document ).triggerHandler( "ready" );
			}
		}
	},
	
	bindReady: function() {
		if ( readyBound ) {
			return;
		}

		readyBound = true;

		// Catch cases where $(document).ready() is called after the
		// browser event has already occurred.
		if ( document.readyState === "complete" ) {
			// Handle it asynchronously to allow scripts the opportunity to delay ready
			return setTimeout( jomsQuery.ready, 1 );
		}

		// Mozilla, Opera and webkit nightlies currently support this event
		if ( document.addEventListener ) {
			// Use the handy event callback
			document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
			
			// A fallback to window.onload, that will always work
			window.addEventListener( "load", jomsQuery.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", DOMContentLoaded);
			
			// A fallback to window.onload, that will always work
			window.attachEvent( "onload", jomsQuery.ready );

			// If IE and not a frame
			// continually check to see if the document is ready
			var toplevel = false;

			try {
				toplevel = window.frameElement == null;
			} catch(e) {}

			if ( document.documentElement.doScroll && toplevel ) {
				doScrollCheck();
			}
		}
	},

	// 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 jomsQuery.type(obj) === "function";
	},

	isArray: Array.isArray || function( obj ) {
		return jomsQuery.type(obj) === "array";
	},

	// A crude way of determining if an object is a window
	isWindow: function( obj ) {
		return obj && typeof obj === "object" && "setInterval" in obj;
	},

	isNaN: function( obj ) {
		return obj == null || !rdigit.test( obj ) || isNaN( obj );
	},

	type: function( obj ) {
		return obj == null ?
			String( obj ) :
			class2type[ toString.call(obj) ] || "object";
	},

	isPlainObject: function( obj ) {
		// Must be an Object.
		// Because of IE, we also have to check the presence of the constructor property.
		// Make sure that DOM nodes and window objects don't pass through, as well
		if ( !obj || jomsQuery.type(obj) !== "object" || obj.nodeType || jomsQuery.isWindow( obj ) ) {
			return false;
		}
		
		// Not own constructor property must be Object
		if ( obj.constructor &&
			!hasOwn.call(obj, "constructor") &&
			!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
			return false;
		}
		
		// Own properties are enumerated firstly, so to speed up,
		// if last one is own, then all properties are own.
	
		var key;
		for ( key in obj ) {}
		
		return key === undefined || hasOwn.call( obj, key );
	},

	isEmptyObject: function( obj ) {
		for ( var name in obj ) {
			return false;
		}
		return true;
	},
	
	error: function( msg ) {
		throw msg;
	},
	
	parseJSON: function( data ) {
		if ( typeof data !== "string" || !data ) {
			return null;
		}

		// Make sure leading/trailing whitespace is removed (IE can't handle it)
		data = jomsQuery.trim( data );
		
		// Make sure the incoming data is actual JSON
		// Logic borrowed from http://json.org/json2.js
		if ( rvalidchars.test(data.replace(rvalidescape, "@")
			.replace(rvalidtokens, "]")
			.replace(rvalidbraces, "")) ) {

			// Try to use the native JSON parser first
			return window.JSON && window.JSON.parse ?
				window.JSON.parse( data ) :
				(new Function("return " + data))();

		} else {
			jomsQuery.error( "Invalid JSON: " + data );
		}
	},

	noop: function() {},

	// Evalulates a script in a global context
	globalEval: function( data ) {
		if ( data && rnotwhite.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 ( jomsQuery.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,
			isObj = length === undefined || jomsQuery.isFunction(object);

		if ( args ) {
			if ( isObj ) {
				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 ( isObj ) {
				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;
	},

	// Use native String.trim function wherever possible
	trim: trim ?
		function( text ) {
			return text == null ?
				"" :
				trim.call( text );
		} :

		// Otherwise use our own trimming functionality
		function( text ) {
			return text == null ?
				"" :
				text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
		},

	// results is for internal usage only
	makeArray: function( array, results ) {
		var ret = results || [];

		if ( array != null ) {
			// The window, strings (and functions) also have 'length'
			// The extra typeof function check is to prevent crashes
			// in Safari 2 (See: #3039)
			// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
			var type = jomsQuery.type(array);

			if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jomsQuery.isWindow( array ) ) {
				push.call( ret, array );
			} else {
				jomsQuery.merge( ret, array );
			}
		}

		return ret;
	},

	inArray: function( elem, array ) {
		if ( array.indexOf ) {
			return array.indexOf( elem );
		}

		for ( var i = 0, length = array.length; i < length; i++ ) {
			if ( array[ i ] === elem ) {
				return i;
			}
		}

		return -1;
	},

	merge: function( first, second ) {
		var i = first.length, j = 0;

		if ( typeof second.length === "number" ) {
			for ( var l = second.length; j < l; j++ ) {
				first[ i++ ] = second[ j ];
			}
		
		} else {
			while ( second[j] !== undefined ) {
				first[ i++ ] = second[ j++ ];
			}
		}

		first.length = i;

		return first;
	},

	grep: function( elems, callback, inv ) {
		var ret = [], retVal;
		inv = !!inv;

		// Go through the array, only saving the items
		// that pass the validator function
		for ( var i = 0, length = elems.length; i < length; i++ ) {
			retVal = !!callback( elems[ i ], i );
			if ( inv !== retVal ) {
				ret.push( elems[ i ] );
			}
		}

		return ret;
	},

	// arg is for internal usage only
	map: function( elems, callback, arg ) {
		var ret = [], value;

		// 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++ ) {
			value = callback( elems[ i ], i, arg );

			if ( value != null ) {
				ret[ ret.length ] = value;
			}
		}

		return ret.concat.apply( [], ret );
	},

	// A global GUID counter for objects
	guid: 1,

	proxy: function( fn, proxy, thisObject ) {
		if ( arguments.length === 2 ) {
			if ( typeof proxy === "string" ) {
				thisObject = fn;
				fn = thisObject[ proxy ];
				proxy = undefined;

			} else if ( proxy && !jomsQuery.isFunction( proxy ) ) {
				thisObject = proxy;
				proxy = undefined;
			}
		}

		if ( !proxy && fn ) {
			proxy = function() {
				return fn.apply( thisObject || this, arguments );
			};
		}

		// Set the guid of unique handler to the same of original handler, so it can be removed
		if ( fn ) {
			proxy.guid = fn.guid = fn.guid || proxy.guid || jomsQuery.guid++;
		}

		// So proxy can be declared as an argument
		return proxy;
	},

	// Mutifunctional method to get and set values to a collection
	// The value/s can be optionally by executed if its a function
	access: function( elems, key, value, exec, fn, pass ) {
		var length = elems.length;
	
		// Setting many attributes
		if ( typeof key === "object" ) {
			for ( var k in key ) {
				jomsQuery.access( elems, k, key[k], exec, fn, value );
			}
			return elems;
		}
	
		// Setting one attribute
		if ( value !== undefined ) {
			// Optionally, function values get executed if exec is true
			exec = !pass && exec && jomsQuery.isFunction(value);
		
			for ( var i = 0; i < length; i++ ) {
				fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
			}
		
			return elems;
		}
	
		// Getting an attribute
		return length ? fn( elems[0], key ) : undefined;
	},

	now: function() {
		return (new Date()).getTime();
	},

	// Use of jomsQuery.browser is frowned upon.
	// More details: http://docs.jomsQuery.com/Utilities/jomsQuery.browser
	uaMatch: function( ua ) {
		ua = ua.toLowerCase();

		var match = rwebkit.exec( ua ) ||
			ropera.exec( ua ) ||
			rmsie.exec( ua ) ||
			ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
			[];

		return { browser: match[1] || "", version: match[2] || "0" };
	},

	browser: {}
});

// Populate the class2type map
jomsQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
	class2type[ "[object " + name + "]" ] = name.toLowerCase();
});

browserMatch = jomsQuery.uaMatch( userAgent );
if ( browserMatch.browser ) {
	jomsQuery.browser[ browserMatch.browser ] = true;
	jomsQuery.browser.version = browserMatch.version;
}

// Deprecated, use jomsQuery.browser.webkit instead
if ( jomsQuery.browser.webkit ) {
	jomsQuery.browser.safari = true;
}

if ( indexOf ) {
	jomsQuery.inArray = function( elem, array ) {
		return indexOf.call( array, elem );
	};
}

// Verify that \s matches non-breaking spaces
// (IE fails on this test)
if ( !rwhite.test( "\xA0" ) ) {
	trimLeft = /^[\s\xA0]+/;
	trimRight = /[\s\xA0]+$/;
}

// All jomsQuery objects should point back to these
rootjomsQuery = jomsQuery(document);

// Cleanup functions for the document ready method
if ( document.addEventListener ) {
	DOMContentLoaded = function() {
		document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
		jomsQuery.ready();
	};

} else if ( document.attachEvent ) {
	DOMContentLoaded = function() {
		// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
		if ( document.readyState === "complete" ) {
			document.detachEvent( "onreadystatechange", DOMContentLoaded );
			jomsQuery.ready();
		}
	};
}

// The DOM ready check for Internet Explorer
function doScrollCheck() {
	if ( jomsQuery.isReady ) {
		return;
	}

	try {
		// If IE is used, use the trick by Diego Perini
		// http://javascript.nwbox.com/IEContentLoaded/
		document.documentElement.doScroll("left");
	} catch(e) {
		setTimeout( doScrollCheck, 1 );
		return;
	}

	// and execute any waiting functions
	jomsQuery.ready();
}

// Expose jomsQuery to the global object
// return (window.jomsQuery = window.$ = jomsQuery);
return (window.jomsQuery = window.joms.jQuery = jomsQuery);

})();


(function() {

	jomsQuery.support = {};

	var root = document.documentElement,
		script = document.createElement("script"),
		div = document.createElement("div"),
		id = "script" + jomsQuery.now();

	div.style.display = "none";
	div.innerHTML = "   <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";

	var all = div.getElementsByTagName("*"),
		a = div.getElementsByTagName("a")[0],
		select = document.createElement("select"),
		opt = select.appendChild( document.createElement("option") );

	// Can't get basic test support
	if ( !all || !all.length || !a ) {
		return;
	}

	jomsQuery.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 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)
		// Use a regex to work around a WebKit issue. See #5145
		opacity: /^0.55$/.test( a.style.opacity ),

		// Verify style float existence
		// (IE uses styleFloat instead of cssFloat)
		cssFloat: !!a.style.cssFloat,

		// Make sure that if no value is specified for a checkbox
		// that it defaults to "on".
		// (WebKit defaults to "" instead)
		checkOn: div.getElementsByTagName("input")[0].value === "on",

		// Make sure that a selected-by-default option has a working selected property.
		// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
		optSelected: opt.selected,

		// Will be defined later
		optDisabled: false,
		checkClone: false,
		scriptEval: false,
		noCloneEvent: true,
		boxModel: null,
		inlineBlockNeedsLayout: false,
		shrinkWrapBlocks: false,
		reliableHiddenOffsets: true
	};

	// Make sure that the options inside disabled selects aren't marked as disabled
	// (WebKit marks them as diabled)
	select.disabled = true;
	jomsQuery.support.optDisabled = !opt.disabled;

	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 ] ) {
		jomsQuery.support.scriptEval = true;
		delete window[ id ];
	}

	root.removeChild( script );

	if ( div.attachEvent && div.fireEvent ) {
		div.attachEvent("onclick", function click() {
			// Cloning a node shouldn't copy over any
			// bound event handlers (IE does this)
			jomsQuery.support.noCloneEvent = false;
			div.detachEvent("onclick", click);
		});
		div.cloneNode(true).fireEvent("onclick");
	}

	div = document.createElement("div");
	div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";

	var fragment = document.createDocumentFragment();
	fragment.appendChild( div.firstChild );

	// WebKit doesn't clone checked state correctly in fragments
	jomsQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;

	// Figure out if the W3C box model works as expected
	// document.body must exist before we can do this
	jomsQuery(function() {
		var div = document.createElement("div");
		div.style.width = div.style.paddingLeft = "1px";

		document.body.appendChild( div );
		jomsQuery.boxModel = jomsQuery.support.boxModel = div.offsetWidth === 2;

		if ( "zoom" in div.style ) {
			// Check if natively block-level elements act like inline-block
			// elements when setting their display to 'inline' and giving
			// them layout
			// (IE < 8 does this)
			div.style.display = "inline";
			div.style.zoom = 1;
			jomsQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;

			// Check if elements with layout shrink-wrap their children
			// (IE 6 does this)
			div.style.display = "";
			div.innerHTML = "<div style='width:4px;'></div>";
			jomsQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
		}

		div.innerHTML = "<table><tr><td style='padding:0;display:none'></td><td>t</td></tr></table>";
		var tds = div.getElementsByTagName("td");

		// Check if table cells still have offsetWidth/Height when they are set
		// to display:none and there are still other visible table cells in a
		// table row; if so, offsetWidth/Height are not reliable for use when
		// determining if an element has been hidden directly using
		// display:none (it is still safe to use offsets if a parent element is
		// hidden; don safety goggles and see bug #4512 for more information).
		// (only IE 8 fails this test)
		jomsQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;

		tds[0].style.display = "";
		tds[1].style.display = "none";

		// Check if empty table cells still have offsetWidth/Height
		// (IE < 8 fail this test)
		jomsQuery.support.reliableHiddenOffsets = jomsQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
		div.innerHTML = "";

		document.body.removeChild( div ).style.display = "none";
		div = tds = null;
	});

	// Technique from Juriy Zaytsev
	// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
	var eventSupported = function( eventName ) {
		var el = document.createElement("div");
		eventName = "on" + eventName;

		var isSupported = (eventName in el);
		if ( !isSupported ) {
			el.setAttribute(eventName, "return;");
			isSupported = typeof el[eventName] === "function";
		}
		el = null;

		return isSupported;
	};

	jomsQuery.support.submitBubbles = eventSupported("submit");
	jomsQuery.support.changeBubbles = eventSupported("change");

	// release memory in IE
	root = script = div = all = a = null;
})();

jomsQuery.props = {
	"for": "htmlFor",
	"class": "className",
	readonly: "readOnly",
	maxlength: "maxLength",
	cellspacing: "cellSpacing",
	rowspan: "rowSpan",
	colspan: "colSpan",
	tabindex: "tabIndex",
	usemap: "useMap",
	frameborder: "frameBorder"
};




var windowData = {},
	rbrace = /^(?:\{.*\}|\[.*\])$/;

jomsQuery.extend({
	cache: {},

	// Please use with caution
	uuid: 0,

	// Unique for each copy of jomsQuery on the page	
	expando: "jomsQuery" + jomsQuery.now(),

	// The following elements throw uncatchable exceptions if you
	// attempt to add expando properties to them.
	noData: {
		"embed": true,
		// Ban all objects except for Flash (which handle expandos)
		"object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
		"applet": true
	},

	data: function( elem, name, data ) {
		if ( !jomsQuery.acceptData( elem ) ) {
			return;
		}

		elem = elem == window ?
			windowData :
			elem;

		var isNode = elem.nodeType,
			id = isNode ? elem[ jomsQuery.expando ] : null,
			cache = jomsQuery.cache, thisCache;

		if ( isNode && !id && typeof name === "string" && data === undefined ) {
			return;
		}

		// Get the data from the object directly
		if ( !isNode ) {
			cache = elem;

		// Compute a unique ID for the element
		} else if ( !id ) {
			elem[ jomsQuery.expando ] = id = ++jomsQuery.uuid;
		}

		// Avoid generating a new cache unless none exists and we
		// want to manipulate it.
		if ( typeof name === "object" ) {
			if ( isNode ) {
				cache[ id ] = jomsQuery.extend(cache[ id ], name);

			} else {
				jomsQuery.extend( cache, name );
			}

		} else if ( isNode && !cache[ id ] ) {
			cache[ id ] = {};
		}

		thisCache = isNode ? cache[ id ] : cache;

		// Prevent overriding the named cache with undefined values
		if ( data !== undefined ) {
			thisCache[ name ] = data;
		}

		return typeof name === "string" ? thisCache[ name ] : thisCache;
	},

	removeData: function( elem, name ) {
		if ( !jomsQuery.acceptData( elem ) ) {
			return;
		}

		elem = elem == window ?
			windowData :
			elem;

		var isNode = elem.nodeType,
			id = isNode ? elem[ jomsQuery.expando ] : elem,
			cache = jomsQuery.cache,
			thisCache = isNode ? cache[ id ] : id;

		// If we want to remove a specific section of the element's data
		if ( name ) {
			if ( thisCache ) {
				// Remove the section of cache data
				delete thisCache[ name ];

				// If we've removed all the data, remove the element's cache
				if ( isNode && jomsQuery.isEmptyObject(thisCache) ) {
					jomsQuery.removeData( elem );
				}
			}

		// Otherwise, we want to remove all of the element's data
		} else {
			if ( isNode && jomsQuery.support.deleteExpando ) {
				delete elem[ jomsQuery.expando ];

			} else if ( elem.removeAttribute ) {
				elem.removeAttribute( jomsQuery.expando );

			// Completely remove the data cache
			} else if ( isNode ) {
				delete cache[ id ];

			// Remove all fields from the object
			} else {
				for ( var n in elem ) {
					delete elem[ n ];
				}
			}
		}
	},

	// A method for determining if a DOM node can handle the data expando
	acceptData: function( elem ) {
		if ( elem.nodeName ) {
			var match = jomsQuery.noData[ elem.nodeName.toLowerCase() ];

			if ( match ) {
				return !(match === true || elem.getAttribute("classid") !== match);
			}
		}

		return true;
	}
});

jomsQuery.fn.extend({
	data: function( key, value ) {
		if ( typeof key === "undefined" ) {
			return this.length ? jomsQuery.data( this[0] ) : null;

		} else if ( typeof key === "object" ) {
			return this.each(function() {
				jomsQuery.data( this, key );
			});
		}

		var parts = key.split(".");
		parts[1] = parts[1] ? "." + parts[1] : "";

		if ( value === undefined ) {
			var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);

			// Try to fetch any internally stored data first
			if ( data === undefined && this.length ) {
				data = jomsQuery.data( this[0], key );

				// If nothing was found internally, try to fetch any
				// data from the HTML5 data-* attribute
				if ( data === undefined && this[0].nodeType === 1 ) {
					data = this[0].getAttribute( "data-" + key );

					if ( typeof data === "string" ) {
						try {
							data = data === "true" ? true :
								data === "false" ? false :
								data === "null" ? null :
								!jomsQuery.isNaN( data ) ? parseFloat( data ) :
								rbrace.test( data ) ? jomsQuery.parseJSON( data ) :
								data;
						} catch( e ) {}

					} else {
						data = undefined;
					}
				}
			}

			return data === undefined && parts[1] ?
				this.data( parts[0] ) :
				data;

		} else {
			return this.each(function() {
				var $this = jomsQuery( this ), args = [ parts[0], value ];

				$this.triggerHandler( "setData" + parts[1] + "!", args );
				jomsQuery.data( this, key, value );
				$this.triggerHandler( "changeData" + parts[1] + "!", args );
			});
		}
	},

	removeData: function( key ) {
		return this.each(function() {
			jomsQuery.removeData( this, key );
		});
	}
});




jomsQuery.extend({
	queue: function( elem, type, data ) {
		if ( !elem ) {
			return;
		}

		type = (type || "fx") + "queue";
		var q = jomsQuery.data( elem, type );

		// Speed up dequeue by getting out quickly if this is just a lookup
		if ( !data ) {
			return q || [];
		}

		if ( !q || jomsQuery.isArray(data) ) {
			q = jomsQuery.data( elem, type, jomsQuery.makeArray(data) );

		} else {
			q.push( data );
		}

		return q;
	},

	dequeue: function( elem, type ) {
		type = type || "fx";

		var queue = jomsQuery.queue( elem, type ), fn = queue.shift();

		// If the fx queue is dequeued, always remove the progress sentinel
		if ( fn === "inprogress" ) {
			fn = queue.shift();
		}

		if ( fn ) {
			// Add a progress sentinel to prevent the fx queue from being
			// automatically dequeued
			if ( type === "fx" ) {
				queue.unshift("inprogress");
			}

			fn.call(elem, function() {
				jomsQuery.dequeue(elem, type);
			});
		}
	}
});

jomsQuery.fn.extend({
	queue: function( type, data ) {
		if ( typeof type !== "string" ) {
			data = type;
			type = "fx";
		}

		if ( data === undefined ) {
			return jomsQuery.queue( this[0], type );
		}
		return this.each(function( i ) {
			var queue = jomsQuery.queue( this, type, data );

			if ( type === "fx" && queue[0] !== "inprogress" ) {
				jomsQuery.dequeue( this, type );
			}
		});
	},
	dequeue: function( type ) {
		return this.each(function() {
			jomsQuery.dequeue( this, type );
		});
	},

	// Based off of the plugin by Clint Helfers, with permission.
	// http://blindsignals.com/index.php/2009/07/jomsQuery-delay/
	delay: function( time, type ) {
		time = jomsQuery.fx ? jomsQuery.fx.speeds[time] || time : time;
		type = type || "fx";

		return this.queue( type, function() {
			var elem = this;
			setTimeout(function() {
				jomsQuery.dequeue( elem, type );
			}, time );
		});
	},

	clearQueue: function( type ) {
		return this.queue( type || "fx", [] );
	}
});




var rclass = /[\n\t]/g,
	rspaces = /\s+/,
	rreturn = /\r/g,
	rspecialurl = /^(?:href|src|style)$/,
	rtype = /^(?:button|input)$/i,
	rfocusable = /^(?:button|input|object|select|textarea)$/i,
	rclickable = /^a(?:rea)?$/i,
	rradiocheck = /^(?:radio|checkbox)$/i;

jomsQuery.fn.extend({
	attr: function( name, value ) {
		return jomsQuery.access( this, name, value, true, jomsQuery.attr );
	},

	removeAttr: function( name, fn ) {
		return this.each(function(){
			jomsQuery.attr( this, name, "" );
			if ( this.nodeType === 1 ) {
				this.removeAttribute( name );
			}
		});
	},

	addClass: function( value ) {
		if ( jomsQuery.isFunction(value) ) {
			return this.each(function(i) {
				var self = jomsQuery(this);
				self.addClass( value.call(this, i, self.attr("class")) );
			});
		}

		if ( value && typeof value === "string" ) {
			var classNames = (value || "").split( rspaces );

			for ( var i = 0, l = this.length; i < l; i++ ) {
				var elem = this[i];

				if ( elem.nodeType === 1 ) {
					if ( !elem.className ) {
						elem.className = value;

					} else {
						var className = " " + elem.className + " ", setClass = elem.className;
						for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
							if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
								setClass += " " + classNames[c];
							}
						}
						elem.className = jomsQuery.trim( setClass );
					}
				}
			}
		}

		return this;
	},

	removeClass: function( value ) {
		if ( jomsQuery.isFunction(value) ) {
			return this.each(function(i) {
				var self = jomsQuery(this);
				self.removeClass( value.call(this, i, self.attr("class")) );
			});
		}

		if ( (value && typeof value === "string") || value === undefined ) {
			var classNames = (value || "").split( rspaces );

			for ( var i = 0, l = this.length; i < l; i++ ) {
				var elem = this[i];

				if ( elem.nodeType === 1 && elem.className ) {
					if ( value ) {
						var className = (" " + elem.className + " ").replace(rclass, " ");
						for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
							className = className.replace(" " + classNames[c] + " ", " ");
						}
						elem.className = jomsQuery.trim( className );

					} else {
						elem.className = "";
					}
				}
			}
		}

		return this;
	},

	toggleClass: function( value, stateVal ) {
		var type = typeof value, isBool = typeof stateVal === "boolean";

		if ( jomsQuery.isFunction( value ) ) {
			return this.each(function(i) {
				var self = jomsQuery(this);
				self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
			});
		}

		return this.each(function() {
			if ( type === "string" ) {
				// toggle individual class names
				var className, i = 0, self = jomsQuery(this),
					state = stateVal,
					classNames = value.split( rspaces );

				while ( (className = classNames[ i++ ]) ) {
					// check each className given, space seperated list
					state = isBool ? state : !self.hasClass( className );
					self[ state ? "addClass" : "removeClass" ]( className );
				}

			} else if ( type === "undefined" || type === "boolean" ) {
				if ( this.className ) {
					// store className if set
					jomsQuery.data( this, "__className__", this.className );
				}

				// toggle whole className
				this.className = this.className || value === false ? "" : jomsQuery.data( this, "__className__" ) || "";
			}
		});
	},

	hasClass: function( selector ) {
		var className = " " + selector + " ";
		for ( var i = 0, l = this.length; i < l; i++ ) {
			if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
				return true;
			}
		}

		return false;
	},

	val: function( value ) {
		if ( !arguments.length ) {
			var elem = this[0];

			if ( elem ) {
				if ( jomsQuery.nodeName( elem, "option" ) ) {
					// attributes.value is undefined in Blackberry 4.7 but
					// uses .value. See #6932
					var val = elem.attributes.value;
					return !val || val.specified ? elem.value : elem.text;
				}

				// We need to handle select boxes special
				if ( jomsQuery.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 ];

						// Don't return options that are disabled or in a disabled optgroup
						if ( option.selected && (jomsQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && 
								(!option.parentNode.disabled || !jomsQuery.nodeName( option.parentNode, "optgroup" )) ) {

							// Get the specific value for the option
							value = jomsQuery(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;
				}

				// Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
				if ( rradiocheck.test( elem.type ) && !jomsQuery.support.checkOn ) {
					return elem.getAttribute("value") === null ? "on" : elem.value;
				}
				

				// Everything else, we just grab the value
				return (elem.value || "").replace(rreturn, "");

			}

			return undefined;
		}

		var isFunction = jomsQuery.isFunction(value);

		return this.each(function(i) {
			var self = jomsQuery(this), val = value;

			if ( this.nodeType !== 1 ) {
				return;
			}

			if ( isFunction ) {
				val = value.call(this, i, self.val());
			}

			// Treat null/undefined as ""; convert numbers to string
			if ( val == null ) {
				val = "";
			} else if ( typeof val === "number" ) {
				val += "";
			} else if ( jomsQuery.isArray(val) ) {
				val = jomsQuery.map(val, function (value) {
					return value == null ? "" : value + "";
				});
			}

			if ( jomsQuery.isArray(val) && rradiocheck.test( this.type ) ) {
				this.checked = jomsQuery.inArray( self.val(), val ) >= 0;

			} else if ( jomsQuery.nodeName( this, "select" ) ) {
				var values = jomsQuery.makeArray(val);

				jomsQuery( "option", this ).each(function() {
					this.selected = jomsQuery.inArray( jomsQuery(this).val(), values ) >= 0;
				});

				if ( !values.length ) {
					this.selectedIndex = -1;
				}

			} else {
				this.value = val;
			}
		});
	}
});

jomsQuery.extend({
	attrFn: {
		val: true,
		css: true,
		html: true,
		text: true,
		data: true,
		width: true,
		height: true,
		offset: true
	},
		
	attr: function( elem, name, value, pass ) {
		// don't set attributes on text and comment nodes
		if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
			return undefined;
		}

		if ( pass && name in jomsQuery.attrFn ) {
			return jomsQuery(elem)[name](value);
		}

		var notxml = elem.nodeType !== 1 || !jomsQuery.isXMLDoc( elem ),
			// Whether we are setting (or getting)
			set = value !== undefined;

		// Try to normalize/fix the name
		name = notxml && jomsQuery.props[ name ] || name;

		// Only do all the following if this is a node (faster for style)
		if ( elem.nodeType === 1 ) {
			// These attributes require special treatment
			var special = rspecialurl.test( name );

			// Safari mis-reports the default selected property of an option
			// Accessing the parent's selectedIndex property fixes it
			if ( name === "selected" && !jomsQuery.support.optSelected ) {
				var parent = elem.parentNode;
				if ( parent ) {
					parent.selectedIndex;
	
					// Make sure that it also works with optgroups, see #5701
					if ( parent.parentNode ) {
						parent.parentNode.selectedIndex;
					}
				}
			}

			// If applicable, access the attribute via the DOM 0 way
			// 'in' checks fail in Blackberry 4.7 #6931
			if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) {
				if ( set ) {
					// We can't allow the type property to be changed (since it causes problems in IE)
					if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
						jomsQuery.error( "type property can't be changed" );
					}

					if ( value === null ) {
						if ( elem.nodeType === 1 ) {
							elem.removeAttribute( name );
						}

					} else {
						elem[ name ] = value;
					}
				}

				// browsers index elements by id/name on forms, give priority to attributes.
				if ( jomsQuery.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 :
						rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
							0 :
							undefined;
				}

				return elem[ name ];
			}

			if ( !jomsQuery.support.style && notxml && name === "style" ) {
				if ( set ) {
					elem.style.cssText = "" + value;
				}

				return elem.style.cssText;
			}

			if ( set ) {
				// convert the value to a string (all browsers do this but IE) see #1070
				elem.setAttribute( name, "" + value );
			}

			// Ensure that missing attributes return undefined
			// Blackberry 4.7 returns "" from getAttribute #6938
			if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {
				return undefined;
			}

			var attr = !jomsQuery.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;
		}
	}
});




var rnamespaces = /\.(.*)$/,
	rformElems = /^(?:textarea|input|select)$/i,
	rperiod = /\./g,
	rspace = / /g,
	rescape = /[^\w\s.|`]/g,
	fcleanup = function( nm ) {
		return nm.replace(rescape, "\\$&");
	},
	focusCounts = { focusin: 0, focusout: 0 };

/*
 * A number of helper functions used for managing events.
 * Many of the ideas behind this code originated from
 * Dean Edwards' addEvent library.
 */
jomsQuery.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 ( jomsQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
			elem = window;
		}

		if ( handler === false ) {
			handler = returnFalse;
		}

		var handleObjIn, handleObj;

		if ( handler.handler ) {
			handleObjIn = handler;
			handler = handleObjIn.handler;
		}

		// Make sure that the function being executed has a unique ID
		if ( !handler.guid ) {
			handler.guid = jomsQuery.guid++;
		}

		// Init the element's event structure
		var elemData = jomsQuery.data( elem );

		// If no elemData is found then we must be trying to bind to one of the
		// banned noData elements
		if ( !elemData ) {
			return;
		}

		// Use a key less likely to result in collisions for plain JS objects.
		// Fixes bug #7150.
		var eventKey = elem.nodeType ? "events" : "__events__",
			events = elemData[ eventKey ],
			eventHandle = elemData.handle;
			
		if ( typeof events === "function" ) {
			// On plain objects events is a fn that holds the the data
			// which prevents this data from being JSON serialized
			// the function does not need to be called, it just contains the data
			eventHandle = events.handle;
			events = events.events;

		} else if ( !events ) {
			if ( !elem.nodeType ) {
				// On plain objects, create a fn that acts as the holder
				// of the values to avoid JSON serialization of event data
				elemData[ eventKey ] = elemData = function(){};
			}

			elemData.events = events = {};
		}

		if ( !eventHandle ) {
			elemData.handle = eventHandle = function() {
				// Handle the second event of a trigger and when
				// an event is called after a page has unloaded
				return typeof jomsQuery !== "undefined" && !jomsQuery.event.triggered ?
					jomsQuery.event.handle.apply( eventHandle.elem, arguments ) :
					undefined;
			};
		}

		// Add elem as a property of the handle function
		// This is to prevent a memory leak with non-native events in IE.
		eventHandle.elem = elem;

		// Handle multiple events separated by a space
		// jomsQuery(...).bind("mouseover mouseout", fn);
		types = types.split(" ");

		var type, i = 0, namespaces;

		while ( (type = types[ i++ ]) ) {
			handleObj = handleObjIn ?
				jomsQuery.extend({}, handleObjIn) :
				{ handler: handler, data: data };

			// Namespaced event handlers
			if ( type.indexOf(".") > -1 ) {
				namespaces = type.split(".");
				type = namespaces.shift();
				handleObj.namespace = namespaces.slice(0).sort().join(".");

			} else {
				namespaces = [];
				handleObj.namespace = "";
			}

			handleObj.type = type;
			if ( !handleObj.guid ) {
				handleObj.guid = handler.guid;
			}

			// Get the current list of functions bound to this event
			var handlers = events[ type ],
				special = jomsQuery.event.special[ type ] || {};

			// 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 ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
					// Bind the global event handler to the element
					if ( elem.addEventListener ) {
						elem.addEventListener( type, eventHandle, false );

					} else if ( elem.attachEvent ) {
						elem.attachEvent( "on" + type, eventHandle );
					}
				}
			}
			
			if ( special.add ) { 
				special.add.call( elem, handleObj ); 

				if ( !handleObj.handler.guid ) {
					handleObj.handler.guid = handler.guid;
				}
			}

			// Add the function to the element's handler list
			handlers.push( handleObj );

			// Keep track of which events have been used, for global triggering
			jomsQuery.event.global[ type ] = true;
		}

		// Nullify elem to prevent memory leaks in IE
		elem = null;
	},

	global: {},

	// Detach an event or set of events from an element
	remove: function( elem, types, handler, pos ) {
		// don't do events on text and comment nodes
		if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
			return;
		}

		if ( handler === false ) {
			handler = returnFalse;
		}

		var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
			eventKey = elem.nodeType ? "events" : "__events__",
			elemData = jomsQuery.data( elem ),
			events = elemData && elemData[ eventKey ];

		if ( !elemData || !events ) {
			return;
		}
		
		if ( typeof events === "function" ) {
			elemData = events;
			events = events.events;
		}

		// types is actually an event object here
		if ( types && types.type ) {
			handler = types.handler;
			types = types.type;
		}

		// Unbind all events for the element
		if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
			types = types || "";

			for ( type in events ) {
				jomsQuery.event.remove( elem, type + types );
			}

			return;
		}

		// Handle multiple events separated by a space
		// jomsQuery(...).unbind("mouseover mouseout", fn);
		types = types.split(" ");

		while ( (type = types[ i++ ]) ) {
			origType = type;
			handleObj = null;
			all = type.indexOf(".") < 0;
			namespaces = [];

			if ( !all ) {
				// Namespaced event handlers
				namespaces = type.split(".");
				type = namespaces.shift();

				namespace = new RegExp("(^|\\.)" + 
					jomsQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
			}

			eventType = events[ type ];

			if ( !eventType ) {
				continue;
			}

			if ( !handler ) {
				for ( j = 0; j < eventType.length; j++ ) {
					handleObj = eventType[ j ];

					if ( all || namespace.test( handleObj.namespace ) ) {
						jomsQuery.event.remove( elem, origType, handleObj.handler, j );
						eventType.splice( j--, 1 );
					}
				}

				continue;
			}

			special = jomsQuery.event.special[ type ] || {};

			for ( j = pos || 0; j < eventType.length; j++ ) {
				handleObj = eventType[ j ];

				if ( handler.guid === handleObj.guid ) {
					// remove the given handler for the given type
					if ( all || namespace.test( handleObj.namespace ) ) {
						if ( pos == null ) {
							eventType.splice( j--, 1 );
						}

						if ( special.remove ) {
							special.remove.call( elem, handleObj );
						}
					}

					if ( pos != null ) {
						break;
					}
				}
			}

			// remove generic event handler if no more handlers exist
			if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
				if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
					jomsQuery.removeEvent( elem, type, elemData.handle );
				}

				ret = null;
				delete events[ type ];
			}
		}

		// Remove the expando if it's no longer used
		if ( jomsQuery.isEmptyObject( events ) ) {
			var handle = elemData.handle;
			if ( handle ) {
				handle.elem = null;
			}

			delete elemData.events;
			delete elemData.handle;

			if ( typeof elemData === "function" ) {
				jomsQuery.removeData( elem, eventKey );

			} else if ( jomsQuery.isEmptyObject( elemData ) ) {
				jomsQuery.removeData( elem );
			}
		}
	},

	// bubbling is internal
	trigger: function( event, data, elem /*, bubbling */ ) {
		// Event object or event type
		var type = event.type || event,
			bubbling = arguments[3];

		if ( !bubbling ) {
			event = typeof event === "object" ?
				// jomsQuery.Event object
				event[ jomsQuery.expando ] ? event :
				// Object literal
				jomsQuery.extend( jomsQuery.Event(type), event ) :
				// Just the event type (string)
				jomsQuery.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 ( jomsQuery.event.global[ type ] ) {
					jomsQuery.each( jomsQuery.cache, function() {
						if ( this.events && this.events[type] ) {
							jomsQuery.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 = jomsQuery.makeArray( data );
			data.unshift( event );
		}

		event.currentTarget = elem;

		// Trigger the event, it is assumed that "handle" is a function
		var handle = elem.nodeType ?
			jomsQuery.data( elem, "handle" ) :
			(jomsQuery.data( elem, "__events__" ) || {}).handle;

		if ( handle ) {
			handle.apply( elem, data );
		}

		var parent = elem.parentNode || elem.ownerDocument;

		// Trigger an inline bound script
		try {
			if ( !(elem && elem.nodeName && jomsQuery.noData[elem.nodeName.toLowerCase()]) ) {
				if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
					event.result = false;
					event.preventDefault();
				}
			}

		// prevent IE from throwing an error for some elements with some event types, see #3533
		} catch (inlineError) {}

		if ( !event.isPropagationStopped() && parent ) {
			jomsQuery.event.trigger( event, data, parent, true );

		} else if ( !event.isDefaultPrevented() ) {
			var target = event.target, old, targetType = type.replace(rnamespaces, ""),
				isClick = jomsQuery.nodeName(target, "a") && targetType === "click",
				special = jomsQuery.event.special[ targetType ] || {};

			if ( (!special._default || special._default.call( elem, event ) === false) && 
				!isClick && !(target && target.nodeName && jomsQuery.noData[target.nodeName.toLowerCase()]) ) {

				try {
					if ( target[ targetType ] ) {
						// Make sure that we don't accidentally re-trigger the onFOO events
						old = target[ "on" + targetType ];

						if ( old ) {
							target[ "on" + targetType ] = null;
						}

						jomsQuery.event.triggered = true;
						target[ targetType ]();
					}

				// prevent IE from throwing an error for some elements with some event types, see #3533
				} catch (triggerError) {}

				if ( old ) {
					target[ "on" + targetType ] = old;
				}

				jomsQuery.event.triggered = false;
			}
		}
	},

	handle: function( event ) {
		var all, handlers, namespaces, namespace_sort = [], namespace_re, events, args = jomsQuery.makeArray( arguments );

		event = args[0] = jomsQuery.event.fix( event || window.event );
		event.currentTarget = this;

		// Namespaced event handlers
		all = event.type.indexOf(".") < 0 && !event.exclusive;

		if ( !all ) {
			namespaces = event.type.split(".");
			event.type = namespaces.shift();
			namespace_sort = namespaces.slice(0).sort();
			namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)");
		}

		event.namespace = event.namespace || namespace_sort.join(".");

		events = jomsQuery.data(this, this.nodeType ? "events" : "__events__");

		if ( typeof events === "function" ) {
			events = events.events;
		}

		handlers = (events || {})[ event.type ];

		if ( events && handlers ) {
			// Clone the handlers to prevent manipulation
			handlers = handlers.slice(0);

			for ( var j = 0, l = handlers.length; j < l; j++ ) {
				var handleObj = handlers[ j ];

				// Filter the functions by class
				if ( all || namespace_re.test( handleObj.namespace ) ) {
					// Pass in a reference to the handler function itself
					// So that we can later remove it
					event.handler = handleObj.handler;
					event.data = handleObj.data;
					event.handleObj = handleObj;
	
					var ret = handleObj.handler.apply( this, args );

					if ( ret !== undefined ) {
						event.result = ret;
						if ( ret === false ) {
							event.preventDefault();
							event.stopPropagation();
						}
					}

					if ( event.isImmediatePropagationStopped() ) {
						break;
					}
				}
			}
		}

		return event.result;
	},

	props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),

	fix: function( event ) {
		if ( event[ jomsQuery.expando ] ) {
			return event;
		}

		// store a copy of the original event object
		// and "clone" to set read-only properties
		var originalEvent = event;
		event = jomsQuery.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 && doc.clientLeft || body && body.clientLeft || 0);
			event.pageY = event.clientY + (doc && doc.scrollTop  || body && body.scrollTop  || 0) - (doc && doc.clientTop  || body && body.clientTop  || 0);
		}

		// Add which for key events
		if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
			event.which = event.charCode != null ? 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 !== undefined ) {
			event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
		}

		return event;
	},

	// Deprecated, use jomsQuery.guid instead
	guid: 1E8,

	// Deprecated, use jomsQuery.proxy instead
	proxy: jomsQuery.proxy,

	special: {
		ready: {
			// Make sure the ready event is setup
			setup: jomsQuery.bindReady,
			teardown: jomsQuery.noop
		},

		live: {
			add: function( handleObj ) {
				jomsQuery.event.add( this,
					liveConvert( handleObj.origType, handleObj.selector ),
					jomsQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); 
			},

			remove: function( handleObj ) {
				jomsQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
			}
		},

		beforeunload: {
			setup: function( data, namespaces, eventHandle ) {
				// We only want to do this special case on windows
				if ( jomsQuery.isWindow( this ) ) {
					this.onbeforeunload = eventHandle;
				}
			},

			teardown: function( namespaces, eventHandle ) {
				if ( this.onbeforeunload === eventHandle ) {
					this.onbeforeunload = null;
				}
			}
		}
	}
};

jomsQuery.removeEvent = document.removeEventListener ?
	function( elem, type, handle ) {
		if ( elem.removeEventListener ) {
			elem.removeEventListener( type, handle, false );
		}
	} : 
	function( elem, type, handle ) {
		if ( elem.detachEvent ) {
			elem.detachEvent( "on" + type, handle );
		}
	};

jomsQuery.Event = function( src ) {
	// Allow instantiation without the 'new' keyword
	if ( !this.preventDefault ) {
		return new jomsQuery.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 = jomsQuery.now();

	// Mark it as fixed
	this[ jomsQuery.expando ] = true;
};

function returnFalse() {
	return false;
}
function returnTrue() {
	return true;
}

// jomsQuery.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
jomsQuery.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)
		} else {
			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 jomsQuery.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;

	// Firefox sometimes assigns relatedTarget a XUL element
	// which we cannot access the parentNode property of
	try {
		// Traverse up the tree
		while ( parent && parent !== this ) {
			parent = parent.parentNode;
		}

		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
			jomsQuery.event.handle.apply( this, arguments );
		}

	// assuming we've left the element since we most likely mousedover a xul element
	} catch(e) { }
},

// In case of event delegation, we only need to rename the event.type,
// liveHandler will take care of the rest.
delegate = function( event ) {
	event.type = event.data;
	jomsQuery.event.handle.apply( this, arguments );
};

// Create mouseenter and mouseleave events
jomsQuery.each({
	mouseenter: "mouseover",
	mouseleave: "mouseout"
}, function( orig, fix ) {
	jomsQuery.event.special[ orig ] = {
		setup: function( data ) {
			jomsQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
		},
		teardown: function( data ) {
			jomsQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
		}
	};
});

// submit delegation
if ( !jomsQuery.support.submitBubbles ) {

	jomsQuery.event.special.submit = {
		setup: function( data, namespaces ) {
			if ( this.nodeName.toLowerCase() !== "form" ) {
				jomsQuery.event.add(this, "click.specialSubmit", function( e ) {
					var elem = e.target, type = elem.type;

					if ( (type === "submit" || type === "image") && jomsQuery( elem ).closest("form").length ) {
						e.liveFired = undefined;
						return trigger( "submit", this, arguments );
					}
				});
	 
				jomsQuery.event.add(this, "keypress.specialSubmit", function( e ) {
					var elem = e.target, type = elem.type;

					if ( (type === "text" || type === "password") && jomsQuery( elem ).closest("form").length && e.keyCode === 13 ) {
						e.liveFired = undefined;
						return trigger( "submit", this, arguments );
					}
				});

			} else {
				return false;
			}
		},

		teardown: function( namespaces ) {
			jomsQuery.event.remove( this, ".specialSubmit" );
		}
	};

}

// change delegation, happens here so we have bind.
if ( !jomsQuery.support.changeBubbles ) {

	var changeFilters,

	getVal = function( elem ) {
		var type = elem.type, val = elem.value;

		if ( type === "radio" || type === "checkbox" ) {
			val = elem.checked;

		} else if ( type === "select-multiple" ) {
			val = elem.selectedIndex > -1 ?
				jomsQuery.map( elem.options, function( elem ) {
					return elem.selected;
				}).join("-") :
				"";

		} else if ( elem.nodeName.toLowerCase() === "select" ) {
			val = elem.selectedIndex;
		}

		return val;
	},

	testChange = function testChange( e ) {
		var elem = e.target, data, val;

		if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
			return;
		}

		data = jomsQuery.data( elem, "_change_data" );
		val = getVal(elem);

		// the current data will be also retrieved by beforeactivate
		if ( e.type !== "focusout" || elem.type !== "radio" ) {
			jomsQuery.data( elem, "_change_data", val );
		}
		
		if ( data === undefined || val === data ) {
			return;
		}

		if ( data != null || val ) {
			e.type = "change";
			e.liveFired = undefined;
			return jomsQuery.event.trigger( e, arguments[1], elem );
		}
	};

	jomsQuery.event.special.change = {
		filters: {
			focusout: testChange, 

			beforedeactivate: testChange,

			click: function( e ) {
				var elem = e.target, type = elem.type;

				if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
					return testChange.call( this, e );
				}
			},

			// Change has to be called before submit
			// Keydown will be called before keypress, which is used in submit-event delegation
			keydown: function( e ) {
				var elem = e.target, type = elem.type;

				if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
					(e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
					type === "select-multiple" ) {
					return testChange.call( this, e );
				}
			},

			// Beforeactivate happens also before the previous element is blurred
			// with this event you can't trigger a change event, but you can store
			// information
			beforeactivate: function( e ) {
				var elem = e.target;
				jomsQuery.data( elem, "_change_data", getVal(elem) );
			}
		},

		setup: function( data, namespaces ) {
			if ( this.type === "file" ) {
				return false;
			}

			for ( var type in changeFilters ) {
				jomsQuery.event.add( this, type + ".specialChange", changeFilters[type] );
			}

			return rformElems.test( this.nodeName );
		},

		teardown: function( namespaces ) {
			jomsQuery.event.remove( this, ".specialChange" );

			return rformElems.test( this.nodeName );
		}
	};

	changeFilters = jomsQuery.event.special.change.filters;

	// Handle when the input is .focus()'d
	changeFilters.focus = changeFilters.beforeactivate;
}

function trigger( type, elem, args ) {
	args[0].type = type;
	return jomsQuery.event.handle.apply( elem, args );
}

// Create "bubbling" focus and blur events
if ( document.addEventListener ) {
	jomsQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
		jomsQuery.event.special[ fix ] = {
			setup: function() {
				if ( focusCounts[fix]++ === 0 ) {
					document.addEventListener( orig, handler, true );
				}
			}, 
			teardown: function() { 
				if ( --focusCounts[fix] === 0 ) {
					document.removeEventListener( orig, handler, true );
				}
			}
		};

		function handler( e ) { 
			e = jomsQuery.event.fix( e );
			e.type = fix;
			return jomsQuery.event.trigger( e, null, e.target );
		}
	});
}

jomsQuery.each(["bind", "one"], function( i, name ) {
	jomsQuery.fn[ name ] = function( type, data, fn ) {
		// Handle object literals
		if ( typeof type === "object" ) {
			for ( var key in type ) {
				this[ name ](key, data, type[key], fn);
			}
			return this;
		}
		
		if ( jomsQuery.isFunction( data ) || data === false ) {
			fn = data;
			data = undefined;
		}

		var handler = name === "one" ? jomsQuery.proxy( fn, function( event ) {
			jomsQuery( this ).unbind( event, handler );
			return fn.apply( this, arguments );
		}) : fn;

		if ( type === "unload" && name !== "one" ) {
			this.one( type, data, fn );

		} else {
			for ( var i = 0, l = this.length; i < l; i++ ) {
				jomsQuery.event.add( this[i], type, handler, data );
			}
		}

		return this;
	};
});

jomsQuery.fn.extend({
	unbind: function( type, fn ) {
		// Handle object literals
		if ( typeof type === "object" && !type.preventDefault ) {
			for ( var key in type ) {
				this.unbind(key, type[key]);
			}

		} else {
			for ( var i = 0, l = this.length; i < l; i++ ) {
				jomsQuery.event.remove( this[i], type, fn );
			}
		}

		return this;
	},
	
	delegate: function( selector, types, data, fn ) {
		return this.live( types, data, fn, selector );
	},
	
	undelegate: function( selector, types, fn ) {
		if ( arguments.length === 0 ) {
				return this.unbind( "live" );
		
		} else {
			return this.die( types, null, fn, selector );
		}
	},
	
	trigger: function( type, data ) {
		return this.each(function() {
			jomsQuery.event.trigger( type, data, this );
		});
	},

	triggerHandler: function( type, data ) {
		if ( this[0] ) {
			var event = jomsQuery.Event( type );
			event.preventDefault();
			event.stopPropagation();
			jomsQuery.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 ) {
			jomsQuery.proxy( fn, args[ i++ ] );
		}

		return this.click( jomsQuery.proxy( fn, function( event ) {
			// Figure out which function to execute
			var lastToggle = ( jomsQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
			jomsQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );

			// Make sure that clicks stop
			event.preventDefault();

			// and execute the function
			return args[ lastToggle ].apply( this, arguments ) || false;
		}));
	},

	hover: function( fnOver, fnOut ) {
		return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
	}
});

var liveMap = {
	focus: "focusin",
	blur: "focusout",
	mouseenter: "mouseover",
	mouseleave: "mouseout"
};

jomsQuery.each(["live", "die"], function( i, name ) {
	jomsQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
		var type, i = 0, match, namespaces, preType,
			selector = origSelector || this.selector,
			context = origSelector ? this : jomsQuery( this.context );
		
		if ( typeof types === "object" && !types.preventDefault ) {
			for ( var key in types ) {
				context[ name ]( key, data, types[key], selector );
			}
			
			return this;
		}

		if ( jomsQuery.isFunction( data ) ) {
			fn = data;
			data = undefined;
		}

		types = (types || "").split(" ");

		while ( (type = types[ i++ ]) != null ) {
			match = rnamespaces.exec( type );
			namespaces = "";

			if ( match )  {
				namespaces = match[0];
				type = type.replace( rnamespaces, "" );
			}

			if ( type === "hover" ) {
				types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
				continue;
			}

			preType = type;

			if ( type === "focus" || type === "blur" ) {
				types.push( liveMap[ type ] + namespaces );
				type = type + namespaces;

			} else {
				type = (liveMap[ type ] || type) + namespaces;
			}

			if ( name === "live" ) {
				// bind live handler
				for ( var j = 0, l = context.length; j < l; j++ ) {
					jomsQuery.event.add( context[j], "live." + liveConvert( type, selector ),
						{ data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
				}

			} else {
				// unbind live handler
				context.unbind( "live." + liveConvert( type, selector ), fn );
			}
		}
		
		return this;
	};
});

function liveHandler( event ) {
	var stop, maxLevel, elems = [], selectors = [],
		related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
		events = jomsQuery.data( this, this.nodeType ? "events" : "__events__" );

	if ( typeof events === "function" ) {
		events = events.events;
	}

	// Make sure we avoid non-left-click bubbling in Firefox (#3861)
	if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) {
		return;
	}

	if ( event.namespace ) {
		namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
	}

	event.liveFired = this;

	var live = events.live.slice(0);

	for ( j = 0; j < live.length; j++ ) {
		handleObj = live[j];

		if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
			selectors.push( handleObj.selector );

		} else {
			live.splice( j--, 1 );
		}
	}

	match = jomsQuery( event.target ).closest( selectors, event.currentTarget );

	for ( i = 0, l = match.length; i < l; i++ ) {
		close = match[i];

		for ( j = 0; j < live.length; j++ ) {
			handleObj = live[j];

			if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) {
				elem = close.elem;
				related = null;

				// Those two events require additional checking
				if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
					event.type = handleObj.preType;
					related = jomsQuery( event.relatedTarget ).closest( handleObj.selector )[0];
				}

				if ( !related || related !== elem ) {
					elems.push({ elem: elem, handleObj: handleObj, level: close.level });
				}
			}
		}
	}

	for ( i = 0, l = elems.length; i < l; i++ ) {
		match = elems[i];

		if ( maxLevel && match.level > maxLevel ) {
			break;
		}

		event.currentTarget = match.elem;
		event.data = match.handleObj.data;
		event.handleObj = match.handleObj;

		ret = match.handleObj.origHandler.apply( match.elem, arguments );

		if ( ret === false || event.isPropagationStopped() ) {
			maxLevel = match.level;

			if ( ret === false ) {
				stop = false;
			}
		}
	}

	return stop;
}

function liveConvert( type, selector ) {
	return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&");
}

jomsQuery.each( ("blur focus focusin focusout 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
	jomsQuery.fn[ name ] = function( data, fn ) {
		if ( fn == null ) {
			fn = data;
			data = null;
		}

		return arguments.length > 0 ?
			this.bind( name, data, fn ) :
			this.trigger( name );
	};

	if ( jomsQuery.attrFn ) {
		jomsQuery.attrFn[ name ] = true;
	}
});

// Prevent memory leaks in IE
// Window isn't included so as not to unbind existing unload events
// More info:
//  - http://isaacschlueter.com/2006/10/msie-memory-leaks/
if ( window.attachEvent && !window.addEventListener ) {
	jomsQuery(window).bind("unload", function() {
		for ( var id in jomsQuery.cache ) {
			if ( jomsQuery.cache[ id ].handle ) {
				// Try/Catch is to handle iframes being unloaded, see #4280
				try {
					jomsQuery.event.remove( jomsQuery.cache[ id ].handle.elem );
				} catch(e) {}
			}
		}
	});
}


/*!
 * Sizzle CSS Selector Engine - v1.0
 *  Copyright 2009, The Dojo Foundation
 *  Released under the MIT, BSD, and GPL Licenses.
 *  More information: http://sizzlejs.com/
 */
(function(){

var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
	done = 0,
	toString = Object.prototype.toString,
	hasDuplicate = false,
	baseHasDuplicate = true;

// Here we check if the JavaScript engine is using some sort of
// optimization where it does not always call our comparision
// function. If that is the case, discard the hasDuplicate value.
//   Thus far that includes Google Chrome.
[0, 0].sort(function(){
	baseHasDuplicate = false;
	return 0;
});

var Sizzle = function(selector, context, results, seed) {
	results = results || [];
	context = context || document;

	var origContext = context;

	if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
		return [];
	}
	
	if ( !selector || typeof selector !== "string" ) {
		return results;
	}

	var parts = [], m, set, checkSet, extra, prune = true, contextXML = Sizzle.isXML(context),
		soFar = selector, ret, cur, pop, i;
	
	// Reset the position of the chunker regexp (start from head)
	do {
		chunker.exec("");
		m = chunker.exec(soFar);

		if ( m ) {
			soFar = m[3];
		
			parts.push( m[1] );
		
			if ( m[2] ) {
				extra = m[3];
				break;
			}
		}
	} while ( m );

	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 {
		// Take a shortcut and set the context if the root selector is an ID
		// (but not if it'll be faster if the inner selector is an ID)
		if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
				Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
			ret = Sizzle.find( parts.shift(), context, contextXML );
			context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
		}

		if ( context ) {
			ret = seed ?
				{ expr: parts.pop(), set: makeArray(seed) } :
				Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
			set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;

			if ( parts.length > 0 ) {
				checkSet = makeArray(set);
			} else {
				prune = false;
			}

			while ( parts.length ) {
				cur = parts.pop();
				pop = cur;

				if ( !Expr.relative[ cur ] ) {
					cur = "";
				} else {
					pop = parts.pop();
				}

				if ( pop == null ) {
					pop = context;
				}

				Expr.relative[ cur ]( checkSet, pop, contextXML );
			}
		} else {
			checkSet = parts = [];
		}
	}

	if ( !checkSet ) {
		checkSet = set;
	}

	if ( !checkSet ) {
		Sizzle.error( cur || selector );
	}

	if ( toString.call(checkSet) === "[object Array]" ) {
		if ( !prune ) {
			results.push.apply( results, checkSet );
		} else if ( context && context.nodeType === 1 ) {
			for ( i = 0; checkSet[i] != null; i++ ) {
				if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
					results.push( set[i] );
				}
			}
		} else {
			for ( 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, origContext, results, seed );
		Sizzle.uniqueSort( results );
	}

	return results;
};

Sizzle.uniqueSort = function(results){
	if ( sortOrder ) {
		hasDuplicate = baseHasDuplicate;
		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.matchesSelector = function(node, expr){
	return Sizzle(expr, null, null, [node]).length > 0;
};

Sizzle.find = function(expr, context, isXML){
	var set;

	if ( !expr ) {
		return [];
	}

	for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
		var type = Expr.order[i], match;
		
		if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
			var left = match[1];
			match.splice(1,1);

			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] && Sizzle.isXML(set[0]);

	while ( expr && set.length ) {
		for ( var type in Expr.filter ) {
			if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
				var filter = Expr.filter[ type ], found, item, left = match[1];
				anyFound = false;

				match.splice(1,1);

				if ( left.substr( left.length - 1 ) === "\\" ) {
					continue;
				}

				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 ) {
				Sizzle.error( expr );
			} else {
				break;
			}
		}

		old = expr;
	}

	return curLoop;
};

Sizzle.error = function( msg ) {
	throw "Syntax error, unrecognized expression: " + msg;
};

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\))?/
	},
	leftMatch: {},
	attrMap: {
		"class": "className",
		"for": "htmlFor"
	},
	attrHandle: {
		href: function(elem){
			return elem.getAttribute("href");
		}
	},
	relative: {
		"+": function(checkSet, part){
			var isPartStr = typeof part === "string",
				isTag = isPartStr && !/\W/.test(part),
				isPartStrNotTag = isPartStr && !isTag;

			if ( isTag ) {
				part = part.toLowerCase();
			}

			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.toLowerCase() === part ?
						elem || false :
						elem === part;
				}
			}

			if ( isPartStrNotTag ) {
				Sizzle.filter( part, checkSet, true );
			}
		},
		">": function(checkSet, part){
			var isPartStr = typeof part === "string",
				elem, i = 0, l = checkSet.length;

			if ( isPartStr && !/\W/.test(part) ) {
				part = part.toLowerCase();

				for ( ; i < l; i++ ) {
					elem = checkSet[i];
					if ( elem ) {
						var parent = elem.parentNode;
						checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
					}
				}
			} else {
				for ( ; i < l; i++ ) {
					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, nodeCheck;

			if ( typeof part === "string" && !/\W/.test(part) ) {
				part = part.toLowerCase();
				nodeCheck = part;
				checkFn = dirNodeCheck;
			}

			checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
		},
		"~": function(checkSet, part, isXML){
			var doneName = done++, checkFn = dirCheck, nodeCheck;

			if ( typeof part === "string" && !/\W/.test(part) ) {
				part = part.toLowerCase();
				nodeCheck = part;
				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]);
				// Check parentNode to catch when Blackberry 4.6 returns
				// nodes that are no longer in the document #6963
				return m && m.parentNode ? [m] : [];
			}
		},
		NAME: function(match, context){
			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 + " ").replace(/[\t\n]/g, " ").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){
			return match[1].toLowerCase();
		},
		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 ( ( chunker.exec(match[3]) || "" ).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.toLowerCase() === "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 || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
			} else if ( name === "not" ) {
				var not = match[3];

				for ( var j = 0, l = not.length; j < l; j++ ) {
					if ( not[j] === elem ) {
						return false;
					}
				}

				return true;
			} else {
				Sizzle.error( "Syntax error, unrecognized expression: " + name );
			}
		},
		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.toLowerCase() === 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,
	fescape = function(all, num){
		return "\\" + (num - 0 + 1);
	};

for ( var type in Expr.match ) {
	Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
	Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
}

var makeArray = function(array, results) {
	array = Array.prototype.slice.call( array, 0 );

	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.
// Also verifies that the returned array holds DOM nodes
// (which is not the case in the Blackberry browser)
try {
	Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;

// Provide a fallback method if it does not work
} catch(e){
	makeArray = function(array, results) {
		var ret = results || [], i = 0;

		if ( toString.call(array) === "[object Array]" ) {
			Array.prototype.push.apply( ret, array );
		} else {
			if ( typeof array.length === "number" ) {
				for ( var l = array.length; i < l; i++ ) {
					ret.push( array[i] );
				}
			} else {
				for ( ; array[i]; i++ ) {
					ret.push( array[i] );
				}
			}
		}

		return ret;
	};
}

var sortOrder, siblingCheck;

if ( document.documentElement.compareDocumentPosition ) {
	sortOrder = function( a, b ) {
		if ( a === b ) {
			hasDuplicate = true;
			return 0;
		}

		if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
			return a.compareDocumentPosition ? -1 : 1;
		}

		return a.compareDocumentPosition(b) & 4 ? -1 : 1;
	};
} else {
	sortOrder = function( a, b ) {
		var ap = [], bp = [], aup = a.parentNode, bup = b.parentNode,
			cur = aup, al, bl;

		// The nodes are identical, we can exit early
		if ( a === b ) {
			hasDuplicate = true;
			return 0;

		// If the nodes are siblings (or identical) we can do a quick check
		} else if ( aup === bup ) {
			return siblingCheck( a, b );

		// If no parents were found then the nodes are disconnected
		} else if ( !aup ) {
			return -1;

		} else if ( !bup ) {
			return 1;
		}

		// Otherwise they're somewhere else in the tree so we need
		// to build up a full list of the parentNodes for comparison
		while ( cur ) {
			ap.unshift( cur );
			cur = cur.parentNode;
		}

		cur = bup;

		while ( cur ) {
			bp.unshift( cur );
			cur = cur.parentNode;
		}

		al = ap.length;
		bl = bp.length;

		// Start walking down the tree looking for a discrepancy
		for ( var i = 0; i < al && i < bl; i++ ) {
			if ( ap[i] !== bp[i] ) {
				return siblingCheck( ap[i], bp[i] );
			}
		}

		// We ended someplace up the tree so do a sibling check
		return i === al ?
			siblingCheck( a, bp[i], -1 ) :
			siblingCheck( ap[i], b, 1 );
	};

	siblingCheck = function( a, b, ret ) {
		if ( a === b ) {
			return ret;
		}

		var cur = a.nextSibling;

		while ( cur ) {
			if ( cur === b ) {
				return -1;
			}

			cur = cur.nextSibling;
		}

		return 1;
	};
}

// Utility function for retreiving the text value of an array of DOM nodes
Sizzle.getText = function( elems ) {
	var ret = "", elem;

	for ( var i = 0; elems[i]; i++ ) {
		elem = elems[i];

		// Get the text from text nodes and CDATA nodes
		if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
			ret += elem.nodeValue;

		// Traverse everything else, except comment nodes
		} else if ( elem.nodeType !== 8 ) {
			ret += Sizzle.getText( elem.childNodes );
		}
	}

	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("div"),
		id = "script" + (new Date()).getTime();
	form.innerHTML = "<a 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 );
	root = form = null; // release memory in IE
})();

(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);
		};
	}

	div = null; // release memory in IE
})();

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 && !Sizzle.isXML(context) ) {
				if ( context.nodeType === 9 ) {
					try {
						return makeArray( context.querySelectorAll(query), extra );
					} catch(qsaError) {}

				// qSA works strangely on Element-rooted queries
				// We can work around this by specifying an extra ID on the root
				// and working up from there (Thanks to Andrew Dupont for the technique)
				// IE 8 doesn't work on object elements
				} else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
					var old = context.id, id = context.id = "__sizzle__";

					try {
						return makeArray( context.querySelectorAll( "#" + id + " " + query ), extra );

					} catch(pseudoError) {
					} finally {
						if ( old ) {
							context.id = old;

						} else {
							context.removeAttribute( "id" );
						}
					}
				}
			}
		
			return oldSizzle(query, context, extra, seed);
		};

		for ( var prop in oldSizzle ) {
			Sizzle[ prop ] = oldSizzle[ prop ];
		}

		div = null; // release memory in IE
	})();
}

(function(){
	var html = document.documentElement,
		matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector,
		pseudoWorks = false;

	try {
		// This should fail with an exception
		// Gecko does not error, returns false instead
		matches.call( document.documentElement, ":sizzle" );
	
	} catch( pseudoError ) {
		pseudoWorks = true;
	}

	if ( matches ) {
		Sizzle.matchesSelector = function( node, expr ) {
				try { 
					if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) ) {
						return matches.call( node, expr );
					}
				} catch(e) {}

				return Sizzle(expr, null, null, [node]).length > 0;
		};
	}
})();

(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)
	// Also, make sure that getElementsByClassName actually exists
	if ( !div.getElementsByClassName || 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]);
		}
	};

	div = null; // release memory in IE
})();

function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
	for ( var i = 0, l = checkSet.length; i < l; i++ ) {
		var elem = checkSet[i];
		if ( elem ) {
			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.toLowerCase() === cur ) {
					match = elem;
					break;
				}

				elem = elem[dir];
			}

			checkSet[i] = match;
		}
	}
}

function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
	for ( var i = 0, l = checkSet.length; i < l; i++ ) {
		var elem = checkSet[i];
		if ( elem ) {
			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;
		}
	}
}

Sizzle.contains = document.documentElement.contains ? function(a, b){
	return a !== b && (a.contains ? a.contains(b) : true);
} : function(a, b){
	return !!(a.compareDocumentPosition(b) & 16);
};

Sizzle.isXML = function(elem){
	// documentElement is verified for cases where it doesn't yet exist
	// (such as loading iframes in IE - #4833) 
	var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
	return documentElement ? documentElement.nodeName !== "HTML" : false;
};

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
jomsQuery.find = Sizzle;
jomsQuery.expr = Sizzle.selectors;
jomsQuery.expr[":"] = jomsQuery.expr.filters;
jomsQuery.unique = Sizzle.uniqueSort;
jomsQuery.text = Sizzle.getText;
jomsQuery.isXMLDoc = Sizzle.isXML;
jomsQuery.contains = Sizzle.contains;


})();


var runtil = /Until$/,
	rparentsprev = /^(?:parents|prevUntil|prevAll)/,
	// Note: This RegExp should be improved, or likely pulled from Sizzle
	rmultiselector = /,/,
	isSimple = /^.[^:#\[\.,]*$/,
	slice = Array.prototype.slice,
	POS = jomsQuery.expr.match.POS;

jomsQuery.fn.extend({
	find: function( selector ) {
		var ret = this.pushStack( "", "find", selector ), length = 0;

		for ( var i = 0, l = this.length; i < l; i++ ) {
			length = ret.length;
			jomsQuery.find( selector, this[i], ret );

			if ( i > 0 ) {
				// Make sure that the results are unique
				for ( var n = length; n < ret.length; n++ ) {
					for ( var r = 0; r < length; r++ ) {
						if ( ret[r] === ret[n] ) {
							ret.splice(n--, 1);
							break;
						}
					}
				}
			}
		}

		return ret;
	},

	has: function( target ) {
		var targets = jomsQuery( target );
		return this.filter(function() {
			for ( var i = 0, l = targets.length; i < l; i++ ) {
				if ( jomsQuery.contains( this, targets[i] ) ) {
					return true;
				}
			}
		});
	},

	not: function( selector ) {
		return this.pushStack( winnow(this, selector, false), "not", selector);
	},

	filter: function( selector ) {
		return this.pushStack( winnow(this, selector, true), "filter", selector );
	},
	
	is: function( selector ) {
		return !!selector && jomsQuery.filter( selector, this ).length > 0;
	},

	closest: function( selectors, context ) {
		var ret = [], i, l, cur = this[0];

		if ( jomsQuery.isArray( selectors ) ) {
			var match, matches = {}, selector, level = 1;

			if ( cur && selectors.length ) {
				for ( i = 0, l = selectors.length; i < l; i++ ) {
					selector = selectors[i];

					if ( !matches[selector] ) {
						matches[selector] = jomsQuery.expr.match.POS.test( selector ) ? 
							jomsQuery( selector, context || this.context ) :
							selector;
					}
				}

				while ( cur && cur.ownerDocument && cur !== context ) {
					for ( selector in matches ) {
						match = matches[selector];

						if ( match.jomsQuery ? match.index(cur) > -1 : jomsQuery(cur).is(match) ) {
							ret.push({ selector: selector, elem: cur, level: level });
						}
					}

					cur = cur.parentNode;
					level++;
				}
			}

			return ret;
		}

		var pos = POS.test( selectors ) ? 
			jomsQuery( selectors, context || this.context ) : null;

		for ( i = 0, l = this.length; i < l; i++ ) {
			cur = this[i];

			while ( cur ) {
				if ( pos ? pos.index(cur) > -1 : jomsQuery.find.matchesSelector(cur, selectors) ) {
					ret.push( cur );
					break;

				} else {
					cur = cur.parentNode;
					if ( !cur || !cur.ownerDocument || cur === context ) {
						break;
					}
				}
			}
		}

		ret = ret.length > 1 ? jomsQuery.unique(ret) : ret;
		
		return this.pushStack( ret, "closest", selectors );
	},
	
	// Determine the position of an element within
	// the matched set of elements
	index: function( elem ) {
		if ( !elem || typeof elem === "string" ) {
			return jomsQuery.inArray( this[0],
				// If it receives a string, the selector is used
				// If it receives nothing, the siblings are used
				elem ? jomsQuery( elem ) : this.parent().children() );
		}
		// Locate the position of the desired element
		return jomsQuery.inArray(
			// If it receives a jomsQuery object, the first element is used
			elem.jomsQuery ? elem[0] : elem, this );
	},

	add: function( selector, context ) {
		var set = typeof selector === "string" ?
				jomsQuery( selector, context || this.context ) :
				jomsQuery.makeArray( selector ),
			all = jomsQuery.merge( this.get(), set );

		return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
			all :
			jomsQuery.unique( all ) );
	},

	andSelf: function() {
		return this.add( this.prevObject );
	}
});

// A painfully simple check to see if an element is disconnected
// from a document (should be improved, where feasible).
function isDisconnected( node ) {
	return !node || !node.parentNode || node.parentNode.nodeType === 11;
}

jomsQuery.each({
	parent: function( elem ) {
		var parent = elem.parentNode;
		return parent && parent.nodeType !== 11 ? parent : null;
	},
	parents: function( elem ) {
		return jomsQuery.dir( elem, "parentNode" );
	},
	parentsUntil: function( elem, i, until ) {
		return jomsQuery.dir( elem, "parentNode", until );
	},
	next: function( elem ) {
		return jomsQuery.nth( elem, 2, "nextSibling" );
	},
	prev: function( elem ) {
		return jomsQuery.nth( elem, 2, "previousSibling" );
	},
	nextAll: function( elem ) {
		return jomsQuery.dir( elem, "nextSibling" );
	},
	prevAll: function( elem ) {
		return jomsQuery.dir( elem, "previousSibling" );
	},
	nextUntil: function( elem, i, until ) {
		return jomsQuery.dir( elem, "nextSibling", until );
	},
	prevUntil: function( elem, i, until ) {
		return jomsQuery.dir( elem, "previousSibling", until );
	},
	siblings: function( elem ) {
		return jomsQuery.sibling( elem.parentNode.firstChild, elem );
	},
	children: function( elem ) {
		return jomsQuery.sibling( elem.firstChild );
	},
	contents: function( elem ) {
		return jomsQuery.nodeName( elem, "iframe" ) ?
			elem.contentDocument || elem.contentWindow.document :
			jomsQuery.makeArray( elem.childNodes );
	}
}, function( name, fn ) {
	jomsQuery.fn[ name ] = function( until, selector ) {
		var ret = jomsQuery.map( this, fn, until );
		
		if ( !runtil.test( name ) ) {
			selector = until;
		}

		if ( selector && typeof selector === "string" ) {
			ret = jomsQuery.filter( selector, ret );
		}

		ret = this.length > 1 ? jomsQuery.unique( ret ) : ret;

		if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
			ret = ret.reverse();
		}

		return this.pushStack( ret, name, slice.call(arguments).join(",") );
	};
});

jomsQuery.extend({
	filter: function( expr, elems, not ) {
		if ( not ) {
			expr = ":not(" + expr + ")";
		}

		return elems.length === 1 ?
			jomsQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
			jomsQuery.find.matches(expr, elems);
	},
	
	dir: function( elem, dir, until ) {
		var matched = [], cur = elem[dir];
		while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jomsQuery( cur ).is( until )) ) {
			if ( cur.nodeType === 1 ) {
				matched.push( cur );
			}
			cur = cur[dir];
		}
		return matched;
	},

	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;
	},

	sibling: function( n, elem ) {
		var r = [];

		for ( ; n; n = n.nextSibling ) {
			if ( n.nodeType === 1 && n !== elem ) {
				r.push( n );
			}
		}

		return r;
	}
});

// Implement the identical functionality for filter and not
function winnow( elements, qualifier, keep ) {
	if ( jomsQuery.isFunction( qualifier ) ) {
		return jomsQuery.grep(elements, function( elem, i ) {
			var retVal = !!qualifier.call( elem, i, elem );
			return retVal === keep;
		});

	} else if ( qualifier.nodeType ) {
		return jomsQuery.grep(elements, function( elem, i ) {
			return (elem === qualifier) === keep;
		});

	} else if ( typeof qualifier === "string" ) {
		var filtered = jomsQuery.grep(elements, function( elem ) {
			return elem.nodeType === 1;
		});

		if ( isSimple.test( qualifier ) ) {
			return jomsQuery.filter(qualifier, filtered, !keep);
		} else {
			qualifier = jomsQuery.filter( qualifier, filtered );
		}
	}

	return jomsQuery.grep(elements, function( elem, i ) {
		return (jomsQuery.inArray( elem, qualifier ) >= 0) === keep;
	});
}




var rinlinejomsQuery = / jomsQuery\d+="(?:\d+|null)"/g,
	rleadingWhitespace = /^\s+/,
	rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
	rtagName = /<([\w:]+)/,
	rtbody = /<tbody/i,
	rhtml = /<|&#?\w+;/,
	rnocache = /<(?:script|object|embed|option|style)/i,
	rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,  // checked="checked" or checked (html5)
	raction = /\=([^="'>\s]+\/)>/g,
	wrapMap = {
		option: [ 1, "<select multiple='multiple'>", "</select>" ],
		legend: [ 1, "<fieldset>", "</fieldset>" ],
		thead: [ 1, "<table>", "</table>" ],
		tr: [ 2, "<table><tbody>", "</tbody></table>" ],
		td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
		col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
		area: [ 1, "<map>", "</map>" ],
		_default: [ 0, "", "" ]
	};

wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;

// IE can't serialize <link> and <script> tags normally
if ( !jomsQuery.support.htmlSerialize ) {
	wrapMap._default = [ 1, "div<div>", "</div>" ];
}

jomsQuery.fn.extend({
	text: function( text ) {
		if ( jomsQuery.isFunction(text) ) {
			return this.each(function(i) {
				var self = jomsQuery(this);
				self.text( text.call(this, i, self.text()) );
			});
		}

		if ( typeof text !== "object" && text !== undefined ) {
			return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
		}

		return jomsQuery.text( this );
	},

	wrapAll: function( html ) {
		if ( jomsQuery.isFunction( html ) ) {
			return this.each(function(i) {
				jomsQuery(this).wrapAll( html.call(this, i) );
			});
		}

		if ( this[0] ) {
			// The elements to wrap the target around
			var wrap = jomsQuery( html, this[0].ownerDocument ).eq(0).clone(true);

			if ( this[0].parentNode ) {
				wrap.insertBefore( this[0] );
			}

			wrap.map(function() {
				var elem = this;

				while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
					elem = elem.firstChild;
				}

				return elem;
			}).append(this);
		}

		return this;
	},

	wrapInner: function( html ) {
		if ( jomsQuery.isFunction( html ) ) {
			return this.each(function(i) {
				jomsQuery(this).wrapInner( html.call(this, i) );
			});
		}

		return this.each(function() {
			var self = jomsQuery( this ), contents = self.contents();

			if ( contents.length ) {
				contents.wrapAll( html );

			} else {
				self.append( html );
			}
		});
	},

	wrap: function( html ) {
		return this.each(function() {
			jomsQuery( this ).wrapAll( html );
		});
	},

	unwrap: function() {
		return this.parent().each(function() {
			if ( !jomsQuery.nodeName( this, "body" ) ) {
				jomsQuery( this ).replaceWith( this.childNodes );
			}
		}).end();
	},

	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() {
		if ( this[0] && this[0].parentNode ) {
			return this.domManip(arguments, false, function( elem ) {
				this.parentNode.insertBefore( elem, this );
			});
		} else if ( arguments.length ) {
			var set = jomsQuery(arguments[0]);
			set.push.apply( set, this.toArray() );
			return this.pushStack( set, "before", arguments );
		}
	},

	after: function() {
		if ( this[0] && this[0].parentNode ) {
			return this.domManip(arguments, false, function( elem ) {
				this.parentNode.insertBefore( elem, this.nextSibling );
			});
		} else if ( arguments.length ) {
			var set = this.pushStack( this, "after", arguments );
			set.push.apply( set, jomsQuery(arguments[0]).toArray() );
			return set;
		}
	},
	
	// keepData is for internal use only--do not document
	remove: function( selector, keepData ) {
		for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
			if ( !selector || jomsQuery.filter( selector, [ elem ] ).length ) {
				if ( !keepData && elem.nodeType === 1 ) {
					jomsQuery.cleanData( elem.getElementsByTagName("*") );
					jomsQuery.cleanData( [ elem ] );
				}

				if ( elem.parentNode ) {
					 elem.parentNode.removeChild( elem );
				}
			}
		}
		
		return this;
	},

	empty: function() {
		for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
			// Remove element nodes and prevent memory leaks
			if ( elem.nodeType === 1 ) {
				jomsQuery.cleanData( elem.getElementsByTagName("*") );
			}

			// Remove any remaining nodes
			while ( elem.firstChild ) {
				elem.removeChild( elem.firstChild );
			}
		}
		
		return this;
	},

	clone: function( events ) {
		// Do the clone
		var ret = this.map(function() {
			if ( !jomsQuery.support.noCloneEvent && !jomsQuery.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, ownerDocument = this.ownerDocument;
				if ( !html ) {
					var div = ownerDocument.createElement("div");
					div.appendChild( this.cloneNode(true) );
					html = div.innerHTML;
				}

				return jomsQuery.clean([html.replace(rinlinejomsQuery, "")
					// Handle the case in IE 8 where action=/test/> self-closes a tag
					.replace(raction, '="$1">')
					.replace(rleadingWhitespace, "")], ownerDocument)[0];
			} else {
				return this.cloneNode(true);
			}
		});

		// Copy the events from the original to the clone
		if ( events === true ) {
			cloneCopyEvent( this, ret );
			cloneCopyEvent( this.find("*"), ret.find("*") );
		}

		// Return the cloned set
		return ret;
	},

	html: function( value ) {
		if ( value === undefined ) {
			return this[0] && this[0].nodeType === 1 ?
				this[0].innerHTML.replace(rinlinejomsQuery, "") :
				null;

		// See if we can take a shortcut and just use innerHTML
		} else if ( typeof value === "string" && !rnocache.test( value ) &&
			(jomsQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
			!wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {

			value = value.replace(rxhtmlTag, "<$1></$2>");

			try {
				for ( var i = 0, l = this.length; i < l; i++ ) {
					// Remove element nodes and prevent memory leaks
					if ( this[i].nodeType === 1 ) {
						jomsQuery.cleanData( this[i].getElementsByTagName("*") );
						this[i].innerHTML = value;
					}
				}

			// If using innerHTML throws an exception, use the fallback method
			} catch(e) {
				this.empty().append( value );
			}

		} else if ( jomsQuery.isFunction( value ) ) {
			this.each(function(i){
				var self = jomsQuery(this);
				self.html( value.call(this, i, self.html()) );
			});

		} else {
			this.empty().append( value );
		}

		return this;
	},

	replaceWith: function( value ) {
		if ( this[0] && this[0].parentNode ) {
			// Make sure that the elements are removed from the DOM before they are inserted
			// this can help fix replacing a parent with child elements
			if ( jomsQuery.isFunction( value ) ) {
				return this.each(function(i) {
					var self = jomsQuery(this), old = self.html();
					self.replaceWith( value.call( this, i, old ) );
				});
			}

			if ( typeof value !== "string" ) {
				value = jomsQuery(value).detach();
			}

			return this.each(function() {
				var next = this.nextSibling, parent = this.parentNode;

				jomsQuery(this).remove();

				if ( next ) {
					jomsQuery(next).before( value );
				} else {
					jomsQuery(parent).append( value );
				}
			});
		} else {
			return this.pushStack( jomsQuery(jomsQuery.isFunction(value) ? value() : value), "replaceWith", value );
		}
	},

	detach: function( selector ) {
		return this.remove( selector, true );
	},

	domManip: function( args, table, callback ) {
		var results, first, value = args[0], scripts = [], fragment, parent;

		// We can't cloneNode fragments that contain checked, in WebKit
		if ( !jomsQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
			return this.each(function() {
				jomsQuery(this).domManip( args, table, callback, true );
			});
		}

		if ( jomsQuery.isFunction(value) ) {
			return this.each(function(i) {
				var self = jomsQuery(this);
				args[0] = value.call(this, i, table ? self.html() : undefined);
				self.domManip( args, table, callback );
			});
		}

		if ( this[0] ) {
			parent = value && value.parentNode;

			// If we're in a fragment, just use that instead of building a new one
			if ( jomsQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
				results = { fragment: parent };

			} else {
				results = jomsQuery.buildFragment( args, this, scripts );
			}
			
			fragment = results.fragment;
			
			if ( fragment.childNodes.length === 1 ) {
				first = fragment = fragment.firstChild;
			} else {
				first = fragment.firstChild;
			}

			if ( first ) {
				table = table && jomsQuery.nodeName( first, "tr" );

				for ( var i = 0, l = this.length; i < l; i++ ) {
					callback.call(
						table ?
							root(this[i], first) :
							this[i],
						i > 0 || results.cacheable || this.length > 1  ?
							fragment.cloneNode(true) :
							fragment
					);
				}
			}

			if ( scripts.length ) {
				jomsQuery.each( scripts, evalScript );
			}
		}

		return this;
	}
});

function root( elem, cur ) {
	return jomsQuery.nodeName(elem, "table") ?
		(elem.getElementsByTagName("tbody")[0] ||
		elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
		elem;
}

function cloneCopyEvent(orig, ret) {
	var i = 0;

	ret.each(function() {
		if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
			return;
		}

		var oldData = jomsQuery.data( orig[i++] ), curData = jomsQuery.data( this, oldData ), events = oldData && oldData.events;

		if ( events ) {
			delete curData.handle;
			curData.events = {};

			for ( var type in events ) {
				for ( var handler in events[ type ] ) {
					jomsQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
				}
			}
		}
	});
}

jomsQuery.buildFragment = function( args, nodes, scripts ) {
	var fragment, cacheable, cacheresults,
		doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);

	// Only cache "small" (1/2 KB) strings that are associated with the main document
	// Cloning options loses the selected state, so don't cache them
	// IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
	// Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
	if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
		!rnocache.test( args[0] ) && (jomsQuery.support.checkClone || !rchecked.test( args[0] )) ) {

		cacheable = true;
		cacheresults = jomsQuery.fragments[ args[0] ];
		if ( cacheresults ) {
			if ( cacheresults !== 1 ) {
				fragment = cacheresults;
			}
		}
	}

	if ( !fragment ) {
		fragment = doc.createDocumentFragment();
		jomsQuery.clean( args, doc, fragment, scripts );
	}

	if ( cacheable ) {
		jomsQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
	}

	return { fragment: fragment, cacheable: cacheable };
};

jomsQuery.fragments = {};

jomsQuery.each({
	appendTo: "append",
	prependTo: "prepend",
	insertBefore: "before",
	insertAfter: "after",
	replaceAll: "replaceWith"
}, function( name, original ) {
	jomsQuery.fn[ name ] = function( selector ) {
		var ret = [], insert = jomsQuery( selector ),
			parent = this.length === 1 && this[0].parentNode;
		
		if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
			insert[ original ]( this[0] );
			return this;
			
		} else {
			for ( var i = 0, l = insert.length; i < l; i++ ) {
				var elems = (i > 0 ? this.clone(true) : this).get();
				jomsQuery( insert[i] )[ original ]( elems );
				ret = ret.concat( elems );
			}
		
			return this.pushStack( ret, name, insert.selector );
		}
	};
});

jomsQuery.extend({
	clean: function( elems, context, fragment, scripts ) {
		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;
		}

		var ret = [];

		for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
			if ( typeof elem === "number" ) {
				elem += "";
			}

			if ( !elem ) {
				continue;
			}

			// Convert html string into DOM nodes
			if ( typeof elem === "string" && !rhtml.test( elem ) ) {
				elem = context.createTextNode( elem );

			} else if ( typeof elem === "string" ) {
				// Fix "XHTML"-style tags in all browsers
				elem = elem.replace(rxhtmlTag, "<$1></$2>");

				// Trim whitespace, otherwise indexOf won't work as expected
				var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
					wrap = wrapMap[ tag ] || wrapMap._default,
					depth = wrap[0],
					div = context.createElement("div");

				// Go to html and back, then peel off extra wrappers
				div.innerHTML = wrap[1] + elem + wrap[2];

				// Move to the right depth
				while ( depth-- ) {
					div = div.lastChild;
				}

				// Remove IE's autoinserted <tbody> from table fragments
				if ( !jomsQuery.support.tbody ) {

					// String was a <table>, *may* have spurious <tbody>
					var hasBody = rtbody.test(elem),
						tbody = tag === "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 ( jomsQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
							tbody[ j ].parentNode.removeChild( tbody[ j ] );
						}
					}

				}

				// IE completely kills leading whitespace when innerHTML is used
				if ( !jomsQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
					div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
				}

				elem = div.childNodes;
			}

			if ( elem.nodeType ) {
				ret.push( elem );
			} else {
				ret = jomsQuery.merge( ret, elem );
			}
		}

		if ( fragment ) {
			for ( i = 0; ret[i]; i++ ) {
				if ( scripts && jomsQuery.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(jomsQuery.makeArray(ret[i].getElementsByTagName("script"))) );
					}
					fragment.appendChild( ret[i] );
				}
			}
		}

		return ret;
	},
	
	cleanData: function( elems ) {
		var data, id, cache = jomsQuery.cache,
			special = jomsQuery.event.special,
			deleteExpando = jomsQuery.support.deleteExpando;
		
		for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
			if ( elem.nodeName && jomsQuery.noData[elem.nodeName.toLowerCase()] ) {
				continue;
			}

			id = elem[ jomsQuery.expando ];
			
			if ( id ) {
				data = cache[ id ];
				
				if ( data && data.events ) {
					for ( var type in data.events ) {
						if ( special[ type ] ) {
							jomsQuery.event.remove( elem, type );

						} else {
							jomsQuery.removeEvent( elem, type, data.handle );
						}
					}
				}
				
				if ( deleteExpando ) {
					delete elem[ jomsQuery.expando ];

				} else if ( elem.removeAttribute ) {
					elem.removeAttribute( jomsQuery.expando );
				}
				
				delete cache[ id ];
			}
		}
	}
});

function evalScript( i, elem ) {
	if ( elem.src ) {
		jomsQuery.ajax({
			url: elem.src,
			async: false,
			dataType: "script"
		});
	} else {
		jomsQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
	}

	if ( elem.parentNode ) {
		elem.parentNode.removeChild( elem );
	}
}




var ralpha = /alpha\([^)]*\)/i,
	ropacity = /opacity=([^)]*)/,
	rdashAlpha = /-([a-z])/ig,
	rupper = /([A-Z])/g,
	rnumpx = /^-?\d+(?:px)?$/i,
	rnum = /^-?\d/,

	cssShow = { position: "absolute", visibility: "hidden", display: "block" },
	cssWidth = [ "Left", "Right" ],
	cssHeight = [ "Top", "Bottom" ],
	curCSS,

	// cache check for defaultView.getComputedStyle
	getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,

	fcamelCase = function( all, letter ) {
		return letter.toUpperCase();
	};

jomsQuery.fn.css = function( name, value ) {
	// Setting 'undefined' is a no-op
	if ( arguments.length === 2 && value === undefined ) {
		return this;
	}

	return jomsQuery.access( this, name, value, true, function( elem, name, value ) {
		return value !== undefined ?
			jomsQuery.style( elem, name, value ) :
			jomsQuery.css( elem, name );
	});
};

jomsQuery.extend({
	// Add in style property hooks for overriding the default
	// behavior of getting and setting a style property
	cssHooks: {
		opacity: {
			get: function( elem, computed ) {
				if ( computed ) {
					// We should always get a number back from opacity
					var ret = curCSS( elem, "opacity", "opacity" );
					return ret === "" ? "1" : ret;

				} else {
					return elem.style.opacity;
				}
			}
		}
	},

	// Exclude the following css properties to add px
	cssNumber: {
		"zIndex": true,
		"fontWeight": true,
		"opacity": true,
		"zoom": true,
		"lineHeight": true
	},

	// Add in properties whose names you wish to fix before
	// setting or getting the value
	cssProps: {
		// normalize float css property
		"float": jomsQuery.support.cssFloat ? "cssFloat" : "styleFloat"
	},

	// Get and set the style property on a DOM Node
	style: function( elem, name, value, extra ) {
		// Don't set styles on text and comment nodes
		if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
			return;
		}

		// Make sure that we're working with the right name
		var ret, origName = jomsQuery.camelCase( name ),
			style = elem.style, hooks = jomsQuery.cssHooks[ origName ];

		name = jomsQuery.cssProps[ origName ] || origName;

		// Check if we're setting a value
		if ( value !== undefined ) {
			// Make sure that NaN and null values aren't set. See: #7116
			if ( typeof value === "number" && isNaN( value ) || value == null ) {
				return;
			}

			// If a number was passed in, add 'px' to the (except for certain CSS properties)
			if ( typeof value === "number" && !jomsQuery.cssNumber[ origName ] ) {
				value += "px";
			}

			// If a hook was provided, use that value, otherwise just set the specified value
			if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
				// Wrapped to prevent IE from throwing errors when 'invalid' values are provided
				// Fixes bug #5509
				try {
					style[ name ] = value;
				} catch(e) {}
			}

		} else {
			// If a hook was provided get the non-computed value from there
			if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
				return ret;
			}

			// Otherwise just get the value from the style object
			return style[ name ];
		}
	},

	css: function( elem, name, extra ) {
		// Make sure that we're working with the right name
		var ret, origName = jomsQuery.camelCase( name ),
			hooks = jomsQuery.cssHooks[ origName ];

		name = jomsQuery.cssProps[ origName ] || origName;

		// If a hook was provided get the computed value from there
		if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
			return ret;

		// Otherwise, if a way to get the computed value exists, use that
		} else if ( curCSS ) {
			return curCSS( elem, name, origName );
		}
	},

	// 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 ( name in options ) {
			elem.style[ name ] = old[ name ];
		}
	},

	camelCase: function( string ) {
		return string.replace( rdashAlpha, fcamelCase );
	}
});

// DEPRECATED, Use jomsQuery.css() instead
jomsQuery.curCSS = jomsQuery.css;

jomsQuery.each(["height", "width"], function( i, name ) {
	jomsQuery.cssHooks[ name ] = {
		get: function( elem, computed, extra ) {
			var val;

			if ( computed ) {
				if ( elem.offsetWidth !== 0 ) {
					val = getWH( elem, name, extra );

				} else {
					jomsQuery.swap( elem, cssShow, function() {
						val = getWH( elem, name, extra );
					});
				}

				return val + "px";
			}
		},

		set: function( elem, value ) {
			if ( rnumpx.test( value ) ) {
				// ignore negative width and height values #1599
				value = parseFloat(value);

				if ( value >= 0 ) {
					return value + "px";
				}

			} else {
				return value;
			}
		}
	};
});

if ( !jomsQuery.support.opacity ) {
	jomsQuery.cssHooks.opacity = {
		get: function( elem, computed ) {
			// IE uses filters for opacity
			return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ?
				(parseFloat(RegExp.$1) / 100) + "" :
				computed ? "1" : "";
		},

		set: function( elem, value ) {
			var style = elem.style;

			// IE has trouble with opacity if it does not have layout
			// Force it by setting the zoom level
			style.zoom = 1;

			// Set the alpha filter to set the opacity
			var opacity = jomsQuery.isNaN(value) ?
				"" :
				"alpha(opacity=" + value * 100 + ")",
				filter = style.filter || "";

			style.filter = ralpha.test(filter) ?
				filter.replace(ralpha, opacity) :
				style.filter + ' ' + opacity;
		}
	};
}

if ( getComputedStyle ) {
	curCSS = function( elem, newName, name ) {
		var ret, defaultView, computedStyle;

		name = name.replace( rupper, "-$1" ).toLowerCase();

		if ( !(defaultView = elem.ownerDocument.defaultView) ) {
			return undefined;
		}

		if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
			ret = computedStyle.getPropertyValue( name );
			if ( ret === "" && !jomsQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
				ret = jomsQuery.style( elem, name );
			}
		}

		return ret;
	};

} else if ( document.documentElement.currentStyle ) {
	curCSS = function( elem, name ) {
		var left, rsLeft, ret = elem.currentStyle && elem.currentStyle[ name ], style = elem.style;

		// 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 ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
			// Remember the original values
			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 = name === "fontSize" ? "1em" : (ret || 0);
			ret = style.pixelLeft + "px";

			// Revert the changed values
			style.left = left;
			elem.runtimeStyle.left = rsLeft;
		}

		return ret;
	};
}

function getWH( elem, name, extra ) {
	var which = name === "width" ? cssWidth : cssHeight,
		val = name === "width" ? elem.offsetWidth : elem.offsetHeight;

	if ( extra === "border" ) {
		return val;
	}

	jomsQuery.each( which, function() {
		if ( !extra ) {
			val -= parseFloat(jomsQuery.css( elem, "padding" + this )) || 0;
		}

		if ( extra === "margin" ) {
			val += parseFloat(jomsQuery.css( elem, "margin" + this )) || 0;

		} else {
			val -= parseFloat(jomsQuery.css( elem, "border" + this + "Width" )) || 0;
		}
	});

	return val;
}

if ( jomsQuery.expr && jomsQuery.expr.filters ) {
	jomsQuery.expr.filters.hidden = function( elem ) {
		var width = elem.offsetWidth, height = elem.offsetHeight;

		return (width === 0 && height === 0) || (!jomsQuery.support.reliableHiddenOffsets && (elem.style.display || jomsQuery.css( elem, "display" )) === "none");
	};

	jomsQuery.expr.filters.visible = function( elem ) {
		return !jomsQuery.expr.filters.hidden( elem );
	};
}




var jsc = jomsQuery.now(),
	rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
	rselectTextarea = /^(?:select|textarea)/i,
	rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
	rnoContent = /^(?:GET|HEAD|DELETE)$/,
	rbracket = /\[\]$/,
	jsre = /\=\?(&|$)/,
	rquery = /\?/,
	rts = /([?&])_=[^&]*/,
	rurl = /^(\w+:)?\/\/([^\/?#]+)/,
	r20 = /%20/g,
	rhash = /#.*$/,

	// Keep a copy of the old load method
	_load = jomsQuery.fn.load;

jomsQuery.fn.extend({
	load: function( url, params, callback ) {
		if ( typeof url !== "string" && _load ) {
			return _load.apply( this, arguments );

		// Don't do a request if no elements are being requested
		} else if ( !this.length ) {
			return this;
		}

		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 ( jomsQuery.isFunction( params ) ) {
				// We assume that it's the callback
				callback = params;
				params = null;

			// Otherwise, build a param string
			} else if ( typeof params === "object" ) {
				params = jomsQuery.param( params, jomsQuery.ajaxSettings.traditional );
				type = "POST";
			}
		}

		var self = this;

		// Request the remote document
		jomsQuery.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
						jomsQuery("<div>")
							// inject the contents of the document in, removing the scripts
							// to avoid any 'Permission Denied' errors in IE
							.append(res.responseText.replace(rscript, ""))

							// 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 jomsQuery.param(this.serializeArray());
	},

	serializeArray: function() {
		return this.map(function() {
			return this.elements ? jomsQuery.makeArray(this.elements) : this;
		})
		.filter(function() {
			return this.name && !this.disabled &&
				(this.checked || rselectTextarea.test(this.nodeName) ||
					rinput.test(this.type));
		})
		.map(function( i, elem ) {
			var val = jomsQuery(this).val();

			return val == null ?
				null :
				jomsQuery.isArray(val) ?
					jomsQuery.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
jomsQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) {
	jomsQuery.fn[o] = function( f ) {
		return this.bind(o, f);
	};
});

jomsQuery.extend({
	get: function( url, data, callback, type ) {
		// shift arguments if data argument was omited
		if ( jomsQuery.isFunction( data ) ) {
			type = type || callback;
			callback = data;
			data = null;
		}

		return jomsQuery.ajax({
			type: "GET",
			url: url,
			data: data,
			success: callback,
			dataType: type
		});
	},

	getScript: function( url, callback ) {
		return jomsQuery.get(url, null, callback, "script");
	},

	getJSON: function( url, data, callback ) {
		return jomsQuery.get(url, data, callback, "json");
	},

	post: function( url, data, callback, type ) {
		// shift arguments if data argument was omited
		if ( jomsQuery.isFunction( data ) ) {
			type = type || callback;
			callback = data;
			data = {};
		}

		return jomsQuery.ajax({
			type: "POST",
			url: url,
			data: data,
			success: callback,
			dataType: type
		});
	},

	ajaxSetup: function( settings ) {
		jomsQuery.extend( jomsQuery.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,
		traditional: false,
		*/
		// This function can be overriden by calling jomsQuery.ajaxSetup
		xhr: function() {
			return new window.XMLHttpRequest();
		},
		accepts: {
			xml: "application/xml, text/xml",
			html: "text/html",
			script: "text/javascript, application/javascript",
			json: "application/json, text/javascript",
			text: "text/plain",
			_default: "*/*"
		}
	},

	ajax: function( origSettings ) {
		var s = jomsQuery.extend(true, {}, jomsQuery.ajaxSettings, origSettings),
			jsonp, status, data, type = s.type.toUpperCase(), noContent = rnoContent.test(type);

		s.url = s.url.replace( rhash, "" );

		// Use original (not extended) context object if it was provided
		s.context = origSettings && origSettings.context != null ? origSettings.context : s;

		// convert data if not already a string
		if ( s.data && s.processData && typeof s.data !== "string" ) {
			s.data = jomsQuery.param( s.data, s.traditional );
		}

		// Handle JSONP Parameter Callbacks
		if ( s.dataType === "jsonp" ) {
			if ( type === "GET" ) {
				if ( !jsre.test( s.url ) ) {
					s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
				}
			} else if ( !s.data || !jsre.test(s.data) ) {
				s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
			}
			s.dataType = "json";
		}

		// Build temporary JSONP function
		if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
			jsonp = s.jsonpCallback || ("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
			var customJsonp = window[ jsonp ];

			window[ jsonp ] = function( tmp ) {
				data = tmp;
				jomsQuery.handleSuccess( s, xhr, status, data );
				jomsQuery.handleComplete( s, xhr, status, data );

				if ( jomsQuery.isFunction( customJsonp ) ) {
					customJsonp( tmp );

				} else {
					// Garbage collect
					window[ jsonp ] = undefined;

					try {
						delete window[ jsonp ];
					} catch( jsonpError ) {}
				}
				
				if ( head ) {
					head.removeChild( script );
				}
			};
		}

		if ( s.dataType === "script" && s.cache === null ) {
			s.cache = false;
		}

		if ( s.cache === false && type === "GET" ) {
			var ts = jomsQuery.now();

			// try replacing _= if it is there
			var ret = s.url.replace(rts, "$1_=" + ts);

			// if nothing was replaced, add timestamp to the end
			s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
		}

		// If data is available, append data to url for get requests
		if ( s.data && type === "GET" ) {
			s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
		}

		// Watch for a new set of requests
		if ( s.global && jomsQuery.active++ === 0 ) {
			jomsQuery.event.trigger( "ajaxStart" );
		}

		// Matches an absolute URL, and saves the domain
		var parts = rurl.exec( s.url ),
			remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);

		// If we're requesting a remote document
		// and trying to load JSON or Script with a GET
		if ( s.dataType === "script" && type === "GET" && remote ) {
			var head = document.getElementsByTagName("head")[0] || document.documentElement;
			var script = document.createElement("script");
			if ( s.scriptCharset ) {
				script.charset = s.scriptCharset;
			}
			script.src = s.url;

			// 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;
						jomsQuery.handleSuccess( s, xhr, status, data );
						jomsQuery.handleComplete( s, xhr, status, data );

						// Handle memory leak in IE
						script.onload = script.onreadystatechange = null;
						if ( head && script.parentNode ) {
							head.removeChild( script );
						}
					}
				};
			}

			// Use insertBefore instead of appendChild  to circumvent an IE6 bug.
			// This arises when a base node is used (#2709 and #4378).
			head.insertBefore( script, head.firstChild );

			// We handle everything using the script element injection
			return undefined;
		}

		var requestDone = false;

		// Create the request object
		var xhr = s.xhr();

		if ( !xhr ) {
			return;
		}

		// 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 content-type if data specified and content-body is valid for this type
			if ( (s.data != null && !noContent) || (origSettings && origSettings.contentType) ) {
				xhr.setRequestHeader("Content-Type", s.contentType);
			}

			// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
			if ( s.ifModified ) {
				if ( jomsQuery.lastModified[s.url] ) {
					xhr.setRequestHeader("If-Modified-Since", jomsQuery.lastModified[s.url]);
				}

				if ( jomsQuery.etag[s.url] ) {
					xhr.setRequestHeader("If-None-Match", jomsQuery.etag[s.url]);
				}
			}

			// Set header so the called script knows that it's an XMLHttpRequest
			// Only send the header if it's not a remote XHR
			if ( !remote ) {
				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 ] + ", */*; q=0.01" :
				s.accepts._default );
		} catch( headerError ) {}

		// Allow custom headers/mimetypes and early abort
		if ( s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false ) {
			// Handle the global AJAX counter
			if ( s.global && jomsQuery.active-- === 1 ) {
				jomsQuery.event.trigger( "ajaxStop" );
			}

			// close opended socket
			xhr.abort();
			return false;
		}

		if ( s.global ) {
			jomsQuery.triggerGlobal( s, "ajaxSend", [xhr, s] );
		}

		// Wait for a response to come back
		var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
			// The request was aborted
			if ( !xhr || xhr.readyState === 0 || isTimeout === "abort" ) {
				// Opera doesn't call onreadystatechange before this point
				// so we simulate the call
				if ( !requestDone ) {
					jomsQuery.handleComplete( s, xhr, status, data );
				}

				requestDone = true;
				if ( xhr ) {
					xhr.onreadystatechange = jomsQuery.noop;
				}

			// 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;
				xhr.onreadystatechange = jomsQuery.noop;

				status = isTimeout === "timeout" ?
					"timeout" :
					!jomsQuery.httpSuccess( xhr ) ?
						"error" :
						s.ifModified && jomsQuery.httpNotModified( xhr, s.url ) ?
							"notmodified" :
							"success";

				var errMsg;

				if ( status === "success" ) {
					// Watch for, and catch, XML document parse errors
					try {
						// process the data (runs the xml through httpData regardless of callback)
						data = jomsQuery.httpData( xhr, s.dataType, s );
					} catch( parserError ) {
						status = "parsererror";
						errMsg = parserError;
					}
				}

				// Make sure that the request was successful or notmodified
				if ( status === "success" || status === "notmodified" ) {
					// JSONP handles its own success callback
					if ( !jsonp ) {
						jomsQuery.handleSuccess( s, xhr, status, data );
					}
				} else {
					jomsQuery.handleError( s, xhr, status, errMsg );
				}

				// Fire the complete handlers
				if ( !jsonp ) {
					jomsQuery.handleComplete( s, xhr, status, data );
				}

				if ( isTimeout === "timeout" ) {
					xhr.abort();
				}

				// Stop memory leaks
				if ( s.async ) {
					xhr = null;
				}
			}
		};

		// Override the abort handler, if we can (IE 6 doesn't allow it, but that's OK)
		// Opera doesn't fire onreadystatechange at all on abort
		try {
			var oldAbort = xhr.abort;
			xhr.abort = function() {
				// xhr.abort in IE7 is not a native JS function
				// and does not have a call property
				if ( xhr && oldAbort.call ) {
					oldAbort.call( xhr );
				}

				onreadystatechange( "abort" );
			};
		} catch( abortError ) {}

		// Timeout checker
		if ( s.async && 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( noContent || s.data == null ? null : s.data );

		} catch( sendError ) {
			jomsQuery.handleError( s, xhr, null, sendError );

			// Fire the complete handlers
			jomsQuery.handleComplete( s, xhr, status, data );
		}

		// firefox 1.5 doesn't fire statechange for sync requests
		if ( !s.async ) {
			onreadystatechange();
		}

		// return XMLHttpRequest to allow aborting the request etc.
		return xhr;
	},

	// Serialize an array of form elements or a set of
	// key/values into a query string
	param: function( a, traditional ) {
		var s = [], add = function( key, value ) {
			// If value is a function, invoke it and return its value
			value = jomsQuery.isFunction(value) ? value() : value;
			s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
		};
		
		// Set traditional to true for jomsQuery <= 1.3.2 behavior.
		if ( traditional === undefined ) {
			traditional = jomsQuery.ajaxSettings.traditional;
		}
		
		// If an array was passed in, assume that it is an array of form elements.
		if ( jomsQuery.isArray(a) || a.jomsQuery ) {
			// Serialize the form elements
			jomsQuery.each( a, function() {
				add( this.name, this.value );
			});
			
		} else {
			// If traditional, encode the "old" way (the way 1.3.2 or older
			// did it), otherwise encode params recursively.
			for ( var prefix in a ) {
				buildParams( prefix, a[prefix], traditional, add );
			}
		}

		// Return the resulting serialization
		return s.join("&").replace(r20, "+");
	}
});

function buildParams( prefix, obj, traditional, add ) {
	if ( jomsQuery.isArray(obj) && obj.length ) {
		// Serialize array item.
		jomsQuery.each( obj, function( i, v ) {
			if ( traditional || rbracket.test( prefix ) ) {
				// Treat each array item as a scalar.
				add( prefix, v );

			} else {
				// If array item is non-scalar (array or object), encode its
				// numeric index to resolve deserialization ambiguity issues.
				// Note that rack (as of 1.0.0) can't currently deserialize
				// nested arrays properly, and attempting to do so may cause
				// a server error. Possible fixes are to modify rack's
				// deserialization algorithm or to provide an option or flag
				// to force array serialization to be shallow.
				buildParams( prefix + "[" + ( typeof v === "object" || jomsQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
			}
		});
			
	} else if ( !traditional && obj != null && typeof obj === "object" ) {
		if ( jomsQuery.isEmptyObject( obj ) ) {
			add( prefix, "" );

		// Serialize object item.
		} else {
			jomsQuery.each( obj, function( k, v ) {
				buildParams( prefix + "[" + k + "]", v, traditional, add );
			});
		}
					
	} else {
		// Serialize scalar item.
		add( prefix, obj );
	}
}

// This is still on the jomsQuery object... for now
// Want to move this to jomsQuery.ajax some day
jomsQuery.extend({

	// Counter for holding the number of active queries
	active: 0,

	// Last-Modified header cache for next request
	lastModified: {},
	etag: {},

	handleError: function( s, xhr, status, e ) {
		// If a local callback was specified, fire it
		if ( s.error ) {
			s.error.call( s.context, xhr, status, e );
		}

		// Fire the global callback
		if ( s.global ) {
			jomsQuery.triggerGlobal( s, "ajaxError", [xhr, s, e] );
		}
	},

	handleSuccess: function( s, xhr, status, data ) {
		// If a local callback was specified, fire it and pass it the data
		if ( s.success ) {
			s.success.call( s.context, data, status, xhr );
		}

		// Fire the global callback
		if ( s.global ) {
			jomsQuery.triggerGlobal( s, "ajaxSuccess", [xhr, s] );
		}
	},

	handleComplete: function( s, xhr, status ) {
		// Process result
		if ( s.complete ) {
			s.complete.call( s.context, xhr, status );
		}

		// The request was completed
		if ( s.global ) {
			jomsQuery.triggerGlobal( s, "ajaxComplete", [xhr, s] );
		}

		// Handle the global AJAX counter
		if ( s.global && jomsQuery.active-- === 1 ) {
			jomsQuery.event.trigger( "ajaxStop" );
		}
	},
		
	triggerGlobal: function( s, type, args ) {
		(s.context && s.context.url == null ? jomsQuery(s.context) : jomsQuery.event).trigger(type, args);
	},

	// 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 ) {
		var lastModified = xhr.getResponseHeader("Last-Modified"),
			etag = xhr.getResponseHeader("Etag");

		if ( lastModified ) {
			jomsQuery.lastModified[url] = lastModified;
		}

		if ( etag ) {
			jomsQuery.etag[url] = etag;
		}

		return xhr.status === 304;
	},

	httpData: function( xhr, type, s ) {
		var ct = xhr.getResponseHeader("content-type") || "",
			xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
			data = xml ? xhr.responseXML : xhr.responseText;

		if ( xml && data.documentElement.nodeName === "parsererror" ) {
			jomsQuery.error( "parsererror" );
		}

		// Allow a pre-filtering function to sanitize the response
		// s 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" ) {
			// Get the JavaScript object, if JSON is used.
			if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
				data = jomsQuery.parseJSON( data );

			// If the type is "script", eval it in global context
			} else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
				jomsQuery.globalEval( data );
			}
		}

		return data;
	}

});

/*
 * Create the request object; Microsoft failed to properly
 * implement the XMLHttpRequest in IE7 (can't request local files),
 * so we use the ActiveXObject when it is available
 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
 * we need a fallback.
 */
if ( window.ActiveXObject ) {
	jomsQuery.ajaxSettings.xhr = function() {
		if ( window.location.protocol !== "file:" ) {
			try {
				return new window.XMLHttpRequest();
			} catch(xhrError) {}
		}

		try {
			return new window.ActiveXObject("Microsoft.XMLHTTP");
		} catch(activeError) {}
	};
}

// Does this browser support XHR requests?
jomsQuery.support.ajax = !!jomsQuery.ajaxSettings.xhr();




var elemdisplay = {},
	rfxtypes = /^(?:toggle|show|hide)$/,
	rfxnum = /^([+\-]=)?([\d+.\-]+)(.*)$/,
	timerId,
	fxAttrs = [
		// height animations
		[ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
		// width animations
		[ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
		// opacity animations
		[ "opacity" ]
	];

jomsQuery.fn.extend({
	show: function( speed, easing, callback ) {
		if ( speed || speed === 0 ) {
			return this.animate( genFx("show", 3), speed, easing, callback);
		} else {
			for ( var i = 0, j = this.length; i < j; i++ ) {
				// Reset the inline display of this element to learn if it is
				// being hidden by cascaded rules or not
				if ( !jomsQuery.data(this[i], "olddisplay") && this[i].style.display === "none" ) {
					this[i].style.display = "";
				}

				// Set elements which have been overridden with display: none
				// in a stylesheet to whatever the default browser style is
				// for such an element
				if ( this[i].style.display === "" && jomsQuery.css( this[i], "display" ) === "none" ) {
					jomsQuery.data(this[i], "olddisplay", defaultDisplay(this[i].nodeName));
				}
			}

			// Set the display of most of the elements in a second loop
			// to avoid the constant reflow
			for ( i = 0; i < j; i++ ) {
				this[i].style.display = jomsQuery.data(this[i], "olddisplay") || "";
			}

			return this;
		}
	},

	hide: function( speed, easing, callback ) {
		if ( speed || speed === 0 ) {
			return this.animate( genFx("hide", 3), speed, easing, callback);

		} else {
			for ( var i = 0, j = this.length; i < j; i++ ) {
				var display = jomsQuery.css( this[i], "display" );

				if ( display !== "none" ) {
					jomsQuery.data( this[i], "olddisplay", display );
				}
			}

			// Set the display of the elements in a second loop
			// to avoid the constant reflow
			for ( i = 0; i < j; i++ ) {
				this[i].style.display = "none";
			}

			return this;
		}
	},

	// Save the old toggle function
	_toggle: jomsQuery.fn.toggle,

	toggle: function( fn, fn2, callback ) {
		var bool = typeof fn === "boolean";

		if ( jomsQuery.isFunction(fn) && jomsQuery.isFunction(fn2) ) {
			this._toggle.apply( this, arguments );

		} else if ( fn == null || bool ) {
			this.each(function() {
				var state = bool ? fn : jomsQuery(this).is(":hidden");
				jomsQuery(this)[ state ? "show" : "hide" ]();
			});

		} else {
			this.animate(genFx("toggle", 3), fn, fn2, callback);
		}

		return this;
	},

	fadeTo: function( speed, to, easing, callback ) {
		return this.filter(":hidden").css("opacity", 0).show().end()
					.animate({opacity: to}, speed, easing, callback);
	},

	animate: function( prop, speed, easing, callback ) {
		var optall = jomsQuery.speed(speed, easing, callback);

		if ( jomsQuery.isEmptyObject( prop ) ) {
			return this.each( optall.complete );
		}

		return this[ optall.queue === false ? "each" : "queue" ](function() {
			// XXX â€˜thisâ€™ does not always have a nodeName when running the
			// test suite

			var opt = jomsQuery.extend({}, optall), p,
				isElement = this.nodeType === 1,
				hidden = isElement && jomsQuery(this).is(":hidden"),
				self = this;

			for ( p in prop ) {
				var name = jomsQuery.camelCase( p );

				if ( p !== name ) {
					prop[ name ] = prop[ p ];
					delete prop[ p ];
					p = name;
				}

				if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
					return opt.complete.call(this);
				}

				if ( isElement && ( p === "height" || p === "width" ) ) {
					// Make sure that nothing sneaks out
					// Record all 3 overflow attributes because IE does not
					// change the overflow attribute when overflowX and
					// overflowY are set to the same value
					opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];

					// Set display property to inline-block for height/width
					// animations on inline elements that are having width/height
					// animated
					if ( jomsQuery.css( this, "display" ) === "inline" &&
							jomsQuery.css( this, "float" ) === "none" ) {
						if ( !jomsQuery.support.inlineBlockNeedsLayout ) {
							this.style.display = "inline-block";

						} else {
							var display = defaultDisplay(this.nodeName);

							// inline-level elements accept inline-block;
							// block-level elements need to be inline with layout
							if ( display === "inline" ) {
								this.style.display = "inline-block";

							} else {
								this.style.display = "inline";
								this.style.zoom = 1;
							}
						}
					}
				}

				if ( jomsQuery.isArray( prop[p] ) ) {
					// Create (if needed) and add to specialEasing
					(opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
					prop[p] = prop[p][0];
				}
			}

			if ( opt.overflow != null ) {
				this.style.overflow = "hidden";
			}

			opt.curAnim = jomsQuery.extend({}, prop);

			jomsQuery.each( prop, function( name, val ) {
				var e = new jomsQuery.fx( self, opt, name );

				if ( rfxtypes.test(val) ) {
					e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );

				} else {
					var parts = rfxnum.exec(val),
						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" ) {
							jomsQuery.style( self, name, (end || 1) + unit);
							start = ((end || 1) / e.cur(true)) * start;
							jomsQuery.style( self, 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 = jomsQuery.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;
	}

});

function genFx( type, num ) {
	var obj = {};

	jomsQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
		obj[ this ] = type;
	});

	return obj;
}

// Generate shortcuts for custom animations
jomsQuery.each({
	slideDown: genFx("show", 1),
	slideUp: genFx("hide", 1),
	slideToggle: genFx("toggle", 1),
	fadeIn: { opacity: "show" },
	fadeOut: { opacity: "hide" }
}, function( name, props ) {
	jomsQuery.fn[ name ] = function( speed, easing, callback ) {
		return this.animate( props, speed, easing, callback );
	};
});

jomsQuery.extend({
	speed: function( speed, easing, fn ) {
		var opt = speed && typeof speed === "object" ? jomsQuery.extend({}, speed) : {
			complete: fn || !fn && easing ||
				jomsQuery.isFunction( speed ) && speed,
			duration: speed,
			easing: fn && easing || easing && !jomsQuery.isFunction(easing) && easing
		};

		opt.duration = jomsQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
			opt.duration in jomsQuery.fx.speeds ? jomsQuery.fx.speeds[opt.duration] : jomsQuery.fx.speeds._default;

		// Queueing
		opt.old = opt.complete;
		opt.complete = function() {
			if ( opt.queue !== false ) {
				jomsQuery(this).dequeue();
			}
			if ( jomsQuery.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 = {};
		}
	}

});

jomsQuery.fx.prototype = {
	// Simple function for setting a style value
	update: function() {
		if ( this.options.step ) {
			this.options.step.call( this.elem, this.now, this );
		}

		(jomsQuery.fx.step[this.prop] || jomsQuery.fx.step._default)( this );
	},

	// Get the current size
	cur: function() {
		if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
			return this.elem[ this.prop ];
		}

		var r = parseFloat( jomsQuery.css( this.elem, this.prop ) );
		return r && r > -10000 ? r : 0;
	},

	// Start an animation from one number to another
	custom: function( from, to, unit ) {
		this.startTime = jomsQuery.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, fx = jomsQuery.fx;
		function t( gotoEnd ) {
			return self.step(gotoEnd);
		}

		t.elem = this.elem;

		if ( t() && jomsQuery.timers.push(t) && !timerId ) {
			timerId = setInterval(fx.tick, fx.interval);
		}
	},

	// Simple 'show' function
	show: function() {
		// Remember where we started, so that we can go back to it later
		this.options.orig[this.prop] = jomsQuery.style( this.elem, 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
		jomsQuery( 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] = jomsQuery.style( this.elem, this.prop );
		this.options.hide = true;

		// Begin the animation
		this.custom(this.cur(), 0);
	},

	// Each step of an animation
	step: function( gotoEnd ) {
		var t = jomsQuery.now(), done = true;

		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;

			for ( var i in this.options.curAnim ) {
				if ( this.options.curAnim[i] !== true ) {
					done = false;
				}
			}

			if ( done ) {
				// Reset the overflow
				if ( this.options.overflow != null && !jomsQuery.support.shrinkWrapBlocks ) {
					var elem = this.elem, options = this.options;
					jomsQuery.each( [ "", "X", "Y" ], function (index, value) {
						elem.style[ "overflow" + value ] = options.overflow[index];
					} );
				}

				// Hide the element if the "hide" operation was done
				if ( this.options.hide ) {
					jomsQuery(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 ) {
						jomsQuery.style( this.elem, 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
			var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
			var defaultEasing = this.options.easing || (jomsQuery.easing.swing ? "swing" : "linear");
			this.pos = jomsQuery.easing[specialEasing || defaultEasing](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;
	}
};

jomsQuery.extend( jomsQuery.fx, {
	tick: function() {
		var timers = jomsQuery.timers;

		for ( var i = 0; i < timers.length; i++ ) {
			if ( !timers[i]() ) {
				timers.splice(i--, 1);
			}
		}

		if ( !timers.length ) {
			jomsQuery.fx.stop();
		}
	},

	interval: 13,

	stop: function() {
		clearInterval( timerId );
		timerId = null;
	},

	speeds: {
		slow: 600,
		fast: 200,
		// Default speed
		_default: 400
	},

	step: {
		opacity: function( fx ) {
			jomsQuery.style( fx.elem, "opacity", fx.now );
		},

		_default: function( fx ) {
			if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
				fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
			} else {
				fx.elem[ fx.prop ] = fx.now;
			}
		}
	}
});

if ( jomsQuery.expr && jomsQuery.expr.filters ) {
	jomsQuery.expr.filters.animated = function( elem ) {
		return jomsQuery.grep(jomsQuery.timers, function( fn ) {
			return elem === fn.elem;
		}).length;
	};
}

function defaultDisplay( nodeName ) {
	if ( !elemdisplay[ nodeName ] ) {
		var elem = jomsQuery("<" + nodeName + ">").appendTo("body"),
			display = elem.css("display");

		elem.remove();

		if ( display === "none" || display === "" ) {
			display = "block";
		}

		elemdisplay[ nodeName ] = display;
	}

	return elemdisplay[ nodeName ];
}




var rtable = /^t(?:able|d|h)$/i,
	rroot = /^(?:body|html)$/i;

if ( "getBoundingClientRect" in document.documentElement ) {
	jomsQuery.fn.offset = function( options ) {
		var elem = this[0], box;

		if ( options ) { 
			return this.each(function( i ) {
				jomsQuery.offset.setOffset( this, options, i );
			});
		}

		if ( !elem || !elem.ownerDocument ) {
			return null;
		}

		if ( elem === elem.ownerDocument.body ) {
			return jomsQuery.offset.bodyOffset( elem );
		}

		try {
			box = elem.getBoundingClientRect();
		} catch(e) {}

		var doc = elem.ownerDocument,
			docElem = doc.documentElement;

		// Make sure we're not dealing with a disconnected DOM node
		if ( !box || !jomsQuery.contains( docElem, elem ) ) {
			return box || { top: 0, left: 0 };
		}

		var body = doc.body,
			win = getWindow(doc),
			clientTop  = docElem.clientTop  || body.clientTop  || 0,
			clientLeft = docElem.clientLeft || body.clientLeft || 0,
			scrollTop  = (win.pageYOffset || jomsQuery.support.boxModel && docElem.scrollTop  || body.scrollTop ),
			scrollLeft = (win.pageXOffset || jomsQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft),
			top  = box.top  + scrollTop  - clientTop,
			left = box.left + scrollLeft - clientLeft;

		return { top: top, left: left };
	};

} else {
	jomsQuery.fn.offset = function( options ) {
		var elem = this[0];

		if ( options ) { 
			return this.each(function( i ) {
				jomsQuery.offset.setOffset( this, options, i );
			});
		}

		if ( !elem || !elem.ownerDocument ) {
			return null;
		}

		if ( elem === elem.ownerDocument.body ) {
			return jomsQuery.offset.bodyOffset( elem );
		}

		jomsQuery.offset.initialize();

		var offsetParent = elem.offsetParent, prevOffsetParent = elem,
			doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
			body = doc.body, defaultView = doc.defaultView,
			prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
			top = elem.offsetTop, left = elem.offsetLeft;

		while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
			if ( jomsQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
				break;
			}

			computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
			top  -= elem.scrollTop;
			left -= elem.scrollLeft;

			if ( elem === offsetParent ) {
				top  += elem.offsetTop;
				left += elem.offsetLeft;

				if ( jomsQuery.offset.doesNotAddBorder && !(jomsQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
					top  += parseFloat( computedStyle.borderTopWidth  ) || 0;
					left += parseFloat( computedStyle.borderLeftWidth ) || 0;
				}

				prevOffsetParent = offsetParent;
				offsetParent = elem.offsetParent;
			}

			if ( jomsQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
				top  += parseFloat( computedStyle.borderTopWidth  ) || 0;
				left += parseFloat( computedStyle.borderLeftWidth ) || 0;
			}

			prevComputedStyle = computedStyle;
		}

		if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
			top  += body.offsetTop;
			left += body.offsetLeft;
		}

		if ( jomsQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
			top  += Math.max( docElem.scrollTop, body.scrollTop );
			left += Math.max( docElem.scrollLeft, body.scrollLeft );
		}

		return { top: top, left: left };
	};
}

jomsQuery.offset = {
	initialize: function() {
		var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jomsQuery.css(body, "marginTop") ) || 0,
			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>";

		jomsQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );

		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);

		checkDiv.style.position = "fixed";
		checkDiv.style.top = "20px";

		// safari subtracts parent border width here which is 5px
		this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
		checkDiv.style.position = checkDiv.style.top = "";

		innerDiv.style.overflow = "hidden";
		innerDiv.style.position = "relative";

		this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);

		this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);

		body.removeChild( container );
		body = container = innerDiv = checkDiv = table = td = null;
		jomsQuery.offset.initialize = jomsQuery.noop;
	},

	bodyOffset: function( body ) {
		var top = body.offsetTop, left = body.offsetLeft;

		jomsQuery.offset.initialize();

		if ( jomsQuery.offset.doesNotIncludeMarginInBodyOffset ) {
			top  += parseFloat( jomsQuery.css(body, "marginTop") ) || 0;
			left += parseFloat( jomsQuery.css(body, "marginLeft") ) || 0;
		}

		return { top: top, left: left };
	},
	
	setOffset: function( elem, options, i ) {
		var position = jomsQuery.css( elem, "position" );

		// set position first, in-case top/left are set even on static elem
		if ( position === "static" ) {
			elem.style.position = "relative";
		}

		var curElem = jomsQuery( elem ),
			curOffset = curElem.offset(),
			curCSSTop = jomsQuery.css( elem, "top" ),
			curCSSLeft = jomsQuery.css( elem, "left" ),
			calculatePosition = (position === "absolute" && jomsQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1),
			props = {}, curPosition = {}, curTop, curLeft;

		// need to be able to calculate position if either top or left is auto and position is absolute
		if ( calculatePosition ) {
			curPosition = curElem.position();
		}

		curTop  = calculatePosition ? curPosition.top  : parseInt( curCSSTop,  10 ) || 0;
		curLeft = calculatePosition ? curPosition.left : parseInt( curCSSLeft, 10 ) || 0;

		if ( jomsQuery.isFunction( options ) ) {
			options = options.call( elem, i, curOffset );
		}

		if (options.top != null) {
			props.top = (options.top - curOffset.top) + curTop;
		}
		if (options.left != null) {
			props.left = (options.left - curOffset.left) + curLeft;
		}
		
		if ( "using" in options ) {
			options.using.call( elem, props );
		} else {
			curElem.css( props );
		}
	}
};


jomsQuery.fn.extend({
	position: function() {
		if ( !this[0] ) {
			return null;
		}

		var elem = this[0],

		// Get *real* offsetParent
		offsetParent = this.offsetParent(),

		// Get correct offsets
		offset       = this.offset(),
		parentOffset = rroot.test(offsetParent[0].nodeName) ? { 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  -= parseFloat( jomsQuery.css(elem, "marginTop") ) || 0;
		offset.left -= parseFloat( jomsQuery.css(elem, "marginLeft") ) || 0;

		// Add offsetParent borders
		parentOffset.top  += parseFloat( jomsQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
		parentOffset.left += parseFloat( jomsQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;

		// Subtract the two offsets
		return {
			top:  offset.top  - parentOffset.top,
			left: offset.left - parentOffset.left
		};
	},

	offsetParent: function() {
		return this.map(function() {
			var offsetParent = this.offsetParent || document.body;
			while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jomsQuery.css(offsetParent, "position") === "static") ) {
				offsetParent = offsetParent.offsetParent;
			}
			return offsetParent;
		});
	}
});


// Create scrollLeft and scrollTop methods
jomsQuery.each( ["Left", "Top"], function( i, name ) {
	var method = "scroll" + name;

	jomsQuery.fn[ method ] = function(val) {
		var elem = this[0], win;
		
		if ( !elem ) {
			return null;
		}

		if ( val !== undefined ) {
			// Set the scroll offset
			return this.each(function() {
				win = getWindow( this );

				if ( win ) {
					win.scrollTo(
						!i ? val : jomsQuery(win).scrollLeft(),
						 i ? val : jomsQuery(win).scrollTop()
					);

				} else {
					this[ method ] = val;
				}
			});
		} else {
			win = getWindow( elem );

			// Return the scroll offset
			return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
				jomsQuery.support.boxModel && win.document.documentElement[ method ] ||
					win.document.body[ method ] :
				elem[ method ];
		}
	};
});

function getWindow( elem ) {
	return jomsQuery.isWindow( elem ) ?
		elem :
		elem.nodeType === 9 ?
			elem.defaultView || elem.parentWindow :
			false;
}




// Create innerHeight, innerWidth, outerHeight and outerWidth methods
jomsQuery.each([ "Height", "Width" ], function( i, name ) {

	var type = name.toLowerCase();

	// innerHeight and innerWidth
	jomsQuery.fn["inner" + name] = function() {
		return this[0] ?
			parseFloat( jomsQuery.css( this[0], type, "padding" ) ) :
			null;
	};

	// outerHeight and outerWidth
	jomsQuery.fn["outer" + name] = function( margin ) {
		return this[0] ?
			parseFloat( jomsQuery.css( this[0], type, margin ? "margin" : "border" ) ) :
			null;
	};

	jomsQuery.fn[ type ] = function( size ) {
		// Get window width or height
		var elem = this[0];
		if ( !elem ) {
			return size == null ? null : this;
		}
		
		if ( jomsQuery.isFunction( size ) ) {
			return this.each(function( i ) {
				var self = jomsQuery( this );
				self[ type ]( size.call( this, i, self[ type ]() ) );
			});
		}

		return jomsQuery.isWindow( elem ) ?
			// Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
			elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
			elem.document.body[ "client" + name ] :

			// Get document width or height
			(elem.nodeType === 9) ? // is it a document
				// Either scroll[Width/Height] or offset[Width/Height], whichever is greater
				Math.max(
					elem.documentElement["client" + name],
					elem.body["scroll" + name], elem.documentElement["scroll" + name],
					elem.body["offset" + name], elem.documentElement["offset" + name]
				) :

				// Get or set width or height on the element
				size === undefined ?
					// Get width or height on the element
					parseFloat( jomsQuery.css( elem, type ) ) :

					// Set the width or height on the element (default to pixels if value is unitless)
					this.css( type, typeof size === "string" ? size : size + "px" );
	};

});


})(window);


/*
    http://www.JSON.org/json2.js
    2011-01-18

    Public Domain.

    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.

    See http://www.JSON.org/js.html


    This code should be minified before deployment.
    See http://javascript.crockford.com/jsmin.html

    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
    NOT CONTROL.


    This file creates a global JSON object containing two methods: stringify
    and parse.

        JSON.stringify(value, replacer, space)
            value       any JavaScript value, usually an object or array.

            replacer    an optional parameter that determines how object
                        values are stringified for objects. It can be a
                        function or an array of strings.

            space       an optional parameter that specifies the indentation
                        of nested structures. If it is omitted, the text will
                        be packed without extra whitespace. If it is a number,
                        it will specify the number of spaces to indent at each
                        level. If it is a string (such as '\t' or '&nbsp;'),
                        it contains the characters used to indent at each level.

            This method produces a JSON text from a JavaScript value.

            When an object value is found, if the object contains a toJSON
            method, its toJSON method will be called and the result will be
            stringified. A toJSON method does not serialize: it returns the
            value represented by the name/value pair that should be serialized,
            or undefined if nothing should be serialized. The toJSON method
            will be passed the key associated with the value, and this will be
            bound to the value

            For example, this would serialize Dates as ISO strings.

                Date.prototype.toJSON = function (key) {
                    function f(n) {
                        // Format integers to have at least two digits.
                        return n < 10 ? '0' + n : n;
                    }

                    return this.getUTCFullYear()   + '-' +
                         f(this.getUTCMonth() + 1) + '-' +
                         f(this.getUTCDate())      + 'T' +
                         f(this.getUTCHours())     + ':' +
                         f(this.getUTCMinutes())   + ':' +
                         f(this.getUTCSeconds())   + 'Z';
                };

            You can provide an optional replacer method. It will be passed the
            key and value of each member, with this bound to the containing
            object. The value that is returned from your method will be
            serialized. If your method returns undefined, then the member will
            be excluded from the serialization.

            If the replacer parameter is an array of strings, then it will be
            used to select the members to be serialized. It filters the results
            such that only members with keys listed in the replacer array are
            stringified.

            Values that do not have JSON representations, such as undefined or
            functions, will not be serialized. Such values in objects will be
            dropped; in arrays they will be replaced with null. You can use
            a replacer function to replace those with JSON values.
            JSON.stringify(undefined) returns undefined.

            The optional space parameter produces a stringification of the
            value that is filled with line breaks and indentation to make it
            easier to read.

            If the space parameter is a non-empty string, then that string will
            be used for indentation. If the space parameter is a number, then
            the indentation will be that many spaces.

            Example:

            text = JSON.stringify(['e', {pluribus: 'unum'}]);
            // text is '["e",{"pluribus":"unum"}]'


            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'

            text = JSON.stringify([new Date()], function (key, value) {
                return this[key] instanceof Date ?
                    'Date(' + this[key] + ')' : value;
            });
            // text is '["Date(---current time---)"]'


        JSON.parse(text, reviver)
            This method parses a JSON text to produce an object or array.
            It can throw a SyntaxError exception.

            The optional reviver parameter is a function that can filter and
            transform the results. It receives each of the keys and values,
            and its return value is used instead of the original value.
            If it returns what it received, then the structure is not modified.
            If it returns undefined then the member is deleted.

            Example:

            // Parse the text. Values that look like ISO date strings will
            // be converted to Date objects.

            myData = JSON.parse(text, function (key, value) {
                var a;
                if (typeof value === 'string') {
                    a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
                    if (a) {
                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
                            +a[5], +a[6]));
                    }
                }
                return value;
            });

            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
                var d;
                if (typeof value === 'string' &&
                        value.slice(0, 5) === 'Date(' &&
                        value.slice(-1) === ')') {
                    d = new Date(value.slice(5, -1));
                    if (d) {
                        return d;
                    }
                }
                return value;
            });


    This is a reference implementation. You are free to copy, modify, or
    redistribute.
*/

/*jslint evil: true, strict: false, regexp: false */

/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
    lastIndex, length, parse, prototype, push, replace, slice, stringify,
    test, toJSON, toString, valueOf
*/


// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.

var JSON;
if (!JSON) {
    JSON = {};
}

(function () {
    "use strict";

    function f(n) {
        // Format integers to have at least two digits.
        return n < 10 ? '0' + n : n;
    }

    if (typeof Date.prototype.toJSON !== 'function') {

        Date.prototype.toJSON = function (key) {

            return isFinite(this.valueOf()) ?
                this.getUTCFullYear()     + '-' +
                f(this.getUTCMonth() + 1) + '-' +
                f(this.getUTCDate())      + 'T' +
                f(this.getUTCHours())     + ':' +
                f(this.getUTCMinutes())   + ':' +
                f(this.getUTCSeconds())   + 'Z' : null;
        };

        String.prototype.toJSON      =
            Number.prototype.toJSON  =
            Boolean.prototype.toJSON = function (key) {
                return this.valueOf();
            };
    }

    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        gap,
        indent,
        meta = {    // table of character substitutions
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        },
        rep;


    function quote(string) {

// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.

        escapable.lastIndex = 0;
        return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
            var c = meta[a];
            return typeof c === 'string' ? c :
                '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
        }) + '"' : '"' + string + '"';
    }


    function str(key, holder) {

// Produce a string from holder[key].

        var i,          // The loop counter.
            k,          // The member key.
            v,          // The member value.
            length,
            mind = gap,
            partial,
            value = holder[key];

// If the value has a toJSON method, call it to obtain a replacement value.

        if (value && typeof value === 'object' &&
                typeof value.toJSON === 'function') {
            value = value.toJSON(key);
        }

// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.

        if (typeof rep === 'function') {
            value = rep.call(holder, key, value);
        }

// What happens next depends on the value's type.

        switch (typeof value) {
        case 'string':
            return quote(value);

        case 'number':

// JSON numbers must be finite. Encode non-finite numbers as null.

            return isFinite(value) ? String(value) : 'null';

        case 'boolean':
        case 'null':

// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.

            return String(value);

// If the type is 'object', we might be dealing with an object or an array or
// null.

        case 'object':

// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.

            if (!value) {
                return 'null';
            }

// Make an array to hold the partial results of stringifying this object value.

            gap += indent;
            partial = [];

// Is the value an array?

            if (Object.prototype.toString.apply(value) === '[object Array]') {

// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.

                length = value.length;
                for (i = 0; i < length; i += 1) {
                    partial[i] = str(i, value) || 'null';
                }

// Join all of the elements together, separated with commas, and wrap them in
// brackets.

                v = partial.length === 0 ? '[]' : gap ?
                    '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
                    '[' + partial.join(',') + ']';
                gap = mind;
                return v;
            }

// If the replacer is an array, use it to select the members to be stringified.

            if (rep && typeof rep === 'object') {
                length = rep.length;
                for (i = 0; i < length; i += 1) {
                    k = rep[i];
                    if (typeof k === 'string') {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            } else {

// Otherwise, iterate through all of the keys in the object.

                for (k in value) {
                    if (Object.hasOwnProperty.call(value, k)) {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            }

// Join all of the member texts together, separated with commas,
// and wrap them in braces.

            v = partial.length === 0 ? '{}' : gap ?
                '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
                '{' + partial.join(',') + '}';
            gap = mind;
            return v;
        }
    }

// If the JSON object does not yet have a stringify method, give it one.

    if (typeof JSON.stringify !== 'function') {
        JSON.stringify = function (value, replacer, space) {

// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.

            var i;
            gap = '';
            indent = '';

// If the space parameter is a number, make an indent string containing that
// many spaces.

            if (typeof space === 'number') {
                for (i = 0; i < space; i += 1) {
                    indent += ' ';
                }

// If the space parameter is a string, it will be used as the indent string.

            } else if (typeof space === 'string') {
                indent = space;
            }

// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.

            rep = replacer;
            if (replacer && typeof replacer !== 'function' &&
                    (typeof replacer !== 'object' ||
                    typeof replacer.length !== 'number')) {
                throw new Error('JSON.stringify');
            }

// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.

            return str('', {'': value});
        };
    }


// If the JSON object does not yet have a parse method, give it one.

    if (typeof JSON.parse !== 'function') {
        JSON.parse = function (text, reviver) {

// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.

            var j;

            function walk(holder, key) {

// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.

                var k, v, value = holder[key];
                if (value && typeof value === 'object') {
                    for (k in value) {
                        if (Object.hasOwnProperty.call(value, k)) {
                            v = walk(value, k);
                            if (v !== undefined) {
                                value[k] = v;
                            } else {
                                delete value[k];
                            }
                        }
                    }
                }
                return reviver.call(holder, key, value);
            }


// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.

            text = String(text);
            cx.lastIndex = 0;
            if (cx.test(text)) {
                text = text.replace(cx, function (a) {
                    return '\\u' +
                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
                });
            }

// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.

// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.

            if (/^[\],:{}\s]*$/
                    .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
                        .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
                        .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {

// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.

                j = eval('(' + text + ')');

// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.

                return typeof reviver === 'function' ?
                    walk({'': j}, '') : j;
            }

// If the text is not JSON parseable, then a SyntaxError is thrown.

            throw new SyntaxError('JSON.parse');
        };
    }
}());


jomsQuery.includejQuery();

/*** script-1.2.js ***/

// In the case where our joms.jQuery
// is overriden by other jQuery.
if (typeof(joms)=='undefined')
{
	// We will recreate our joms namespace
	// with joms.jQuery pointing to their jQuery.
	joms = {
		jQuery: window.jQuery,
		extend: function(obj){
			this.jQuery.extend(this, obj);
		}
	}
}

joms.extend({
	plugins: {
		extend: function (obj){
			//joms.jQuery.extend(joms.plugin, func);
			joms.jQuery.extend(joms.plugins, obj);
		},
		initialize: function()
		{
			joms.jQuery.each(joms.plugins, function(index, value) {
				try{
				    value.initialize();
				}
				catch(err)
				{
					//Handle errors here
				}
			});
		}
	},
	activities: {
		showMap: function( id, addr ){
			if(joms.jQuery('#newsfeed-map-'+id+ ' img').length == 0){
				var mapWidth = joms.jQuery('#newsfeed-map-'+id).parent().width();
				var mapHTML = '<img src="http://maps.google.com/maps/api/staticmap?center='+addr+'&amp;zoom=14&amp;size=' + mapWidth + 'x150&amp;sensor=false&amp;markers=color:red|'+addr+'" />';
				mapHTML += '<img src="http://maps.google.com/maps/api/staticmap?center='+addr+'&amp;zoom=5&amp;size=' + mapWidth + 'x150&amp;sensor=false&amp;markers=color:red|'+addr+'" />';
				mapHTML += '<img src="http://maps.google.com/maps/api/staticmap?center='+addr+'&amp;zoom=2&amp;size=' + mapWidth + 'x150&amp;sensor=false&amp;markers=color:red|'+addr+'" />';
				joms.jQuery('#newsfeed-map-'+id+ ' .newsfeed-mapFade').append(mapHTML);
			}
			joms.jQuery('#newsfeed-map-'+id).toggle();
		},
		getContent: function( activityId ){
				jax.call('community' , 'activities,ajaxGetContent' , activityId );
		},
		setContent: function( activityId , content ){
			joms.jQuery("#profile-newsfeed-item-content-" + activityId ).html( content )
				.removeClass("small profile-newsfeed-item-action").addClass("newsfeed-content-hidden").slideDown();
		},
		showVideo: function( activityId ){
			joms.jQuery('#profile-newsfeed-item-content-' + activityId + ' .video-object').slideDown();
			joms.jQuery('#profile-newsfeed-item-content-' + activityId + ' .video-object embed').css('width' , joms.jQuery('#profile-newsfeed-item-content-' + activityId ).width() );
		},
		selectCustom: function( type ){

			if( type == 'predefined' )
			{
				joms.jQuery( '#custom-text' ).css( 'display' , 'none');
				joms.jQuery( '#custom-predefined').css( 'display' , 'block' );
			}
			else
			{
				joms.jQuery( '#custom-text' ).css( 'display' , 'block' );
				joms.jQuery( '#custom-predefined').css( 'display' , 'none' );
			}
		},
		addCustom: function(){
			if( jQuery('input[name=custom-message]:checked').val() == 'predefined' )
			{
			    var selected		= joms.jQuery('#custom-predefined').val();
			    var selectedText	= joms.jQuery('#custom-predefined :selected').html();
			    
			    if( selected != 'default' )
				{
					jax.call( 'community' , 'activities,ajaxAddPredefined' , selected , selectedText );
 				}
			}
			else
			{
			    customText  =   joms.jQuery.trim( joms.jQuery('#custom-text').val() );

			    if( customText.length != 0 ){
				    jax.call( 'community' , 'activities,ajaxAddPredefined' , 'system.message' , customText );
			    }
			}
		},
		append: function( html ){
			joms.jQuery( '#activity-more,#activity-exclusions' ).remove();
			joms.jQuery( '#activity-stream-container' ).append( html );
			joms.jQuery('body').focus();
		},
		initMap: function()
		{
			if(joms.jQuery('.newsfeed-mapFade').length) {
				joms.jQuery('.newsfeed-mapFade').live('mouseenter',function(e) {
					joms.jQuery(this).find('img:eq(2)').fadeOut(300).data('hidden',1);
					
					
				});
				joms.jQuery('.newsfeed-mapFade').live('mouseleave',function(e) {
					joms.jQuery(this).find('img:eq(2)').fadeIn(300).data('hidden',0);
				});
				
								
				//console.log(mpX + ' - ' + mpY);
				
				joms.jQuery('.newsfeed-mapFade').mousemove(function(e) {
					//console.log("move mouse");
					
					var offObj = joms.jQuery('.newsfeed-mapFade').offset();
				
					var x = offObj.left;
					var y = offObj.top;
					var ex = joms.jQuery('.newsfeed-mapFade').width() + x;
					var ey = joms.jQuery('.newsfeed-mapFade').height() + y;
					
					//console.log("Enter mouse");
					// Calculate middlepoint
					var mpX = x + ((ex - x) / 2);
					var mpY = y + ((ey - y) / 2);
				
					// if mouse is within small target zone
					if (e.pageX <= (mpX+15)
						&& e.pageX >= (mpX-15)
						&& e.pageY <= (mpY+5)
						&& e.pageY >= (mpY-35))
					{
						if(!joms.jQuery(this).find('img:eq(1)').data('hidden')) {
							joms.jQuery(this).find('img:eq(1)').fadeOut(300).data('hidden',1);
						}
					} else {
						if(joms.jQuery(this).find('img:eq(1)').data('hidden')) {
							joms.jQuery(this).find('img:eq(1)').fadeIn(300).data('hidden',0);
						}
					}
				});
					
					
			}		
		},
		more: function(){
			// Retrieve exclusions so we won't fetch the same data again.
			var exclusions	= joms.jQuery('#activity-exclusions').val();
			
			var categoryFilter = '';
			
			if(joms.jQuery('.all-activity').hasClass('active-state')){
				categoryFilter = 'all';
			}else if(joms.jQuery('.me-and-friends-activity').hasClass('active-state')){
				categoryFilter = 'friends';
			}else if(joms.jQuery('.p-active-profile-activity').hasClass('active-state')){
				categoryFilter = 'self';
			}else if(joms.jQuery('.p-active-profile-and-friends-activity').hasClass('active-state')){
				categoryFilter = 'friends';
			}else{
				categoryFilter = 'self';
			}
			
			// Show loading image
			joms.jQuery( '#activity-more .more-activity-text' ).hide();
			joms.jQuery( '#activity-more .loading' ).show().css( 'float' , 'none' ).css( 'margin' , '5px 5px 0 180px');
			jax.call( 'community' , 'activities,ajaxGetActivities' , exclusions , joms.jQuery( '#community-wrap #activity-type').val(), js_profileId,'',categoryFilter );
		},
		appendLatest: function(html, delay, text){
			//joms.jQuery( '#activity-exclusions' ).remove();
			joms.jQuery('ul.cFeed').prepend(html);
			
			var totalNewUpdate = joms.jQuery('.newly-added').length;

			if(totalNewUpdate > 0){
				joms.jQuery('#activity-update-click').html(text);
				/*
				if(totalNewUpdate == 1){
					joms.jQuery('#activity-update-click').html("1 new update");
				}else{
					joms.jQuery('#activity-update-click').html(totalNewUpdate+" new updates");
				}
				*/
				joms.jQuery('.joms-latest-activities-container').show();
			}
			setTimeout("reloadActivities();",delay);
		},
		nextActivitiesCheck: function(delay){
			setTimeout("reloadActivities();",delay);
		},
		getLatestContent: function (latestId,isProfilePage){
			// Retrieve exclusions so we won't fetch the same data again.
			var exclusions = joms.jQuery('#activity-exclusions').val();
			var categoryFilter = '';
			
			if(joms.jQuery('.all-activity').hasClass('active-state')){
				categoryFilter = 'all';
			}else if(joms.jQuery('.me-and-friends-activity').hasClass('active-state')){
				categoryFilter = 'friends';
			}else if(joms.jQuery('.p-active-profile-activity').hasClass('active-state')){
				categoryFilter = 'self';
			}else if(joms.jQuery('.p-active-profile-and-friends-activity').hasClass('active-state')){
				categoryFilter = 'friends';
			}else{
				categoryFilter = 'self';
			}
			
			//pause if cWindow is enabled
			if(joms.jQuery('div#cWindow').hasClass('dialog')){
				joms.activities.nextActivitiesCheck(5000);
			}else if(latestId > 0){
				jax.call( 'community' , 'activities,ajaxGetActivities' , '' , joms.jQuery( '#community-wrap #activity-type').val(), js_profileId, latestId, isProfilePage,categoryFilter );
			}
		}
	},
	apps: {
		windowTitle: '',
		toggle: function (id){
			joms.jQuery(id).children('.app-box-actions').slideToggle('fast');
			joms.jQuery(id).children('.app-box-footer').slideToggle('fast');
			joms.jQuery(id).children('.app-box-content').slideToggle('fast',
				function() {

					joms.jQuery.cookie( id , joms.jQuery(this).css('display') );
					joms.jQuery(id).toggleClass('collapse', (joms.jQuery(this).css('display')=='none'));
				}
			);
		},
		showAboutWindow: function(appName){
			var ajaxCall = "jax.call('community', 'apps,ajaxShowAbout', '"+appName+"');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		showPrivacyWindow: function(appName){
			var ajaxCall = "jax.call('community', 'apps,ajaxShowPrivacy', '"+appName+"');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		showSettingsWindow: function(id, appName){
			var ajaxCall = "jax.call('community', 'apps,ajaxShowSettings', '"+id+"', '"+appName+"');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		savePrivacy: function(){
			var value   = joms.jQuery('input[name=privacy]:checked').val();
			var appName = joms.jQuery('input[name=appname]').val();
			jax.call('community', 'apps,ajaxSavePrivacy', appName, value);
		},
		saveSettings: function(){
			jax.call('community', 'apps,ajaxSaveSettings', jax.getFormValues('appSetting'));
		},
		remove: function(appName){
			var ajaxCall = "jax.call('community', 'apps,ajaxRemove', '"+appName+"');";
			cWindowShow(ajaxCall, this.windowTitle, 450, 100);
		},
		add: function(appName){
			jax.call('community', 'apps,ajaxAdd', appName );
		},
		initToggle: function(){
			joms.jQuery('.app-box').each(function(){
				var id	= '#' + joms.jQuery(this).attr('id');

				if(joms.jQuery.cookie( id )=='none')
				{
					joms.jQuery(id).addClass('collapse');
					joms.jQuery(id).children('.app-box-actions').css('display' , 'none' );
					joms.jQuery(id).children('.app-box-footer').css('display' , 'none' );
					joms.jQuery(id).children('.app-box-content').css('display' , 'none' );
				}
			});
		}
	},
	bookmarks:{
		show: function( currentURI ){
			var ajaxCall = "jax.call('community', 'bookmarks,ajaxShowBookmarks','" + currentURI + "');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		email: function( currentURI ){

			var formContent	= jax.getFormValues('bookmarks-email');
			var content		= formContent[1][1];
			var email		= formContent[0][1];

			var ajaxCall = "jax.call('community', 'bookmarks,ajaxEmailPage','" + currentURI + "','" +  email + "',\"" + content + "\");";
			cWindowShow( ajaxCall , '', 450, 100);
		}
	},
	report: {
		emptyMessage: '',

		checkReport: function(){
			if( joms.jQuery( '#report-message' ).val() == '' )
			{
				joms.jQuery( '#report-message-error' ).html( this.emptyMessage ).css( 'color' , 'red' );
				return false;
			}
			return true;
		},
		showWindow: function ( reportFunc, arguments ){   
			var ajaxCall	= 'jax.call("community" , "system,ajaxReport" , "' + reportFunc + '","' + location.href + '" ,' + arguments + ');';
			cWindowShow(ajaxCall, '', 450, 100);
		},
		submit: function ( reportFunc , pageLink , arguments ){
			if( joms.report.checkReport() )
			{
			var formVars = jax.getFormValues('report-form');

			var ajaxcall='jax.call("community", "system,ajaxSendReport","' + reportFunc + '","' + location.href + '","' + formVars[1][1] + '" , ' + arguments + ')';

// 				var message	= escape( joms.jQuery('#report-message').val() );
// 				var ajaxcall='jax.call("community", "system,ajaxSendReport","' + reportFunc + '","' + location.href + '","' + message + '" , ' + arguments + ')';
				cWindowShow(ajaxcall, '', 450, 100);
			}
		}
	},
	featured: {
		add: function(uniqueId , controller ){
			var ajaxCall = "jax.call('community', '" + controller + ",ajaxAddFeatured', '"+uniqueId+"');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		remove: function(uniqueId , controller ){
			var ajaxCall = "jax.call('community','" + controller + ",ajaxRemoveFeatured','" + uniqueId + "');";
			cWindowShow(ajaxCall,'', 450, 100);
		}
	},
	flash: {
		enabled: function(){
			// ie
			try
			{
				try
				{
					// avoid fp6 minor version lookup issues
					// see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
					var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
					try
					{
						axo.AllowScriptAccess = 'always';
					}
					catch(e)
					{
						return '6,0,0';
					}
				}
				catch(e)
				{
				}
				return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
			// other browsers
			}
			catch(e)
			{
				try
				{
					if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)
					{
						return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
					}
				}
				catch(e)
				{
				}
			}
			return false;
		}
	},
	invitation:{
		showForm: function( users , callback , cid , displayFriends , displayEmail ){
			var ajaxCall	= 'jax.call("community", "system,ajaxShowInvitationForm","' + users + '","' + callback + '","' + cid + '","' + displayFriends + '","' + displayEmail + '")';
			var height		= 520;
			
			height			= displayFriends != "0" ? height : height - 108;
			height			= displayEmail != "0" ? height : height - 108;

			cWindowShow(ajaxCall, '', 550, height );
		},
		send: function( callback , cid ){
			jax.call( 'community' , 'system,ajaxSubmitInvitation' , callback , cid , jax.getFormValues('community-invitation-form') );
		},
		selectMember:function( element ){
		
			if( joms.jQuery( element + ' input').is(':checked') )
			{
				joms.jQuery( element ).addClass('invitation-item-invited').children('.invitation-checkbox').show();
			}
			else
			{
				joms.jQuery( element ).removeClass('invitation-item-invited');
			}
		},
		selectNone: function ( listID ){
			joms.jQuery(listID).find('li').each(function() {
				joms.jQuery(this).removeClass('invitation-item-invited');
				joms.jQuery(this).find('input').attr('checked', false);
				//joms.invitation.selectMember('#'+joms.jQuery(this).attr('id'));
			});
		},
		selectAll: function ( listID ){
			joms.invitation.selectNone(listID);
			joms.jQuery(listID).find('li').each(function() {
				joms.jQuery(this).find('input').click();
				joms.invitation.selectMember('#'+joms.jQuery(this).attr('id'));
			});
		}
	},
	album:{
	  init: function(){
	    joms.jQuery('.album').hover(
	      function() {
	        // only show the hover menu if there's actually something in it
	        if(joms.jQuery(this).find('.album-actions a').length) joms.jQuery(this).find('.album-actions').fadeIn('fast');
	      }, function() {
	        joms.jQuery(this).find('.album-actions').stop(true, true).hide();
	      }
	    );
	
		joms.jQuery('.video-item').hover(
	      function() {
	        // only show the hover menu if there's actually something in it
	        if(joms.jQuery(this).find('.album-actions a').length) joms.jQuery(this).find('.album-actions').fadeIn('fast');
	      }, function() {
	        joms.jQuery(this).find('.album-actions').stop(true, true).hide();
	      }
	    );
	    
	    joms.jQuery('.cFeaturedItem').hover(
        function() {
          // only show the hover menu if there's actually something in it
          if(joms.jQuery(this).find('.album-actions a').length) joms.jQuery(this).find('.album-actions').fadeIn('fast');
        }, function() {
          joms.jQuery(this).find('.album-actions').stop(true, true).hide();
        }
      );
	    
	    
	  }
	},
	memberlist:{
		submit: function(){
		
			if( joms.jQuery('input#title').val() == '' )
			{
				joms.jQuery('#filter-title-error').show();
				return false;
			}
			
			if( joms.jQuery('textarea#description').val() == '' )
			{
				joms.jQuery('#filter-description-error').show();
				return false;
			}
			
			joms.jQuery('#jsform-memberlist-addlist').submit();
		},
		showSaveForm: function( keys , filterJson ){
			var keys = keys.split( ',' );
			var values = Array();
			var avatarOnly	= jQuery('#avatar:checked').val() != 1 ? 0 : 1;
			
			for( var i = 0; i < keys.length ; i++ )
			{
				var tmpArray	= new Array();
				var value		= '';
				var key			= keys[i];
                                
				if( filterJson['fieldType' + key] == 'birthdate' && filterJson['condition' + key] == 'between')
				{
					value		= filterJson[ 'value' + keys[i] ] + ',' + filterJson[ 'value' + keys[i] + '_2' ]
				}
				else
				{
					value	= filterJson[ 'value' + keys[ i ] ];
				}

				values[i]	= new Array( 'field=' + filterJson['field'+ keys[i] ] , 
										 'condition=' + filterJson['condition'+ keys[i]] ,
										 'fieldType=' + filterJson['fieldType'+ keys[i]] ,
										 'value=' + value 
									);
			}
			
			var valuesString = '';
			for( var x = 0; x < values.length; x++ )
			{
				valuesString += '"' + values[x] + '"';

				if( (x + 1) != values.length )
					valuesString += ',';
			}
			
			var ajaxCall = 'jax.call("community", "memberlist,ajaxShowSaveForm","' + joms.jQuery("input[@name=operator]:checked").val() + '","' + avatarOnly + '",' + valuesString + ');';
			cWindowShow(ajaxCall, '', 470, 300);
		}
	},
	notifications: {
		showWindow: function (){
			var ajaxCall = 'jax.call("community", "notification,ajaxGetNotification", "")';
			cWindowShow(ajaxCall, '', 450, 100);
		},
		updateNotifyCount: function (){
			var notifyCount	= joms.jQuery('#toolbar-item-notify-count').text();

			if(joms.jQuery.trim(notifyCount) != '' && notifyCount > 0)
			{
				//first we update the count. if the updated count == 0, then we hide the tab.
				notifyCount = notifyCount - 1;
				joms.jQuery('#toolbar-item-notify-count').html(notifyCount);
				if (notifyCount == 0)
				{
					joms.jQuery('#toolbar-item-notify').hide(); 
					setTimeout('cWindowHide()', 1000);
				}
			}
		}
	},
	filters:{
		bind: function(){
			var loading	= this.loading;
			joms.jQuery(document).ready( function()
			{
				//sorting option binding for members display
				joms.jQuery('.newest-member').bind('click', function() {
				    if ( !joms.jQuery(this).hasClass('active-state') ) {
				        loading( joms.jQuery(this).attr('class') );
						jax.call('community', 'frontpage,ajaxGetNewestMember', frontpageUsers);
					}
				});
				joms.jQuery('.active-member').bind('click', function() {
				    if ( !joms.jQuery(this).hasClass('active-state') ) {
			            loading( joms.jQuery(this).attr('class') );
						jax.call('community', 'frontpage,ajaxGetActiveMember', frontpageUsers);
					}
				});
				joms.jQuery('.popular-member').bind('click', function() {
				    if ( !joms.jQuery(this).hasClass('active-state') ) {
				        loading( joms.jQuery(this).attr('class') );
				    	jax.call('community', 'frontpage,ajaxGetPopularMember', frontpageUsers);
					}
				});
				joms.jQuery('.featured-member').bind('click', function() {
				    if ( !joms.jQuery(this).hasClass('active-state') ) {
				        loading( joms.jQuery(this).attr('class') );
				    	jax.call('community', 'frontpage,ajaxGetFeaturedMember', frontpageUsers);
					}
				});

				//sorting option binding for activity stream
				joms.jQuery('.all-activity').bind('click', function() {
				    if ( !joms.jQuery(this).hasClass('active-state') ) {
			            loading( joms.jQuery(this).attr('class') );
						joms.ajax.call('frontpage,ajaxGetActivities', [ 'all' ] , {
							success: function()
							{
								joms.jQuery( '#activity-type' ).val( 'all' );
							}
						});
					}
				});
				joms.jQuery('.me-and-friends-activity').bind('click', function() {
				    if ( !joms.jQuery(this).hasClass('active-state') ) {
				        loading( joms.jQuery(this).attr('class') );
				    	joms.ajax.call('frontpage,ajaxGetActivities', [ 'me-and-friends' ] , {
							success: function()
							{
								joms.jQuery( '#activity-type' ).val( 'me-and-friends' );
							}
						});
					}
				});
				joms.jQuery('.active-profile-and-friends-activity').bind('click', function() {
				    if ( !joms.jQuery(this).hasClass('active-state') ) {
				        loading( joms.jQuery(this).attr('class') );
				    	jax.call('community', 'frontpage,ajaxGetActivities', 'active-profile-and-friends', joms.user.getActive());
					}
				});
				joms.jQuery('.active-profile-activity').bind('click', function() {
				    if ( !joms.jQuery(this).hasClass('active-state') ) {
				        loading( joms.jQuery(this).attr('class') );
				    	jax.call('community', 'frontpage,ajaxGetActivities', 'active-profile', joms.user.getActive());
					}
				});
				joms.jQuery('.p-active-profile-and-friends-activity').bind('click', function() {
				    if ( !joms.jQuery(this).hasClass('active-state') ) {
				        loading( joms.jQuery(this).attr('class') );
				    	jax.call('community', 'frontpage,ajaxGetActivities', 'active-profile-and-friends', joms.user.getActive(), 'profile');
					}
				});
				joms.jQuery('.p-active-profile-activity').bind('click', function() {
				    if ( !joms.jQuery(this).hasClass('active-state') ) {
				        loading( joms.jQuery(this).attr('class') );
				    	jax.call('community', 'frontpage,ajaxGetActivities', 'active-profile', joms.user.getActive(), 'profile');
					}
				});

				// sorting and binding for videos
				joms.jQuery('.newest-videos').bind('click', function() {
				    if ( !joms.jQuery(this).hasClass('active-state') ) {
				        loading( joms.jQuery(this).attr('class') );
						jax.call('community', 'frontpage,ajaxGetNewestVideos', frontpageVideos);
					}
				});
				joms.jQuery('.popular-videos').bind('click', function() {
				    if ( !joms.jQuery(this).hasClass('active-state') ) {
				        loading( joms.jQuery(this).attr('class') );
				    	jax.call('community', 'frontpage,ajaxGetPopularVideos', frontpageVideos);
					}
				});
				joms.jQuery('.featured-videos').bind('click', function() {
				    if ( !joms.jQuery(this).hasClass('active-state') ) {
				        loading( joms.jQuery(this).attr('class') );
				    	jax.call('community', 'frontpage,ajaxGetFeaturedVideos', frontpageVideos);
					}
				});

				// remove last link border
				joms.jQuery('.popular-member').css('border-right', '0').css('padding-right', '0');
				joms.jQuery('.me-and-friends-activity').css('border-right', '0').css('padding-right', '0');
				joms.jQuery('.active-profile-activity').css('border-right', '0').css('padding-right', '0');
			});
		},
		loading: function(element){
			elParent = joms.jQuery('.'+element).parent().parent().attr('id');
			if ( elParent === '' ) {
		        elParent = joms.jQuery('.'+element).parent().attr('id');
			}
		    joms.jQuery('#' + elParent + ' .loading').show();
		    joms.jQuery('#' + elParent + ' a').removeClass('active-state');
		    joms.jQuery('.'+element).addClass('active-state');
		},
		hideLoading: function(){
			joms.jQuery( '.loading' ).hide();
			// rebind the tooltip
			joms.jQuery('.jomTipsJax').addClass('jomTips');
			joms.tooltip.setup();
		}
	},
	groups: {
		invitation: {
			accept: function( groupId ){
				jax.call( 'community' , 'groups,ajaxAcceptInvitation' , groupId )
			},
			reject: function( groupId ){
				jax.call( 'community' , 'groups,ajaxRejectInvitation' , groupId  );
			}
		},
		addInvite: function( element ){
			var parentId = joms.jQuery('#' +element).parent().attr('id');

			if(parentId == "friends-list")
			{
				joms.jQuery("#friends-invited").append(joms.jQuery('#' +element)).html();
			}
			else
			{
				joms.jQuery("#friends-list").append(joms.jQuery('#' +element)).html();
			}
		},
		removeTopic: function( title , groupid , topicid ){
			var ajaxCall = 'jax.call("community","groups,ajaxShowRemoveDiscussion", "' + groupid + '","' + topicid + '");';
			cWindowShow(ajaxCall, title, 450, 100);
		},
		lockTopic: function( title , groupid , topicid ){
			var ajaxCall = 'jax.call("community","groups,ajaxShowLockDiscussion", "' + groupid + '","' + topicid + '");';
			cWindowShow(ajaxCall, title, 450, 100);
		},
		editBulletin: function(){

			if( joms.jQuery('#bulletin-edit-data').css('display') == 'none' )
			{
				joms.jQuery('#bulletin-edit-data').show();
			}
			else
			{
				joms.jQuery('#bulletin-edit-data').hide();
			}

		},
		removeBulletin: function( title , groupid , bulletinid ){
			var ajaxCall = 'jax.call("community", "groups,ajaxShowRemoveBulletin", "' + groupid + '","' + bulletinid + '");';
			cWindowShow(ajaxCall, title, 450, 100);
		},
		unpublish: function( groupId ){
			jax.call( 'community' , 'groups,ajaxUnpublishGroup', groupId);
		},
		leave: function( groupid ){
			var ajaxCall = 'jax.call("community", "groups,ajaxShowLeaveGroup", "' + groupid + '");';
			cWindowShow(ajaxCall, '', 450, 100);
		},
		joinWindow: function( groupid ){
			var ajaxCall = 'jax.call("community", "groups,ajaxShowJoinGroup", "' + groupid + '", location.href );';
			cWindowShow(ajaxCall, '', 450, 100);
		},
		edit: function(){
			// Check if input is already displayed
			joms.jQuery('#community-group-info .cdata').each(function(){
				// Test if the next div is cinput

				if(joms.jQuery(this).next().html() && joms.jQuery(this).css('display') != 'none' )
					joms.jQuery(this).css('display' , 'none');
				else
					joms.jQuery(this).css('display' , 'block');
			});

			joms.jQuery('#community-group-info .cinput').each(function(){
				if(joms.jQuery(this).css('display') == 'none')
					joms.jQuery(this).css('display' , 'block');
				else
					joms.jQuery(this).css('display' , 'none');
			});

			if(joms.jQuery('div#community-group-info-actions').css('display') != 'none')
				joms.jQuery('div#community-group-info-actions').css('display' , 'none');
			else
				joms.jQuery('div#community-group-info-actions').css('display' , 'block');
		},
		save: function( groupid ){
			var name		= joms.jQuery('#community-group-name').val();
			var description	= joms.jQuery('#community-group-description').val();
			var website		= joms.jQuery('#community-group-website').val();
			var category	= joms.jQuery('#community-group-category').val();
			var approvals	= joms.jQuery("input[@name='group-approvals']:checked").val();

			jax.call('community' , 'groups,ajaxSaveGroup' , groupid , name , description , website , category , approvals);
		},
		update: function( groupName , groupDescription , groupWebsite , groupCategory){
			// Re-update group data
			joms.jQuery('#community-group-data-name').html( groupName );
			joms.jQuery('#community-group-data-description').html( groupDescription );
			joms.jQuery('#community-group-data-website').html( groupWebsite );
			joms.jQuery('#community-group-data-category').html( groupCategory );
			this.edit();
		},
		deleteGroup: function( groupId ){
			var ajaxCall = "jax.call('community', 'groups,ajaxWarnGroupDeletion', '" + groupId + "');";
			cWindowShow(ajaxCall, '', 450, 100, 'error');
		},
		toggleSearchSubmenu: function( e ){

			joms.jQuery(e).next('ul').toggle().find('input[type=text]').focus();
		},
		confirmMemberRemoval: function( memberId, groupId ){

			var ajaxCall = function()
			{
				jax.call("community", "groups,ajaxConfirmMemberRemoval", memberId, groupId);	
			};

			cWindowShow(ajaxCall, '', 450, 80, 'warning');
		},
		removeMember: function( memberId , groupId ){
			var banMember = joms.jQuery('#cWindow input[name=block]').attr('checked');

			if (banMember)
			{
				jax.call('community', 'groups,ajaxBanMember', memberId , groupId );
			} else {
				jax.call('community', 'groups,ajaxRemoveMember', memberId , groupId );
			}			
		}		
	},
	friends: {
		saveTag: function(){
			var formVars = jax.getFormValues('tagsForm');
			jax.call("community", "friends,ajaxFriendTagSave", formVars);
			return false;
		},
		saveGroup: function(userid) {
			if(document.getElementById('newtag').value == ''){
			    window.alert('TPL_DB_INVALIDTAG');
			}else{
				jax.call("community", "friends,ajaxAddGroup",userid,joms.jQuery('#newtag').val());
			}
		},
		cancelRequest: function( friendsId ){
			var ajaxCall = 'jax.call("community" , "friends,ajaxCancelRequest" , "' + friendsId + '");';
			cWindowShow(ajaxCall, '', 450, 100);
		},
		connect: function( friendid ){
			var ajaxCall = 'jax.call("community", "friends,ajaxConnect", '+friendid+')';
			cWindowShow(ajaxCall, '', 450, 100);
		},
		addNow: function(){
		 	var formVars = jax.getFormValues('addfriend');
		 	jax.call("community", "friends,ajaxSaveFriend",formVars);
		 	return false;
		},
		confirmFriendRemoval: function( friendId ){

			var ajaxCall = function()
			{
				jax.call("community", "friends,ajaxConfirmFriendRemoval", friendId);	
			};

			cWindowShow(ajaxCall, '', 450, 80, 'warning');
		},
		remove: function( friendId ) {
			var blockFriend = joms.jQuery('#cWindow input[name=block]').attr('checked');

			var ajaxCall;
			if (blockFriend)
			{
				ajaxCall = function()
				{
					jax.call("community", "friends,ajaxBlockFriend", friendId);
				};
			} else {
				ajaxCall = function()
				{
					jax.call("community", "friends,ajaxRemoveFriend", friendId);
				};
			}

			cWindowShow(ajaxCall, '', 450, 80, 'warning');
		}
	},
	messaging: {
		loadComposeWindow: function(userid){
			var ajaxCall = 'jax.call("community", "inbox,ajaxCompose", '+userid+')';
			cWindowShow(ajaxCall, '', 450, 100);
		},
		send: function(){
			var formVars = jax.getFormValues('writeMessageForm');
			jax.call("community", "inbox,ajaxSend", formVars);
			return false;
		}
	},
	walls: {
		insertOrder: 'prepend',
		add: function ( uniqueId, addFunc ){

			jax.loadingFunction = function()
			{
				joms.jQuery('#wall-message,#wall-submit').attr('disabled', true);
			}

			jax.doneLoadingFunction = function()
			{
				joms.jQuery('#wall-message,#wall-submit').attr('disabled', false);
			};

			if(typeof getCacheId == 'function')
			{
				cache_id = getCacheId();
			}
			else
			{
				cache_id = "";
			}

			jax.call('community', addFunc, joms.jQuery('#wall-message').val(), uniqueId, cache_id);
		},
		insert: function( html ){
			joms.jQuery('#wall-message').val('');
			if(joms.walls.insertOrder == 'prepend'){
				joms.jQuery('#wallContent').prepend(html);
			} else{
				// append
				joms.jQuery('#wallContent .wallComments:last').after(html);
			}
		},
		remove: function( type , wallId , contentId ){
			if(confirm('Are you sure you want to delete this wall?'))
			{
				jax.call('community' , type + ',ajaxRemoveWall' , wallId , contentId );
				joms.jQuery('#wall_' + wallId ).fadeOut('normal', function(){joms.jQuery(this).remove()});

				// Process ajax calls
			}
		},
		update: function( id , message ){
			//Hide popups
			cWindowHide();

			//Update the existing html codes
			joms.jQuery( '#wall_' + id ).replaceWith( message );
		},
		save: function( id , editableFunc ){
			jax.call('community' , 'system,ajaxUpdateWall' , id , joms.jQuery('#wall-edit-' + id).val() , editableFunc );
		},
		edit: function( id , permissionFunc ){

			if( joms.jQuery('#wall-edit-' + id ).val() != null )
			{
				joms.jQuery('#wall-message-'+ id).show();
				joms.jQuery('#wall-edit-container-'+ id).remove();
			}
			else
			{
				// Hide current message
				joms.jQuery('#wall-message-' + id ).hide();
				joms.jQuery('#wall_' + id + ' div.content').prepend( '<span id="wall-edit-container-' + id + '"></span>').prepend('<div class="loading" style="display:block;float: left;"></div>');

				jax.call('community' , 'system,ajaxEditWall' , id , permissionFunc );
				joms.utils.textAreaWidth('#wall-edit-' + id );
				joms.utils.autogrow('#wall-edit-' + id);
			}
		},
		more: function(){
			// Pass the necessary params to ajaxGetOlderWalls
			var groupId			= joms.jQuery('#wall-groupId').val();
			var discussionId	= joms.jQuery('#wall-discussionId').val();
			var limitStart		= joms.jQuery('#wall-limitStart').val();
			
			// Show loading image
			joms.jQuery( '#wall-more .more-wall-text' ).hide();
			joms.jQuery( '#wall-more .loading' ).show().css( 'float' , 'none' ).css( 'margin' , '5px 5px 0 180px');
			jax.call( 'community' , 'system,ajaxGetOlderWalls' , groupId, discussionId, limitStart );
		},
		append: function( html ){
			//joms.jQuery("#wallContent div.wallComments:last").css('border-bottom', '1px dotted #333');
			joms.jQuery( '#wall-more,#wall-groupId,#wall-discussionId,#wall-limitStart' ).remove();
			joms.jQuery( '#wall-containter' ).append( html );
		},
		prepend: function( html ){
			joms.jQuery( '#wall-more' ).remove();
			joms.jQuery( '#wall-groupId' ).remove();
			joms.jQuery( '#wall-discussionId' ).remove();
			joms.jQuery( '#wall-limitStart' ).remove();
			joms.jQuery( '#wall-containter' ).prepend( html );
		}
	},
	toolbar: {
		timeout: 500,
		closetimer: 0,
		ddmenuitem: 0,
		open: function( id ){

			if ( joms.jQuery('#'+id).length > 0 ) {
				// cancel close timer
				joms.toolbar.cancelclosetime();

				// close old layer
				if(joms.toolbar.ddmenuitem)
				{
					joms.toolbar.ddmenuitem.style.visibility = 'hidden';
				}

				// get new layer and show it
				joms.toolbar.ddmenuitem = document.getElementById(id);
				joms.toolbar.ddmenuitem.style.visibility = 'visible';
			}
		},
		close: function(){
			if(joms.toolbar.ddmenuitem)
			{
				joms.toolbar.ddmenuitem.style.visibility = 'hidden';
			}
		},
		closetime: function(){
			joms.toolbar.closetimer	= window.setTimeout( joms.toolbar.close , joms.toolbar.timeout );
		},
		cancelclosetime: function(){
			if( joms.toolbar.closetimer )
			{
				window.clearTimeout( joms.toolbar.closetimer );
				joms.toolbar.closetimer = null;
			}
		}
	},
	registrations:{
		showTermsWindow: function(){
			var ajaxCall = 'jax.call("community", "register,ajaxShowTnc", "")';
			cWindowShow(ajaxCall, this.windowTitle , 600, 350);
		},
		authenticate: function(){
			jax.call("community", "register,ajaxGenerateAuthKey");
		},
		authenticateAssign: function(){
			jax.call("community", "register,ajaxAssignAuthKey");
		},
		assignAuthKey: function(fname, lblname, authkey){
			eval("document.forms['" + fname + "'].elements['" + lblname + "'].value = '" + authkey + "';");
		},
		showWarning: function(message) {
			cWindowShow('joms.jQuery(\'#cWindowContent\').html(\''+message+'\')' , 'Notice' , 450 , 200 , 'warning');
		}
	},
	
	miniwall:{
	  initialize: function() {
	    //alert('init');
	    joms.jQuery('.wall-coc-item').hover(
	      function() {       // hover in function
	        joms.jQuery(this).find('.wall-coc-remove-link').stop(true, true).fadeIn('fast');
	      },
	      function () {      // hover out function
	        joms.jQuery(this).find('.wall-coc-remove-link').stop(true, true).fadeOut('fast');
	      }
	    );
	  },
		add: function(id){
			var cmt = joms.jQuery('#wall-cmt-'+ id +' textarea').val();
			cmt = joms.jQuery.trim(cmt);
			if(cmt.length > 0) 
			{
				joms.jQuery('#wall-cmt-'+ id +' .wall-coc-form-action.add').attr('disabled', true);
				joms.jQuery('#wall-cmt-'+ id +' .wall-coc-errors').hide();
				
				jax.loadingFunction = function() {
				  joms.jQuery('#wall-cmt-'+ id +' textarea').attr('disabled', true);
					
					joms.jQuery('#wall-cmt-'+ id +' .wall-coc-form-actions').append('<em class="wall-cmt-loading">Posting...</em>');
					jax.loadingFunction = function() {}				// clear the callbacks after each call
				};
				
				jax.doneLoadingFunction = function() {
					// joms.jQuery('#wall-cmt-'+ id +' .wall-coc-form-actions em').html('Comment posted!');
					// setTimeout("joms.jQuery('#wall-cmt-"+ id +" .wall-coc-form-actions em').fadeOut()", 800);
					joms.jQuery('#wall-cmt-'+ id +' .wall-coc-form-actions').find('em').remove();
					joms.jQuery('#wall-cmt-'+ id +' textarea').attr('disabled', false).val('');
					joms.jQuery('#wall-cmt-'+ id +' .wall-coc-form-action.add').attr('disabled', false);
					
					// update comment count
					cmtCountObj = joms.jQuery('#wall-cmt-'+id).parent().parent().find('.wall-cmt-count');
					curCmtCount = parseInt(cmtCountObj.html());
					cmtCountObj.parent().fadeOut('fast', function() {
              // plus one and update the value again
              cmtCountObj.html(curCmtCount + 1);
              cmtCountObj.parent().fadeIn('fast');
          });
					joms.miniwall.initialize();
					jax.doneLoadingFunction = function() {}			// clear the callbacks after each call
				};
				
				jax.call("community", "system,ajaxStreamAddComment", id, cmt);
			}
		},
		insert: function(id, text){
			// Form must be there, if a user cannot comment
			joms.jQuery('#wall-cmt-'+ id +' .wallform').before(text);
			// comment with zero comment could will have this class to hide the whole
			// comment area, remove it after we insert a new comment
			joms.jQuery('#wall-cmt-'+ id +' .wallnone').removeClass('wallnone');
			joms.miniwall.cancel(id);
			joms.miniwall.initialize();
		},
		loadall: function(id, text){
			// remove all element first
			joms.jQuery('#wall-cmt-'+id+' .wall-coc-item').remove();

			// replace the 'more' link with proper content
			joms.jQuery('#wall-cmt-'+id+' .wallmore').replaceWith(text);
			joms.miniwall.initialize();
		},
		cancel: function(id){
			joms.jQuery('#wall-cmt-'+ id +' textarea').val('');
			//joms.jQuery('#wall-cmt-'+ id +' .show-cmt').show();
			joms.jQuery('#wall-cmt-'+ id +' .wall-coc-errors').hide();
			joms.jQuery('#wall-cmt-'+ id +' .wall-coc-form-action.add').removeAttr('disabled');
			joms.jQuery('#wall-cmt-'+ id +' form').hide();
			joms.jQuery('#wall-cmt-'+ id +' .wallnone').css('display', 'none');
			
			/**
			 * Modified by Adam Lim on 13 July 2011
			 * Added condition to verify if there is any comment posted
			 * will only show [Reply] if there is comment, hide everything otherwise
			 */
			if (joms.jQuery('#wall-cmt-'+ id +' .wall-coc-item').length <= 0)//test
			{
				joms.jQuery('#wall-cmt-'+ id + ' .wallcmt').addClass('wallnone');
			}
			else
			{                   
				joms.jQuery('#wall-cmt-'+ id +' .show-cmt').show();
			}
		},
		remove: function(id){
		  
		  var cmtCountObj = joms.jQuery('#wall-'+id).parent().parent().parent().find('.wall-cmt-count');
		  
		  // change comment color to red while its being removed via ajax
		  jax.loadingFunction = function() {
          joms.jQuery('#wall-'+id)
            .css({backgroundColor: '#ffdddd'})
            .find('.wall-coc-remove-link').show().html('<em class="wall-cmt-loading wall-cmt-loading-inline">Removing...</em>');
          jax.loadingFunction = function() {}       // clear the callbacks after each call
        };
		  
      // setup callbacks after loading
      jax.doneLoadingFunction = function() {
          // find the currently shown value of the comment count
          var curCmtCount = parseInt(cmtCountObj.html());
          //alert(curCmtCount);
          if(curCmtCount > 0) {
            
            // if this is the last comment, remove the last  'Reply' link as well
            if(curCmtCount == 1) {
              joms.jQuery('#wall-'+id).parent().parent().find('.wallcmt:last').addClass('wallnone');
            }
            
            // flash the count so it looks more interesting
            cmtCountObj.parent().fadeOut('fast', function() {
              // minus one and update the value again
              cmtCountObj.html(curCmtCount - 1);
              cmtCountObj.parent().fadeIn('fast');
            });
          }
          // now remove the display of that particular comment
          joms.jQuery('#wall-'+id).fadeOut('slow', function() {
            joms.jQuery(this).remove();
          }).find('.wall-coc-remove-link').hide();
          joms.miniwall.initialize();
          jax.doneLoadingFunction = function() {}     // clear the callbacks after each call
      };
		  
			jax.call('community', 'system,ajaxStreamRemoveComment', id);
		},
		show: function(id){
			try{
			var w = joms.jQuery('#'+ id +' form').parent().width();

			joms.jQuery('#wall-cmt-'+ id +' .wall-coc-form-action.add').removeAttr('disabled');
			joms.jQuery('#wall-cmt-'+ id +' form').width(w).show();
			joms.jQuery('#wall-cmt-'+ id +' .show-cmt').hide();
			
			// The wall element is hidden if there is no comment at all, show it
			joms.jQuery('#wall-cmt-'+ id + ' .wallnone').removeClass('wallnone');
			
			// We need to remove all other textarea that were added by the autogrow function
			joms.jQuery('#wall-cmt-'+ id +' textarea:[name!="comment"]').remove();			
			
			// @todo: should only autogrow once.
			var textarea = joms.jQuery('#wall-cmt-'+ id +' textarea');
			if( !textarea.data('autogrow') )
			{
				joms.utils.textAreaWidth(textarea);
				joms.utils.autogrow(textarea);
				
				textarea.focus();
	
				textarea.blur(function(){
					if (joms.jQuery(this).val()=='') joms.miniwall.cancel(id);
				}).data('autogrow', true);
			}
			} catch(e){
				// donothing really
			}
			
		}
	},
		
	comments:{
		add: function(id){
			var cmt = joms.jQuery('#'+ id +' textarea').val();
			if(cmt != '') {
				joms.jQuery('#'+ id +' .wall-coc-form-action.add').attr('disabled', true);
				if(typeof getCacheId == 'function')
				{
					cache_id = getCacheId();
				}
				else
				{
					cache_id = "";
				}
				jax.call("community", "plugins,walls,ajaxAddComment", id, cmt, cache_id);
			}
		},
		insert: function(id, text){
			joms.jQuery('#'+ id +' form').before(text);
			joms.comments.cancel(id);
		},
		remove: function(obj){
			var cmtDiv = joms.jQuery(obj).parents('.wallcmt');
			var index  = joms.jQuery( cmtDiv ).index();
			try{console.log(index);} catch(err){}
			var parentId = joms.jQuery(obj).parents('.wallcmt').parent().attr('id');
			try{console.log(parentId);} catch(err){}
			//joms.jQuery(obj).parent('.wallcmt').remove();

			jax.call("community", "plugins,walls,ajaxRemoveComment", parentId, index);
		},
		cancel: function(id){
			joms.jQuery('#'+ id +' textarea').val('');
			joms.jQuery('#'+ id +' form').hide();
			joms.jQuery('#'+ id +' .show-cmt').show();
			joms.jQuery('#'+ id + ' .wall-coc-errors').hide();
			joms.jQuery('#'+ id +' .wall-coc-form-action.add').removeAttr('disabled');
		},
		show: function(id){
			var w = joms.jQuery('#'+ id +' form').parent().width();

			joms.jQuery('#'+ id +' .wall-coc-form-action.add').removeAttr('disabled');
			joms.jQuery('#'+ id +' form').width(w).show();
			joms.jQuery('#'+ id +' .show-cmt').hide();

			var textarea = joms.jQuery('#'+ id +' textarea');
			if( !textarea.data('autogrow') ){
				joms.utils.textAreaWidth(textarea);
				joms.utils.autogrow(textarea);
	
				textarea.blur(function(){
					if (joms.jQuery(this).val()=='') joms.comments.cancel(id);
			}).data('autogrow', true);
			}
		}
	},
	utils: {
		// Resize the width of the giventext to follow the innerWidth of
		// another DOM object
		// The textarea must be visible
		textAreaWidth: function(target) {
			with (joms.jQuery(target))
			{
				css('width', '100%');
				// Google Chrome doesn't return correct outerWidth() else things would be nicer.
				// css('width', width()*2 - outerWidth(true));
				css('width', width() - parseInt(css('borderLeftWidth'))
				                     - parseInt(css('borderRightWidth'))
				                     - parseInt(css('padding-left'))
				                     - parseInt(css('padding-right')));
			}
		},

		autogrow: function (id, options) {
			if (options==undefined)
				options = {};

			// In JomSocial, by default every autogrow element will have a 300 maxHeight.
			options.maxHeight = options.maxHeight || 300;

			joms.jQuery(id).autogrow(options);
		}
	},
	maps: {
		mapsObj: null,
		geocoder: null,
		initialize: function(target, address, title, info) {
			if(typeof google.maps =='undefined')
			{
				// Google map is not loaded yet, wait another 1 seconds?
				setTimeout('joms.maps.initialize(\''+target+'\', \''+address+'\')', 1000);
			}
			else
			{
				joms.maps.geocoder = new google.maps.Geocoder();
				joms.maps.geocoder.geocode( {'address': address}, function(results, status) {
					if (status == google.maps.GeocoderStatus.OK) {

						if(joms.maps.mapsObj == null)
						{
							joms.maps.mapsObj = new Array();
						}
						// @todo: unoptimized, should not load a random location first
						var latlng = new google.maps.LatLng(-34.397, 150.644);
					    var mapOptions = {
					      zoom: 14,
					      center: latlng,
					      mapTypeId: google.maps.MapTypeId.ROADMAP
					    }

					    // Map id is incremented for each map
					    var mapId = joms.maps.mapsObj.length;

					    joms.maps.mapsObj[mapId] = new google.maps.Map(document.getElementById(target), mapOptions);

						joms.maps.mapsObj[mapId].setCenter(results[0].geometry.location);
						var marker = new google.maps.Marker({
							map: joms.maps.mapsObj[mapId],
							position: results[0].geometry.location,
							title:title
						});

						if(info.length > 0){
							var infowindow = new google.maps.InfoWindow({
							    content: info
							});

							google.maps.event.addListener(marker, 'click', function() {
								var mapId  = joms.jQuery('div#'+target).data('maps');
								infowindow.open(joms.maps.mapsObj[mapId], marker);
							});
						}

						// Store map object in the div id
						joms.jQuery('div#'+target).data('maps', mapId);

					} else {
						alert("Geocode was not successful for the following reason: " + status);
					}
				});
			}
		},
		addMarker: function(target, lat, lng, title, info) {
			if(joms.maps.mapsObj == null)
			{
				// Google map is not loaded yet, wait another 1 seconds?
				setTimeout('joms.maps.addMarker(\''+target+'\', '+lat+', '+lng+', \''+title+'\', \''+info+'\')', 1000);
			}
			else
			{
				var mapId  = joms.jQuery('div#'+target).data('maps');
				var myLatlng = new google.maps.LatLng(lat,lng);
				var marker = new google.maps.Marker({
					position: myLatlng,
					map: joms.maps.mapsObj[mapId],
					title:title
				});

				if(info.length > 0){
					var infowindow = new google.maps.InfoWindow({
					    content: info
					});

					google.maps.event.addListener(marker, 'click', function() {
						var mapId  = joms.jQuery('div#'+target).data('maps');
						infowindow.open(joms.maps.mapsObj[mapId], marker);
					});
				}

			}
		}
	},
	connect: {
	    checkRealname: function( value ){
	        var tmpLoadingFunction  = jax.loadingFunction;
			jax.loadingFunction = function(){};
			jax.doneLoadingFunction = function(){jax.loadingFunction = tmpLoadingFunction;};
			jax.call('community','connect,ajaxCheckName', value);
		},
	    checkEmail: function( value ){
	        var tmpLoadingFunction  = jax.loadingFunction;
			jax.loadingFunction = function(){};
			jax.doneLoadingFunction = function(){jax.loadingFunction = tmpLoadingFunction;};
			jax.call('community','connect,ajaxCheckEmail', value);
		},
		checkUsername: function( value ){
	        var tmpLoadingFunction  = jax.loadingFunction;
			jax.loadingFunction = function(){};
			jax.doneLoadingFunction = function(){jax.loadingFunction = tmpLoadingFunction;};
		    jax.call('community','connect,ajaxCheckUsername', value);
		},
		// Displays popup that requires user to update their details upon
		update: function(){
			var ajaxCall = "jax.call('community', 'connect,ajaxUpdate' );";
			cWindowShow(ajaxCall, '', 450, 200);
		},
		updateEmail: function(){
		    joms.jQuery('#facebook-email-update').submit();
		},
		importData: function(){
		    var importStatus    = joms.jQuery('#importstatus').is(':checked') ? 1 : 0;
		    var importAvatar    = joms.jQuery('#importavatar').is(':checked') ? 1 : 0 ;
		    jax.call('community','connect,ajaxImportData',  importStatus , importAvatar );
		},
		mergeNotice: function(){
			var ajaxCall = "jax.call('community','connect,ajaxMergeNotice');";
			cWindowShow(ajaxCall, '', 450, 200);
		},
		merge: function(){
			var ajaxCall = "jax.call('community','connect,ajaxMerge');";
			cWindowShow(ajaxCall, '', 450, 200);
		},
		validateUser: function(){
			// Validate existing user
			var ajaxCall = "jax.call('community','connect,ajaxValidateLogin','" + joms.jQuery('#existingusername').val() + "','" + joms.jQuery('#existingpassword').val() + "');";
			cWindowShow(ajaxCall, '', 450, 200);
		},
		newUser: function(){
			var ajaxCall = "jax.call('community','connect,ajaxShowNewUserForm');";
			cWindowShow(ajaxCall, '', 450, 200);
		},
		existingUser: function(){
			var ajaxCall = "jax.call('community','connect,ajaxShowExistingUserForm');";
			cWindowShow(ajaxCall, '', 450, 200);
		},
		selectType: function(){
			if(joms.jQuery('[name=membertype]:checked').val() == '1' )
			{
				joms.connect.newUser();
			}
			else
			{
				joms.connect.existingUser();
			}
		},
		validateNewAccount: function(){
			// Check for errors on the forms.
			jax.call('community','connect,ajaxCheckEmail', joms.jQuery('#newemail').val() );
			jax.call('community','connect,ajaxCheckUsername', joms.jQuery('#newusername').val() );
			jax.call('community','connect,ajaxCheckName', joms.jQuery('#newname').val() );

			var isValid	= true;
			if(joms.jQuery('#newname').val() == "" || joms.jQuery('#error-newname').css('display') != 'none')
			{
				isValid = false;
			}

			if(joms.jQuery('#newusername').val() == "" || joms.jQuery('#error-newusername').css('display') != 'none')
			{
				isValid = false;
			}

			if(joms.jQuery('#newemail').val() == '' || joms.jQuery('#error-newemail').css('display') != 'none' )
			{
				isValid = false;
			}

			if(isValid)
			{
				var ajaxCall = "jax.call('community', 'connect,ajaxCreateNewAccount' , '" + joms.jQuery('#newname').val() + "', '" + joms.jQuery('#newusername').val() + "','" + joms.jQuery('#newemail').val() + "');";
				cWindowShow(ajaxCall, '', 450, 200);
			}
		}
	},

	// Video component
	videos: {
		playProfileVideo: function(id, userid){
			jax.call('community', 'profile,ajaxPlayProfileVideo', id, userid);
		},
		linkConfirmProfileVideo: function(id){
			var ajaxCall = "jax.call('community', 'profile,ajaxConfirmLinkProfileVideo', '" + id + "');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		linkProfileVideo: function(id){
			var ajaxCall = "jax.call('community', 'profile,ajaxLinkProfileVideo', '" + id + "');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		removeConfirmProfileVideo: function(userid, videoid){
			var ajaxCall = "jax.call('community', 'profile,ajaxRemoveConfirmLinkProfileVideo', '" + userid + "', '" + videoid + "');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		removeLinkProfileVideo: function(userid, videoid){
			var ajaxCall = "jax.call('community', 'profile,ajaxRemoveLinkProfileVideo', '" + userid + "', '" + videoid + "');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		showEditWindow: function(id , redirectUrl ){

			if( typeof redirectUrl == 'undefined' )
				redirectUrl	= '';

			var ajaxCall = "jax.call('community', 'videos,ajaxEditVideo', '"+id+"' , '" + redirectUrl + "');";
			cWindowShow(ajaxCall, '' , 450, 400);
		},
		deleteVideo: function(videoId){
			var ajaxCall = "jax.call('community' , 'videos,ajaxRemoveVideo', '" + videoId + "','myvideos');";
			cWindowShow(ajaxCall, '', 450, 150);
		},
		playerConf: {
			// Default flowplayer configuration here
		},
		addVideo: function(creatortype, groupid) {
			if(typeof creatortype == "undefined" || creatortype == "")
			{
				var creatortype="";
				var groupid = "";
			}
			var ajaxCall = "jax.call('community', 'videos,ajaxAddVideo', '" + creatortype + "', '" + groupid + "');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		linkVideo: function(creatortype, groupid) {
			var ajaxCall = "jax.call('community', 'videos,ajaxLinkVideo', '" + creatortype + "', '" + groupid + "');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		uploadVideo: function(creatortype, groupid) {
			var ajaxCall = "jax.call('community', 'videos,ajaxUploadVideo', '" + creatortype + "', '" + groupid + "');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		submitLinkVideo: function() {
			var isValid = true;

			videoLinkUrl = "#linkVideo input[name='videoLinkUrl']";
			if(joms.jQuery.trim(joms.jQuery(videoLinkUrl).val())=='')
			{
				joms.jQuery(videoLinkUrl).addClass('invalid');
				isValid = false;
			}
			else
			{
				joms.jQuery(videoLinkUrl).removeClass('invalid');
			}

			if (isValid)
			{
				joms.jQuery('#cwin-wait').css("margin-left","20px");
				joms.jQuery('#cwin-wait').show();

				document.linkVideo.submit();
			}
		},
		submitUploadVideo: function() {
			var isValid = true;

			videoFile = "#uploadVideo input[name='videoFile']";

			if(joms.jQuery.trim(joms.jQuery(videoFile).val())=='')
			{
				joms.jQuery(videoFile).addClass('invalid');
				isValid = false;
			}
			else
			{
				joms.jQuery(videoFile).removeClass('invalid');
			}

			videoTitle = "#uploadVideo input[name='title']";
			if(joms.jQuery.trim(joms.jQuery(videoTitle).val())=='')
			{
				joms.jQuery(videoTitle).addClass('invalid');
				isValid = false;
			}
			else
			{
				joms.jQuery(videoTitle).removeClass('invalid');
			}

			if (isValid)
			{
				joms.jQuery('#cwin-wait').css("margin-left","20px");
				joms.jQuery('#cwin-wait').show();

				document.uploadVideo.submit();
			}
		},
		fetchThumbnail: function(videoId){
			var ajaxCall = "jax.call('community' , 'videos,ajaxFetchThumbnail', '" + videoId + "','myvideos');";
			cWindowShow(ajaxCall, '', 450, 150);
		},
		toggleSearchSubmenu: function(e){
			joms.jQuery(e).next('ul').toggle().find('input[type=text]').focus();
		}
	},
	users: {
		banUser: function( userId , isBlocked ){
			var ajaxCall = "jax.call('community', 'profile,ajaxBanUser', '" + userId + "' , '" + isBlocked + "');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		removePicture: function( userId ){
			var ajaxCall = "jax.call('community', 'profile,ajaxRemovePicture', '" + userId + "');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		updateURL: function( userId ){
			var ajaxCall = "jax.call('community', 'profile,ajaxUpdateURL', '" + userId + "');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		uploadNewPicture: function( userId ){
			var ajaxCall = "jax.call('community', 'profile,ajaxUploadNewPicture', '" + userId + "');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
	   blockUser: function( userId ){
			var ajaxCall = 'jax.call("community", "profile,ajaxBlockUser", "' + userId + '");';
			cWindowShow(ajaxCall, '', 450, 100);
       },
	   unBlockUser: function( userId, layout ){
	        layout = layout || null;
			var ajaxCall = 'jax.call("community", "profile,ajaxUnblockUser", "' + userId + '", "' + layout + '");';
			cWindowShow(ajaxCall, '', 450, 100);
       }
	},

	user: {
		getActive: function( ){
			// return the current active user
			return js_profileId;
		}
	},

	events: {
		deleteEvent: function( eventId ){
			var ajaxCall = "jax.call('community', 'events,ajaxWarnEventDeletion', '" + eventId + "');";
			cWindowShow(ajaxCall, '', 450, 100, 'warning');
		},
		join: function( eventId ){
			var ajaxCall = 'jax.call("community", "events,ajaxRequestInvite", "' + eventId + '", location.href );';
			cWindowShow(ajaxCall, '', 450, 100);
		},
		leave: function( eventId ){
			var ajaxCall = 'jax.call("community", "events,ajaxIgnoreEvent", "' + eventId + '");';
			cWindowShow(ajaxCall, '', 450, 100);
		},
		sendmail: function( eventId ){
			var ajaxCall = 'jax.call("community", "events,ajaxSendEmail", "' + eventId + '");';
			cWindowShow(ajaxCall, '', 450, 300);
		},
		confirmBlockGuest: function(userId, eventId){
			var ajaxCall = 'jax.call("community", "events,ajaxConfirmBlockGuest", "' + userId + '", "' + eventId + '");';
			cWindowShow(ajaxCall, '', 450, 100);
		},
		blockGuest: function(userId, eventId){
			var ajaxCall = 'jax.call("community", "events,ajaxBlockGuest", "' + userId + '", "' + eventId + '");';
			cWindowShow(ajaxCall, '', 450, 100);
		},
		confirmUnblockGuest: function(userId, eventId){
			var ajaxCall = 'jax.call("community", "events,ajaxConfirmUnblockGuest", "' + userId + '", "' + eventId + '");';
			cWindowShow(ajaxCall, '', 450, 100);
		},
		unblockGuest: function(userId, eventId){
			var ajaxCall = 'jax.call("community", "events,ajaxUnblockGuest", "' + userId + '", "' + eventId + '");';
			cWindowShow(ajaxCall, '', 450, 100);
		},
		confirmRemoveGuest: function(userId, eventId){
			var ajaxCall = 'jax.call("community", "events,ajaxConfirmRemoveGuest", "' + userId + '", "' + eventId + '");';
			cWindowShow(ajaxCall, '', 450, 80, 'warning');
		},
		removeGuest: function(userId, eventId)
		{		
			var blockGuest = joms.jQuery('#cWindow input[name=block]').attr('checked');

			var ajaxCall = ''
			if (blockGuest)
			{
				ajaxCall = 'jax.call("community", "events,ajaxBlockGuest", "' + userId + '", "' + eventId + '");';
			} else {
				ajaxCall = 'jax.call("community", "events,ajaxRemoveGuest", "' + userId + '", "' + eventId + '");';
			}

			cWindowShow(ajaxCall, '', 450, 100, 'warning');
		},
		joinNow: function(eventId){
			jax.call("community" , "events,ajaxJoinInvitation" , eventId );
		},
		rejectNow: function(eventId){
			jax.call('community' , 'events,ajaxRejectInvitation' , eventId );
		},
		toggleSearchSubmenu: function(e){
			joms.jQuery(e).next('ul').toggle().find('input[type=text]').focus();
		},
		displayNearbyEvents: function(location){
			joms.ajax.call('events,ajaxDisplayNearbyEvents', [location], {
				success: function(html)
				{
				    joms.jQuery('#community-event-nearby-listing').html(html);

				}
			});
		},
		switchImport: function( importType ){

			if( importType == 'file' )
			{
				joms.jQuery('#event-import-url').css('display' , 'none' );
				joms.jQuery('#event-import-file').css('display' , 'block' );
				joms.jQuery('#import-type').val( 'file' );
			}

			if( importType == 'url' )
			{
				joms.jQuery('#event-import-file').css('display' , 'none' );
				joms.jQuery('#event-import-url').css('display' , 'block' );
				joms.jQuery('#import-type').val('url');
			}
		}
	},
	profile: {
		confirmRemoveAvatar: function(){
			var ajaxCall = 'jax.call("community", "profile,ajaxConfirmRemoveAvatar");';
			cWindowShow(ajaxCall, '', 450, 100);
		},
		setStatusLimit: function( textAreaElement ){
			joms.jQuery( textAreaElement ).keyup(function(){
				var max = parseInt( joms.jQuery(this).attr('maxlength'));
				if( joms.jQuery(this).val().length > max)
				{
					joms.jQuery(this).val( joms.jQuery(this).val().substr(0, joms.jQuery(this).attr('maxlength')));
				}
				joms.jQuery('#profile-status-notice span').html( (max - joms.jQuery(this).val().length) );
			});
		}
	},
	privacy: {
		init: function(){
			joms.jQuery('select.js_PrivacySelect').each(function() {
				var tmpHTML = "";
				var currValue;
				
				// get current value of pre-selected item from the dropdown
				joms.jQuery(this).find('option').each(function() {
					if(joms.jQuery(this).attr('selected')) {
						currValue = joms.jQuery(this).val();
					}
				});
				
				// construct HTML
				tmpHTML += "<dl class='js_dropDownMaster'>\n";
				tmpHTML += "<dt name=" + currValue + " class='js_dropDown js_dropSelect-" + currValue + "'><strong>" + joms.jQuery(this).find('option[selected="selected"]').text() + "</strong><span></span></dt>\n";
				tmpHTML += "<dd>\n<ul class='js_dropDownParent'>\n";
				
				joms.jQuery(this).find('option').each(function() {
					var currOptVal = joms.jQuery(this).val();			
					
					// add extra class for currently selected option
					if(currOptVal == currValue) {
						tmpHTML += "<li class='js_dropDownCurrent'>";
					} else {
						tmpHTML += "<li>";
					}
					
					tmpHTML += "<a href='javascript:void()' name='" + currOptVal + "' class='js_dropDownChild js_dropDown-" + currOptVal + "'>" + joms.jQuery(this).text() + "</a></li>\n";
				});
				
				tmpHTML += "</ul>\n</dd>\n</dl>";
				
				// write HTML
				joms.jQuery(this).parent().prepend(tmpHTML);
				
				// hide original select box
				joms.jQuery(this).hide();
		
			});
			
			joms.jQuery('.js_dropDownChild').live('click',function(e) {
				e.preventDefault();
				var selectedVal = joms.jQuery(this).attr('name');
				var selectedText = "";
				// console.log('clicked. value - ' + selectedVal);
				
				// once clicked, change the select to pick that one
				joms.jQuery(this).closest('.js_PriContainer').find('option').each(function() {
					// traverse through each select box and mark the same value as 'selected' = true
					if(joms.jQuery(this).val() == selectedVal) {
						joms.jQuery(this).attr('selected', 'selected');
						selectedText = joms.jQuery(this).text();
					} else {
						joms.jQuery(this).attr('selected', false);
					}
				});
				
				// get current selection value
				var dropDownObj = joms.jQuery(this).parent().parent().parent().parent().find('dt');
				var currShowVal = dropDownObj.attr('name');
				// console.log(currShowVal);
				dropDownObj.removeClass('js_dropSelect-' + currShowVal).addClass('js_dropSelect-' + selectedVal).attr('name', selectedVal).html('<strong>' + selectedText + '</strong><span></span>');
				// console.log(dropDownObj.attr('name') + ' - ' + selectedText);
				
				// hide box after selecting
				// joms.jQuery(this).parent().parent().parent().parent().data('state',0).removeClass('js_Current').find('dd').hide();
				joms.privacy.closeAll();
			});
			
			// click trigger to open
			joms.jQuery('.js_dropDownMaster dt').live('click', function(e) {
				e.preventDefault();
				if (joms.jQuery(this).parent().data('state')) {
					// joms.jQuery(this).parent().data('state',0).removeClass('js_Current').find('dd').hide();
					joms.privacy.closeAll();
					joms.jQuery('body').unbind('click');
				} else {
					joms.privacy.closeAll();
					joms.jQuery(this).parent().parent().addClass('js_PrivacyOpen');
					joms.jQuery(this).parent().data('state',1).addClass('js_Current').find('dd').show();
					joms.jQuery('body').bind('click', function(e) {
						var tarObj = joms.jQuery(e.target);
						//console.log(tarObj);
						if(tarObj.parents('.js_PriContainer').length == 0) {
							joms.privacy.closeAll();
						}
					});
				}	
			});
		},
		closeAll: function() {
		  joms.jQuery('.js_PriContainer').removeClass('js_PrivacyOpen');
			joms.jQuery('.js_dropDownMaster').each(function() {
				joms.jQuery(this).data('state',0).removeClass('js_Current').find('dd').hide();
			});
		}
	},
	tooltip: {
		setup: function( ){
			// Hide all active visible qTip
			joms.jQuery('.qtip-active').hide();
			setTimeout('joms.jQuery(\'.qtip-active\').hide()', 150);
			try{clearTimeout(joms.jQuery.fn.qtip.timers.show);} catch(e){}

			// Scan the document and setup the tooltip that has .jomTips
			joms.jQuery(".jomTips").each(function(){
		    	var tipStyle = 'tipNormal';
		    	var tipWidth = 220;
		    	var tipPos	 = {corner: {target: 'topMiddle',tooltip: 'bottomMiddle'}}
		    	var tipShow  = true;
		    	var tipHide	 = {when: {event: 'mouseout'}, effect: {length: 10}}

		    	if(joms.jQuery(this).hasClass('tipRight'))
				{
		    		tipStyle = 'tipRight';
		    		tipWidth = 320;
		    		tipPos	 = {corner: {target: 'rightMiddle',tooltip: 'leftMiddle'}}
		    	}

		    	if(joms.jQuery(this).hasClass('tipWide'))
				{
		    		tipWidth = 420;
		    	}

		    	if(joms.jQuery(this).hasClass('tipFullWidth'))
				{
		    		tipWidth = joms.jQuery(this).innerWidth()-20;
		    	}

		    	// Split the title and the content
		    	var title = '';
		    	var content = joms.jQuery(this).attr('title');
				var contentArray = content.split('::');

				// Remove the 'title' attributes from the existing .jomTips classes
				joms.jQuery( this ).attr('title' , '' );

				if(contentArray.length == 2)
				{
					content = contentArray[1];
					title = {text: contentArray[0]} ;
				} else
					title = title = {text: ''} ;;


		    	joms.jQuery(this).qtip({
		    		content: {
					   text: content,
					   title: title
					},
					style: {name:tipStyle , width: tipWidth},
					position: tipPos,
					hide: tipHide,
					show: {solo: true, effect: {length: 50}}
			 	}).removeClass('jomTips');
			});

			return true;
		},

		setStyle: function() {
			joms.jQuery.fn.qtip.styles.tipNormal = { // Last part is the name of the style
				width: 320,
				border: {
					width: 7,
					radius: 5
				},
				tip: true,
				name: 'dark' // Inherit the rest of the attributes from the preset dark style
			}

			joms.jQuery.fn.qtip.styles.tipRight = { // Last part is the name of the style
				tip: 'leftMiddle',
				name: 'tipNormal' // Inherit the rest of the attributes from the preset dark style
			}

			return true;
		}
	},
	like : {
		extractData: function(id) {
		    id = id.split('-');
		    var data = [];
		    data['element'] = id[1];
		    data['itemid']  = id[2];

			// replace element _ with .
			data['element'] = data['element'].replace('_', '.');
		    return data;
		},
		like: function(e){
		    var like  = joms.jQuery(e).parents('.like-snippet');
		    var data = this.extractData(like.attr('id'));

		    // Remove the onclick attribute value to avoid double processing
		    joms.jQuery(e).attr('onclick', '');

		    joms.ajax.call('system,ajaxLike', [data['element'], data['itemid']], {
			success: function(html)
			{
			    like.replaceWith(html);
			}
		    });
		},
		dislike: function(e){
		    var like  = joms.jQuery(e).parents('.like-snippet');
		    var data = this.extractData(like.attr('id'));

		    // Remove the onclick attribute value to avoid double processing
		    joms.jQuery(e).attr('onclick', '');

		    joms.ajax.call('system,ajaxDislike', [data['element'], data['itemid']], {
			success: function(html)
			{
			    like.replaceWith(html);
			}
		    });
		},
		unlike: function(e){
		    var like  = joms.jQuery(e).parents('.like-snippet');
		    var data = this.extractData(like.attr('id'));

		    // Remove the onclick attribute value to avoid double processing
		    joms.jQuery(e).attr('onclick', '');

		    joms.ajax.call('system,ajaxUnlike', [data['element'], data['itemid']], {
			success: function(html)
			{
			    like.replaceWith(html);
			}
		    });
		}
	},
	tag: {
		add: function(element, id){
			jax.call('community', 'system,ajaxAddTag', element, id, joms.jQuery('#tag-addbox').val());
		},
		pick : function(element, id, tag){
			jax.call('community', 'system,ajaxAddTag', element, id, tag );
		},
		remove: function(id){
			jax.call('community', 'system,ajaxRemoveTag', id);
		},
		moreHide: function(element, id){
			joms.jQuery('#tag-list li').each(function(i, l){
				if(i > 8){
					// @todo: limit should come from global config
					joms.jQuery(l).hide();
				}
			});
			joms.jQuery('.more-tag-show').show();
			joms.jQuery('.more-tag-hide').hide();
		},
		moreShow: function(element, id){
			joms.jQuery('#tag-list li').each(function(i, l){
				if(i > 8){
					// @todo: limit should come from global config
					joms.jQuery(l).show();
				}
			});
			joms.jQuery('.more-tag-show').hide();
			joms.jQuery('.more-tag-hide').show();
		},
		toggleMore: function(element, id){
			// Hide/show other tags
			joms.jQuery('#tag-list li').each(function(i, l){
				if(i > 8){
					// @todo: limit should come from global config
					joms.jQuery(l).toggle();
				}
			});
		},
		list: function(tag){
			var ajaxCall = "jax.call('community', 'system,ajaxShowTagged', '"+tag+"');";
			cWindowShow(ajaxCall, '', 450, 100);
		},
		edit: function(element, cid){
			// start edit window
			joms.tag.moreShow(element, cid);
			var tagClass = element+"-"+cid;
			joms.jQuery('#tag-editor.tag-editor-'+tagClass+',.tag-token a.tag-delete').show();
		},
		
		done: function(element, cid){
			joms.tag.moreHide(element, cid);
			var tagClass = element+"-"+cid;
			joms.jQuery('#tag-editor.tag-editor-'+tagClass+',.tag-token a.tag-delete').hide();
		}
	},
	geolocation : {
		showNearByEvents: function( location ){
		    joms.jQuery('#community-event-nearby-listing').show();
		    joms.jQuery('#showNearByEventsLoading').show();

		    // Check if already have the input
		    if( typeof(location) == 'undefined' )
		    {
			// Check if the browsers support W3C Geolocation API
			if( navigator.geolocation )
			{
			    navigator.geolocation.getCurrentPosition(function(location)
			    {
				var lat	=   location.coords.latitude;
				var lng	=   location.coords.longitude;

				// Reverse Geocoding - Google Maps Javascript API V3 Services
				geocoder	=   new google.maps.Geocoder();
				var latlng	=   new google.maps.LatLng( lat, lng );

				geocoder.geocode({'latLng': latlng}, function(results, status){
				    if( status == google.maps.GeocoderStatus.OK ){
					if ( results[4] ){
					    location = results[4].formatted_address;
					    joms.geolocation.setCookie( 'currentLocation', location );
					    joms.events.displayNearbyEvents( location );
					}
				    } else {
					alert("Geocoder failed due to: " + status);
				    }
				});
			    });
			}
			else // If the browser not support W3C Geolocation API, show the error message
			{
			    alert('Sorry, your browser does not support this feature.');
			    joms.jQuery('#community-event-nearby-listing').hide();
			    joms.jQuery('#showNearByEventsLoading').hide();
			}
		    }
		    else
		    {
			joms.events.displayNearbyEvents( location );
		    }
		},
		validateNearByEventsForm: function(){
		    var location   =   joms.jQuery('#userInputLocation').val();

		    if( location.length != 0 )
		    {
			joms.geolocation.showNearByEvents( location );
		    }
		},
		setCookie: function( c_name, value ){
		    var exdate=new Date();

		    // Calculate expiry date 1 hour from now
		    exdate.setTime(exdate.getTime() + (60 * 60 * 1000));

		    document.cookie=c_name+ "=" +escape(value)+";expires="+exdate;
		},
		getCookie: function( c_name ){
		    if (document.cookie.length>0)
		    {
			c_start=document.cookie.indexOf(c_name + "=");
			if (c_start!=-1)
			{
			    c_start=c_start + c_name.length+1;
			    c_end=document.cookie.indexOf(";",c_start);
			    if (c_end==-1) c_end=document.cookie.length;
			    return unescape(document.cookie.substring(c_start,c_end));
			}
		    }
		    return "";
		}
	}
});


// close layer when click-out
joms.jQuery(document).click( function() {
    joms.toolbar.close();
});


/*
* Toolbar notification counter update
* @param string jQuery selector
* @param string/int number of counts to increase/decrease
*/
function update_counter(selector, count){
	
	//e.g selector = '#jsMenuNotif > .notifcount'
	//validate the count number
	if(!count){
		count = 0;
	}
	var currnum = parseInt(jQuery(selector).html(), 10); 
	count = parseInt(count, 10);
	if(currnum <= 1) {
		jQuery(selector).css('display','none');
	} else{ 
		jQuery(selector).html(currnum + count); 
	}
}


function get_cookies_array() {

    var cookies = { };

    if (document.cookie && document.cookie != '')
	{
		var split = document.cookie.split(';');
		for (var i = 0; i < split.length; i++)
		{
			var name_value = split[i].split("=");
			name_value[0] = name_value[0].replace(/^ /, '');
			cookies[decodeURIComponent(name_value[0])] = decodeURIComponent(name_value[1]);
		}
    }

    return cookies;

}


// Document ready
joms.jQuery(document).ready(function () {
	joms.tooltip.setStyle();
	joms.tooltip.setup();
	joms.apps.initToggle();
	joms.plugins.initialize();
	
	if(joms.jQuery('.album-actions').length) {
    joms.album.init();
  }
	
	if(joms.jQuery('.wall-coc-item').length) {
	  joms.miniwall.initialize();
	}

	joms.activities.initMap();
});

/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
joms.jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        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(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        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 { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = joms.jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};




(function($) {
    $.fn.autogrow = function(o) {
		
		var o = o || {};

        this.filter('textarea').each(function(){

			var textarea = $(this);

			if (textarea.hasClass('shadow')) return;

			var shadow = textarea.data('shadow');
			var offset = textarea.outerHeight() - textarea.innerHeight();

			if (!shadow)
			{
				shadow =
					textarea
						.clone()
						.unbind()
						.removeAttr('name')
						.addClass('shadow')
						.css(
						{
							'position'   : 'absolute',
							'visibility' : 'hidden',
							'height'     : 0
						})
						.insertAfter(textarea);

				if (o.lineHeight==undefined) o.lineHeight = shadow.val(' ')[0].scrollHeight;

				textarea
					.data('shadow', shadow)
					.bind('focus blur keyup keypress autogrow', autogrow);
			}

			if (o.minHeight==undefined) o.minHeight = textarea.height();
			if (o.maxHeight==undefined) o.maxHeight = 0;

			function autogrow()
			{
				shadow.val(textarea.val());

				// IE bug
				shadow[0].scrollHeight;

				var height = shadow[0].scrollHeight;

				if (height > o.maxHeight && o.maxHeight > 0)
				{
					height = o.maxHeight;
					textarea.css('overflow', 'auto');
				} else {
					//height = (height < o.minHeight) ? o.minHeight : height + o.lineHeight;
					height = (height < o.minHeight) ? o.minHeight : height;
					textarea.css('overflow', 'hidden');
				}
				
				textarea.height(height);
			}

            autogrow();
        });

        return this;
    }
})(joms.jQuery);


/*
 * jquery.qtip. The jQuery tooltip plugin
 *
 * Copyright (c) 2009 Craig Thompson
 * http://craigsworks.com
 *
 * Licensed under MIT
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Launch  : February 2009
 * Version : 1.0.0-rc3
 * Released: Tuesday 12th May, 2009 - 00:00
 * Debug: jquery.qtip.debug.js
 */
(function(f){f.fn.qtip=function(B,u){var y,t,A,s,x,w,v,z;if(typeof B=="string"){if(typeof f(this).data("qtip")!=="object"){f.fn.qtip.log.error.call(self,1,f.fn.qtip.constants.NO_TOOLTIP_PRESENT,false)}if(B=="api"){return f(this).data("qtip").interfaces[f(this).data("qtip").current]}else{if(B=="interfaces"){return f(this).data("qtip").interfaces}}}else{if(!B){B={}}if(typeof B.content!=="object"||(B.content.jquery&&B.content.length>0)){B.content={text:B.content}}if(typeof B.content.title!=="object"){B.content.title={text:B.content.title}}if(typeof B.position!=="object"){B.position={corner:B.position}}if(typeof B.position.corner!=="object"){B.position.corner={target:B.position.corner,tooltip:B.position.corner}}if(typeof B.show!=="object"){B.show={when:B.show}}if(typeof B.show.when!=="object"){B.show.when={event:B.show.when}}if(typeof B.show.effect!=="object"){B.show.effect={type:B.show.effect}}if(typeof B.hide!=="object"){B.hide={when:B.hide}}if(typeof B.hide.when!=="object"){B.hide.when={event:B.hide.when}}if(typeof B.hide.effect!=="object"){B.hide.effect={type:B.hide.effect}}if(typeof B.style!=="object"){B.style={name:B.style}}B.style=c(B.style);s=f.extend(true,{},f.fn.qtip.defaults,B);s.style=a.call({options:s},s.style);s.user=f.extend(true,{},B)}return f(this).each(function(){if(typeof B=="string"){w=B.toLowerCase();A=f(this).qtip("interfaces");if(typeof A=="object"){if(u===true&&w=="destroy"){while(A.length>0){A[A.length-1].destroy()}}else{if(u!==true){A=[f(this).qtip("api")]}for(y=0;y<A.length;y++){if(w=="destroy"){A[y].destroy()}else{if(A[y].status.rendered===true){if(w=="show"){A[y].show()}else{if(w=="hide"){A[y].hide()}else{if(w=="focus"){A[y].focus()}else{if(w=="disable"){A[y].disable(true)}else{if(w=="enable"){A[y].disable(false)}}}}}}}}}}}else{v=f.extend(true,{},s);v.hide.effect.length=s.hide.effect.length;v.show.effect.length=s.show.effect.length;if(v.position.container===false){v.position.container=f(document.body)}if(v.position.target===false){v.position.target=f(this)}if(v.show.when.target===false){v.show.when.target=f(this)}if(v.hide.when.target===false){v.hide.when.target=f(this)}t=f.fn.qtip.interfaces.length;for(y=0;y<t;y++){if(typeof f.fn.qtip.interfaces[y]=="undefined"){t=y;break}}x=new d(f(this),v,t);f.fn.qtip.interfaces[t]=x;if(typeof f(this).data("qtip")=="object"){if(typeof f(this).attr("qtip")==="undefined"){f(this).data("qtip").current=f(this).data("qtip").interfaces.length}f(this).data("qtip").interfaces.push(x)}else{f(this).data("qtip",{current:0,interfaces:[x]})}if(v.content.prerender===false&&v.show.when.event!==false&&v.show.ready!==true){v.show.when.target.bind(v.show.when.event+".qtip-"+t+"-create",{qtip:t},function(C){z=f.fn.qtip.interfaces[C.data.qtip];z.options.show.when.target.unbind(z.options.show.when.event+".qtip-"+C.data.qtip+"-create");z.cache.mouse={x:C.pageX,y:C.pageY};p.call(z);z.options.show.when.target.trigger(z.options.show.when.event)})}else{x.cache.mouse={x:v.show.when.target.offset().left,y:v.show.when.target.offset().top};p.call(x)}}})};function d(u,t,v){var s=this;s.id=v;s.options=t;s.status={animated:false,rendered:false,disabled:false,focused:false};s.elements={target:u.addClass(s.options.style.classes.target),tooltip:null,wrapper:null,content:null,contentWrapper:null,title:null,button:null,tip:null,bgiframe:null};s.cache={mouse:{},position:{},toggle:0};s.timers={};f.extend(s,s.options.api,{show:function(y){var x,z;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"show")}if(s.elements.tooltip.css("display")!=="none"){return s}s.elements.tooltip.stop(true,false);x=s.beforeShow.call(s,y);if(x===false){return s}function w(){if(s.options.position.type!=="static"){s.focus()}s.onShow.call(s,y);if(f.browser.msie){s.elements.tooltip.get(0).style.removeAttribute("filter")}}s.cache.toggle=1;if(s.options.position.type!=="static"){s.updatePosition(y,(s.options.show.effect.length>0))}if(typeof s.options.show.solo=="object"){z=f(s.options.show.solo)}else{if(s.options.show.solo===true){z=f("div.qtip").not(s.elements.tooltip)}}if(z){z.each(function(){if(f(this).qtip("api").status.rendered===true){f(this).qtip("api").hide()}})}if(typeof s.options.show.effect.type=="function"){s.options.show.effect.type.call(s.elements.tooltip,s.options.show.effect.length);s.elements.tooltip.queue(function(){w();f(this).dequeue()})}else{switch(s.options.show.effect.type.toLowerCase()){case"fade":s.elements.tooltip.fadeIn(s.options.show.effect.length,w);break;case"slide":s.elements.tooltip.slideDown(s.options.show.effect.length,function(){w();if(s.options.position.type!=="static"){s.updatePosition(y,true)}});break;case"grow":s.elements.tooltip.show(s.options.show.effect.length,w);break;default:s.elements.tooltip.show(null,w);break}s.elements.tooltip.addClass(s.options.style.classes.active)}return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_SHOWN,"show")},hide:function(y){var x;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"hide")}else{if(s.elements.tooltip.css("display")==="none"){return s}}clearTimeout(s.timers.show);s.elements.tooltip.stop(true,false);x=s.beforeHide.call(s,y);if(x===false){return s}function w(){s.onHide.call(s,y)}s.cache.toggle=0;if(typeof s.options.hide.effect.type=="function"){s.options.hide.effect.type.call(s.elements.tooltip,s.options.hide.effect.length);s.elements.tooltip.queue(function(){w();f(this).dequeue()})}else{switch(s.options.hide.effect.type.toLowerCase()){case"fade":s.elements.tooltip.fadeOut(s.options.hide.effect.length,w);break;case"slide":s.elements.tooltip.slideUp(s.options.hide.effect.length,w);break;case"grow":s.elements.tooltip.hide(s.options.hide.effect.length,w);break;default:s.elements.tooltip.hide(null,w);break}s.elements.tooltip.removeClass(s.options.style.classes.active)}return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_HIDDEN,"hide")},updatePosition:function(w,x){var C,G,L,J,H,E,y,I,B,D,K,A,F,z;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updatePosition")}else{if(s.options.position.type=="static"){return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.CANNOT_POSITION_STATIC,"updatePosition")}}G={position:{left:0,top:0},dimensions:{height:0,width:0},corner:s.options.position.corner.target};L={position:s.getPosition(),dimensions:s.getDimensions(),corner:s.options.position.corner.tooltip};if(s.options.position.target!=="mouse"){if(s.options.position.target.get(0).nodeName.toLowerCase()=="area"){J=s.options.position.target.attr("coords").split(",");for(C=0;C<J.length;C++){J[C]=parseInt(J[C])}H=s.options.position.target.parent("map").attr("name");E=f('img[usemap="#'+H+'"]:first').offset();G.position={left:Math.floor(E.left+J[0]),top:Math.floor(E.top+J[1])};switch(s.options.position.target.attr("shape").toLowerCase()){case"rect":G.dimensions={width:Math.ceil(Math.abs(J[2]-J[0])),height:Math.ceil(Math.abs(J[3]-J[1]))};break;case"circle":G.dimensions={width:J[2]+1,height:J[2]+1};break;case"poly":G.dimensions={width:J[0],height:J[1]};for(C=0;C<J.length;C++){if(C%2==0){if(J[C]>G.dimensions.width){G.dimensions.width=J[C]}if(J[C]<J[0]){G.position.left=Math.floor(E.left+J[C])}}else{if(J[C]>G.dimensions.height){G.dimensions.height=J[C]}if(J[C]<J[1]){G.position.top=Math.floor(E.top+J[C])}}}G.dimensions.width=G.dimensions.width-(G.position.left-E.left);G.dimensions.height=G.dimensions.height-(G.position.top-E.top);break;default:return f.fn.qtip.log.error.call(s,4,f.fn.qtip.constants.INVALID_AREA_SHAPE,"updatePosition");break}G.dimensions.width-=2;G.dimensions.height-=2}else{if(s.options.position.target.add(document.body).length===1){G.position={left:f(document).scrollLeft(),top:f(document).scrollTop()};G.dimensions={height:f(window).height(),width:f(window).width()}}else{if(typeof s.options.position.target.attr("qtip")!=="undefined"){G.position=s.options.position.target.qtip("api").cache.position}else{G.position=s.options.position.target.offset()}G.dimensions={height:s.options.position.target.outerHeight(),width:s.options.position.target.outerWidth()}}}y=f.extend({},G.position);if(G.corner.search(/right/i)!==-1){y.left+=G.dimensions.width}if(G.corner.search(/bottom/i)!==-1){y.top+=G.dimensions.height}if(G.corner.search(/((top|bottom)Middle)|center/)!==-1){y.left+=(G.dimensions.width/2)}if(G.corner.search(/((left|right)Middle)|center/)!==-1){y.top+=(G.dimensions.height/2)}}else{G.position=y={left:s.cache.mouse.x,top:s.cache.mouse.y};G.dimensions={height:1,width:1}}if(L.corner.search(/right/i)!==-1){y.left-=L.dimensions.width}if(L.corner.search(/bottom/i)!==-1){y.top-=L.dimensions.height}if(L.corner.search(/((top|bottom)Middle)|center/)!==-1){y.left-=(L.dimensions.width/2)}if(L.corner.search(/((left|right)Middle)|center/)!==-1){y.top-=(L.dimensions.height/2)}I=(f.browser.msie)?1:0;B=(f.browser.msie&&parseInt(f.browser.version.charAt(0))===6)?1:0;if(s.options.style.border.radius>0){if(L.corner.search(/Left/)!==-1){y.left-=s.options.style.border.radius}else{if(L.corner.search(/Right/)!==-1){y.left+=s.options.style.border.radius}}if(L.corner.search(/Top/)!==-1){y.top-=s.options.style.border.radius}else{if(L.corner.search(/Bottom/)!==-1){y.top+=s.options.style.border.radius}}}if(I){if(L.corner.search(/top/)!==-1){y.top-=I}else{if(L.corner.search(/bottom/)!==-1){y.top+=I}}if(L.corner.search(/left/)!==-1){y.left-=I}else{if(L.corner.search(/right/)!==-1){y.left+=I}}if(L.corner.search(/leftMiddle|rightMiddle/)!==-1){y.top-=1}}if(s.options.position.adjust.screen===true){y=o.call(s,y,G,L)}if(s.options.position.target==="mouse"&&s.options.position.adjust.mouse===true){if(s.options.position.adjust.screen===true&&s.elements.tip){K=s.elements.tip.attr("rel")}else{K=s.options.position.corner.tooltip}y.left+=(K.search(/right/i)!==-1)?-6:6;y.top+=(K.search(/bottom/i)!==-1)?-6:6}if(!s.elements.bgiframe&&f.browser.msie&&parseInt(f.browser.version.charAt(0))==6){f("select, object").each(function(){A=f(this).offset();A.bottom=A.top+f(this).height();A.right=A.left+f(this).width();if(y.top+L.dimensions.height>=A.top&&y.left+L.dimensions.width>=A.left){k.call(s)}})}y.left+=s.options.position.adjust.x;y.top+=s.options.position.adjust.y;F=s.getPosition();if(y.left!=F.left||y.top!=F.top){z=s.beforePositionUpdate.call(s,w);if(z===false){return s}s.cache.position=y;if(x===true){s.status.animated=true;s.elements.tooltip.animate(y,200,"swing",function(){s.status.animated=false})}else{s.elements.tooltip.css(y)}s.onPositionUpdate.call(s,w);if(typeof w!=="undefined"&&w.type&&w.type!=="mousemove"){f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_POSITION_UPDATED,"updatePosition")}}return s},updateWidth:function(w){var x;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateWidth")}else{if(w&&typeof w!=="number"){return f.fn.qtip.log.error.call(s,2,"newWidth must be of type number","updateWidth")}}x=s.elements.contentWrapper.siblings().add(s.elements.tip).add(s.elements.button);if(!w){if(typeof s.options.style.width.value=="number"){w=s.options.style.width.value}else{s.elements.tooltip.css({width:"auto"});x.hide();if(f.browser.msie){s.elements.wrapper.add(s.elements.contentWrapper.children()).css({zoom:"normal"})}w=s.getDimensions().width+1;if(!s.options.style.width.value){if(w>s.options.style.width.max){w=s.options.style.width.max}if(w<s.options.style.width.min){w=s.options.style.width.min}}}}if(w%2!==0){w-=1}s.elements.tooltip.width(w);x.show();if(s.options.style.border.radius){s.elements.tooltip.find(".qtip-betweenCorners").each(function(y){f(this).width(w-(s.options.style.border.radius*2))})}if(f.browser.msie){s.elements.wrapper.add(s.elements.contentWrapper.children()).css({zoom:"1"});s.elements.wrapper.width(w);if(s.elements.bgiframe){s.elements.bgiframe.width(w).height(s.getDimensions.height)}}return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_WIDTH_UPDATED,"updateWidth")},updateStyle:function(w){var z,A,x,y,B;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateStyle")}else{if(typeof w!=="string"||!f.fn.qtip.styles[w]){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.STYLE_NOT_DEFINED,"updateStyle")}}s.options.style=a.call(s,f.fn.qtip.styles[w],s.options.user.style);s.elements.content.css(q(s.options.style));if(s.options.content.title.text!==false){s.elements.title.css(q(s.options.style.title,true))}s.elements.contentWrapper.css({borderColor:s.options.style.border.color});if(s.options.style.tip.corner!==false){if(f("<canvas>").get(0).getContext){z=s.elements.tooltip.find(".qtip-tip canvas:first");x=z.get(0).getContext("2d");x.clearRect(0,0,300,300);y=z.parent("div[rel]:first").attr("rel");B=b(y,s.options.style.tip.size.width,s.options.style.tip.size.height);h.call(s,z,B,s.options.style.tip.color||s.options.style.border.color)}else{if(f.browser.msie){z=s.elements.tooltip.find('.qtip-tip [nodeName="shape"]');z.attr("fillcolor",s.options.style.tip.color||s.options.style.border.color)}}}if(s.options.style.border.radius>0){s.elements.tooltip.find(".qtip-betweenCorners").css({backgroundColor:s.options.style.border.color});if(f("<canvas>").get(0).getContext){A=g(s.options.style.border.radius);s.elements.tooltip.find(".qtip-wrapper canvas").each(function(){x=f(this).get(0).getContext("2d");x.clearRect(0,0,300,300);y=f(this).parent("div[rel]:first").attr("rel");r.call(s,f(this),A[y],s.options.style.border.radius,s.options.style.border.color)})}else{if(f.browser.msie){s.elements.tooltip.find('.qtip-wrapper [nodeName="arc"]').each(function(){f(this).attr("fillcolor",s.options.style.border.color)})}}}return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_STYLE_UPDATED,"updateStyle")},updateContent:function(A,y){var z,x,w;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateContent")}else{if(!A){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.NO_CONTENT_PROVIDED,"updateContent")}}z=s.beforeContentUpdate.call(s,A);if(typeof z=="string"){A=z}else{if(z===false){return}}if(f.browser.msie){s.elements.contentWrapper.children().css({zoom:"normal"})}if(A.jquery&&A.length>0){A.clone(true).appendTo(s.elements.content).show()}else{s.elements.content.html(A)}x=s.elements.content.find("img[complete=false]");if(x.length>0){w=0;x.each(function(C){f('<img src="'+f(this).attr("src")+'" />').load(function(){if(++w==x.length){B()}})})}else{B()}function B(){s.updateWidth();if(y!==false){if(s.options.position.type!=="static"){s.updatePosition(s.elements.tooltip.is(":visible"),true)}if(s.options.style.tip.corner!==false){n.call(s)}}}s.onContentUpdate.call(s);return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_CONTENT_UPDATED,"loadContent")},loadContent:function(w,z,A){var y;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"loadContent")}y=s.beforeContentLoad.call(s);if(y===false){return s}if(A=="post"){f.post(w,z,x)}else{f.get(w,z,x)}function x(B){s.onContentLoad.call(s);f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_CONTENT_LOADED,"loadContent");s.updateContent(B)}return s},updateTitle:function(w){if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"updateTitle")}else{if(!w){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.NO_CONTENT_PROVIDED,"updateTitle")}}returned=s.beforeTitleUpdate.call(s);if(returned===false){return s}if(s.elements.button){s.elements.button=s.elements.button.clone(true)}s.elements.title.html(w);if(s.elements.button){s.elements.title.prepend(s.elements.button)}s.onTitleUpdate.call(s);return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_TITLE_UPDATED,"updateTitle")},focus:function(A){var y,x,w,z;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"focus")}else{if(s.options.position.type=="static"){return f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.CANNOT_FOCUS_STATIC,"focus")}}y=parseInt(s.elements.tooltip.css("z-index"));x=6000+f("div.qtip[qtip]").length-1;if(!s.status.focused&&y!==x){z=s.beforeFocus.call(s,A);if(z===false){return s}f("div.qtip[qtip]").not(s.elements.tooltip).each(function(){if(f(this).qtip("api").status.rendered===true){w=parseInt(f(this).css("z-index"));if(typeof w=="number"&&w>-1){f(this).css({zIndex:parseInt(f(this).css("z-index"))-1})}f(this).qtip("api").status.focused=false}});s.elements.tooltip.css({zIndex:x});s.status.focused=true;s.onFocus.call(s,A);f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_FOCUSED,"focus")}return s},disable:function(w){if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"disable")}if(w){if(!s.status.disabled){s.status.disabled=true;f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_DISABLED,"disable")}else{f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.TOOLTIP_ALREADY_DISABLED,"disable")}}else{if(s.status.disabled){s.status.disabled=false;f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_ENABLED,"disable")}else{f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.TOOLTIP_ALREADY_ENABLED,"disable")}}return s},destroy:function(){var w,x,y;x=s.beforeDestroy.call(s);if(x===false){return s}if(s.status.rendered){s.options.show.when.target.unbind("mousemove.qtip",s.updatePosition);s.options.show.when.target.unbind("mouseout.qtip",s.hide);s.options.show.when.target.unbind(s.options.show.when.event+".qtip");s.options.hide.when.target.unbind(s.options.hide.when.event+".qtip");s.elements.tooltip.unbind(s.options.hide.when.event+".qtip");s.elements.tooltip.unbind("mouseover.qtip",s.focus);s.elements.tooltip.remove()}else{s.options.show.when.target.unbind(s.options.show.when.event+".qtip-create")}if(typeof s.elements.target.data("qtip")=="object"){y=s.elements.target.data("qtip").interfaces;if(typeof y=="object"&&y.length>0){for(w=0;w<y.length-1;w++){if(y[w].id==s.id){y.splice(w,1)}}}}delete f.fn.qtip.interfaces[s.id];if(typeof y=="object"&&y.length>0){s.elements.target.data("qtip").current=y.length-1}else{s.elements.target.removeData("qtip")}s.onDestroy.call(s);f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_DESTROYED,"destroy");return s.elements.target},getPosition:function(){var w,x;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"getPosition")}w=(s.elements.tooltip.css("display")!=="none")?false:true;if(w){s.elements.tooltip.css({visiblity:"hidden"}).show()}x=s.elements.tooltip.offset();if(w){s.elements.tooltip.css({visiblity:"visible"}).hide()}return x},getDimensions:function(){var w,x;if(!s.status.rendered){return f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.TOOLTIP_NOT_RENDERED,"getDimensions")}w=(!s.elements.tooltip.is(":visible"))?true:false;if(w){s.elements.tooltip.css({visiblity:"hidden"}).show()}x={height:s.elements.tooltip.outerHeight(),width:s.elements.tooltip.outerWidth()};if(w){s.elements.tooltip.css({visiblity:"visible"}).hide()}return x}})}function p(){var s,w,u,t,v,y,x;s=this;s.beforeRender.call(s);s.status.rendered=true;s.elements.tooltip='<div qtip="'+s.id+'" class="qtip '+(s.options.style.classes.tooltip||s.options.style)+'"style="display:none; -moz-border-radius:0; -webkit-border-radius:0; border-radius:0;position:'+s.options.position.type+';">  <div class="qtip-wrapper" style="position:relative; overflow:hidden; text-align:left;">    <div class="qtip-contentWrapper" style="overflow:hidden;">       <div class="qtip-content '+s.options.style.classes.content+'"></div></div></div></div>';s.elements.tooltip=f(s.elements.tooltip);s.elements.tooltip.appendTo(s.options.position.container);s.elements.tooltip.data("qtip",{current:0,interfaces:[s]});s.elements.wrapper=s.elements.tooltip.children("div:first");s.elements.contentWrapper=s.elements.wrapper.children("div:first").css({background:s.options.style.background});s.elements.content=s.elements.contentWrapper.children("div:first").css(q(s.options.style));if(f.browser.msie){s.elements.wrapper.add(s.elements.content).css({zoom:1})}if(s.options.hide.when.event=="unfocus"){s.elements.tooltip.attr("unfocus",true)}if(typeof s.options.style.width.value=="number"){s.updateWidth()}if(f("<canvas>").get(0).getContext||f.browser.msie){if(s.options.style.border.radius>0){m.call(s)}else{s.elements.contentWrapper.css({border:s.options.style.border.width+"px solid "+s.options.style.border.color})}if(s.options.style.tip.corner!==false){e.call(s)}}else{s.elements.contentWrapper.css({border:s.options.style.border.width+"px solid "+s.options.style.border.color});s.options.style.border.radius=0;s.options.style.tip.corner=false;f.fn.qtip.log.error.call(s,2,f.fn.qtip.constants.CANVAS_VML_NOT_SUPPORTED,"render")}if((typeof s.options.content.text=="string"&&s.options.content.text.length>0)||(s.options.content.text.jquery&&s.options.content.text.length>0)){u=s.options.content.text}else{if(typeof s.elements.target.attr("title")=="string"&&s.elements.target.attr("title").length>0){u=s.elements.target.attr("title").replace("\\n","<br />");s.elements.target.attr("title","")}else{if(typeof s.elements.target.attr("alt")=="string"&&s.elements.target.attr("alt").length>0){u=s.elements.target.attr("alt").replace("\\n","<br />");s.elements.target.attr("alt","")}else{u=" ";f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.NO_VALID_CONTENT,"render")}}}if(s.options.content.title.text!==false){j.call(s)}s.updateContent(u);l.call(s);if(s.options.show.ready===true){s.show()}if(s.options.content.url!==false){t=s.options.content.url;v=s.options.content.data;y=s.options.content.method||"get";s.loadContent(t,v,y)}s.onRender.call(s);f.fn.qtip.log.error.call(s,1,f.fn.qtip.constants.EVENT_RENDERED,"render")}function m(){var F,z,t,B,x,E,u,G,D,y,w,C,A,s,v;F=this;F.elements.wrapper.find(".qtip-borderBottom, .qtip-borderTop").remove();t=F.options.style.border.width;B=F.options.style.border.radius;x=F.options.style.border.color||F.options.style.tip.color;E=g(B);u={};for(z in E){u[z]='<div rel="'+z+'" style="'+((z.search(/Left/)!==-1)?"left":"right")+":0; position:absolute; height:"+B+"px; width:"+B+'px; overflow:hidden; line-height:0.1px; font-size:1px">';if(f("<canvas>").get(0).getContext){u[z]+='<canvas height="'+B+'" width="'+B+'" style="vertical-align: top"></canvas>'}else{if(f.browser.msie){G=B*2+3;u[z]+='<v:arc stroked="false" fillcolor="'+x+'" startangle="'+E[z][0]+'" endangle="'+E[z][1]+'" style="width:'+G+"px; height:"+G+"px; margin-top:"+((z.search(/bottom/)!==-1)?-2:-1)+"px; margin-left:"+((z.search(/Right/)!==-1)?E[z][2]-3.5:-1)+'px; vertical-align:top; display:inline-block; behavior:url(#default#VML)"></v:arc>'}}u[z]+="</div>"}D=F.getDimensions().width-(Math.max(t,B)*2);y='<div class="qtip-betweenCorners" style="height:'+B+"px; width:"+D+"px; overflow:hidden; background-color:"+x+'; line-height:0.1px; font-size:1px;">';w='<div class="qtip-borderTop" dir="ltr" style="height:'+B+"px; margin-left:"+B+'px; line-height:0.1px; font-size:1px; padding:0;">'+u.topLeft+u.topRight+y;F.elements.wrapper.prepend(w);C='<div class="qtip-borderBottom" dir="ltr" style="height:'+B+"px; margin-left:"+B+'px; line-height:0.1px; font-size:1px; padding:0;">'+u.bottomLeft+u.bottomRight+y;F.elements.wrapper.append(C);if(f("<canvas>").get(0).getContext){F.elements.wrapper.find("canvas").each(function(){A=E[f(this).parent("[rel]:first").attr("rel")];r.call(F,f(this),A,B,x)})}else{if(f.browser.msie){F.elements.tooltip.append('<v:image style="behavior:url(#default#VML);"></v:image>')}}s=Math.max(B,(B+(t-B)));v=Math.max(t-B,0);F.elements.contentWrapper.css({border:"0px solid "+x,borderWidth:v+"px "+s+"px"})}function r(u,w,s,t){var v=u.get(0).getContext("2d");v.fillStyle=t;v.beginPath();v.arc(w[0],w[1],s,0,Math.PI*2,false);v.fill()}function e(v){var t,s,x,u,w;t=this;if(t.elements.tip!==null){t.elements.tip.remove()}s=t.options.style.tip.color||t.options.style.border.color;if(t.options.style.tip.corner===false){return}else{if(!v){v=t.options.style.tip.corner}}x=b(v,t.options.style.tip.size.width,t.options.style.tip.size.height);t.elements.tip='<div class="'+t.options.style.classes.tip+'" dir="ltr" rel="'+v+'" style="position:absolute; height:'+t.options.style.tip.size.height+"px; width:"+t.options.style.tip.size.width+'px; margin:0 auto; line-height:0.1px; font-size:1px;">';if(f("<canvas>").get(0).getContext){t.elements.tip+='<canvas height="'+t.options.style.tip.size.height+'" width="'+t.options.style.tip.size.width+'"></canvas>'}else{if(f.browser.msie){u=t.options.style.tip.size.width+","+t.options.style.tip.size.height;w="m"+x[0][0]+","+x[0][1];w+=" l"+x[1][0]+","+x[1][1];w+=" "+x[2][0]+","+x[2][1];w+=" xe";t.elements.tip+='<v:shape fillcolor="'+s+'" stroked="false" filled="true" path="'+w+'" coordsize="'+u+'" style="width:'+t.options.style.tip.size.width+"px; height:"+t.options.style.tip.size.height+"px; line-height:0.1px; display:inline-block; behavior:url(#default#VML); vertical-align:"+((v.search(/top/)!==-1)?"bottom":"top")+'"></v:shape>';t.elements.tip+='<v:image style="behavior:url(#default#VML);"></v:image>';t.elements.contentWrapper.css("position","relative")}}t.elements.tooltip.prepend(t.elements.tip+"</div>");t.elements.tip=t.elements.tooltip.find("."+t.options.style.classes.tip).eq(0);if(f("<canvas>").get(0).getContext){h.call(t,t.elements.tip.find("canvas:first"),x,s)}if(v.search(/top/)!==-1&&f.browser.msie&&parseInt(f.browser.version.charAt(0))===6){t.elements.tip.css({marginTop:-4})}n.call(t,v)}function h(t,v,s){var u=t.get(0).getContext("2d");u.fillStyle=s;u.beginPath();u.moveTo(v[0][0],v[0][1]);u.lineTo(v[1][0],v[1][1]);u.lineTo(v[2][0],v[2][1]);u.fill()}function n(u){var t,w,s,x,v;t=this;if(t.options.style.tip.corner===false||!t.elements.tip){return}if(!u){u=t.elements.tip.attr("rel")}w=positionAdjust=(f.browser.msie)?1:0;t.elements.tip.css(u.match(/left|right|top|bottom/)[0],0);if(u.search(/top|bottom/)!==-1){if(f.browser.msie){if(parseInt(f.browser.version.charAt(0))===6){positionAdjust=(u.search(/top/)!==-1)?-3:1}else{positionAdjust=(u.search(/top/)!==-1)?1:2}}if(u.search(/Middle/)!==-1){t.elements.tip.css({left:"50%",marginLeft:-(t.options.style.tip.size.width/2)})}else{if(u.search(/Left/)!==-1){t.elements.tip.css({left:t.options.style.border.radius-w})}else{if(u.search(/Right/)!==-1){t.elements.tip.css({right:t.options.style.border.radius+w})}}}if(u.search(/top/)!==-1){t.elements.tip.css({top:-positionAdjust})}else{t.elements.tip.css({bottom:positionAdjust})}}else{if(u.search(/left|right/)!==-1){if(f.browser.msie){positionAdjust=(parseInt(f.browser.version.charAt(0))===6)?1:((u.search(/left/)!==-1)?1:2)}if(u.search(/Middle/)!==-1){t.elements.tip.css({top:"50%",marginTop:-(t.options.style.tip.size.height/2)})}else{if(u.search(/Top/)!==-1){t.elements.tip.css({top:t.options.style.border.radius-w})}else{if(u.search(/Bottom/)!==-1){t.elements.tip.css({bottom:t.options.style.border.radius+w})}}}if(u.search(/left/)!==-1){t.elements.tip.css({left:-positionAdjust})}else{t.elements.tip.css({right:positionAdjust})}}}s="padding-"+u.match(/left|right|top|bottom/)[0];x=t.options.style.tip.size[(s.search(/left|right/)!==-1)?"width":"height"];t.elements.tooltip.css("padding",0);t.elements.tooltip.css(s,x);if(f.browser.msie&&parseInt(f.browser.version.charAt(0))==6){v=parseInt(t.elements.tip.css("margin-top"))||0;v+=parseInt(t.elements.content.css("margin-top"))||0;t.elements.tip.css({marginTop:v})}}function j(){var s=this;if(s.elements.title!==null){s.elements.title.remove()}s.elements.title=f('<div class="'+s.options.style.classes.title+'">').css(q(s.options.style.title,true)).css({zoom:(f.browser.msie)?1:0}).prependTo(s.elements.contentWrapper);if(s.options.content.title.text){s.updateTitle.call(s,s.options.content.title.text)}if(s.options.content.title.button!==false&&typeof s.options.content.title.button=="string"){s.elements.button=f('<a class="'+s.options.style.classes.button+'" style="float:right; position: relative"></a>').css(q(s.options.style.button,true)).html(s.options.content.title.button).prependTo(s.elements.title).click(function(t){if(!s.status.disabled){s.hide(t)}})}}function l(){var t,v,u,s;t=this;v=t.options.show.when.target;u=t.options.hide.when.target;if(t.options.hide.fixed){u=u.add(t.elements.tooltip)}if(t.options.hide.when.event=="inactive"){s=["click","dblclick","mousedown","mouseup","mousemove","mouseout","mouseenter","mouseleave","mouseover"];function y(z){if(t.status.disabled===true){return}clearTimeout(t.timers.inactive);t.timers.inactive=setTimeout(function(){f(s).each(function(){u.unbind(this+".qtip-inactive");t.elements.content.unbind(this+".qtip-inactive")});t.hide(z)},t.options.hide.delay)}}else{if(t.options.hide.fixed===true){t.elements.tooltip.bind("mouseover.qtip",function(){if(t.status.disabled===true){return}clearTimeout(t.timers.hide)})}}function x(z){if(t.status.disabled===true){return}if(t.options.hide.when.event=="inactive"){f(s).each(function(){u.bind(this+".qtip-inactive",y);t.elements.content.bind(this+".qtip-inactive",y)});y()}clearTimeout(t.timers.show);clearTimeout(t.timers.hide);t.timers.show=setTimeout(function(){t.show(z)},t.options.show.delay)}function w(z){if(t.status.disabled===true){return}if(t.options.hide.fixed===true&&t.options.hide.when.event.search(/mouse(out|leave)/i)!==-1&&f(z.relatedTarget).parents("div.qtip[qtip]").length>0){z.stopPropagation();z.preventDefault();clearTimeout(t.timers.hide);return false}clearTimeout(t.timers.show);clearTimeout(t.timers.hide);t.elements.tooltip.stop(true,true);t.timers.hide=setTimeout(function(){t.hide(z)},t.options.hide.delay)}if((t.options.show.when.target.add(t.options.hide.when.target).length===1&&t.options.show.when.event==t.options.hide.when.event&&t.options.hide.when.event!=="inactive")||t.options.hide.when.event=="unfocus"){t.cache.toggle=0;v.bind(t.options.show.when.event+".qtip",function(z){if(t.cache.toggle==0){x(z)}else{w(z)}})}else{v.bind(t.options.show.when.event+".qtip",x);if(t.options.hide.when.event!=="inactive"){u.bind(t.options.hide.when.event+".qtip",w)}}if(t.options.position.type.search(/(fixed|absolute)/)!==-1){t.elements.tooltip.bind("mouseover.qtip",t.focus)}if(t.options.position.target==="mouse"&&t.options.position.type!=="static"){v.bind("mousemove.qtip",function(z){t.cache.mouse={x:z.pageX,y:z.pageY};if(t.status.disabled===false&&t.options.position.adjust.mouse===true&&t.options.position.type!=="static"&&t.elements.tooltip.css("display")!=="none"){t.updatePosition(z)}})}}function o(u,v,A){var z,s,x,y,t,w;z=this;if(A.corner=="center"){return v.position}s=f.extend({},u);y={x:false,y:false};t={left:(s.left<f.fn.qtip.cache.screen.scroll.left),right:(s.left+A.dimensions.width+2>=f.fn.qtip.cache.screen.width+f.fn.qtip.cache.screen.scroll.left),top:(s.top<f.fn.qtip.cache.screen.scroll.top),bottom:(s.top+A.dimensions.height+2>=f.fn.qtip.cache.screen.height+f.fn.qtip.cache.screen.scroll.top)};x={left:(t.left&&(A.corner.search(/right/i)!=-1||(A.corner.search(/right/i)==-1&&!t.right))),right:(t.right&&(A.corner.search(/left/i)!=-1||(A.corner.search(/left/i)==-1&&!t.left))),top:(t.top&&A.corner.search(/top/i)==-1),bottom:(t.bottom&&A.corner.search(/bottom/i)==-1)};if(x.left){if(z.options.position.target!=="mouse"){s.left=v.position.left+v.dimensions.width}else{s.left=z.cache.mouse.x}y.x="Left"}else{if(x.right){if(z.options.position.target!=="mouse"){s.left=v.position.left-A.dimensions.width}else{s.left=z.cache.mouse.x-A.dimensions.width}y.x="Right"}}if(x.top){if(z.options.position.target!=="mouse"){s.top=v.position.top+v.dimensions.height}else{s.top=z.cache.mouse.y}y.y="top"}else{if(x.bottom){if(z.options.position.target!=="mouse"){s.top=v.position.top-A.dimensions.height}else{s.top=z.cache.mouse.y-A.dimensions.height}y.y="bottom"}}if(s.left<0){s.left=u.left;y.x=false}if(s.top<0){s.top=u.top;y.y=false}if(z.options.style.tip.corner!==false){s.corner=new String(A.corner);if(y.x!==false){s.corner=s.corner.replace(/Left|Right|Middle/,y.x)}if(y.y!==false){s.corner=s.corner.replace(/top|bottom/,y.y)}if(s.corner!==z.elements.tip.attr("rel")){e.call(z,s.corner)}}return s}function q(u,t){var v,s;v=f.extend(true,{},u);for(s in v){if(t===true&&s.search(/(tip|classes)/i)!==-1){delete v[s]}else{if(!t&&s.search(/(width|border|tip|title|classes|user)/i)!==-1){delete v[s]}}}return v}function c(s){if(typeof s.tip!=="object"){s.tip={corner:s.tip}}if(typeof s.tip.size!=="object"){s.tip.size={width:s.tip.size,height:s.tip.size}}if(typeof s.border!=="object"){s.border={width:s.border}}if(typeof s.width!=="object"){s.width={value:s.width}}if(typeof s.width.max=="string"){s.width.max=parseInt(s.width.max.replace(/([0-9]+)/i,"$1"))}if(typeof s.width.min=="string"){s.width.min=parseInt(s.width.min.replace(/([0-9]+)/i,"$1"))}if(typeof s.tip.size.x=="number"){s.tip.size.width=s.tip.size.x;delete s.tip.size.x}if(typeof s.tip.size.y=="number"){s.tip.size.height=s.tip.size.y;delete s.tip.size.y}return s}function a(){var s,t,u,x,v,w;s=this;u=[true,{}];for(t=0;t<arguments.length;t++){u.push(arguments[t])}x=[f.extend.apply(f,u)];while(typeof x[0].name=="string"){x.unshift(c(f.fn.qtip.styles[x[0].name]))}x.unshift(true,{classes:{tooltip:"qtip-"+(arguments[0].name||"defaults")}},f.fn.qtip.styles.defaults);v=f.extend.apply(f,x);w=(f.browser.msie)?1:0;v.tip.size.width+=w;v.tip.size.height+=w;if(v.tip.size.width%2>0){v.tip.size.width+=1}if(v.tip.size.height%2>0){v.tip.size.height+=1}if(v.tip.corner===true){v.tip.corner=(s.options.position.corner.tooltip==="center")?false:s.options.position.corner.tooltip}return v}function b(v,u,t){var s={bottomRight:[[0,0],[u,t],[u,0]],bottomLeft:[[0,0],[u,0],[0,t]],topRight:[[0,t],[u,0],[u,t]],topLeft:[[0,0],[0,t],[u,t]],topMiddle:[[0,t],[u/2,0],[u,t]],bottomMiddle:[[0,0],[u,0],[u/2,t]],rightMiddle:[[0,0],[u,t/2],[0,t]],leftMiddle:[[u,0],[u,t],[0,t/2]]};s.leftTop=s.bottomRight;s.rightTop=s.bottomLeft;s.leftBottom=s.topRight;s.rightBottom=s.topLeft;return s[v]}function g(s){var t;if(f("<canvas>").get(0).getContext){t={topLeft:[s,s],topRight:[0,s],bottomLeft:[s,0],bottomRight:[0,0]}}else{if(f.browser.msie){t={topLeft:[-90,90,0],topRight:[-90,90,-s],bottomLeft:[90,270,0],bottomRight:[90,270,-s]}}}return t}function k(){var s,t,u;s=this;u=s.getDimensions();t='<iframe class="qtip-bgiframe" frameborder="0" tabindex="-1" src="javascript:false" style="display:block; position:absolute; z-index:-1; filter:alpha(opacity=\'0\'); border: 1px solid red; height:'+u.height+"px; width:"+u.width+'px" />';s.elements.bgiframe=s.elements.wrapper.prepend(t).children(".qtip-bgiframe:first")}f(document).ready(function(){f.fn.qtip.cache={screen:{scroll:{left:f(window).scrollLeft(),top:f(window).scrollTop()},width:f(window).width(),height:f(window).height()}};var s;f(window).bind("scroll",function(t){clearTimeout(s);s=setTimeout(function(){if(t.type==="scroll"){f.fn.qtip.cache.screen.scroll={left:f(window).scrollLeft(),top:f(window).scrollTop()}}else{f.fn.qtip.cache.screen.width=f(window).width();f.fn.qtip.cache.screen.height=f(window).height()}for(i=0;i<f.fn.qtip.interfaces.length;i++){var u=f.fn.qtip.interfaces[i];if(u.status.rendered===true&&(u.options.position.type!=="static"||u.options.position.adjust.scroll&&t.type==="scroll")){u.updatePosition(t,true)}}},100)});f(document).bind("mousedown.qtip",function(t){if(f(t.target).parents("div.qtip").length===0){f(".qtip[unfocus]").each(function(){var u=f(this).qtip("api");if(f(this).is(":visible")&&!u.status.disabled&&f(t.target).add(u.elements.target).length>1){u.hide(t)}})}})});f.fn.qtip.interfaces=[];f.fn.qtip.log={error:function(){return this}};f.fn.qtip.constants={};f.fn.qtip.defaults={content:{prerender:false,text:false,url:false,data:null,title:{text:false,button:false}},position:{target:false,corner:{target:"bottomRight",tooltip:"topLeft"},adjust:{x:0,y:0,mouse:true,screen:false,scroll:true},type:"absolute",container:false},show:{when:{target:false,event:"mouseover"},effect:{type:"fade",length:100},delay:140,solo:false,ready:false},hide:{when:{target:false,event:"mouseout"},effect:{type:"fade",length:100},delay:0,fixed:false},api:{beforeRender:function(){},onRender:function(){},beforePositionUpdate:function(){},onPositionUpdate:function(){},beforeShow:function(){},onShow:function(){},beforeHide:function(){},onHide:function(){},beforeContentUpdate:function(){},onContentUpdate:function(){},beforeContentLoad:function(){},onContentLoad:function(){},beforeTitleUpdate:function(){},onTitleUpdate:function(){},beforeDestroy:function(){},onDestroy:function(){},beforeFocus:function(){},onFocus:function(){}}};f.fn.qtip.styles={defaults:{background:"white",color:"#111",overflow:"hidden",textAlign:"left",width:{min:0,max:250},padding:"5px 9px",border:{width:1,radius:0,color:"#d3d3d3"},tip:{corner:false,color:false,size:{width:13,height:13},opacity:1},title:{background:"#e1e1e1",fontWeight:"bold",padding:"7px 12px"},button:{cursor:"pointer"},classes:{target:"",tip:"qtip-tip",title:"qtip-title",button:"qtip-button",content:"qtip-content",active:"qtip-active"}},cream:{border:{width:3,radius:0,color:"#F9E98E"},title:{background:"#F0DE7D",color:"#A27D35"},background:"#FBF7AA",color:"#A27D35",classes:{tooltip:"qtip-cream"}},light:{border:{width:3,radius:0,color:"#E2E2E2"},title:{background:"#f1f1f1",color:"#454545"},background:"white",color:"#454545",classes:{tooltip:"qtip-light"}},dark:{border:{width:3,radius:0,color:"#303030"},title:{background:"#404040",color:"#f3f3f3"},background:"#505050",color:"#f3f3f3",classes:{tooltip:"qtip-dark"}},red:{border:{width:3,radius:0,color:"#CE6F6F"},title:{background:"#f28279",color:"#9C2F2F"},background:"#F79992",color:"#9C2F2F",classes:{tooltip:"qtip-red"}},green:{border:{width:3,radius:0,color:"#A9DB66"},title:{background:"#b9db8c",color:"#58792E"},background:"#CDE6AC",color:"#58792E",classes:{tooltip:"qtip-green"}},blue:{border:{width:3,radius:0,color:"#ADD9ED"},title:{background:"#D0E9F5",color:"#5E99BD"},background:"#E5F6FE",color:"#4D9FBF",classes:{tooltip:"qtip-blue"}}}})(joms.jQuery);

(function($) {

$.fn.stretchToFit = function(windowResize) {

	(function stretchToFit(target)
	{
		target.css('width', '100%');

		// Google Chrome doesn't return correct outerWidth() else things would be nicer.
		// css('width', width()*2 - outerWidth(true));
		target.css('width', target.width() - parseInt(target.css('borderLeftWidth'))
		                                   - parseInt(target.css('borderRightWidth'))
		                                   - parseInt(target.css('padding-left'))
		                                   - parseInt(target.css('padding-right')));

	})(this);

	return this;

};

})(joms.jQuery);


(function($) {

$.fn.defaultValue = function(defaultText, defaultClass) {

	var target = this;

	function Focus()
	{
		if (target.val()==defaultText)
		{
			target.val('');
		}

		target.removeClass(defaultClass);
	}

	function Blur()
	{
		var _defaultText  = target.data('defaultText');
		var _defaultClass = target.data('defaultClass');

		var empty = target.val().length < 1 ||
		            target.val() == _defaultText ||
		            target.hasClass(_defaultClass);

		if (empty) target.val(defaultText);

		if (defaultClass != _defaultClass)
			target.removeClass('_defaultClass');

		target.toggleClass(defaultClass, empty);
	}

	target
		.focus(Focus)
		.blur(Blur);

	Blur();

	target.data('defaultText', defaultText);
	target.data('defaultClass', defaultClass);

	return target;

}

})(joms.jQuery);


(function($) {

$.fn.serializeJSON = function() {

	var params = {};

	$.each(this.serializeArray(), function()
	{
		params[this.name] = this.value;
	})	

	return params;
}

})(joms.jQuery);

/*** window-1.0.js ***/

function cWindowShow(windowCall, winTitle, contentWidth, contentHeight, winType)
{
	joms.jQuery('#cWindow').remove();

	/* Original HTML at bottom. Edit, encodeURIComponent and put it back here. */
	var cWindow = joms.jQuery(decodeURIComponent('%3Cdiv%20id%3D%22cWindow%22%20class%3D%22dialog%22%3E%0A%09%3Cdiv%20id%3D%22cwin_tl%22%3E%3C%2Fdiv%3E%0A%09%3Cdiv%20id%3D%22cwin_tm%22%3E%3C%2Fdiv%3E%0A%09%3Cdiv%20id%3D%22cwin_tr%22%3E%3C%2Fdiv%3E%0A%09%3Cdiv%20style%3D%22clear%3A%20both%3B%22%3E%3C%2Fdiv%3E%0A%0A%09%3Cdiv%20id%3D%22cwin_ml%22%3E%3C%2Fdiv%3E%0A%09%3Cdiv%20id%3D%22cWindowContentOuter%22%3E%0A%0A%09%09%3Cdiv%20id%3D%22cWindowContentTop%22%3E%0A%09%09%09%3Ca%20href%3D%22javascript%3Avoid(0)%3B%22%20onclick%3D%22cWindowHide()%3B%22%20id%3D%22cwin_close_btn%22%3EClose%3C%2Fa%3E%0A%09%09%09%3Cdiv%20id%3D%22cwin_logo%22%3E%3C%2Fdiv%3E%0A%09%09%09%3Cdiv%20class%3D%22clr%22%3E%3C%2Fdiv%3E%0A%09%09%3C%2Fdiv%3E%0A%0A%09%09%3Cdiv%20id%3D%22cWindowContentWrap%22%3E%0A%09%09%09%3Cdiv%20id%3D%22cWindowContent%22%3E%3C%2Fdiv%3E%0A%09%09%3C%2Fdiv%3E%0A%0A%09%3C%2Fdiv%3E%0A%09%3Cdiv%20id%3D%22cwin_mr%22%3E%3C%2Fdiv%3E%0A%09%3Cdiv%20style%3D%22clear%3A%20both%3B%22%3E%3C%2Fdiv%3E%0A%0A%09%3Cdiv%20id%3D%22cwin_bl%22%3E%3C%2Fdiv%3E%0A%09%3Cdiv%20id%3D%22cwin_bm%22%3E%3C%2Fdiv%3E%0A%09%3Cdiv%20id%3D%22cwin_br%22%3E%3C%2Fdiv%3E%0A%09%3Cdiv%20style%3D%22clear%3A%20both%3B%22%3E%3C%2Fdiv%3E%0A%3C%2Fdiv%3E'));

	var cWindowSize = {
		contentWrapHeight  : function() { return +contentHeight },
		contentOuterWidth  : function() { return +contentWidth },
		contentOuterHeight : function() { return +contentHeight + 30 },
		width              : function() { return this.contentOuterWidth() + 40 },
		height             : function() { return this.contentOuterHeight() + 40 },
		left               : function() { return (joms.jQuery(window).width() - this.width()) / 2 },
		top                : function() { return joms.jQuery(document).scrollTop() + ((joms.jQuery(window).height() - this.height()) / 2) },
		zIndex             : function() { return cGetZIndexMax() + 1 }
	};

	cWindow.find('#cwin_logo')	
		.html(winTitle);

	cWindow.find('#cWindowContentWrap')
		.css(
		{
			'height': cWindowSize.contentWrapHeight()
		});

	cWindow.find('#cWindowContentOuter, #cwin_tm, #cwin_bm')
		.css(
		{
			'width': cWindowSize.contentOuterWidth()
		});

	cWindow.find('#cWindowContentOuter, #cwin_ml, #cwin_mr')
		.css(
		{
			'height': cWindowSize.contentOuterHeight()
		});

	cWindow
		.attr(
		{
			'class' : winType
		})
		.css(
		{
			'width' : cWindowSize.width(),
			'height': cWindowSize.height(),
			'top'   : cWindowSize.top(),
			'left'  : cWindowSize.left(),
			'zIndex': cWindowSize.zIndex()
		})
		.prependTo('body');


	// Set up behaviour
	jax.loadingFunction = function() {
		joms.jQuery('#cWindowContentWrap').addClass('loading')
		                                  .css('overflow', 'hidden');
	};
	jax.doneLoadingFunction = function() {
		joms.jQuery('#cWindowContentWrap').removeClass('loading')
		                                  .css('overflow', 'auto');
	};

	if (windowCall!=undefined && typeof(windowCall)=="string") eval(windowCall);
	if (typeof(windowCall)=="function") windowCall();

	/* Fixes */
		// Rebuild alpha transparent border in IE6
		if (joms.jQuery.browser.msie && joms.jQuery.browser.version.substr(0,1)<7 && typeof(jomsIE6)!="undefined" && jomsIE6==true)
		{
			joms.jQuery('#cwin_tm, #cwin_bm, #cwin_ml, #cwin_mr').each(function()
			{
				joms.jQuery(this)[0].filters(0).sizingMethod="crop";
			})
		}

		// Hide iframe as it appear on top of cWindow
		joms.jQuery('#community-wrap iframe').css('visibility', 'hidden');
	/* Fixes */
}

function cWindowHide()
{
	var cWindow = joms.jQuery('#cWindow');

	cWindow.find('#cWindowAction').add('<div>')
		.animate({bottom: '-30px'}, 'fast', function()
		{
			cWindow
				.fadeOut('fast', function()
				{
					cWindow.remove();
					joms.jQuery('#community-wrap iframe').css('visibility', 'visible');
				});
		});
}

// Add content to cWindow and auto-resize them
function cWindowAddContent(html, actions){

	var actionBarHeight = (actions) ? 30 : 0;

	var oldh = joms.jQuery('#cWindowContentWrap').height();
	var oldt = joms.jQuery('#cWindow').position().top;

	var cWindow = joms.jQuery('#cWindow');

	var cWindowContent = 
	cWindow.find('#cWindowContent')
		.html(html);

	var h = cWindowContent.outerHeight();

	var maxH = joms.jQuery(window).height() * 0.7;

	if (h > maxH) h = maxH;
	
	cWindow.find('#cWindowContentWrap')
		.animate(
		{
			'height' : '+='+ (h-oldh) + 'px'
		});

	cWindow.find('#cWindowContentOuter, #cwin_ml, #cwin_mr')
		.animate(
		{
			'height' : '+='+ ((h-oldh) + (actionBarHeight)) + 'px'
		});

	cWindow
		.animate(
		{
			'height' : '+='+  ((h-oldh) + (actionBarHeight)) + 'px',
			'top'    : '-=' + (h-oldh)/2 + 'px'
		},
		function() {
			if (actions)
			{
				joms.jQuery('<div id="cWindowAction">')
					.html(actions)
					.css('bottom', '-30px')
					.appendTo('#cWindowContentOuter')
					.animate({bottom: '0px'});
			}
		});
}

function cWindowResize(h)
{
	var actions = joms.jQuery('#cWindowActions');

	var actionBarHeight = (actions.length > 0) ? 30 : 0;

	var oldh = joms.jQuery('#cWindowContentWrap').height();
	var oldt = joms.jQuery('#cWindow').position().top;

	h = parseInt(h);

	var cWindow = joms.jQuery('#cWindow');
	
	cWindow.find('#cWindowContentWrap')
		.animate(
		{
			'height' : '+='+ (h-oldh) + 'px'
		});

	cWindow.find('#cWindowContentOuter, #cwin_ml, #cwin_mr')
		.animate(
		{
			'height' : '+='+ ((h-oldh) + (actionBarHeight)) + 'px'
		});

	cWindow
		.animate(
		{
			'height' : '+='+  ((h-oldh) + (actionBarHeight)) + 'px',
			'top'    : '-=' + (h-oldh)/2 + 'px'
		});
}

function cWindowActions(action)
{
	var actions = joms.jQuery('#cWindowActions');

	var actionBarHeight = (actions) ? 30 : 0;

	// Remove any existing cWindowAction	
	joms.jQuery('#cWindowAction').remove();
	
	var oldh = joms.jQuery('#cWindowContentWrap').height();
	var oldt = joms.jQuery('#cWindow').position().top;

	var cWindow = joms.jQuery('#cWindow');

	var h = joms.jQuery('#cWindowContent').outerHeight();
	
	cWindow.find('#cWindowContentWrap')
		.animate(
		{
			'height' : '+='+ (h-oldh) + 'px'
		});

	cWindow.find('#cWindowContentOuter, #cwin_ml, #cwin_mr')
		.animate(
		{
			'height' : '+='+ ((h-oldh) + (actionBarHeight)) + 'px'
		});

	cWindow
		.animate(
		{
			'height' : '+='+  ((h-oldh) + (actionBarHeight)) + 'px',
			'top'    : '-=' + (h-oldh)/2 + 'px'
		},
		function() {
			if (actions)
			{
				joms.jQuery('<div id="cWindowAction">')
					.html(action)
					.css('bottom', '-30px')
					.appendTo('#cWindowContentOuter')
					.animate({bottom: '0px'});
			}
		});

	// Set up behavior when actions are invoked
	jax.loadingFunction = function() {
		joms.jQuery('#cWindowAction').addClass('loading');
		joms.jQuery('#cWindowContent').find('input, textarea, button')
		                         .attr('disabled', true);
	}
	jax.doneLoadingFunction = function() {
		joms.jQuery('#cWindowAction').removeClass('loading');
		joms.jQuery('#cWindowContent').find('input, textarea, button')
		                         .attr('disabled', false);
	};
}

function cGetZIndexMax()
{
	var allElems = document.getElementsByTagName?
	document.getElementsByTagName("*"):
	document.all; // or test for that too
	var maxZIndex = 0;

	for(var i=0;i<allElems.length;i++) {
		var elem = allElems[i];
		var cStyle = null;
		if (elem.currentStyle) {cStyle = elem.currentStyle;}
		else if (document.defaultView && document.defaultView.getComputedStyle) {
			cStyle = document.defaultView.getComputedStyle(elem,"");
		}

		var sNum;
		if (cStyle) {
			sNum = Number(cStyle.zIndex);
		} else {
			sNum = Number(elem.style.zIndex);
		}
		if (!isNaN(sNum)) {
			maxZIndex = Math.max(maxZIndex,sNum);
		}
	}	
	return maxZIndex;
}

/*
<div id="cWindow" class="dialog">
	<div id="cwin_tl"></div>
	<div id="cwin_tm"></div>
	<div id="cwin_tr"></div>
	<div style="clear: both;"></div>

	<div id="cwin_ml"></div>
	<div id="cWindowContentOuter">

		<div id="cWindowContentTop">
			<a href="javascript:void(0);" onclick="cWindowHide();" id="cwin_close_btn">Close</a>
			<div id="cwin_logo"></div>
			<div class="clr"></div>
		</div>

		<div id="cWindowContentWrap">
			<div id="cWindowContent"></div>
		</div>

	</div>
	<div id="cwin_mr"></div>
	<div style="clear: both;"></div>

	<div id="cwin_bl"></div>
	<div id="cwin_bm"></div>
	<div id="cwin_br"></div>
	<div style="clear: both;"></div>
</div>
*/
;

/*** joms.ajax.js ***/

/*
=========
joms.ajax
=========

joms.ajax = jax + jQuery.ajax().
Jax is like the protocol. jQuery.ajax() is like the transport.

Process flow:
Jax wraps data.
  |
jQuery.ajax() sends the data to server.
  |
Server returns jax responses.
  |
jQuery.ajax() delegate jax responses.
  |
jax.processResponse() executes jax response.
  |
jQuery.ajax() extract callback data
embedded within jax responses.
  |
jQuery.ajax() pass the callback data to
error, success & complete handler.

This is done without modifying neither jax or jQuery.ajax() library.
So existing jax.call() can execute side-by-side without problems.

============================
How to use joms.ajax.call()?
============================

joms.ajax.call(sFunc, sArgs, callback)
joms.ajax.call('controller,function', [arg1, arg2], function(data) {
	// What to do when the ajax call is successful
});

joms.ajax.call(sFunc, sArgs, settings)
joms.ajax.call('controller,function', [arg1, arg2] {
	success: function(data) {
		// What to do when the ajax call is successful
	},
	error: function(data) {
		// What to do when the ajax call is not successful
		// e.g. timeout, 404, 500, etc.
	},

	// For more settings to fiddle with, look up jQuery.ajax() docs.
});


===========================================
Advantage of joms.ajax() with example usage
===========================================

1. Ability to use PHP associative array as JSON as callback data, e.g.

	// ---- PHP side --- //
	$callbackData['url'] = 'http://www.jomsocial.com'
	$callbackData['caption'] = 'JomSocial'
		
	$objResponse->addScriptCall('__callback', $callbackData);
	
	// ---- JS side --- //
	joms.ajax.call('controller,function', [arg1, arg2], function(data)
	{
		console.log(data.url);     // output http://www.jomsocial.com
		console.log(data.caption); // output JomSocial
	});	
	
2. Ability to handle server timeouts or other errors, e.g.

	joms.ajax.call('apps,ajaxSetOrder', [appOrder], {
		success: function(data) {
			// Remove saving indicator
			jQuery('#app-position').removeClass('onSave');
		},
		error: function(data) {
			// Revert app ordering
			jQuery('#app-position').sortable('cancel');
		}
	});

3. Continue writing relevant codes within the same function in JS,
   instead of writing them as addScriptCall() in PHP, while
   preserving the function/variable scope those relevant codes
   could access and reuse, e.g.

	function removePhoto()
	{
		var photo   = jQuery('#photo-63');
		var photoId = photo.attr('id').split('-')[1];
		
		joms.ajax.call('photos,ajaxRemovePhoto', [photoId], function(data)
		{
			// Now I can use back the 'photo' variable
			// $objResponse->addScriptCall('jQuery("#photo-' + $photoId + ')').remove');
	
			jQuery(photo).remove();
		});
	}
*/

joms.extend({
	ajax: {
		execute: function(o)
		{
			// Rearrange jQuery.ajax callback order.
			// jQuery.ajax : beforeSend -> dataFilter -> success/error -> complete
			// joms.ajax   : beforeSend -> beforeDataFilter -> dataFilter -> afterDataFilter -> fail/success/error -> complete
			//
			// joms.ajax callback handlers
			// - beforeSend: function(xhr)
			// - fail      : function(xhr, status, e)
			// - beforeDataFilter: function(jaxData)
			// - afterDataFilter : function(jomsData)
			// - success   : function(arg1, arg2...)  // from $objResponse->addScriptCall('__callback', $arg1, $arg2);
			// - error     : function(arg1, arg2...)  // from $objResponse->addScriptCall('__throwError', $arg1, $arg2);
			// - complete  : function(xhr, status)
			var settings = {};
			joms.jQuery.extend(settings, o);			

			settings.error = function()
			{
				if (o.fail) o.fail.apply(this, arguments);
			}

			settings.dataFilter = function(jaxData, type)
			{
				if (o.beforeDataFilter) o.beforeDataFilter(jaxData);

				// Delegate jax commands to jax.processReponse()
				jax.processResponse(jaxData);
				
				// Extract callback data embedded inside jaxData
				var jomsData = {
					success: joms.ajax.extractJomsData(jaxData, '__callback'),
					error  : joms.ajax.extractJomsData(jaxData, '__throwError')
				}
				
				if (o.afterDataFilter) o.afterDataFilter(jomsData);

				return jomsData;
			}

			settings.success = function(jomsData, status)
			{
				if (jomsData.error.length>0 && o.error)
				{
					joms.jQuery.each(jomsData.error, function(i, args)
					{
						o.error.apply(this, args);
					});
					return;
				}

				if (jomsData.success.length>0 && o.success)
				{
					joms.jQuery.each(jomsData.success, function(i, args)
					{
						o.success.apply(this, args);
					});
				}
			}

			// Create a dummy __callback function so we don't have
			// waste computing cycles trying to filter them out in
			// filterJaxResponse();
			window.__callback = window.__throwError = function() {};
			
			// Use jQuery.ajax() (replacing the not-so-fun jax.submitTask())
			joms.jQuery.ajax(settings);
		},

		/*
		 * joms.ajax.call()
		 *
		 * @param sFunc {String} The server function to call in the format of "controller,function"
		 * @param sArgs {Array} The arguments to pass to the server function
		 * @param o {Function/Object} If passed as a function, it is treated as callback function
		 *                            that gets executed by 'success' event.
		 *                            If passed as an object, it is treated as ajax settings.
		 */
		call: function(sFunc, sArgs, o)
		{
			var settings = {
				url: jax_live_site,
				type: 'POST',
				data: {
					option : 'community',
					task   : 'azrul_ajax',
					no_html: 1,
					func   : sFunc
				},
				dataType: 'text'
			};
			
			// To fix CSRF issues.
			settings.data[ jax_token_var ]	= 1;
			
			// Build Jax-style arguments for the url param
			joms.jQuery.extend(settings.data, this.buildSArgs(sArgs));
			
			// If o is callback function, wrap it back as an ajax settings object.
			if (typeof o=='function')
				o = {success: o};
			
			// Override default settings with provided settings
			joms.jQuery.extend(settings, o);

			this.execute(settings);
		},
		
		/*
		 * joms.ajax.buildSArgs()
		 * [Internal function]
		 *
		 * Modified from jax.call().
		 * Instead of building arguments into a string,
		 * this function builds arguments into a key/value object,
		 * and jQuery.ajax() function will serialize them.
		 *
		 * @param sArgs {array} An array of arguments to pass into the server function.
		 */
		buildSArgs: function(sArgs)
		{
			var data = {};
			
			joms.jQuery(sArgs).each(function(i, a)
			{
				if (typeof a=='string')
					a.replace(/"/g, '&quot;');

				if (!jax.isArray(a))
					a = new Array('_d_', encodeURIComponent(a));
					
				data['arg'+i] = jax.stringify(a);
			})

			return data;
		},

		extractJomsData: function(jaxData, handler)
		{		
			var jomsData = [];
			joms.jQuery.each(eval(jaxData), function()
			{
				if (this[0]=='cs' && this[1]==handler)
				{
					jomsData.push(this.slice(3)[0]);
				}
			});

			return jomsData;
		}
	}	
});

/*** mootools.js ***/

//MooTools, My Object Oriented Javascript Tools. Copyright (c) 2006 Valerio Proietti, <http://mad4milk.net>, MIT Style License.

var MooTools={version:'1.12'};function $defined(obj){return(obj!=undefined);};function $type(obj){if(!$defined(obj))return false;if(obj.htmlElement)return'element';var type=typeof obj;if(type=='object'&&obj.nodeName){switch(obj.nodeType){case 1:return'element';case 3:return(/\S/).test(obj.nodeValue)?'textnode':'whitespace';}}
if(type=='object'||type=='function'){switch(obj.constructor){case Array:return'array';case RegExp:return'regexp';case Class:return'class';}
if(typeof obj.length=='number'){if(obj.item)return'collection';if(obj.callee)return'arguments';}}
return type;};function $merge(){var mix={};for(var i=0;i<arguments.length;i++){for(var property in arguments[i]){var ap=arguments[i][property];var mp=mix[property];if(mp&&$type(ap)=='object'&&$type(mp)=='object')mix[property]=$merge(mp,ap);else mix[property]=ap;}}
return mix;};var $extend=function(){var args=arguments;if(!args[1])args=[this,args[0]];for(var property in args[1])args[0][property]=args[1][property];return args[0];};var $native=function(){for(var i=0,l=arguments.length;i<l;i++){arguments[i].extend=function(props){for(var prop in props){if(!this.prototype[prop])this.prototype[prop]=props[prop];if(!this[prop])this[prop]=$native.generic(prop);}};}};$native.generic=function(prop){return function(bind){return this.prototype[prop].apply(bind,Array.prototype.slice.call(arguments,1));};};$native(Function,Array,String,Number);function $chk(obj){return!!(obj||obj===0);};function $pick(obj,picked){return $defined(obj)?obj:picked;};function $random(min,max){return Math.floor(Math.random()*(max-min+1)+min);};function $time(){return new Date().getTime();};function $clear(timer){clearTimeout(timer);clearInterval(timer);return null;};var Abstract=function(obj){obj=obj||{};obj.extend=$extend;return obj;};var Window=new Abstract(window);var Document=new Abstract(document);document.head=document.getElementsByTagName('head')[0];window.xpath=!!(document.evaluate);if(window.ActiveXObject)window.ie=window[window.XMLHttpRequest?'ie7':'ie6']=true;else if(document.childNodes&&!document.all&&!navigator.taintEnabled)window.webkit=window[window.xpath?'webkit420':'webkit419']=true;else if(document.getBoxObjectFor!=null||window.mozInnerScreenX!=null)window.gecko=true;window.khtml=window.webkit;Object.extend=$extend;if(typeof HTMLElement=='undefined'){var HTMLElement=function(){};if(window.webkit)document.createElement("iframe");HTMLElement.prototype=(window.webkit)?window["[[DOMElement.prototype]]"]:{};}
HTMLElement.prototype.htmlElement=function(){};if(window.ie6)try{document.execCommand("BackgroundImageCache",false,true);}catch(e){};var Class=function(properties){var klass=function(){return(arguments[0]!==null&&this.initialize&&$type(this.initialize)=='function')?this.initialize.apply(this,arguments):this;};$extend(klass,this);klass.prototype=properties;klass.constructor=Class;return klass;};Class.empty=function(){};Class.prototype={extend:function(properties){var proto=new this(null);for(var property in properties){var pp=proto[property];proto[property]=Class.Merge(pp,properties[property]);}
return new Class(proto);},implement:function(){for(var i=0,l=arguments.length;i<l;i++)$extend(this.prototype,arguments[i]);}};Class.Merge=function(previous,current){if(previous&&previous!=current){var type=$type(current);if(type!=$type(previous))return current;switch(type){case'function':var merged=function(){this.parent=arguments.callee.parent;return current.apply(this,arguments);};merged.parent=previous;return merged;case'object':return $merge(previous,current);}}
return current;};var Chain=new Class({chain:function(fn){this.chains=this.chains||[];this.chains.push(fn);return this;},callChain:function(){if(this.chains&&this.chains.length)this.chains.shift().delay(10,this);},clearChain:function(){this.chains=[];}});var Events=new Class({addEvent:function(type,fn){if(fn!=Class.empty){this.$events=this.$events||{};this.$events[type]=this.$events[type]||[];this.$events[type].include(fn);}
return this;},fireEvent:function(type,args,delay){if(this.$events&&this.$events[type]){this.$events[type].each(function(fn){fn.create({'bind':this,'delay':delay,'arguments':args})();},this);}
return this;},removeEvent:function(type,fn){if(this.$events&&this.$events[type])this.$events[type].remove(fn);return this;}});var Options=new Class({setOptions:function(){this.options=$merge.apply(null,[this.options].extend(arguments));if(this.addEvent){for(var option in this.options){if($type(this.options[option]=='function')&&(/^on[A-Z]/).test(option))this.addEvent(option,this.options[option]);}}
return this;}});Array.extend({forEach:function(fn,bind){for(var i=0,j=this.length;i<j;i++)fn.call(bind,this[i],i,this);},filter:function(fn,bind){var results=[];for(var i=0,j=this.length;i<j;i++){if(fn.call(bind,this[i],i,this))results.push(this[i]);}
return results;},map:function(fn,bind){var results=[];for(var i=0,j=this.length;i<j;i++)results[i]=fn.call(bind,this[i],i,this);return results;},every:function(fn,bind){for(var i=0,j=this.length;i<j;i++){if(!fn.call(bind,this[i],i,this))return false;}
return true;},some:function(fn,bind){for(var i=0,j=this.length;i<j;i++){if(fn.call(bind,this[i],i,this))return true;}
return false;},indexOf:function(item,from){var len=this.length;for(var i=(from<0)?Math.max(0,len+from):from||0;i<len;i++){if(this[i]===item)return i;}
return-1;},copy:function(start,length){start=start||0;if(start<0)start=this.length+start;length=length||(this.length-start);var newArray=[];for(var i=0;i<length;i++)newArray[i]=this[start++];return newArray;},remove:function(item){var i=0;var len=this.length;while(i<len){if(this[i]===item){this.splice(i,1);len--;}else{i++;}}
return this;},contains:function(item,from){return this.indexOf(item,from)!=-1;},associate:function(keys){var obj={},length=Math.min(this.length,keys.length);for(var i=0;i<length;i++)obj[keys[i]]=this[i];return obj;},extend:function(array){for(var i=0,j=array.length;i<j;i++)this.push(array[i]);return this;},merge:function(array){for(var i=0,l=array.length;i<l;i++)this.include(array[i]);return this;},include:function(item){if(!this.contains(item))this.push(item);return this;},getRandom:function(){return this[$random(0,this.length-1)]||null;},getLast:function(){return this[this.length-1]||null;}});Array.prototype.each=Array.prototype.forEach;Array.each=Array.forEach;function $A(array){return Array.copy(array);};function $each(iterable,fn,bind){if(iterable&&typeof iterable.length=='number'&&$type(iterable)!='object'){Array.forEach(iterable,fn,bind);}else{for(var name in iterable)fn.call(bind||iterable,iterable[name],name);}};Array.prototype.test=Array.prototype.contains;String.extend({test:function(regex,params){return(($type(regex)=='string')?new RegExp(regex,params):regex).test(this);},toInt:function(){return parseInt(this,10);},toFloat:function(){return parseFloat(this);},camelCase:function(){return this.replace(/-\D/g,function(match){return match.charAt(1).toUpperCase();});},hyphenate:function(){return this.replace(/\w[A-Z]/g,function(match){return(match.charAt(0)+'-'+match.charAt(1).toLowerCase());});},capitalize:function(){return this.replace(/\b[a-z]/g,function(match){return match.toUpperCase();});},trim:function(){return this.replace(/^\s+|\s+$/g,'');},clean:function(){return this.replace(/\s{2,}/g,' ').trim();},rgbToHex:function(array){var rgb=this.match(/\d{1,3}/g);return(rgb)?rgb.rgbToHex(array):false;},hexToRgb:function(array){var hex=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);return(hex)?hex.slice(1).hexToRgb(array):false;},contains:function(string,s){return(s)?(s+this+s).indexOf(s+string+s)>-1:this.indexOf(string)>-1;},escapeRegExp:function(){return this.replace(/([.*+?^${}()|[\]\/\\])/g,'\\$1');}});Array.extend({rgbToHex:function(array){if(this.length<3)return false;if(this.length==4&&this[3]==0&&!array)return'transparent';var hex=[];for(var i=0;i<3;i++){var bit=(this[i]-0).toString(16);hex.push((bit.length==1)?'0'+bit:bit);}
return array?hex:'#'+hex.join('');},hexToRgb:function(array){if(this.length!=3)return false;var rgb=[];for(var i=0;i<3;i++){rgb.push(parseInt((this[i].length==1)?this[i]+this[i]:this[i],16));}
return array?rgb:'rgb('+rgb.join(',')+')';}});Function.extend({create:function(options){var fn=this;options=$merge({'bind':fn,'event':false,'arguments':null,'delay':false,'periodical':false,'attempt':false},options);if($chk(options.arguments)&&$type(options.arguments)!='array')options.arguments=[options.arguments];return function(event){var args;if(options.event){event=event||window.event;args=[(options.event===true)?event:new options.event(event)];if(options.arguments)args.extend(options.arguments);}
else args=options.arguments||arguments;var returns=function(){return fn.apply($pick(options.bind,fn),args);};if(options.delay)return setTimeout(returns,options.delay);if(options.periodical)return setInterval(returns,options.periodical);if(options.attempt)try{return returns();}catch(err){return false;};return returns();};},pass:function(args,bind){return this.create({'arguments':args,'bind':bind});},attempt:function(args,bind){return this.create({'arguments':args,'bind':bind,'attempt':true})();},bind:function(bind,args){return this.create({'bind':bind,'arguments':args});},bindAsEventListener:function(bind,args){return this.create({'bind':bind,'event':true,'arguments':args});},delay:function(delay,bind,args){return this.create({'delay':delay,'bind':bind,'arguments':args})();},periodical:function(interval,bind,args){return this.create({'periodical':interval,'bind':bind,'arguments':args})();}});Number.extend({toInt:function(){return parseInt(this);},toFloat:function(){return parseFloat(this);},limit:function(min,max){return Math.min(max,Math.max(min,this));},round:function(precision){precision=Math.pow(10,precision||0);return Math.round(this*precision)/precision;},times:function(fn){for(var i=0;i<this;i++)fn(i);}});var Element=new Class({initialize:function(el,props){if($type(el)=='string'){if(window.ie&&props&&(props.name||props.type)){var name=(props.name)?' name="'+props.name+'"':'';var type=(props.type)?' type="'+props.type+'"':'';delete props.name;delete props.type;el='<'+el+name+type+'>';}
el=document.createElement(el);}
el=$(el);return(!props||!el)?el:el.set(props);}});var Elements=new Class({initialize:function(elements){return(elements)?$extend(elements,this):this;}});Elements.extend=function(props){for(var prop in props){this.prototype[prop]=props[prop];this[prop]=$native.generic(prop);}};function $(el){if(!el)return null;if(el.htmlElement)return Garbage.collect(el);if([window,document].contains(el))return el;var type=$type(el);if(type=='string'){el=document.getElementById(el);type=(el)?'element':false;}
if(type!='element')return null;if(el.htmlElement)return Garbage.collect(el);if(['object','embed'].contains(el.tagName.toLowerCase()))return el;$extend(el,Element.prototype);el.htmlElement=function(){};return Garbage.collect(el);};document.getElementsBySelector=document.getElementsByTagName;function $$(){var elements=[];for(var i=0,j=arguments.length;i<j;i++){var selector=arguments[i];switch($type(selector)){case'element':elements.push(selector);case'boolean':break;case false:break;case'string':selector=document.getElementsBySelector(selector,true);default:elements.extend(selector);}}
return $$.unique(elements);};$$.unique=function(array){var elements=[];for(var i=0,l=array.length;i<l;i++){if(array[i].$included)continue;var element=$(array[i]);if(element&&!element.$included){element.$included=true;elements.push(element);}}
for(var n=0,d=elements.length;n<d;n++)elements[n].$included=null;return new Elements(elements);};Elements.Multi=function(property){return function(){var args=arguments;var items=[];var elements=true;for(var i=0,j=this.length,returns;i<j;i++){returns=this[i][property].apply(this[i],args);if($type(returns)!='element')elements=false;items.push(returns);};return(elements)?$$.unique(items):items;};};Element.extend=function(properties){for(var property in properties){HTMLElement.prototype[property]=properties[property];Element.prototype[property]=properties[property];Element[property]=$native.generic(property);var elementsProperty=(Array.prototype[property])?property+'Elements':property;Elements.prototype[elementsProperty]=Elements.Multi(property);}};Element.extend({set:function(props){for(var prop in props){var val=props[prop];switch(prop){case'styles':this.setStyles(val);break;case'events':if(this.addEvents)this.addEvents(val);break;case'properties':this.setProperties(val);break;default:this.setProperty(prop,val);}}
return this;},inject:function(el,where){el=$(el);switch(where){case'before':el.parentNode.insertBefore(this,el);break;case'after':var next=el.getNext();if(!next)el.parentNode.appendChild(this);else el.parentNode.insertBefore(this,next);break;case'top':var first=el.firstChild;if(first){el.insertBefore(this,first);break;}
default:el.appendChild(this);}
return this;},injectBefore:function(el){return this.inject(el,'before');},injectAfter:function(el){return this.inject(el,'after');},injectInside:function(el){return this.inject(el,'bottom');},injectTop:function(el){return this.inject(el,'top');},adopt:function(){var elements=[];$each(arguments,function(argument){elements=elements.concat(argument);});$$(elements).inject(this);return this;},remove:function(){return this.parentNode.removeChild(this);},clone:function(contents){var el=$(this.cloneNode(contents!==false));if(!el.$events)return el;el.$events={};for(var type in this.$events)el.$events[type]={'keys':$A(this.$events[type].keys),'values':$A(this.$events[type].values)};return el.removeEvents();},replaceWith:function(el){el=$(el);this.parentNode.replaceChild(el,this);return el;},appendText:function(text){this.appendChild(document.createTextNode(text));return this;},hasClass:function(className){return this.className.contains(className,' ');},addClass:function(className){if(!this.hasClass(className))this.className=(this.className+' '+className).clean();return this;},removeClass:function(className){this.className=this.className.replace(new RegExp('(^|\\s)'+className+'(?:\\s|$)'),'$1').clean();return this;},toggleClass:function(className){return this.hasClass(className)?this.removeClass(className):this.addClass(className);},setStyle:function(property,value){switch(property){case'opacity':return this.setOpacity(parseFloat(value));case'float':property=(window.ie)?'styleFloat':'cssFloat';}
property=property.camelCase();switch($type(value)){case'number':if(!['zIndex','zoom'].contains(property))value+='px';break;case'array':value='rgb('+value.join(',')+')';}
this.style[property]=value;return this;},setStyles:function(source){switch($type(source)){case'object':Element.setMany(this,'setStyle',source);break;case'string':this.style.cssText=source;}
return this;},setOpacity:function(opacity){if(opacity==0){if(this.style.visibility!="hidden")this.style.visibility="hidden";}else{if(this.style.visibility!="visible")this.style.visibility="visible";}
if(!this.currentStyle||!this.currentStyle.hasLayout)this.style.zoom=1;if(window.ie)this.style.filter=(opacity==1)?'':"alpha(opacity="+opacity*100+")";this.style.opacity=this.$tmp.opacity=opacity;return this;},getStyle:function(property){property=property.camelCase();var result=this.style[property];if(!$chk(result)){if(property=='opacity')return this.$tmp.opacity;result=[];for(var style in Element.Styles){if(property==style){Element.Styles[style].each(function(s){var style=this.getStyle(s);result.push(parseInt(style)?style:'0px');},this);if(property=='border'){var every=result.every(function(bit){return(bit==result[0]);});return(every)?result[0]:false;}
return result.join(' ');}}
if(property.contains('border')){if(Element.Styles.border.contains(property)){return['Width','Style','Color'].map(function(p){return this.getStyle(property+p);},this).join(' ');}else if(Element.borderShort.contains(property)){return['Top','Right','Bottom','Left'].map(function(p){return this.getStyle('border'+p+property.replace('border',''));},this).join(' ');}}
if(document.defaultView)result=document.defaultView.getComputedStyle(this,null).getPropertyValue(property.hyphenate());else if(this.currentStyle)result=this.currentStyle[property];}
if(window.ie)result=Element.fixStyle(property,result,this);if(result&&property.test(/color/i)&&result.contains('rgb')){return result.split('rgb').splice(1,4).map(function(color){return color.rgbToHex();}).join(' ');}
return result;},getStyles:function(){return Element.getMany(this,'getStyle',arguments);},walk:function(brother,start){brother+='Sibling';var el=(start)?this[start]:this[brother];while(el&&$type(el)!='element')el=el[brother];return $(el);},getPrevious:function(){return this.walk('previous');},getNext:function(){return this.walk('next');},getFirst:function(){return this.walk('next','firstChild');},getLast:function(){return this.walk('previous','lastChild');},getParent:function(){return $(this.parentNode);},getChildren:function(){return $$(this.childNodes);},hasChild:function(el){return!!$A(this.getElementsByTagName('*')).contains(el);},getProperty:function(property){var index=Element.Properties[property];if(index)return this[index];var flag=Element.PropertiesIFlag[property]||0;if(!window.ie||flag)return this.getAttribute(property,flag);var node=this.attributes[property];return(node)?node.nodeValue:null;},removeProperty:function(property){var index=Element.Properties[property];if(index)this[index]='';else this.removeAttribute(property);return this;},getProperties:function(){return Element.getMany(this,'getProperty',arguments);},setProperty:function(property,value){var index=Element.Properties[property];if(index)this[index]=value;else this.setAttribute(property,value);return this;},setProperties:function(source){return Element.setMany(this,'setProperty',source);},setHTML:function(){this.innerHTML=$A(arguments).join('');return this;},setText:function(text){var tag=this.getTag();if(['style','script'].contains(tag)){if(window.ie){if(tag=='style')this.styleSheet.cssText=text;else if(tag=='script')this.setProperty('text',text);return this;}else{this.removeChild(this.firstChild);return this.appendText(text);}}
this[$defined(this.innerText)?'innerText':'textContent']=text;return this;},getText:function(){var tag=this.getTag();if(['style','script'].contains(tag)){if(window.ie){if(tag=='style')return this.styleSheet.cssText;else if(tag=='script')return this.getProperty('text');}else{return this.innerHTML;}}
return($pick(this.innerText,this.textContent));},getTag:function(){return this.tagName.toLowerCase();},empty:function(){Garbage.trash(this.getElementsByTagName('*'));return this.setHTML('');}});Element.fixStyle=function(property,result,element){if($chk(parseInt(result)))return result;if(['height','width'].contains(property)){var values=(property=='width')?['left','right']:['top','bottom'];var size=0;values.each(function(value){size+=element.getStyle('border-'+value+'-width').toInt()+element.getStyle('padding-'+value).toInt();});return element['offset'+property.capitalize()]-size+'px';}else if(property.test(/border(.+)Width|margin|padding/)){return'0px';}
return result;};Element.Styles={'border':[],'padding':[],'margin':[]};['Top','Right','Bottom','Left'].each(function(direction){for(var style in Element.Styles)Element.Styles[style].push(style+direction);});Element.borderShort=['borderWidth','borderStyle','borderColor'];Element.getMany=function(el,method,keys){var result={};$each(keys,function(key){result[key]=el[method](key);});return result;};Element.setMany=function(el,method,pairs){for(var key in pairs)el[method](key,pairs[key]);return el;};Element.Properties=new Abstract({'class':'className','for':'htmlFor','colspan':'colSpan','rowspan':'rowSpan','accesskey':'accessKey','tabindex':'tabIndex','maxlength':'maxLength','readonly':'readOnly','frameborder':'frameBorder','value':'value','disabled':'disabled','checked':'checked','multiple':'multiple','selected':'selected'});Element.PropertiesIFlag={'href':2,'src':2};Element.Methods={Listeners:{addListener:function(type,fn){if(this.addEventListener)this.addEventListener(type,fn,false);else this.attachEvent('on'+type,fn);return this;},removeListener:function(type,fn){if(this.removeEventListener)this.removeEventListener(type,fn,false);else this.detachEvent('on'+type,fn);return this;}}};window.extend(Element.Methods.Listeners);document.extend(Element.Methods.Listeners);Element.extend(Element.Methods.Listeners);var Garbage={elements:[],collect:function(el){if(!el.$tmp){Garbage.elements.push(el);el.$tmp={'opacity':1};}
return el;},trash:function(elements){for(var i=0,j=elements.length,el;i<j;i++){if(!(el=elements[i])||!el.$tmp)continue;if(el.$events)el.fireEvent('trash').removeEvents();for(var p in el.$tmp)el.$tmp[p]=null;for(var d in Element.prototype)el[d]=null;Garbage.elements[Garbage.elements.indexOf(el)]=null;el.htmlElement=el.$tmp=el=null;}
Garbage.elements.remove(null);},empty:function(){Garbage.collect(window);Garbage.collect(document);Garbage.trash(Garbage.elements);}};window.addListener('beforeunload',function(){window.addListener('unload',Garbage.empty);if(window.ie)window.addListener('unload',CollectGarbage);});var Event=new Class({initialize:function(event){if(event&&event.$extended)return event;this.$extended=true;event=event||window.event;this.event=event;this.type=event.type;this.target=event.target||event.srcElement;if(this.target.nodeType==3)this.target=this.target.parentNode;this.shift=event.shiftKey;this.control=event.ctrlKey;this.alt=event.altKey;this.meta=event.metaKey;if(['DOMMouseScroll','mousewheel'].contains(this.type)){this.wheel=(event.wheelDelta)?event.wheelDelta/120:-(event.detail||0)/3;}else if(this.type.contains('key')){this.code=event.which||event.keyCode;for(var name in Event.keys){if(Event.keys[name]==this.code){this.key=name;break;}}
if(this.type=='keydown'){var fKey=this.code-111;if(fKey>0&&fKey<13)this.key='f'+fKey;}
this.key=this.key||String.fromCharCode(this.code).toLowerCase();}else if(this.type.test(/(click|mouse|menu)/)){this.page={'x':event.pageX||event.clientX+document.documentElement.scrollLeft,'y':event.pageY||event.clientY+document.documentElement.scrollTop};this.client={'x':event.pageX?event.pageX-window.pageXOffset:event.clientX,'y':event.pageY?event.pageY-window.pageYOffset:event.clientY};this.rightClick=(event.which==3)||(event.button==2);switch(this.type){case'mouseover':this.relatedTarget=event.relatedTarget||event.fromElement;break;case'mouseout':this.relatedTarget=event.relatedTarget||event.toElement;}
this.fixRelatedTarget();}
return this;},stop:function(){return this.stopPropagation().preventDefault();},stopPropagation:function(){if(this.event.stopPropagation)this.event.stopPropagation();else this.event.cancelBubble=true;return this;},preventDefault:function(){if(this.event.preventDefault)this.event.preventDefault();else this.event.returnValue=false;return this;}});Event.fix={relatedTarget:function(){if(this.relatedTarget&&this.relatedTarget.nodeType==3)this.relatedTarget=this.relatedTarget.parentNode;},relatedTargetGecko:function(){try{Event.fix.relatedTarget.call(this);}catch(e){this.relatedTarget=this.target;}}};Event.prototype.fixRelatedTarget=(window.gecko)?Event.fix.relatedTargetGecko:Event.fix.relatedTarget;Event.keys=new Abstract({'enter':13,'up':38,'down':40,'left':37,'right':39,'esc':27,'space':32,'backspace':8,'tab':9,'delete':46});Element.Methods.Events={addEvent:function(type,fn){this.$events=this.$events||{};this.$events[type]=this.$events[type]||{'keys':[],'values':[]};if(this.$events[type].keys.contains(fn))return this;this.$events[type].keys.push(fn);var realType=type;var custom=Element.Events[type];if(custom){if(custom.add)custom.add.call(this,fn);if(custom.map)fn=custom.map;if(custom.type)realType=custom.type;}
if(!this.addEventListener)fn=fn.create({'bind':this,'event':true});this.$events[type].values.push(fn);return(Element.NativeEvents.contains(realType))?this.addListener(realType,fn):this;},removeEvent:function(type,fn){if(!this.$events||!this.$events[type])return this;var pos=this.$events[type].keys.indexOf(fn);if(pos==-1)return this;var key=this.$events[type].keys.splice(pos,1)[0];var value=this.$events[type].values.splice(pos,1)[0];var custom=Element.Events[type];if(custom){if(custom.remove)custom.remove.call(this,fn);if(custom.type)type=custom.type;}
return(Element.NativeEvents.contains(type))?this.removeListener(type,value):this;},addEvents:function(source){return Element.setMany(this,'addEvent',source);},removeEvents:function(type){if(!this.$events)return this;if(!type){for(var evType in this.$events)this.removeEvents(evType);this.$events=null;}else if(this.$events[type]){this.$events[type].keys.each(function(fn){this.removeEvent(type,fn);},this);this.$events[type]=null;}
return this;},fireEvent:function(type,args,delay){if(this.$events&&this.$events[type]){this.$events[type].keys.each(function(fn){fn.create({'bind':this,'delay':delay,'arguments':args})();},this);}
return this;},cloneEvents:function(from,type){if(!from.$events)return this;if(!type){for(var evType in from.$events)this.cloneEvents(from,evType);}else if(from.$events[type]){from.$events[type].keys.each(function(fn){this.addEvent(type,fn);},this);}
return this;}};window.extend(Element.Methods.Events);document.extend(Element.Methods.Events);Element.extend(Element.Methods.Events);Element.Events=new Abstract({'mouseenter':{type:'mouseover',map:function(event){event=new Event(event);if(event.relatedTarget!=this&&!this.hasChild(event.relatedTarget))this.fireEvent('mouseenter',event);}},'mouseleave':{type:'mouseout',map:function(event){event=new Event(event);if(event.relatedTarget!=this&&!this.hasChild(event.relatedTarget))this.fireEvent('mouseleave',event);}},'mousewheel':{type:(window.gecko)?'DOMMouseScroll':'mousewheel'}});Element.NativeEvents=['click','dblclick','mouseup','mousedown','mousewheel','DOMMouseScroll','mouseover','mouseout','mousemove','keydown','keypress','keyup','load','unload','beforeunload','resize','move','focus','blur','change','submit','reset','select','error','abort','contextmenu','scroll'];Function.extend({bindWithEvent:function(bind,args){return this.create({'bind':bind,'arguments':args,'event':Event});}});Elements.extend({filterByTag:function(tag){return new Elements(this.filter(function(el){return(Element.getTag(el)==tag);}));},filterByClass:function(className,nocash){var elements=this.filter(function(el){return(el.className&&el.className.contains(className,' '));});return(nocash)?elements:new Elements(elements);},filterById:function(id,nocash){var elements=this.filter(function(el){return(el.id==id);});return(nocash)?elements:new Elements(elements);},filterByAttribute:function(name,operator,value,nocash){var elements=this.filter(function(el){var current=Element.getProperty(el,name);if(!current)return false;if(!operator)return true;switch(operator){case'=':return(current==value);case'*=':return(current.contains(value));case'^=':return(current.substr(0,value.length)==value);case'$=':return(current.substr(current.length-value.length)==value);case'!=':return(current!=value);case'~=':return current.contains(value,' ');}
return false;});return(nocash)?elements:new Elements(elements);}});function $E(selector,filter){return($(filter)||document).getElement(selector);};function $ES(selector,filter){return($(filter)||document).getElementsBySelector(selector);};$$.shared={'regexp':/^(\w*|\*)(?:#([\w-]+)|\.([\w-]+))?(?:\[(\w+)(?:([!*^$]?=)["']?([^"'\]]*)["']?)?])?$/,'xpath':{getParam:function(items,context,param,i){var temp=[context.namespaceURI?'xhtml:':'',param[1]];if(param[2])temp.push('[@id="',param[2],'"]');if(param[3])temp.push('[contains(concat(" ", @class, " "), " ',param[3],' ")]');if(param[4]){if(param[5]&&param[6]){switch(param[5]){case'*=':temp.push('[contains(@',param[4],', "',param[6],'")]');break;case'^=':temp.push('[starts-with(@',param[4],', "',param[6],'")]');break;case'$=':temp.push('[substring(@',param[4],', string-length(@',param[4],') - ',param[6].length,' + 1) = "',param[6],'"]');break;case'=':temp.push('[@',param[4],'="',param[6],'"]');break;case'!=':temp.push('[@',param[4],'!="',param[6],'"]');}}else{temp.push('[@',param[4],']');}}
items.push(temp.join(''));return items;},getItems:function(items,context,nocash){var elements=[];var xpath=document.evaluate('.//'+items.join('//'),context,$$.shared.resolver,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for(var i=0,j=xpath.snapshotLength;i<j;i++)elements.push(xpath.snapshotItem(i));return(nocash)?elements:new Elements(elements.map($));}},'normal':{getParam:function(items,context,param,i){if(i==0){if(param[2]){var el=context.getElementById(param[2]);if(!el||((param[1]!='*')&&(Element.getTag(el)!=param[1])))return false;items=[el];}else{items=$A(context.getElementsByTagName(param[1]));}}else{items=$$.shared.getElementsByTagName(items,param[1]);if(param[2])items=Elements.filterById(items,param[2],true);}
if(param[3])items=Elements.filterByClass(items,param[3],true);if(param[4])items=Elements.filterByAttribute(items,param[4],param[5],param[6],true);return items;},getItems:function(items,context,nocash){return(nocash)?items:$$.unique(items);}},resolver:function(prefix){return(prefix=='xhtml')?'http://www.w3.org/1999/xhtml':false;},getElementsByTagName:function(context,tagName){var found=[];for(var i=0,j=context.length;i<j;i++)found.extend(context[i].getElementsByTagName(tagName));return found;}};$$.shared.method=(window.xpath)?'xpath':'normal';Element.Methods.Dom={getElements:function(selector,nocash){var items=[];selector=selector.trim().split(' ');for(var i=0,j=selector.length;i<j;i++){var sel=selector[i];var param=sel.match($$.shared.regexp);if(!param)break;param[1]=param[1]||'*';var temp=$$.shared[$$.shared.method].getParam(items,this,param,i);if(!temp)break;items=temp;}
return $$.shared[$$.shared.method].getItems(items,this,nocash);},getElement:function(selector){return $(this.getElements(selector,true)[0]||false);},getElementsBySelector:function(selector,nocash){var elements=[];selector=selector.split(',');for(var i=0,j=selector.length;i<j;i++)elements=elements.concat(this.getElements(selector[i],true));return(nocash)?elements:$$.unique(elements);}};Element.extend({getElementById:function(id){var el=document.getElementById(id);if(!el)return false;for(var parent=el.parentNode;parent!=this;parent=parent.parentNode){if(!parent)return false;}
return el;},getElementsByClassName:function(className){return this.getElements('.'+className);}});document.extend(Element.Methods.Dom);Element.extend(Element.Methods.Dom);Element.extend({getValue:function(){switch(this.getTag()){case'select':var values=[];$each(this.options,function(option){if(option.selected)values.push($pick(option.value,option.text));});return(this.multiple)?values:values[0];case'input':if(!(this.checked&&['checkbox','radio'].contains(this.type))&&!['hidden','text','password'].contains(this.type))break;case'textarea':return this.value;}
return false;},getFormElements:function(){return $$(this.getElementsByTagName('input'),this.getElementsByTagName('select'),this.getElementsByTagName('textarea'));},toQueryString:function(){var queryString=[];this.getFormElements().each(function(el){var name=el.name;var value=el.getValue();if(value===false||!name||el.disabled)return;var qs=function(val){queryString.push(name+'='+encodeURIComponent(val));};if($type(value)=='array')value.each(qs);else qs(value);});return queryString.join('&');}});Element.extend({scrollTo:function(x,y){this.scrollLeft=x;this.scrollTop=y;},getSize:function(){return{'scroll':{'x':this.scrollLeft,'y':this.scrollTop},'size':{'x':this.offsetWidth,'y':this.offsetHeight},'scrollSize':{'x':this.scrollWidth,'y':this.scrollHeight}};},getPosition:function(overflown){overflown=overflown||[];var el=this,left=0,top=0;do{left+=el.offsetLeft||0;top+=el.offsetTop||0;el=el.offsetParent;}while(el);overflown.each(function(element){left-=element.scrollLeft||0;top-=element.scrollTop||0;});return{'x':left,'y':top};},getTop:function(overflown){return this.getPosition(overflown).y;},getLeft:function(overflown){return this.getPosition(overflown).x;},getCoordinates:function(overflown){var position=this.getPosition(overflown);var obj={'width':this.offsetWidth,'height':this.offsetHeight,'left':position.x,'top':position.y};obj.right=obj.left+obj.width;obj.bottom=obj.top+obj.height;return obj;}});Element.Events.domready={add:function(fn){if(window.loaded){fn.call(this);return;}
var domReady=function(){if(window.loaded)return;window.loaded=true;window.timer=$clear(window.timer);this.fireEvent('domready');}.bind(this);if(document.readyState&&window.webkit){window.timer=function(){if(['loaded','complete'].contains(document.readyState))domReady();}.periodical(50);}else if(document.readyState&&window.ie){if(!$('ie_ready')){var src=(window.location.protocol=='https:')?'://0':'javascript:void(0)';document.write('<script id="ie_ready" defer src="'+src+'"><\/script>');$('ie_ready').onreadystatechange=function(){if(this.readyState=='complete')domReady();};}}else{window.addListener("load",domReady);document.addListener("DOMContentLoaded",domReady);}}};window.onDomReady=function(fn){return this.addEvent('domready',fn);};window.extend({getWidth:function(){if(this.webkit419)return this.innerWidth;if(this.opera)return document.body.clientWidth;return document.documentElement.clientWidth;},getHeight:function(){if(this.webkit419)return this.innerHeight;if(this.opera)return document.body.clientHeight;return document.documentElement.clientHeight;},getScrollWidth:function(){if(this.ie)return Math.max(document.documentElement.offsetWidth,document.documentElement.scrollWidth);if(this.webkit)return document.body.scrollWidth;return document.documentElement.scrollWidth;},getScrollHeight:function(){if(this.ie)return Math.max(document.documentElement.offsetHeight,document.documentElement.scrollHeight);if(this.webkit)return document.body.scrollHeight;return document.documentElement.scrollHeight;},getScrollLeft:function(){return this.pageXOffset||document.documentElement.scrollLeft;},getScrollTop:function(){return this.pageYOffset||document.documentElement.scrollTop;},getSize:function(){return{'size':{'x':this.getWidth(),'y':this.getHeight()},'scrollSize':{'x':this.getScrollWidth(),'y':this.getScrollHeight()},'scroll':{'x':this.getScrollLeft(),'y':this.getScrollTop()}};},getPosition:function(){return{'x':0,'y':0};}});var Fx={};Fx.Base=new Class({options:{onStart:Class.empty,onComplete:Class.empty,onCancel:Class.empty,transition:function(p){return-(Math.cos(Math.PI*p)-1)/2;},duration:500,unit:'px',wait:true,fps:50},initialize:function(options){this.element=this.element||null;this.setOptions(options);if(this.options.initialize)this.options.initialize.call(this);},step:function(){var time=$time();if(time<this.time+this.options.duration){this.delta=this.options.transition((time-this.time)/this.options.duration);this.setNow();this.increase();}else{this.stop(true);this.set(this.to);this.fireEvent('onComplete',this.element,10);this.callChain();}},set:function(to){this.now=to;this.increase();return this;},setNow:function(){this.now=this.compute(this.from,this.to);},compute:function(from,to){return(to-from)*this.delta+from;},start:function(from,to){if(!this.options.wait)this.stop();else if(this.timer)return this;this.from=from;this.to=to;this.change=this.to-this.from;this.time=$time();this.timer=this.step.periodical(Math.round(1000/this.options.fps),this);this.fireEvent('onStart',this.element);return this;},stop:function(end){if(!this.timer)return this;this.timer=$clear(this.timer);if(!end)this.fireEvent('onCancel',this.element);return this;},custom:function(from,to){return this.start(from,to);},clearTimer:function(end){return this.stop(end);}});Fx.Base.implement(new Chain,new Events,new Options);Fx.CSS={select:function(property,to){if(property.test(/color/i))return this.Color;var type=$type(to);if((type=='array')||(type=='string'&&to.contains(' ')))return this.Multi;return this.Single;},parse:function(el,property,fromTo){if(!fromTo.push)fromTo=[fromTo];var from=fromTo[0],to=fromTo[1];if(!$chk(to)){to=from;from=el.getStyle(property);}
var css=this.select(property,to);return{'from':css.parse(from),'to':css.parse(to),'css':css};}};Fx.CSS.Single={parse:function(value){return parseFloat(value);},getNow:function(from,to,fx){return fx.compute(from,to);},getValue:function(value,unit,property){if(unit=='px'&&property!='opacity')value=Math.round(value);return value+unit;}};Fx.CSS.Multi={parse:function(value){return value.push?value:value.split(' ').map(function(v){return parseFloat(v);});},getNow:function(from,to,fx){var now=[];for(var i=0;i<from.length;i++)now[i]=fx.compute(from[i],to[i]);return now;},getValue:function(value,unit,property){if(unit=='px'&&property!='opacity')value=value.map(Math.round);return value.join(unit+' ')+unit;}};Fx.CSS.Color={parse:function(value){return value.push?value:value.hexToRgb(true);},getNow:function(from,to,fx){var now=[];for(var i=0;i<from.length;i++)now[i]=Math.round(fx.compute(from[i],to[i]));return now;},getValue:function(value){return'rgb('+value.join(',')+')';}};Fx.Style=Fx.Base.extend({initialize:function(el,property,options){this.element=$(el);this.property=property;this.parent(options);},hide:function(){return this.set(0);},setNow:function(){this.now=this.css.getNow(this.from,this.to,this);},set:function(to){this.css=Fx.CSS.select(this.property,to);return this.parent(this.css.parse(to));},start:function(from,to){if(this.timer&&this.options.wait)return this;var parsed=Fx.CSS.parse(this.element,this.property,[from,to]);this.css=parsed.css;return this.parent(parsed.from,parsed.to);},increase:function(){this.element.setStyle(this.property,this.css.getValue(this.now,this.options.unit,this.property));}});Element.extend({effect:function(property,options){return new Fx.Style(this,property,options);}});Fx.Styles=Fx.Base.extend({initialize:function(el,options){this.element=$(el);this.parent(options);},setNow:function(){for(var p in this.from)this.now[p]=this.css[p].getNow(this.from[p],this.to[p],this);},set:function(to){var parsed={};this.css={};for(var p in to){this.css[p]=Fx.CSS.select(p,to[p]);parsed[p]=this.css[p].parse(to[p]);}
return this.parent(parsed);},start:function(obj){if(this.timer&&this.options.wait)return this;this.now={};this.css={};var from={},to={};for(var p in obj){var parsed=Fx.CSS.parse(this.element,p,obj[p]);from[p]=parsed.from;to[p]=parsed.to;this.css[p]=parsed.css;}
return this.parent(from,to);},increase:function(){for(var p in this.now)this.element.setStyle(p,this.css[p].getValue(this.now[p],this.options.unit,p));}});Element.extend({effects:function(options){return new Fx.Styles(this,options);}});Fx.Elements=Fx.Base.extend({initialize:function(elements,options){this.elements=$$(elements);this.parent(options);},setNow:function(){for(var i in this.from){var iFrom=this.from[i],iTo=this.to[i],iCss=this.css[i],iNow=this.now[i]={};for(var p in iFrom)iNow[p]=iCss[p].getNow(iFrom[p],iTo[p],this);}},set:function(to){var parsed={};this.css={};for(var i in to){var iTo=to[i],iCss=this.css[i]={},iParsed=parsed[i]={};for(var p in iTo){iCss[p]=Fx.CSS.select(p,iTo[p]);iParsed[p]=iCss[p].parse(iTo[p]);}}
return this.parent(parsed);},start:function(obj){if(this.timer&&this.options.wait)return this;this.now={};this.css={};var from={},to={};for(var i in obj){var iProps=obj[i],iFrom=from[i]={},iTo=to[i]={},iCss=this.css[i]={};for(var p in iProps){var parsed=Fx.CSS.parse(this.elements[i],p,iProps[p]);iFrom[p]=parsed.from;iTo[p]=parsed.to;iCss[p]=parsed.css;}}
return this.parent(from,to);},increase:function(){for(var i in this.now){var iNow=this.now[i],iCss=this.css[i];for(var p in iNow)this.elements[i].setStyle(p,iCss[p].getValue(iNow[p],this.options.unit,p));}}});Fx.Scroll=Fx.Base.extend({options:{overflown:[],offset:{'x':0,'y':0},wheelStops:true},initialize:function(element,options){this.now=[];this.element=$(element);this.bound={'stop':this.stop.bind(this,false)};this.parent(options);if(this.options.wheelStops){this.addEvent('onStart',function(){document.addEvent('mousewheel',this.bound.stop);}.bind(this));this.addEvent('onComplete',function(){document.removeEvent('mousewheel',this.bound.stop);}.bind(this));}},setNow:function(){for(var i=0;i<2;i++)this.now[i]=this.compute(this.from[i],this.to[i]);},scrollTo:function(x,y){if(this.timer&&this.options.wait)return this;var el=this.element.getSize();var values={'x':x,'y':y};for(var z in el.size){var max=el.scrollSize[z]-el.size[z];if($chk(values[z]))values[z]=($type(values[z])=='number')?values[z].limit(0,max):max;else values[z]=el.scroll[z];values[z]+=this.options.offset[z];}
return this.start([el.scroll.x,el.scroll.y],[values.x,values.y]);},toTop:function(){return this.scrollTo(false,0);},toBottom:function(){return this.scrollTo(false,'full');},toLeft:function(){return this.scrollTo(0,false);},toRight:function(){return this.scrollTo('full',false);},toElement:function(el){var parent=this.element.getPosition(this.options.overflown);var target=$(el).getPosition(this.options.overflown);return this.scrollTo(target.x-parent.x,target.y-parent.y);},increase:function(){this.element.scrollTo(this.now[0],this.now[1]);}});Fx.Slide=Fx.Base.extend({options:{mode:'vertical'},initialize:function(el,options){this.element=$(el);this.wrapper=new Element('div',{'styles':$extend(this.element.getStyles('margin'),{'overflow':'hidden'})}).injectAfter(this.element).adopt(this.element);this.element.setStyle('margin',0);this.setOptions(options);this.now=[];this.parent(this.options);this.open=true;this.addEvent('onComplete',function(){this.open=(this.now[0]===0);});if(window.webkit419)this.addEvent('onComplete',function(){if(this.open)this.element.remove().inject(this.wrapper);});},setNow:function(){for(var i=0;i<2;i++)this.now[i]=this.compute(this.from[i],this.to[i]);},vertical:function(){this.margin='margin-top';this.layout='height';this.offset=this.element.offsetHeight;},horizontal:function(){this.margin='margin-left';this.layout='width';this.offset=this.element.offsetWidth;},slideIn:function(mode){this[mode||this.options.mode]();return this.start([this.element.getStyle(this.margin).toInt(),this.wrapper.getStyle(this.layout).toInt()],[0,this.offset]);},slideOut:function(mode){this[mode||this.options.mode]();return this.start([this.element.getStyle(this.margin).toInt(),this.wrapper.getStyle(this.layout).toInt()],[-this.offset,0]);},hide:function(mode){this[mode||this.options.mode]();this.open=false;return this.set([-this.offset,0]);},show:function(mode){this[mode||this.options.mode]();this.open=true;return this.set([0,this.offset]);},toggle:function(mode){if(this.wrapper.offsetHeight==0||this.wrapper.offsetWidth==0)return this.slideIn(mode);return this.slideOut(mode);},increase:function(){this.element.setStyle(this.margin,this.now[0]+this.options.unit);this.wrapper.setStyle(this.layout,this.now[1]+this.options.unit);}});Fx.Transition=function(transition,params){params=params||[];if($type(params)!='array')params=[params];return $extend(transition,{easeIn:function(pos){return transition(pos,params);},easeOut:function(pos){return 1-transition(1-pos,params);},easeInOut:function(pos){return(pos<=0.5)?transition(2*pos,params)/2:(2-transition(2*(1-pos),params))/2;}});};Fx.Transitions=new Abstract({linear:function(p){return p;}});Fx.Transitions.extend=function(transitions){for(var transition in transitions){Fx.Transitions[transition]=new Fx.Transition(transitions[transition]);Fx.Transitions.compat(transition);}};Fx.Transitions.compat=function(transition){['In','Out','InOut'].each(function(easeType){Fx.Transitions[transition.toLowerCase()+easeType]=Fx.Transitions[transition]['ease'+easeType];});};Fx.Transitions.extend({Pow:function(p,x){return Math.pow(p,x[0]||6);},Expo:function(p){return Math.pow(2,8*(p-1));},Circ:function(p){return 1-Math.sin(Math.acos(p));},Sine:function(p){return 1-Math.sin((1-p)*Math.PI/2);},Back:function(p,x){x=x[0]||1.618;return Math.pow(p,2)*((x+1)*p-x);},Bounce:function(p){var value;for(var a=0,b=1;1;a+=b,b/=2){if(p>=(7-4*a)/11){value=-Math.pow((11-6*a-11*p)/4,2)+b*b;break;}}
return value;},Elastic:function(p,x){return Math.pow(2,10*--p)*Math.cos(20*p*Math.PI*(x[0]||1)/3);}});['Quad','Cubic','Quart','Quint'].each(function(transition,i){Fx.Transitions[transition]=new Fx.Transition(function(p){return Math.pow(p,[i+2]);});Fx.Transitions.compat(transition);});var Drag={};Drag.Base=new Class({options:{handle:false,unit:'px',onStart:Class.empty,onBeforeStart:Class.empty,onComplete:Class.empty,onSnap:Class.empty,onDrag:Class.empty,limit:false,modifiers:{x:'left',y:'top'},grid:false,snap:6},initialize:function(el,options){this.setOptions(options);this.element=$(el);this.handle=$(this.options.handle)||this.element;this.mouse={'now':{},'pos':{}};this.value={'start':{},'now':{}};this.bound={'start':this.start.bindWithEvent(this),'check':this.check.bindWithEvent(this),'drag':this.drag.bindWithEvent(this),'stop':this.stop.bind(this)};this.attach();if(this.options.initialize)this.options.initialize.call(this);},attach:function(){this.handle.addEvent('mousedown',this.bound.start);return this;},detach:function(){this.handle.removeEvent('mousedown',this.bound.start);return this;},start:function(event){this.fireEvent('onBeforeStart',this.element);this.mouse.start=event.page;var limit=this.options.limit;this.limit={'x':[],'y':[]};for(var z in this.options.modifiers){if(!this.options.modifiers[z])continue;this.value.now[z]=this.element.getStyle(this.options.modifiers[z]).toInt();this.mouse.pos[z]=event.page[z]-this.value.now[z];if(limit&&limit[z]){for(var i=0;i<2;i++){if($chk(limit[z][i]))this.limit[z][i]=($type(limit[z][i])=='function')?limit[z][i]():limit[z][i];}}}
if($type(this.options.grid)=='number')this.options.grid={'x':this.options.grid,'y':this.options.grid};document.addListener('mousemove',this.bound.check);document.addListener('mouseup',this.bound.stop);this.fireEvent('onStart',this.element);event.stop();},check:function(event){var distance=Math.round(Math.sqrt(Math.pow(event.page.x-this.mouse.start.x,2)+Math.pow(event.page.y-this.mouse.start.y,2)));if(distance>this.options.snap){document.removeListener('mousemove',this.bound.check);document.addListener('mousemove',this.bound.drag);this.drag(event);this.fireEvent('onSnap',this.element);}
event.stop();},drag:function(event){this.out=false;this.mouse.now=event.page;for(var z in this.options.modifiers){if(!this.options.modifiers[z])continue;this.value.now[z]=this.mouse.now[z]-this.mouse.pos[z];if(this.limit[z]){if($chk(this.limit[z][1])&&(this.value.now[z]>this.limit[z][1])){this.value.now[z]=this.limit[z][1];this.out=true;}else if($chk(this.limit[z][0])&&(this.value.now[z]<this.limit[z][0])){this.value.now[z]=this.limit[z][0];this.out=true;}}
if(this.options.grid[z])this.value.now[z]-=(this.value.now[z]%this.options.grid[z]);this.element.setStyle(this.options.modifiers[z],this.value.now[z]+this.options.unit);}
this.fireEvent('onDrag',this.element);event.stop();},stop:function(){document.removeListener('mousemove',this.bound.check);document.removeListener('mousemove',this.bound.drag);document.removeListener('mouseup',this.bound.stop);this.fireEvent('onComplete',this.element);}});Drag.Base.implement(new Events,new Options);Element.extend({makeResizable:function(options){return new Drag.Base(this,$merge({modifiers:{x:'width',y:'height'}},options));}});Drag.Move=Drag.Base.extend({options:{droppables:[],container:false,overflown:[]},initialize:function(el,options){this.setOptions(options);this.element=$(el);this.droppables=$$(this.options.droppables);this.container=$(this.options.container);this.position={'element':this.element.getStyle('position'),'container':false};if(this.container)this.position.container=this.container.getStyle('position');if(!['relative','absolute','fixed'].contains(this.position.element))this.position.element='absolute';var top=this.element.getStyle('top').toInt();var left=this.element.getStyle('left').toInt();if(this.position.element=='absolute'&&!['relative','absolute','fixed'].contains(this.position.container)){top=$chk(top)?top:this.element.getTop(this.options.overflown);left=$chk(left)?left:this.element.getLeft(this.options.overflown);}else{top=$chk(top)?top:0;left=$chk(left)?left:0;}
this.element.setStyles({'top':top,'left':left,'position':this.position.element});this.parent(this.element);},start:function(event){this.overed=null;if(this.container){var cont=this.container.getCoordinates();var el=this.element.getCoordinates();if(this.position.element=='absolute'&&!['relative','absolute','fixed'].contains(this.position.container)){this.options.limit={'x':[cont.left,cont.right-el.width],'y':[cont.top,cont.bottom-el.height]};}else{this.options.limit={'y':[0,cont.height-el.height],'x':[0,cont.width-el.width]};}}
this.parent(event);},drag:function(event){this.parent(event);var overed=this.out?false:this.droppables.filter(this.checkAgainst,this).getLast();if(this.overed!=overed){if(this.overed)this.overed.fireEvent('leave',[this.element,this]);this.overed=overed?overed.fireEvent('over',[this.element,this]):null;}
return this;},checkAgainst:function(el){el=el.getCoordinates(this.options.overflown);var now=this.mouse.now;return(now.x>el.left&&now.x<el.right&&now.y<el.bottom&&now.y>el.top);},stop:function(){if(this.overed&&!this.out)this.overed.fireEvent('drop',[this.element,this]);else this.element.fireEvent('emptydrop',this);this.parent();return this;}});Element.extend({makeDraggable:function(options){return new Drag.Move(this,options);}});var XHR=new Class({options:{method:'post',async:true,onRequest:Class.empty,onSuccess:Class.empty,onFailure:Class.empty,urlEncoded:true,encoding:'utf-8',autoCancel:false,headers:{}},setTransport:function(){this.transport=(window.XMLHttpRequest)?new XMLHttpRequest():(window.ie?new ActiveXObject('Microsoft.XMLHTTP'):false);return this;},initialize:function(options){this.setTransport().setOptions(options);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers={};if(this.options.urlEncoded&&this.options.method=='post'){var encoding=(this.options.encoding)?'; charset='+this.options.encoding:'';this.setHeader('Content-type','application/x-www-form-urlencoded'+encoding);}
if(this.options.initialize)this.options.initialize.call(this);},onStateChange:function(){if(this.transport.readyState!=4||!this.running)return;this.running=false;var status=0;try{status=this.transport.status;}catch(e){};if(this.options.isSuccess.call(this,status))this.onSuccess();else this.onFailure();this.transport.onreadystatechange=Class.empty;},isSuccess:function(status){return((status>=200)&&(status<300));},onSuccess:function(){this.response={'text':this.transport.responseText,'xml':this.transport.responseXML};this.fireEvent('onSuccess',[this.response.text,this.response.xml]);this.callChain();},onFailure:function(){this.fireEvent('onFailure',this.transport);},setHeader:function(name,value){this.headers[name]=value;return this;},send:function(url,data){if(this.options.autoCancel)this.cancel();else if(this.running)return this;this.running=true;if(data&&this.options.method=='get'){url=url+(url.contains('?')?'&':'?')+data;data=null;}
this.transport.open(this.options.method.toUpperCase(),url,this.options.async);this.transport.onreadystatechange=this.onStateChange.bind(this);if((this.options.method=='post')&&this.transport.overrideMimeType)this.setHeader('Connection','close');$extend(this.headers,this.options.headers);for(var type in this.headers)try{this.transport.setRequestHeader(type,this.headers[type]);}catch(e){};this.fireEvent('onRequest');this.transport.send($pick(data,null));return this;},cancel:function(){if(!this.running)return this;this.running=false;this.transport.abort();this.transport.onreadystatechange=Class.empty;this.setTransport();this.fireEvent('onCancel');return this;}});XHR.implement(new Chain,new Events,new Options);var Ajax=XHR.extend({options:{data:null,update:null,onComplete:Class.empty,evalScripts:false,evalResponse:false},initialize:function(url,options){this.addEvent('onSuccess',this.onComplete);this.setOptions(options);this.options.data=this.options.data||this.options.postBody;if(!['post','get'].contains(this.options.method)){this._method='_method='+this.options.method;this.options.method='post';}
this.parent();this.setHeader('X-Requested-With','XMLHttpRequest');this.setHeader('Accept','text/javascript, text/html, application/xml, text/xml, */*');this.url=url;},onComplete:function(){if(this.options.update)$(this.options.update).empty().setHTML(this.response.text);if(this.options.evalScripts||this.options.evalResponse)this.evalScripts();this.fireEvent('onComplete',[this.response.text,this.response.xml],20);},request:function(data){data=data||this.options.data;switch($type(data)){case'element':data=$(data).toQueryString();break;case'object':data=Object.toQueryString(data);}
if(this._method)data=(data)?[this._method,data].join('&'):this._method;return this.send(this.url,data);},evalScripts:function(){var script,scripts;if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader('Content-type')))scripts=this.response.text;else{scripts=[];var regexp=/<script[^>]*>([\s\S]*?)<\/script>/gi;while((script=regexp.exec(this.response.text)))scripts.push(script[1]);scripts=scripts.join('\n');}
if(scripts)(window.execScript)?window.execScript(scripts):window.setTimeout(scripts,0);},getHeader:function(name){try{return this.transport.getResponseHeader(name);}catch(e){};return null;}});Object.toQueryString=function(source){var queryString=[];for(var property in source)queryString.push(encodeURIComponent(property)+'='+encodeURIComponent(source[property]));return queryString.join('&');};Element.extend({send:function(options){return new Ajax(this.getProperty('action'),$merge({data:this.toQueryString()},options,{method:'post'})).request();}});var Cookie=new Abstract({options:{domain:false,path:false,duration:false,secure:false},set:function(key,value,options){options=$merge(this.options,options);value=encodeURIComponent(value);if(options.domain)value+='; domain='+options.domain;if(options.path)value+='; path='+options.path;if(options.duration){var date=new Date();date.setTime(date.getTime()+options.duration*24*60*60*1000);value+='; expires='+date.toGMTString();}
if(options.secure)value+='; secure';document.cookie=key+'='+value;return $extend(options,{'key':key,'value':value});},get:function(key){var value=document.cookie.match('(?:^|;)\\s*'+key.escapeRegExp()+'=([^;]*)');return value?decodeURIComponent(value[1]):false;},remove:function(cookie,options){if($type(cookie)=='object')this.set(cookie.key,'',$merge(cookie,{duration:-1}));else this.set(cookie,'',$merge(options,{duration:-1}));}});var Json={toString:function(obj){switch($type(obj)){case'string':return'"'+obj.replace(/(["\\])/g,'\\$1')+'"';case'array':return'['+obj.map(Json.toString).join(',')+']';case'object':var string=[];for(var property in obj)string.push(Json.toString(property)+':'+Json.toString(obj[property]));return'{'+string.join(',')+'}';case'number':if(isFinite(obj))break;case false:return'null';}
return String(obj);},evaluate:function(str,secure){return(($type(str)!='string')||(secure&&!str.test(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/)))?null:eval('('+str+')');}};Json.Remote=XHR.extend({initialize:function(url,options){this.url=url;this.addEvent('onSuccess',this.onComplete);this.parent(options);this.setHeader('X-Request','JSON');},send:function(obj){return this.parent(this.url,'json='+Json.toString(obj));},onComplete:function(){this.fireEvent('onComplete',[Json.evaluate(this.response.text,this.options.secure)]);}});var Asset=new Abstract({javascript:function(source,properties){properties=$merge({'onload':Class.empty},properties);var script=new Element('script',{'src':source}).addEvents({'load':properties.onload,'readystatechange':function(){if(this.readyState=='complete')this.fireEvent('load');}});delete properties.onload;return script.setProperties(properties).inject(document.head);},css:function(source,properties){return new Element('link',$merge({'rel':'stylesheet','media':'screen','type':'text/css','href':source},properties)).inject(document.head);},image:function(source,properties){properties=$merge({'onload':Class.empty,'onabort':Class.empty,'onerror':Class.empty},properties);var image=new Image();image.src=source;var element=new Element('img',{'src':source});['load','abort','error'].each(function(type){var event=properties['on'+type];delete properties['on'+type];element.addEvent(type,function(){this.removeEvent(type,arguments.callee);event.call(this);});});if(image.width&&image.height)element.fireEvent('load',element,1);return element.setProperties(properties);},images:function(sources,options){options=$merge({onComplete:Class.empty,onProgress:Class.empty},options);if(!sources.push)sources=[sources];var images=[];var counter=0;sources.each(function(source){var img=new Asset.image(source,{'onload':function(){options.onProgress.call(this,counter);counter++;if(counter==sources.length)options.onComplete();}});images.push(img);});return new Elements(images);}});var Hash=new Class({length:0,initialize:function(object){this.obj=object||{};this.setLength();},get:function(key){return(this.hasKey(key))?this.obj[key]:null;},hasKey:function(key){return(key in this.obj);},set:function(key,value){if(!this.hasKey(key))this.length++;this.obj[key]=value;return this;},setLength:function(){this.length=0;for(var p in this.obj)this.length++;return this;},remove:function(key){if(this.hasKey(key)){delete this.obj[key];this.length--;}
return this;},each:function(fn,bind){$each(this.obj,fn,bind);},extend:function(obj){$extend(this.obj,obj);return this.setLength();},merge:function(){this.obj=$merge.apply(null,[this.obj].extend(arguments));return this.setLength();},empty:function(){this.obj={};this.length=0;return this;},keys:function(){var keys=[];for(var property in this.obj)keys.push(property);return keys;},values:function(){var values=[];for(var property in this.obj)values.push(this.obj[property]);return values;}});function $H(obj){return new Hash(obj);};Hash.Cookie=Hash.extend({initialize:function(name,options){this.name=name;this.options=$extend({'autoSave':true},options||{});this.load();},save:function(){if(this.length==0){Cookie.remove(this.name,this.options);return true;}
var str=Json.toString(this.obj);if(str.length>4096)return false;Cookie.set(this.name,str,this.options);return true;},load:function(){this.obj=Json.evaluate(Cookie.get(this.name),true)||{};this.setLength();}});Hash.Cookie.Methods={};['extend','set','merge','empty','remove'].each(function(method){Hash.Cookie.Methods[method]=function(){Hash.prototype[method].apply(this,arguments);if(this.options.autoSave)this.save();return this;};});Hash.Cookie.implement(Hash.Cookie.Methods);var Color=new Class({initialize:function(color,type){type=type||(color.push?'rgb':'hex');var rgb,hsb;switch(type){case'rgb':rgb=color;hsb=rgb.rgbToHsb();break;case'hsb':rgb=color.hsbToRgb();hsb=color;break;default:rgb=color.hexToRgb(true);hsb=rgb.rgbToHsb();}
rgb.hsb=hsb;rgb.hex=rgb.rgbToHex();return $extend(rgb,Color.prototype);},mix:function(){var colors=$A(arguments);var alpha=($type(colors[colors.length-1])=='number')?colors.pop():50;var rgb=this.copy();colors.each(function(color){color=new Color(color);for(var i=0;i<3;i++)rgb[i]=Math.round((rgb[i]/100*(100-alpha))+(color[i]/100*alpha));});return new Color(rgb,'rgb');},invert:function(){return new Color(this.map(function(value){return 255-value;}));},setHue:function(value){return new Color([value,this.hsb[1],this.hsb[2]],'hsb');},setSaturation:function(percent){return new Color([this.hsb[0],percent,this.hsb[2]],'hsb');},setBrightness:function(percent){return new Color([this.hsb[0],this.hsb[1],percent],'hsb');}});function $RGB(r,g,b){return new Color([r,g,b],'rgb');};function $HSB(h,s,b){return new Color([h,s,b],'hsb');};Array.extend({rgbToHsb:function(){var red=this[0],green=this[1],blue=this[2];var hue,saturation,brightness;var max=Math.max(red,green,blue),min=Math.min(red,green,blue);var delta=max-min;brightness=max/255;saturation=(max!=0)?delta/max:0;if(saturation==0){hue=0;}else{var rr=(max-red)/delta;var gr=(max-green)/delta;var br=(max-blue)/delta;if(red==max)hue=br-gr;else if(green==max)hue=2+rr-br;else hue=4+gr-rr;hue/=6;if(hue<0)hue++;}
return[Math.round(hue*360),Math.round(saturation*100),Math.round(brightness*100)];},hsbToRgb:function(){var br=Math.round(this[2]/100*255);if(this[1]==0){return[br,br,br];}else{var hue=this[0]%360;var f=hue%60;var p=Math.round((this[2]*(100-this[1]))/10000*255);var q=Math.round((this[2]*(6000-this[1]*f))/600000*255);var t=Math.round((this[2]*(6000-this[1]*(60-f)))/600000*255);switch(Math.floor(hue/60)){case 0:return[br,t,p];case 1:return[q,br,p];case 2:return[p,br,t];case 3:return[p,q,br];case 4:return[t,p,br];case 5:return[br,p,q];}}
return false;}});var Scroller=new Class({options:{area:20,velocity:1,onChange:function(x,y){this.element.scrollTo(x,y);}},initialize:function(element,options){this.setOptions(options);this.element=$(element);this.mousemover=([window,document].contains(element))?$(document.body):this.element;},start:function(){this.coord=this.getCoords.bindWithEvent(this);this.mousemover.addListener('mousemove',this.coord);},stop:function(){this.mousemover.removeListener('mousemove',this.coord);this.timer=$clear(this.timer);},getCoords:function(event){this.page=(this.element==window)?event.client:event.page;if(!this.timer)this.timer=this.scroll.periodical(50,this);},scroll:function(){var el=this.element.getSize();var pos=this.element.getPosition();var change={'x':0,'y':0};for(var z in this.page){if(this.page[z]<(this.options.area+pos[z])&&el.scroll[z]!=0)
change[z]=(this.page[z]-this.options.area-pos[z])*this.options.velocity;else if(this.page[z]+this.options.area>(el.size[z]+pos[z])&&el.scroll[z]+el.size[z]!=el.scrollSize[z])
change[z]=(this.page[z]-el.size[z]+this.options.area-pos[z])*this.options.velocity;}
if(change.y||change.x)this.fireEvent('onChange',[el.scroll.x+change.x,el.scroll.y+change.y]);}});Scroller.implement(new Events,new Options);var Slider=new Class({options:{onChange:Class.empty,onComplete:Class.empty,onTick:function(pos){this.knob.setStyle(this.p,pos);},mode:'horizontal',steps:100,offset:0},initialize:function(el,knob,options){this.element=$(el);this.knob=$(knob);this.setOptions(options);this.previousChange=-1;this.previousEnd=-1;this.step=-1;this.element.addEvent('mousedown',this.clickedElement.bindWithEvent(this));var mod,offset;switch(this.options.mode){case'horizontal':this.z='x';this.p='left';mod={'x':'left','y':false};offset='offsetWidth';break;case'vertical':this.z='y';this.p='top';mod={'x':false,'y':'top'};offset='offsetHeight';}
this.max=this.element[offset]-this.knob[offset]+(this.options.offset*2);this.half=this.knob[offset]/2;this.getPos=this.element['get'+this.p.capitalize()].bind(this.element);this.knob.setStyle('position','relative').setStyle(this.p,-this.options.offset);var lim={};lim[this.z]=[-this.options.offset,this.max-this.options.offset];this.drag=new Drag.Base(this.knob,{limit:lim,modifiers:mod,snap:0,onStart:function(){this.draggedKnob();}.bind(this),onDrag:function(){this.draggedKnob();}.bind(this),onComplete:function(){this.draggedKnob();this.end();}.bind(this)});if(this.options.initialize)this.options.initialize.call(this);},set:function(step){this.step=step.limit(0,this.options.steps);this.checkStep();this.end();this.fireEvent('onTick',this.toPosition(this.step));return this;},clickedElement:function(event){var position=event.page[this.z]-this.getPos()-this.half;position=position.limit(-this.options.offset,this.max-this.options.offset);this.step=this.toStep(position);this.checkStep();this.end();this.fireEvent('onTick',position);},draggedKnob:function(){this.step=this.toStep(this.drag.value.now[this.z]);this.checkStep();},checkStep:function(){if(this.previousChange!=this.step){this.previousChange=this.step;this.fireEvent('onChange',this.step);}},end:function(){if(this.previousEnd!==this.step){this.previousEnd=this.step;this.fireEvent('onComplete',this.step+'');}},toStep:function(position){return Math.round((position+this.options.offset)/this.max*this.options.steps);},toPosition:function(step){return this.max*step/this.options.steps;}});Slider.implement(new Events);Slider.implement(new Options);var SmoothScroll=Fx.Scroll.extend({initialize:function(options){this.parent(window,options);this.links=(this.options.links)?$$(this.options.links):$$(document.links);var location=window.location.href.match(/^[^#]*/)[0]+'#';this.links.each(function(link){if(link.href.indexOf(location)!=0)return;var anchor=link.href.substr(location.length);if(anchor&&$(anchor))this.useLink(link,anchor);},this);if(!window.webkit419)this.addEvent('onComplete',function(){window.location.hash=this.anchor;});},useLink:function(link,anchor){link.addEvent('click',function(event){this.anchor=anchor;this.toElement(anchor);event.stop();}.bindWithEvent(this));}});var Sortables=new Class({options:{handles:false,onStart:Class.empty,onComplete:Class.empty,ghost:true,snap:3,onDragStart:function(element,ghost){ghost.setStyle('opacity',0.7);element.setStyle('opacity',0.7);},onDragComplete:function(element,ghost){element.setStyle('opacity',1);ghost.remove();this.trash.remove();}},initialize:function(list,options){this.setOptions(options);this.list=$(list);this.elements=this.list.getChildren();this.handles=(this.options.handles)?$$(this.options.handles):this.elements;this.bound={'start':[],'moveGhost':this.moveGhost.bindWithEvent(this)};for(var i=0,l=this.handles.length;i<l;i++){this.bound.start[i]=this.start.bindWithEvent(this,this.elements[i]);}
this.attach();if(this.options.initialize)this.options.initialize.call(this);this.bound.move=this.move.bindWithEvent(this);this.bound.end=this.end.bind(this);},attach:function(){this.handles.each(function(handle,i){handle.addEvent('mousedown',this.bound.start[i]);},this);},detach:function(){this.handles.each(function(handle,i){handle.removeEvent('mousedown',this.bound.start[i]);},this);},start:function(event,el){this.active=el;this.coordinates=this.list.getCoordinates();if(this.options.ghost){var position=el.getPosition();this.offset=event.page.y-position.y;this.trash=new Element('div').inject(document.body);this.ghost=el.clone().inject(this.trash).setStyles({'position':'absolute','left':position.x,'top':event.page.y-this.offset});document.addListener('mousemove',this.bound.moveGhost);this.fireEvent('onDragStart',[el,this.ghost]);}
document.addListener('mousemove',this.bound.move);document.addListener('mouseup',this.bound.end);this.fireEvent('onStart',el);event.stop();},moveGhost:function(event){var value=event.page.y-this.offset;value=value.limit(this.coordinates.top,this.coordinates.bottom-this.ghost.offsetHeight);this.ghost.setStyle('top',value);event.stop();},move:function(event){var now=event.page.y;this.previous=this.previous||now;var up=((this.previous-now)>0);var prev=this.active.getPrevious();var next=this.active.getNext();if(prev&&up&&now<prev.getCoordinates().bottom)this.active.injectBefore(prev);if(next&&!up&&now>next.getCoordinates().top)this.active.injectAfter(next);this.previous=now;},serialize:function(converter){return this.list.getChildren().map(converter||function(el){return this.elements.indexOf(el);},this);},end:function(){this.previous=null;document.removeListener('mousemove',this.bound.move);document.removeListener('mouseup',this.bound.end);if(this.options.ghost){document.removeListener('mousemove',this.bound.moveGhost);this.fireEvent('onDragComplete',[this.active,this.ghost]);}
this.fireEvent('onComplete',this.active);}});Sortables.implement(new Events,new Options);var Tips=new Class({options:{onShow:function(tip){tip.setStyle('visibility','visible');},onHide:function(tip){tip.setStyle('visibility','hidden');},maxTitleChars:30,showDelay:100,hideDelay:100,className:'tool',offsets:{'x':16,'y':16},fixed:false},initialize:function(elements,options){this.setOptions(options);this.toolTip=new Element('div',{'class':this.options.className+'-tip','styles':{'position':'absolute','top':'0','left':'0','visibility':'hidden'}}).inject(document.body);this.wrapper=new Element('div').inject(this.toolTip);$$(elements).each(this.build,this);if(this.options.initialize)this.options.initialize.call(this);},build:function(el){el.$tmp.myTitle=(el.href&&el.getTag()=='a')?el.href.replace('http://',''):(el.rel||false);if(el.title){var dual=el.title.split('::');if(dual.length>1){el.$tmp.myTitle=dual[0].trim();el.$tmp.myText=dual[1].trim();}else{el.$tmp.myText=el.title;}
el.removeAttribute('title');}else{el.$tmp.myText=false;}
if(el.$tmp.myTitle&&el.$tmp.myTitle.length>this.options.maxTitleChars)el.$tmp.myTitle=el.$tmp.myTitle.substr(0,this.options.maxTitleChars-1)+"&hellip;";el.addEvent('mouseenter',function(event){this.start(el);if(!this.options.fixed)this.locate(event);else this.position(el);}.bind(this));if(!this.options.fixed)el.addEvent('mousemove',this.locate.bindWithEvent(this));var end=this.end.bind(this);el.addEvent('mouseleave',end);el.addEvent('trash',end);},start:function(el){this.wrapper.empty();if(el.$tmp.myTitle){this.title=new Element('span').inject(new Element('div',{'class':this.options.className+'-title'}).inject(this.wrapper)).setHTML(el.$tmp.myTitle);}
if(el.$tmp.myText){this.text=new Element('span').inject(new Element('div',{'class':this.options.className+'-text'}).inject(this.wrapper)).setHTML(el.$tmp.myText);}
$clear(this.timer);this.timer=this.show.delay(this.options.showDelay,this);},end:function(event){$clear(this.timer);this.timer=this.hide.delay(this.options.hideDelay,this);},position:function(element){var pos=element.getPosition();this.toolTip.setStyles({'left':pos.x+this.options.offsets.x,'top':pos.y+this.options.offsets.y});},locate:function(event){var win={'x':window.getWidth(),'y':window.getHeight()};var scroll={'x':window.getScrollLeft(),'y':window.getScrollTop()};var tip={'x':this.toolTip.offsetWidth,'y':this.toolTip.offsetHeight};var prop={'x':'left','y':'top'};for(var z in prop){var pos=event.page[z]+this.options.offsets[z];if((pos+tip[z]-scroll[z])>win[z])pos=event.page[z]-this.options.offsets[z]-tip[z];this.toolTip.setStyle(prop[z],pos);};},show:function(){if(this.options.timeout)this.timer=this.hide.delay(this.options.timeout,this);this.fireEvent('onShow',[this.toolTip]);},hide:function(){this.fireEvent('onHide',[this.toolTip]);}});Tips.implement(new Events,new Options);var Group=new Class({initialize:function(){this.instances=$A(arguments);this.events={};this.checker={};},addEvent:function(type,fn){this.checker[type]=this.checker[type]||{};this.events[type]=this.events[type]||[];if(this.events[type].contains(fn))return false;else this.events[type].push(fn);this.instances.each(function(instance,i){instance.addEvent(type,this.check.bind(this,[type,instance,i]));},this);return this;},check:function(type,instance,i){this.checker[type][i]=true;var every=this.instances.every(function(current,j){return this.checker[type][j]||false;},this);if(!every)return;this.checker[type]={};this.events[type].each(function(event){event.call(this,this.instances,instance);},this);}});var Accordion=Fx.Elements.extend({options:{onActive:Class.empty,onBackground:Class.empty,display:0,show:false,height:true,width:false,opacity:true,fixedHeight:false,fixedWidth:false,wait:false,alwaysHide:false},initialize:function(){var options,togglers,elements,container;$each(arguments,function(argument,i){switch($type(argument)){case'object':options=argument;break;case'element':container=$(argument);break;default:var temp=$$(argument);if(!togglers)togglers=temp;else elements=temp;}});this.togglers=togglers||[];this.elements=elements||[];this.container=$(container);this.setOptions(options);this.previous=-1;if(this.options.alwaysHide)this.options.wait=true;if($chk(this.options.show)){this.options.display=false;this.previous=this.options.show;}
if(this.options.start){this.options.display=false;this.options.show=false;}
this.effects={};if(this.options.opacity)this.effects.opacity='fullOpacity';if(this.options.width)this.effects.width=this.options.fixedWidth?'fullWidth':'offsetWidth';if(this.options.height)this.effects.height=this.options.fixedHeight?'fullHeight':'scrollHeight';for(var i=0,l=this.togglers.length;i<l;i++)this.addSection(this.togglers[i],this.elements[i]);this.elements.each(function(el,i){if(this.options.show===i){this.fireEvent('onActive',[this.togglers[i],el]);}else{for(var fx in this.effects)el.setStyle(fx,0);}},this);this.parent(this.elements);if($chk(this.options.display))this.display(this.options.display);},addSection:function(toggler,element,pos){toggler=$(toggler);element=$(element);var test=this.togglers.contains(toggler);var len=this.togglers.length;this.togglers.include(toggler);this.elements.include(element);if(len&&(!test||pos)){pos=$pick(pos,len-1);toggler.injectBefore(this.togglers[pos]);element.injectAfter(toggler);}else if(this.container&&!test){toggler.inject(this.container);element.inject(this.container);}
var idx=this.togglers.indexOf(toggler);toggler.addEvent('click',this.display.bind(this,idx));if(this.options.height)element.setStyles({'padding-top':0,'border-top':'none','padding-bottom':0,'border-bottom':'none'});if(this.options.width)element.setStyles({'padding-left':0,'border-left':'none','padding-right':0,'border-right':'none'});element.fullOpacity=1;if(this.options.fixedWidth)element.fullWidth=this.options.fixedWidth;if(this.options.fixedHeight)element.fullHeight=this.options.fixedHeight;element.setStyle('overflow','hidden');if(!test){for(var fx in this.effects)element.setStyle(fx,0);}
return this;},display:function(index){index=($type(index)=='element')?this.elements.indexOf(index):index;if((this.timer&&this.options.wait)||(index===this.previous&&!this.options.alwaysHide))return this;this.previous=index;var obj={};this.elements.each(function(el,i){obj[i]={};var hide=(i!=index)||(this.options.alwaysHide&&(el.offsetHeight>0));this.fireEvent(hide?'onBackground':'onActive',[this.togglers[i],el]);for(var fx in this.effects)obj[i][fx]=hide?0:el[this.effects[fx]];},this);return this.start(obj);},showThisHideOpen:function(index){return this.display(index);}});Fx.Accordion=Accordion;

/*** rokbox.js ***/

/**
 * RokBox System Plugin
 *
 * @package		Joomla
 * @subpackage	RokBox System Plugin
 * @copyright Copyright (C) 2009 RocketTheme. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see RT-LICENSE.php
 * @author RocketTheme, LLC
 *
 * RokBox System Plugin includes:
 * ------------
 * SWFObject v1.5: SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * -------------
 * JW Player: JW Player is (c) released under CC by-nc-sa 2.0:
 * http://creativecommons.org/licenses/by-nc-sa/2.0/
 * 
 */

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('V.4A({\'2B\':E(){L 8.1z(\'2b\',\'\')},\'1S\':E(){L 8.1z(\'2b\',\'3l\')}});8O.4A({\'8N\':E(){u a=/^(1U|4F):\\/\\/([a-z-.0-9]+)[\\/]{0,1}/i.4f(J.2I);u b=/^(1U|4F):\\/\\/([a-z-.0-9]+)[\\/]{0,1}/i.4f(8);L a[2]===b[2]}});u 3U=C 4H({2O:\'2.0\',A:{\'1C\':\'8u\',\'4I\':\'8s\',\'1B\':2i.4u.4r.8o,\'1D\':4l,\'49\':40,\'1t\':\'4L\',\'2r\':M,\'4N\':8g,\'3Y\':I,\'2F\':M,1y:{\'33\':\'#8a\',\'1d\':0.85,\'3z\':87,\'1D\':4l,\'1B\':2i.4u.4r.4T},\'52-53\':0,\'5d-2w\':0,\'1b-B\':50,2H:{\'D\':5h,\'B\':7U},\'1P\':\'M\',\'2p\':\'I\',\'1a\':\'#7Q\',\'5o\':I,\'2T\':\'5p\',\'36\':I,\'37\':I,\'38\':M,\'3b\':I},5u:E(f){8.5B(f);u g=C 7F("^"+8.A.1C),16=8.A.1C,F=8;8.1H=[];8.2x=C 7A({});8.2l=I;8.29=I;8.7x=$$(\'a\').7w(E(a){u b=a.26(\'2P\'),11=I,4n=I,1E=I;u c=(b||\'\').4v(g);t(c){t(b)11=b.U(/\\([a-5K-5L-Z]+\\)/g)||I;t(b)1E=b.U(/\\[1E\\=(.+)+\\]/)||I;t(1E[1]){a.1E=1E[1]}N{a.1E=I};t(11[0]){11=11[0].1M("(","").1M(")","");t(!8.2x.7j(11))8.2x.4x(11,[]);u d=8.2x.4y(11);d.7f(a);4n=d.1h;8.2x.4x(11,d)};a.11=11;a.4w=4n;a.1N(\'1G\',8.1G.5R(a,[a.1I,a.1F,a.2P,8]))};L c}.5T(8));u h=$77(8.A.1y,{\'Q\':16+\'-1y\',\'1k\':16+\'-1y\'});8.2s=C 4q(I,h).1N(\'5W\',E(){F.24(F.1H)}).1N(\'5Z\',E(){t(F.2l){F.2l=I;u e=F.1O[0],3v=F.1O[1],2t=F.1O[2],1g=F.1O[3],1s;t(3v.26(\'Q\').4v(\'2y\'))1s=2t[1g];N 1s=2t[1g-2];F.1G.3r(1R,F,[I,1s.1I,1s.1F,1s.2P,F,1s])}});8.1y=8.2s.1y.1N(\'1G\',E(){F.29=I;F.2a()});8.W=C V(\'1o\',{\'Q\':16+\'-W\',\'1k\':16+\'-\'+8.A.4I}).Y(1c.4h).1J({\'4e\':\'4c\',\'3z\':66,\'1d\':0}).1S();u i=C V(\'1o\',{\'Q\':16+\'-13\',\'1k\':16+\'-1n\'}).Y(8.W);u j=C V(\'1o\',{\'1k\':16+\'-3c\'}).Y(i);u k=C V(\'1o\',{\'1k\':16+\'-18\'}).Y(j);u l=C V(\'1o\',{\'Q\':16+\'-6y\',\'1k\':16+\'-1n\'}).Y(8.W);u m=C V(\'1o\',{\'1k\':16+\'-3c\'}).Y(l);8.18=C V(\'1o\',{\'1k\':16+\'-18\'}).Y(m);u n=C V(\'1o\',{\'Q\':16+\'-6v\',\'1k\':16+\'-1n\'}).Y(8.W);u o=C V(\'1o\',{\'1k\':16+\'-3c\'}).Y(n);u p=C V(\'1o\',{\'1k\':16+\'-18\'}).Y(o);C V(\'1o\',{\'1k\':\'6s\'}).Y(8.W);8.1w=C V(\'a\',{\'Q\':16+\'-2a\',\'1F\':\'#\'}).2c(\'<1K>[x] 2a</1K>\').Y(8.18);8.1w.1N(\'1G\',E(e){C 31(e).2V();F.29=I;F.2a(e)});8.1v={\'W\':C 2i.6h(8.W,{\'1D\':8.A.1D,3S:M,\'1B\':8.A.1B,6i:E(){t(F.O==\'2R\')L;t(!8.6w.1d&&F.2s.24){F.W.1S();t(!F.29){F.2s.1S()}N{t(F.2l){F.2l=I;u e=F.1O[0],3v=F.1O[1],2t=F.1O[2],1g=F.1O[3],1s;t(3v.26(\'Q\').4v(\'2y\'))1s=2t[1g];N 1s=2t[1g-2];F.1G.3r(1R,F,[I,1s.1I,1s.1F,1s.2P,F,1s])}}}N{F.6e.3r(50,F)}}}),\'18\':C 2i.6h(8.18,{\'1D\':8.A.1D,3S:M,\'1B\':8.A.1B}),\'B\':C 2i.6d(8.18,\'B\',{\'1D\':8.A.1D,3S:M,\'1B\':8.A.1B})};J.1N(\'6x\',E(){F.25(F.W);F.2s.25()});t(8.A.3Y)J.1N(\'1X\',E(){F.25(F.W)})},1G:E(e,a,b,c,d,f){t(e)C 31(e).2V();u g=\'\';u h=c.U(/([0-9]+\\s?[0-9]+)/g)||[\'\'];h=h[0].1r(" ");u h=c.U(/([0-9%]+\\s?[0-9%]+)/g)||[\'\'];g=h[0].1r(" ");h=h[0].1r(" ");t(c.U(/2K/g))g=\'2K\';u i=d.1u();t(!f)f=I;u j=8.11||f.11;u k=d.1w.1e(\'B\').X()||d.1w.17().G.y||0;u l=d.A[\'1b-B\']||0;h[0]=(h[0])?h[0]:\'\';h[1]=(h[1])?h[1]:\'\';t((!h[0].3n("%")&&!h[1].3n("%"))&&!h[0].1h||!h[1].1h){t(b.U(/3p\\.1i\\/2W/i)){h[0]=5h;h[1]=73}N t(b.U(/3K\\./i)){h[0]=79;h[1]=7a}N t(b.U(/4d\\.1i\\/2W/i)){h[0]=3H;h[1]=7h}N t(b.U(/3I\\.1i\\/5N/i)){h[0]=3H;h[1]=7k}N t(b.U(/3A\\.1i\\/[0-9]{1,}/i)){h[0]=3H;h[1]=7m}N t(b.U(/\\.(5J|3L|3s|5G|5F|5E|5D|5C|3N|5A|5z|5y|5x|5w)$/i)){h[0]=7I;h[1]=7J}N t(b.U(/\\.(5t|3m|5r)$/i)){h[0]=7M;h[1]=45}};u m=J.17().G;t(h[0]>((J.1V)?J.3h:m.x)||g==\'2K\')h[0]=((J.1V)?J.3h:m.x)-d.1u(M)-20;t(h[1]>((J.1V)?J.35:m.y)||g==\'2K\')h[1]=((J.1V)?J.35:m.y)-d.1u()-k-l-20;t($O(h[0])!=\'5k\'&&$O(h[1])!=\'5k\'){t(h[0].3n("%")&&h[1].3n("%")){u n=(J.1V)?J.3h:m.x;u o=(J.1V)?J.35:m.y;h[0]=h[0].1M("%","").X();h[1]=h[1].1M("%","").X();h[0]=h[0]>1R?1R:h[0];h[1]=h[1]>1R?1R:h[1];h[0]=n*h[0]/1R;h[1]=o*h[1]/1R;h[0]=h[0]-d.1u(M)-20;h[1]=h[1]-d.1u()-k-l-20}}c={D:(h[0]||d.A.2H.D).X(),B:(h[1]||d.A.2H.B).X()};5j={D:(h[0]||d.A.2H.D).X()+d.1u(M),B:(h[1]||d.A.2H.B).X()+d.1u()+k};d.1H=[8,a,b,c,j,8.4w||f.4w,5j,8.1E];t(!d.29)d.2s.5i();N d.24(d.1H)},1u:E(a){u b=(8.A[\'52-53\']*2)+(8.A[\'5d-2w\']*2);L b},24:E(){1Q=1Q[0];u b=1Q;u d=1Q[0],j=1Q[1],1F=1Q[2],G=1Q[3],A=1Q[6],1E=1Q[7],F=8;8.1w.1z(\'3X\',\'80\');u e=F.1w.1e(\'B\').X()||F.1w.17().G.y||F.1w.82.B.X()||0;t(F.1w.1e(\'4e\')==\'4c\')e=0;u g=F.A[\'1b-B\']||0;8.W.1J({\'D\':A.D,\'B\':A.B+g+e}).2B();8.18.1J({\'D\':G.D,\'B\':G.B+e+g});t(F.A.2r&&!8.1f){u i=F.41(j)||[I,I];u j=i[0],2q=i[1];8.1f=C V(\'1o\',{\'Q\':8.A.1C+\'-1f\'}).Y(8.18).1z(\'1d\',0).59(j,2q)};t(F.A.2r&&8.1f)8.1f.1S().1z(\'B\',0);t(F.15)F.15.4b();u k=8.25(8.W,A)[1];8.1v.W.1l(8.3g(8.A.1t,k).1l).2D(E(){t(F.A.2r&&F.1f){(E(){u a=F.1f.17().G.y||0;u b=F.18.1e(\'B\').X();u c=F.1f.83().84().1h;F.1v.B.1l(b+a-e).2D(E(){F.1f.1t(\'1d\').1l(1);t(F.A.2F){F.4g=F.2F.5R(F);1c.1N(\'4Z\',F.4g)}})}).3r(F.A.4N)}});u h=G.B+e+g;u f=8.3g(8.A.1t,k).1l;t(f.D||f.B)8.1v.18.1l({\'D\':($O(f.D)==\'4Y\')?[0,G.D]:G.D,\'B\':($O(f.B)==\'4Y\')?[0,h]:h});N 8.18.1J({\'D\':G.D,\'B\':h})},2a:E(a,b){u c=8,1t;u d={\'1n\':8.W.1e(\'1n\').X(),\'13\':8.W.1e(\'13\').X()};8.1w.1z(\'3X\',\'4X\');8.15.2e(\'2o\');8.4U();1t=8.3g((b)?b:8.A.1t,d).2E;t(8.A.2r)8.1f.1t(\'1d\').4x(0);t(8.A.2F)1c.8b(\'4Z\',c.4g);t(8.1b)8.1b.4o();8.1b=I;u e={};t($4Q(1t.D))e.D=4P.4O(1t.D-c.1u());t($4Q(1t.B))e.B=4P.4O(1t.B);8.1v.18.1l(e).2D(E(){c.1v.B.2V();t(c.1f)c.1f.1z(\'B\',\'\');c.18.1J({\'D\':\'\',\'B\':\'\'});c.15.1J({\'D\':\'\',\'B\':\'\'})});8.1v.W.1l(1t);L 8},2F:E(e){C 31(e);4p(e.3w){1L\'1n\':t(8.1b)8.2X.3y(\'1G\',e);27;1L\'3c\':t(8.1b)8.2Z.3y(\'1G\',e);27;1L\'8C\':8.29=I;8.2a(e,\'3C\')}},25:E(a,b){u c=J.17();t(!a)a=$(8.W);t(!b){u d=a.17().G;b={\'D\':d.x,\'B\':d.y}};u e=8.A[\'1b-B\'];u f=c.1X.x+(((J.1V)?J.3h:c.G.x)/2)-(b.D/2)-a.1e(\'2w-1n\').X();u g=c.1X.y+(((J.1V)?J.35:c.G.y)/2)-(b.B/2)-a.1e(\'2w-13\').X()-(e/2);u h={\'13\':(g>0)?g:0,\'1n\':(f>0)?f:0};L[a.1J(h),h]},6e:E(){t(8.15)8.15.4o();t(8.1f)8.1f.1S();u d=8.1H[1],K=8.1H[2],G=8.1H[3],11=8.1H[4],1g=8.1H[5],16=8.A.1C;u f=8.1H[7];u g=8.1w.1e(\'B\').X()||8.1w.17().G.y||0;u h=8.A[\'1b-B\']||0;8.O=I;t(f){8.O=\'1E\';8.H=$(f)}N t(K.U(/\\.(8S|8W|7R|8P|8K)$/i)||8.1H[0].8J==\'2R\'){8.O=\'2R\';u i=8;8.H=C 8y.2R(K,{Q:\'1m\',8t:E(){i.15.2e(\'8q\').4K(\'8k\');i.15.2c(\'<4M>8h 8c 86.</4M>\')},4V:E(){G.D=8.D;G.B=8.B;i.15.1J(G);u a=8,2M=J.17();u b=2M.1X.y+(2M.G.y/2)-(8.B/2)-i.W.1e(\'2w-13\').X();t(b<0)b=0;t(i.18.1e(\'D\').X()!=G.D&&i.18.1e(\'B\').X()!=G.B){i.1v.18.1l({\'D\':G.D,\'B\':G.B+i.1u(M)+h})};u c=2M.1X.x+(2M.G.x/2)-(8.D/2)-(i.1u(M)/2)-i.W.1e(\'2w-1n\').X();i.1v.W.1l({\'1n\':(c>0)?c:0,\'D\':8.D+i.1u(M),\'B\':8.B+i.1u()+h+g}).2D(E(){i.15.2e(\'2o\');a.Y(i.15);t(i.1b)i.1b.2B()})}})}N t(K.U(/\\.(5J|3L|3s|5G|5F|5E|5D|5C)$/i)){8.O=\'3L\';t(1x.2k&&1x.2k.1h){8.H=\'<H Q="1m" 3k="3j..." O="4i/4W" 51="1U://2d.54.1i/55/56.57" 2L="\'+K+\'" D="\'+G.D+\'" B="\'+G.B+\'"><S P="2m" T="\'+K+\'" /><S P="58" T="5a" /><S P="2p" T="\'+8.A.2p+\'" /><S P="1P" T="\'+8.A.1P+\'" /><S P="1a" T="\'+8.A.1a+\'" /><S P="5b" T="M" /></H>\'}N{8.H=\'<H 3Z="5c:7Z-7Y-7X-7V-7S" 3k="3j..." 51="1U://2d.54.1i/55/56.57" O="4i/4W" D="\'+G.D+\'" B="\'+G.B+\'" Q="1m"><S P="2m" T="\'+K+\'" /><S P="58" T="5a" /><S P="2p" T="\'+8.A.2p+\'" /><S P="1P" T="\'+8.A.1P+\'" /><S P="1a" T="\'+8.A.1a+\'" /><S P="5b" T="M" /></H>\'}}N t(K.U(/\\.(3N|5A|5z|5y|5x|5w)$/i)){8.O=\'3N\';t(1x.2k&&1x.2k.1h){8.H=\'<H Q="1m" 3k="3j..." O="2n/x-5m" 2L="\'+K+\'" D="\'+G.D+\'" B="\'+G.B+\'" /><S P="2m" T="\'+K+\'" /><S P="5n" T="\'+8.A.1P+\'" /><S P="1a" T="\'+8.A.1a+\'" /></H>\'}N{8.H=\'<H Q="1m" 3k="3j..." 3Z="7P:7L-7H-7G-7D-7l" O="2n/x-5m" 2L="\'+K+\'" D="\'+G.D+\'" B="\'+G.B+\'" /><S P="3J" T="\'+K+\'" /><S P="7i" T="\'+8.A.2p+\'"><S P="5n" T="\'+8.A.1P+\'" /><S P="1a" T="\'+8.A.1a+\'" /><S P="7g" T="M" /></H>\'}}N t(K.U(/3p\\.1i\\/2W\\?v=/i)||K.U(/3p\\-7c\\.1i\\/2W\\?v=/i)){8.O=\'1W\';u j=3D(K);8.1Y=j[\'2z\'][\'v\'];74 j[\'2z\'][\'v\'];t(8.A.5o&&!j[\'2z\'][\'1P\'])j[\'2z\'][\'1P\']=1;8.H=C 1q("1U://2d.3p.1i/v/"+8.1Y+\'&\'+2v.72(j[\'2z\']),"1m",G.D,G.B,"9",8.A.1a,"2U","2N");8.H.1j(\'2h\',\'22\');8.H.1j(\'2f\',\'M\')}N t(K.U(/3K\\./i)){8.O=\'1W\';u k=K.1r("71")[0].1r(\'/\');8.5Y=k[k.1h-1];8.H=C 1q("1U://2d.3K.1i/1A/"+8.5Y+"&70=1&6X=33:6U;6T:6S;6J:6G;6D:6C;&6B=1&6A=0","1m",G.D,G.B,"9",8.A.1a);8.H.1j(\'2h\',\'22\');8.H.1j(\'2f\',\'M\')}N t(K.U(/4d\\.1i\\/2W/i)){8.O=\'1W\';u k=K.1r(\'/\');8.1Y=k[4];8.H=C 1q("1U://2d.4d.1i/6z/"+8.1Y+"/.1A","1m",G.D,G.B,"9",8.A.1a,"2U","2N");8.H.1j(\'2h\',\'22\');8.H.1j(\'2f\',\'M\')}N t(K.U(/3I\\.1i\\/5N/i)){8.O=\'1W\';u k=K.1r(\'=\');8.1Y=k[1];8.H=C 1q("1U://4i.3I.1i/6t.1A?6k="+8.1Y+"&1P=1&8r=6l","1m",G.D,G.B,"9",8.A.1a,"2U","2N");8.H.1j(\'2h\',\'22\');8.H.1j(\'2f\',\'M\')}N t(K.U(/3A\\.1i\\/[0-9]{1,}/i)){8.O=\'1W\';u k=K.1r(\'/\');8.1Y=k[3];8.A.38=(8.A.38)?1:0;8.A.37=(8.A.37)?1:0;8.A.3b=(8.A.3b)?1:0;8.A.36=(8.A.36)?1:0;8.A.2T=(8.A.2T.U(/[0-9]{6}/))?8.A.2T:\'5p\';8.H=C 1q("1U://2d.3A.1i/6m.1A?6n="+8.1Y+"&2C;6o=2d.3A.1i&2C;2K="+8.A.38+"&2C;6p="+8.A.37+"&2C;6q="+8.A.3b+"&2C;6r="+8.A.36+"&2C;6g="+8.A.2T+"","1m",G.D,G.B,"9",8.A.1a);8.H.1j(\'2h\',\'22\');8.H.1j(\'2f\',\'M\')}N t(K.U(/\\.1A/i)){8.O=\'1W\';8.H=C 1q(K,"1m",G.D,G.B,"9",8.A.1a,"2U","2N");8.H.1j(\'2h\',\'22\');8.H.1j(\'2f\',\'M\')}N t(K.U(/\\.6u/i)&&J.6f){8.O=\'1W\';K=J.6f+\'6c/6c.1A?6b=\'+K;8.H=C 1q(K,"1m",G.D,G.B,"9",8.A.1a,"2U","2N");8.H.1j(\'2h\',\'22\');8.H.1j(\'2f\',\'M\')}N t(K.U(/\\.(5t|5r)$/i)){8.O=\'2u\';8.H=\'<H Q="1m"" D="\'+G.D+\'" B="\'+G.B+\'" 2L="\'+K+\'"" O="\'+((J.3F)?\'2n/x-3a\':\'2u/3s\')+\'"><S T="\'+K+\'" P="2m"/><S T="\'+K+\'" P="3J"/><S T="\'+((J.3F)?\'2n/x-3a\':\'2u/3s\')+\'" P="O"/><S P="1a" T="\'+8.A.1a+\'" /><p>6a 69 68 28 67: \'+K+\'</p></H>\'}N t(K.U(/\\.3m$/i)){8.O=\'2u\';8.H=\'<H Q="1m"" D="\'+G.D+\'" B="\'+G.B+\'" 2L="\'+K+\'"" O="\'+((J.3F)?\'2n/x-3a\':\'2u/3m\')+\'"><S T="\'+K+\'" P="2m"/><S T="\'+K+\'" P="3J"/><S T="\'+((J.3F)?\'2n/x-3a\':\'2u/3m\')+\'" P="O"/><S P="1a" T="\'+8.A.1a+\'" /><p>6a 69 68 28 67: \'+K+\'</p></H>\'}N{8.O=\'42\';u l="1m"+$6E()+$44(0,1R);8.H=C V(\'42\').46({Q:l,D:G.D,B:G.B,6F:0,3Y:\'6H\',2m:K});u i=8;8.H.4V=E(){i.15.2e(\'2o\')}}8.3G=$(\'1m\');t(8.O){8.15=C V(\'1o\',{\'Q\':16+\'-15\',\'1k\':16+\'-15\'}).4K(\'2o\').1J(G).6I(8.18);t(8.O==\'1W\')8.H.64(8.15);N t(8.O==\'1E\'){8.H.6K(M).Y(8.15.2e(\'2o\')).1z(\'2b\',\'6L\')}N t(8.O==\'6M\'){8.H.Y(8.15);C 6N(K,{\'6O\':\'4y\',\'6P\':M,\'6Q\':8.H,6i:E(){8.15.2e(\'2o\')}.5T(8)}).6R()}N t(8.O==\'42\'){8.H.Y(8.15)}N t(8.O!=\'2R\')8.15.2e(\'2o\').2c(8.H);t(11){u m=8.2x.4y(11),i=8;t(m.1h>1){t(!8.1b){8.1b=C V(\'1o\',{\'Q\':8.A.1C+\'-1b\'}).Y(8.18).1S();t(1g!=1){8.2X=C V(\'a\',{\'Q\':8.A.1C+\'-3t\'}).Y(8.1b).2c(\'<1K>&63;3t</1K>\');8.2X.46({\'1F\':m[1g-2].26(\'1F\'),\'1I\':m[1g-2].26(\'1I\')})};t(1g!=m.1h){8.2Z=C V(\'a\',{\'Q\':8.A.1C+\'-2y\'}).Y(8.1b).2c(\'<1K>2y &62;</1K>\');8.2Z.46({\'1F\':m[1g].26(\'1F\'),\'1I\':m[1g].26(\'1I\')})};t(1g==1)8.2X=C V(\'a\',{\'Q\':8.A.1C+\'-3t\',\'1k\':\'3u\',\'1F\':\'#\'}).Y(8.1b,\'13\').2c(\'<1K>&63;3t</1K>\');t(1g==m.1h)8.2Z=C V(\'a\',{\'Q\':8.A.1C+\'-2y\',\'1k\':\'3u\',\'1F\':\'#\'}).Y(8.1b).2c(\'<1K>2y &62;</1K>\');8.2X.1N(\'1G\',E(e){e=C 31(e).2V();t(!8.61(\'3u\')){i.2l=M;i.1O=[e,8,m,1g];i.29=M;i.2a(e,\'3C\')}});8.2Z.1N(\'1G\',E(e){e=C 31(e).2V();t(!8.61(\'3u\')){i.2l=M;i.1O=[e,8,m,1g];i.29=M;i.2a(e,\'3C\')}})};8.1b.2B()}};t(8.A.2r){u n=8.41(d)||[I,I];u o=n[0],2q=n[1];t(8.1f)8.1f.4b().4o();8.1f=C V(\'1o\',{\'Q\':8.A.1C+\'-1f\'}).Y(8.18).1z(\'1d\',0).59(o,2q)}}},4U:E(){t(8.O){8.15.1z(\'3X\',\'4X\').4b()}8.3G=2j;8.O=I},41:E(a){a=a.1r(" :: ")||I;4p(a.1h){1L 0:L I;27;1L 1:u b=I;u c=C V(\'p\').4k(a[0]);27;1L 2:u b=C V(\'6V\').4k(a[0]);u c=C V(\'p\').4k(a[1]);27}L[b,c]},6W:E(a){u b=a.26(\'2P\'),11=I;t(b)11=b.U(/\\([a-5K-5L-Z]+\\)/g)||I;t(11[0])11=11[0].1M("(","").1M(")","");N 11=I;L 11}});3U.4m(C 60,C 6Y);u 4q=C 4H({A:{\'Q\':I,\'1k\':I,\'33\':\'#6Z\',\'1d\':0.7,\'3z\':66,\'1D\':4l,\'1B\':2i.4u.4r.4T},5u:E(a,b){8.5X=$(a)||$(1c.4h);8.5B(b);8.1y=C V(\'1o\',{\'Q\':8.A.Q||(\'5V-\'+$44(1,5U)),\'1k\':8.A.Q||(\'5V-\'+$44(1,5U)),\'75\':{\'1d\':0,\'2b\':\'3l\',\'4e\':\'4c\',\'13\':0,\'1n\':0,\'76\':\'78\',\'33-6g\':8.A.33,\'z-1g\':8.A.3z}}).Y(1c.4h);8.1v=C 2i.6d(8.1y,\'1d\',{1D:8.A.1D,1B:8.A.1B});8.24=I;L 8},25:E(a){u b=8.5X;a=a||J.17().4t;8.1y.1J({13:b.5S().y||0,1n:b.5S().x||0,D:J.17().G.x,B:a.y});L 8},2B:E(){u a=8.1y,F=8;8.1y.1z(\'2b\',\'\');8.24=M;8.25().1v.1l(8.A.1d).2D(E(){F.3y(\'5W\',a)});L 8},1S:E(){u a=8.1y,F=8;8.24=I;8.25().1v.1l(0).2D(E(){a.1z(\'2b\',\'3l\');F.3y(\'5Z\',a)});L 8},5i:E(){8[8.24?\'1S\':\'2B\']();L 8}});4q.4m(C 60,C 7b);3U.4m({3g:E(a,b){u c={};t(!b)b=0;4p(a){1L\'3C\':c={\'1l\':{\'13\':[b.13-8.A.49,b.13],\'1d\':1},\'2E\':{\'13\':8.W.1e(\'13\').X()+8.A.49,\'1d\':0}};27;1L\'4L\':u d=8.W.1e(\'B\').X(),D=8.W.1e(\'D\').X();c={\'1l\':{\'13\':[b.13+(d/2),b.13],\'B\':[0,d],\'1d\':1},\'2E\':{\'13\':b.13+(d/2),\'1n\':J.17().G.x/2-((J.17().4t.x-10)/2),\'D\':J.17().4t.x-30,\'B\':0,\'1d\':0}};27;1L\'7d\':u d=8.W.1e(\'B\').X(),D=8.W.1e(\'D\').X();c={\'1l\':{\'B\':[0,d],\'D\':[0,D],\'1d\':1,\'13\':[(J.17().G.y/2)+J.17().1X.y,b.13],\'1n\':[(J.17().G.x/2)+J.17().1X.x,b.1n]},\'2E\':{\'B\':0,\'D\':0,\'1d\':0,\'13\':(J.17().G.y/2)+J.17().1X.y,\'1n\':(J.17().G.x/2)+J.17().1X.x}};27;1L\'7e\':c={\'1l\':{\'1d\':1},\'2E\':{\'1d\':0}}};L c}});E 3D(a){u o=3D.A,m=o.3E[o.5Q?"5P":"5O"].4f(a),2A={},i=14;5M(i--)2A[o.3w[i]]=m[i]||"";2A[o.q.P]={};2A[o.3w[12]].1M(o.q.3E,E($0,$1,$2){t($1)2A[o.q.P][$1]=$2});L 2A};3D.A={5Q:I,3w:["7n","7o","7p","7q","7r","7s","7t","7u","7v","7y","7z","6b","7B","7C"],q:{P:"2z",3E:/(?:^|&)([^&=]*)=?([^&]*)/g},3E:{5P:/^(?:([^:\\/?#]+):)?(?:\\/\\/((?:(([^:@]*):?([^:@]*))?@)?([^:\\/?#]*)(?::(\\d*))?))?((((?:[^?#\\/]*\\/)*)([^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/,5O:/^(?:(?![^:@]+:[^:@\\/]*@)([^:\\/?#.]+):)?(?:\\/\\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/}};t(2J R=="4j"){u R=C 2v()}t(2J R.2Q=="4j"){R.2Q=C 2v()}t(2J R.1Z=="4j"){R.1Z=C 2v()}R.1q=E(a,b,w,h,d,c,e,f,g,i){t(!1c.3i){L}8.5I=i?i:"7E";8.5H=R.2Q.4a(8.5I);8.43=C 2v();8.3e=C 2v();8.3W=C 5v();t(a){8.1p("1A",a)}t(b){8.1p("Q",b)}t(w){8.1p("D",w)}t(h){8.1p("B",h)}t(d){8.1p("2O",C R.1T(d.7K().1r(".")))}8.34=R.1Z.5s();t(!J.1V&&1c.3V&&8.34.2g>7){R.1q.5q=M}t(c){8.1j("1a",c)}u q=e?e:"7N";8.1j("7O",q);8.1p("39",I);8.1p("2S",I);u j=(f)?f:J.2I;8.1p("4z",j);8.1p("3d","");t(g){8.1p("3d",g)}};R.1q.5l={39:E(a){8.3R=!a?"7T.1A":a;8.1p("39",M)},1p:E(a,b){8.3W[a]=b},19:E(a){L 8.3W[a]},1j:E(a,b){8.43[a]=b},3Q:E(){L 8.43},2G:E(a,b){8.3e[a]=b},7W:E(a){L 8.3e[a]},5g:E(){L 8.3e},3O:E(){u a=C 5v();u b;u c=8.5g();28(b 3o c){a[a.1h]=b+"="+c[b]}L a},5f:E(){u a="";t(1x.2k&&1x.3M&&1x.3M.1h){t(8.19("2S")){8.2G("5e","81");8.1p("1A",8.3R)}a="<88 O=\\"2n/x-89-1W\\" 2m=\\""+8.19("1A")+"\\" D=\\""+8.19("D")+"\\" B=\\""+8.19("B")+"\\" 32=\\""+8.19("32")+"\\"";a+=" Q=\\""+8.19("Q")+"\\" P=\\""+8.19("Q")+"\\" ";u b=8.3Q();28(u c 3o b){a+=[c]+"=\\""+b[c]+"\\" "}u d=8.3O().4S("&");t(d.1h>0){a+="4R=\\""+d+"\\""}a+="/>"}N{t(8.19("2S")){8.2G("5e","8d");8.1p("1A",8.3R)}a="<H Q=\\""+8.19("Q")+"\\" 3Z=\\"5c:8e-8f-8i-8j-8l\\" D=\\""+8.19("D")+"\\" B=\\""+8.19("B")+"\\" 32=\\""+8.19("32")+"\\">";a+="<S P=\\"3G\\" T=\\""+8.19("1A")+"\\" />";u e=8.3Q();28(u c 3o e){a+="<S P=\\""+c+"\\" T=\\""+e[c]+"\\" />"}u f=8.3O().4S("&");t(f.1h>0){a+="<S P=\\"4R\\" T=\\""+f+"\\" />"}a+="</H>"}L a},64:E(a){t(8.19("39")){u b=C R.1T([6,0,65]);t(8.34.3f(b)&&!8.34.3f(8.19("2O"))){8.1p("2S",M);8.2G("8m",8n(8.19("4z")));1c.1I=1c.1I.8p(0,47)+" - 4J 6j 8v";8.2G("8w",1c.1I)}}t(8.5H||8.19("2S")||8.34.3f(8.19("2O"))){u n=(2J a=="8x")?1c.3i(a):a;n.8z=8.5f();L M}N{t(8.19("3d")!=""){1c.2I.1M(8.19("3d"))}}L I}};R.1Z.5s=E(){u a=C R.1T([0,0,0]);t(1x.2k&&1x.3M.1h){u x=1x.2k["8A 4J"];t(x&&x.2q){a=C R.1T(x.2q.1M(/([a-8B-Z]|\\s)+/,"").1M(/(\\s+r|\\s+b[0-9]+)/,".").1r("."))}}N{t(1x.4G&&1x.4G.3P("8D 8E")>=0){u b=1;u c=3;5M(b){3q{c++;b=C 3x("23.23."+c);a=C R.1T([c,0,0])}3B(e){b=2j}}}N{3q{u b=C 3x("23.23.7")}3B(e){3q{u b=C 3x("23.23.6");a=C R.1T([6,0,21]);b.8F="22"}3B(e){t(a.2g==6){L a}}3q{b=C 3x("23.23")}3B(e){}}t(b!=2j){a=C R.1T(b.8G("$2O").1r(" ")[1].1r(","))}}}L a};R.1T=E(a){8.2g=a[0]!=2j?48(a[0]):0;8.2Y=a[1]!=2j?48(a[1]):0;8.4s=a[2]!=2j?48(a[2]):0};R.1T.5l.3f=E(a){t(8.2g<a.2g){L I}t(8.2g>a.2g){L M}t(8.2Y<a.2Y){L I}t(8.2Y>a.2Y){L M}t(8.4s<a.4s){L I}L M};R.2Q={4a:E(a){u q=1c.2I.8H||1c.2I.8I;t(a==2j){L q}t(q){u b=q.3T(1).1r("&");28(u i=0;i<b.1h;i++){t(b[i].3T(0,b[i].3P("="))==a){L b[i].3T((b[i].3P("=")+1))}}}L""}};R.1Z.4E=E(){u a=1c.8L("8M");28(u i=a.1h-1;i>=0;i--){a[i].32.2b="3l";28(u x 3o a[i]){t(2J a[i][x]=="E"){a[i][x]=E(){}}}}};t(R.1q.5q){t(!R.4D){R.1Z.4C=E(){8Q=E(){};8R=E(){};J.4B("8T",R.1Z.4E)};J.4B("8U",R.1Z.4C);R.4D=M}}t(!1c.3i&&1c.3V){1c.3i=E(a){L 1c.3V[a]}}u 8V=R.2Q.4a;u 8X=R.1q;u 1q=R.1q;',62,556,'||||||||this|||||||||||||||||||||if|var||||||options|height|new|width|function|self|size|object|false|window|url|return|true|else|type|name|id|deconcept|param|value|match|Element|wrapper|toInt|inject|||group||top||container|cls|getSize|center|getAttribute|bgcolor|arrows|document|opacity|getStyle|caption|index|length|com|addParam|class|start|rokboxobject|left|div|setAttribute|SWFObject|split|what|effect|overflow|fx|closeButton|navigator|overlay|setStyle|swf|transition|className|duration|module|href|click|current|title|setStyles|span|case|replace|addEvent|nextGroup|autoplay|arguments|100|hide|PlayerVersion|http|opera|flash|scroll|videoID|SWFObjectUtil|||always|ShockwaveFlash|open|reposition|getProperty|break|for|swtch|close|display|setHTML|www|removeClass|allowfullscreen|major|allowscriptaccess|Fx|null|plugins|changeGroup|src|application|spinner|controller|description|captions|overlayObj|list|audio|Object|padding|groups|next|queryKey|uri|show|amp|chain|end|keyEvents|addVariable|defaultSize|location|typeof|fullscreen|data|winSize|transparent|version|rel|util|image|doExpressInstall|vimeoColor|wmode|stop|watch|prevArrow|minor|nextArrow||Event|style|background|installedVer|innerHeight|vimeoPortrait|vimeoTitle|vimeoFullScreen|useExpressInstall|mplayer2|vimeoByline|right|redirectUrl|variables|versionIsValid|effects|innerWidth|getElementById|loading|standby|none|wav|contains|in|youtube|try|delay|mpeg|previous|inactive|selfLink|key|ActiveXObject|fireEvent|zIndex|vimeo|catch|growl|parseUri|parser|ie|movie|400|google|filename|dailymotion|qt|mimeTypes|wmv|getVariablePairs|indexOf|getParams|xiSWFPath|wait|substring|RokBox|all|attributes|visibility|scrolling|classid||getCaption|iframe|params|random||setProperties||parseInt|chase|getRequestParameter|empty|absolute|metacafe|position|exec|evt|body|video|undefined|setText|200|implement|len|remove|switch|Rokverlay|Quad|rev|scrollSize|Transitions|test|idx|set|get|xiRedirectUrl|extend|attachEvent|prepUnload|unloadSet|cleanupSWFs|https|userAgent|Class|theme|Flash|addClass|quicksilver|h1|captionsDelay|abs|Math|chk|flashvars|join|easeInOut|unloadVideo|onload|quicktime|hidden|array|keyup||codebase|frame|border|apple|qtactivex|qtplugin|cab|scale|adopt|aspect|enablejavascript|clsid|content|MMplayerType|getSWFHTML|getVariables|640|toggle|options2|number|prototype|oleobject|autoStart|youtubeAutoplay|00adef|doPrepUnload|m4a|getPlayerVersion|mp3|initialize|Array|asf|asx|wvx|wax|wma|setOptions|m4v|mv4|xvid|avi|divx|skipDetect|DETECT_KEY|mov|z0|9A|while|videoplay|loose|strict|strictMode|bindWithEvent|getPosition|bind|1000|rokverlay|onShow|where|videoId|onHide|Options|hasClass|gt|lt|write||65555|playing|matched|plugin|No|file|jwplayer|Style|loadVideo|rokboxPath|color|Styles|onComplete|Player|docId|en|moogaloop|clip_id|server|show_title|show_byline|show_portrait|clr|googleplayer|flv|bottom|now|resize|middle|fplayer|related|autoPlay|FFC300|special|time|frameBorder|333333|auto|injectInside|foreground|clone|block|html|Ajax|method|evalScripts|update|request|FFFFFF|glow|DDDDDD|h2|getGroup|colors|Chain|000000|v3|_|toQueryString|385|delete|styles|cursor|merge|pointer|420|339|Events|nocookie|explode|fade|push|stretchToFit|345|showcontrols|hasKey|326|0080C74C7E95|225|source|protocol|authority|userInfo|user|password|host|port|relative|filter|elements|path|directory|Hash|query|anchor|94AB|detectflash|RegExp|11D0|B0F6|504|336|toString|22D6f312|320|high|quality|CLSID|f3f3f3|jpeg|D3488ABDDC6B|expressinstall|460|BC80|getVariable|4B23|8C17|02BF25D5|visible|PlugIn|currentStyle|getText|trim||found|65550|embed|shockwave|000|removeEvent|not|ActiveX|D27CDB6E|AE6D|800|Image|11cf|96B8|warning|444553540000|MMredirectURL|escape|easeOut|slice|liading|hl|default|onerror|rokbox|Installation|MMdoctitle|string|Asset|innerHTML|Shockwave|zA|esc|Windows|CE|AllowScriptAccess|GetVariable|search|hash|alt|bmp|getElementsByTagName|OBJECT|sameDomain|String|png|__flash_unloadHandler|__flash_savedUnloadHandler|gif|onunload|onbeforeunload|getQueryParamValue|jpg|FlashObject'.split('|'),0,{}))
;

/*** rokbox-config.js ***/

/* All the presets options are the custom ones */

var rokbox;
window.addEvent('domready', function() {
	rokbox = new RokBox({
		'theme': 'clean', // this string must match the theme folder name (string, no space, lowercase)
		'transition': Fx.Transitions.Quad.easeOut, // Transition to use when opening RokBox
		'duration': 400, // Duration of opening RokBox Effect (integer, milliseconds)
		'chase': 50, // Chase to use for the animation. works only for growl, see next line. (integer)
		'frame-border': 20, // Width of each border if any (integer, pixels)
		'content-padding': 0, // Padding of internal content wrapper (integer, pixels)
		'arrows-height': 25, // Height of arrows div (integer, pixels)
		'effect': 'growl', // Type of effect to use. Presets are: 'quicksilver', 'growl', 'explode'
		'captions': 1, // Whether to enable or disable captions (boolean, 1 or 0)
		'captionsDelay': 800, // How long captions effect should last, when captions are enabled (integer, milliseconds)
		'scrolling': 1, // Makes RokBox follow when scrolling the page (boolean, 1 or 0)
		'keyEvents': 1, // Enable keyevents. Esc, Left, Right to close and change previous or next (boolean, 1 or 0)
		'overlay': {
			'background': '#000', // Overlay background color (string, hex color format with starting hash #)
			'opacity': 0.4, // Opacity of the overlay (float, from 0 to 1, 0.1 makes it invisible but clickable)
			'duration': 150, // Duration of overlay effect (integer, milliseconds)
			'transition': Fx.Transitions.Quad.easeInOut // Transition to use for opacity effect
		},
		'defaultSize': {
			'width': 640, // Default RokBox window width (integer)
			'height': 460 // Default RokBox window height (integer)
		},
		'autoplay': 'true', // Enable or disable autoplay for QuickTimes and WM videos (string, 'true' or 'false')
		'controller': 'true', // Enable or disable controllers for QuickTimes and WM videos (string, 'true' or 'false')
		'bgcolor': '#ffffff', // Set Background colors for all videos and flash services that support it (string, hex color format with starting hash #)
		'youtubeAutoplay': 0, // Enable or disable autoplay for YouTube (boolean, 1 or 0)
		'vimeoColor': '00adef', // Vimeo Color Scheme (string, hex color format WITHOUT starting hash #)
		'vimeoPortrait': 0, // Enable or disable Vimeo Portrait Button (boolean, 1 or 0)
		'vimeoTitle': 0, // Enable or disable Vimeo Title caption (boolean, 1 or 0)
		'vimeoFullScreen': 1, // Enable or disable Vimeo FullScreen button (boolean, 1 or 0)
		'vimeoByline': 0 // Enable or disable Vimeo's Author line (boolean, 1 or 0)
	});
});

/*** ajax_1.3.js ***/

function Jax(){var loadingTimeout=400;var iframe;this.loadingFunction=function(){};this.doneLoadingFunction=function(){};this.stringify=function(arg){var c,i,l,o,u,v;switch(typeof arg){case"object":if(arg){if(arg.constructor==Array){o="";for(i=0;i<arg.length;++i){v=this.stringify(arg[i]);if(o&&(v!==u)){o+=","}if(v!==u){o+=v}}return"["+o+"]"}else{if(typeof arg.toString!="undefined"){o="";for(i in arg){v=this.stringify(arg[i]);if(v!==u){if(o){o+=","}o+=this.stringify(i)+":"+v}}return"{"+o+"}"}else{return}}}return"";case"unknown":case"undefined":case"function":return u;case"string":arg=arg.replace(/"/g,'\\"');l=arg.length;o='"';for(i=0;i<l;i+=1){c=arg.charAt(i);if(c>=" "){if(c=="\\"||c=='"'){o+="\\"}o+=c}else{switch(c){case'"':o+='\\"';break;case"\b":o+="\\b";break;case"\f":o+="\\f";break;case"\n":o+="\\n";break;case"\r":o+="\\r";break;case"\t":o+="\\t";break;default:c=c.charCodeAt();o+="\\u00";o+=Math.floor(c/16).toString(16);o+=(c%16).toString(16)}}}return o+'"';default:return String(arg)}};this.getRequestObject=function(){if(window.XMLHttpRequest){http_request=new XMLHttpRequest()}else{if(window.ActiveXObject){var msxmlhttp=new Array("Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP");for(var i=0;i<msxmlhttp.length;i++){try{http_request=new ActiveXObject(msxmlhttp[i])}catch(e){http_request=null}}}}if(!http_request){alert("Unfortunatelly you browser doesn't support this feature.");return false}return http_request};this.$=function(sId){if(!sId){return null}var returnObj=document.getElementById(sId);if(!returnObj&&document.all){returnObj=document.all[sId]}return returnObj};this.addEvent=function(obj,type,fn){if(obj.attachEvent){obj["e"+type+fn]=fn;obj[type+fn]=function(){obj["e"+type+fn](window.event)};obj.attachEvent("on"+type,obj[type+fn])}else{obj.addEventListener(type,fn,false)}};this.removeEvent=function(obj,type,fn){if(obj.detachEvent){obj.detachEvent("on"+type,obj[type+fn]);obj[type+fn]=null}else{obj.removeEventListener(type,fn,false)}};this.submitITask=function(comName,func,postData,responseFunc){var xmlReq=this.buildXmlReq(comName,func,postData,responseFunc,true);this.loadingFunction();if(!this.iframe){this.iframe=document.createElement("iframe");this.iframe.setAttribute("id","ajaxIframe");this.iframe.setAttribute("height",0);this.iframe.setAttribute("width",0);this.iframe.setAttribute("border",0);this.iframe.style.visibility="hidden";document.body.appendChild(this.iframe);this.iframe.src=xmlReq}else{this.iframe.src=xmlReq}};this.extractIFrameBody=function(iFrameEl){var doc=null;if(iFrameEl.contentDocument){doc=iFrameEl.contentDocument}else{if(iFrameEl.contentWindow){doc=iFrameEl.contentWindow.document}else{if(iFrameEl.document){doc=iFrameEl.document}else{alert("Error: could not find sumiFrame document");return null}}}return doc.body};this.buildXmlReq=function(comName,func,postData,responseFunc,iframe){var xmlReq="";if(iframe){xmlReq+="?"}else{xmlReq+="&"}xmlReq+="option="+comName;xmlReq+="&no_html=1";xmlReq+="&task=azrul_ajax";xmlReq+="&func="+func;xmlReq+="&"+jax_token_var+"=1";if(postData){xmlReq+="&"+postData}return xmlReq};this.submitTask=function(comName,func,postData,responseFunc){var xmlhttp=this.getRequestObject();var targetUrl=jax_live_site;xmlhttp.open("POST",targetUrl,true);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){jax.doneLoadingFunction();jax.processResponse(xmlhttp.responseText)}else{}}};var id=1;var xmlReq=this.buildXmlReq(comName,func,postData,responseFunc);this.loadingFunction();xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlhttp.send(xmlReq)};this.processIResponse=function(){jax.doneLoadingFunction();var resp=(this.extractIFrameBody(this.iframe).innerHTML);resp=resp.replace(/&lt;/g,"<");resp=resp.replace(/&gt;/g,">");resp=resp.replace(/&amp;/g,"&");resp=resp.replace(/&quot;/g,'"');resp=resp.replace(/&#39;/g,"'");this.processResponse(resp)};this.BetterInnerHTML=function(o,p,q){function r(a){var b;if(typeof DOMParser!="undefined"){b=(new DOMParser()).parseFromString(a,"application/xml")}else{var c=["MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XMLDOM"];for(var i=0;i<c.length&&!b;i++){try{b=new ActiveXObject(c[i]);b.loadXML(a)}catch(e){}}}return b}function s(a,b,c){a[b]=function(){return eval(c)}}function t(b,c,d){if(typeof d=="undefined"){d=1}if(d>1){if(c.nodeType==1){var e=document.createElement(c.nodeName);var f={};for(var a=0,g=c.attributes.length;a<g;a++){var h=c.attributes[a].name,k=c.attributes[a].value,l=(h.substr(0,2)=="on");if(l){f[h]=k}else{switch(h){case"class":e.className=k;break;case"for":e.htmlFor=k;break;default:e.setAttribute(h,k)}}}b=b.appendChild(e);for(l in f){s(b,l,f[l])}}else{if(c.nodeType==3){var m=(c.nodeValue?c.nodeValue:"");var n=m.replace(/^\s*|\s*$/g,"");if(n.length<7||(n.indexOf("<!--")!=0&&n.indexOf("-->")!=(n.length-3))){b.appendChild(document.createTextNode(m))}}}}for(var i=0,j=c.childNodes.length;i<j;i++){t(b,c.childNodes[i],d+1)}}p="<root>"+p+"</root>";var u=r(p);if(o&&u){if(q!=false){while(o.lastChild){o.removeChild(o.lastChild)}}t(o,u.documentElement)}};this.processResponse=function(responseTxt){var result=eval(responseTxt);for(var i=0;i<result.length;i++){var cmd=result[i][0];var id=result[i][1];var property=result[i][2];var data=result[i][3];var objElement=this.$(id);switch(cmd){case"as":if(objElement){eval("objElement."+property+"=  data ; ")}break;case"al":if(data){alert(data)}break;case"ce":this.create(id,property,data);break;case"rm":this.remove(id);break;case"cs":var scr=id+"(";if(this.isArray(data)){scr+="(data[0])";for(var l=1;l<data.length;l++){scr+=",(data["+l+"])"}}else{scr+="data"}scr+=");";eval(scr);break;default:alert("Unknow command: "+cmd)}}};this.isArray=function(obj){if(obj){return obj.constructor==Array}return false};this.buildCall=function(comName,sFunction){};this.icall=function(comName,sFunction){var arg="";if(arguments.length>2){for(var i=2;i<arguments.length;i++){var a=arguments[i];if(this.isArray(a)){arg+="arg"+i+"="+this.stringify(a)+"&"}else{if(typeof a=="string"){var t=new Array("_d_",encodeURIComponent(a));arg+="arg"+i+"="+this.stringify(t)+"&"}else{var t=new Array("_d_",encodeURIComponent(a));arg+="arg"+i+"="+this.stringify(t)+"&"}}}}if(jax_site_type=="1.5"){this.submitTask(comName,sFunction,arg)}else{this.submitITask(comName,sFunction,arg)}};this.call=function(comName,sFunction){var arg="";if(arguments.length>2){for(var i=2;i<arguments.length;i++){var a=arguments[i];if(this.isArray(a)){arg+="arg"+i+"="+this.stringify(a)+"&"}else{if(typeof a=="string"){a=a.replace(/"/g,"&quot;");var t=new Array("_d_",encodeURIComponent(a));arg+="arg"+i+"="+this.stringify(t)+"&"}else{var t=new Array("_d_",encodeURIComponent(a));arg+="arg"+i+"="+this.stringify(t)+"&"}}}}this.submitTask(comName,sFunction,arg)};this.create=function(sParentId,sTag,sId){var objParent=this.$(sParentId);objElement=document.createElement(sTag);objElement.setAttribute("id",sId);if(objParent){objParent.appendChild(objElement)}};this.remove=function(sId){objElement=this.$(sId);if(objElement&&objElement.parentNode&&objElement.parentNode.removeChild){objElement.parentNode.removeChild(objElement)}};this.getFormValues=function(frm){var objForm;objForm=this.$(frm);if(!Array.prototype.indexOf){Array.prototype.indexOf=function(elt){var len=this.length;var from=Number(arguments[1])||0;from=(from<0)?Math.ceil(from):Math.floor(from);if(from<0){from+=len}for(;from<len;from++){if(from in this&&this[from]===elt){return from}}return -1}}var postData=new Array();if(objForm&&objForm.tagName=="FORM"){var formElements=objForm.elements;var assCheckbox=new Array();var assCntIdx=0;var arrayHiddenValues=new Array();var arrayHiddenCount=0;if(formElements.length>0){for(var i=0;i<formElements.length;i++){if(!formElements[i].name){continue}if(formElements[i].type&&(formElements[i].type=="radio"||formElements[i].type=="checkbox")&&formElements[i].checked==false){continue}var name=formElements[i].name;if(name){if(formElements[i].type=="select-multiple"){postData[i]=new Array();for(var j=0;j<formElements[i].length;j++){if(formElements[i].options[j].selected===true){var value=formElements[i].options[j].value;postData[i][j]=new Array(name,encodeURIComponent(value))}}}else{if(formElements[i].type=="checkbox"){if(assCheckbox.indexOf(formElements[i].name)==-1){assCheckbox[assCntIdx]=formElements[i].name;assCntIdx++}}else{if(formElements[i].type=="hidden"){if(arrayHiddenValues.indexOf(formElements[i].name)==-1){arrayHiddenValues[arrayHiddenCount]=formElements[i].name;arrayHiddenCount++}}else{var value=formElements[i].value;value=value.replace(/"/g,"&quot;");postData[i]=new Array(name,encodeURIComponent(value))}}}}}}if(arrayHiddenValues.length>0){for(var i=0;i<arrayHiddenValues.length;i++){var hiddenElement=document.getElementsByName(arrayHiddenValues[i]);if(hiddenElement){if(hiddenElement.length>1){var curLen=postData.length;postData[curLen]=new Array();for(var j=0;j<hiddenElement.length;j++){var value=hiddenElement[j].value;value=value.replace(/"/g,"&quot;");postData[curLen][j]=new Array(arrayHiddenValues[i],encodeURIComponent(value))}}else{var value=hiddenElement[0].value;value=value.replace(/"/g,"&quot;");postData[postData.length]=new Array(arrayHiddenValues[i],encodeURIComponent(value))}}}}if(assCheckbox.length>0){for(var i=0;i<assCheckbox.length;i++){var objCheckbox=document.getElementsByName(assCheckbox[i]);if(objCheckbox){if(objCheckbox.length>1){var tmpIdx=0;var curLen=postData.length;postData[curLen]=new Array();for(var j=0;j<objCheckbox.length;j++){if(objCheckbox[j].checked){var value=objCheckbox[j].value;value=value.replace(/"/g,"&quot;");postData[curLen][j]=new Array(assCheckbox[i],encodeURIComponent(value));tmpIdx++}}}else{if(objCheckbox[0].checked){var value=objCheckbox[0].value;value=value.replace(/"/g,"&quot;");postData[postData.length]=new Array(assCheckbox[i],encodeURIComponent(value))}}}}}}return postData}}function jax_iresponse(){jax.processIResponse()}var jax=new Jax();

/*** jbolo_chat.js ***/

function gsCookie(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        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(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        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 { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie.length>0 && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {  
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};




function callbackFn(status) {
	if (status.success) {
		var obj = status.ref;
		window.onload = function() {
			if (obj && typeof obj.loadsndfx != "undefined") {
				//LOAD MP3'S
				obj.loadsndfx('doh.mp3');
				//ATTACH SNDFX TO BUTTONS
				
				//ONLOAD EVENT
				
			}
		};
	}
};

/*

Copyright (c) 2009 Anant Garg (anantgarg.com | inscripts.com)

This script may be used for non-commercial purposes only. For any
commercial purposes, please contact the author at 
anant.garg@inscripts.com

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

*/


var jb_windowFocus = true;
var jb_username;
var jb_chatHeartbeatCount = 0;
var jb_minChatHeartbeat = 1000;
var jb_maxChatHeartbeat = 33000;
var jb_chatHeartbeatTime = jb_minChatHeartbeat;
var jb_originalTitle;
var jb_blinkOrder = 0;

var jb_chatboxFocus = new Array();
var jb_newMessages = new Array();
var jb_newMessagesWin = new Array();
var jb_chatBoxes = new Array();
var chattile='';

jQuery(document).ready(function(){

	jb_originalTitle = document.title;
	startChatSession();

	jQuery([window, document]).blur(function(){
		jb_windowFocus = false;
	}).focus(function(){
		jb_windowFocus = true;
		document.title = jb_originalTitle;
	});
	for (x in jb_newMessagesWin) { 
			
			jb_newMessagesWin[x] = false;
		}
});

function strstr( haystack, needle ,bool) {
    var pos = 0;
     
    haystack += '';
    pos = haystack.indexOf( needle );
    if (pos == -1) {
        return false;
    } else{
        if( bool ){
            return haystack.substr( 0, pos );
        } else{
            return haystack.slice( pos );
        }
    }
}

function restructureChatBoxes(){
	var align = 0;
	for (x in jb_chatBoxes) {
		if (jb_chatBoxes) {
			chatboxtitle = jb_chatBoxes[x];
			if ((strstr(jb_chatBoxes[x], 'function')) == false) {
				if (jQuery("#chatbox_" + chatboxtitle).css('display') != 'none') {
					if (align == 0) {
						jQuery("#chatbox_" + chatboxtitle).css('right', '20px');
					}
					else {
						var width = (align) * (225 + 7) + 20;
						jQuery("#chatbox_" + chatboxtitle).css('right', width + 'px');
					}
					align++;
				}
			}
		}	
	}
}

function chatWith(chatuser) {  
	createChatBox(chatuser); 
	jQuery("#chatbox_"+chatuser+" .chatboxtextarea").focus();
}

function createChatBox(chatboxtitle,minimizeChatBox) {
	if (jQuery("#chatbox_"+chatboxtitle).length > 0) { 
		if (jQuery("#chatbox_"+chatboxtitle).css('display') == 'none') {
			jQuery("#chatbox_"+chatboxtitle).css('display','block');
			restructureChatBoxes();
		}
		// Module Click Fixed
		jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent").css('display','block');
		jQuery("#chatbox_"+chatboxtitle+" .chatboxinput").css('display','block');
		// IE positioning hack
		if (jQuery.browser.msie && jQuery.browser.version.substr(0,1)<8) {
		jQuery('#chatbox_'+chatboxtitle).removeClass('chatbox_m');
		}

		jQuery("#chatbox_"+chatboxtitle+" .chatboxtextarea").focus();
		return;
	}
	

	jQuery(" <div />" ).attr("id","chatbox_"+chatboxtitle)
	.addClass("chatbox")
	.html('<div class="chatboxhead" onclick="toggleChatBoxGrowth(\''+chatboxtitle+'\')"><div class="chatboxtitle"></div><div class="chatboxoptions"><span class="minimize">_</span> <span onclick="closeChatBox(\''+chatboxtitle+'\')" class="minimize">X</span></div><br clear="all"/></div><div class="chatboxcontent"></div><div class="chatboxoffline">'+jb_offlinemsg+'</div><div class="chatboxinput"><textarea class="chatboxtextarea" onkeydown="javascript:return checkChatBoxInputKey(event,this,\''+chatboxtitle+'\');"></textarea></div>')
	.appendTo(jQuery( "body" ));

	jQuery("#chatbox_"+chatboxtitle).css('bottom', '0px');
	jQuery("#chatbox_"+chatboxtitle).css('z-index', 1000);

	chattitle = chatboxtitle;
	jQuery.ajax({
	  url: jb_abs_link+"index.php?option=com_jbolo&action=getinfo&uid="+chatboxtitle,
	  cache: false,
	  dataType: "json",
	  success: function(udetails) { 
	   	chattitle = udetails.name;
			jQuery("#chatbox_"+chatboxtitle+" .chatboxtitle").html(chattitle.substr(0,25));
		}
	});
    
	chatBoxeslength = 0;
	
	for (x in jb_chatBoxes) {
		if (jb_chatBoxes) {
			if ((strstr(jb_chatBoxes[x], 'function')) == false) {
				if (jQuery("#chatbox_" + jb_chatBoxes[x]).css('display') != 'none') {
					chatBoxeslength++;
				}
			}
		}	
	}


	if (chatBoxeslength == 0) {
		jQuery("#chatbox_"+chatboxtitle).css('right', '20px');
	} else {
		width = (chatBoxeslength)*(225+7)+20;
		jQuery("#chatbox_"+chatboxtitle).css('right', width+'px');
	}
	
	jb_chatBoxes.push(chatboxtitle);

	if (minimizeChatBox == 1) {
		minimizedChatBoxes = new Array();

		if (gsCookie('chatbox_minimized')) {
			minimizedChatBoxes = gsCookie('chatbox_minimized').split(/\|/);
		}
		minimize = 0;
		for (j=0;j<minimizedChatBoxes.length;j++) { 
			if (minimizedChatBoxes[j]) {
				if (minimizedChatBoxes[j] == chatboxtitle) {
					minimize = 1;
				}
			}	
		}

		if (minimize == 1) {
			jQuery('#chatbox_'+chatboxtitle+' .chatboxcontent').css('display','none');
			jQuery('#chatbox_'+chatboxtitle+' .chatboxinput').css('display','none');
		}
	}

	jb_chatboxFocus[chatboxtitle] = false;

	jQuery("#chatbox_"+chatboxtitle+" .chatboxtextarea").blur(function(){
		jb_chatboxFocus[chatboxtitle] = false;
		jQuery("#chatbox_"+chatboxtitle+" .chatboxtextarea").removeClass('chatboxtextareaselected');
	}).focus(function(){
		jb_chatboxFocus[chatboxtitle] = true;
		jb_newMessages[chatboxtitle] = false;
		jQuery('#chatbox_'+chatboxtitle+' .chatboxhead').removeClass('chatboxblink');
		jQuery("#chatbox_"+chatboxtitle+" .chatboxtextarea").addClass('chatboxtextareaselected');
	});

	jQuery("#chatbox_"+chatboxtitle).click(function() {
		if (jQuery('#chatbox_'+chatboxtitle+' .chatboxcontent').css('display') != 'none') {
			jQuery("#chatbox_"+chatboxtitle+" .chatboxtextarea").focus();
		}
	});

	jQuery("#chatbox_"+chatboxtitle).show();
}


function chatHeartbeat(){ 

	var itemsfound = 0;
	
	if (jb_windowFocus == false) {
 		
		var blinkNumber = 0;
		var titleChanged = 0;
		for (x in jb_newMessagesWin) {
			if (jb_newMessagesWin[x]) {
				
				if (jb_newMessagesWin[x]!=''&& jb_newMessagesWin[x]!='undefined') {
					
					++blinkNumber;
					if (blinkNumber >= jb_blinkOrder) {
						
						document.title = jb_newMessagesWin[x];
						titleChanged = 1;
						break;
					}
				}
			}	
		}
		
		if (titleChanged == 0) {
			document.title = jb_originalTitle;
			jb_blinkOrder = 0;
		} else {
			++jb_blinkOrder;
			
		}

	} else {
		for (x in jb_newMessagesWin) { 
			
			jb_newMessagesWin[x] = false;
		}
	}

	for (x in jb_newMessages) { 
		if (jb_newMessages[x] == true) {
			if (jb_chatboxFocus[x] == false) {
				//FIXME: add toggle all or none policy, otherwise it looks funny
				
				jQuery('#chatbox_'+x+' .chatboxhead').toggleClass('chatboxblink');
			}
		}
	}
	var jb_usrno = jQuery("#jbusers>li").length;
	jQuery.ajax({
	  url: jb_abs_link+"index.php?option=com_jbolo&action=chatheartbeat&userno="+jb_usrno,
	  cache: false,
	  dataType: "json",
	  success: function(data) { 

		jQuery.each(data.it, function(i,item){

			if (item)	{ // fix strange ie bug
				if(this.m!=null && this.show!=null)
				{
					var chatboxtitle = this.f;
					
					thismessage = jb_doReplace(this.m);
					
					if (jQuery("#chatbox_"+chatboxtitle).length <= 0) {
						createChatBox(chatboxtitle);
					}
					if (jQuery("#chatbox_"+chatboxtitle).css('display') == 'none') {
						jQuery("#chatbox_"+chatboxtitle).css('display','block');
						restructureChatBoxes();
					}
					
					if (this.s == 1) {
						this.f = trans_me;//jb_username;
					} else if (this.s == 0) {
						this.f = this.show;
					}
					if(this.lst!=null)
					{
						jQuery("#jbusers").html(this.lst);
					}
					jQuery('#chatbox_'+chatboxtitle+' .chatboxoffline').css('display','none');
					jQuery('#chatbox_'+chatboxtitle+' .chatboxcontent').css('height','200px');
					jQuery('#jb_user_'+chatboxtitle).css('display','block');
	
					if (this.s == 2) {
						jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent").append('<div class="chatboxmessage"><span class="chatboxinfo">'+thismessage+'</span></div>');
					} else {
	
						jb_newMessages[chatboxtitle] = true;
						jb_newMessagesWin[chatboxtitle] = this.show + " " + jb_says;
						jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent").append('<div class="chatboxmessage"><span class="chatboxmessagefrom">'+this.f+':&nbsp;&nbsp;</span><span class="chatboxmessagecontent">'+thismessage+'</span></div>');
					}
					jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop(jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);
					itemsfound += 1;
					chatboxtitle= null;
				}
				else
				{
					jQuery("#jbusers").html(this.lst);
					jQuery('#chatbox_'+chatboxtitle+' .chatboxoffline').css('display','none');
					jQuery('#chatbox_'+chatboxtitle+' .chatboxcontent').css('height','200px');
				}
				
			} 
		});

		jb_chatHeartbeatCount++;

		if (itemsfound > 0) {
			jb_chatHeartbeatTime = jb_minChatHeartbeat;
			jb_chatHeartbeatCount = 1;
		} else if (jb_chatHeartbeatCount >= 10) {
			jb_chatHeartbeatTime *= 2;
			jb_chatHeartbeatCount = 1;
			if (jb_chatHeartbeatTime > jb_maxChatHeartbeat) {
				jb_chatHeartbeatTime = jb_maxChatHeartbeat;
			}
		}

		setTimeout('chatHeartbeat();',jb_chatHeartbeatTime);
	}});

}

function closeChatBox(chatboxtitle) {
	jQuery('#chatbox_'+chatboxtitle).css('display','none');
	restructureChatBoxes();

	jQuery.post(jb_abs_link+"index.php?option=com_jbolo&action=closechat", { chatbox: chatboxtitle} , function(data){	
	});

}

function toggleChatBoxGrowth(chatboxtitle) {
	if (jQuery('#chatbox_'+chatboxtitle+' .chatboxcontent').css('display') == 'none') {  
		
		var minimizedChatBoxes = new Array();
		
		if (gsCookie('chatbox_minimized')) {
			minimizedChatBoxes = gsCookie('chatbox_minimized').split(/\|/);
		}

		var newCookie = '';

		for (i=0;i<minimizedChatBoxes.length;i++) { 
			if (minimizedChatBoxes[i] != chatboxtitle) {
				newCookie += chatboxtitle+'|';
			}
		}

		newCookie = newCookie.slice(0, -1)
	

		gsCookie('chatbox_minimized', newCookie);
		jQuery('#chatbox_'+chatboxtitle+' .chatboxcontent').css('display','block');
		jQuery('#chatbox_'+chatboxtitle+' .chatboxinput').css('display','block');
		jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop(jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);

		// IE positioning hack
		if (jQuery.browser.msie && jQuery.browser.version.substr(0,1)<8) {
			jQuery('#chatbox_'+chatboxtitle).removeClass('chatbox_m');
		}
	} else {
		
		var newCookie = chatboxtitle;

		if (gsCookie('chatbox_minimized')) {
			newCookie += '|'+gsCookie('chatbox_minimized');
		}


		gsCookie('chatbox_minimized',newCookie);
		jQuery('#chatbox_'+chatboxtitle+' .chatboxcontent').css('display','none');
		jQuery('#chatbox_'+chatboxtitle+' .chatboxinput').css('display','none');

		// IE positioning hack
		if (jQuery.browser.msie && jQuery.browser.version.substr(0,1)<8) {
			jQuery('#chatbox_'+chatboxtitle).addClass('chatbox_m');
		}
	}
	
}

var jb_message=" ";

	var maxHeight = 94;

function checkChatBoxInputKey(event,chatboxtextarea,chatboxtitle) {  
 //alert(jQuery(chatboxtextarea).val());

	if(event.keyCode == 13 && event.shiftKey == 0)  {
		jb_message = jQuery(chatboxtextarea).val();
		msg = jb_message.replace(/^\s+|\s+$/g,"");

		jQuery(chatboxtextarea).val('');
		jQuery(chatboxtextarea).focus();
		jQuery(chatboxtextarea).css('height','44px');
		if (msg != '') {
			jQuery.post(jb_abs_link+"index.php?option=com_jbolo&action=sendchat", {to: chatboxtitle, message: msg} , function(sendop){
				jb_message = msg.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;");
				nmessage = jb_doReplace(jb_message);
				if(sendop=='me2')
				{
					sendop='me';
					jQuery('#chatbox_'+chatboxtitle+' .chatboxoffline').css('display','block');
					jQuery('#chatbox_'+chatboxtitle+' .chatboxcontent').css('height','184px');
					jQuery('#jb_user_'+chatboxtitle).css('display','none');
				}
				else
				{
					jQuery('#chatbox_'+chatboxtitle+' .chatboxoffline').css('display','none');
					jQuery('#chatbox_'+chatboxtitle+' .chatboxcontent').css('height','200px');
					jQuery('#jb_user_'+chatboxtitle).css('display','block');
				}
				jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent").append('<div class="chatboxmessage"><span class="chatboxmessagefrom">'+sendop+':&nbsp;&nbsp;</span><span class="chatboxmessagecontent">'+nmessage+'</span></div>');
				jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop(jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);
			});
		}
		jb_chatHeartbeatTime = jb_minChatHeartbeat;
		jb_chatHeartbeatCount = 1;

		return false;
	}

	var adjustedHeight = chatboxtextarea.clientHeight;
//	alert(adjustedHeight);
	if(adjustedHeight)
	{
	if (maxHeight > adjustedHeight) {
		adjustedHeight = Math.max(chatboxtextarea.scrollHeight, adjustedHeight);
		if (maxHeight)
			adjustedHeight = Math.min(maxHeight, adjustedHeight);
		if (adjustedHeight > chatboxtextarea.clientHeight)
			jQuery(chatboxtextarea).css('height',adjustedHeight+8 +'px');
	}
	}	
	 else {
		jQuery(chatboxtextarea).css('overflow','auto');
	}
	
}

function startChatSession(){  
	jQuery.ajax({
	  url: jb_abs_link+"index.php?option=com_jbolo&action=startchatsession",
	  cache: false,
	  dataType: "json",
	  success: function(data) {  
		
		 jb_username = data.jb_username;
		if (jb_username == "undefined") { jb_username = "Guest"; }

		jQuery.each(data.items, function(i,item){ 
			if (this)	{ // fix strange ie bug
				//alert(this.f);
				var chatboxtitle = this.f;
				thismessage = jb_doReplace(this.m);
				
				if (jQuery("#chatbox_"+chatboxtitle).length <= 0) {
					createChatBox(chatboxtitle,1);
				}
				
				if (this.s == 1) {
					this.f = data.me;
				} else if (this.s == 0) {
					this.f = this.show;
				}

				if (this.s == 2) {
					jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent").append('<div class="chatboxmessage"><span class="chatboxinfo">'+thismessage+'</span></div>');
				} else {
					jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent").append('<div class="chatboxmessage"><span class="chatboxmessagefrom">'+this.f+':&nbsp;&nbsp;</span><span class="chatboxmessagecontent">'+thismessage+'</span></div>');
				}
			}
		});
		
		for (i=0;i<jb_chatBoxes.length;i++) { 
			chatboxtitle = jb_chatBoxes[i];
			jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop(jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);
			setTimeout('jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop(jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);', 100); // yet another strange ie bug
		}
	
	setTimeout('chatHeartbeat();',jb_chatHeartbeatTime);
		
	}});
}
;
