// Automatic file build by bin/build_all_jsV3.js, don't modify it

//
// Javascript base files
//

/**
 * Use object Fotolia_Locale to translate string
 * @param string str
 * @return string str
 */
function _(str)
{
    var tmp = str;

    if (typeof Fotolia_Locale == 'function') {
        tmp = Fotolia_Locale.current_localisation[str];
    }

    if (typeof tmp != 'undefined') {
        str = tmp;
    }

    return str;
}

// This code is in the public domain. Feel free to link back to http://jan.moesen.nu/
function sprintf() {
    if (!arguments || arguments.length < 1 || !RegExp) {
        return;
    }

    var str = arguments[0];
    var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
    var a = b = [], numSubstitutions = 0, numMatches = 0;
    while (a = re.exec(str)) {
        var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
        var pPrecision = a[5], pType = a[6], rightPart = a[7];

        numMatches++;

        if (pType == '%') {
            subst = '%';
        } else {
            numSubstitutions++;
            if (numSubstitutions >= arguments.length) {
                alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).');
            }

            var param = arguments[numSubstitutions];
            var pad = '';
            if (pPad && pPad.substr(0,1) == "'") {
                pad = leftpart.substr(1,1);
            } else if (pPad) {
                pad = pPad;
            }

            var justifyRight = true;
            if (pJustify && pJustify === "-") {
                justifyRight = false;
            }

            var minLength = -1;
            if (pMinLength) {
                minLength = parseInt(pMinLength);
            }

            var precision = -1;
            if (pPrecision && pType == 'f') {
                precision = parseInt(pPrecision.substring(1));
            }

            var subst = param;
            if (pType == 'b') {
                subst = parseInt(param).toString(2);
            } else if (pType == 'c') {
                subst = String.fromCharCode(parseInt(param));
            } else if (pType == 'd') {
                subst = parseInt(param) ? parseInt(param) : 0;
            } else if (pType == 'u') {
                subst = Math.abs(param);
            } else if (pType == 'f') {
                subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param);
            } else if (pType == 'o') {
                subst = parseInt(param).toString(8);
            } else if (pType == 's') {
                subst = param;
            } else if (pType == 'x') {
                subst = ('' + parseInt(param).toString(16)).toLowerCase();
            } else if (pType == 'X') {
                subst = ('' + parseInt(param).toString(16)).toUpperCase();
            }
        }

        str = leftpart + subst + rightPart;
    }

    return str;
}



// Copyright 2011 Google Inc. All Rights Reserved.

/**
 * @fileoverview A simple script to automatically track Facebook and Twitter
 * buttons using Google Analytics social tracking feature.
 * @author api.nickm@google.com (Nick Mihailovski)
 */


/**
 * Namespace.
 * @type {Object}.
 */
var _ga = _ga || {};


/**
 * Ensure global _gaq Google Anlaytics queue has be initialized.
 * @type {Array}
 */
var _gaq = _gaq || [];


/**
 * Helper method to track social features. This assumes all the social
 * scripts / apis are loaded synchronously. If they are loaded async,
 * you might need to add the nextwork specific tracking call to the
 * a callback once the network's script has loaded.
 * @param {string} opt_pageUrl An optional URL to associate the social
 *     tracking with a particular page.
 * @param {string} opt_trackerName An optional name for the tracker object.
 */
_ga.trackSocial = function(opt_pageUrl, opt_trackerName) {
  _ga.trackFacebook(opt_pageUrl, opt_trackerName);
  _ga.trackTwitter(opt_pageUrl, opt_trackerName);
};


/**
 * Tracks Facebook likes, unlikes and sends by suscribing to the Facebook
 * JSAPI event model. Note: This will not track facebook buttons using the
 * iFrame method.
 * @param {string} opt_pageUrl An optional URL to associate the social
 *     tracking with a particular page.
 * @param {string} opt_trackerName An optional name for the tracker object.
 */
_ga.trackFacebook = function(opt_pageUrl, opt_trackerName) {
  var trackerName = _ga.buildTrackerName_(opt_trackerName);
  try {
    if (FB && FB.Event && FB.Event.subscribe) {
      FB.Event.subscribe('edge.create', function(targetUrl) {
        _gaq.push([trackerName + '_trackSocial', 'facebook', 'like',
            targetUrl, opt_pageUrl]);
      });
      FB.Event.subscribe('edge.remove', function(targetUrl) {
        _gaq.push([trackerName + '_trackSocial', 'facebook', 'unlike',
            targetUrl, opt_pageUrl]);
      });
      FB.Event.subscribe('message.send', function(targetUrl) {
        _gaq.push([trackerName + '_trackSocial', 'facebook', 'send',
            targetUrl, opt_pageUrl]);
      });
    }
  } catch (e) {}
};


/**
 * Returns the normalized tracker name configuration parameter.
 * @param {string} opt_trackerName An optional name for the tracker object.
 * @return {string} If opt_trackerName is set, then the value appended with
 *     a . Otherwise an empty string.
 * @private
 */
_ga.buildTrackerName_ = function(opt_trackerName) {
  return opt_trackerName ? opt_trackerName + '.' : '';
};


/**
 * Tracks everytime a user clicks on a tweet button from Twitter.
 * This subscribes to the Twitter JS API event mechanism to listen for
 * clicks coming from this page. Details here:
 * http://dev.twitter.com/pages/intents-events#click
 * This method should be called once the twitter API has loaded.
 * @param {string} opt_pageUrl An optional URL to associate the social
 *     tracking with a particular page.
 * @param {string} opt_trackerName An optional name for the tracker object.
 */
_ga.trackTwitter = function(opt_pageUrl, opt_trackerName) {
  var trackerName = _ga.buildTrackerName_(opt_trackerName);
  try {
    if (twttr && twttr.events && twttr.events.bind) {
      twttr.events.bind('tweet', function(event) {
        if (event) {
          var targetUrl; // Default value is undefined.
          if (event.target && event.target.nodeName == 'IFRAME') {
            targetUrl = _ga.extractParamFromUri_(event.target.src, 'url');
          }
          _gaq.push([trackerName + '_trackSocial', 'twitter', 'tweet',
            targetUrl, opt_pageUrl]);
        }
      });
    }
  } catch (e) {}
};


/**
 * Extracts a query parameter value from a URI.
 * @param {string} uri The URI from which to extract the parameter.
 * @param {string} paramName The name of the query paramater to extract.
 * @return {string} The un-encoded value of the query paramater. underfined
 *     if there is no URI parameter.
 * @private
 */
_ga.extractParamFromUri_ = function(uri, paramName) {
  if (!uri) {
    return;
  }
  var uri = uri.split('#')[0];  // Remove anchor.
  var parts = uri.split('?');  // Check for query params.
  if (parts.length == 1) {
    return;
  }
  var query = decodeURI(parts[1]);

  // Find url param.
  paramName += '=';
  var params = query.split('&');
  for (var i = 0, param; param = params[i]; ++i) {
    if (param.indexOf(paramName) === 0) {
      return unescape(param.split('=')[1]);
    }
  }
  return;
};



//
// JQuery core and plugins
//

/*!
 * jQuery JavaScript Library v1.6.2
 * http://jquery.com/
 *
 * Copyright 2011, John Resig
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 * Copyright 2011, The Dojo Foundation
 * Released under the MIT, BSD, and GPL Licenses.
 *
 * Date: Thu Jun 30 14:16:56 2011 -0400
 */
(function(a,b){function cv(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cs(a){if(!cg[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ch||(ch=c.createElement("iframe"),ch.frameBorder=ch.width=ch.height=0),b.appendChild(ch);if(!ci||!ch.createElement)ci=(ch.contentWindow||ch.contentDocument).document,ci.write((c.compatMode==="CSS1Compat"?"<!doctype html>":"")+"<html><body>"),ci.close();d=ci.createElement(a),ci.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ch)}cg[a]=e}return cg[a]}function cr(a,b){var c={};f.each(cm.concat.apply([],cm.slice(0,b)),function(){c[this]=a});return c}function cq(){cn=b}function cp(){setTimeout(cq,0);return cn=f.now()}function cf(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ce(){try{return new a.XMLHttpRequest}catch(b){}}function b$(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h=="string"&&(e[h.toLowerCase()]=a.converters[h]);l=k,k=d[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=e[m]||e["* "+k];if(!n){p=b;for(o in e){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=e[j[1]+" "+k];if(p){o=e[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&f.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function bZ(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function bY(a,b,c,d){if(f.isArray(b))f.each(b,function(b,e){c||bC.test(a)?d(a,e):bY(a+"["+(typeof e=="object"||f.isArray(e)?b:"")+"]",e,c,d)});else if(!c&&b!=null&&typeof b=="object")for(var e in b)bY(a+"["+e+"]",b[e],c,d);else d(a,b)}function bX(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bR,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=bX(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=bX(a,c,d,e,"*",g));return l}function bW(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(f.isFunction(c)){var d=b.toLowerCase().split(bN),e=0,g=d.length,h,i,j;for(;e<g;e++)h=d[e],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function bA(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=b==="width"?bv:bw;if(d>0){c!=="border"&&f.each(e,function(){c||(d-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?d+=parseFloat(f.css(a,c+this))||0:d-=parseFloat(f.css(a,"border"+this+"Width"))||0});return d+"px"}d=bx(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0,c&&f.each(e,function(){d+=parseFloat(f.css(a,"padding"+this))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+this+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+this))||0)});return d+"px"}function bm(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(be,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bl(a){f.nodeName(a,"input")?bk(a):"getElementsByTagName"in a&&f.grep(a.getElementsByTagName("input"),bk)}function bk(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bj(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bi(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bh(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(var i=0,j=g[h].length;i<j;i++)f.event.add(b,h+(g[h][i].namespace?".":"")+g[h][i].namespace,g[h][i],g[h][i].data)}}}}function bg(a,b){return f.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function W(a,b,c){b=b||0;if(f.isFunction(b))return f.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return f.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=f.grep(a,function(a){return a.nodeType===1});if(R.test(b))return f.filter(b,d,!c);b=f.filter(b,d)}return f.grep(a,function(a,d){return f.inArray(a,b)>=0===c})}function V(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function N(a,b){return(a&&a!=="*"?a+".":"")+b.replace(z,"`").replace(A,"&")}function M(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;i<s.length;i++)g=s[i],g.origType.replace(x,"")===a.type?q.push(g.selector):s.splice(i--,1);e=f(a.target).closest(q,a.currentTarget);for(j=0,k=e.length;j<k;j++){m=e[j];for(i=0;i<s.length;i++){g=s[i];if(m.selector===g.selector&&(!n||n.test(g.namespace))&&!m.elem.disabled){h=m.elem,d=null;if(g.preType==="mouseenter"||g.preType==="mouseleave")a.type=g.preType,d=f(a.relatedTarget).closest(g.selector)[0],d&&f.contains(h,d)&&(d=h);(!d||d!==h)&&p.push({elem:h,handleObj:g,level:m.level})}}}for(j=0,k=p.length;j<k;j++){e=p[j];if(c&&e.level>c)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function K(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function E(){return!0}function D(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(j,"$1-$2").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(g){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function J(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(J,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=/-([a-z])/ig,x=function(a,b){return b.toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j<k;j++)if((a=arguments[j])!=null)for(c in a){d=i[c],f=a[c];if(i===f)continue;l&&f&&(e.isPlainObject(f)||(g=e.isArray(f)))?(g?(g=!1,h=d&&e.isArray(d)?d:[]):h=d&&e.isPlainObject(d)?d:{},i[c]=e.extend(l,h,f)):f!==b&&(i[c]=f)}return i},e.extend({noConflict:function(b){a.$===e&&(a.$=g),b&&a.jQuery===e&&(a.jQuery=f);return e},isReady:!1,readyWait:1,holdReady:function(a){a?e.readyWait++:e.ready(!0)},ready:function(a){if(a===!0&&!--e.readyWait||a!==!0&&!e.isReady){if(!c.body)return setTimeout(e.ready,1);e.isReady=!0;if(a!==!0&&--e.readyWait>0)return;A.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!A){A=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a);return c===b||D.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(b,c,d){a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),d=c.documentElement,(!d||!d.nodeName||d.nodeName==="parsererror")&&e.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g<h;)if(c.apply(a[g++],d)===!1)break}else if(i){for(f in a)if(c.call(a[f],f,a[f])===!1)break}else for(;g<h;)if(c.call(a[g],g,a[g++])===!1)break;return a},trim:G?function(a){return a==null?"":G.call(a)}:function(a){return a==null?"":(a+"").replace(k,"").replace(l,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var d=e.type(a);a.length==null||d==="string"||d==="function"||d==="regexp"||e.isWindow(a)?E.call(c,a):e.merge(c,a)}return c},inArray:function(a,b){if(H)return H.call(b,a);for(var c=0,d=b.length;c<d;c++)if(b[c]===a)return c;return-1},merge:function(a,c){var d=a.length,e=0;if(typeof c.length=="number")for(var f=c.length;e<f;e++)a[d++]=c[e];else while(c[e]!==b)a[d++]=c[e++];a.length=d;return a},grep:function(a,b,c){var d=[],e;c=!!c;for(var f=0,g=a.length;f<g;f++)e=!!b(a[f],f),c!==e&&d.push(a[f]);return d},map:function(a,c,d){var f,g,h=[],i=0,j=a.length,k=a instanceof e||j!==b&&typeof j=="number"&&(j>0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i<j;i++)f=c(a[i],i,d),f!=null&&(h[h.length]=f);else for(g in a)f=c(a[g],g,d),f!=null&&(h[h.length]=f);return h.concat.apply([],h)},guid:1,proxy:function(a,c){if(typeof c=="string"){var d=a[c];c=a,a=d}if(!e.isFunction(a))return b;var f=F.call(arguments,2),g=function(){return a.apply(c,f.concat(F.call(arguments)))};g.guid=a.guid=a.guid||g.guid||e.guid++;return g},access:function(a,c,d,f,g,h){var i=a.length;if(typeof c=="object"){for(var j in c)e.access(a,j,c[j],f,g,d);return a}if(d!==b){f=!h&&f&&e.isFunction(d);for(var k=0;k<i;k++)g(a[k],c,f?d.call(a[k],k,g(a[k],c)):d,h);return a}return i?g(a[0],c):b},now:function(){return(new Date).getTime()},uaMatch:function(a){a=a.toLowerCase();var b=s.exec(a)||t.exec(a)||u.exec(a)||a.indexOf("compatible")<0&&v.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}e.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function(d,f){f&&f instanceof e&&!(f instanceof a)&&(f=a(f));return e.fn.init.call(this,d,f,b)},a.fn.init.prototype=a.fn;var b=a(c);return a},browser:{}}),e.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){I["[object "+b+"]"]=b.toLowerCase()}),z=e.uaMatch(y),z.browser&&(e.browser[z.browser]=!0,e.browser.version=z.version),e.browser.webkit&&(e.browser.safari=!0),j.test(" ")&&(k=/^[\s\xA0]+/,l=/[\s\xA0]+$/),h=e(c),c.addEventListener?B=function(){c.removeEventListener("DOMContentLoaded",B,!1),e.ready()}:c.attachEvent&&(B=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",B),e.ready())});return e}(),g="done fail isResolved isRejected promise then always pipe".split(" "),h=[].slice;f.extend({_Deferred:function(){var a=[],b,c,d,e={done:function(){if(!d){var c=arguments,g,h,i,j,k;b&&(k=b,b=0);for(g=0,h=c.length;g<h;g++)i=c[g],j=f.type(i),j==="array"?e.done.apply(e,i):j==="function"&&a.push(i);k&&e.resolveWith(k[0],k[1])}return this},resolveWith:function(e,f){if(!d&&!b&&!c){f=f||[],c=1;try{while(a[0])a.shift().apply(e,f)}finally{b=[e,f],c=0}}return this},resolve:function(){e.resolveWith(this,arguments);return this},isResolved:function(){return!!c||!!b},cancel:function(){d=1,a=[];return this}};return e},Deferred:function(a){var b=f._Deferred(),c=f._Deferred(),d;f.extend(b,{then:function(a,c){b.done(a).fail(c);return this},always:function(){return b.done.apply(b,arguments).fail.apply(this,arguments)},fail:c.done,rejectWith:c.resolveWith,reject:c.resolve,isRejected:c.isResolved,pipe:function(a,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[c,"reject"]},function(a,c){var e=c[0],g=c[1],h;f.isFunction(e)?b[a](function(){h=e.apply(this,arguments),h&&f.isFunction(h.promise)?h.promise().then(d.resolve,d.reject):d[g](h)}):b[a](d[g])})}).promise()},promise:function(a){if(a==null){if(d)return d;d=a={}}var c=g.length;while(c--)a[g[c]]=b[g[c]];return a}}),b.done(c.cancel).fail(b.cancel),delete b.cancel,a&&a.call(b,b);return b},when:function(a){function i(a){return function(c){b[a]=arguments.length>1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c<d;c++)b[c]&&f.isFunction(b[c].promise)?b[c].promise().then(i(c),g.reject):--e;e||g.resolveWith(g,b)}else g!==a&&g.resolveWith(g,d?[a]:[]);return g.promise()}}),f.support=function(){var a=c.createElement("div"),b=c.documentElement,d,e,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;a.setAttribute("className","t"),a.innerHTML="   <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=a.getElementsByTagName("input")[0],k={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,k.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,k.optDisabled=!h.disabled;try{delete a.test}catch(v){k.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function(){k.noCloneEvent=!1}),a.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),k.radioValue=i.value==="t",i.setAttribute("checked","checked"),a.appendChild(i),l=c.createDocumentFragment(),l.appendChild(a.firstChild),k.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",m=c.getElementsByTagName("body")[0],o=c.createElement(m?"div":"body"),p={visibility:"hidden",width:0,height:0,border:0,margin:0},m&&f.extend(p,{position:"absolute",left:-1e3,top:-1e3});for(t in p)o.style[t]=p[t];o.appendChild(a),n=m||b,n.insertBefore(o,n.firstChild),k.appendChecked=i.checked,k.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,k.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="<div style='width:4px;'></div>",k.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>",q=a.getElementsByTagName("td"),u=q[0].offsetHeight===0,q[0].style.display="",q[1].style.display="none",k.reliableHiddenOffsets=u&&q[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",a.appendChild(j),k.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0),o.innerHTML="",n.removeChild(o);if(a.attachEvent)for(t in{submit:1,change:1,focusin:1})s="on"+t,u=s in a,u||(a.setAttribute(s,"return;"),u=typeof a[s]=="function"),k[t+"Bubbles"]=u;o=l=g=h=m=j=a=i=null;return k}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([a-z])([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g=f.expando,h=typeof c=="string",i,j=a.nodeType,k=j?f.cache:a,l=j?a[f.expando]:a[f.expando]&&f.expando;if((!l||e&&l&&!k[l][g])&&h&&d===b)return;l||(j?a[f.expando]=l=++f.uuid:l=f.expando),k[l]||(k[l]={},j||(k[l].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?k[l][g]=f.extend(k[l][g],c):k[l]=f.extend(k[l],c);i=k[l],e&&(i[g]||(i[g]={}),i=i[g]),d!==b&&(i[f.camelCase(c)]=d);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[f.camelCase(c)]||i[c]:i}},removeData:function(b,c,d){if(!!f.acceptData(b)){var e=f.expando,g=b.nodeType,h=g?f.cache:b,i=g?b[f.expando]:f.expando;if(!h[i])return;if(c){var j=d?h[i][e]:h[i];if(j){delete j[c];if(!l(j))return}}if(d){delete h[i][e];if(!l(h[i]))return}var k=h[i][e];f.support.deleteExpando||h!=a?delete h[i]:h[i]=null,k?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=k):g&&(f.support.deleteExpando?delete b[f.expando]:b.removeAttribute?b.removeAttribute(f.expando):b[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h<i;h++)g=e[h].name,g.indexOf("data-")===0&&(g=f.camelCase(g.substring(5)),k(this[0],g,d[g]))}}return d}if(typeof a=="object")return this.each(function(){f.data(this,a)});var j=a.split(".");j[1]=j[1]?"."+j[1]:"";if(c===b){d=this.triggerHandler("getData"+j[1]+"!",[j[0]]),d===b&&this.length&&(d=f.data(this[0],a),d=k(this[0],a,d));return d===b&&j[1]?this.data(j[0]):d}return this.each(function(){var b=f(this),d=[j[0],c];b.triggerHandler("setData"+j[1]+"!",d),f.data(this,a,c),b.triggerHandler("changeData"+j[1]+"!",d)})},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,c){a&&(c=(c||"fx")+"mark",f.data(a,c,(f.data(a,c,b,!0)||0)+1,!0))},_unmark:function(a,c,d){a!==!0&&(d=c,c=a,a=!1);if(c){d=d||"fx";var e=d+"mark",g=a?0:(f.data(c,e,b,!0)||1)-1;g?f.data(c,e,g,!0):(f.removeData(c,e,!0),m(c,d,"mark"))}},queue:function(a,c,d){if(a){c=(c||"fx")+"queue";var e=f.data(a,c,b,!0);d&&(!e||f.isArray(d)?e=f.data(a,c,f.makeArray(d),!0):e.push(d));return e||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e;d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),d.call(a,function(){f.dequeue(a,b)})),c.length||(f.removeData(a,b+"queue",!0),m(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){typeof a!="string"&&(c=a,a="fx");if(c===b)return f.queue(this[0],a);return this.each(function(){var b=f.queue(this,a,c);a==="fx"&&b[0]!=="inprogress"&&f.dequeue(this,a)})},dequeue:function(a){return this.each(function(){f.dequeue(this,a)})},delay:function(a,b){a=f.fx?f.fx.speeds[a]||a:a,b=b||"fx";return this.queue(b,function(){var c=this;setTimeout(function(){f.dequeue(c,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){function m(){--h||d.resolveWith(e,[e])}typeof a!="string"&&(c=a,a=b),a=a||"fx";var d=f.Deferred(),e=this,g=e.length,h=1,i=a+"defer",j=a+"queue",k=a+"mark",l;while(g--)if(l=f.data(e[g],i,b,!0)||(f.data(e[g],j,b,!0)||f.data(e[g],k,b,!0))&&f.data(e[g],i,f._Deferred(),!0))h++,l.done(m);m();return d.promise()}});var n=/[\n\t\r]/g,o=/\s+/,p=/\r/g,q=/^(?:button|input)$/i,r=/^(?:button|input|object|select|textarea)$/i,s=/^a(?:rea)?$/i,t=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,u=/\:|^on/,v,w;f.fn.extend({attr:function(a,b){return f.access(this,a,b,!0,f.attr)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,a,b,!0,f.prop)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(o);for(c=0,d=this.length;c<d;c++){e=this[c];if(e.nodeType===1)if(!e.className&&b.length===1)e.className=a;else{g=" "+e.className+" ";for(h=0,i=b.length;h<i;h++)~g.indexOf(" "+b[h]+" ")||(g+=b[h]+" ");e.className=f.trim(g)}}}return this},removeClass:function(a){var c,d,e,g,h,i,j;if(f.isFunction(a))return this.each(function(b){f(this).removeClass(a.call(this,b,this.className))});if(a&&typeof a=="string"||a===b){c=(a||"").split(o);for(d=0,e=this.length;d<e;d++){g=this[d];if(g.nodeType===1&&g.className)if(a){h=(" "+g.className+" ").replace(n," ");for(i=0,j=c.length;i<j;i++)h=h.replace(" "+c[i]+" "," ");g.className=f.trim(h)}else g.className=""}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";if(f.isFunction(a))return this.each(function(c){f(this).toggleClass(a.call(this,c,this.className,b),b)});return this.each(function(){if(c==="string"){var e,g=0,h=f(this),i=b,j=a.split(o);while(e=j[g++])i=d?i:!h.hasClass(e),h[i?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&f._data(this,"__className__",this.className),this.className=this.className||a===!1?"":f._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ";for(var c=0,d=this.length;c<d;c++)if((" "+this[c].className+" ").replace(n," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;d=e.value;return typeof d=="string"?d.replace(p,""):d==null?"":d}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c=a.selectedIndex,d=[],e=a.options,g=a.type==="select-one";if(c<0)return null;for(var h=g?c:0,i=g?c+1:e.length;h<i;h++){var j=e[h];if(j.selected&&(f.support.optDisabled?!j.disabled:j.getAttribute("disabled")===null)&&(!j.parentNode.disabled||!f.nodeName(j.parentNode,"optgroup"))){b=f(j).val();if(g)return b;d.push(b)}}if(g&&!d.length&&e.length)return f(e[c]).val();return d},set:function(a,b){var c=f.makeArray(b);f(a).find("option").each(function(){this.selected=f.inArray(f(this).val(),c)>=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);var h,i,j=g!==1||!f.isXMLDoc(a);j&&(c=f.attrFix[c]||c,i=f.attrHooks[c],i||(t.test(c)?i=w:v&&c!=="className"&&(f.nodeName(a,"form")||u.test(c))&&(i=v)));if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j&&(h=i.get(a,c))!==null)return h;h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){var c;a.nodeType===1&&(b=f.attrFix[b]||b,f.support.getSetAttribute?a.removeAttribute(b):(f.attr(a,b,""),a.removeAttributeNode(a.getAttributeNode(b))),t.test(b)&&(c=f.propFix[b]||b)in a&&(a[c]=!1))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},tabIndex:{get:function(a){var c=a.getAttributeNode("tabIndex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}},value:{get:function(a,b){if(v&&f.nodeName(a,"button"))return v.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(v&&f.nodeName(a,"button"))return v.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);i&&(c=f.propFix[c]||c,h=f.propHooks[c]);return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==b?g:a[c]},propHooks:{}}),w={get:function(a,c){return f.prop(a,c)?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},f.support.getSetAttribute||(f.attrFix=f.propFix,v=f.attrHooks.name=f.attrHooks.title=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&d.nodeValue!==""?d.nodeValue:b},set:function(a,b,c){var d=a.getAttributeNode(c);if(d){d.nodeValue=b;return b}}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var x=/\.(.*)$/,y=/^(?:textarea|input|select)$/i,z=/\./g,A=/ /g,B=/[^\w\s.|`]/g,C=function(a){return a.replace(B,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=D;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=D);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),C).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j<p.length;j++){q=p[j];if(l||n.test(q.namespace))f.event.remove(a,r,q.handler,j),p.splice(j--,1)}continue}o=f.event.special[h]||{};for(j=e||0;j<p.length;j++){q=p[j];if(d.guid===q.guid){if(l||n.test(q.namespace))e==null&&p.splice(j--,1),o.remove&&o.remove.call(a,q);if(e!=null)break}}if(p.length===0||e!=null&&p.length===1)(!o.teardown||o.teardown.call(a,m)===!1)&&f.removeEvent(a,h,s.handle),g=null,delete t[h]}if(f.isEmptyObject(t)){var u=s.handle;u&&(u.elem=null),delete s.events,delete s.handle,f.isEmptyObject(s)&&f.removeData(a,b,!0)}}},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,e,g){var h=c.type||c,i=[],j;h.indexOf("!")>=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.
shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d!=null?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h<i;h++){var j=d[h];if(e||c.namespace_re.test(j.namespace)){c.handler=j.handler,c.data=j.data,c.handleObj=j;var k=j.handler.apply(this,g);k!==b&&(c.result=k,k===!1&&(c.preventDefault(),c.stopPropagation()));if(c.isImmediatePropagationStopped())break}}return c.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(a){if(a[f.expando])return a;var d=a;a=f.Event(d);for(var e=this.props.length,g;e;)g=this.props[--e],a[g]=d[g];a.target||(a.target=a.srcElement||c),a.target.nodeType===3&&(a.target=a.target.parentNode),!a.relatedTarget&&a.fromElement&&(a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement);if(a.pageX==null&&a.clientX!=null){var h=a.target.ownerDocument||c,i=h.documentElement,j=h.body;a.pageX=a.clientX+(i&&i.scrollLeft||j&&j.scrollLeft||0)-(i&&i.clientLeft||j&&j.clientLeft||0),a.pageY=a.clientY+(i&&i.scrollTop||j&&j.scrollTop||0)-(i&&i.clientTop||j&&j.clientTop||0)}a.which==null&&(a.charCode!=null||a.keyCode!=null)&&(a.which=a.charCode!=null?a.charCode:a.keyCode),!a.metaKey&&a.ctrlKey&&(a.metaKey=a.ctrlKey),!a.which&&a.button!==b&&(a.which=a.button&1?1:a.button&2?3:a.button&4?2:0);return a},guid:1e8,proxy:f.proxy,special:{ready:{setup:f.bindReady,teardown:f.noop},live:{add:function(a){f.event.add(this,N(a.origType,a.selector),f.extend({},a,{handler:M,guid:a.handler.guid}))},remove:function(a){f.event.remove(this,N(a.origType,a.selector),a)}},beforeunload:{setup:function(a,b,c){f.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}}},f.removeEvent=c.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){a.detachEvent&&a.detachEvent("on"+b,c)},f.Event=function(a,b){if(!this.preventDefault)return new f.Event(a,b);a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?E:D):this.type=a,b&&f.extend(this,b),this.timeStamp=f.now(),this[f.expando]=!0},f.Event.prototype={preventDefault:function(){this.isDefaultPrevented=E;var a=this.originalEvent;!a||(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=E;var a=this.originalEvent;!a||(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=E,this.stopPropagation()},isDefaultPrevented:D,isPropagationStopped:D,isImmediatePropagationStopped:D};var F=function(a){var b=a.relatedTarget,c=!1,d=a.type;a.type=a.data,b!==this&&(b&&(c=f.contains(this,b)),c||(f.event.handle.apply(this,arguments),a.type=d))},G=function(a){a.type=a.data,f.event.handle.apply(this,arguments)};f.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){f.event.special[a]={setup:function(c){f.event.add(this,b,c&&c.selector?G:F,a)},teardown:function(a){f.event.remove(this,b,a&&a.selector?G:F)}}}),f.support.submitBubbles||(f.event.special.submit={setup:function(a,b){if(!f.nodeName(this,"form"))f.event.add(this,"click.specialSubmit",function(a){var b=a.target,c=b.type;(c==="submit"||c==="image")&&f(b).closest("form").length&&K("submit",this,arguments)}),f.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,c=b.type;(c==="text"||c==="password")&&f(b).closest("form").length&&a.keyCode===13&&K("submit",this,arguments)});else return!1},teardown:function(a){f.event.remove(this,".specialSubmit")}});if(!f.support.changeBubbles){var H,I=function(a){var b=a.type,c=a.value;b==="radio"||b==="checkbox"?c=a.checked:b==="select-multiple"?c=a.selectedIndex>-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},J=function(c){var d=c.target,e,g;if(!!y.test(d.nodeName)&&!d.readOnly){e=f._data(d,"_change_data"),g=I(d),(c.type!=="focusout"||d.type!=="radio")&&f._data(d,"_change_data",g);if(e===b||g===e)return;if(e!=null||g)c.type="change",c.liveFired=b,f.event.trigger(c,arguments[1],d)}};f.event.special.change={filters:{focusout:J,beforedeactivate:J,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&J.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&J.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",I(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in H)f.event.add(this,c+".specialChange",H[c]);return y.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return y.test(this.nodeName)}},H=f.event.special.change.filters,H.focus=H.beforeactivate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i<j;i++)f.event.add(this[i],a,g,d);return this}}),f.fn.extend({unbind:function(a,b){if(typeof a=="object"&&!a.preventDefault)for(var c in a)this.unbind(c,a[c]);else for(var d=0,e=this.length;d<e;d++)f.event.remove(this[d],a,b);return this},delegate:function(a,b,c,d){return this.live(b,c,d,a)},undelegate:function(a,b,c){return arguments.length===0?this.unbind("live"):this.die(b,null,c,a)},trigger:function(a,b){return this.each(function(){f.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return f.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||f.guid++,d=0,e=function(c){var e=(f.data(this,"lastToggle"+a.guid)||0)%d;f.data(this,"lastToggle"+a.guid,e+1),c.preventDefault();return b[e].apply(this,arguments)||!1};e.guid=c;while(d<b.length)b[d++].guid=c;return this.click(e)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var L={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};f.each(["live","die"],function(a,c){f.fn[c]=function(a,d,e,g){var h,i=0,j,k,l,m=g||this.selector,n=g?this:f(this.context);if(typeof a=="object"&&!a.preventDefault){for(var o in a)n[c](o,d,a[o],m);return this}if(c==="die"&&!a&&g&&g.charAt(0)==="."){n.unbind(g);return this}if(d===!1||f.isFunction(d))e=d||D,d=b;a=(a||"").split(" ");while((h=a[i++])!=null){j=x.exec(h),k="",j&&(k=j[0],h=h.replace(x,""));if(h==="hover"){a.push("mouseenter"+k,"mouseleave"+k);continue}l=h,L[h]?(a.push(L[h]+k),h=h+k):h=(L[h]||h)+k;if(c==="live")for(var p=0,q=n.length;p<q;p++)f.event.add(n[p],"live."+N(h,m),{data:d,selector:m,handler:e,origType:h,origHandler:e,preType:l});else n.unbind("live."+N(h,m),e)}return this}}),f.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(a,b){f.fn[b]=function(a,c){c==null&&(c=a,a=null);return arguments.length>0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i){var j=!1;i=i[a];while(i){if(i.sizcache===c){j=d[i.sizset];break}if(i.nodeType===1){f||(i.sizcache=c,i.sizset=g);if(typeof b!="string"){if(i===b){j=!0;break}}else if(k.filter(b,[i]).length>0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i){var j=!1;i=i[a];while(i){if(i.sizcache===c){j=d[i.sizset];break}i.nodeType===1&&!f&&(i.sizcache=c,i.sizset=g);if(i.nodeName.toLowerCase()===b){j=i;break}i=i[a]}d[g]=j}}}var a=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1)}return a},k.matches=function(a,b){return k(a,null,null,b)},k.matchesSelector=function(a,b){return k(b,null,null,[a]).length>0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e<f;e++){var g,h=l.order[e];if(g=l.leftMatch[h].exec(a)){var j=g[1];g.splice(1,1);if(j.substr(j.length-1)!=="\\"){g[1]=(g[1]||"").replace(i,""),d=l.find[h](g,b,c);if(d!=null){a=a.replace(l.match[h],"");break}}}}d||(d=typeof b.getElementsByTagName!="undefined"?b.getElementsByTagName("*"):[]);return{set:d,expr:a}},k.filter=function(a,c,d,e){var f,g,h=a,i=[],j=c,m=c&&c[0]&&k.isXML(c[0]);while(a&&c.length){for(var n in l.filter)if((f=l.leftMatch[n].exec(a))!=null&&f[2]){var o,p,q=l.filter[n],r=f[1];g=!1,f.splice(1,1);if(r.substr(r.length-1)==="\\")continue;j===i&&(i=[]);if(l.preFilter[n]){f=l.preFilter[n](f,j,d,i,e,m);if(!f)g=o=!0;else if(f===!0)continue}if(f)for(var s=0;(p=j[s])!=null;s++)if(p){o=q(p,f,s,j);var t=e^!!o;d&&o!=null?t?g=!0:j[s]=!1:t&&(i.push(p),g=!0)}if(o!==b){d||(j=i),a=a.replace(l.match[n],"");if(!g)return[];break}}if(a===h)if(g==null)k.error(a);else break;h=a}return j},k.error=function(a){throw"Syntax error, unrecognized expression: "+a};var l=k.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|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAttribute("type")}},relative:{"+":function(a,b){var c=typeof b=="string",d=c&&!j.test(b),e=c&&!d;d&&(b=b.toLowerCase());for(var f=0,g=a.length,h;f<g;f++)if(h=a[f]){while((h=h.previousSibling)&&h.nodeType!==1);a[f]=e||h&&h.nodeName.toLowerCase()===b?h||!1:h===b}e&&k.filter(b,a,!0)},">":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e<f;e++){c=a[e];if(c){var g=c.parentNode;a[e]=g.nodeName.toLowerCase()===b?g:!1}}}else{for(;e<f;e++)c=a[e],c&&(a[e]=d?c.parentNode:c.parentNode===b);d&&k.filter(b,a,!0)}},"":function(a,b,c){var e,f=d++,g=u;typeof b=="string"&&!j.test(b)&&(b=b.toLowerCase(),e=b,g=t),g("parentNode",b,f,a,e,c)},"~":function(a,b,c){var e,f=d++,g=u;typeof b=="string"&&!j.test(b)&&(b=b.toLowerCase(),e=b,g=t),g("previousSibling",b,f,a,e,c)}},find:{ID:function(a,b,c){if(typeof b.getElementById!="undefined"&&!c){var d=b.getElementById(a[1]);return d&&d.parentNode?[d]:[]}},NAME:function(a,b){if(typeof b.getElementsByName!="undefined"){var c=[],d=b.getElementsByName(a[1]);for(var e=0,f=d.length;e<f;e++)d[e].getAttribute("name")===a[1]&&c.push(d[e]);return c.length===0?null:c}},TAG:function(a,b){if(typeof b.getElementsByTagName!="undefined")return b.getElementsByTagName(a[1])}},preFilter:{CLASS:function(a,b,c,d,e,f){a=" "+a[1].replace(i,"")+" ";if(f)return a;for(var g=0,h;(h=b[g])!=null;g++)h&&(e^(h.className&&(" "+h.className+" ").replace(/[\t\n\r]/g," ").indexOf(a)>=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return b<c[3]-0},gt:function(a,b,c){return b>c[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h<i;h++)if(g[h]===a)return!1;return!0}k.error(e)},CHILD:function(a,b){var c=b[1],d=a;switch(c){case"only":case"first":while(d=d.previousSibling)if(d.nodeType===1)return!1;if(c==="first")return!0;d=a;case"last":while(d=d.nextSibling)if(d.nodeType===1)return!1;return!0;case"nth":var e=b[2],f=b[3];if(e===1&&f===0)return!0;var g=b[0],h=a.parentNode;if(h&&(h.sizcache!==g||!a.nodeIndex)){var i=0;for(d=h.firstChild;d;d=d.nextSibling)d.nodeType===1&&(d.nodeIndex=++i);h.sizcache=g}var j=a.nodeIndex-f;return e===0?j===0:j%e===0&&j/e>=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c<f;c++)d.push(a[c]);else for(;a[c];c++)d.push(a[c]);return d}}var r,s;c.documentElement.compareDocumentPosition?r=function(a,b){if(a===b){g=!0;return 0}if(!a.compareDocumentPosition||!b.compareDocumentPosition)return a.compareDocumentPosition?-1:1;return a.compareDocumentPosition(b)&4?-1:1}:(r=function(a,b){if(a===b){g=!0;return 0}if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-b.sourceIndex;var c,d,e=[],f=[],h=a.parentNode,i=b.parentNode,j=h;if(h===i)return s(a,b);if(!h)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)f.unshift(j),j=j.parentNode;c=e.length,d=f.length;for(var k=0;k<c&&k<d;k++)if(e[k]!==f[k])return s(e[k],f[k]);return k===c?s(a,f[k],-1):s(e[k],b,1)},s=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),k.getText=function(a){var b="",c;for(var d=0;a[d];d++)c=a[d],c.nodeType===3||c.nodeType===4?b+=c.nodeValue:c.nodeType!==8&&(b+=k.getText(c.childNodes));return b},function(){var a=c.createElement("div"),d="script"+(new Date).getTime(),e=c.documentElement;a.innerHTML="<a name='"+d+"'/>",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="<p class='TEST'></p>";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="<div class='test e'></div><div class='test'></div>";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g<h;g++)k(a,f[g],d);return k.filter(e,d)};f.find=k,f.expr=k.selectors,f.expr[":"]=f.expr.filters,f.unique=k.uniqueSort,f.text=k.getText,f.isXMLDoc=k.isXML,f.contains=k.contains}();var O=/Until$/,P=/^(?:parents|prevUntil|prevAll)/,Q=/,/,R=/^.[^:#\[\.,]*$/,S=Array.prototype.slice,T=f.expr.match.POS,U={children:!0,contents:!0,next:!0,prev:!0};f.fn.extend({find:function(a){var b=this,c,d;if(typeof a!="string")return f(a).filter(function(){for(c=0,d=b.length;c<d;c++)if(f.contains(b[c],this))return!0});var e=this.pushStack("","find",a),g,h,i;for(c=0,d=this.length;c<d;c++){g=e.length,f.find(a,this[c],e);if(c>0)for(h=g;h<e.length;h++)for(i=0;i<g;i++)if(e[i]===e[h]){e.splice(h--,1);break}}return e},has:function(a){var b=f(a);return this.filter(function(){for(var a=0,c=b.length;a<c;a++)if(f.contains(this,b[a]))return!0})},not:function(a){return this.pushStack(W(this,a,!1),"not",a)},filter:function(a){return this.pushStack(W(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d<e;d++)i=a[d],j[i]||(j[i]=T.test(i)?f(i,b||this.context):i);while(g&&g.ownerDocument&&g!==b){for(i in j)h=j[i],(h.jquery?h.index(g)>-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=T.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d<e;d++){g=this[d];while(g){if(l?l.index(g)>-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a||typeof a=="string")return f.inArray(this[0],a?f(a):this.parent().children());return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(V(c[0])||V(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=S.call(arguments);O.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!U[a]?f.unique(e):e,(this.length>1||Q.test(d))&&P.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var X=/ jQuery\d+="(?:\d+|null)"/g,Y=/^\s+/,Z=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,$=/<([\w:]+)/,_=/<tbody/i,ba=/<|&#?\w+;/,bb=/<(?:script|object|embed|option|style)/i,bc=/checked\s*(?:[^=]|=\s*.checked.)/i,bd=/\/(java|ecma)script/i,be=/^\s*<!(?:\[CDATA\[|\-\-)/,bf={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,"",""]};bf.optgroup=bf.option,bf.tbody=bf.tfoot=bf.colgroup=bf.caption=bf.thead,bf.th=bf.td,f.support.htmlSerialize||(bf._default=[1,"div<div>","</div>"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(X,""):null;if(typeof a=="string"&&!bb.test(a)&&(f.support.leadingWhitespace||!Y.test(a))&&!bf[($.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Z,"<$1></$2>");try{for(var c=0,d=this.length;c<d;c++)this[c].nodeType===1&&(f.cleanData(this[c].getElementsByTagName("*")),this[c].innerHTML=a)}catch(e){this.empty().append(a)}}else f.isFunction(a)?this.each(function(b){var c=f(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(f.isFunction(a))return this.each(function(b){var c=f(this),d=c.html();c.replaceWith(a.call(this,b,d))});typeof a!="string"&&(a=f(a).detach());return this.each(function(){var b=this.nextSibling,c=this.parentNode;f(this).remove(),b?f(b).before(a):f(c).append(a)})}return this.length?this.pushStack(f(f.isFunction(a)?a():a),"replaceWith",a):this},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){var e,g,h,i,j=a[0],k=[];if(!f.support.checkClone&&arguments.length===3&&typeof j=="string"&&bc.test(j))return this.each(function(){f(this).domManip(a,c,d,!0)});if(f.isFunction(j))return this.each(function(e){var g=f(this);a[0]=j.call(this,e,c?g.html():b),g.domManip(a,c,d)});if(this[0]){i=j&&j.parentNode,f.support.parentNode&&i&&i.nodeType===11&&i.childNodes.length===this.length?e={fragment:i}:e=f.buildFragment(a,this,k),h=e.fragment,h.childNodes.length===1?g=h=h.firstChild:g=h.firstChild;if(g){c=c&&f.nodeName(g,"tr");for(var l=0,m=this.length,n=m-1;l<m;l++)d.call(c?bg(this[l],g):this[l],e.cacheable||m>1&&l<n?f.clone(h,!0,!0):h)}k.length&&f.each(k,bm)}return this}}),f.buildFragment=function(a,b,d){var e,g,h,i;b&&b[0]&&(i=b[0].ownerDocument||b[0]),i.createDocumentFragment||(i=c),a.length===1&&typeof a[0]=="string"&&a[0].length<512&&i===c&&a[0].charAt(0)==="<"&&!bb.test(a[0])&&(f.support.checkClone||!bc.test(a[0]))&&(g=!0,h=f.fragments[a[0]],h&&h!==1&&(e=h)),e||(e=i.createDocumentFragment(),f.clean(a,i,e,d)),g&&(f.fragments[a[0]]=h?e:1);return{fragment:e,cacheable:g}},f.fragments={},f.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){f.fn[a]=function(c){var d=[],e=f(c),g=this.length===1&&this[0].parentNode;if(g&&g.nodeType===11&&g.childNodes.length===1&&e.length===1){e[b](this[0]);return this}for(var h=0,i=e.length;h<i;h++){var j=(h>0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j
)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bi(a,d),e=bj(a),g=bj(d);for(h=0;e[h];++h)bi(e[h],g[h])}if(b){bh(a,d);if(c){e=bj(a),g=bj(d);for(h=0;e[h];++h)bh(e[h],g[h])}}e=g=null;return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!ba.test(k))k=b.createTextNode(k);else{k=k.replace(Z,"<$1></$2>");var l=($.exec(k)||["",""])[1].toLowerCase(),m=bf[l]||bf._default,n=m[0],o=b.createElement("div");o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=_.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]==="<table>"&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&Y.test(k)&&o.insertBefore(b.createTextNode(Y.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i<r;i++)bl(k[i]);else bl(k);k.nodeType?h.push(k):h=f.merge(h,k)}if(d){g=function(a){return!a.type||bd.test(a.type)};for(j=0;h[j];j++)if(e&&f.nodeName(h[j],"script")&&(!h[j].type||h[j].type.toLowerCase()==="text/javascript"))e.push(h[j].parentNode?h[j].parentNode.removeChild(h[j]):h[j]);else{if(h[j].nodeType===1){var s=f.grep(h[j].getElementsByTagName("script"),g);h.splice.apply(h,[j+1,0].concat(s))}d.appendChild(h[j])}}return h},cleanData:function(a){var b,c,d=f.cache,e=f.expando,g=f.event.special,h=f.support.deleteExpando;for(var i=0,j;(j=a[i])!=null;i++){if(j.nodeName&&f.noData[j.nodeName.toLowerCase()])continue;c=j[f.expando];if(c){b=d[c]&&d[c][e];if(b&&b.events){for(var k in b.events)g[k]?f.event.remove(j,k):f.removeEvent(j,k,b.handle);b.handle&&(b.handle.elem=null)}h?delete j[f.expando]:j.removeAttribute&&j.removeAttribute(f.expando),delete d[c]}}}});var bn=/alpha\([^)]*\)/i,bo=/opacity=([^)]*)/,bp=/([A-Z]|^ms)/g,bq=/^-?\d+(?:px)?$/i,br=/^-?\d/,bs=/^[+\-]=/,bt=/[^+\-\.\de]+/g,bu={position:"absolute",visibility:"hidden",display:"block"},bv=["Left","Right"],bw=["Top","Bottom"],bx,by,bz;f.fn.css=function(a,c){if(arguments.length===2&&c===b)return this;return f.access(this,a,c,!0,function(a,c,d){return d!==b?f.style(a,c,d):f.css(a,c)})},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bx(a,"opacity","opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d;if(h==="number"&&isNaN(d)||d==null)return;h==="string"&&bs.test(d)&&(d=+d.replace(bt,"")+parseFloat(f.css(a,c)),h="number"),h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(bx)return bx(a,c)},swap:function(a,b,c){var d={};for(var e in b)d[e]=a.style[e],a.style[e]=b[e];c.call(a);for(e in b)a.style[e]=d[e]}}),f.curCSS=f.css,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){var e;if(c){if(a.offsetWidth!==0)return bA(a,b,d);f.swap(a,bu,function(){e=bA(a,b,d)});return e}},set:function(a,b){if(!bq.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bo.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle;c.zoom=1;var e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.filter=bn.test(g)?g.replace(bn,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bx(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(by=function(a,c){var d,e,g;c=c.replace(bp,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bz=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bq.test(d)&&br.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bx=by||bz,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bB=/%20/g,bC=/\[\]$/,bD=/\r?\n/g,bE=/#.*$/,bF=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bG=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bH=/^(?:about|app|app\-storage|.+\-extension|file|widget):$/,bI=/^(?:GET|HEAD)$/,bJ=/^\/\//,bK=/\?/,bL=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bM=/^(?:select|textarea)/i,bN=/\s+/,bO=/([?&])_=[^&]*/,bP=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bQ=f.fn.load,bR={},bS={},bT,bU;try{bT=e.href}catch(bV){bT=c.createElement("a"),bT.href="",bT=bT.href}bU=bP.exec(bT.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bQ)return bQ.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("<div>").append(c.replace(bL,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bM.test(this.nodeName)||bG.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bD,"\r\n")}}):{name:b.name,value:c.replace(bD,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?f.extend(!0,a,f.ajaxSettings,b):(b=a,a=f.extend(!0,f.ajaxSettings,b));for(var c in{context:1,url:1})c in b?a[c]=b[c]:c in f.ajaxSettings&&(a[c]=f.ajaxSettings[c]);return a},ajaxSettings:{url:bT,isLocal:bH.test(bU[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML}},ajaxPrefilter:bW(bR),ajaxTransport:bW(bS),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a?4:0;var o,r,u,w=l?bZ(d,v,l):b,x,y;if(a>=200&&a<300||a===304){if(d.ifModified){if(x=v.getResponseHeader("Last-Modified"))f.lastModified[k]=x;if(y=v.getResponseHeader("Etag"))f.etag[k]=y}if(a===304)c="notmodified",o=!0;else try{r=b$(d,w),c="success",o=!0}catch(z){c="parsererror",u=z}}else{u=c;if(!c||a)c="error",a<0&&(a=0)}v.status=a,v.statusText=c,o?h.resolveWith(e,[r,c,v]):h.rejectWith(e,[v,c,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,c]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bF.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bE,"").replace(bJ,bU[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bN),d.crossDomain==null&&(r=bP.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bU[1]&&r[2]==bU[2]&&(r[3]||(r[1]==="http:"?80:443))==(bU[3]||(bU[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bX(bR,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bI.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bK.test(d.url)?"&":"?")+d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bO,"$1_="+x);d.url=y+(y===d.url?(bK.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", */*; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bX(bS,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){status<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)bY(g,a[g],c,e);return d.join("&").replace(bB,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var b_=f.now(),ca=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+b_++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ca.test(b.url)||e&&ca.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ca,l),b.url===j&&(e&&(k=k.replace(ca,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cb=a.ActiveXObject?function(){for(var a in cd)cd[a](0,1)}:!1,cc=0,cd;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ce()||cf()}:ce,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cb&&delete cd[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cc,cb&&(cd||(cd={},f(a).unload(cb)),cd[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cg={},ch,ci,cj=/^(?:toggle|show|hide)$/,ck=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cl,cm=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cn,co=a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cr("show",3),a,b,c);for(var g=0,h=this.length;g<h;g++)d=this[g],d.style&&(e=d.style.display,!f._data(d,"olddisplay")&&e==="none"&&(e=d.style.display=""),e===""&&f.css(d,"display")==="none"&&f._data(d,"olddisplay",cs(d.nodeName)));for(g=0;g<h;g++){d=this[g];if(d.style){e=d.style.display;if(e===""||e==="none")d.style.display=f._data(d,"olddisplay")||""}}return this},hide:function(a,b,c){if(a||a===0)return this.animate(cr("hide",3),a,b,c);for(var d=0,e=this.length;d<e;d++)if(this[d].style){var g=f.css(this[d],"display");g!=="none"&&!f._data(this[d],"olddisplay")&&f._data(this[d],"olddisplay",g)}for(d=0;d<e;d++)this[d].style&&(this[d].style.display="none");return this},_toggle:f.fn.toggle,toggle:function(a,b,c){var d=typeof a=="boolean";f.isFunction(a)&&f.isFunction(b)?this._toggle.apply(this,arguments):a==null||d?this.each(function(){var b=d?a:f(this).is(":hidden");f(this)[b?"show":"hide"]()}):this.animate(cr("toggle",3),a,b,c);return this},fadeTo:function(a,b,c,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=f.speed(b,c,d);if(f.isEmptyObject(a))return this.each(e.complete,[!1]);a=f.extend({},a);return this[e.queue===!1?"each":"queue"](function(){e.queue===!1&&f._mark(this);var b=f.extend({},e),c=this.nodeType===1,d=c&&f(this).is(":hidden"),g,h,i,j,k,l,m,n,o;b.animatedProperties={};for(i in a){g=f.camelCase(i),i!==g&&(a[g]=a[i],delete a[i]),h=a[g],f.isArray(h)?(b.animatedProperties[g]=h[1],h=a[g]=h[0]):b.animatedProperties[g]=b.specialEasing&&b.specialEasing[g]||b.easing||"swing";if(h==="hide"&&d||h==="show"&&!d)return b.complete.call(this);c&&(g==="height"||g==="width")&&(b.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY],f.css(this,"display")==="inline"&&f.css(this,"float")==="none"&&(f.support.inlineBlockNeedsLayout?(j=cs(this.nodeName),j==="inline"?this.style.display="inline-block":(this.style.display="inline",this.style.zoom=1)):this.style.display="inline-block"))}b.overflow!=null&&(this.style.overflow="hidden");for(i in a)k=new f.fx(this,b,i),h=a[i],cj.test(h)?k[h==="toggle"?d?"show":"hide":h]():(l=ck.exec(h),m=k.cur(),l?(n=parseFloat(l[2]),o=l[3]||(f.cssNumber[i]?"":"px"),o!=="px"&&(f.style(this,i,(n||1)+o),m=(n||1)/k.cur()*m,f.style(this,i,m+o)),l[1]&&(n=(l[1]==="-="?-1:1)*n+m),k.custom(m,n,o)):k.custom(m,h,""));return!0})},stop:function(a,b){a&&this.queue([]),this.each(function(){var a=f.timers,c=a.length;b||f._unmark(!0,this);while(c--)a[c].elem===this&&(b&&a[c](!0),a.splice(c,1))}),b||this.dequeue();return this}}),f.each({slideDown:cr("show",1),slideUp:cr("hide",1),slideToggle:cr("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){f.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),f.extend({speed:function(a,b,c){var d=a&&typeof a=="object"?f.extend({},a):{complete:c||!c&&b||f.isFunction(a)&&a,duration:a,easing:c&&b||b&&!f.isFunction(b)&&b};d.duration=f.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in f.fx.speeds?f.fx.speeds[d.duration]:f.fx.speeds._default,d.old=d.complete,d.complete=function(a){f.isFunction(d.old)&&d.old.call(this),d.queue!==!1?f.dequeue(this):a!==!1&&f._unmark(this)};return d},easing:{linear:function(a,b,c,d){return c+d*a},swing:function(a,b,c,d){return(-Math.cos(a*Math.PI)/2+.5)*d+c}},timers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig=b.orig||{}}}),f.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(f.fx.step[this.prop]||f.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a,b=f.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a},custom:function(a,b,c){function h(a){return d.step(a)}var d=this,e=f.fx,g;this.startTime=cn||cp(),this.start=a,this.end=b,this.unit=c||this.unit||(f.cssNumber[this.prop]?"":"px"),this.now=this.start,this.pos=this.state=0,h.elem=this.elem,h()&&f.timers.push(h)&&!cl&&(co?(cl=!0,g=function(){cl&&(co(g),e.tick())},co(g)):cl=setInterval(e.tick,e.interval))},show:function(){this.options.orig[this.prop]=f.style(this.elem,this.prop),this.options.show=!0,this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),f(this.elem).show()},hide:function(){this.options.orig[this.prop]=f.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b=cn||cp(),c=!0,d=this.elem,e=this.options,g,h;if(a||b>=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){for(var a=f.timers,b=0;b<a.length;++b)a[b]()||a.splice(b--,1);a.length||f.fx.stop()},interval:13,stop:function(){clearInterval(cl),cl=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){f.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit:a.elem[a.prop]=a.now}}}),f.expr&&f.expr.filters&&(f.expr.filters.animated=function(a){return f.grep(f.timers,function(b){return a===b.elem}).length});var ct=/^t(?:able|d|h)$/i,cu=/^(?:body|html)$/i;"getBoundingClientRect"in c.documentElement?f.fn.offset=function(a){var b=this[0],c;if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);try{c=b.getBoundingClientRect()}catch(d){}var e=b.ownerDocument,g=e.documentElement;if(!c||!f.contains(g,b))return c?{top:c.top,left:c.left}:{top:0,left:0};var h=e.body,i=cv(e),j=g.clientTop||h.clientTop||0,k=g.clientLeft||h.clientLeft||0,l=i.pageYOffset||f.support.boxModel&&g.scrollTop||h.scrollTop,m=i.pageXOffset||f.support.boxModel&&g.scrollLeft||h.scrollLeft,n=c.top+l-j,o=c.left+m-k;return{top:n,left:o}}:f.fn.offset=function(a){var b=this[0];if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);f.offset.initialize();var c,d=b.offsetParent,e=b,g=b.ownerDocument,h=g.documentElement,i=g.body,j=g.defaultView,k=j?j.getComputedStyle(b,null):b.currentStyle,l=b.offsetTop,m=b.offsetLeft;while((b=b.parentNode)&&b!==i&&b!==h){if(f.offset.supportsFixedPosition&&k.position==="fixed")break;c=j?j.getComputedStyle(b,null):b.currentStyle,l-=b.scrollTop,m-=b.scrollLeft,b===d&&(l+=b.offsetTop,m+=b.offsetLeft,f.offset.doesNotAddBorder&&(!f.offset.doesAddBorderForTableAndCells||!ct.test(b.nodeName))&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),e=d,d=b.offsetParent),f.offset.subtractsBorderForOverflowNotVisible&&c.overflow!=="visible"&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),k=c}if(k.position==="relative"||k.position==="static")l+=i.offsetTop,m+=i.offsetLeft;f.offset.supportsFixedPosition&&k.position==="fixed"&&(l+=Math.max(h.scrollTop,i.scrollTop),m+=Math.max(h.scrollLeft,i.scrollLeft));return{top:l,left:m}},f.offset={initialize:function(){var a=c.body,b=c.createElement("div"),d,e,g,h,i=parseFloat(f.css(a,"marginTop"))||0,j="<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>";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),f.offset.initialize=f.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.offset.initialize(),f.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cu.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cu.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cv(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cv(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a&&a.style?parseFloat(f.css(a,d,"padding")):null},f.fn["outer"+c]=function(a){var b=this[0];return b&&b.style?parseFloat(f.css(b,d,a?"margin":"border")):null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c];return e.document.compatMode==="CSS1Compat"&&g||e.document.body["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var h=f.css(e,d),i=parseFloat(h);return f.isNaN(i)?h:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window);

(function(h){var j=false,n=/xyz/.test(function(){})?/\b_super\b/:/.*/,l=function(a,c,d){d=d||a;for(var b in a)d[b]=typeof a[b]=="function"&&typeof c[b]=="function"&&n.test(a[b])?function(i,g){return function(){var e=this._super,f;this._super=c[i];f=g.apply(this,arguments);this._super=e;return f}}(b,a[b]):a[b]};jQuery.Class=function(){arguments.length&&this.extend.apply(this,arguments)};h.extend(h.Class,{callback:function(a){var c=jQuery.makeArray(arguments),d;a=c.shift();jQuery.isArray(a)||(a=[a]);
d=this;return function(){for(var b=c.concat(jQuery.makeArray(arguments)),i,g=a.length,e=0,f;e<g;e++)if(f=a[e]){if((i=typeof f=="string")&&d._set_called)d.called=f;b=(i?d[f]:f).apply(d,b||[]);if(e<g-1)b=!jQuery.isArray(b)||b._use_call?[b]:b}return b}},getObject:function(a,c){c=c||window;a=a?a.split(/\./):[];for(var d=0;d<a.length;d++)c=c[a[d]]||(c[a[d]]={});return c},newInstance:function(){var a=this.rawInstance(),c;if(a.setup)c=a.setup.apply(a,arguments);if(a.init)a.init.apply(a,h.isArray(c)?c:arguments);
return a},setup:function(a){this.defaults=h.extend(true,{},a.defaults,this.defaults);return arguments},rawInstance:function(){j=true;var a=new this;j=false;return a},extend:function(a,c,d){function b(){if(!j)return this.constructor!==b&&arguments.length?this.extend.apply(this,arguments):this.Class.newInstance.apply(this.Class,arguments)}if(typeof a!="string"){d=c;c=a;a=null}if(!d){d=c;c=null}d=d||{};var i=this,g=this.prototype,e,f,m,k;j=true;k=new this;j=false;l(d,g,k);for(e in this)if(this.hasOwnProperty(e)&&
h.inArray(e,["prototype","defaults","getObject"])==-1)b[e]=this[e];l(c,this,b);if(a){g=a.split(/\./);f=g.pop();m=current=h.Class.getObject(g.join("."));current[f]=b}h.extend(b,{prototype:k,namespace:m,shortName:f,constructor:b,fullName:a});b.prototype.Class=b.prototype.constructor=b;i=b.setup.apply(b,[i].concat(h.makeArray(arguments)));if(b.init)b.init.apply(b,i||[]);return b}});jQuery.Class.prototype.callback=jQuery.Class.callback})(jQuery);


jQuery.cookie=function(a,b,c){if(arguments.length>1&&(b===null||typeof b!=="object")){c=jQuery.extend({},c);if(b===null){c.expires=-1}if(typeof c.expires==='number'){var d=c.expires,t=c.expires=new Date();t.setDate(t.getDate()+d)}return(document.cookie=[encodeURIComponent(a),'=',c.raw?String(b):encodeURIComponent(String(b)),c.expires?'; expires='+c.expires.toUTCString():'',c.path?'; path='+c.path:'',c.domain?'; domain='+c.domain:'',c.secure?'; secure':''].join(''))}c=b||{};var e,decode=c.raw?function(s){return s}:decodeURIComponent;return(e=new RegExp('(?:^|; )'+encodeURIComponent(a)+'=([^;]*)').exec(document.cookie))?decode(e[1]):null};



/**
 * jQuery Templates
 *
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Written by: Stan Lemon <stanlemon@mac.com>
 *
 * Based off of the Ext.Template library, available at:
 * http://www.extjs.com
 *
 * This library provides basic templating functionality, allowing for macro-based
 * templates within jQuery.
 *
 * Basic Usage:
 *
 * var t = $.template('<div id="foo">Hello ${name}, how are you ${question}?  I am ${me:substr(0,10)}</div>');
 *
 * $(selector).append( t , {
 *     name: 'Stan',
 *     question: 'feeling',
 *     me: 'doing quite well myself, thank you very much!'
 * });
 *
 * Requires: jQuery 1.2+
 *
 *
 * @todo    Add callbacks to the DOM manipulation methods, so that events can be bound
 *          to template nodes after creation.
 */
(function($){

    /**
     * Create a New Template
     */
    $.template = function(html, options) {
        return new $.template.instance(html, options);
    };

    /**
     * Template constructor - Creates a new template instance.
     *
     * @param 	html 	The string of HTML to be used for the template.
     * @param 	options An object of configurable options.  Currently
     * 			you can toggle compile as a boolean value and set a custom
     *          template regular expression on the property regx by
     *          specifying the key of the regx to use from the regx object.
     */
    $.template.instance = function(html, options) {
        // If a custom regular expression has been set, grab it from the regx object
        if ( options && options['regx'] ) options.regx = this.regx[ options.regx ];

        this.options = $.extend({
            compile: 		false,
            regx:           this.regx.standard
        }, options || {});

        this.html = html;

        if (this.options.compile) {
            this.compile();
        }
        this.isTemplate = true;
    };

    /**
     * Regular Expression for Finding Variables
     *
     * The default pattern looks for variables in JSP style, the form of: ${variable}
     * There are also regular expressions available for ext-style variables and
     * jTemplate style variables.
     *
     * You can add your own regular expressions for variable ussage by doing.
     * $.extend({ $.template.re , {
     *     myvartype: /...../g
     * }
     *
     * Then when creating a template do:
     * var t = $.template("<div>...</div>", { regx: 'myvartype' });
     */
    $.template.regx = $.template.instance.prototype.regx = {
        jsp:        /\$\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
        ext:        /\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
        jtemplates: /\{\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}\}/g
    };

    /**
     * Set the standard regular expression to be used.
     */
    $.template.regx.standard = $.template.regx.jsp;

    /**
     * Variable Helper Methods
     *
     * This is a collection of methods which can be used within the variable syntax, ie:
     * ${variable:substr(0,30)} Which would only print a substring, 30 characters in length
     * begining at the first character for the variable named "variable".
     *
     * A basic substring helper is provided as an example of how you can define helpers.
     * To add more helpers simply do:
     * $.extend( $.template.helpers , {
     *	 sampleHelper: function() { ... }
     * });
     */
    $.template.helpers = $.template.instance.prototype.helpers = {
        substr : function(value, start, length){
            return String(value).substr(start, length);
        }
    };


    /**
     * Template Instance Methods
     */
    $.extend( $.template.instance.prototype, {

        /**
         * Apply Values to a Template
         *
         * This is the macro-work horse of the library, it receives an object
         * and the properties of that objects are assigned to the template, where
         * the variables in the template represent keys within the object itself.
         *
         * @param 	values 	An object of properties mapped to template variables
         */
        apply: function(values) {
            if (this.options.compile) {
                return this.compiled(values);
            } else {
                var tpl = this;
                var fm = this.helpers;

                var fn = function(m, name, format, args) {
                    if (format) {
                        if (format.substr(0, 5) == "this."){
                            return tpl.call(format.substr(5), values[name], values);
                        } else {
                            if (args) {
                                // quoted values are required for strings in compiled templates,
                                // but for non compiled we need to strip them
                                // quoted reversed for jsmin
                                var re = /^\s*['"](.*)["']\s*$/;
                                args = args.split(',');

                                for(var i = 0, len = args.length; i < len; i++) {
                                    args[i] = args[i].replace(re, "$1");
                                }
                                args = [values[name]].concat(args);
                            } else {
                                args = [values[name]];
                            }

                            return fm[format].apply(fm, args);
                        }
                    } else {
                        return values[name] !== undefined ? values[name] : "";
                    }
                };

                return this.html.replace(this.options.regx, fn);
            }
        },

        /**
         * Compile a template for speedier usage
         */
        compile: function() {
            var sep = $.browser.mozilla ? "+" : ",";
            var fm = this.helpers;

            var fn = function(m, name, format, args){
                if (format) {
                    args = args ? ',' + args : "";

                    if (format.substr(0, 5) != "this.") {
                        format = "fm." + format + '(';
                    } else {
                        format = 'this.call("'+ format.substr(5) + '", ';
                        args = ", values";
                    }
                } else {
                    args= ''; format = "(values['" + name + "'] == undefined ? '' : ";
                }
                return "'"+ sep + format + "values['" + name + "']" + args + ")"+sep+"'";
            };

            var body;

            if ($.browser.mozilla) {
                body = "this.compiled = function(values){ return '" +
                       this.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.options.regx, fn) +
                        "';};";
            } else {
                body = ["this.compiled = function(values){ return ['"];
                body.push(this.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.options.regx, fn));
                body.push("'].join('');};");
                body = body.join('');
            }
            eval(body);
            return this;
        }
    });


    /**
     * Save a reference in this local scope to the original methods which we're
     * going to overload.
     **/
    var $_old = {
        domManip: $.fn.domManip,
        text: $.fn.text,
        html: $.fn.html
    };

    /**
     * Overwrite the domManip method so that we can use things like append() by passing a
     * template object and macro parameters.
     */
    $.fn.domManip = function( args, table, reverse, callback ) {
        if (args[0].isTemplate) {
            // Apply the template and it's arguments...
            args[0] = args[0].apply( args[1] );
            // Get rid of the arguements, we don't want to pass them on
            delete args[1];
        }

        // Call the original method
        var r = $_old.domManip.apply(this, arguments);

        return r;
    };

    /**
     * Overwrite the html() method
     */
    $.fn.html = function( value , o ) {
        if (value && value.isTemplate) var value = value.apply( o );

        var r = $_old.html.apply(this, [value]);

        return r;
    };

    /**
     * Overwrite the text() method
     */
    $.fn.text = function( value , o ) {
        if (value && value.isTemplate) var value = value.apply( o );

        var r = $_old.text.apply(this, [value]);

        return r;
    };

})(jQuery);


/*

 jQuery Tools 1.2.5 / Flashembed - New wave Flash embedding

 NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.

 http://flowplayer.org/tools/toolbox/flashembed.html

 Since : March 2008
 Date  :    Wed Sep 22 06:02:10 2010 +0000
*/
(function(){function f(a,b){if(b)for(var c in b)if(b.hasOwnProperty(c))a[c]=b[c];return a}function l(a,b){var c=[];for(var d in a)if(a.hasOwnProperty(d))c[d]=b(a[d]);return c}function m(a,b,c){if(e.isSupported(b.version))a.innerHTML=e.getHTML(b,c);else if(b.expressInstall&&e.isSupported([6,65]))a.innerHTML=e.getHTML(f(b,{src:b.expressInstall}),{MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title});else{if(!a.innerHTML.replace(/\s/g,"")){a.innerHTML="<h2>Flash version "+b.version+
" or greater is required</h2><h3>"+(g[0]>0?"Your version is "+g:"You have no flash plugin installed")+"</h3>"+(a.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='"+k+"'>here</a></p>");if(a.tagName=="A")a.onclick=function(){location.href=k}}if(b.onFail){var d=b.onFail.call(this);if(typeof d=="string")a.innerHTML=d}}if(i)window[b.id]=document.getElementById(b.id);f(this,{getRoot:function(){return a},getOptions:function(){return b},getConf:function(){return c},
getApi:function(){return a.firstChild}})}var i=document.all,k="http://www.adobe.com/go/getflashplayer",n=typeof jQuery=="function",o=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,j={width:"100%",height:"100%",id:"_"+(""+Math.random()).slice(9),allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:[3,0],onFail:null,expressInstall:null,w3c:false,cachebusting:false};window.attachEvent&&window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}});
window.flashembed=function(a,b,c){if(typeof a=="string")a=document.getElementById(a.replace("#",""));if(a){if(typeof b=="string")b={src:b};return new m(a,f(f({},j),b),c)}};var e=f(window.flashembed,{conf:j,getVersion:function(){var a,b;try{b=navigator.plugins["Shockwave Flash"].description.slice(16)}catch(c){try{b=(a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"))&&a.GetVariable("$version")}catch(d){try{b=(a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"))&&a.GetVariable("$version")}catch(h){}}}return(b=
o.exec(b))?[b[1],b[3]]:[0,0]},asString:function(a){if(a===null||a===undefined)return null;var b=typeof a;if(b=="object"&&a.push)b="array";switch(b){case "string":a=a.replace(new RegExp('(["\\\\])',"g"),"\\$1");a=a.replace(/^\s?(\d+\.?\d+)%/,"$1pct");return'"'+a+'"';case "array":return"["+l(a,function(d){return e.asString(d)}).join(",")+"]";case "function":return'"function()"';case "object":b=[];for(var c in a)a.hasOwnProperty(c)&&b.push('"'+c+'":'+e.asString(a[c]));return"{"+b.join(",")+"}"}return String(a).replace(/\s/g,
" ").replace(/\'/g,'"')},getHTML:function(a,b){a=f({},a);var c='<object width="'+a.width+'" height="'+a.height+'" id="'+a.id+'" name="'+a.id+'"';if(a.cachebusting)a.src+=(a.src.indexOf("?")!=-1?"&":"?")+Math.random();c+=a.w3c||!i?' data="'+a.src+'" type="application/x-shockwave-flash"':' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';c+=">";if(a.w3c||i)c+='<param name="movie" value="'+a.src+'" />';a.width=a.height=a.id=a.w3c=a.src=null;a.onFail=a.version=a.expressInstall=null;for(var d in a)if(a[d])c+=
'<param name="'+d+'" value="'+a[d]+'" />';a="";if(b){for(var h in b)if(b[h]){d=b[h];a+=h+"="+(/function|object/.test(typeof d)?e.asString(d):d)+"&"}a=a.slice(0,-1);c+='<param name="flashvars" value=\''+a+"' />"}c+="</object>";return c},isSupported:function(a){return g[0]>a[0]||g[0]==a[0]&&g[1]>=a[1]}}),g=e.getVersion();if(n){jQuery.tools=jQuery.tools||{version:"1.2.5"};jQuery.tools.flashembed={conf:j};jQuery.fn.flashembed=function(a,b){return this.each(function(){$(this).data("flashembed",flashembed(this,
a,b))})}}})();


(function(D){var A="Lite-1.0";D.fn.cycle=function(E){return this.each(function(){E=E||{};if(this.cycleTimeout){clearTimeout(this.cycleTimeout)}this.cycleTimeout=0;this.cyclePause=0;var I=D(this);var J=E.slideExpr?D(E.slideExpr,this):I.children();var G=J.get();if(G.length<2){if(window.console&&window.console.log){window.console.log("terminating; too few slides: "+G.length)}return }var H=D.extend({},D.fn.cycle.defaults,E||{},D.metadata?I.metadata():D.meta?I.data():{});H.before=H.before?[H.before]:[];H.after=H.after?[H.after]:[];H.after.unshift(function(){H.busy=0});var F=this.className;H.width=parseInt((F.match(/w:(\d+)/)||[])[1])||H.width;H.height=parseInt((F.match(/h:(\d+)/)||[])[1])||H.height;H.timeout=parseInt((F.match(/t:(\d+)/)||[])[1])||H.timeout;if(I.css("position")=="static"){I.css("position","relative")}if(H.width){I.width(H.width)}if(H.height&&H.height!="auto"){I.height(H.height)}var K=0;J.css({position:"absolute",top:0,left:0}).hide().each(function(M){D(this).css("z-index",G.length-M)});D(G[K]).css("opacity",1).show();if(D.browser.msie){G[K].style.removeAttribute("filter")}if(H.fit&&H.width){J.width(H.width)}if(H.fit&&H.height&&H.height!="auto"){J.height(H.height)}if(H.pause){I.hover(function(){this.cyclePause=1},function(){this.cyclePause=0})}D.fn.cycle.transitions.fade(I,J,H);J.each(function(){var M=D(this);this.cycleH=(H.fit&&H.height)?H.height:M.height();this.cycleW=(H.fit&&H.width)?H.width:M.width()});J.not(":eq("+K+")").css({opacity:0});if(H.cssFirst){D(J[K]).css(H.cssFirst)}if(H.timeout){if(H.speed.constructor==String){H.speed={slow:600,fast:200}[H.speed]||400}if(!H.sync){H.speed=H.speed/2}while((H.timeout-H.speed)<250){H.timeout+=H.speed}}H.speedIn=H.speed;H.speedOut=H.speed;H.slideCount=G.length;H.currSlide=K;H.nextSlide=1;var L=J[K];if(H.before.length){H.before[0].apply(L,[L,L,H,true])}if(H.after.length>1){H.after[1].apply(L,[L,L,H,true])}if(H.click&&!H.next){H.next=H.click}if(H.next){D(H.next).bind("click",function(){return C(G,H,H.rev?-1:1)})}if(H.prev){D(H.prev).bind("click",function(){return C(G,H,H.rev?1:-1)})}if(H.timeout){this.cycleTimeout=setTimeout(function(){B(G,H,0,!H.rev)},H.timeout+(H.delay||0))}})};function B(J,E,I,K){if(E.busy){return }var H=J[0].parentNode,M=J[E.currSlide],L=J[E.nextSlide];if(H.cycleTimeout===0&&!I){return }if(I||!H.cyclePause){if(E.before.length){D.each(E.before,function(N,O){O.apply(L,[M,L,E,K])})}var F=function(){if(D.browser.msie){this.style.removeAttribute("filter")}D.each(E.after,function(N,O){O.apply(L,[M,L,E,K])})};if(E.nextSlide!=E.currSlide){E.busy=1;D.fn.cycle.custom(M,L,E,F)}var G=(E.nextSlide+1)==J.length;E.nextSlide=G?0:E.nextSlide+1;E.currSlide=G?J.length-1:E.nextSlide-1}if(E.timeout){H.cycleTimeout=setTimeout(function(){B(J,E,0,!E.rev)},E.timeout)}}function C(E,F,I){var H=E[0].parentNode,G=H.cycleTimeout;if(G){clearTimeout(G);H.cycleTimeout=0}F.nextSlide=F.currSlide+I;if(F.nextSlide<0){F.nextSlide=E.length-1}else{if(F.nextSlide>=E.length){F.nextSlide=0}}B(E,F,1,I>=0);return false}D.fn.cycle.custom=function(K,H,I,E){var J=D(K),G=D(H);G.css({opacity:0});var F=function(){G.animate({opacity:1},I.speedIn,I.easeIn,E)};J.animate({opacity:0},I.speedOut,I.easeOut,function(){J.css({display:"none"});if(!I.sync){F()}});if(I.sync){F()}};D.fn.cycle.transitions={fade:function(F,G,E){G.not(":eq(0)").css("opacity",0);E.before.push(function(){D(this).show()})}};D.fn.cycle.ver=function(){return A};D.fn.cycle.defaults={timeout:4000,speed:1000,next:null,prev:null,before:null,after:null,height:"auto",sync:1,fit:0,pause:0,delay:0,slideExpr:null}})(jQuery);

(function(a){a.fn.equalHeights=function(c,b){tallest=(c)?c:0;this.each(function(){if(a(this).height()>tallest){tallest=a(this).height()}});if((b)&&tallest>b){tallest=b}return this.each(function(){a(this).height(tallest).css("overflow","auto")})}})(jQuery);

(function(f){function l(g,h){function d(a){if(!e){e=true;c.start&&c.start(a,b)}}function i(a,j){if(e){clearTimeout(k);k=setTimeout(function(){e=false;c.stop&&c.stop(a,b)},j>=0?j:c.delay)}}var c=f.extend({start:null,stop:null,delay:400},h),b=f(g),e=false,k;b.keypress(d);b.keydown(function(a){if(a.keyCode===8||a.keyCode===46)d(a)});b.keyup(i);b.blur(function(a){i(a,0)})}f.fn.typing=function(g){return this.each(function(h,d){l(d,g)})}})(jQuery);



/*
 * jQuery plugin: fieldSelection - v0.1.0 - last change: 2006-12-16
 * (c) 2006 Alex Brem <alex@0xab.cd> - http://blog.0xab.cd
 */
(function(){var c={getSelection:function(){var e=this.jquery?this[0]:this;return(('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)}})||(document.selection&&function(){e.focus();var r=document.selection.createRange();if(r==null){return{start:0,end:e.value.length,length:0}}var a=e.createTextRange();var b=a.duplicate();a.moveToBookmark(r.getBookmark());b.setEndPoint('EndToStart',a);return{start:b.text.length,end:b.text.length+r.text.length,length:r.text.length,text:r.text}})||function(){return{start:0,end:e.value.length,length:0}})()},replaceSelection:function(){var e=this.jquery?this[0]:this;var a=arguments[0]||'';return(('selectionStart'in e&&function(){e.value=e.value.substr(0,e.selectionStart)+a+e.value.substr(e.selectionEnd,e.value.length);return this})||(document.selection&&function(){e.focus();document.selection.createRange().text=a;return this})||function(){e.value+=a;return this})()}};jQuery.each(c,function(i){jQuery.fn[i]=this})})();


//
// Fotolia objects
//

$.Class.extend('Fotolia',
// Static properties
{
    initialize: function()
    {
        Fotolia_Toggle.initialize();

        Fotolia_Search_Toggle.initialize();

        Fotolia.initImageFaders();

        Fotolia_Design.initialize();

        Fotolia_Tooltip.initialize();
        Fotolia_Popup.initialize();

        Fotolia_AjaxActions.initialize();

        Fotolia_Lightbox.initialize();

        Fotolia_Form.initialize();
        Fotolia_Div_Select.initialize();

        Fotolia_AutoFormFields.initialize();

        Fotolia_ShoppingCart.initialize();
        Fotolia_CartSummary.initialize();

        Fotolia_SearchColorPicker.initialize();
        Fotolia_Search.initialize();
        Fotolia_Pagination.initialize();
        Fotolia_Content.initialize();

        Fotolia_Flash.initialize();

        Fotolia_Zoom.initialize();

        $('a.confirm_delete').click(Fotolia.confirmDeleteClick);

        $('a.new_window').click(Fotolia.clickOpenNewWindow);
    },

    initImageFaders: function()
    {
        $('div.fader_content_list').each(function(index) {
            var obj = $(this);
            var json_content_data = obj.html();
            var id_parts = obj.attr('id').split(':');

            var container_obj = $('[id="fader_image_holder:' + id_parts[1] + '"]');

            Fotolia.populate(json_content_data, container_obj);

            container_obj.cycle({
                fx: 'fade',
                before:Fotolia.onBeforeFader,
                timeout: 5000
            });
        });

        $('[id^="fader_image_container:"]').cycle({
            fx: 'fade',
            timeout: 5000
        });
    },

    populate: function (json_data, div)
    {
        var data = $.parseJSON(json_data);
        div = $(div);

        for (i in data) {
            div.append('<a id="L_intro_fader:' + data[i].id + '" href="' + data[i].url + '">' + data[i].src + '</a>');
        }
    },

    onBeforeFader: function(currSlideElement, nextSlideElement, options, forwardFlag)
    {
        $(nextSlideElement).not(':has(img)').html('<img src="' + $(nextSlideElement).html() + '">');
    },

    goToPage: function(n, limit, nb_contents, url)
    {
        if (n != parseInt(n)) {
            return;
        }

        if (n < 1) {
            n = 1;
        } else if (n > Math.ceil(nb_contents / limit)) {
            n = Math.ceil(nb_contents / limit);
        }

        window.location.href = url + ((n - 1) * limit);
    },

    getURLVars: function()
    {
        var url_vars = {};
        var hash = '';

        if (window.location.href.indexOf('?') != -1) {

            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

            for (var i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                url_vars[hash[0]] = decodeURIComponent(hash[1]);
            }
        }
        return url_vars;
    },

    buildURL: function(base_url, query_array)
    {
        var hashes = new Array();

        for (i in query_array) {
            hashes.push(i + '=' + encodeURIComponent(query_array[i]));
        }

        if (base_url === null) {
            if (window.location.href.indexOf('?') != -1) {
                base_url = window.location.href.slice(0, window.location.href.indexOf('?'));
            } else {
                base_url = window.location.href;
            }
        }

        return base_url + '?' + hashes.join('&');
    },

    go: function(url)
    {
        window.location.href = url;
    },

    /**
     * Handles events, calls the proper method
     *
     * @param Event e The event object for the event
     */
    eventHandler: function(e)
    {
        e.data.obj[e.data.method](e, $(this));
    },

    /**
     * Handles events, calls the proper method
     *
     * @param Event e The event object for the event
     */
    eventHandler: function(e)
    {
        e.data.obj[e.data.method](e, $(this));
    },

    singlePostSubmit: function(e)
    {
        var form = $(this);
        var submit_form = true;

        if (form && form.data('is_posted')) {

            submit_form = false;
            e.stopPropagation();

        } else {

            submit_form = true;
            form.data('is_posted', true);

        }

        return submit_form;
    },

    confirmDeleteClick: function(e)
    {
        if (!confirm(_('Are you sure you want to delete this?'))) {
            e.stopImmediatePropagation();
            return false;
        }
    },

    clickOpenNewWindow: function(e)
    {
        window.open($(this).attr('href'));

        e.stopPropagation();
        return false;
    },

    showMessage: function(message)
    {
        alert(message);
    },

    formatNumber: function(number, decimals)
    {
        if (!decimals) {
            decimals = 2;
        }

        return number.toFixed(decimals);
    },

    lastEmptyFunction: function() {}
},
//Class Properties
{
});

/**
 * Fotolia_Locale have to be initialize from view with current locale
 */
$.Class.extend('Fotolia_Locale',
// Static properties
{
    localisations: {},
    current_localisation: null,
    current_local: 'en_US',

    initialize: function(current_locale) {

        if (current_locale && typeof Fotolia_Locale.localisations[current_locale] != 'undefined') {
            Fotolia_Locale.current_locale = current_locale;
        }

        if (typeof Fotolia_Locale.localisations[current_locale] != 'undefined') {
            Fotolia_Locale.current_localisation = Fotolia_Locale.localisations[current_locale];
        }
    }
},
//Class Properties
{
});

/**
 * all AJAX actions
 */
$.Class.extend('Fotolia_AjaxActions',
// Static properties
{
    obj: null,

    initialize: function()
    {
        // attache event to each link with href like '*/Ajax*', event if they aprear after page loading
        $('a[href^="/Ajax"]:not(.no_ajax_bind)').live('click', Fotolia_AjaxActions.basicClick);
    },

    basicClick: function(e)
    {
        Fotolia_AjaxActions.ajaxCall($(this).attr('href'), $(this));

        e.stopImmediatePropagation();

        return false;
    },

    radioClick: function(e)
    {
        var url = $(this).attr('href');

        Fotolia_AjaxActions.ajaxCall($(this).attr('href'), $(this));

        e.stopImmediatePropagation();

        return false;
    },

    ajaxCall: function(url, source_object)
    {
        $.ajax({
            url: url,
            type: 'GET',
            complete: Fotolia_AjaxActions.ajaxCallback,
            error: Fotolia_AjaxActions.ajaxError,
            context: source_object,
            dataType: 'text'
        });

        return false;
    },

    ajaxPostCall: function (url, source_object, data, error_callback)
    {
        if (typeof error_callback == 'undefined') {
            error_callback == 'Fotolia_AjaxActions.ajaxError';
        }

        $.ajax({
            url: url,
            type: 'POST',
            complete: Fotolia_AjaxActions.ajaxCallback,
            error: error_callback,
            context: source_object,
            dataType: 'text',
            data: data
        });

        return false;
    },

    ajaxCallback: function(XHR, text_status)
    {
        Fotolia_AjaxActions.obj = $(this);
        eval(XHR.responseText);
        Fotolia_AjaxActions.obj = null;
    },

    ajaxError: function(XHR, text_status, error_thrown)
    {
    },

    confirmAjaxCall: function(e)
    {
        if (confirm(_('Are you sure?'))) {
            Fotolia_AjaxActions.ajaxCall($(this).attr('href'), $(this));
        }

        e.stopImmediatePropagation();
        return false;
    }

},
//Class Properties
{
});

$.Class.extend('Fotolia_AutoFormFields',
// Static properties
{
    initialize: function()
    {
        $('div.auto_drop').each(Fotolia_AutoFormFields.initializeAutoDropdown);
    },

    /**
     * Initialize auto drop downs
     */
    initializeAutoDropdown: function()
    {
        var main_obj = $(this);
        var drop_down_holder_obj = $('div.auto_drop_holder', main_obj);
        var select_obj = $('select', drop_down_holder_obj);

        $('span.auto_drop_title', main_obj).each(function() {
            // Select next div tag with class auto_drop_body
            var body_div = $(this).next('.auto_drop_body');

            select_obj.append($('<option>' + $(this).html() + '</option>').data('body_div', body_div));

            body_div.hide();
        });

        select_obj.change(Fotolia_AutoFormFields.changeAutoDropdown);

        Fotolia_AutoFormFields._handleAutoDropdownChange(select_obj);

        drop_down_holder_obj.show();
    },

    /**
     * Event method called when the drop down is changed
     */
    changeAutoDropdown: function(e)
    {
        Fotolia_AutoFormFields._handleAutoDropdownChange($(this));
    },

    /**
     * Handles the change for the auto drop down
     */
    _handleAutoDropdownChange: function(select_obj)
    {
        var current_value = select_obj.val();

        $('option', select_obj).each(function() {
            var option = $(this);
            var body_div = option.data('body_div');

            if (option.val() == current_value) {
                body_div.show();
            } else {
                body_div.hide();
            }
        });
    }
},
//Class Properties
{
});

$.Class.extend('Fotolia_CartSummary',
// Static properties
{
    elm_can_scroll: false,
    state: 'on_top', // available states : on_top, on_bottom, on_move
    scroll_element_id: 'cart_summary',
    scroll_container_id: 'cart_content',
    scroll_element: null,
    scroll_container: null,
    scroll_limits: [],
    bottom_pos: null,
    fixed_margin: 15,

    initialize: function ()
    {
        // get scroll element and referencial
        var scroll_element = $('#' + this.scroll_element_id)[0];
        var scroll_container = $('#' + this.scroll_container_id)[0];

        if (typeof scroll_element != 'undefined' && typeof scroll_container != 'undefined') {
            // set Fotolia_CartSummary variable
            Fotolia_CartSummary.scroll_element = scroll_element;
            Fotolia_CartSummary.scroll_container = scroll_container;

            // set scroll limits and prevent window resize
            Fotolia_CartSummary.updateScrollLimits();
            $(window).bind('resize', Fotolia_CartSummary.updateScrollLimits);

            // assign scroll function listener of scroll event
            $(window).bind('scroll', Fotolia_CartSummary.onScroll);
        }
    },

    /**
     * onScroll event action
     */
    onScroll: function (e)
    {
        if (Fotolia_CartSummary.elm_can_scroll) {
            // get window position
            var window_pos = $(window).scrollTop();

            if (window_pos < Fotolia_CartSummary.scroll_limits['top']) {
                // current position is smaller than top scroll limit
                Fotolia_CartSummary.stopScroll('top');

            } else if (window_pos > Fotolia_CartSummary.scroll_limits['bottom']) {
                // current position is greater than bottom scroll limit
                Fotolia_CartSummary.stopScroll('bottom');

            } else {
                // between limit, start scroll if needed
                Fotolia_CartSummary.startScroll();
            }

            e.stopPropagation();
            return false;
        }
    },

    /**
     * start cart scroll with smooth effect.
     * cart element move to fixed position relative to window's top or bottom
     */
    startScroll: function(limit_label)
    {
        if (Fotolia_CartSummary.state != 'on_move') {
            var element = Fotolia_CartSummary.scroll_element;

            // set animate params for top 'startScroll'
            var element_pos = 0;
            var anim_operator = '+=';

            if (Fotolia_CartSummary.state == 'on_bottom') {
                // set animate params for bottom 'startScroll'
                element_pos = Fotolia_CartSummary.fixed_margin * 2;
                anim_operator = '-=';
            }
            // initialize fixed position
            $(element).css({position: 'fixed', top: element_pos});

            // move to fixed position at window's top
            var top = anim_operator + Fotolia_CartSummary.fixed_margin;
            Fotolia_CartSummary.animateElement(top);

            // update Fotolia_CartSummary state
            Fotolia_CartSummary.state = 'on_move';
        }

        return false;
    },

    /**
     * stop cart scroll with smooth effect.
     * cart element move to static position at container top or bottom
     */
    stopScroll: function(limit_label)
    {
        if (Fotolia_CartSummary.state == 'on_move') {
            var element = Fotolia_CartSummary.scroll_element;

            if (limit_label == 'top') {

                // update Fotolia_CartSummary state
                Fotolia_CartSummary.state = 'on_top';

                // set initial position
                $(element).css({
                    top: Fotolia_CartSummary.fixed_margin,
                    position: 'relative'
                });

                // move to final postition
                var top = 0;
                Fotolia_CartSummary.animateElement(top);

                // reset pos as static
                $(element).css({position: null, top: null});

            } else if (limit_label == 'bottom') {

                // update Fotolia_CartSummary state
                Fotolia_CartSummary.state = 'on_bottom';

                // set initial position
                $(element).css({
                    top: Fotolia_CartSummary.bottom_pos,
                    position: 'relative'
                });

                // move to final postition
                var top = Fotolia_CartSummary.bottom_pos;
                Fotolia_CartSummary.animateElement(top);
            }
        }

        return false;
    },

    /**
     * Assign scroll limit and scroll element relative position when it stop as bottom
     * used on Fotolia_CartSummary initlialize and on window resize
     */
    updateScrollLimits: function()
    {
        // get stuff
        var container_offset = $(Fotolia_CartSummary.scroll_container).offset();
        var shopping_cart_item_margin = 10;
        var container_height = $(Fotolia_CartSummary.scroll_container).height() - shopping_cart_item_margin;
        var element_height = $(Fotolia_CartSummary.scroll_element).height();

        // set scroll limits trigger
        Fotolia_CartSummary.scroll_limits['top'] = container_offset.top;
        Fotolia_CartSummary.scroll_limits['bottom'] = container_offset.top + container_height - element_height - (2 * Fotolia_CartSummary.fixed_margin);

        Fotolia_CartSummary.elm_can_scroll = container_height > element_height;

        // set scroll_element relative position when it stop at bottom
        Fotolia_CartSummary.bottom_pos = container_height - element_height;

        if (!Fotolia_CartSummary.elm_can_scroll) {
            // reset css
            Fotolia_CartSummary.state = 'on_top';
            $(Fotolia_CartSummary.scroll_element).css({position: 'static', top: null});
        }

        return false;
    },

    /**
     * used on Fotolia_ShoppingCart, when removing cart items
     */
    onContainerChange: function()
    {
        Fotolia_CartSummary.updateScrollLimits();
        var element_height = $(Fotolia_CartSummary.scroll_element).height();

        var display_limit_bottom = Fotolia_CartSummary.scroll_limits['bottom'] + (2 * Fotolia_CartSummary.fixed_margin);
        var scroll_element_pos = $(Fotolia_CartSummary.scroll_element).position().top;

        if (display_limit_bottom < scroll_element_pos) {
            if (!Fotolia_CartSummary.elm_can_scroll) {
                // reset css
                Fotolia_CartSummary.state = 'on_top';
                $(Fotolia_CartSummary.scroll_element).css({position: 'static', top: null});
            } else if (Fotolia_CartSummary.state == 'on_move') {
                Fotolia_CartSummary.stopScroll('bottom');
            }
        }
    },

    /**
     * use jquery animate function
     */
    animateElement:function (top)
    {
        var element = Fotolia_CartSummary.scroll_element;

        $(element).animate({
            top: top
        }, {
            duration: 'slow',
            queue: false
        });
    }
},
//Class Properties
{
});

$.Class.extend('Fotolia_Content',
// Static properties
{
    original_height : null,
    highlighted_row_rel : null,

    initialize: function()
    {
        Fotolia_Content.keywords_search_submit = $('input#keywords_search_submit');
        Fotolia_Content.keywords_list = $.parseJSON($('#keywords_list').html());

        $('a#content_select_pixels').click(Fotolia_Content.clickShowPixels);
        $('a#content_select_local').click(Fotolia_Content.clickShowLocal);
        $('span#content_show_keywords').click(Fotolia_Content.clickShowKeywords);

        $('tr.detail-grid-license-choice').click(Fotolia_Content.clickLicenseRow);

        if (Fotolia_Content.keywords_search_submit.length && Fotolia_Content.keywords_list.length) {
            $('.detail-grid-keywords a').click(Fotolia_Content.clickSelectKeyword);
            Fotolia_Content.keywords_search_submit.click(Fotolia_Content.clickKeywordsSearchSubmit);
        }

        $('#content_details_add_to_cart').click(function() {
            // keep track of the row's rel, since the link's href changes later
            Fotolia_Content.highlighted_row_rel = $(this).attr('href');
        });
    },

    clickShowLocal: function(e)
    {
        $('a#content_select_pixels').removeClass('on');
        $('a#content_select_local').addClass('on');

        $('[id^="content_size:pixels:"]').hide();
        $('[id^="content_size:local:"]').show();
    },

    clickShowPixels: function(e)
    {
        $('a#content_select_local').removeClass('on');
        $('a#content_select_pixels').addClass('on');

        $('[id^="content_size:local:"]').hide();
        $('[id^="content_size:pixels:"]').show();
    },

    clickShowKeywords: function(e)
    {
        $('td.detail-grid-keywords').removeClass('with_hidden_keywords');
        $('span#content_show_keywords').remove();
    },

    clickSelectKeyword: function(e)
    {
        var link_selected = $(this);
        var nb_keywords_selected = $('.detail-grid-keywords a.selected').length;
        if (nb_keywords_selected < 10 && !link_selected.hasClass('selected')) {
            link_selected.addClass('selected');
            nb_keywords_selected++;
        } else {
            link_selected.removeClass('selected');
            nb_keywords_selected--;
        }

        if (Fotolia_Content.keywords_search_submit.hasClass('display_none')) {
            Fotolia_Content.keywords_search_submit.removeClass('display_none');
        } else if (nb_keywords_selected == 0) {
            Fotolia_Content.keywords_search_submit.addClass('display_none');
        }

        return false;
    },

    clickKeywordsSearchSubmit: function(e)
    {
        var keywords_list = new Array();

        $('.detail-grid-keywords a').each(function(key, value) {
            if($(this).hasClass('selected')) {
                keyword = Fotolia_Content.keywords_list[key];
                if (keyword.indexOf(' ') > 0) {
                    keyword = '"' + keyword + '"';
                }
                keywords_list.push(keyword);
            }
        });
        $('#keywords_search_input').val(keywords_list.join(' '));
    },

    clickLicenseRow: function(e)
    {
        var chosen_license_row = $(this);

        if ($('.content-in-cart').size() == 0) {
            Fotolia_Content._highlightRow(chosen_license_row, false);

            // update add to cart link href
            $('#content_details_add_to_cart').attr('href', chosen_license_row.attr('rel'));
        } else {
            // update license in cart
            var data = [];
            data.push({name: 'update_in_cart', value: true});

            Fotolia_AjaxActions.ajaxPostCall(chosen_license_row.attr('rel'), $(this), data);
        }
    },

    clickLicenseRowCallBack: function(chosen_license_row)
    {
        Fotolia_Content._highlightRow(chosen_license_row, true);
    },

    addToCartCallback: function()
    {
        Fotolia_Content._highlightRow($('.detail-grid tr[rel="' + Fotolia_Content.highlighted_row_rel + '"]'), true);
    },

    _highlightRow: function(chosen_license_row, content_in_cart)
    {
        if (content_in_cart === undefined) {
            content_in_cart = false;
        }

        $('.detail-grid tr.detail-grid-license-choice').removeClass('on');
        chosen_license_row.addClass('on');

        if (content_in_cart) {
            $('.detail-grid tr.detail-grid-license-choice .detail-grid-download img').removeClass('img-ok').addClass('img-download on');

            $('.detail-grid-download img', chosen_license_row).removeClass('img-download').addClass('img-ok');
        }
    }
},
//Class Properties
{
});

$.Class.extend('Fotolia_Design',
// Static properties
{
    initialize: function()
    {
        // equalize column height
        $(".category-content").equalHeights();
    }
},
//Class Properties
{
});

$.Class.extend('Fotolia_Div_Select',
// Static properties
{
    div_selects: new Array(),

    initialize: function()
    {
        $('div[id^="div_select:"]').each(function() {
            Fotolia_Div_Select.div_selects.push(new Fotolia_Div_Select($(this)));
        });
    }
},
//Class Properties
{
    main_obj: null,
    current_obj: null,
    options: null,

    init: function(obj)
    {
        this.main_obj = obj;
        this.current_obj = $('a.div_select_current', this.main_obj);
        this.options = $('div.div_select_options a', this.main_obj);
        this.options.bind('click', {obj: this, method: 'clickOption'}, Fotolia.eventHandler);

        var parts = this.main_obj.attr('id').split(':');

        this.input_obj = $('input[id="' + parts[1] + '"]');
    },

    clickOption: function(e, target)
    {
        this.current_obj.html(target.html());

        this.input_obj.val(target.attr('rel'));
    }
});

$.Class.extend('Fotolia_Flash',
// Static properties
{
    initialize: function()
    {
        $('[id^="embed_flash:"]').each(Fotolia_Flash.embedFlash);
    },

    embedFlash: function()
    {
        var embed_obj = $(this);

        var json_data = $.parseJSON($('#[id="data:' + embed_obj.attr('id') + '"]').html());

        if (json_data) {
            embed_obj.flashembed(json_data.embed_vars, json_data.flash_vars);
        }
    }
},
//Class Properties
{
});

$.Class.extend('Fotolia_Form',
// Static properties
{
    initialize: function()
    {
        Fotolia_Form.initSelectCheckboxesLinks();

        $('form[id^="single_submit_form:"]').bind('submit', Fotolia_Form.submitSingleSubmitForm);

        $('a[id^="submit_form:"]').click(Fotolia_Form.clickSubmitForm);
        $('a[id^="submit_form_confirm_delete:"]').click(Fotolia_Form.clickSubmitFormConfirmDelete);

        $('a[id^="show_hidden_form:"]').each(Fotolia_Form.initializeShowHiddenForm);

        $('select[id^="submit_form_select:"]').change(Fotolia_Form.changeDropDownSubmit);

        $('input[type="radio"][id^="submit_form_radio:"]').change(Fotolia_Form.changeDropDownSubmit);
    },

    /**
     * Initialize checkbox links
     */
    initSelectCheckboxesLinks: function()
    {
        $('a[id^="select_all_checkboxes"]').bind('click', Fotolia_Form.clickSelectAllCheckboxes);
        $('a[id^="unselect_all_checkboxes"]').bind('click', Fotolia_Form.clickUnselectAllCheckboxes);
        $('a[id^="toggle_all_checkboxes"]').bind('click', Fotolia_Form.clickToggleAllCheckboxes);

        $('input[id^="select_all_checkboxes"]').bind('change', Fotolia_Form.changeSelectAllCheckboxes);

        $('select[id^="ajax_select_post"]').bind('change', Fotolia_Form.changeAjaxSelectPost)
    },

    /**
     * Disable form submit after the first one
     */
    submitSingleSubmitForm: function(e)
    {
        // form is already submited
        if (typeof(this.has_been_submitted) == 'undefined' || !this.has_been_submitted) {

            // set as submited form
            this.has_been_submitted = true;

            // send form
            this.submit();

            // disabled submit buttons
            var submit_buttons = $(this).find(':input[type="submit"]');
            if (submit_buttons) {
                $(submit_buttons).prop('disabled', true);
            }
        }

        e.stopPropagation();
        return false;
    },

    /**
     * Select all checkboxes click event
     */
    clickSelectAllCheckboxes: function(e)
    {
        var id_parts = $(this).attr('id').split(':');
        var form_id = id_parts[1];

        $('form#' + id_parts[1] + ' :checkbox').prop('checked', true);

        e.stopPropagation();
        return false;
    },

    /**
     * Select all checkboxes click event
     */
    clickUnselectAllCheckboxes: function(e)
    {
        var id_parts = $(this).attr('id').split(':');
        var form_id = id_parts[1];

        $('form#' + id_parts[1] + ' :checkbox').prop('checked', false);

        e.stopPropagation();
        return false;
    },

    /**
     * Select / Unselect all checkboxes check event (with input checkbox)
     */
    changeSelectAllCheckboxes: function(e)
    {
        var id_parts = $(this).attr('id').split(':');
        var form_id = id_parts[1];
        var to_check = $(this).prop('checked');
        $('form#' + id_parts[1] + ' tbody :checkbox').prop('checked', to_check);

        e.stopPropagation();
    },
    /**
     * Toggle all checkboxes click event
     */
    clickToggleAllCheckboxes: function(e)
    {
        var id_parts = $(this).attr('id').split(':');
        var form_id = id_parts[1];

        var checkboxes = $('form#' + id_parts[1] + ' :checkbox');

        for (var i = 0; i < checkboxes.length; i++) {
            checkboxes[i].attr('checked', !checkboxes[i].prop('checked'));
        }

        e.stopPropagation();
        return false;
    },

    /**
     * Called when select boxes are changed
     */
    changeAjaxSelectPost: function(e)
    {
        var id_parts = $(this).attr('id').split(':');
        var url = $('[id="' + id_parts[1] + '"]').val();

        Fotolia_AjaxActions.ajaxPostCall(url, $(this), {value: $(this).val()});
    },

    /**
     * Called when submit form link is clicked
     */
    clickSubmitForm: function(e)
    {
        var id_parts = $(this).attr('id').split(':');

        $('form[id="' + id_parts[1] + '"]').submit();

        e.stopPropagation();
        return false;
    },

    /**
     * Called when submit form confirm delete link is clicked
     */
    clickSubmitFormConfirmDelete: function(e)
    {
        if (confirm(_('Are you sure you want to delete these?'))) {
            var id_parts = $(this).attr('id').split(':');

            $('form[id="' + id_parts[1] + '"]').submit();
        }

        e.stopPropagation();
        return false;
    },

    initializeShowHiddenForm: function(index)
    {
        var id_parts = $(this).attr('id').split(':');

        $(this).click(Fotolia_Form.clickShowHiddenForm);

        $('[id="' + id_parts[1] + ':cancel"]').click(Fotolia_Form.clickHideHiddenForm);
    },

    /**
     * Action to show hidden forms
     */
    clickShowHiddenForm: function(e)
    {
        var link = $(this);
        var id_parts = link.attr('id').split(':');

        $('[id="' + id_parts[1] + '"]').show();
        link.hide();

        e.stopPropagation();
        return false;
    },

    /**
     * Action to hide hidden forms
     */
    clickHideHiddenForm: function(e)
    {
        var id_parts = $(this).attr('id').split(':');

        $('[id="' + id_parts[0] + '"]').hide();
        $('a[id="show_hidden_form:' + id_parts[0] + '"]').show();

        e.stopPropagation();
        return false;
    },

    /**
     * Action for when a drop down submit is changed
     */
    changeDropDownSubmit: function(e)
    {
        var id_parts = $(this).attr('id').split(':');

        $('form[id="' + id_parts[1] + '"]').submit();
    }
},
//Class Properties
{
});

$.Class.extend('Fotolia_Lightbox',
// Static properties
{
    lightbox_form_id: 'lightbox_form',
    lightbox_move_url_id: 'lightbox_move_url',

    initialize: function()
    {
        $('a[id="lightbox:remove_selected_from_cart"]').click(Fotolia_Lightbox.clickRemoveSelected);
        $('a[id="lightbox:remove_selected_from_lightbox"]').click(Fotolia_Lightbox.clickRemoveSelected);
        $('select[id="lightbox:move_content"]').change(Fotolia_Lightbox.changeMoveContent);

        // add remove gallery with live, galleries list box can be update with ajax request
        $('a[id^="lightbox:remove_gallery"]').live('click', Fotolia_AjaxActions.confirmAjaxCall);

        $('[id="show_hidden_form:edit_gallery_form"]').click(Fotolia_Lightbox.clickShowEditForm);
        $('[id="edit_gallery_form:cancel"]').click(Fotolia_Lightbox.clickHideEditForm);
    },

    /**
     *
     */
    clickShowEditForm: function()
    {
        $('#lightbox_form div.option a').parent(0).hide();
    },

    /**
     *
     */
    clickHideEditForm: function()
    {
        $('#lightbox_form div.option a').parent(0).show();
    },

    /**
     * Action to remove selected items from the lightbox
     */
    clickRemoveSelected: function(e)
    {
        var selected_ids = [];
        $('form#' + Fotolia_Lightbox.lightbox_form_id + ' :checkbox:checked').each(function() {
            selected_ids.push($(this).val());
        });

        if (selected_ids.length > 0) {
            Fotolia_AjaxActions.ajaxPostCall($(this).attr('href'), $(this), {content_ids: selected_ids.join(',')});
        }

        e.stopImmediatePropagation();
        return false;
    },

    /**
     * Called when select boxes are changed
     */
    changeMoveContent: function(e)
    {
        if ($(this).val() !== 'none') {
            var selected_ids = [];
            $('form#' + Fotolia_Lightbox.lightbox_form_id + ' :checkbox:checked').each(function() {
                selected_ids.push($(this).val());
            });

            if (selected_ids.length > 0) {
                var url = $('a[id="' + Fotolia_Lightbox.lightbox_move_url_id + '"]').attr('href');

                var data = {
                    new_lightbox_id32: $(this).val(),
                    content_ids: selected_ids.join(',')
                }

                Fotolia_AjaxActions.ajaxPostCall(url, $(this), data);
            } else {
                Fotolia_Lightbox.resetMoveSelect();
            }
        }
    },

    /**
     * Updates the lightbox counts
     *
     * @param string nb_contents The number of contents to set to
     */
    updateLightboxNbContents: function(nb_contents)
    {
        $('[id="global_lightbox:nbcontents"]').html(nb_contents);
        $('[id="lightbox:nbcontents"]').html(nb_contents);
    },

    /**
     * Updates the count for the gallery
     *
     * @param string gallery_id32 The id32 of the gallery to update
     * @param string nb_contents The number of contents to set to
     */
    updateGalleryNbContents: function(gallery_id32, nb_contents)
    {
        $('[id="lightbox:gallery_count:' + gallery_id32 + '"]').html(nb_contents);
    },

    /**
     * Removes a content from the lightbox
     *
     * @param string content_id The content id to remove
     */
    removeContentFromLightbox: function(content_id, callback)
    {
        var i = 0;
        var nb_content_ids;

        if ((typeof content_id).toLowerCase() == 'number') {
            nb_content_ids = 1;
        } else {
            nb_content_ids = content_id.length;
        }

        $(content_id).each(function(k, elm) {
            $('div[id="lightbox_item:' + elm + '"]').fadeOut('slow', function() {

                if (typeof callback != 'undefined') {
                    // remove all elements before executing callback
                    if (++i == nb_content_ids) {
                        eval(callback);
                    }

                } else {
                    $(this).remove();
                }
            });
        });
    },

    /**
     * Removes a gallery
     *
     * @param string content_id The content id to remove
     */
    removeGallery: function(gallery_id, callback)
    {
        $('div[id="lightbox:gallery:' + gallery_id + '"]').fadeOut('slow', function() {
            $(this).remove();

            if (typeof callback != 'undefined') {
                eval(callback);
            }
        });
    },

    /**
     * Resets the move to lightbox box
     */
    resetMoveSelect: function()
    {
        $('select[id="lightbox:move_content"]').val('none');
    }
},
//Class Properties
{

});

$.Class.extend('Fotolia_Pagination',
// Static properties
{
    initialize: function()
    {
        $('input[id^="pagination:gotopage"]').keydown(Fotolia_Pagination.changePaginationPage);
    },

    changePaginationPage: function(e)
    {
        if (e.keyCode == 13) {

            // do not submit form
            e.preventDefault();

            var text_box = $(this);
            var url_vars = Fotolia.getURLVars();
            var value = text_box.val();
            var name_parts = text_box.attr('name').split(':');

            if (name_parts.length > 3 && value > 0) {
                if (name_parts[3] != '') {
                    var param_prefix = name_parts[3] + '_';
                } else {
                    var param_prefix = '';
                }

                if (name_parts[1] == 'custom') {
                    var offset_param_name = name_parts[4];
                    var limit_param_name = name_parts[5];
                    var limit = name_parts[6];

                    var limit_value = url_vars[limit_param_name] ? url_vars[limit_param_name] : false;

                    // calculate offset
                    var per_page = limit_value ? limit_value : limit;
                    value = (value - 1) * per_page;

                    url_vars[offset_param_name] = value;

                } else {
                    // get some params from URL
                    var per_page_value = url_vars[param_prefix + 'per_page'] ? url_vars[param_prefix + 'per_page'] : false;
                    var order_by_value = url_vars[param_prefix + 'order_by'] ? url_vars[param_prefix + 'order_by'] : false;

                    url_vars[param_prefix + 'page'] = value;

                    if (per_page_value) {
                        url_vars[param_prefix + 'per_page'] = per_page_value;
                    }

                    if (order_by_value) {
                        url_vars[param_prefix + 'order_by'] = order_by_value;
                    }
                }
            }
            Fotolia.go(Fotolia.buildURL(null, url_vars));
        }
    }
},
//Class Properties
{
});

$.Class.extend('Fotolia_Popup',
// Static properties
{
    initialize: function()
    {
        $('a[id^="display_popup:"]').click(Fotolia_Popup.divOpen);

        $('a.popin-close, #fade').live('click', function() {
            $('#fade , .popin-block').fadeOut(function() {
                $('#fade').remove();
            });
            return false;
        });
    },

    open: function(url, title, width, height, options)
    {

        if (typeof(options) == 'undefined') {
            options = '';
        }

        if (typeof(width) == 'undefined') {
            width = window.outerWidth / 2;
        }

        if (typeof(height) == 'undefined') {
            height = window.outerHeight / 2;
        }

        popup = window.open(url, 'PopUp',
            ', scrollbars=yes ' +
            ', width=' + width + ' ' +
            ', height=' + height + ' ' +
            ', top=' + Math.round((window.outerHeight / 2) - (height / 2)) + ' ' +
            ', left=' + Math.round((window.outerWidth / 2) - (width / 2))
        );
    },

    divOpen: function()
    {
        Fotolia_Popup.pop_id = $(this).attr('id').split(':')[1];

         if (!$('#' + Fotolia_Popup.pop_id ).length) {
            var post_url = (("https:" == document.location.protocol) ? "/Ajax/Secure/RetrieveInfos" : "/Ajax/RetrieveInfos");
            var content = $.ajax({
                url: post_url,
                type: 'POST',
                complete: Fotolia_Popup.computeSize,
                dataType: 'text',
                data: {pop_id: Fotolia_Popup.pop_id}
            });
        } else {
            $('#' + Fotolia_Popup.pop_id).fadeIn();
        }

        // Fade in Background
        $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
        $('#fade').css({'filter':'alpha(opacity=70)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies

        return false;
    },

    computeSize: function(response)
    {
        $('body').append('<div id="' + Fotolia_Popup.pop_id + '" class="popin-block">' + response.responseText + '</div>');
        // Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
        var popWidth = '700';
        // Fade in the Popup and add close button
        $('#' + Fotolia_Popup.pop_id).fadeIn().css({'width': Number(popWidth)}).prepend('<a href="#" class="popin-close"></a>');

        var popMargTop = ($('#' + Fotolia_Popup.pop_id).height() + 80) / 2;
        var popMargLeft = ($('#' + Fotolia_Popup.pop_id).width() + 80) / 2;

        // Apply Margin to Popup
        $('#' + Fotolia_Popup.pop_id).css({'margin-top' : -popMargTop,'margin-left' : -popMargLeft});

    }

},
//Class Properties
{
});

$.Class.extend('Fotolia_ColorConvertor',
// Static properties
{
},
//Class Properties
{
    init: function ()
    {
    },

    /**
     * convert Hexadecimal color to Rgb color
     * function from http://www.eyecon.ro/colorpicker/#about
     */
    hexToRgb: function (hex)
    {
        var hex = parseInt((($.inArray('#', hex) > -1) ? hex.substring(1) : hex), 16);
        return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
    },

    /**
     * convert hexadecimal color to Hsl color
     */
    hexToHsl: function (hex)
    {
        return this.rgbToHsl(this.hexToRgb(hex));
    },

    /**
     * convert Rgb color to Hsl color
     * function found on http://www.easyrgb.com/index.php?X=MATH
     */
    rgbToHsl: function (rgb)
    {
        var hsl = {h: 0, s: 0, l: 0};
        var rgb = {
            r: rgb.r / 255,
            g: rgb.g / 255,
            b: rgb.b / 255
        };

        var min = Math.min(rgb.r, rgb.g, rgb.b);
        var max = Math.max(rgb.r, rgb.g, rgb.b);
        var delta = max - min;

        // lightness
        hsl.l = (max + min) / 2;

        if (delta == 0) {
            hsl.h = hsl.s = 0;
        } else {

            // saturation
            if (hsl.l < 50) {
                hsl.s = delta / (max + min);
            } else {
                hsl.s = delta / (2 - max - min);
            }

            // hue
            delta_r = (((max - rgb.r) / 6) + (delta / 2)) / delta;
            delta_g = (((max - rgb.g) / 6) + (delta / 2)) / delta;
            delta_b= (((max - rgb.b) / 6) + (delta / 2)) / delta;

            if (rgb.r == max) {
                hsl.h = delta_b - delta_g;
            } else if (rgb.g == max) {
                hsl.h = (1/3) + delta_r - delta_b;
            } else if (rgb.b == max) {
                hsl.h = (2/3) + delta_g - delta_r;
            }

            if (hsl.h < 0) {
                hsl.h += 1;
            }

            if (hsl.h > 1) {
               hsl.h -= 1;
            }
        }

        rgb = {
            r: rgb.r * 255,
            g: rgb.g * 255,
            b: rgb.b * 255
        }

        hsl.h = parseInt(360 * hsl.h, 10);
        hsl.s = parseInt(100 * hsl.s, 10);
        hsl.l = parseInt(100 * hsl.l, 10);

        return hsl;
    },

    /**
     * convert Hsl color to Rgb color
     * function found on http://www.easyrgb.com/index.php?X=MATH
     */
    hslToRgb: function (hsl)
    {
        var h = hsl.h / 360;
        var s = hsl.s / 100;
        var l = hsl.l / 100;

        var rgb = {r:0, g:0, b:0};
        if (s == 0) {
            rgb = {
                r: l * 255,
                g: l * 255,
                b: l * 255
            }
        } else {

            var value_1, value_2;

            if (l < 0.5) {
                value_2 = l * (1 + s);
            } else {
                value_2 = (l + s) - (s * l);
            }

            value_1 = 2 * l - value_2;

            rgb = {
                r: 255 * this.hueToRgb( value_1, value_2, h + (1/3)),
                g: 255 * this.hueToRgb( value_1, value_2, h),
                b: 255 * this.hueToRgb( value_1, value_2, h - (1/3))
            };
        }

        rgb = {
            r: parseInt(rgb.r, 10),
            g: parseInt(rgb.g, 10),
            b: parseInt(rgb.b, 10)
        }

        return rgb;
    },

    /**
     * Used by Fotolia_ColorConvertor.hslToRgb
     * return red, green or blue value
     */
    hueToRgb: function (value_1, value_2, hue)
    {
        if (hue < 0) {
            hue += 1;
        }
        if (hue > 1) {
            hue -= 1;
        }

        if ((6 * hue) < 1) {
            return (value_1 + (value_2 - value_1) * 6 * hue);
        }
        if ((2 * hue) < 1) {
            return value_2;
        }
        if ((3 * hue) < 2) {
            return (value_1 + (value_2 - value_1) * ((2/3) - hue) * 6);
        }

        return value_1;
    },

    /**
     * Convert Rgb color to Hexadecimal color
     * function from http://www.eyecon.ro/colorpicker/#about
     */
    rgbToHex: function (rgb)
    {
        var hex = [
            rgb.r.toString(16),
            rgb.g.toString(16),
            rgb.b.toString(16)
        ];
        $.each(hex, function (nr, val) {
            if (val.length == 1) {
                hex[nr] = '0' + val;
            }
        });

        return hex.join('');
    },

    /**
     * Convert Hsl color to Hexadecimal color
     */
    hslToHex: function (hsl)
    {
        return this.rgbToHex(this.hslToRgb(hsl));
    }

});

$.Class.extend('Fotolia_SearchColorPicker',
// Static properties
{
    hue_class: 'colorpicker_hue',
    hex_class: 'colorpicker_hex',
    lightness_class: 'colorpicker_lightness',
    new_color_class: 'colorpicker_new_color',
    submit_class: 'colorpicker_submit',
    colors_class: 'colorpicker_colors',

    /**
     * Found search-colorpicker element and instanciate Fotolia_SearchColorPicker
     */
    initialize: function()
    {
        var search_colorpicker = $('#search-colorpicker');
        if ($(search_colorpicker).length > 0) {
            // javascript enabled, so we display colorpicker form block
            $(search_colorpicker).parents('div.advancedsearch-form-block').removeClass('display_none');

            var colorpicker = new Fotolia_SearchColorPicker(search_colorpicker);
        }
    }
},
//Class Properties
{
    colors: new Array,
    convertor: null,
    hex: '1C851B',
    hsl: {h:0, s:80, l:100},
    ui_hue: null,
    ui_lightness: null,
    ui_hex: null,
    ui_new_color: null,
    ui_offset: null,
    current_target_class: null,
    default_saturation: 80,

    /**
     * Get all dom elements needed and set events
     */
    init: function(target)
    {
        var colorpicker = target;

        this.search_params = $.parseJSON(colorpicker.children(':first-child').children(':first-child').html());
        this.convertor = new Fotolia_ColorConvertor();

        // initialize color change on user interface hexa
        this.current_target_class = Fotolia_SearchColorPicker.hex_class;

        // get dom elements
        this.ui_hue = colorpicker.find('div.' + Fotolia_SearchColorPicker.hue_class + ' div');
        this.ui_lightness = colorpicker.find('div.' + Fotolia_SearchColorPicker.lightness_class + ' div');
        this.ui_hex = colorpicker.find('div.' + Fotolia_SearchColorPicker.hex_class + ' input')[0];
        this.ui_new_color = colorpicker.find('div.' + Fotolia_SearchColorPicker.new_color_class);
        this.ui_offset = colorpicker.find('div.' + Fotolia_SearchColorPicker.lightness_class).offset().left;
        this.ui_colors = target.find('input.' + Fotolia_SearchColorPicker.colors_class);
        this.ui_submit_link = colorpicker.find('div.' + Fotolia_SearchColorPicker.submit_class + ' a');

        // set colors
        var choosed_colors = this.ui_colors.val();

        if (choosed_colors.length > 0) {
            this.colors = choosed_colors.split(',');

            // set current color to last color choosed
            this.hex = this.colors.slice().pop();
        }

        this.ui_hue.bind('mousedown', {obj: this, method: 'onMouseDownSlider'}, Fotolia.eventHandler)
        this.ui_lightness.bind('mousedown', {obj: this, method: 'onMouseDownSlider'}, Fotolia.eventHandler)
        this.ui_hue.parent(0)
            .bind('mousedown', {obj: this, method: 'onMouseDownSlider'}, Fotolia.eventHandler)
            .bind('click', {obj: this, method: 'onClickSlider'}, Fotolia.eventHandler);
        this.ui_lightness.parent(0)
            .bind('mousedown', {obj: this, method: 'onMouseDownSlider'}, Fotolia.eventHandler)
            .bind('click', {obj: this, method: 'onClickSlider'}, Fotolia.eventHandler);

        $(this.ui_hex).bind('keyup', {obj: this, method: 'onkeyUpHex'}, Fotolia.eventHandler);

        $(this.ui_new_color).parent(0).bind('click', {obj: this, method: 'onNewColorClick'}, Fotolia.eventHandler);
        $(this.ui_submit_link).bind('click', {obj: this, method: 'onNewColorClick'}, Fotolia.eventHandler);

        this.hsl = this.convertor.hexToHsl(this.hex);

        this.setHsl();
        this.setHex();
    },

    /**
     * Set form hidden field with all color
     */
    setHiddenFormField: function()
    {
        this.ui_colors.val(this.colors.join(','));
    },

    /**
     * Use change value on parameter to update this.hsl, this.hex
     * use Fotolia_ColorConvertor
     * update ui_hex and ui_sliders
     */
    changeColor: function(value)
    {
        if (this.current_target_class != null) {
            var hsl, hex;

            switch (this.current_target_class) {
                case Fotolia_SearchColorPicker.lightness_class:
                    this.hsl = value;
                    this.hex = this.convertor.hslToHex(this.hsl);
                    break;
                case Fotolia_SearchColorPicker.hue_class:
                    this.hsl = {h:value, s:this.default_saturation, l:this.hsl.l};
                    this.hex = this.convertor.hslToHex(this.hsl);
                    break;
                case Fotolia_SearchColorPicker.hex_class:
                    this.hex = value;
                    this.hsl = this.convertor.hexToHsl(this.hex);
                    break;
                default:
                    return false;
            }

            this.setHsl();

            if (this.current_target_class != Fotolia_SearchColorPicker.hex_class) {
                this.setHex();
            }
        }
    },

    /**
     * Set ui_hex value with current hex value
     */
    setHex: function()
    {
        $(this.ui_hex).attr('value', this.hex.toUpperCase());
    },

    /**
     * Set sliders positions with current hsl value
     */
    setHsl: function()
    {
        this.ui_hue.css('left', this.getHueSlideValue(this.hsl.h));
        this.ui_lightness.css('left', this.getLightnessSlideValue(this.hsl.l));
        this.ui_new_color.css('backgroundColor', '#' + this.hex);

        if (this.current_target_class != Fotolia_SearchColorPicker.lightness_class) {
            $(this.ui_lightness.parents()[0]).css('backgroundColor', '#' + this.convertor.hslToHex({h:this.hsl.h, s:this.default_saturation, l:60}));
        }
    },

    /**
     * Use event position data and current slider to calculate hue or lightness value
     */
    getColorValueFromEvent: function(event)
    {
        var color_value;

        if (this.current_target_class == Fotolia_SearchColorPicker.lightness_class) {
            color_value = {
                h: this.hsl.h,
                s: this.default_saturation,
                l: parseInt(100*(Math.max(0,Math.min(181, (event.pageX - this.ui_offset))))/181, 10)
            };
        } else {
            color_value = parseInt(360*(Math.max(0,Math.min(181,(event.pageX - this.ui_offset))))/181, 10);
        }

        return color_value;
    },

    /**
     * Convert lightness slider position to lightness value
     */
    getLightnessSlideValue: function (value)
    {
        return display_value = parseInt(181 * value/100, 10);
    },

    /**
     * Convert hue slider position to hue value
     */
    getHueSlideValue: function (value)
    {
        return display_value = parseInt(181 * value/360, 10);
    },

    addColor: function()
    {
        var color_added = false;
        if (this.colors.length < 5 && $.inArray(this.hex, this.colors) == -1) {

            this.colors.push(this.hex);
            this.setHiddenFormField();
            color_added = true;
        }

        return color_added;
    },

    //
    // Events
    //

    /**
     * Event: add new color to color'sd list
     */
    onNewColorClick: function(e)
    {
        if (this.addColor()) {

            var base_url = window.location.origin;
            if (typeof base_url == 'undefined') {
                var origin_pattern = /(http|https):\/\/[^(\/)]*/g;
                base_url = window.location.href.match(origin_pattern);
            }

            var link = base_url + '/search';
            this.search_params['colors'] = this.ui_colors.val();

            var query = '';
            for(var key in this.search_params) {
                var value = this.search_params[key];

                if (value.length > 0) {
                    if (typeof value == 'object') {
                        tmp = '';
                        for (var tmp_key in value) {
                            tmp_value = value[tmp_key];
                            tmp_key = key + '[' + tmp_key + ']';
                            tmp += encodeURIComponent(tmp_key) + "=" + encodeURIComponent(tmp_value) + "&";
                        }

                        query += tmp.substring(0, (tmp.length -1));
                    } else {
                        query += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&";
                    }
                }
            }
            query = query.substring(0, (query.length -1));

            if (query.length > 0) {
                link += '?' + query;
            }

            $(this.ui_new_color).parent(0).attr('href', link);
            $(this.ui_submit_link).attr('href', link);
        }

        return false;
    },

    /**
     * Event: Update color from slider
     */
    onMouseMoveSlider: function(e)
    {
        this.changeColor(this.getColorValueFromEvent(e), $(e.target).attr('class'));
        e.stopPropagation();
        return false;
    },

    /**
     * Event: Update color from slider
     */
    onClickSlider: function(e)
    {
        this.current_target_class = $(e.target).attr('class');
        this.changeColor(this.getColorValueFromEvent(e));

        e.stopPropagation();
        return false;
    },

    /**
     * Event: Update colors Fotolia_SearchColorPicker from hexadecimal field
     */
    onkeyUpHex: function (e)
    {
        var hex = $(this.ui_hex).val();
        if ($.inArray('#', hex) == 0) {
            hex = hex.substring(1, 7);
        }

        if (hex.length == 3) {

            var tmp = hex.substring(0, 1) + hex.substring(0, 1);
            tmp += hex.substring(1, 2) + hex.substring(1, 2);
            tmp += hex.substring(2, 3) + hex.substring(2, 3);
            hex = tmp;
        }

        var is_hex_pattern = /[0-9a-fA-F]/g;
        if (
            hex != this.hex &&
            hex.length == 6 &&
            hex.match(is_hex_pattern).length == 6
        ) {
            this.current_target_class = $(this.ui_hex).parent().attr('class');
            this.changeColor(hex);
        }

        e.stopPropagation();
        return false;
    },

    /**
     * Event: Add new events onMouseUpSlider and onMouseMoveSlider to document
     */
    onMouseDownSlider: function (e)
    {
        this.current_target_class = $(e.target).attr('class');
        if (this.current_target_class.length == 0) {
            this.current_target_class = $(e.target).parents('div', 0).attr('class');
        }

        $(document).bind('mouseup', {obj: this, method: 'onMouseUpSlider'}, Fotolia.eventHandler);
        $(document).bind('mousemove', {obj: this, method: 'onMouseMoveSlider'}, Fotolia.eventHandler);

        e.stopPropagation();
        return false;
    },

    /**
     * Event: Remove onMouseUpSlider and onMouseMoveSlider to document
     */
    onMouseUpSlider: function (e)
    {
        $(document).unbind('mouseup');
        $(document).unbind('mousemove');

        e.stopPropagation();
        return false;
    }

});

$.Class.extend('Fotolia_Search',
// Static properties
{
    search_input: null,
    search_filter: null,
    search_bar_width: null,

    initialize: function()
    {
        Fotolia_Search.checkbox_types = $('input[name!="filters[content_type:all]"][name^="filters[content_type:"]');
        Fotolia_Search.checkbox_all = $('input[name^="filters[content_type:all]"]');

        $('.auto-check-files-types input[name^="filters[content_type:"]').change(Fotolia_Search.changeSearchDropDown);

        $('input[id^="filters[price_"]').click(Fotolia_Search.clickPrice);

        // set right margin
        Fotolia_Search.search_input = $('#global_search_form input.search-input');
        Fotolia_Search.search_filter = $('#global_search_form div.search-filter');

        if (this.search_filter.offset() != null) {
            Fotolia_Search.search_bar_width = this.search_filter.offset().left - this.search_input.offset().left + this.search_filter.outerWidth();

            Fotolia_Search.applySearchBarFix();
        }
    },

    changeSearchDropDown: function(e)
    {
        var current_checkbox = $(this);

        var current_container = $(current_checkbox).parents('.auto-check-files-types')[0];
        var checkbox_types = Fotolia_Search.checkbox_types;
        var checkbox_all = Fotolia_Search.checkbox_all;

        if (current_checkbox.attr('name') == 'filters[content_type:all]') {

            // All is selcted
            if (current_checkbox.prop('checked')) {
                $(checkbox_types).prop('checked', false);
                $(checkbox_all).prop('checked', true);

            } else {
                if (!$(current_container).find('input[name!="filters[content_type:all]"][name^="filters[content_type:"]:checked').length) {
                    // No others, select all
                    $(checkbox_all).prop('checked', true);
                }
            }
        } else {

            if ($(current_container).find('input[name!="filters[content_type:all]"][name^="filters[content_type:"]:checked').length == $(current_container).find('input[name!="filters[content_type:all]"][name^="filters[content_type:"]').length) {
                // We have all, we must select all
                $(checkbox_types).prop('checked', false);
                $(checkbox_all).prop('checked', true);

            } else if ($(current_container).find('input[name!="filters[content_type:all]"][name^="filters[content_type:"]:checked').length == 0) {
                // We have nothing, we must select all
                $(checkbox_all).prop('checked', true);
            } else {
                // This is not all, we must deselect all
                $(checkbox_all).prop('checked', false);
                $('input[name="' + current_checkbox.attr('name') + '"]').prop('checked', current_checkbox.prop('checked'));
            }
        }

        var labels = new Array();

        $('p.search-filter-list input[name^="filters[content_type:"]:checked').each(function () {
            labels.push($.trim($(this).parent().text()));
        });

        $('#global_search_filter_choice').html(labels.join(', '));

        // set right margin
        Fotolia_Search.applySearchBarFix();
    },

    clickAdvancedSearch: function(e)
    {
        this.parents('form').submit();

        e.stopPropagation();
        return false;
    },

    clickPrice: function(e)
    {
        var current_input = $(this);
        if (current_input.attr('type') == 'text') {
            // Reset the radio
            $('input[id="filters[price_xs]"]').val(['all']);

        } else {
            // Reset input text
            $('input[id="filters[price_x]"]').val('');
        }

        e.stopPropagation();

    },

    applySearchBarFix: function()
    {
        var search_filter_width = this.search_filter.outerWidth();
        var is_ie6or7 = (typeof $.browser.msie != 'undefined' && $.browser.msie == true && $.browser.version <= '7.0');

        if (is_ie6or7) {
            // set search_filter width, then search_input can take the right size
            this.search_filter.css('width', '500px');
            search_filter_width = $('#global_search_form  a.search-filter-choice').outerWidth();
        }

        var search_input_width = this.search_input.outerWidth(true);

        $(this.search_input).css('margin-right', search_filter_width);

        var search_input_width = this.search_bar_width - search_filter_width;
        $(this.search_input).css('width', search_input_width);

        if (is_ie6or7) {
            // reset search_filter
            this.search_filter.css('margin-left',  search_input_width + 10);
            this.search_filter.css('width', search_filter_width);
        }
    }
},
//Class Properties
{
});

$.Class.extend('Fotolia_Search_Toggle',
// Static properties
{
    cookie_name: 'advanced_search_state',
    displayed_elements: 0,

    /**
     * init Sidebar toggle
     */
    initialize: function()
    {
        // Get all elements on unique array.
        var buttons = $('[id^="search_toggle_"]');

        if ($(buttons).size() > 0) {
            // Init Element states with cookie or defaults values
            Fotolia_Search_Toggle._initElementsStates(buttons);
        }
    },

    /**
     * Set Fotolia_Search_Toggle.displayed_elements with cookie value
     * If cookie not found, initialize with default values
     */
    _initElementsStates: function(buttons)
    {
        var search_toggle, has_cookie;

        // Try to get cookie value
        Fotolia_Search_Toggle.displayed_elements = $.cookie(Fotolia_Search_Toggle.cookie_name);

        if (Fotolia_Search_Toggle.displayed_elements == null) {
            Fotolia_Search_Toggle.displayed_elements = 0
            has_cookie = false;
        } else {
            Fotolia_Search_Toggle.displayed_elements = parseInt(Fotolia_Search_Toggle.displayed_elements)
            has_cookie = true;
        }

        $(buttons).each(function(index, button) {

            search_toggle = new Fotolia_Search_Toggle(button);

            if (!has_cookie && $(button).hasClass('on')) {
                Fotolia_Search_Toggle.displayed_elements |= search_toggle.key;
            }

            Fotolia_Search_Toggle.applyToggle(button, search_toggle);
        });
    },

    /**
     * Update cookie value
     */
    setCookieData: function ()
    {
        $.cookie(Fotolia_Search_Toggle.cookie_name, Fotolia_Search_Toggle.displayed_elements, { path: '/' });
    },

    /**
     * Toggle element
     */
    applyToggle: function(element, toggle_obj, event)
    {
        var active_element = (Fotolia_Search_Toggle.displayed_elements & toggle_obj.key) != 0;

        if (element.id == 'search_toggle_1') {
            // Toggle sidebar

            if (!active_element) {
                $('#advanced_search_block_toggle').attr('class', 'advancedsearch-close');
                $('#search_toggle_1').attr('class', 'advancedsearch-resize-close');
                $('.list').attr('class', 'list-close');
            } else {
                $('#advanced_search_block_toggle').attr('class', 'advancedsearch');
                $('#search_toggle_1').attr('class', 'advancedsearch-resize');
                $('.list-close').attr('class', 'list');
            }

        } else if (element.id == 'search_toggle_16') {
            if (active_element) {
                $('span[id^="search_token:"]').toggle();
                $('input#k.search-input').tokenInput();

            } else {
                if (event && event.type == 'click') {
                    window.location.reload();
                }
            }
        } else {
            // Toggle searchbox

            if (active_element) {
                $(element).parent().addClass('on');
            } else if ($(element).parent().hasClass('on')) {
                $(element).parent().removeClass('on');
            }
        }
    }
},
//Class Properties
{
    key: null,

    /**
     * Initialize,
     * Set object vars and event
     */
    init: function(element)
    {
        // Get binary key
        this.key = 1 << $(element.id.split('_')).last()[0];

        // Set toggle event
        $(element).click({obj: this, method: 'onClick'}, Fotolia.eventHandler);
    },

    /**
     * Toggle event
     */
    onClick:  function(e, target)
    {
        // change element display state
        Fotolia_Search_Toggle.displayed_elements ^= this.key;

        // Save on cookie
        Fotolia_Search_Toggle.setCookieData();

        // Toggle element
        Fotolia_Search_Toggle.applyToggle(target[0], this, e);

        e.stopPropagation();
        return false;
    }

});

/*
 * jQuery Plugin: Tokenizing Autocomplete Text Entry
 * Version 1.4.2
 *
 * Copyright (c) 2009 James Smith (http://loopj.com)
 * Licensed jointly under the GPL and MIT licenses,
 * choose which one suits your project best!
 *
 */

(function ($) {
// Default settings
var DEFAULT_SETTINGS = {
    hintText: "Type in a search term",
    noResultsText: "No results",
    searchingText: "",
    deleteText: "&times;",
    searchDelay: 300,
    minChars: 1,
    tokenLimit: null,
    jsonContainer: null,
    queryParam: "k",
    tokenDelimiter: " ",
    preventDuplicates: false,
    prePopulate: null,
    animateDropdown: true,
    onAdd: null,
    onDelete: null
};

// Default classes to use when theming
var DEFAULT_CLASSES = {
    tokenList: "token-input-list",
    token: "token-input-token",
    tokenBoolean: "token-input-token-boolean",
    tokenDelete: "token-input-delete-token",
    selectedToken: "token-input-selected-token",
    highlightedToken: "token-input-highlighted-token",
    dropdown: "token-input-dropdown",
    dropdownItem: "token-input-dropdown-item",
    dropdownItem2: "token-input-dropdown-item2",
    selectedDropdownItem: "token-input-selected-dropdown-item",
    inputToken: "token-input-input-token"
};

// Input box position "enum"
var POSITION = {
    BEFORE: 0,
    AFTER: 1,
    END: 2
};

// Keys "enum"
var KEY = {
    BACKSPACE: 8,
    TAB: 9,
    ENTER: 13,
    ESCAPE: 27,
    SPACE: 32,
    PAGE_UP: 33,
    PAGE_DOWN: 34,
    END: 35,
    HOME: 36,
    LEFT: 37,
    UP: 38,
    RIGHT: 39,
    DOWN: 40,
    NUMPAD_ENTER: 108,
    COMMA: 188
};


// Expose the .tokenInput function to jQuery as a plugin
$.fn.tokenInput = function (options) {
    var settings = $.extend({}, DEFAULT_SETTINGS, options || {});

    return this.each(function () {
        new $.TokenList(this, settings);
    });
};


// TokenList class for each input
$.TokenList = function (input, settings) {

    // Build class names
    if(settings.classes) {
        // Use custom class names
        settings.classes = $.extend({}, DEFAULT_CLASSES, settings.classes);
    } else if(settings.theme) {
        // Use theme-suffixed default class names
        settings.classes = {};
        $.each(DEFAULT_CLASSES, function(key, value) {
            settings.classes[key] = value + "-" + settings.theme;
        });
    } else {
        settings.classes = DEFAULT_CLASSES;
    }


    // Save the tokens
    var saved_tokens = [];

    // Keep track of the number of tokens in the list
    var token_count = 0;

    // Keep track of the timeout, old vals
    var timeout;
    var input_val;

    var is_edit = false;

    // Create a new text input an attach keyup events
    var input_box = $("<input type=\"text\"  autocomplete=\"off\">")
        .css({
            outline: "none",
            backgroundColor: "transparent"
        })
        .blur(function () {
            /* hide_dropdown(); */
        })
        .bind("keyup keydown blur update", resize_input)
        .keydown(function (event) {
            var previous_token;
            var next_token;

            switch(event.keyCode) {
                case KEY.LEFT:
                case KEY.RIGHT:
                case KEY.UP:
                case KEY.DOWN:
                    if(!$(this).val()) {
                        previous_token = input_token.prev();
                        next_token = input_token.next();

                        if((previous_token.length && previous_token.get(0) === selected_token) || (next_token.length && next_token.get(0) === selected_token)) {
                            // Check if there is a previous/next token and it is selected
                            if(event.keyCode === KEY.LEFT || event.keyCode === KEY.UP) {
                                deselect_token($(selected_token), POSITION.BEFORE);
                            } else {
                                deselect_token($(selected_token), POSITION.AFTER);
                            }
                        } else if((event.keyCode === KEY.LEFT || event.keyCode === KEY.UP) && previous_token.length) {
                            // We are moving left, select the previous token if it exists
                            select_token($(previous_token.get(0)));
                        } else if((event.keyCode === KEY.RIGHT || event.keyCode === KEY.DOWN) && next_token.length) {
                            // We are moving right, select the next token if it exists
                            select_token($(next_token.get(0)));
                        }
                    }
                    break;

                case KEY.BACKSPACE:
                    previous_token = input_token.prev();

                    if(!$(this).val().length) {
                        if(selected_token) {
                            delete_token($(selected_token));
                        } else if(previous_token.length) {
                            select_token($(previous_token.get(0)));
                        }

                        return false;
                    }
                    break;

                case KEY.ESCAPE:
                    // hide_dropdown();
                    return true;

                // case KEY.SPACE:
                //     if (!is_edit) {
                //         add_token();
                //         return false;
                //     }
                //     break;

                case KEY.NUMPAD_ENTER:
                case KEY.ENTER:
                    add_token();
                    if (is_edit) {
                        is_edit = false;
                        return false;
                    }
                    break;

                default:
                    break;
            }
        });

    var form = $(input).parents('form');
    form.submit(function (event) {
        saved_tokens_submit = new Array();
        add_token();
        token_list.children().each(function () {
            var existing_token = $(this);
            var existing_data = $.data(existing_token.get(0), "tokeninput");
            if(existing_data && existing_data.id) {
                saved_tokens_submit.push(existing_data.id);
            }
        });

        // Update the hidden input
        hidden_input.val(saved_tokens_submit.join(settings.tokenDelimiter));

        this.submit();

    });

    // Keep a reference to the original input box
    previous_val = $(input).val();

    var hidden_input = $(input)
       .hide()
       .val("")
       .focus(function () {
           input_box.focus();
       })
       .blur(function () {
           input_box.blur();
       });

    // Keep a reference to the selected token and dropdown item
    var selected_token = null;

    // The list to store the token items in
    var token_list = $("<ul />")
        .addClass(settings.classes.tokenList)
        .click(function (event) {
            var li = $(event.target).closest("li");
            if(li && li.get(0) && $.data(li.get(0), "tokeninput")) {
                edit_token(li);
                input_box.focus();
            } else {
                // Deselect selected token
                if(selected_token) {
                    deselect_token($(selected_token), POSITION.END);
                }

                // Focus input box
                input_box.focus();
            }
        })
        .mouseover(function (event) {
            var li = $(event.target).closest("li");
            if(li && selected_token !== this) {
                li.addClass(settings.classes.highlightedToken);
            }
        })
        .mouseout(function (event) {
            var li = $(event.target).closest("li");
            if (li && selected_token !== this) {
                li.removeClass(settings.classes.highlightedToken);
            }
        })
        .insertBefore(hidden_input);

    // The token holding the input box
    var input_token = $("<li />")
        .addClass(settings.classes.inputToken)
        .appendTo(token_list)
        .append(input_box);

    // Magic element to help us resize the text input
    var input_resizer = $("<tester/>")
        .insertAfter(input_box)
        .css({
            position: "absolute",
            top: -9999,
            left: -9999,
            width: "auto",
            fontSize: input_box.css("fontSize"),
            fontFamily: input_box.css("fontFamily"),
            fontWeight: input_box.css("fontWeight"),
            letterSpacing: input_box.css("letterSpacing"),
            whiteSpace: "nowrap"
        });

    // Pre-populate list if items exist

    // li_data = settings.prePopulate || hidden_input.data("pre");
    // console.log(previous_val.split('"'));
    if (previous_val.length) {
        li_data = parse_input(previous_val);
        if(li_data && li_data.length) {
            $.each(li_data, function (index, value) {
                insert_token(value, value);
            });
        }
    }

    $("#container_search").addClass('container_search');

    //
    //
    // Private functions
    //

    function resize_input() {
        if(input_val === (input_val = input_box.val())) {return;}

        // Enter new content into resizer and resize input accordingly
        var escaped = input_val.replace(/&/g, '&amp;').replace(/\s/g,' ').replace(/</g, '&lt;').replace(/>/g, '&gt;');
        input_resizer.html(escaped);
        input_box.width(input_resizer.width() + 30);

        place_input_box();
    }

    // Inner function to a token to the list
    function insert_token(id, value) {
        // todo : merge arrays
        var no_delete_tags = [ 'AND', 'OR', 'NOT', '-', '(', ')' ];

        if ($.inArray($.trim(value), no_delete_tags) > -1 ) {
            var token_class =  settings.classes.tokenBoolean;
        } else {
            var token_class =  settings.classes.token;
        }
        var this_token = $("<li><p>" + value + "</p> </li>")
          .addClass(token_class)
          .insertBefore(input_token);

        if ($.inArray($.trim(value), no_delete_tags) == -1 ) {

            // The 'delete token' button
            $("<span>" + settings.deleteText + "</span>")
                .addClass(settings.classes.tokenDelete)
                .appendTo(this_token)
                .click(function () {
                    delete_token($(this).parent());
                    return false;
                });
        } else {
            this_token.click(function () {
                delete_token(this_token);
                return false;
            });
        }
        // Store data on the token
        var token_data = {"id": id, "name": value};
        $.data(this_token.get(0), "tokeninput", token_data);

        // Save this token for duplicate checking
        saved_tokens.push(token_data);

        // Update the hidden input
        var token_ids = $.map(saved_tokens, function (el) {
            return el.id;
        });
        hidden_input.val(token_ids.join(settings.tokenDelimiter));

        token_count += 1;

        return this_token;
    }

    // Add a token to the token list based on user input
    function add_token () {
        var item = input_box;
        var keyword_to_add = $.trim(input_box.val());
        var li_data = $.data(item.get(0), "tokeninput");
        var callback = settings.onAdd;

        if (!keyword_to_add) {
            return;
        }

        // See if the token already exists and select it if we don't want duplicates
        if(token_count > 0 && settings.preventDuplicates) {
            var found_existing_token = null;
            token_list.children().each(function () {
                var existing_token = $(this);
                var existing_data = $.data(existing_token.get(0), "tokeninput");
                if(existing_data && existing_data.id === li_data.id) {
                    found_existing_token = existing_token;
                    return false;
                }
            });

            if(found_existing_token) {
                select_token(found_existing_token);
                input_token.insertAfter(found_existing_token);
                input_box.focus();
                return;
            }
        }

        var tokens = new Array();
        tokens = parse_input(keyword_to_add);
        if(tokens && tokens.length) {
            $.each(tokens, function (index, value) {
                insert_token(value, value);
            });
        } else {
            return;
        }

        // Check the token limit
        if(settings.tokenLimit !== null && token_count >= settings.tokenLimit) {
            input_box.hide();
           //  hide_dropdown();
            return;
        } else {
            input_box.focus();
        }

        // Clear input box
        input_box.val('');

        // Execute the onAdd callback if defined
        if($.isFunction(callback)) {
            callback(li_data);
        }

    }

    // Select a token in the token list
    function select_token (token) {
        token.addClass(settings.classes.selectedToken);
        selected_token = token.get(0);

        // Hide input box
        input_box.val('');
        place_input_box();

    }

    // Deselect a token in the token list
    function deselect_token (token, position) {
        token.removeClass(settings.classes.selectedToken);
        selected_token = null;

        if(position === POSITION.BEFORE) {
            input_token.insertBefore(token);
        } else if(position === POSITION.AFTER) {
            input_token.insertAfter(token);
        } else {
            input_token.appendTo(token_list);
        }

        // Show the input box and give it focus again
        input_box.focus();

        place_input_box();
    }

    // place input
    function place_input_box() {

        position = token_list.children(':last').position();
        position_first = token_list.children(':first').position();
        position_input = input_box.position();

        if (selected_token) {
            if (position_input.left < $(selected_token).position().left) {
                ref =  position_input.left;
            } else {
                ref = $(selected_token).position().left;
            }
        } else {
            ref =  position_input.left;
        }

        input_box_width = input_box.width();
        if ((position.left + input_box_width) < 400) {
            token_list.css('margin-left', 0);
        } else if ((position.left - ref + input_box_width )> 400 ) {
            token_list.css('margin-left', - ref);
        } else if (position.left > 400) {
            new_position = position.left - 400 + input_box.width();
            token_list.css('margin-left', - new_position);
        }
    }
    // Toggle selection of a token in the token list
    function toggle_select_token(token) {
        var previous_selected_token = selected_token;

        if(selected_token) {
            deselect_token($(selected_token), POSITION.END);
        }

        if(previous_selected_token === token.get(0)) {
            deselect_token(token, POSITION.END);
        } else {
            select_token(token);
        }
    }

    function edit_token(token) {
        token_value = $.data(token.get(0), "tokeninput");
        add_token();

        is_edit = true;
        input_token.insertAfter(token, POSITION.AFTER);

        delete_token(token);

        input_box.val(token_value.name);
        // Show the input box and give it focus again
        resize_input();
        input_box.focus();

        /* $.data(token.get(0), "tokeninput"); */
    }

    // Delete a token from the token list
    function delete_token (token) {
        // Remove the id from the saved list
        var token_data = $.data(token.get(0), "tokeninput");
        var callback = settings.onDelete;

        // Delete the token
        token.remove();
        selected_token = null;

        // Show the input box and give it focus again
        input_box.focus();

        // Remove this token from the saved list
        saved_tokens = $.grep(saved_tokens, function (val) {
            return (val.id !== token_data.id);
        });

        // Update the hidden input
        var token_ids = $.map(saved_tokens, function (el) {
            return el.id;
        });
        hidden_input.val(token_ids.join(settings.tokenDelimiter));

        token_count -= 1;

        if(settings.tokenLimit !== null) {
            input_box
                .show()
                .val("")
                .focus();
        }

        // Execute the onDelete callback if defined
        if($.isFunction(callback)) {
            callback(token_data);
        }
    }

    // Highlight the query part of the search term
    function highlight_term(value, term) {
        return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<b>$1</b>");
    }

    // parse input to split token
    function parse_input(str) {
        var boolean_keywords = [ 'AND', 'OR', 'NOT', '-' ];
        var tags = [ '(', ')'];
        if (str.length == 0) {
            return false;
        }

        // split string by space then rebuild it per real token
        var str_splitted = str.split(' ');

        var tokens = new Array();
        var need_end_quote = false;
        var tmp_word = new Array();
        if (str_splitted.length) {
            for (var i = 0, length = str_splitted.length; i < length; i++ ) {
                str_value = $.trim(str_splitted[i]);
                if ($.inArray(str_value, boolean_keywords) > -1 && !need_end_quote) {
                    tokens.push(str_value);
                    continue;
                }
                /* console.log(str_value); */
                var start_point = 0;
                var str_parts = new Array();
                for (var j = 0, str_value_length = str_value.length; j < str_value_length; j++ ) {
                    if (str_value[j] == '(' || str_value[j] == ')') {
                        if (j > 0 && j != start_point) {
                            str_parts.push(str_value.slice(start_point, j));
                        }

                        if (j < str_value_length) {
                            str_parts.push(str_value.slice(j, j+1));
                        }
                        start_point = j+1;
                    }
                }

                if (start_point < str_value_length) {
                    str_parts.push(str_value.slice(start_point, str_value_length));
                }

                for (var k = 0, str_parts_length = str_parts.length; k < str_parts_length; k++ ) {
                    str_part_value = $.trim(str_parts[k]);
                    if (str_part_value[0] === '"' && !need_end_quote) {
                        need_end_quote = true;
                        if (str_part_value.length > 1 && str_part_value[str_part_value.length-1] == '"') {
                            need_end_quote = false;
                        }
                    } else if (str_part_value[str_part_value.length-1] === '"') {
                        need_end_quote = false;
                    }
                    if (need_end_quote) {
                        tmp_word.push(str_part_value);
                    } else {
                        if (tmp_word) {
                            tmp_word.push(str_part_value);
                            tokens.push(tmp_word.join(' '));
                            tmp_word = new Array();
                        } else {
                            tokens.push(str_part_value);
                        }
                        need_end_quote = false;
                    }
                }
            }
        }
        return tokens;
    }

};

}(jQuery));
$.Class.extend('Fotolia_ShoppingCart',
// Static properties
{
    cart_items_form: 'cart_items_form',
    cart_item_prefix: 'shopping_cart_item',
    cart_item_license_details_prefix: 'shopping_cart_item_license_info',
    cart_item_unselect_license_prefix: 'shopping_cart_item_unselect_license',
    cart_items_available_for_subscription: [],
    cart_item_trs: null,

    login_form: null,
    signup_form: null,

    initialize: function()
    {
        if ($('div#shopping_cart_view').length) {
            // We are on view shopping cart page
            $('select.scart_license_select').change(Fotolia_ShoppingCart.changeUpdateAllToLicense);
            $('a.scart_unselect_licenses').click(Fotolia_ShoppingCart.clickUnselectAllLicenses);

            // check contract before form submit
            $('#checkout').click(Fotolia_ShoppingCart.clickDownload);

            $('select#lightbox_id32_top').change(Fotolia_ShoppingCart.changeTransferToGallery);
            $('select#lightbox_id32_bottom').change(Fotolia_ShoppingCart.changeTransferToGallery);

            $('form#' + Fotolia_ShoppingCart.cart_items_form + ' :radio').change(Fotolia_ShoppingCart.changeChangeLicense);

            Fotolia_ShoppingCart.cart_item_trs = $('form#' + Fotolia_ShoppingCart.cart_items_form + ' .cart-grid tr');
            Fotolia_ShoppingCart.cart_item_trs.click(Fotolia_ShoppingCart.clickLicenseLine);

            $('a[id^="shopping_cart_item_unselect_license"]').click(Fotolia_ShoppingCart.clickUnselectLicense);

            // toggle forms
            $('a#shopping_cart_login').click(Fotolia_ShoppingCart.showLoginForm);
            $('a#shopping_cart_signup').click(Fotolia_ShoppingCart.showSignUpForm);

            Fotolia_ShoppingCart.login_form = $('#shopping_cart_login_form');
            Fotolia_ShoppingCart.signup_form = $('#shopping_cart_signup_form');

            // get content_ids available for subscription from hidden fields
            $('[class=content_available_for_subscription]').each(function() {
                Fotolia_ShoppingCart.cart_items_available_for_subscription = Fotolia_ShoppingCart.cart_items_available_for_subscription.concat($(this).attr('name').match('\\d+'));
            });
        }

    },

    /**
     * Action called on change on the update all to license box
     */
    changeUpdateAllToLicense: function(e)
    {
        var select = $(this);

        if (select.val() != 'highest' && select.val() != 'highest_vector') {
            $('form#' + Fotolia_ShoppingCart.cart_items_form + ' :radio[value="' + select.val() + '"]').each(function() {
                Fotolia_ShoppingCart._doRadioSelectedActions($(this));
            });
        } else {
            // for each content available for subscription, select highest sub license
            for (index in Fotolia_ShoppingCart.cart_items_available_for_subscription) {
                var content_id = Fotolia_ShoppingCart.cart_items_available_for_subscription[index];

                // 'highest' or 'highest_vector'
                var selected_license_type = select.val();

                // get the content's highest available subscription license from hidden field
                var selected_license = $('form#' + Fotolia_ShoppingCart.cart_items_form + ' [name^=' + '"' + selected_license_type + '_sub_license[' + content_id + ']"]').attr('value');

                $('form#' + Fotolia_ShoppingCart.cart_items_form + ' [name="license[' + content_id + ']"]:radio[value="' + selected_license + '"]').each(function() {
                    Fotolia_ShoppingCart._doRadioSelectedActions($(this));
                });
            }
        }

        Fotolia_ShoppingCart._requestUpdate(select, 'all');

        select.val(0);
    },

    /**
     * Unselect License
     */
    unselectLicense: function (content_id)
    {
        $('form#' + Fotolia_ShoppingCart.cart_items_form + ' :radio[name="license[' + content_id + ']"]').prop('checked', false).parents('tr.on').removeClass('on');
        $('a[id="shopping_cart_item_unselect_license:' + content_id + '"]').hide();
    },

    /**
     * Action called when unselect licenses link is clicked
     */
    clickUnselectLicense: function (e)
    {
        var link = $(this);
        var parts = link.attr('id').split(':');

        if (parts[1]) {
            $('form#' + Fotolia_ShoppingCart.cart_items_form + ' :radio[name="license[' + parts[1] + ']"]').prop('checked', false);
            link.hide();
            Fotolia_ShoppingCart._requestUpdate(link, parts[1]);
        }
    },

    /**
     * Action called on unselect all licenses link
     */
    clickUnselectAllLicenses: function(e)
    {
        $('form#' + Fotolia_ShoppingCart.cart_items_form + ' :radio').prop('checked', false);
        Fotolia_ShoppingCart.cart_item_trs.removeClass('on');

        Fotolia_ShoppingCart._requestUpdate($(this), 'all');

        e.stopPropagation();
        return false;
    },

    /**
     * Method called on change event on the license boxes
     */
    changeChangeLicense: function(e)
    {
        var current_radio = $(this);

        Fotolia_ShoppingCart._doRadioSelectedActions(current_radio);

        var content_id_changed = current_radio.attr('id').replace(/[^0-9]/g, '');

        Fotolia_ShoppingCart._requestUpdate(current_radio, content_id_changed);
    },

    /**
     * Event: change selected license at click on license line
     * exec changeChangeLicense()
     */
    clickLicenseLine: function(e)
    {
        var target = $(e.target);

        if (target.prop('tagName').toLowerCase() !== 'input') {
            var current_radio = $($(e.target).parents('tr')[0]).find('input')[0];

            if (!$(current_radio).prop('checked')) {
                $(current_radio).change();

            }

            e.stopPropagation();
            return false;
        }
    },

    /**
     * Called when transfer to gallery drop down is changed
     */
    changeTransferToGallery: function(e)
    {
        var select = $(this);

        var text = $('#' + select.attr('id') + ' :selected').text();

        if (confirm(sprintf(_('Are you sure you want to move all images to the %s gallery?'), text))) {
            Fotolia.go(select.val());
        }

        e.stopPropagation();
        return false;
    },

    /**
     * Perform actions when radio button is selected
     *
     * @param obj radio_obj The radio button object that was selected
     */
    _doRadioSelectedActions: function(radio_obj)
    {
        $('form#' + Fotolia_ShoppingCart.cart_items_form + ' :radio[name="' + radio_obj.attr('name') + '"]').each(function() {
            var radio = $(this);
            radio.prop('checked', false);
            radio.parents('tr:first').removeClass('on');
        });

        radio_obj.prop('checked', true);
        radio_obj.parents('tr:first').addClass('on');

        var content_id = radio_obj.attr('id').replace(/[^0-9]/g, '');

        $('a[id="shopping_cart_item_unselect_license:' + content_id+ '"]').show();
    },

    /**
     * Method called on click on the download button
     */
    clickDownload: function(e)
    {
        if (!$('#contract_accept').prop('checked')) {
            alert(_('Please accept the contract conditions'));

            return false;
        }

        e.stopPropagation();
    },

    /**
     * Updates the summary for the shopping cart
     *
     * @param object data JSON object with summary data
     */
    updateSummary: function(data)
    {
        $('#shopping_cart_purchased_items').html(data.purchased_items);
        $('#shopping_cart_available_credits').html(data.available_credits);
        $('#shopping_cart_total').html(data.total_price);

        var remaining = $('#shopping_cart_remaining_credits');

        remaining.html(data.remaining_credits);

        if (data.nb_remaining_credits < 0) {
            remaining.addClass('negative');
            $('#shopping_cart_download_link').hide();
            $('#shopping_cart_buy_credits_link').show();
        } else {
            remaining.removeClass('negative');
            $('#shopping_cart_buy_credits_link').hide();
            $('#shopping_cart_download_link').show();
        }
    },

    /**
     * Update the license details for an item in the cart
     */
    updateLicenseDetails: function(content_id, data)
    {
        var obj = $('[id="' + Fotolia_ShoppingCart.cart_item_license_details_prefix + ':' + content_id + '"]');

        if (obj) {
            obj.html(data);

            Fotolia_Tooltip.initialize(obj);
        }
    },

    /**
     * Updates the number of contents in the shopping cart
     *
     * @param string nb_contents The number of contents to update to
     */
    updateShoppingcartNbContents: function(nb_contents)
    {
        $('[id="global_shoppingcart:nbcontents"]').html(nb_contents);
    },

    /**
     * Removes a content id from the cart
     *
     * @param int content_id The content id to remove
     */
    removeFromCart: function(content_id)
    {
        $('[id="' + Fotolia_ShoppingCart.cart_item_prefix + ':' + content_id + '"]').fadeOut('slow', function() {
            $(this).remove();
            if ($('[id^="' + Fotolia_ShoppingCart.cart_item_prefix + ':"]').length == 0) {
                $('.tools').remove();
                $('#cart_summary').css({'position':'relative', 'top':'', 'left':''});
                $('.cart-item-block.empty-cart').fadeIn('slow');
            }

            Fotolia_CartSummary.onContainerChange();
        });
    },

    /**
     * Shows the subscription full notice
     *
     * @param string text The text to show
     */
    subscriptionFullNotice: function(text)
    {
        Fotolia.showMessage(text);
    },

    /**
     * Method to call when license is changed to update the summary
     */
    _requestUpdate: function(obj, content_id_changed)
    {
        var form = $('form#' + Fotolia_ShoppingCart.cart_items_form);
        var data = form.serializeArray();

        data.push({name: 'content_id_changed', value: content_id_changed});

        Fotolia_AjaxActions.ajaxPostCall($('#ajax_shopping_cart_update').attr('href'), obj, data);
    },

    /**
     * Shows the login form
     */
    showLoginForm: function(e)
    {
        Fotolia_ShoppingCart.login_form.show();
        Fotolia_ShoppingCart.signup_form.hide();

        e.stopPropagation();
        return false;
    },

    /**
     * Shows the sign up form
     */
    showSignUpForm: function(e)
    {
        Fotolia_ShoppingCart.signup_form.show();
        Fotolia_ShoppingCart.login_form.hide();

        var url = '/Ajax/ShoppingCart/Subscribe';
        Fotolia_AjaxActions.ajaxPostCall(url, $(this));

        e.stopPropagation();
        return false;
    }
},
//Class Properties
{
});

$.Class.extend('Fotolia_Toggle',
// Static properties
{
    initialize: function()
    {
        // hide toggled elements
        $('div[id^="toggled_"]').toggle(0);
        // add click event to hide/show toggled elements
        $('[id^="toggle:"]').click(Fotolia_Toggle.clickToggle);
    },

    clickToggle: function (e)
    {
        $('#' + this.id.split(':')[1]).toggle(0);

        e.stopPropagation();
        return false;
    }
},
//Class Properties
{
});

$.Class.extend('Fotolia_Tooltip',
// Static properties
{
    nb: 0,
    tooltip_template: $.template('\
            <div class="${content_classes}" style="width: 428px;">\
                <div class="preview-top"></div>\
                <div class="preview-content">\
                    <div class="preview-title">\
                        <span class="preview-copyright">${contributor_name}</span>\
                        <img class="img img-16 ${css_ico_class}" src="${static_base}all/img/clear.gif" alt="camera" /> #${content_id}\
                    </div>\
                    <div class="preview-thumbnail" style="${content_height_css}">${embed_html}</div>\
                    <div class="preview-meta">\
                        <p class="preview-downloads"><img class="img img-16 img-download" src="${static_base}all/img/clear.gif" alt="download" /> ${nb_downloads}</p>\
                        <p class="preview-views"><img class="img img-16 img-eye" src="${static_base}all/img/clear.gif" alt="eye" /> ${nb_views}</p>\
                        <p class="preview-licence"><em>${licenses_label}</em> ${licenses} ${sub_icon}</p>\
                        <p class="preview-credits"><em>${credits_label}</em> ${credits} <img class="img img-16 img-credits" src="${static_base}all/img/clear.gif" alt="credits" /></p>\
                    <div class="cb"></div>\
                </div>\
            </div>\
            <div class="preview-bottom"></div>\
        </div>\
    ', {compile: true}),

    sub_icon_template: $.template('<img class="img img-24 img-green-subscription" src="${static_base}all/img/clear.gif" alt="subscription" />'),
    infinite_icon_template: $.template('<img class="img img-24" src="${static_base}all/img/clear.gif" alt="infinite" />'),
    offset: 15,

    /**
     * Init for the tooltips
     */
    initialize: function(context)
    {
        if (context) {
            $('img.with-ezpz-tooltip', context).each(Fotolia_Tooltip.applyImageTooltip);
            $('div.simple-image-thumb img', context).each(Fotolia_Tooltip.applySimpleImageTooltip);
            $('a[id^="tooltip:"]', context).each(Fotolia_Tooltip.applyHTMLTooltip);
        } else {
            $('img.with-ezpz-tooltip').each(Fotolia_Tooltip.applyImageTooltip);
            $('div.simple-image-thumb img', context).each(Fotolia_Tooltip.applySimpleImageTooltip);
            $('a[id^="tooltip:"]').each(Fotolia_Tooltip.applyHTMLTooltip);
        }
    },

    applyImageTooltip: function()
    {
        var target = $(this);
        var regexp = new RegExp('\/[0-9\/-]+\/(30|110)_F_');

        if (!target.attr('src').match(regexp)) {
            return;
        }

        var tooltip = new Fotolia_Tooltip(target, 'image');
    },

    applySimpleImageTooltip: function()
    {
        var target = $(this);
        var regexp = new RegExp('\/[0-9\/-]+\/(30|110)_F_');

        if (!target.attr('src').match(regexp)) {
            return;
        }

        var tooltip = new Fotolia_Tooltip(target, 'simple_image');
    },

    applyHTMLTooltip: function()
    {
        var tooltip = new Fotolia_Tooltip($(this), 'html');
    }
},
//Class Properties
{
    target: null,
    content: null,
    content_processed: false,
    quarter_choosed: false,
    last_mouse_x: null,
    last_mouse_y: null,
    type: null,
    best_quarter: null,
    window_limits: null,

    init: function(target, type)
    {
        this.target = target;
        this.type = type;

        // Set id on target object
        this.target.attr('id', this.target_id);
        this.target.attr('title', '');
        this.target.bind('mouseover', {obj: this, method: 'onMouseOver'}, Fotolia.eventHandler);
        this.target.bind('mousemove', {obj: this, method: 'onMouseMove'}, Fotolia.eventHandler);
        this.target.bind('mouseout', {obj: this, method: 'onMouseOut'}, Fotolia.eventHandler);

        switch (this.type) {
            case 'html':
                this._initHTMLTooltip();
                break;

            case 'image':
            case 'simple_image':
            default:
                this._initImageTooltip();
                break;

        }

        Fotolia_Tooltip.nb++;
    },

    _initImageTooltip: function()
    {
        // find first div on parents nodes
        this.content = $('div.tooltip-data', this.target.parents('div')[0]);
        this.content.css('position', 'fixed');
        this.content.css('z-index', '100000');
    },

    _initHTMLTooltip: function()
    {
        var parts = this.target.attr('id').split(':');

        if (parts[1]) {
            var div_id = parts[1];

            this.content = $('div#' + div_id);
            this.content.css('position', 'fixed');
            this.content.css('z-index', '100000');
        }
    },

    onMouseOver: function(e, target)
    {
        if (!this.content_processed) {
            switch (this.type) {
                case 'html':
                    break;

                case 'simple_image':
                    var json_data = $.parseJSON(this.content.html());
                    if (!json_data) {
                        return;
                    }

                    var regexp = new RegExp('\/(30|110)_F_');
                    var img_src = this.target.attr('src').replace(regexp, '/400_F_');

                    json_data.img_srcS = this.target.attr('src');
                    json_data.img_srcL = this.target.attr('src').replace(regexp, '/400_F_');

                    var embed_html = [
                        '<div class="preview-content">',
                        '<img class="simple-preview-img display_none" width="' + json_data.w + '" height="' + json_data.h + '" src="' + json_data.img_srcL + '" alt="#' + json_data.content_id + '" />',
                        '<img width="' + json_data.w + '" height="' + json_data.h + '" src="' + $(target).attr('src') + '" alt="#' + json_data.content_id + '" />',
                        '</div>'
                    ].join('');

                    this.content.html('');
                    this.content.append(embed_html);

                    this.content.find('img.simple-preview-img').bind('load', {obj: this, method: 'onLoadImage'}, Fotolia.eventHandler);
                    break;

                case 'image':
                default:
                    var json_data = $.parseJSON(this.content.html());
                    if (!json_data) {
                        return;
                    }

                    var regexp = new RegExp('\/(30|110)_F_');
                    var img_src = this.target.attr('src').replace(regexp, '/400_F_');

                    json_data.img_srcS = this.target.attr('src');
                    json_data.img_srcL = this.target.attr('src').replace(regexp, '/400_F_');

                    if (json_data.video) {
                        var flv_src = json_data.url_flv;

                        var flv_player_src = ('https:' == document.location.protocol ? 'https://sstatic.fotolia.com' : 'http://s.ftcdn.net');
                        flv_player_src = flv_player_src + '/r/v2010/573bc909c4e3b21b2f71effcdd206903243858f9/pics/all/flash/flv_player.swf';

                        json_data.embed_html = flashembed.getHTML({
                            src: flv_player_src,
                            width: json_data.w,
                            height: json_data.h,
                            version: [9, 0],
                            expressInstall: 'expressInstall.swf',
                            allowfullScreen: false,
                            menu: false,
                            w3c: true,
                            id: 'flv_thumb' + json_data.content_id
                        },
                        {
                            autoplay: true,
                            repeat: true,
                            video_src: flv_src,
                            first_img: json_data.img_srcL
                        });

                        json_data.css_ico_class = 'img-video';

                    } else {
                        json_data.embed_html = [
                            '<img class="preview-img display_none" width="' + json_data.w + '" height="' + json_data.h + '" src="' + json_data.img_srcL + '" alt="#' + json_data.content_id + '" />',
                            '<img width="' + json_data.w + '" height="' + json_data.h + '" src="' + $(target).attr('src') + '" alt="#' + json_data.content_id + '" />'
                        ];

                        json_data.embed_html = json_data.embed_html.join('');

                        if (json_data.vector) {
                            json_data.css_ico_class = 'img-vector';
                        } else {
                            json_data.css_ico_class = 'img-camera';
                        }
                    }

                    // force tooltips image/flash container height
                    json_data.content_height_css = 'height:' +json_data.h + 'px';

                    if (typeof Fotolia.static_pics_url != 'undefined') {
                        json_data.static_base = Fotolia.static_pics_url;
                    }

                    json_data.content_classes = 'preview';
                    if (json_data.infinite) {
                        json_data.sub_icon = Fotolia_Tooltip.infinite_icon_template.apply(json_data);
                        json_data.content_classes += ' infinite';
                    } else if (json_data.subscription) {
                        json_data.sub_icon = Fotolia_Tooltip.sub_icon_template.apply(json_data);
                    } else {
                        json_data.sub_icon = '';
                    }

                    json_data.licenses_label = _('Licenses:');
                    json_data.credits_label = _('Credits:');

                    this.content.html('');
                    this.content.append(Fotolia_Tooltip.tooltip_template, json_data);

                    if (json_data.is_video) {
                        // trigger Flash parsing
                        Fotolia_Flash.initialize();
                    } else {
                        this.content.find('img.preview-img').bind('load', {obj: this, method: 'onLoadImage'}, Fotolia.eventHandler);
                    }
            }

            this.content_processed = true;
        }

        // chose best quarter to display tooltips on mouse over
        this.chooseQuarter(e);

        e.stopPropagation();
        return false;
    },

    onLoadImage: function(e)
    {
        $(e.target).next().hide();
        $(e.target).show();
    },

    onMouseOut: function(e, target)
    {
        this.content.hide();
        this.quarter_choosed = false;

        e.stopPropagation();
        return false;
    },

    onMouseMove: function(e, target)
    {
        if (this.quarter_choosed) {
            if (e.pageX) {
                this.last_mouse_x = e.pageX;
            }
            if (e.pageY) {
                this.last_mouse_y = e.pageY;
            }
            var top, left, offset, window_width, window_height;
            offset = Fotolia_Tooltip.offset;
            window_width = $(window).width();
            window_height = $(window).height();

            // Calculate real mouse position with reference to scroll
            var real_mouse_x = this.last_mouse_x - $(window).scrollLeft();
            var real_mouse_y = this.last_mouse_y - $(window).scrollTop();

            switch (this.best_quarter) {
                case 'nw':
                    top = real_mouse_y - offset - this.content_height;
                    left = real_mouse_x - offset - this.content_width;
                    break;

                case 'ne':
                    top = real_mouse_y - offset - this.content_height;
                    left = real_mouse_x + offset;
                    break;


                case 'sw':
                    top = real_mouse_y + offset;
                    left = real_mouse_x - offset - this.content_width;
                    break;

                case 'se':
                default:
                    top = real_mouse_y + offset;
                    left = real_mouse_x + offset;

            }

            // try to not get of the windows
            if (top < this.window_limits['north']) {
                top = this.window_limits['north'];
            } else if (top > this.window_limits['south']) {
                top = this.window_limits['south'];
            }

            if (left < this.window_limits['west']) {
                left = this.window_limits['west'];
            } else if (left > this.window_limits['east']) {
                left= this.window_limits['east'];
            }

            this.content.css('top', top);
            this.content.css('left', left);
            this.content.show();
        }

        e.stopPropagation();
        return false;
    },

    chooseQuarter: function (e)
    {
        var window_limits, target_pos, available_way, inner_obj;
        // set content properties
        this.content.show();

        if (this.type == 'image') {
            inner_obj = $(':first-child', this.content);
        } else {
            inner_obj = $(this.content);
        }
        this.content_height = inner_obj.outerHeight(true);
        this.content_width = inner_obj.outerWidth(true);

        this.content.hide()

        // get window limits
        window_limits = [];
        window_limits['south'] = $(window).height() - this.content_height;
        window_limits['east'] = $(window).width() - this.content_width;
        window_limits['north'] = 0;
        window_limits['west'] = 0;

        // get target position (max south, east, north, west)
        target_pos = [];
        target_pos['south'] = this.target.offset().top + this.target.outerHeight() - $(window).scrollTop();
        target_pos['east'] = this.target.offset().left + this.target.outerWidth() - $(window).scrollLeft();
        target_pos['north'] = this.target.offset().top - $(window).scrollTop();
        target_pos['west'] = this.target.offset().left - $(window).scrollLeft();

        // get available_way to display complet tooltip
        available_way = [];
        available_way['south'] = target_pos['south'] < window_limits['south'];
        available_way['east'] = target_pos['east'] < window_limits['east'];
        available_way['north'] = (target_pos['north'] - this.content_height) > window_limits['north'];
        available_way['west'] = (target_pos['west'] - this.content_width) > window_limits['west'];

        // try to display on south-east
        if (available_way['south'] && available_way['east']){
            this.best_quarter = 'se';
        } else {
            var vertical_way, horizontal_way;
            vertical_way = 's';
            horizontal_way = 'e';

            if (!available_way['south']) {
                // north is there a better way ?
                if (available_way['north']) {
                    vertical_way = 'n';
                } else if (target_pos['north'] > ($(window).height() - target_pos['south'])) {
                    vertical_way = 'n';
                }
            }

            if (!available_way['east']) {
                // west is there a better way ?
                if (available_way['west']) {
                    horizontal_way = 'w';
                } else if (target_pos['west'] > ($(window).width() - target_pos['east'])) {
                    horizontal_way = 'w';
                }
            }

            // set best_quarter to onMouseMove event.
            this.best_quarter = vertical_way + horizontal_way;
        }

        // set window properties
        this.window_limits = window_limits;
        this.quarter_choosed = true;
    }

});

/*
Zoom on 400px images
*/
$.Class.extend('Fotolia_Zoom',
// Static properties
{
    id_reg_exp: new RegExp('\/(jpg|photos_mini)\/.+\/(300|400)_F_'),

    zooms: new Array(),

    /**
     * Initializes zooms on the page
     */
    initialize: function() {
        var images = $('img');
        var zoom_present = false;

        for (var i = 0; i < images.length; i++) {

            if (!images[i].src.match(Fotolia_Zoom.id_reg_exp)) {
                continue;
            }

            Fotolia_Zoom.createNewZoom(images[i]);
            zoom_present = true;
        }

        if (zoom_present) {
            $(document).bind('click', Fotolia_Zoom.reinitAll);
        }
    },

    /**
     * Creates a new zoom
     *
     * @param object img jQuery or HTML image object
     */
    createNewZoom: function(img)
    {
        // Make sure it's a jquery object
        img = $(img);
        // zoom ratio for each new click
        if (zoom_ratio = img.attr('zoom_ratio')) {
            zoom_ratio = Number(zoom_ratio);
            if (zoom_ratio == 0) {
                return false;
            }
        } else {
            return false;
        }

        if (zoom_depth_max = img.attr('zoom_depth_max')) {
            zoom_depth_max = Number(zoom_depth_max);
        } else {
            return false;
        }

        hash = img.attr('hash');

        var zoom = new Fotolia_Zoom(img, zoom_ratio, zoom_depth_max, hash);
        zoom.create();
    },

    /**
     * Gets the zoom object with the provided id
     *
     * @param string id The id to look for
     *
     * @return Fotolia_Zoom|null Returns the zoom object or null
     */
    getZoom: function(id)
    {
        for (var i = 0; i < Fotolia_Zoom.zooms.length; i++) {
            if (Fotolia_Zoom.zooms[i].id == id) {
                return Fotolia_Zoom.zooms[i];
            }
        }
        return null;
    },

    /**
     * Reinits all zooms
     */
    reinitAll: function()
    {
        var zoom;
        for (var i = 0, l = Fotolia_Zoom.zooms.length; i < l; i++) {

            zoom = Fotolia_Zoom.zooms[i];
            if (!zoom.loading) {
                zoom.reinit();
            }
        }
    },

    /**
     * Hides the clip box for a zoom
     *
     * @param string id The id of the zoom to hide the clip box for
     */
    hideZoomClip: function(id)
    {
        var zoom = Fotolia_Zoom.getZoom(id);
        if (zoom) {
            zoom.hideClip();
        }
    },

    /**
     * Handles events, calls the proper method
     *
     * @param Event e The event object for the event
     */
    eventHandler: function(e)
    {
        var zoom = e.data.zoom;

        switch (e.data.event) {
            case 'mouseover':
                zoom.onMouseOver(e);
                break;

            case 'mousemove':
                zoom.onMouseMove(e);
                break;

            case 'mouseout':
                zoom.onMouseOut(e);
                break;

            case 'click':
                zoom.onClick(e);
                break;

            case 'load':
                zoom.onloadZoomImage();
                break;

            case 'error':
                zoom.loading = false;
                break;

            default:

        }
    }
},
// Class Properties
{
    id: null,
    img: null,
    zoom_ratio: null,
    zoom_depth_max: null,
    border_size: 1,
    out_border_size: 1,
    ratio: null,
    zoom_depth: 0,
    loading: false,
    container_x_coord: null,
    container_y_coord: null,
    container_width: null,
    container_height: null,
    original_src: null,
    zoom_image: null,
    original_image: null,

    /**
     * Constructor for Fotolia_Zoom object
     *
     * @param object img jQuery object for the image
     * @param float zoom_ratio The zoom ratio
     * @param float zoom_depth_max The max zoom depth
     */
    init: function(img, zoom_ratio, zoom_depth_max, hash)
    {
        this.img = img;

        // zoom ratio for each new click
        this.zoom_ratio = zoom_ratio
        this.zoom_depth_max = zoom_depth_max + 1;

        // ratio of the clip box
        this.ratio = 1 / this.zoom_ratio;

        this.loading = false;

        this.hash = hash;
    },

    create: function()
    {
        var src = this.img.attr('src');

        // add events, only on jpg
        if (!src.match(this.Class.id_reg_exp)) {
            return false;
        }

        var new_image = this.img.clone();

        new_image.attr('id', 'img:' + src)
            .attr('title', '')
            .prop('is_original_img', true);

        this.original_image = new_image;
        this.original_src = src;
        this.container_width = this.img.prop('width');
        this.container_height = this.img.prop('height');

        // create clip
        var div_clip = $('<div></div>');

        div_clip.hide()
            .css('width', Math.round(this.container_width * this.ratio) + 'px')
            .css('height', Math.round(this.container_height * this.ratio) + 'px')
            .css('position', 'absolute')
            .css('border', '1px solid #777777')
            .css('borderWidth', Math.round(this.border_size) + 'px')
            .addClass('FotoliaZoomClip');

        // create container
        var div = $('<div></div>');

        this.id = 'FotoliaZoom:' + src;

        div.attr('id', this.id)
            .css('width', this.container_width + 'px')
            .css('height', this.container_height + 'px')
            .css('position', 'relative')
            .css('overflow', 'hidden')
            .addClass('FotoliaZoom')
            .append(new_image)
            .append(div_clip);

        // replace original image
        this.img.replaceWith(div);

        // name references
        this.container = div;
        this.img = new_image;
        this.clip = div_clip;

        div.bind('mouseover', {zoom: this, event: 'mouseover'}, Fotolia_Zoom.eventHandler);
        div.bind('mousemove', {zoom: this, event: 'mousemove'}, Fotolia_Zoom.eventHandler);
        div.bind('mouseout', {zoom: this, event: 'mouseout'}, Fotolia_Zoom.eventHandler);
        div.bind('click', {zoom: this, event: 'click'}, Fotolia_Zoom.eventHandler);

        Fotolia_Zoom.zooms.push(this);
    },

    /**
     * Event for when the mouse is moved on the image
     *
     * @param Event e The event object
     */
    onMouseMove: function(e)
    {
        var x_coord = e.pageX;
        var y_coord = e.pageY;

        // reference to clip
        var clip_width = this.clip.width();
        var clip_height = this.clip.height();

        var left = Math.ceil(x_coord - this.container_x_coord - clip_width / 2);
        var top = Math.ceil(y_coord - this.container_y_coord - clip_height / 2);

        if (left < 0) {
            left = 0;
        } else if (left >= (this.container_width - clip_width)) {
            left = this.container_width - clip_width - this.border_size * 2;
        }

        if (top < 0) {
            top = 0;
        } else if (top >= (this.container_height - clip_height)) {
            top = this.container_height - clip_height - this.border_size * 2;
        }

        if (isNaN(top)) {
            top = 0;
        }

        if (isNaN(left)) {
            left = 0;
        }

        this.clip.css('top', top + 'px');
        this.clip.css('left', left + 'px');
    },

    /**
     * Event for when the mouse is moved over the image
     *
     * @param Event e The event object
     */
    onMouseOver: function(e)
    {
        if (this.hide_clip_timeout) {
            window.clearTimeout(this.hide_clip_timeout);
        }

        if (this.zoom_depth >= this.zoom_depth_max) {
            return false;
        } else if (this.loading) {
            return false;
        } else {
            if (this.clip.is(':visible')) {
                return false;
            }

            this.showClip();
        }
    },

    /**
     * Event for when the mouse is moved out of the image
     *
     * @param Event e The event object
     */
    onMouseOut: function(e)
    {
        if (this.hide_clip_timeout) {
            window.clearTimeout(this.hide_clip_timeout);
        }

        this.hide_clip_timeout = window.setTimeout('Fotolia_Zoom.hideZoomClip("' + this.id + '");', 100);
    },

    /**
     * Handles the click event for clicks on the zoom image
     *
     * @param Event e The event object
     */
    onClick: function(e)
    {
        if (!this.loading) {
            if (this.zoom_depth == 0) {
                // first call
                this.base_x = 0;
                this.base_y = 0;

                this.base_left = 0;
                this.base_top = 0;

                this.zoom_depth = 1;
            }

            if (this.zoom_depth >= this.zoom_depth_max) {
                this.reinit();
                this.showClip();
            } else {
                var img_offset = this.img.offset();
                var clip_offset = this.clip.offset();
                var clip_width = this.clip.width();
                var clip_height = this.clip.height();

                var container_width = this.container_width;
                var container_height = this.container_height;

                var current_zoom_ratio = Math.pow(this.zoom_ratio, this.zoom_depth - 1);

                this.base_x = ((0 - this.base_left) + clip_offset.left - img_offset.left + this.border_size + clip_width / 2) / current_zoom_ratio;
                this.base_y = ((0 - this.base_top) + clip_offset.top - img_offset.top + this.border_size + clip_height / 2) / current_zoom_ratio;

                this.base_left = (container_width / 2) - (this.base_x * this.zoom_ratio * current_zoom_ratio);
                this.base_top = (container_height / 2) - (this.base_y * this.zoom_ratio * current_zoom_ratio);

                // request new image (zoom + crop) and display it
                var zoom_image = $('<img />');
                var zoom_image_src = 'http://zoom.fotolia.com/Content/Zoom/' + (this.zoom_ratio * current_zoom_ratio) + '/' + this.base_x + '/' + this.base_y + '/?path=' + escape(this.original_src);
                if (typeof this.hash != 'undefined') {
                    zoom_image_src += '&hash=' + this.hash;
                }

                zoom_image.bind('error', {zoom: this, event:'error'}, Fotolia_Zoom.eventHandler)
                zoom_image.bind('load', {zoom: this, event:'load'}, Fotolia_Zoom.eventHandler)

                this.loading = true;
                zoom_image.attr('src', zoom_image_src);

                this.zoom_image = zoom_image;

                // and now we compute for browser zoom
                if (img_offset.left == 0 && this.img.width() == container_width) {
                    // no zoom for the current image
                    current_zoom_ratio = 1;
                }

                // dot position which will be the new center (based on current image displayed, dynamix src)
                var x = ((0 - img_offset.left) + clip_offset.left + this.border_size + clip_width / 2);
                var y = ((0 - img_offset.top) + clip_offset.top + this.border_size + clip_height / 2);

                // multiply dims
                var width = container_width * this.zoom_ratio;
                var height = container_height * this.zoom_ratio;

                // translate origin: x,y must be on the center
                var left = (container_width / 2) - (x * this.zoom_ratio);
                var top = (container_height / 2) - (y * this.zoom_ratio);

                // bound origins
                if (left > 0) {
                    left = 0;
                } else if (left + width < container_width) {
                    left = container_width - width;
                }

                if (top > 0) {
                    top = 0;
                } else if (top + height < container_height) {
                    top = container_height - height;
                }

                // browser zoom
                this.img.css('position', 'absolute');
                this.img.css('left', Math.round(left) + 'px');
                this.img.css('top', Math.round(top) + 'px');

                // zoom with current image (browser zoom)
                this.img.css('width', width);
                this.img.css('height', height);

                this.zoom_depth++;

                this.hideClip();
            }
        }

        e.stopImmediatePropagation();
        return false;
    },

    /**
     * Show the zoom clip box
     */
    showClip: function()
    {
        if (!this.container_x_coord) {

            var offset = this.container.offset();
            this.container_x_coord = offset.left;
            this.container_y_coord = offset.top;

        }

        if (this.hide_clip_timeout) {
            window.clearTimeout(this.hide_clip_timeout);
        }

        this.clip.show();
    },

    /**
     * Hide the zoom clip box
     */
    hideClip: function()
    {
        this.clip.hide();
    },

    /**
     * Reinitialize the zoom
     */
    reinit: function()
    {
        this.original_image.css('left', '0px');
        this.original_image.css('top', '0px');
        this.original_image.css('width', this.container_width);
        this.original_image.css('height', this.container_height);

        this.img.hide();
        this.original_image.show();

        if (typeof this.img.prop('is_original_img') == 'undefined') {
            this.img.remove();
        }

        this.img = this.original_image;

        this.base_x = 0;
        this.base_y = 0;

        this.base_left = 0;
        this.base_top = 0;

        this.zoom_depth = 0;
        this.loading = false;
    },

    onloadZoomImage: function()
    {
        this.container.append(this.zoom_image);
        this.img.hide();
        this.zoom_image.show();

        if (typeof this.img.prop('is_original_img') == 'undefined') {
            this.img.remove();
        }

        this.img = this.zoom_image;
        this.loading = false;

        if (this.zoom_depth < this.zoom_depth_max) {
            this.showClip();
        }
    }


});

//
// Fotolia locales
//

Fotolia_Locale.localisations['de_DE'] = {
    'Are you sure you want to delete this?' : 'Möchten Sie wirklich löschen?',
    'Are you sure?' : 'Sind Sie sicher?',
    'Are you sure you want to move all images to the %s gallery?' : 'Sind Sie sich sicher, dass Sie alle Bilder in die Galerie %s bewegen möchten?',
    'Please accept the contract conditions' : 'Bitte akzeptieren Sie die Vertragsbestimmungen',
    'Licenses:' : 'Lizenzen',
    'Credits:' : 'Credits',
    'Open release file' : 'Freigabe öffnen',
    'Delete' : 'Löschen',
    'Minimum price is 1 credit and only integers value are allowed.': 'Der Mindestpreis beträgt 1 Credit und nur ganze Zahlenwerte sind erlaubt',
    'This price is too high !' : 'Dieser Preis ist zu hoch!',
    'This price is too low !' : 'Dieser Preis ist zu niedrig!',
    'You must enter at least 7 keywords' : 'Bitte geben Sie mindestens 7 Schlagworte ein',
    'You must enter 80 keywords maximum' : 'Bitte maximal 80 Schlagwörter eingeben',
    'Please fill out the title (maximum %d characters and alpha numeric only).' : 'Bitte geben Sie einen Titel ein (maximal %d alphanumerische Zeichen)',
    'You must accept the contract conditions.' : 'Sie müssen dieVertragsbestimmungen akzeptieren',
    'Please check the form:' : 'Bitte überprüfen Sie das Formular ',
    'You must agree to all the upload conditions' : 'Sie müssen alle Upload-Bestimmungen akzeptieren',
    'Please select a file to upload from your computer.' : 'Bitte wählen Sie eine Datei auf Ihrem Computer aus, um diese hochzuladen.',
    'You must select a payment method' : 'Bitte wählen Sie eine Zahlungsmethode aus',
    'Release title is under minimum length of %s characters' : 'Titel für Freigabe mindestens %s Zeichen',
    'Release title is over maximum length of %s characters' : 'Titel für Freigabe nicht länger als %s Zeichen'
};


Fotolia_Locale.localisations['en_GB'] = {
    'Are you sure you want to delete this?' : 'Are you sure you want to delete this?',
    'Are you sure?' : 'Are you sure?',
    'Are you sure you want to move all images to the %s gallery?' : 'Are you sure you want to move all images to the %s gallery?',
    'Please accept the contract conditions' : 'Please accept the contract conditions',
    'Licenses:' : 'Licenses:',
    'Credits:' : 'Credits:',
    'Open release file' : 'Open release file',
    'Delete' : 'Delete',
    'Minimum price is 1 credit and only integers value are allowed.': 'Minimum price is 1 credit; only whole numbers allowed.',
    'This price is too high !' : 'The price is too high',
    'This price is too low !' : 'The price is too low',
    'You must enter at least 7 keywords' : 'You must enter at least 7 keywords',
    'You must enter 80 keywords maximum' : 'Maximum of 80 keywords allowed',
    'Please fill out the title (maximum %d characters and alpha numeric only).' : 'Please enter a title (maximum %d characters and alpha numeric only).',
    'You must accept the contract conditions.' : 'You must accept the contract conditions.',
    'Please check the form:' : 'Please check the form:',
    'You must agree to all the upload conditions' : 'You must agree to all the upload conditions',
    'Please select a file to upload from your computer.' : 'Please select a file to upload from your computer.',
    'You must select a payment method' : 'You must select a payment method',
    'Release title is under minimum length of %s characters' : 'Release title is under minimum length of %s characters',
    'Release title is over maximum length of %s characters' : 'Release title is over maximum length of %s characters'
};

Fotolia_Locale.localisations['en_US'] = {
    'Are you sure you want to delete this?' : 'Are you sure you want to delete this?',
    'Are you sure?' : 'Are you sure?',
    'Are you sure you want to move all images to the %s gallery?' : 'Are you sure you want to move all images to the %s gallery?',
    'Please accept the contract conditions' : 'Please accept the contract conditions',
    'Licenses:' : 'Licenses:',
    'Credits:' : 'Credits:',
    'Open release file' : 'Open release file',
    'Delete' : 'Delete',
    'Minimum price is 1 credit and only integers value are allowed.': 'The minimum price is 1 credit; only whole numbers are allowed.',
    'This price is too high !' : 'The price is too high',
    'This price is too low !' : 'The price is too low',
    'You must enter at least 7 keywords' : 'Please enter at least 7 keywords',
    'You must enter 80 keywords maximum' : 'Please enter less than 80 keywords',
    'Please fill out the title (maximum %d characters and alpha numeric only).' : 'Please enter a title (maximum %d characters and alpha numeric only).',
    'You must accept the contract conditions.' : 'Please accept the contract conditions.',
    'Please check the form:' : 'Please check the form:',
    'You must agree to all the upload conditions' : 'Please agree to all the upload conditions before continuing',
    'Please select a file to upload from your computer.' : 'Please select a file to upload from your computer.',
    'You must select a payment method' : 'Please select a payment method before continuing',
    'Release title is under minimum length of %s characters' : 'Release title is under minimum length of %s characters',
    'Release title is over maximum length of %s characters' : 'Release title is over maximum length of %s characters'
};


Fotolia_Locale.localisations['es_ES'] = {
    'Are you sure you want to delete this?' : '¿Seguro que desea borrar esto?',
    'Are you sure?' : '¿Está seguro?',
    'Are you sure you want to move all images to the %s gallery?' : '¿Seguro que desea mover todas las imágenes a la galería %s?',
    'Please accept the contract conditions' : 'Por favor acepte las condiciones del contrato',
    'Licenses:' : 'Licencias',
    'Credits:' : 'Créditos',
    'Open release file' : 'Abrir archivo de contrato',
    'Delete' : 'Borrar',
    'Minimum price is 1 credit and only integers value are allowed.': 'El precio mínimo es 1 crédito y solo se permiten valores enteros',
    'This price is too high !' : '¡El precio es muy alto!',
    'This price is too low !' : '¡El precio es muy bajo!',
    'You must enter at least 7 keywords' : 'Debe escribir al menos 7 palabras clave',
    'You must enter 80 keywords maximum' : 'Debe escribir un máximo de 80 palabras clave',
    'Please fill out the title (maximum %d characters and alpha numeric only).' : 'Por favor complete el título (máximo %d caracteres y solo alfa numérico)',
    'You must accept the contract conditions.' : 'Debe aceptar las condiciones del contrato',
    'Please check the form:' : 'Por favor verifique el formulario',
    'You must agree to all the upload conditions' : 'Debe aceptar las condiciones de envío',
    'Please select a file to upload from your computer.' : 'Por favor seleccione un archivo para enviar desde su ordenador',
    'You must select a payment method' : 'Debe seleccionar un método de pago',
    'Release title is under minimum length of %s characters' : 'El título del contrato está por debajo del mínimo de %s caracteres',
    'Release title is over maximum length of %s characters' : 'El título del contrato supera el máximo de %s caracteres'
};


Fotolia_Locale.localisations['fr_FR'] = {
    'Are you sure you want to delete this?' : 'Confirmez-vous la suppression ?',
    'Are you sure?' : 'Êtes-vous sûr ?',
    'Are you sure you want to move all images to the %s gallery?' : 'Êtes-vous sûr de vouloir transférer toutes les images vers la galerie %s ?',
    'Please accept the contract conditions' : 'Veuillez accepter les conditions contractuelles',
    'Licenses:' : 'Licences :',
    'Credits:' : 'Crédits :',
    'Open release file' : 'Ouvrir le fichier',
    'Delete' : 'Supprimer',
    'Minimum price is 1 credit and only integers value are allowed.': 'Le prix minimum est 1 crédit et seuls les nombres entiers sont acceptés.',
    'This price is too high !' : 'Le prix est trop élevé.',
    'This price is too low !' : 'Le prix est trop faible.',
    'You must enter at least 7 keywords' : 'Vous devez entrer au moins 7 mots clés',
    'You must enter 80 keywords maximum' : 'Vous ne pouvez entrer au maximum que 80 mots clés',
    'Please fill out the title (maximum %d characters and alpha numeric only).' : 'Veuillez renseigner le titre (maximum %d caractères, alphanumériques uniquement).',
    'You must accept the contract conditions.' : 'Vous devez accepter les conditions contractuelles.',
    'Please check the form:' : 'Veuillez vérifier le formulaire :',
    'You must agree to all the upload conditions' : 'Vous devez accepter toutes les dispositions relatives à l\'upload',
    'Please select a file to upload from your computer.' : 'Veuillez sélectionner le fichier à uploader.',
    'You must select a payment method' : 'Vous devez sélectionner une méthode de paiement',
    'Release title is under minimum length of %s characters' : 'Le titre de l\'autorisation est trop court (%s caractères minimum)',
    'Release title is over maximum length of %s characters' : 'Le titre de l\'autorisation est trop long (%s caractères maximum)'
};


Fotolia_Locale.localisations['it_IT'] = {
    'Are you sure you want to delete this?' : 'Confermi di voler cancellare?',
    'Are you sure?' : 'Confermi?',
    'Are you sure you want to move all images to the %s gallery?' : 'Confermi di voler trasferire tutti i file nella galleria %s ?',
    'Please accept the contract conditions' : 'Accetta le condizioni del contratto',
    'Licenses:' : 'Licenze',
    'Credits:' : 'Crediti',
    'Open release file' : 'Apri file liberatoria',
    'Delete' : 'Cancella',
    'Minimum price is 1 credit and only integers value are allowed.': 'Il prezzo minimo è 1 credito. Non sono ammessi valori decimali',
    'This price is too high !' : 'Prezzo troppo alto',
    'This price is too low !' : 'Prezzo troppo basso',
    'You must enter at least 7 keywords' : 'Inserisci almeno 7 parole chiave',
    'You must enter 80 keywords maximum' : 'Inserisci al massimo 80 parole chiave',
    'Please fill out the title (maximum %d characters and alpha numeric only).' : 'Inserisci il titolo (max %d  caratteri e solo alfanumerici)',
    'You must accept the contract conditions.' : 'Devi accettare le condizioni del contratto',
    'Please check the form:' : 'Spunta il box',
    'You must agree to all the upload conditions' : 'E\' essenziale accettare le condizioni di caricamento file',
    'Please select a file to upload from your computer.' : 'Seleziona dal tuo computer un file da caricare',
    'You must select a payment method' : 'Seleziona un metodo di pagamento',
    'Release title is under minimum length of %s characters' : 'Titolo liberatoria inferiore a lunghezza minima di %s caratteri',
    'Release title is over maximum length of %s characters' : 'Titolo liberatoria eccede lunghezza massima di %s caratteri'
};


Fotolia_Locale.localisations['ja_JP'] = {
    'Are you sure you want to delete this?' : '本当に削除してもよいですか？',
    'Are you sure?' : '本当によいですか？',
    'Are you sure you want to move all images to the %s gallery?' : 'すべての作品を %s ギャラリーに移動してもよいですか？',
    'Please accept the contract conditions' : '契約条件に同意してください',
    'Licenses:' : 'ライセンス',
    'Credits:' : 'クレジット',
    'Open release file' : '承諾書ファイルを開く',
    'Delete' : '削除',
    'Minimum price is 1 credit and only integers value are allowed.': '最低価格は1クレジットで、整数のみ入力できます',
    'This price is too high !' : 'この価格は高すぎます',
    'This price is too low !' : 'この価格は低すぎます',
    'You must enter at least 7 keywords' : '少なくとも7つのキーワードを入力してください',
    'You must enter 80 keywords maximum' : '最大で80個のキーワードを設定できます',
    'Please fill out the title (maximum %d characters and alpha numeric only).' : 'タイトルを入力してください（最大 %d 文字で、半角英数字のみ使用できます）。',
    'You must accept the contract conditions.' : '契約条件に同意する必要があります。',
    'Please check the form:' : 'フォームをチェックしてください:',
    'You must agree to all the upload conditions' : 'コンテンツのアップロードに関する契約に同意する必要があります',
    'Please select a file to upload from your computer.' : 'お使いのコンピューターからアップロードするファイルを選択してください。',
    'You must select a payment method' : '支払方法を選択してください',
    'Release title is under minimum length of %s characters' : '承諾書のタイトルが、最短の %s 文字に達していません',
    'Release title is over maximum length of %s characters' : '承諾書のタイトルが、最長の %s 文字を超えています'
};


Fotolia_Locale.localisations['ko_KR'] = {
    'Are you sure you want to delete this?' : '확인: 삭제하시겠습니까?',
    'Are you sure?' : '계속하시겠습니까?',
    'Are you sure you want to move all images to the %s gallery?' : '확인:전체 콘텐츠를 %s 갤러리로 옮기시겠습니까?  ',
    'Please accept the contract conditions' : '서비스 이용약관에 동의하세요',
    'Licenses:' : '라이센스',
    'Credits:' : '크레딧',
    'Open release file' : '동의서 열기',
    'Delete' : '삭제',
    'Minimum price is 1 credit and only integers value are allowed.': '최저가격은 1 크레딧이며, 정수만 입력 가능합니다.',
    'This price is too high !' : '가격이 너무 높습니다',
    'This price is too low !' : '가격이 너무 낮습니다',
    'You must enter at least 7 keywords' : '최소 7개의 키워드를 입력하세요.',
    'You must enter 80 keywords maximum' : '키워드는 최대 80개까지 입력할 수 있습니다',
    'Please fill out the title (maximum %d characters and alpha numeric only).' : '파일명을 입력하세요 (최대 %d자의 문자 또는 숫자) ',
    'You must accept the contract conditions.' : '서비스이용약관에 동의하세요',
    'Please check the form:' : '양식을 확인하세요',
    'You must agree to all the upload conditions' : '모든 콘텐츠 업로드 계약에 동의하세요',
    'Please select a file to upload from your computer.' : '내 컴퓨터에서 업로드할 파일을 선택하세요',
    'You must select a payment method' : '결제방식을 선택하세요',
    'Release title is under minimum length of %s characters' : '동의서 이름이 지나치게 짧습니다. (최소 %s 자)',
    'Release title is over maximum length of %s characters' : '동의서 이름이 지나치게 깁니다. (최대 %s 자)'
};


Fotolia_Locale.localisations['pl_PL'] = {
    'Are you sure you want to delete this?' : 'Czy na pewno chcesz to usunąć?',
    'Are you sure?' : 'Czy na pewno?',
    'Are you sure you want to move all images to the %s gallery?' : 'Czy na pewno chcesz przenieść wszystkie obrazy do galerii %s? ',
    'Please accept the contract conditions' : 'Prosimy zaakceptować warunki umowy',
    'Licenses:' : 'Licencje',
    'Credits:' : 'Kredyty',
    'Open release file' : 'Otwórz plik z umową',
    'Delete' : 'Usuń',
    'Minimum price is 1 credit and only integers value are allowed.': 'Minimalna cena wynosi 1 kredyt, a dozwoloną wartością są liczby całkowite',
    'This price is too high !' : 'Podana cena jest zbyt wysoka!',
    'This price is too low !' : 'Podana cena jest zbyt niska!',
    'You must enter at least 7 keywords' : 'Musisz wprowadzić co najmniej 7 słów kluczowych',
    'You must enter 80 keywords maximum' : 'Możesz wprowadzić maksymalnie 80 słów kluczowych',
    'Please fill out the title (maximum %d characters and alpha numeric only).' : 'Prosimy wprowadzić tytuł (maksymalnie %d znaków, tylko w kodzie alfanumerycznym)',
    'You must accept the contract conditions.' : 'Musisz zaakceptować warunki umowy',
    'Please check the form:' : 'Prosimy sprawdzić formularz',
    'You must agree to all the upload conditions' : 'Musisz zaakceptować warunki umieszczania plików',
    'Please select a file to upload from your computer.' : 'Prosimy wybrać plik do wysłania z Twojego komputera',
    'You must select a payment method' : 'Musisz wybrać sposób płatności',
    'Release title is under minimum length of %s characters' : 'Tytuł zgodny nie przekracza minimalnej długości %s znaków',
    'Release title is over maximum length of %s characters' : 'Tytuł zgodny przekracza maksymalną długość %s znaków'
};


Fotolia_Locale.localisations['pt_BR'] = {
    'Are you sure you want to delete this?' : 'Tem a certeza que quer apagar isto?',
    'Are you sure?' : 'Tem a certeza?',
    'Are you sure you want to move all images to the %s gallery?' : 'Tem a certeza que quer mover todas as imagens para a galeria %s ?',
    'Please accept the contract conditions' : 'Por favor aceite os termos e condições do contrato',
    'Licenses:' : 'Licenças',
    'Credits:' : 'Créditos',
    'Open release file' : 'Abrir',
    'Delete' : 'Eliminar',
    'Minimum price is 1 credit and only integers value are allowed.': 'O preço mínimo é de 1 crédito e unicamente números inteiros serão aceites',
    'This price is too high !' : 'Este preço é muito elevado',
    'This price is too low !' : 'Este preço é muito baixo',
    'You must enter at least 7 keywords' : 'Deverá introduzir pelo menos 7 palavras-chave',
    'You must enter 80 keywords maximum' : 'Deverá introduzir no máximo 80 palavras-chave',
    'Please fill out the title (maximum %d characters and alpha numeric only).' : 'Por favor preencha o titulo (máximo de %d carateres, alfanuméricos unicamente)',
    'You must accept the contract conditions.' : 'Necessita de aceitar os termos e condições',
    'Please check the form:' : 'Por favor verifique o formulário',
    'You must agree to all the upload conditions' : 'Deverá aceitar todas a condições de upload',
    'Please select a file to upload from your computer.' : 'Por favor selecione um arquivo de seu computador para ser carregado',
    'You must select a payment method' : 'Deverá selecionar um método de pagamento',
    'Release title is under minimum length of %s characters' : 'O titulo da Autorização tem de ter no mínimo %s carateres',
    'Release title is over maximum length of %s characters' : 'O titulo da Autorização tem de ter no máximo %s carateres'
};


Fotolia_Locale.localisations['pt_PT'] = {
    'Are you sure you want to delete this?' : 'Tem a certeza que quer apagar isto?',
    'Are you sure?' : 'Tem a certeza?',
    'Are you sure you want to move all images to the %s gallery?' : 'Tem a certeza que quer mover todas as imagens para a galeria %s ?',
    'Please accept the contract conditions' : 'Por favor aceite os termos e condições do contrato',
    'Licenses:' : 'Licenças',
    'Credits:' : 'Créditos',
    'Open release file' : 'Abrir',
    'Delete' : 'Eliminar',
    'Minimum price is 1 credit and only integers value are allowed.': 'O preço mínimo é de 1 crédito e unicamente números inteiros serão aceites',
    'This price is too high !' : 'Este preço é muito elevado',
    'This price is too low !' : 'Este preço é muito baixo',
    'You must enter at least 7 keywords' : 'Deverá introduzir pelo menos 7 palavras-chave',
    'You must enter 80 keywords maximum' : 'Deverá introduzir no máximo 80 palavras-chave',
    'Please fill out the title (maximum %d characters and alpha numeric only).' : 'Por favor preencha o titulo (máximo de %d carateres, alfanuméricos unicamente)',
    'You must accept the contract conditions.' : 'Necessita de aceitar os termos e condições',
    'Please check the form:' : 'Por favor verifique o formulário',
    'You must agree to all the upload conditions' : 'Deverá aceitar todas a condições de upload',
    'Please select a file to upload from your computer.' : 'Por favor selecione um ficheiro do seu computador para ser carregado',
    'You must select a payment method' : 'Deverá selecionar um método de pagamento',
    'Release title is under minimum length of %s characters' : 'O titulo da Autorização tem de ter no mínimo %s carateres',
    'Release title is over maximum length of %s characters' : 'O titulo da Autorização tem de ter no máximo %s carateres'
};


Fotolia_Locale.localisations['ru_RU'] = {
    'Are you sure you want to delete this?' : 'Вы уверены, что хотите удалить это?',
    'Are you sure?' : 'Вы уверены?',
    'Are you sure you want to move all images to the %s gallery?' : 'Вы уверены, что хотите переместить все изображения в %s галерею?',
    'Please accept the contract conditions' : 'Пожалуйста, примите условия Договора',
    'Licenses:' : 'Лицензия',
    'Credits:' : 'Баллы',
    'Open release file' : 'Открыть файл релиза',
    'Delete' : 'Удалить',
    'Minimum price is 1 credit and only integers value are allowed.': 'Минимальная цена 1 балл , допустимы только целые числы.',
    'This price is too high !' : 'Цена слишком высокая!',
    'This price is too low !' : 'Цена слишком низкая!',
    'You must enter at least 7 keywords' : 'Введите минимум 7 ключевых слов',
    'You must enter 80 keywords maximum' : 'Введите максимум 80 ключевых слов',
    'Please fill out the title (maximum %d characters and alpha numeric only).' : 'Пожалуйста, заполните название (максимум %d  знаков, только буквы  и цифры )',
    'You must accept the contract conditions.' : 'Вам необходимо принять условия Договора',
    'Please check the form:' : 'Пожалуйста, проверьте форму',
    'You must agree to all the upload conditions' : 'Вы должны согласиться со всеми условиями скачивания',
    'Please select a file to upload from your computer.' : 'Пожалуйста, выберете , файл, чтобы загрузить',
    'You must select a payment method' : 'Выберете способ оплаты',
    'Release title is under minimum length of %s characters' : 'Название Релиза состоит из %s знаков',
    'Release title is over maximum length of %s characters' : 'Название релиза превышает допустимое количество %s знаков'
};


Fotolia_Locale.localisations['tr_TR'] = {
    'Are you sure you want to delete this?' : 'Bunu silmek istediğinizden emin misiniz?',
    'Are you sure?' : 'Emin misiniz?',
    'Are you sure you want to move all images to the %s gallery?' : 'Tüm görselleri %s isimli galeriye aktarmak istediğinizden emin misiniz?',
    'Please accept the contract conditions' : 'Lütfen sözleşme şartlarını kabul ediniz',
    'Licenses:' : 'Lisanslar:',
    'Credits:' : 'Creditler:',
    'Open release file' : 'İzin belgesi dosyasını aç',
    'Delete' : 'Sil',
    'Minimum price is 1 credit and only integers value are allowed.': 'Minimum fiyat 1 Credit\'tir ve sadece tamsayılar değeri kabul edilir.',
    'This price is too high !' : 'Bu fiyat çok yüksek!',
    'This price is too low !' : 'Bu fiyat çok düşük!',
    'You must enter at least 7 keywords' : 'En az 7 anahtar kelime girmelisiniz',
    'You must enter 80 keywords maximum' : 'Maksimum 80 anahtar kelime girebilirsiniz',
    'Please fill out the title (maximum %d characters and alpha numeric only).' : 'Lütfen başlığı doldurunuz (maksimum %d karakter ve sadece alfasayısal olmalı).',
    'You must accept the contract conditions.' : 'Sözleşme şartlarını kabul etmelisiniz.',
    'Please check the form:' : 'Lütfen formu kontrol ediniz:',
    'You must agree to all the upload conditions' : 'Tüm yükleme koşullarını kabul etmelisiniz',
    'Please select a file to upload from your computer.' : 'Bilgisayarınızdan yükleme yapmak için lütfen bir dosya seçiniz.',
    'You must select a payment method' : 'Bir ödeme yöntemi seçmelisiniz',
    'Release title is under minimum length of %s characters' : 'Model İzin Belgesi\'nin başlığı %s karakterlik minimum uzunluğunun altındadır',
    'Release title is over maximum length of %s characters' : 'Model İzin Belgesi\'nin başlığı %s karakterlik maksimum uzunluğunun üzerindedir'
};

Fotolia_Locale.localisations['zh_CN'] = {
    'Are you sure you want to delete this?' : '您确定要删除这个吗?',
    'Are you sure?' : '您确定吗?',
    'Are you sure you want to move all images to the %s gallery?' : '您确定你要把所有图片移到%s画廊吗?',
    'Please accept the contract conditions' : '请接受合同条件',
    'Licenses:' : '授权书:',
    'Credits:' : '图币:',
    'Open release file' : '打开肖像权让渡书文件',
    'Delete' : '删除',
    'Minimum price is 1 credit and only integers value are allowed.': '最低价格为1个图币, 只接受整数价值。',
    'This price is too high !' : '这个价格太高了！',
    'This price is too low !' : '这个价格太低了！',
    'You must enter at least 7 keywords' : '您必须输入至少7个关键词',
    'You must enter 80 keywords maximum' : '最多输入80个关键字',
    'Please fill out the title (maximum %d characters and alpha numeric only).' : '请填写标题（最多%d个字符, 只限字母和数字）。',
    'You must accept the contract conditions.' : '您必须接受合同的条件。',
    'Please check the form:' : '请检查表格:',
    'You must agree to all the upload conditions' : '您必须同意所有的上传条件',
    'Please select a file to upload from your computer.' : '请从您的计算机选择要上传的文件。',
    'You must select a payment method' : '你必须选择付款方式',
    'Release title is under minimum length of %s characters' : '俏像权让渡书标题必须超过%s个字符',
    'Release title is over maximum length of %s characters' : '俏像权让渡书标题必须少于%s个字符'
};


$(document).ready(function(){
    Fotolia.initialize();
});


