$.extend($.support, {
        touch: "ontouchend" in document
});

/*
 * jQuery Templating Plugin
 * Copyright 2010, John Resig
 * Dual licensed under the MIT or GPL Version 2 licenses.
 */
(function( jQuery, undefined ){
	var oldManip = jQuery.fn.domManip, tmplItmAtt = "_tmplitem", htmlExpr = /^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
		newTmplItems = {}, wrappedItems = {}, appendToTmplItems, topTmplItem = { key: 0, data: {} }, itemKey = 0, cloneIndex = 0, stack = [];

	function newTmplItem( options, parentItem, fn, data ) {
		// Returns a template item data structure for a new rendered instance of a template (a 'template item').
		// The content field is a hierarchical array of strings and nested items (to be
		// removed and replaced by nodes field of dom elements, once inserted in DOM).
		var newItem = {
			data: data || (parentItem ? parentItem.data : {}),
			_wrap: parentItem ? parentItem._wrap : null,
			tmpl: null,
			parent: parentItem || null,
			nodes: [],
			calls: tiCalls,
			nest: tiNest,
			wrap: tiWrap,
			html: tiHtml,
			update: tiUpdate
		};
		if ( options ) {
			jQuery.extend( newItem, options, { nodes: [], parent: parentItem } );
		}
		if ( fn ) {
			// Build the hierarchical content to be used during insertion into DOM
			newItem.tmpl = fn;
			newItem._ctnt = newItem._ctnt || newItem.tmpl( jQuery, newItem );
			newItem.key = ++itemKey;
			// Keep track of new template item, until it is stored as jQuery Data on DOM element
			(stack.length ? wrappedItems : newTmplItems)[itemKey] = newItem;
		}
		return newItem;
	}

	// Override appendTo etc., in order to provide support for targeting multiple elements. (This code would disappear if integrated in jquery core).
	jQuery.each({
		appendTo: "append",
		prependTo: "prepend",
		insertBefore: "before",
		insertAfter: "after",
		replaceAll: "replaceWith"
	}, function( name, original ) {
		jQuery.fn[ name ] = function( selector ) {
			var ret = [], insert = jQuery( selector ), elems, i, l, tmplItems,
				parent = this.length === 1 && this[0].parentNode;

			appendToTmplItems = newTmplItems || {};
			if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
				insert[ original ]( this[0] );
				ret = this;
			} else {
				for ( i = 0, l = insert.length; i < l; i++ ) {
					cloneIndex = i;
					elems = (i > 0 ? this.clone(true) : this).get();
					jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
					ret = ret.concat( elems );
				}
				cloneIndex = 0;
				ret = this.pushStack( ret, name, insert.selector );
			}
			tmplItems = appendToTmplItems;
			appendToTmplItems = null;
			jQuery.tmpl.complete( tmplItems );
			return ret;
		};
	});

	jQuery.fn.extend({
		// Use first wrapped element as template markup.
		// Return wrapped set of template items, obtained by rendering template against data.
		tmpl: function( data, options, parentItem ) {
			return jQuery.tmpl( this[0], data, options, parentItem );
		},

		// Find which rendered template item the first wrapped DOM element belongs to
		tmplItem: function() {
			return jQuery.tmplItem( this[0] );
		},

		// Consider the first wrapped element as a template declaration, and get the compiled template or store it as a named template.
		template: function( name ) {
			return jQuery.template( name, this[0] );
		},

		domManip: function( args, table, callback, options ) {
			// This appears to be a bug in the appendTo, etc. implementation
			// it should be doing .call() instead of .apply(). See #6227
			if ( args[0] && args[0].nodeType ) {
				var dmArgs = jQuery.makeArray( arguments ), argsLength = args.length, i = 0, tmplItem;
				while ( i < argsLength && !(tmplItem = jQuery.data( args[i++], "tmplItem" ))) {}
				if ( argsLength > 1 ) {
					dmArgs[0] = [jQuery.makeArray( args )];
				}
				if ( tmplItem && cloneIndex ) {
					dmArgs[2] = function( fragClone ) {
						// Handler called by oldManip when rendered template has been inserted into DOM.
						jQuery.tmpl.afterManip( this, fragClone, callback );
					};
				}
				oldManip.apply( this, dmArgs );
			} else {
				oldManip.apply( this, arguments );
			}
			cloneIndex = 0;
			if ( !appendToTmplItems ) {
				jQuery.tmpl.complete( newTmplItems );
			}
			return this;
		}
	});

	jQuery.extend({
		// Return wrapped set of template items, obtained by rendering template against data.
		tmpl: function( tmpl, data, options, parentItem ) {
			var ret, topLevel = !parentItem;
			if ( topLevel ) {
				// This is a top-level tmpl call (not from a nested template using {{tmpl}})
				parentItem = topTmplItem;
				tmpl = jQuery.template[tmpl] || jQuery.template( null, tmpl );
				wrappedItems = {}; // Any wrapped items will be rebuilt, since this is top level
			} else if ( !tmpl ) {
				// The template item is already associated with DOM - this is a refresh.
				// Re-evaluate rendered template for the parentItem
				tmpl = parentItem.tmpl;
				newTmplItems[parentItem.key] = parentItem;
				parentItem.nodes = [];
				if ( parentItem.wrapped ) {
					updateWrapped( parentItem, parentItem.wrapped );
				}
				// Rebuild, without creating a new template item
				return jQuery( build( parentItem, null, parentItem.tmpl( jQuery, parentItem ) ));
			}
			if ( !tmpl ) {
				return []; // Could throw...
			}
			if ( typeof data === "function" ) {
				data = data.call( parentItem || {} );
			}
			if ( options && options.wrapped ) {
				updateWrapped( options, options.wrapped );
			}
			ret = jQuery.isArray( data ) ?
				jQuery.map( data, function( dataItem ) {
					return dataItem ? newTmplItem( options, parentItem, tmpl, dataItem ) : null;
				}) :
				[ newTmplItem( options, parentItem, tmpl, data ) ];
			return topLevel ? jQuery( build( parentItem, null, ret ) ) : ret;
		},

		// Return rendered template item for an element.
		tmplItem: function( elem ) {
			var tmplItem;
			if ( elem instanceof jQuery ) {
				elem = elem[0];
			}
			while ( elem && elem.nodeType === 1 && !(tmplItem = jQuery.data( elem, "tmplItem" )) && (elem = elem.parentNode) ) {}
			return tmplItem || topTmplItem;
		},

		// Set:
		// Use $.template( name, tmpl ) to cache a named template,
		// where tmpl is a template string, a script element or a jQuery instance wrapping a script element, etc.
		// Use $( "selector" ).template( name ) to provide access by name to a script block template declaration.

		// Get:
		// Use $.template( name ) to access a cached template.
		// Also $( selectorToScriptBlock ).template(), or $.template( null, templateString )
		// will return the compiled template, without adding a name reference.
		// If templateString includes at least one HTML tag, $.template( templateString ) is equivalent
		// to $.template( null, templateString )
		template: function( name, tmpl ) {
			if (tmpl) {
				// Compile template and associate with name
				if ( typeof tmpl === "string" ) {
					// This is an HTML string being passed directly in.
					tmpl = buildTmplFn( tmpl )
				} else if ( tmpl instanceof jQuery ) {
					tmpl = tmpl[0] || {};
				}
				if ( tmpl.nodeType ) {
					// If this is a template block, use cached copy, or generate tmpl function and cache.
					tmpl = jQuery.data( tmpl, "tmpl" ) || jQuery.data( tmpl, "tmpl", buildTmplFn( tmpl.innerHTML ));
				}
				return typeof name === "string" ? (jQuery.template[name] = tmpl) : tmpl;
			}
			// Return named compiled template
			return name ? (typeof name !== "string" ? jQuery.template( null, name ):
				(jQuery.template[name] ||
					// If not in map, treat as a selector. (If integrated with core, use quickExpr.exec)
					jQuery.template( null, htmlExpr.test( name ) ? name : jQuery( name )))) : null;
		},

		encode: function( text ) {
			// Do HTML encoding replacing < > & and ' and " by corresponding entities.
			return ("" + text).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;");
		}
	});

	jQuery.extend( jQuery.tmpl, {
		tag: {
			"tmpl": {
				_default: { $2: "null" },
				open: "if($notnull_1){_=_.concat($item.nest($1,$2));}"
				// tmpl target parameter can be of type function, so use $1, not $1a (so not auto detection of functions)
				// This means that {{tmpl foo}} treats foo as a template (which IS a function).
				// Explicit parens can be used if foo is a function that returns a template: {{tmpl foo()}}.
			},
			"wrap": {
				_default: { $2: "null" },
				open: "$item.calls(_,$1,$2);_=[];",
				close: "call=$item.calls();_=call._.concat($item.wrap(call,_));"
			},
			"each": {
				_default: { $2: "$index, $value" },
				open: "if($notnull_1){$.each($1a,function($2){with(this){",
				close: "}});}"
			},
			"if": {
				open: "if(($notnull_1) && $1a){",
				close: "}"
			},
			"else": {
				_default: { $1: "true" },
				open: "}else if(($notnull_1) && $1a){"
			},
			"html": {
				// Unecoded expression evaluation.
				open: "if($notnull_1){_.push($1a);}"
			},
			"=": {
				// Encoded expression evaluation. Abbreviated form is ${}.
				_default: { $1: "$data" },
				open: "if($notnull_1){_.push($.encode($1a));}"
			},
			"!": {
				// Comment tag. Skipped by parser
				open: ""
			}
		},

		// This stub can be overridden, e.g. in jquery.tmplPlus for providing rendered events
		complete: function( items ) {
			newTmplItems = {};
		},

		// Call this from code which overrides domManip, or equivalent
		// Manage cloning/storing template items etc.
		afterManip: function afterManip( elem, fragClone, callback ) {
			// Provides cloned fragment ready for fixup prior to and after insertion into DOM
			var content = fragClone.nodeType === 11 ?
				jQuery.makeArray(fragClone.childNodes) :
				fragClone.nodeType === 1 ? [fragClone] : [];

			// Return fragment to original caller (e.g. append) for DOM insertion
			callback.call( elem, fragClone );

			// Fragment has been inserted:- Add inserted nodes to tmplItem data structure. Replace inserted element annotations by jQuery.data.
			storeTmplItems( content );
			cloneIndex++;
		}
	});

	//========================== Private helper functions, used by code above ==========================

	function build( tmplItem, nested, content ) {
		// Convert hierarchical content into flat string array
		// and finally return array of fragments ready for DOM insertion
		var frag, ret = content ? jQuery.map( content, function( item ) {
			return (typeof item === "string") ?
				// Insert template item annotations, to be converted to jQuery.data( "tmplItem" ) when elems are inserted into DOM.
				(tmplItem.key ? item.replace( /(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g, "$1 " + tmplItmAtt + "=\"" + tmplItem.key + "\" $2" ) : item) :
				// This is a child template item. Build nested template.
				build( item, tmplItem, item._ctnt );
		}) :
		// If content is not defined, insert tmplItem directly. Not a template item. May be a string, or a string array, e.g. from {{html $item.html()}}.
		tmplItem;
		if ( nested ) {
			return ret;
		}

		// top-level template
		ret = ret.join("");

		// Support templates which have initial or final text nodes, or consist only of text
		// Also support HTML entities within the HTML markup.
		ret.replace( /^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/, function( all, before, middle, after) {
			frag = jQuery( middle ).get();

			storeTmplItems( frag );
			if ( before ) {
				frag = unencode( before ).concat(frag);
			}
			if ( after ) {
				frag = frag.concat(unencode( after ));
			}
		});
		return frag ? frag : unencode( ret );
	}

	function unencode( text ) {
		// Use createElement, since createTextNode will not render HTML entities correctly
		var el = document.createElement( "div" );
		el.innerHTML = text;
		return jQuery.makeArray(el.childNodes);
	}

	// Generate a reusable function that will serve to render a template against data
	function buildTmplFn( markup ) {
		return new Function("jQuery","$item",
			"var $=jQuery,call,_=[],$data=$item.data;" +

			// Introduce the data as local variables using with(){}
			"with($data){_.push('" +

			// Convert the template into pure JavaScript
			jQuery.trim(markup)
				.replace( /([\\'])/g, "\\$1" )
				.replace( /[\r\t\n]/g, " " )
				.replace( /\$\{([^\}]*)\}/g, "{{= $1}}" )
				.replace( /\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,
				function( all, slash, type, fnargs, target, parens, args ) {
					var tag = jQuery.tmpl.tag[ type ], def, expr, exprAutoFnDetect;
					if ( !tag ) {
						throw "Template command not found: " + type;
					}
					def = tag._default || [];
					if ( parens && !/\w$/.test(target)) {
						target += parens;
						parens = "";
					}
					if ( target ) {
						target = unescape( target );
						args = args ? ("," + unescape( args ) + ")") : (parens ? ")" : "");
						// Support for target being things like a.toLowerCase();
						// In that case don't call with template item as 'this' pointer. Just evaluate...
						expr = parens ? (target.indexOf(".") > -1 ? target + parens : ("(" + target + ").call($item" + args)) : target;
						exprAutoFnDetect = parens ? expr : "(typeof(" + target + ")==='function'?(" + target + ").call($item):(" + target + "))";
					} else {
						exprAutoFnDetect = expr = def.$1 || "null";
					}
					fnargs = unescape( fnargs );
					return "');" +
						tag[ slash ? "close" : "open" ]
							.split( "$notnull_1" ).join( target ? "typeof(" + target + ")!=='undefined' && (" + target + ")!=null" : "true" )
							.split( "$1a" ).join( exprAutoFnDetect )
							.split( "$1" ).join( expr )
							.split( "$2" ).join( fnargs ?
								fnargs.replace( /\s*([^\(]+)\s*(\((.*?)\))?/g, function( all, name, parens, params ) {
									params = params ? ("," + params + ")") : (parens ? ")" : "");
									return params ? ("(" + name + ").call($item" + params) : all;
								})
								: (def.$2||"")
							) +
						"_.push('";
				}) +
			"');}return _;"
		);
	}
	function updateWrapped( options, wrapped ) {
		// Build the wrapped content.
		options._wrap = build( options, true,
			// Suport imperative scenario in which options.wrapped can be set to a selector or an HTML string.
			jQuery.isArray( wrapped ) ? wrapped : [htmlExpr.test( wrapped ) ? wrapped : jQuery( wrapped ).html()]
		).join("");
	}

	function unescape( args ) {
		return args ? args.replace( /\\'/g, "'").replace(/\\\\/g, "\\" ) : null;
	}
	function outerHtml( elem ) {
		var div = document.createElement("div");
		div.appendChild( elem.cloneNode(true) );
		return div.innerHTML;
	}

	// Store template items in jQuery.data(), ensuring a unique tmplItem data data structure for each rendered template instance.
	function storeTmplItems( content ) {
		var keySuffix = "_" + cloneIndex, elem, elems, newClonedItems = {}, i, l, m;
		for ( i = 0, l = content.length; i < l; i++ ) {
			if ( (elem = content[i]).nodeType !== 1 ) {
				continue;
			}
			elems = elem.getElementsByTagName("*");
			for ( m = elems.length - 1; m >= 0; m-- ) {
				processItemKey( elems[m] );
			}
			processItemKey( elem );
		}
		function processItemKey( el ) {
			var pntKey, pntNode = el, pntItem, tmplItem, key;
			// Ensure that each rendered template inserted into the DOM has its own template item,
			if ( (key = el.getAttribute( tmplItmAtt ))) {
				while ( pntNode.parentNode && (pntNode = pntNode.parentNode).nodeType === 1 && !(pntKey = pntNode.getAttribute( tmplItmAtt ))) { }
				if ( pntKey !== key ) {
					// The next ancestor with a _tmplitem expando is on a different key than this one.
					// So this is a top-level element within this template item
					// Set pntNode to the key of the parentNode, or to 0 if pntNode.parentNode is null, or pntNode is a fragment.
					pntNode = pntNode.parentNode ? (pntNode.nodeType === 11 ? 0 : (pntNode.getAttribute( tmplItmAtt ) || 0)) : 0;
					if ( !(tmplItem = newTmplItems[key]) ) {
						// The item is for wrapped content, and was copied from the temporary parent wrappedItem.
						tmplItem = wrappedItems[key];
						tmplItem = newTmplItem( tmplItem, newTmplItems[pntNode]||wrappedItems[pntNode], null, true );
						tmplItem.key = ++itemKey;
						newTmplItems[itemKey] = tmplItem;
					}
					if ( cloneIndex ) {
						cloneTmplItem( key );
					}
				}
				el.removeAttribute( tmplItmAtt );
			} else if ( cloneIndex && (tmplItem = jQuery.data( el, "tmplItem" )) ) {
				// This was a rendered element, cloned during append or appendTo etc.
				// TmplItem stored in jQuery data has already been cloned in cloneCopyEvent. We must replace it with a fresh cloned tmplItem.
				cloneTmplItem( tmplItem.key );
				newTmplItems[tmplItem.key] = tmplItem;
				pntNode = jQuery.data( el.parentNode, "tmplItem" );
				pntNode = pntNode ? pntNode.key : 0;
			}
			if ( tmplItem ) {
				pntItem = tmplItem;
				// Find the template item of the parent element.
				// (Using !=, not !==, since pntItem.key is number, and pntNode may be a string)
				while ( pntItem && pntItem.key != pntNode ) {
					// Add this element as a top-level node for this rendered template item, as well as for any
					// ancestor items between this item and the item of its parent element
					pntItem.nodes.push( el );
					pntItem = pntItem.parent;
				}
				// Delete content built during rendering - reduce API surface area and memory use, and avoid exposing of stale data after rendering...
				delete tmplItem._ctnt;
				delete tmplItem._wrap;
				// Store template item as jQuery data on the element
				jQuery.data( el, "tmplItem", tmplItem );
			}
			function cloneTmplItem( key ) {
				key = key + keySuffix;
				tmplItem = newClonedItems[key] =
					(newClonedItems[key] || newTmplItem( tmplItem, newTmplItems[tmplItem.parent.key + keySuffix] || tmplItem.parent, null, true ));
			}
		}
	}

	//---- Helper functions for template item ----

	function tiCalls( content, tmpl, data, options ) {
		if ( !content ) {
			return stack.pop();
		}
		stack.push({ _: content, tmpl: tmpl, item:this, data: data, options: options });
	}

	function tiNest( tmpl, data, options ) {
		// nested template, using {{tmpl}} tag
		return jQuery.tmpl( jQuery.template( tmpl ), data, options, this );
	}

	function tiWrap( call, wrapped ) {
		// nested template, using {{wrap}} tag
		var options = call.options || {};
		options.wrapped = wrapped;
		// Apply the template, which may incorporate wrapped content,
		return jQuery.tmpl( jQuery.template( call.tmpl ), call.data, options, call.item );
	}

	function tiHtml( filter, textOnly ) {
		var wrapped = this._wrap;
		return jQuery.map(
			jQuery( jQuery.isArray( wrapped ) ? wrapped.join("") : wrapped ).filter( filter || "*" ),
			function(e) {
				return textOnly ?
					e.innerText || e.textContent :
					e.outerHTML || outerHtml(e);
			});
	}

	function tiUpdate() {
		var coll = this.nodes;
		jQuery.tmpl( null, null, null, this).insertBefore( coll[0] );
		jQuery( coll ).remove();
	}
})( jQuery );

/*
 * jQuery 2d Transform
 * http://wiki.github.com/heygrady/transform/
 *
 * Copyright 2010, Grady Kuhnline
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 */
(function(f,g,i,b){var c=180/Math.PI;var j=200/Math.PI;var e=Math.PI/180;var d=2/1.8;var h=0.9;var a=Math.PI/200;f.extend({angle:{runit:/(deg|g?rad)/,radianToDegree:function(k){return k*c},radianToGrad:function(k){return k*j},degreeToRadian:function(k){return k*e},degreeToGrad:function(k){return k*d},gradToDegree:function(k){return k*h},gradToRadian:function(k){return k*a}}})})(jQuery,this,this.document);(function(f,e,b,g){var c=/progid:DXImageTransform\.Microsoft\.Matrix\(.*?\)/;f.extend({transform:function(h){h.transform=this;this.$elem=f(h);this.transformProperty=this.getTransformProperty();this.applyingMatrix=false;this.matrix=null;this.height=null;this.width=null;this.outerHeight=null;this.outerWidth=null;this.boxSizingValue=null;this.boxSizingProperty=null;this.attr=null}});f.extend(f.transform,{funcs:["matrix","origin","reflect","reflectX","reflectXY","reflectY","rotate","scale","scaleX","scaleY","skew","skewX","skewY","translate","translateX","translateY"],rfunc:{angle:/^rotate|skew[X|Y]?$/,length:/^origin|translate[X|Y]?$/,scale:/^scale[X|Y]?$/,reflect:/^reflect(XY|X|Y)?$/}});f.fn.transform=function(h,i){return this.each(function(){var j=this.transform||new f.transform(this);if(h){j.exec(h,i)}})};f.transform.prototype={exec:function(h,i){var j=this.transformProperty;i=f.extend(true,{forceMatrix:false,preserve:false},i);this.attr=null;if(i.preserve){h=f.extend(true,this.getAttrs(true,true),h)}else{h=f.extend(true,{},h)}this.setAttrs(h);if(j&&!i.forceMatrix){return this.execFuncs(h)}else{if(f.browser.msie||(j&&i.forceMatrix)){return this.execMatrix(h)}}return false},execFuncs:function(i){var h=[];var k=this.transformProperty;for(var j in i){if(j=="origin"){this[j].apply(this,f.isArray(i[j])?i[j]:[i[j]])}else{if(f.inArray(j,f.transform.funcs)!=-1){h.push(this.createTransformFunc(j,i[j]))}}}this.$elem.css(k,h.join(" "));return true},execMatrix:function(l){var r,j=this.transformProperty,h;var p=function(C,m){h[C]=parseFloat(m)};for(var i in l){if(f.matrix[i]||i=="matrix"){h=f.isArray(l[i])?l[i]:[l[i]];f.each(h,p);var q;if(i=="matrix"){q=new f.matrix.M2x2(h[0],h[1],h[2],h[3]);if(h[4]){this.setAttr("translateX",h[4])}if(h[5]){this.setAttr("translateY",h[5])}}else{q=f.matrix[i].apply(this,h)}if(!r){r=q}else{r=r.x(q)}}else{if(i=="origin"){h=f.isArray(l[i])?l[i]:[l[i]];this[i].apply(this,h)}}}var n=this.getAttr("translate")||0,B=this.getAttr("translateX")||0,A=this.getAttr("translateY")||0;if(!f.isArray(n)){n=[n,0]}if(!r){r=new f.matrix.M2x2(1,0,0,1)}var y=parseFloat(parseFloat(r.e(1,1)).toFixed(8)),w=parseFloat(parseFloat(r.e(2,1)).toFixed(8)),v=parseFloat(parseFloat(r.e(1,2)).toFixed(8)),u=parseFloat(parseFloat(r.e(2,2)).toFixed(8)),z=0,x=0;if(n[0]||n[1]||B||A){var o=r.x(new f.matrix.V2(parseFloat(n[0])+parseFloat(B),parseFloat(n[1])+parseFloat(A)));z=parseFloat(parseFloat(o.e(1)).toFixed(8));x=parseFloat(parseFloat(o.e(2)).toFixed(8))}if(j&&j.substr(0,4)=="-moz"){this.$elem.css(j,"matrix("+y+", "+w+", "+v+", "+u+", "+z+"px, "+x+"px)")}else{if(j){this.$elem.css(j,"matrix("+y+", "+w+", "+v+", "+u+", "+z+", "+x+")")}else{if(jQuery.browser.msie){var s=this.$elem[0].style;var t="progid:DXImageTransform.Microsoft.Matrix(M11="+y+", M12="+v+", M21="+w+", M22="+u+", sizingMethod='auto expand')";var k=s.filter||jQuery.curCSS(this.$elem[0],"filter")||"";s.filter=c.test(k)?k.replace(c,t):k?k+" "+t:t;this.applyingMatrix=true;this.matrix=r;this.fixPosition(r,z,x);this.applyingMatrix=false;this.matrix=null}}}return true},origin:function(i,l){var k=this.transformProperty,h=this.safeOuterHeight(),j=this.safeOuterWidth();switch(i){case"left":i="0";break;case"right":i=j;break;case"center":i=j*0.5;break}switch(l){case"top":l="0";break;case"bottom":l=h;break;case"center":case g:l=h*0.5;break}i=/%/.test(i)?j*parseFloat(i)/100:parseFloat(i);if(typeof(l)!=="undefined"){l=/%/.test(l)?h*parseFloat(l)/100:parseFloat(l)}if(k){if(!l&&l!==0){this.$elem.css(k+"-origin",i+"px")}else{this.$elem.css(k+"-origin",i+"px "+l+"px")}}if(!l&&l!==0){this.setAttr("origin",i)}else{this.setAttr("origin",[i,l])}return true},getTransformProperty:function(){if(this.transformProperty){return this.transformProperty}var h=b.body;var i={transform:"transform",MozTransform:"-moz-transform",WebkitTransform:"-webkit-transform",OTransform:"-o-transform"};for(var j in i){if(typeof h.style[j]!="undefined"){this.transformProperty=i[j];return i[j]}}return null},createTransformFunc:function(k,l){if(f.transform.rfunc.reflect.test(k)){var j=l?f.matrix[k]():f.matrix.empty(),i=j.e(1,1),h=j.e(2,1),n=j.e(1,2),m=j.e(2,2);return"matrix("+i+", "+h+", "+n+", "+m+", 0, 0)"}l=d(k,l);if(!f.isArray(l)){return k+"("+l+")"}else{if(k=="matrix"){return"matrix("+l[0]+", "+l[1]+", "+l[2]+", "+l[3]+", "+(l[4]||0)+", "+(l[5]||0)+")"}else{return k+"("+l[0]+", "+l[1]+")"}}},fixPosition:function(q,n,m,s,h){var l=new f.matrix.calc(q,this.safeOuterHeight(),this.safeOuterWidth()),r=this.getAttr("origin");var k=l.originOffset({x:parseFloat(r[0]),y:parseFloat(r[1])});var i=l.sides();var j=this.$elem.css("position");if(j=="static"){j="relative"}var p={top:0,left:0};var o={position:j,top:(k.top+m+i.top+p.top)+"px",left:(k.left+n+i.left+p.left)+"px",zoom:1};this.$elem.css(o)}};var a=/^([\+\-]=)?([\d+.\-]+)(.*)$/;function d(j,o){var q=!f.isArray(o)?[o]:o,h=f.transform.rfunc.angle,p=f.transform.rfunc.length;for(var l=0,m=q.length;l<m;l++){var k=a.exec(q[l]),n="";if(h.test(j)){n="deg";if(k[3]&&!f.angle.runit.test(k[3])){k[3]=null}}else{if(p.test(j)){n="px"}}if(!k){q[l]=0+n}else{if(!k[3]){q[l]+=n}}}return m==1?q[0]:q}})(jQuery,this,this.document);(function(d,c,a,f){d.extend(d.transform.prototype,{safeOuterHeight:function(){return this.safeOuterLength("height")},safeOuterWidth:function(){return this.safeOuterLength("width")},safeOuterLength:function(l){var o="outer"+(l=="width"?"Width":"Height");if(d.browser.msie){l=l=="width"?"width":"height";if(this.applyingMatrix&&!this[o]&&this.matrix){var k=new d.matrix.calc(this.matrix,1,1),m=k.size(),g=this.$elem[o]()/m[l];this[o]=g;return g}else{if(this.applyingMatrix&&this[o]){return this[o]}}var n={height:["top","bottom"],width:["left","right"]};var h=this.$elem[0],j=parseFloat(d.curCSS(h,l,true)),p=this.boxSizingProperty,i=this.boxSizingValue;if(!this.boxSizingProperty){p=this.boxSizingProperty=e()||"box-sizing";i=this.boxSizingValue=this.$elem.css(p)||"content-box"}if(this[o]&&this[l]==j){return this[o]}else{this[l]=j}if(p&&(i=="padding-box"||i=="content-box")){j+=parseFloat(d.curCSS(h,"padding-"+n[l][0],true))||0+parseFloat(d.curCSS(h,"padding-"+n[l][1],true))||0}if(p&&i=="content-box"){j+=parseFloat(d.curCSS(h,"border-"+n[l][0]+"-width",true))||0+parseFloat(d.curCSS(h,"border-"+n[l][1]+"-width",true))||0}this[o]=j;return j}return this.$elem[o]()}});var b=null;function e(){if(b){return b}var h={boxSizing:"box-sizing",MozBoxSizing:"-moz-box-sizing",WebkitBoxSizing:"-webkit-box-sizing",OBoxSizing:"-o-box-sizing"},g=a.body;for(var i in h){if(typeof g.style[i]!="undefined"){b=h[i];return b}}return null}})(jQuery,this,this.document);(function(c,d,g,b){var h=/(origin|matrix|reflect(X|XY|Y)?|rotate|scale[XY]?|skew[XY]?|translate[XY]?)\((.*?)\)/g,f=/^origin|matrix|reflect(XY|[XY])?|rotate|scale[XY]?|skew[XY]?|translate[XY]?$/,e="data-transform",i=/\s/,a=/,\s/;c.extend(c.transform.prototype,{setAttrs:function(j){var k="",m;for(var l in j){if(f.test(l)){m=j[l];if(c.isArray(m)){m=m.join(", ")}k+=" "+l+"("+m+")"}}this.attr=c.trim(k);this.$elem.attr(e,this.attr)},setAttr:function(p,q){if(!f.test(p)){return}if(c.isArray(q)){q=q.join(", ")}q=c.trim(q);var n=this.attr||this.$elem.attr(e);if(!n){this.attr=q;this.$elem.attr(e,this.attr)}else{if(n.indexOf(p)>-1){this.attr=n+" "+q;this.$elem.attr(e,this.attr)}}var m=[],j,r;h.exec("");while((j=h.exec(n))!==null){m.push(j[0])}for(var o=0,k=m.length;o<k;o++){h.exec("");r=h.exec(m[o]);if(p==r[1]){m[o]=q;break}}this.attr=m.join(" ");this.$elem.attr(e,this.attr)},getAttrs:function(){var o=this.attr||this.$elem.attr(e);if(!o){return{}}var m=[],n={},j,r,q;h.exec("");while((j=h.exec(o))!==null){m.push(j[0])}for(var p=0,k=m.length;p<k;p++){h.exec("");r=h.exec(m[p]);if(r&&f.test(r[1])){q=r[3].split(a);n[r[1]]=q.length==1?q[0]:q}}return n},getAttr:function(k){if(!f.test(k)){return null}var j=this.attr||this.$elem.attr(e);var s=c.transform.rfunc.scale;if(k!="origin"&&k!="matrix"&&(!j||j.indexOf(k)===-1)){return s.test(k)?1:null}var r=[],t,n,p=null;h.exec("");while((t=h.exec(j))!==null){r.push(t[0])}for(var o=0,m=r.length;o<m;o++){h.exec("");n=h.exec(r[o]);if(k==n[1]){p=n[3].split(a);return p.length==1?p[0]:p}}if(k=="origin"){var q=/%/;p=this.transformProperty?this.$elem.css(this.transformProperty+"-origin"):[this.safeOuterWidth()*0.5,this.safeOuterHeight()*0.5];p=c.isArray(p)?p:p.split(i);if(q.test(p[0])){if(q.test(p[0])){p[0]=this.safeOuterWidth()*(parseFloat(p[0])/100)}if(q.test(p[1])){p[1]=this.safeOuterHeight()*(parseFloat(p[1])/100)}}}else{if(k=="matrix"){p=[1,0,0,1,0,0]}else{if(s.test(k)){p=1}}}return c.isArray(p)&&p.length==1?p[0]:p}})})(jQuery,this,this.document);(function(c,b,a,d){c.extend({matrix:{}});c.extend(c.matrix,{calc:function(e,f,g){this.matrix=e;this.outerHeight=f;this.outerWidth=g},V2:function(e,f){this.elements=[e,f]},M2x2:function(f,e,h,g){this.elements=[f,e,h,g]},empty:function(){return new c.matrix.M2x2(1,0,0,1)},reflect:function(){return new c.matrix.M2x2(-1,0,0,-1)},reflectX:function(){return new c.matrix.M2x2(1,0,0,-1)},reflectXY:function(){return new c.matrix.M2x2(0,1,1,0)},reflectY:function(){return new c.matrix.M2x2(-1,0,0,1)},rotate:function(i){var f=c.angle.degreeToRadian(i),h=Math.cos(f),j=Math.sin(f);var g=h,e=j,l=-j,k=h;return new c.matrix.M2x2(g,l,e,k)},scale:function(f,e){f=f||f===0?f:1;e=e||e===0?e:f;return new c.matrix.M2x2(f,0,0,e)},scaleX:function(e){return c.matrix.scale(e,1)},scaleY:function(e){return c.matrix.scale(1,e)},skew:function(h,f){h=h||0;f=f||0;var i=c.angle.degreeToRadian(h),g=c.angle.degreeToRadian(f),e=Math.tan(i),j=Math.tan(g);return new c.matrix.M2x2(1,e,j,1)},skewX:function(e){return c.matrix.skew(e)},skewY:function(e){return c.matrix.skew(0,e)}});c.matrix.calc.prototype={coord:function(e,h){var g=this.matrix,f=g.x(new c.matrix.V2(e,h));return{x:f.e(1),y:f.e(2)}},corners:function(){var f=this.outerHeight,e=this.outerWidth;return{tl:this.coord(0,0),bl:this.coord(0,f),tr:this.coord(e,0),br:this.coord(e,f)}},sides:function(){var f=this.corners();var g={top:0,bottom:0,left:0,right:0},e,i;for(var h in f){e=f[h].x;i=f[h].y;if(i<g.top){g.top=i}if(i>g.bottom){g.bottom=i}if(e<g.left){g.left=e}if(e>g.right){g.right=e}}return g},size:function(){var e=this.sides();return{height:Math.abs(e.bottom-e.top),width:Math.abs(e.right-e.left)}},originOffset:function(h,g){h=h?h:{x:this.outerWidth*0.5,y:this.outerHeight*0.5};g=g?g:{x:0,y:0};var e=this.coord(h.x,h.y);var f=this.coord(g.x,g.y);return{top:(f.y-g.y)-(e.y-h.y),left:(f.x-g.x)-(e.x-h.x)}}};c.matrix.M2x2.prototype={x:function(g){var f=this.elements,e=g.elements;if(e.length==2){return new c.matrix.V2(f[0]*e[0]+f[1]*e[1],f[2]*e[0]+f[3]*e[1])}else{if(e.length==4){return new c.matrix.M2x2(f[0]*e[0]+f[1]*e[2],f[0]*e[1]+f[1]*e[3],f[2]*e[0]+f[3]*e[2],f[2]*e[1]+f[3]*e[3])}}return false},e:function(g,e){var f=0;if(g==1&&e==2){f=1}else{if(g==2&&e==1){f=2}else{if(g==2&&e==2){f=3}}}return this.elements[f]}};c.matrix.V2.prototype={e:function(e){return this.elements[e-1]}}})(jQuery,this,this.document);(function(e,d,b,f){var a=/^([+\-]=)?([\d+.\-]+)(.*)$/;var c=/^(.*?)\s+([+\-]=)?([\d+.\-]+)(.*)$/;var h=e.fn.animate;e.fn.animate=function(m,j,l,k){if(m&&!jQuery.isEmptyObject(m)){var i=this;jQuery.each(m,function(n,o){if(e.inArray(n,e.transform.funcs)!=-1){if(e.transform.rfunc.reflect.test(n)){var p=o?e.matrix[n]():e.matrix.empty(),t=p.elements;o=[t[0],t[1],t[2],t[3]]}var r=a.exec(o);if((r&&r[3])||e.isArray(o)){var q,u,v=[];if(e.isArray(o)){e.each(o,function(w){r=a.exec(this);q=parseFloat(r[2]);u=r[3]||"px";v.push({end:(r[1]?r[1]:"")+q,unit:u})})}else{q=parseFloat(r[2]);u=r[3]||"px";v.push({end:(r[1]?r[1]:"")+q,unit:u});var s=0;while(r=c.exec(u)){v[s].unit=r[1];v.push({end:(r[2]?r[2]:"")+parseFloat(r[3]),unit:r[4]});u=r[4];s++}}i.data("data-animate-"+n,v);m[n]=v[0].end}}})}return h.apply(this,arguments)};var g=e.fx.prototype.cur;e.fx.prototype.cur=function(k){if(e.inArray(this.prop,e.transform.funcs)!=-1){this.transform=this.transform||this.elem.transform||new e.transform(this.elem);var i=e.transform.rfunc;var j=this.transform.getAttr(this.prop),l=a.exec(e.isArray(j)?j[0]:j);if(j===null||l===null){j=i.scale.test(this.prop)||i.reflect.test(this.prop)?1:0;l=[null,null,j]}return parseFloat(l[2])}return g.apply(this,arguments)};e.fx.multivalueInit=function(l){var j=e(l.elem),i=l.transform.getAttr(l.prop),k=j.data("data-animate-"+l.prop);if(k){j.removeData("data-animate-"+l.prop)}if(e.transform.rfunc.reflect.test(l.prop)){i=l.transform.getAttr("matrix")}l.values=[];if(e.isArray(i)&&!e.isArray(k)){k=[{end:parseFloat(l.end),unit:l.unit},{end:e.transform.rfunc.scale.test(l.prop)?1:0,unit:l.unit}]}if(k){var o,n=e.transform.rfunc.scale,m;e.each(k,function(p,q){if(e.isArray(i)){o=i[p]}else{if(p>0){o=n.test(l.prop)?i:null}else{o=i}}if(!o&&o!==0){o=n.test(l.prop)?1:0}o=parseFloat(o);m=a.exec(q.end);if(m&&m[1]){q.end=((m[1]==="-="?-1:1)*parseFloat(m[2]))+o}l.values.push({start:parseFloat(o),end:parseFloat(q.end),unit:q.unit})})}else{l.values.push({start:parseFloat(l.start),end:parseFloat(l.end),unit:l.unit})}};e.fx.multivalueStep={_default:function(i){e.each(i.values,function(j,k){i.values[j].now=k.start+((k.end-k.start)*i.pos)})}};e.each(e.transform.funcs,function(j,k){e.fx.step[k]=function(n){if(!n.transformInit){n.transform=n.transform||n.elem.transform||new e.transform(n.elem);e.fx.multivalueInit(n);if(n.values.length>1){n.multiple=true}var m=e.transform.rfunc;if(m.angle.test(n.prop)){n.unit="deg"}else{if(m.scale.test(n.prop)){n.unit=""}else{if(m.reflect.test(n.prop)){n.unit=""}else{if(n.prop=="matrix"){n.unit=""}}}}e.each(n.values,function(p){n.values[p].unit=n.unit});n.transformInit=true}if(n.multiple){(e.fx.multivalueStep[n.prop]||e.fx.multivalueStep._default)(n)}else{n.values[0].now=n.now}var l=[];e.each(n.values,function(p,q){if(q.unit=="deg"){while(q.now>=360){q.now-=360}while(q.now<=-360){q.now+=360}}l.push(parseFloat(parseFloat(q.now).toFixed(8))+q.unit)});var i={},o=e.transform.rfunc.reflect.test(n.prop)?"matrix":n.prop;i[o]=n.multiple?l:l[0];n.transform.exec(i,{preserve:true})}})})(jQuery,this,this.document);


// t: current time, b: begInnIng value, c: change In value, d: duration
$.easing.jswing = $.easing.swing;

$.extend($.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert($.easing.default);
		return $.easing[$.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;if ((t/=d)==1) return b+c;if (!p) p=d*.3;
		if (a < Math.abs(c)) {a=c;var s=p/4;}
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;if ((t/=d)==1) return b+c;if (!p) p=d*.3;
		if (a < Math.abs(c)) {a=c;var s=p/4;}
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;if ((t/=d/2)==2) return b+c;if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) {a=c;var s=p/4;}
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});
 

/*
 * jQuery history plugin
 *
 * sample page: http://www.serpere.info/jquery-history-plugin/samples/
 *
 * Copyright (c) 2006-2009 Taku Sano (Mikage Sawatari)
 * Copyright (c) 2010 Takayuki Miwa
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Modified by Lincoln Cooper to add Safari support and only call the callback once during initialization
 * for msie when no initial hash supplied.
 */

(function($) {
	var prev = false;

    var locationWrapper = {
        put: function(hash, win) {
        	prev = true;
            (win || window).location.hash = hash;
        },
        get: function(win) {
        	var w = (win || window),
            	hash = (w.location.hash).replace(/^#/, '');

            if (prev && (w.location.toString() == $.base) && (hash == '')) hash = 'index';
            return $.browser.fx ? hash : hash;
        }
    };

    var iframeWrapper = {
        id: "__jQuery_history",
        init: function() {
            var html = '<iframe id="'+ this.id +'" style="display:none" src="javascript:false;" />';
            $("body").prepend(html);
            return this;
        },
        _document: function() {
            return $("#"+ this.id)[0].contentWindow.document;
        },
        put: function(hash) {
            var doc = this._document();
            doc.open();
            doc.close();
            locationWrapper.put(hash, doc);
        },
        get: function() {
            return locationWrapper.get(this._document());
        }
    };

    // public base interface
    var _ = {
        appState: undefined,
        callback: undefined,
        init:  function(callback) {},
        check: function() {},
        load:  function(hash) {},
		back: true,
        setTitle: function(title) {window.document.title = title || ' ';}
    };
    $.history = _;

    var SimpleImpl = {
        init: function(callback) {
            _.callback = callback;
            var current_hash = locationWrapper.get();
            _.appState = current_hash;
            _.callback(current_hash);
            setInterval(_.check, 100);
        },
        check: function() {
            var current_hash = locationWrapper.get();
            if(current_hash != _.appState) {
                _.appState = current_hash;
                _.callback(current_hash);
            }
        },
        load: function(hash) {
            //if(hash != _.appState) {
                locationWrapper.put(hash);
                _.appState = hash;
                _.callback(hash);
            //}
        }
    };

    var IframeImpl = {
        init: function(callback) {
            _.callback = callback;
            var current_hash = locationWrapper.get();
            _.appState = current_hash;
            iframeWrapper.init().put(current_hash);
            _.callback(current_hash);
            setInterval(_.check, 100);
        },
        check: function() {
            var current_hash = iframeWrapper.get();
            if(current_hash != _.appState) {
                locationWrapper.put(current_hash);
                _.appState = current_hash;
                _.callback(current_hash);
            }
        },
        load: function(hash) {
            //if(hash != _.appState) {
                locationWrapper.put(hash);
                iframeWrapper.put(hash);
                _.appState = hash;
                _.callback(hash);
            //}
        }
    };

    if($.browser.msie && ($.browser.version < 8 || document.documentMode < 8)) {
        $.extend(_, IframeImpl);
    } else {
        $.extend(_, SimpleImpl);
    }
})(jQuery);



$.frontendValidator = {

	_digit: function() {
		$(this).val($(this).val().replace(/[^0-9]/gi,""));
	},

	_instantRequest: function() {
		$(this).parents("form").submit();
	},

	_instantRequestFocus: function() {
		$.WBValidatorTempTextFocus = $(this).val();
	},

	_instantRequestBlur: function() {
		if ($.WBValidatorTempTextFocus != $(this).val()) $(this).parents("form").submit();
		$.WBValidatorTempTextFocus;
	},

	init: function(el) {
		var fv = this;
		var filter = "";

		if (typeof el != "undefined") filter = "#" + el.attr("id") + " ";

		$(filter + ".digitValidator")
			.unbind("keyup", fv._digit)
			.bind("keyup", fv._digit);

		$(filter + ".instantRequest").each(function() {
			$this = $(this);

			if ($this.attr("type") == "text") {
				$.WBValidatorTempTextFocus = "";
				$this.unbind("focus", fv._instantRequestFocus).bind("focus", fv._instantRequestFocus);
				$this.unbind("blur", fv._instantRequestBlur).bind("blur", fv._instantRequestBlur);
			} else {
				$this.unbind("change", fv._instantRequest).bind("change", fv._instantRequest);
			}



		});
	}

};



/* WB TAG Plugin */
$.wbTags = {
	add_tag: function () {

		var $ct = $("textarea", "#mainContent");
		var str = $(this).attr("lang");

		var selection = "";
		var value = $ct.val();
		var range = $ct.getSelection();
		var before = value.substring(0, range.start);
		var after = value.substring(range.end, value.length);

		if (str == "youtube") {
			var trailing = "";

			if (range.text.length <= 0) {
				selection = prompt("Adja meg a Youtube videó url-jét vagy embed kódját!","http://");
			} else {
				if (range.text[range.length-1] == " ") {
					range.text = range.text.substring(0, range.length-1);
					trailing = " ";
				}
				selection = range.text;
			}

			var urls = selection.match(/[\\?\\&]v=([^\\?\\&]+)|embed\/([A-Za-z-0-9_]*)|(\/v\/)([a-zA-Z-0-9_]*)|v=[a-zA-Z-0-9_]*/gi), url, unique = {};
			var html = '';

			if (urls) {
				for (var i=0,l=urls.length; i<l; i++) {
					url = $.trim(urls[i].replace(/embed\/|\?v=|\/v\/|&v=|v=/gi, ''));
					if (url=='') continue;

					if (unique[url]) continue;
					unique[url] = true;

					if (before != '') html += '\n';
					html += "[youtube=" + url + "]Videó megtekintése a Youtube-on[/youtube]\n";
				}

				$ct.val(before + html + trailing + after);
			}

		} else if ((range.text.length > 0) || (str != "img" && str != "url")) {
			if ((str == "url" || str == "img") && range.text.substr(0,7) != "http://" ) {
				range.text = "http://" + range.text;
			}
			var trailing = "";
			if (range.text[range.length-1] == " ") {
				range.text = range.text.substring(0, range.length-1);
				trailing = " ";
			}
    		var selection = "["+str+"]" + range.text + "[/"+str+"]";
			$ct.val(before + selection + trailing + after);
		} else if (str == "url") {
			if (selection = prompt("Adja meg az url-t!","http://")) {
				var title = prompt("Mi található a linken?") || 'link';
				$ct.val(before + "[url=" + selection + "]"+title+"[/url] " + after);
			}
		} else if (str == "img") {
			if (selection = prompt("Adja meg az kép url-t!","http://")) {
				$ct.val(before + "[img]" + selection + "[/img] " + after);
			}
		}

		return false;
	},

	html_to_BBCode: function (s) {
		s = $.trim(s);

		function rep(re, str) {
			s = s.replace(re, str);
		};

		rep(/\r\n|\n\r|\r|\n/gi,"");
		rep(/<a.*?href=\"#comment_(.*?)\".*?>@(.*?)<\/a>/gi,"[valasz=$1]$2[/valasz]");
		rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
		rep(/<a.*?class=\"WBYoutubeComment\".*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[youtube=$1]$2[/youtube]");
		rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
		rep(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
		rep(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
		rep(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
		rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]");
		rep(/<font>(.*?)<\/font>/gi,"$1");
		rep(/<img.*?src=\"(.*?)\".*?>/gi,"[img]$1[/img]");
		rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");
		rep(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]");
		rep(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]");
		rep(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]");
		rep(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]");
		rep(/<em class=\"codeStyle\">(.*?)<\/em>/gi,"[code][i]$1[/i][/code]");
		rep(/<em class=\"quoteStyle\">(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]");
		rep(/<u class=\"codeStyle\">(.*?)<\/u>/gi,"[code][u]$1[/u][/code]");
		rep(/<u class=\"quoteStyle\">(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]");
		rep(/<\/(strong|b)>/gi,"[/b]");
		rep(/<(strong|b)>/gi,"[b]");
		rep(/<\/(em|i)>/gi,"[/i]");
		rep(/<(em|i)>/gi,"[i]");
		rep(/<\/u>/gi,"[/u]");
		rep(/<u>/gi,"[u]");
		rep(/<br \/>/gi,"\n");
		rep(/<br\/>/gi,"\n");
		rep(/<br>/gi,"\n");
		rep(/<p>/gi,"");
		rep(/<\/p>/gi,"\n");
		rep(/&nbsp;/gi," ");
		rep(/&quot;/gi,"\"");
		rep(/&lt;/gi,"<");
		rep(/&gt;/gi,">");
		rep(/&amp;/gi,"&");
		rep(/&undefined;/gi,"'"); // quickfix

		var $t = $('<div>'+s+'</div>');

		$t.find('.WBYoutubeCommentEmbed').each(function() {
			var $this = $(this);
			$this.replaceWith('[youtube='+$this.attr('rel')+']Videó megtekintése a Youtube-on[/youtube]');
		});

		s = $t.html();

		return s;
	}
}

/* WB Comment System */
$(function() {
	var lock = false,
		$c, $form, $submit, $caption, $replyinput, $textarea, $container;

	$.wbComments = {

		init: function() {
			$c = $("#widget_comments");
			if ($c.length == 0) return;

			$container = $c.find('.widget_comment_container');
			$form = $c.find("form");
			$submit = $form.find('input[type=submit]');
			$caption = $c.find(".widget_comment_caption");
			$replyinput = $form.find("input[name=replyto]");
			$textarea = $form.find("textarea");

			$c.find("form").submit(this.add).end()
			  .find("a.widget_comment_reply")	.die().live("click", this.reply).end()
			  .find("a.widget_comment_modify")	.die().live("click", this.modify).end()
			  .find("a.widget_comment_remove")	.die().live("click", this.remove).end()
			  .find("a.widget_comment_moderate").die().live("click", this.moderate).end()
			  .find("a.widget_comment_tag")		.die().live("click", $.wbTags.add_tag).end();
		},

		add: function() {
			if (lock || ($.trim($textarea.val()) == '')) return false;

			$submit.attr("disabled", true);
			lock = true;

			setTimeout(function() {
				lock = false;
				$submit.attr("disabled", false);
			}, 10000);

			$.wbComments.show_message("Kérjük várjon!");

			var $last = $container.children().last();

			$.ajax({
				type: 'post',
				url: $form.attr('action'),
				data: $form.serialize() + "&ajax=true&lastRank=" + ($last.length ? $last.attr('wb:rank') : 0),
				dataType: "html",
				complete: function (data) {
					$.wbComments.hide_message();

					if ($form.attr('action').search("modify") >= 0) $.wbComments.refresh();

					$caption.html('Hozzászólás:');
					$replyinput.val("0").end()
					$textarea.val("");					

					$('<div />').html(data.responseText).children().hide().appendTo($container).slideDown('slow', function() {
						$.youtubeInit();
					});
				}
			});

			return false;
		},

		remove: function() {
			if (!confirm("Biztosan törlöd a hozzászólást?")) return false;

			var $el = $(this);
			$.wbComments.show_message("Kérjük várjon!");
			$.post($.base+"comments/remove", {id: $el.attr("lang")}, function() {
				$.wbComments.hide_message();
				$el.closest(".widget_comment").slideUp("slow", function(){$(this).remove();})
			});

			return false;
		},

		moderate: function() {
			if (!confirm("Biztosan moderálod a hozzászólást?")) return false;

			var $el = $(this);
			$.wbComments.show_message("Kérjük várjon!");

			$.post($.base+"comments/moderate", {id: $(this).attr("lang")}, function() {
				$.wbComments.hide_message();
				$el.closest(".widget_comment").hide("slow", function(){
					$(this)
						.find(".widget_comment_text")
							.html("Az oldal stílusához és szellemiségéhez nem illő moderált tartalom!")
							.end()
						.show("slow");
				});
			});

			return false;
		},

		reply: function() {
			var $this = $(this),
				id = $this.attr("lang"),
				name = $this.attr("rel");

			$('html, body').animate({scrollTop: $("#commentAddBox").offset().top - 30}, 'slow');

			var $ta = $("#widget_comments").find("textarea").focus(),
				val = $ta.val();

			$("#commentAddBox").find("input[name=replyto]").val(id);

			if ($.trim(val) !== "") val += '\n\n';

			$ta.val(val + '[valasz='+id+']'+name+'[/valasz]: ');
			return false;
		},

		modify: function() {
			var $c = $("#widget_comments");
			var $f = $c.find("form");
			var $t = $("#widget_comment_textarea");
			var id = $(this).attr("lang");

			$('html, body').animate({scrollTop: $("#commentAddBox").offset().top - 30}, 'slow');
			$t.val($.wbTags.html_to_BBCode($(this).closest(".widget_comment").find(".widget_comment_text").html())).focus();

			$f.attr("action", $f.attr("action").replace("add", "modify"));
			$c.find('.commentAddBox').find("input[name=id]").val(id);
			$c.find(".widget_comment_caption").html("Hozzászólás szerkesztése:");

			return false;
		},

		refresh: function() {
			window.location = window.location.toString().split('#')[0].split("?")[0]+"?refresh="+Math.floor(Math.random(10)*10);
		},

		show_message: function(msg) {
			$(".widget_comment_messages", "#widget_comments")
				.find("span")
					.html(msg)
					.end()
				.fadeIn("slow");
		},

		hide_message: function() {
			$(".widget_comment_messages", "#widget_comments").fadeOut("slow");
		}

	}

	$.wbComments.init();
});


/*
 * jQuery plugin: fieldSelection - v0.1.0 - last change: 2006-12-16
 * (c) 2006 Alex Brem <alex@0xab.cd> - http://blog.0xab.cd
 */

var fieldSelection = {

	getSelection: function() {

		var e = this.jquery ? this[0] : this;

		return (

			/* mozilla / dom 3.0 */
			('selectionStart' in e && function() {
				var l = e.selectionEnd - e.selectionStart;
				return {start: e.selectionStart, end: e.selectionEnd, length: l, text: e.value.substr(e.selectionStart, l)};
			}) ||

			/* exploder */
			(document.selection && function() {

				e.focus();

				var r = document.selection.createRange();
				if (r == null) {
					return {start: 0, end: e.value.length, length: 0}
				}

				var re = e.createTextRange();
				var rc = re.duplicate();
				re.moveToBookmark(r.getBookmark());
				rc.setEndPoint('EndToStart', re);

				return {start: rc.text.length, end: rc.text.length + r.text.length, length: r.text.length, text: r.text};
			}) ||

			/* browser not supported */
			function() {
				return {start: 0, end: e.value.length, length: 0};
			}

		)();

	},

	replaceSelection: function() {

		var e = this.jquery ? this[0] : this;
		var text = arguments[0] || '';

		return (

			/* mozilla / dom 3.0 */
			('selectionStart' in e && function() {
				e.value = e.value.substr(0, e.selectionStart) + text + e.value.substr(e.selectionEnd, e.value.length);
				return this;
			}) ||

			/* exploder */
			(document.selection && function() {
				e.focus();
				document.selection.createRange().text = text;
				return this;
			}) ||

			/* browser not supported */
			function() {
				e.value += text;
				return this;
			}

		)();

	}

};

jQuery.each(fieldSelection, function(i) {jQuery.fn[i] = this;});


$.initShare = function() {
	var $sh = $('#shareBox');
	if (!$sh.length) return;

	$sh.find('.shareWithTumblr').click(function() {
		var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://www.tumblr.com/share',l=d.location,e=encodeURIComponent,p='?v=3&u='+e(l.href) +'&t='+e(d.title) +'&s='+e(s),u=f+p;try{if(!/^(.*\.)?tumblr[^.]*$/.test(l.host))throw(0);tstbklt();}catch(z){a =function(){if(!w.open(u,'t','toolbar=0,resizable=0,status=1,width=450,height=430'))l.href=u;};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();}void(0);
		return false;
	});
}

$(function() {
	var $menu = $("#menu"),
		$its = $menu.find('a');

	$its.unbind('click.menuactive').bind('click.menuactive', function() {
		$its.removeClass('active');
		$(this).addClass('active');
	});

});

$.faqToggler = (function($) {
    var animDuration, $triggers, targetBody, $bodies;

    return function(o) {
		animDuration = o.animDuration || 1000;
		$triggers = o.trigger;
		targetBody = o.target;
        $bodies = $triggers.parent().find(targetBody);

		$bodies.hide();
		$bodies.eq(0).show();
		$triggers.click(function() {
            var $target = $(this).next(targetBody);

			$bodies.not($target).stop().slideUp(animDuration);
            $target.stop().slideDown(animDuration);

			return false;
		});
    }
})(jQuery);


/*
* Author:      Marco Kuiper (http://www.marcofolio.net/)
* BelongsTo:   The iPhone unlock screen in xHTML, CSS and jQuery
* Modifications: Swing back and "slide to unlock"-fade made by Martin Jansson (http://www.martinjansson.se)
*/

$(function()
{
	if ($.support.touch) return;

	var $us = $("#unlock-slider"),
		url = $us.parent().attr('lang'),
		$stu = $("#slide-to-unlock"),
		$uh = $("#unlock-handle");

	$us.next().remove();

	$us.slider({
		handle: "#unlock-handle",
		animate:true,
		slide: function(e,ui)
		{			
			$stu.css("opacity", 1-(parseInt($uh.css("left"))/110));
		},
		stop: function(e,ui)
		{
			if($uh.position().left >= 135)
			{
				unlock();
			}
			else
			{
				$uh.animate({left: 0}, 200 );
				$stu.animate({opacity: 1}, 200 );
			}
		}
		}
	);

	var unlock = function()
	{
		window.location = url;
	}
});

/* Default animations */
$(function() {
	var $menu = $("#menu").children("ul").removeClass('menuhover'), menuOffset = $menu.offsetParent();

	$menu.css({ position: 'absolute', top: menuOffset.top, left: menuOffset.left, width: '500px' });

	$menu.find("li")
		.bind("mouseenter.menuAnim", function() {
			var $this = $(this), $submenu = $this.children('.submenu');

			$this.children('a').stop().animate({ top: '-5px' }, 100, 'easeOutQuad');

			if ($submenu.length) {
				$submenu.stop().css({display: 'block'}).animate({ opacity: 1 }, 200, 'easeOutQuad');
			}
		})
		.bind("mouseleave.menuAnim", function() {
			var $this = $(this), $submenu = $this.children('.submenu');
			$this.children('a').stop().animate({ top: 0 }, 200, 'swing');
			
			if ($submenu.length) {
				$submenu.stop().css({display: 'block'}).animate({ opacity: 0 }, 200, 'swing', function() { $submenu.css({ display: 'none'}); });
			}
		});
	
});


/* Sliders */
$.mainStickySlider = function(wait) {	
	$(function() {
		var $slider = $("#main_sticky_slider"),
			$els = $slider.children('a').removeClass('active'),
			$act = $els.eq(0).css({ display: 'block', opacity: 1 }),
			lock = false,
			l = $els.length,
			$bullets = $("#main_sticky_slider_bullets").children(),
			index,

			slide = function(nextIndex, force) {				
				if (force || !lock) {
					$act.stop().css({ display: 'block', opacity: 1 }).animate({ opacity: 0, top: '55px' }, 300, 'easeOutQuad', function() {						
						$act.css({ display: 'none'});

						if (!nextIndex && (nextIndex !== 0)) {
							index = $els.index($act) + 1;
							if (index >= l) index = 0;
						} else {
							index = nextIndex;
						}						

						$act = $els.eq(index);						
						$act.stop().css({ display: 'block', opacity: 0, top: '35px' }).animate({ opacity: 1, top: '45px' }, 300, 'easeOutQuad');
						
						$bullets.removeClass('active').eq(index).addClass('active');						
					});
				}

				clearTimeout($.mainStickySliderTimer);
				$.mainStickySliderTimer = setTimeout(function() {slide();}, wait);
			};

		if (l <= 1) return;

		$els.add($bullets).unbind('mouseenter.slider').bind('mouseenter.slide', function() {
			lock = true;
		}).unbind('mouseleave.slider').bind('mouseleave.slide', function() {
			lock = false;
		}).not($bullets).each(function() {
			 (new Image()).src = $(this).find('div').css('background-image').replace(/"/g,"").replace(/url\(|\)$/ig, "");
		});

		$bullets.unbind('click.slider').bind('click.slide', function(e) {
			e.preventDefault();
			var newIndex = $bullets.index($(this));

			if ($els.index($act) == newIndex) return true;

			clearTimeout($.mainStickySliderTimer);
			slide(newIndex, true);
		});

		clearTimeout($.mainStickySliderTimer);
		$.mainStickySliderTimer = setTimeout(function() {slide();}, wait);

	});
}

$.advertSlider = function(wait) {
	$(function() {
		var $slider = $("#advert_box_slider"),
			$els = $slider.children('a').removeClass('active'),
			$act = $els.eq(0).css({ display: 'block', opacity: 1 }),
			lock = false,
			l = $els.length,
			$bullets = $("#advert_box_slider_bullets").children(),
			index,

			slide = function(nextIndex, force) {				
				if (force || !lock) {
					$act.stop().css({ display: 'block', opacity: 1 }).animate({ opacity: 0 }, 300, 'easeOutQuad', function() {
						$act.css({ display: 'none'});
						
						if (!nextIndex && (nextIndex !== 0)) {
							index = $els.index($act) + 1;
							if (index >= l) index = 0;
						} else {
							index = nextIndex;
						}

						$act = $els.eq(index);
						
						$act.stop().css({ display: 'block', opacity: 0 }).animate({ opacity: 1 }, 300, 'easeOutQuad');
						$bullets.removeClass('active').eq(index).addClass('active');
						
					});
				}

				clearTimeout($.advertSliderTimer);
				$.advertSliderTimer = setTimeout(function() {slide();}, wait);
			};

		if (l <= 1) return;

		$els.add($bullets).unbind('mouseenter.slider').bind('mouseenter.slide', function() {
			lock = true;
		}).unbind('mouseleave.slider').bind('mouseleave.slide', function() {
			lock = false;
		}).not($bullets).each(function() {
			 (new Image()).src = $(this).find('div').css('background-image').replace(/"/g,"").replace(/url\(|\)$/ig, "");
		});

		$bullets.unbind('click.slider').bind('click.slide', function(e) {			
			e.preventDefault();
			var newIndex = $bullets.index($(this));

			if ($els.index($act) == newIndex) return true;

			clearTimeout($.advertSliderTimer);
			slide(newIndex, true);
		});

		clearTimeout($.advertSliderTimer);
		$.advertSliderTimer = setTimeout(function() {slide();}, wait);
	});
}

// APPSTORE BOTTOM-SLIDER
$(function() {
	var $container = $('#apps_leafer'),
		$imgs = $container.children(),
		$act = $imgs.last(),
		$next,

		change = function() {
			$next = $act.prev();
			$next.css({ left: '-200px' })
				 .animate({ left: 0 }, 500, 'easeOutBack');

			$act.animate({ left: '200px' }, 500, 'easeOutBack', function() {
				$act.prependTo($container);
				$act = $next;
			});

			setTimeout(change, 3000);
		};
		
	if (!$container.length) return;

	$imgs.not($act).css({left: '-200px'});

	setTimeout(change, 3000);
});

$(function() {
	// BOTTOM-UP NAVIGATION
	$("#header").children('a').filter('.pagedown').unbind('click.bottomnav').bind('click.bottomnav', function() {
		$("html, body").animate({ scrollTop: $(document).height() }, "fast");
		return false;
	});

	$("#footer_top").children('a').filter('.pageup').unbind('click.upnav').bind('click.upnav', function() {
		$("html, body").animate({ scrollTop: 0 }, "fast");
		return false;
	});

	$("#bottomPartnerBox").find('.partner').removeClass('partnerHoverStatic').filter('.partnerHover').hover(
		function(){
			$(this).stop().animate({opacity: 0}, 150, 'swing');
		},
		function(){
			$(this).stop().animate({opacity: 1}, 500, 'easeOutQuad');
		}
	);

	// ADVERT THUMB IMAGE CORRECTION HACK
	var $advertThumb = $('#mainContent').find('.advert_attachments').children('a');
	if ($advertThumb.length) $advertThumb.each(function() {
		var $this = $(this),
			hrefArr = $this.attr('href').split('/'),
			last = hrefArr[hrefArr.length-1];
			hrefArr[hrefArr.length-1] = '_small';
			hrefArr[hrefArr.length] = 'cropped_'+last;
			$this.css('background', 'url('+hrefArr.join('/')+')');

	});

	
});
