/*
 * jQuery JavaScript Library v1.3
 * http://jquery.com/
 *
 * Copyright (c) 2009 John Resig
 * Dual licensed under the MIT and GPL licenses.
 * http://docs.jquery.com/License
 *
 * Date: 2009-01-13 12:50:31 -0500 (Tue, 13 Jan 2009)
 * Revision: 6104
 */
(function(){var l=this,g,x=l.jQuery,o=l.$,n=l.jQuery=l.$=function(D,E){return new n.fn.init(D,E)},C=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;n.fn=n.prototype={init:function(D,G){D=D||document;if(D.nodeType){this[0]=D;this.length=1;this.context=D;return this}if(typeof D==="string"){var F=C.exec(D);if(F&&(F[1]||!G)){if(F[1]){D=n.clean([F[1]],G)}else{var H=document.getElementById(F[3]);if(H){if(H.id!=F[3]){return n().find(D)}var E=n(H);E.context=document;E.selector=D;return E}D=[]}}else{return n(G).find(D)}}else{if(n.isFunction(D)){return n(document).ready(D)}}if(D.selector&&D.context){this.selector=D.selector;this.context=D.context}return this.setArray(n.makeArray(D))},selector:"",jquery:"1.3",size:function(){return this.length},get:function(D){return D===g?n.makeArray(this):this[D]},pushStack:function(E,G,D){var F=n(E);F.prevObject=this;F.context=this.context;if(G==="find"){F.selector=this.selector+(this.selector?" ":"")+D}else{if(G){F.selector=this.selector+"."+G+"("+D+")"}}return F},setArray:function(D){this.length=0;Array.prototype.push.apply(this,D);return this},each:function(E,D){return n.each(this,E,D)},index:function(D){return n.inArray(D&&D.jquery?D[0]:D,this)},attr:function(E,G,F){var D=E;if(typeof E==="string"){if(G===g){return this[0]&&n[F||"attr"](this[0],E)}else{D={};D[E]=G}}return this.each(function(H){for(E in D){n.attr(F?this.style:this,E,n.prop(this,D[E],F,H,E))}})},css:function(D,E){if((D=="width"||D=="height")&&parseFloat(E)<0){E=g}return this.attr(D,E,"curCSS")},text:function(E){if(typeof E!=="object"&&E!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(E))}var D="";n.each(E||this,function(){n.each(this.childNodes,function(){if(this.nodeType!=8){D+=this.nodeType!=1?this.nodeValue:n.fn.text([this])}})});return D},wrapAll:function(D){if(this[0]){var E=n(D,this[0].ownerDocument).clone();if(this[0].parentNode){E.insertBefore(this[0])}E.map(function(){var F=this;while(F.firstChild){F=F.firstChild}return F}).append(this)}return this},wrapInner:function(D){return this.each(function(){n(this).contents().wrapAll(D)})},wrap:function(D){return this.each(function(){n(this).wrapAll(D)})},append:function(){return this.domManip(arguments,true,function(D){if(this.nodeType==1){this.appendChild(D)}})},prepend:function(){return this.domManip(arguments,true,function(D){if(this.nodeType==1){this.insertBefore(D,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(D){this.parentNode.insertBefore(D,this)})},after:function(){return this.domManip(arguments,false,function(D){this.parentNode.insertBefore(D,this.nextSibling)})},end:function(){return this.prevObject||n([])},push:[].push,find:function(D){if(this.length===1&&!/,/.test(D)){var F=this.pushStack([],"find",D);F.length=0;n.find(D,this[0],F);return F}else{var E=n.map(this,function(G){return n.find(D,G)});return this.pushStack(/[^+>] [^+>]/.test(D)?n.unique(E):E,"find",D)}},clone:function(E){var D=this.map(function(){if(!n.support.noCloneEvent&&!n.isXMLDoc(this)){var H=this.cloneNode(true),G=document.createElement("div");G.appendChild(H);return n.clean([G.innerHTML])[0]}else{return this.cloneNode(true)}});var F=D.find("*").andSelf().each(function(){if(this[h]!==g){this[h]=null}});if(E===true){this.find("*").andSelf().each(function(H){if(this.nodeType==3){return}var G=n.data(this,"events");for(var J in G){for(var I in G[J]){n.event.add(F[H],J,G[J][I],G[J][I].data)}}})}return D},filter:function(D){return this.pushStack(n.isFunction(D)&&n.grep(this,function(F,E){return D.call(F,E)})||n.multiFilter(D,n.grep(this,function(E){return E.nodeType===1})),"filter",D)},closest:function(D){var E=n.expr.match.POS.test(D)?n(D):null;return this.map(function(){var F=this;while(F&&F.ownerDocument){if(E?E.index(F)>-1:n(F).is(D)){return F}F=F.parentNode}})},not:function(D){if(typeof D==="string"){if(f.test(D)){return this.pushStack(n.multiFilter(D,this,true),"not",D)}else{D=n.multiFilter(D,this)}}var E=D.length&&D[D.length-1]!==g&&!D.nodeType;return this.filter(function(){return E?n.inArray(this,D)<0:this!=D})},add:function(D){return this.pushStack(n.unique(n.merge(this.get(),typeof D==="string"?n(D):n.makeArray(D))))},is:function(D){return !!D&&n.multiFilter(D,this).length>0},hasClass:function(D){return !!D&&this.is("."+D)},val:function(J){if(J===g){var D=this[0];if(D){if(n.nodeName(D,"option")){return(D.attributes.value||{}).specified?D.value:D.text}if(n.nodeName(D,"select")){var H=D.selectedIndex,K=[],L=D.options,G=D.type=="select-one";if(H<0){return null}for(var E=G?H:0,I=G?H+1:L.length;E<I;E++){var F=L[E];if(F.selected){J=n(F).val();if(G){return J}K.push(J)}}return K}return(D.value||"").replace(/\r/g,"")}return g}if(typeof J==="number"){J+=""}return this.each(function(){if(this.nodeType!=1){return}if(n.isArray(J)&&/radio|checkbox/.test(this.type)){this.checked=(n.inArray(this.value,J)>=0||n.inArray(this.name,J)>=0)}else{if(n.nodeName(this,"select")){var M=n.makeArray(J);n("option",this).each(function(){this.selected=(n.inArray(this.value,M)>=0||n.inArray(this.text,M)>=0)});if(!M.length){this.selectedIndex=-1}}else{this.value=J}}})},html:function(D){return D===g?(this[0]?this[0].innerHTML:null):this.empty().append(D)},replaceWith:function(D){return this.after(D).remove()},eq:function(D){return this.slice(D,+D+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(D){return this.pushStack(n.map(this,function(F,E){return D.call(F,E,F)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(J,M,L){if(this[0]){var I=(this[0].ownerDocument||this[0]).createDocumentFragment(),F=n.clean(J,(this[0].ownerDocument||this[0]),I),H=I.firstChild,D=this.length>1?I.cloneNode(true):I;if(H){for(var G=0,E=this.length;G<E;G++){L.call(K(this[G],H),G>0?D.cloneNode(true):I)}}if(F){n.each(F,y)}}return this;function K(N,O){return M&&n.nodeName(N,"table")&&n.nodeName(O,"tr")?(N.getElementsByTagName("tbody")[0]||N.appendChild(N.ownerDocument.createElement("tbody"))):N}}};n.fn.init.prototype=n.fn;function y(D,E){if(E.src){n.ajax({url:E.src,async:false,dataType:"script"})}else{n.globalEval(E.text||E.textContent||E.innerHTML||"")}if(E.parentNode){E.parentNode.removeChild(E)}}function e(){return +new Date}n.extend=n.fn.extend=function(){var I=arguments[0]||{},G=1,H=arguments.length,D=false,F;if(typeof I==="boolean"){D=I;I=arguments[1]||{};G=2}if(typeof I!=="object"&&!n.isFunction(I)){I={}}if(H==G){I=this;--G}for(;G<H;G++){if((F=arguments[G])!=null){for(var E in F){var J=I[E],K=F[E];if(I===K){continue}if(D&&K&&typeof K==="object"&&!K.nodeType){I[E]=n.extend(D,J||(K.length!=null?[]:{}),K)}else{if(K!==g){I[E]=K}}}}}return I};var b=/z-?index|font-?weight|opacity|zoom|line-?height/i,p=document.defaultView||{},r=Object.prototype.toString;n.extend({noConflict:function(D){l.$=o;if(D){l.jQuery=x}return n},isFunction:function(D){return r.call(D)==="[object Function]"},isArray:function(D){return r.call(D)==="[object Array]"},isXMLDoc:function(D){return D.documentElement&&!D.body||D.tagName&&D.ownerDocument&&!D.ownerDocument.body},globalEval:function(F){F=n.trim(F);if(F){var E=document.getElementsByTagName("head")[0]||document.documentElement,D=document.createElement("script");D.type="text/javascript";if(n.support.scriptEval){D.appendChild(document.createTextNode(F))}else{D.text=F}E.insertBefore(D,E.firstChild);E.removeChild(D)}},nodeName:function(E,D){return E.nodeName&&E.nodeName.toUpperCase()==D.toUpperCase()},each:function(F,J,E){var D,G=0,H=F.length;if(E){if(H===g){for(D in F){if(J.apply(F[D],E)===false){break}}}else{for(;G<H;){if(J.apply(F[G++],E)===false){break}}}}else{if(H===g){for(D in F){if(J.call(F[D],D,F[D])===false){break}}}else{for(var I=F[0];G<H&&J.call(I,G,I)!==false;I=F[++G]){}}}return F},prop:function(G,H,F,E,D){if(n.isFunction(H)){H=H.call(G,E)}return typeof H==="number"&&F=="curCSS"&&!b.test(D)?H+"px":H},className:{add:function(D,E){n.each((E||"").split(/\s+/),function(F,G){if(D.nodeType==1&&!n.className.has(D.className,G)){D.className+=(D.className?" ":"")+G}})},remove:function(D,E){if(D.nodeType==1){D.className=E!==g?n.grep(D.className.split(/\s+/),function(F){return !n.className.has(E,F)}).join(" "):""}},has:function(E,D){return n.inArray(D,(E.className||E).toString().split(/\s+/))>-1}},swap:function(G,F,H){var D={};for(var E in F){D[E]=G.style[E];G.style[E]=F[E]}H.call(G);for(var E in F){G.style[E]=D[E]}},css:function(F,D,H){if(D=="width"||D=="height"){var J,E={position:"absolute",visibility:"hidden",display:"block"},I=D=="width"?["Left","Right"]:["Top","Bottom"];function G(){J=D=="width"?F.offsetWidth:F.offsetHeight;var L=0,K=0;n.each(I,function(){L+=parseFloat(n.curCSS(F,"padding"+this,true))||0;K+=parseFloat(n.curCSS(F,"border"+this+"Width",true))||0});J-=Math.round(L+K)}if(n(F).is(":visible")){G()}else{n.swap(F,E,G)}return Math.max(0,J)}return n.curCSS(F,D,H)},curCSS:function(H,E,F){var K,D=H.style;if(E=="opacity"&&!n.support.opacity){K=n.attr(D,"opacity");return K==""?"1":K}if(E.match(/float/i)){E=v}if(!F&&D&&D[E]){K=D[E]}else{if(p.getComputedStyle){if(E.match(/float/i)){E="float"}E=E.replace(/([A-Z])/g,"-$1").toLowerCase();var L=p.getComputedStyle(H,null);if(L){K=L.getPropertyValue(E)}if(E=="opacity"&&K==""){K="1"}}else{if(H.currentStyle){var I=E.replace(/\-(\w)/g,function(M,N){return N.toUpperCase()});K=H.currentStyle[E]||H.currentStyle[I];if(!/^\d+(px)?$/i.test(K)&&/^\d/.test(K)){var G=D.left,J=H.runtimeStyle.left;H.runtimeStyle.left=H.currentStyle.left;D.left=K||0;K=D.pixelLeft+"px";D.left=G;H.runtimeStyle.left=J}}}}return K},clean:function(E,J,H){J=J||document;if(typeof J.createElement==="undefined"){J=J.ownerDocument||J[0]&&J[0].ownerDocument||document}if(!H&&E.length===1&&typeof E[0]==="string"){var G=/^<(\w+)\s*\/?>$/.exec(E[0]);if(G){return[J.createElement(G[1])]}}var F=[],D=[],K=J.createElement("div");n.each(E,function(O,Q){if(typeof Q==="number"){Q+=""}if(!Q){return}if(typeof Q==="string"){Q=Q.replace(/(<(\w+)[^>]*?)\/>/g,function(S,T,R){return R.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?S:T+"></"+R+">"});var N=n.trim(Q).toLowerCase();var P=!N.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!N.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||N.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!N.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!N.indexOf("<td")||!N.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!N.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||!n.support.htmlSerialize&&[1,"div<div>","</div>"]||[0,"",""];K.innerHTML=P[1]+Q+P[2];while(P[0]--){K=K.lastChild}if(!n.support.tbody){var M=!N.indexOf("<table")&&N.indexOf("<tbody")<0?K.firstChild&&K.firstChild.childNodes:P[1]=="<table>"&&N.indexOf("<tbody")<0?K.childNodes:[];for(var L=M.length-1;L>=0;--L){if(n.nodeName(M[L],"tbody")&&!M[L].childNodes.length){M[L].parentNode.removeChild(M[L])}}}if(!n.support.leadingWhitespace&&/^\s/.test(Q)){K.insertBefore(J.createTextNode(Q.match(/^\s*/)[0]),K.firstChild)}Q=n.makeArray(K.childNodes)}if(Q.nodeType){F.push(Q)}else{F=n.merge(F,Q)}});if(H){for(var I=0;F[I];I++){if(n.nodeName(F[I],"script")&&(!F[I].type||F[I].type.toLowerCase()==="text/javascript")){D.push(F[I].parentNode?F[I].parentNode.removeChild(F[I]):F[I])}else{if(F[I].nodeType===1){F.splice.apply(F,[I+1,0].concat(n.makeArray(F[I].getElementsByTagName("script"))))}H.appendChild(F[I])}}return D}return F},attr:function(I,F,J){if(!I||I.nodeType==3||I.nodeType==8){return g}var G=!n.isXMLDoc(I),K=J!==g;F=G&&n.props[F]||F;if(I.tagName){var E=/href|src|style/.test(F);if(F=="selected"&&I.parentNode){I.parentNode.selectedIndex}if(F in I&&G&&!E){if(K){if(F=="type"&&n.nodeName(I,"input")&&I.parentNode){throw"type property can't be changed"}I[F]=J}if(n.nodeName(I,"form")&&I.getAttributeNode(F)){return I.getAttributeNode(F).nodeValue}if(F=="tabIndex"){var H=I.getAttributeNode("tabIndex");return H&&H.specified?H.value:I.nodeName.match(/^(a|area|button|input|object|select|textarea)$/i)?0:g}return I[F]}if(!n.support.style&&G&&F=="style"){return n.attr(I.style,"cssText",J)}if(K){I.setAttribute(F,""+J)}var D=!n.support.hrefNormalized&&G&&E?I.getAttribute(F,2):I.getAttribute(F);return D===null?g:D}if(!n.support.opacity&&F=="opacity"){if(K){I.zoom=1;I.filter=(I.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(J)+""=="NaN"?"":"alpha(opacity="+J*100+")")}return I.filter&&I.filter.indexOf("opacity=")>=0?(parseFloat(I.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}F=F.replace(/-([a-z])/ig,function(L,M){return M.toUpperCase()});if(K){I[F]=J}return I[F]},trim:function(D){return(D||"").replace(/^\s+|\s+$/g,"")},makeArray:function(F){var D=[];if(F!=null){var E=F.length;if(E==null||typeof F==="string"||n.isFunction(F)||F.setInterval){D[0]=F}else{while(E){D[--E]=F[E]}}}return D},inArray:function(F,G){for(var D=0,E=G.length;D<E;D++){if(G[D]===F){return D}}return -1},merge:function(G,D){var E=0,F,H=G.length;if(!n.support.getAll){while((F=D[E++])!=null){if(F.nodeType!=8){G[H++]=F}}}else{while((F=D[E++])!=null){G[H++]=F}}return G},unique:function(J){var E=[],D={};try{for(var F=0,G=J.length;F<G;F++){var I=n.data(J[F]);if(!D[I]){D[I]=true;E.push(J[F])}}}catch(H){E=J}return E},grep:function(E,I,D){var F=[];for(var G=0,H=E.length;G<H;G++){if(!D!=!I(E[G],G)){F.push(E[G])}}return F},map:function(D,I){var E=[];for(var F=0,G=D.length;F<G;F++){var H=I(D[F],F);if(H!=null){E[E.length]=H}}return E.concat.apply([],E)}});var B=navigator.userAgent.toLowerCase();n.browser={version:(B.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1],safari:/webkit/.test(B),opera:/opera/.test(B),msie:/msie/.test(B)&&!/opera/.test(B),mozilla:/mozilla/.test(B)&&!/(compatible|webkit)/.test(B)};n.each({parent:function(D){return D.parentNode},parents:function(D){return n.dir(D,"parentNode")},next:function(D){return n.nth(D,2,"nextSibling")},prev:function(D){return n.nth(D,2,"previousSibling")},nextAll:function(D){return n.dir(D,"nextSibling")},prevAll:function(D){return n.dir(D,"previousSibling")},siblings:function(D){return n.sibling(D.parentNode.firstChild,D)},children:function(D){return n.sibling(D.firstChild)},contents:function(D){return n.nodeName(D,"iframe")?D.contentDocument||D.contentWindow.document:n.makeArray(D.childNodes)}},function(D,E){n.fn[D]=function(F){var G=n.map(this,E);if(F&&typeof F=="string"){G=n.multiFilter(F,G)}return this.pushStack(n.unique(G),D,F)}});n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(D,E){n.fn[D]=function(){var F=arguments;return this.each(function(){for(var G=0,H=F.length;G<H;G++){n(F[G])[E](this)}})}});n.each({removeAttr:function(D){n.attr(this,D,"");if(this.nodeType==1){this.removeAttribute(D)}},addClass:function(D){n.className.add(this,D)},removeClass:function(D){n.className.remove(this,D)},toggleClass:function(E,D){if(typeof D!=="boolean"){D=!n.className.has(this,E)}n.className[D?"add":"remove"](this,E)},remove:function(D){if(!D||n.filter(D,[this]).length){n("*",this).add([this]).each(function(){n.event.remove(this);n.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){n(">*",this).remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(D,E){n.fn[D]=function(){return this.each(E,arguments)}});function j(D,E){return D[0]&&parseInt(n.curCSS(D[0],E,true),10)||0}var h="jQuery"+e(),u=0,z={};n.extend({cache:{},data:function(E,D,F){E=E==l?z:E;var G=E[h];if(!G){G=E[h]=++u}if(D&&!n.cache[G]){n.cache[G]={}}if(F!==g){n.cache[G][D]=F}return D?n.cache[G][D]:G},removeData:function(E,D){E=E==l?z:E;var G=E[h];if(D){if(n.cache[G]){delete n.cache[G][D];D="";for(D in n.cache[G]){break}if(!D){n.removeData(E)}}}else{try{delete E[h]}catch(F){if(E.removeAttribute){E.removeAttribute(h)}}delete n.cache[G]}},queue:function(E,D,G){if(E){D=(D||"fx")+"queue";var F=n.data(E,D);if(!F||n.isArray(G)){F=n.data(E,D,n.makeArray(G))}else{if(G){F.push(G)}}}return F},dequeue:function(G,F){var D=n.queue(G,F),E=D.shift();if(!F||F==="fx"){E=D[0]}if(E!==g){E.call(G)}}});n.fn.extend({data:function(D,F){var G=D.split(".");G[1]=G[1]?"."+G[1]:"";if(F===g){var E=this.triggerHandler("getData"+G[1]+"!",[G[0]]);if(E===g&&this.length){E=n.data(this[0],D)}return E===g&&G[1]?this.data(G[0]):E}else{return this.trigger("setData"+G[1]+"!",[G[0],F]).each(function(){n.data(this,D,F)})}},removeData:function(D){return this.each(function(){n.removeData(this,D)})},queue:function(D,E){if(typeof D!=="string"){E=D;D="fx"}if(E===g){return n.queue(this[0],D)}return this.each(function(){var F=n.queue(this,D,E);if(D=="fx"&&F.length==1){F[0].call(this)}})},dequeue:function(D){return this.each(function(){n.dequeue(this,D)})}});
/*
 * Sizzle CSS Selector Engine - v0.9.1
 * Copyright 2009, The Dojo Foundation
 * Released under the MIT, BSD, and GPL Licenses.
 * More information: http://sizzlejs.com/
 */
(function(){var N=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|[^[\]]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g,I=0,F=Object.prototype.toString;var E=function(ae,S,aa,V){aa=aa||[];S=S||document;if(S.nodeType!==1&&S.nodeType!==9){return[]}if(!ae||typeof ae!=="string"){return aa}var ab=[],ac,Y,ah,ag,Z,R,Q=true;N.lastIndex=0;while((ac=N.exec(ae))!==null){ab.push(ac[1]);if(ac[2]){R=RegExp.rightContext;break}}if(ab.length>1&&G.match.POS.exec(ae)){if(ab.length===2&&G.relative[ab[0]]){var U="",X;while((X=G.match.POS.exec(ae))){U+=X[0];ae=ae.replace(G.match.POS,"")}Y=E.filter(U,E(/\s$/.test(ae)?ae+"*":ae,S))}else{Y=G.relative[ab[0]]?[S]:E(ab.shift(),S);while(ab.length){var P=[];ae=ab.shift();if(G.relative[ae]){ae+=ab.shift()}for(var af=0,ad=Y.length;af<ad;af++){E(ae,Y[af],P)}Y=P}}}else{var ai=V?{expr:ab.pop(),set:D(V)}:E.find(ab.pop(),ab.length===1&&S.parentNode?S.parentNode:S);Y=E.filter(ai.expr,ai.set);if(ab.length>0){ah=D(Y)}else{Q=false}while(ab.length){var T=ab.pop(),W=T;if(!G.relative[T]){T=""}else{W=ab.pop()}if(W==null){W=S}G.relative[T](ah,W,M(S))}}if(!ah){ah=Y}if(!ah){throw"Syntax error, unrecognized expression: "+(T||ae)}if(F.call(ah)==="[object Array]"){if(!Q){aa.push.apply(aa,ah)}else{if(S.nodeType===1){for(var af=0;ah[af]!=null;af++){if(ah[af]&&(ah[af]===true||ah[af].nodeType===1&&H(S,ah[af]))){aa.push(Y[af])}}}else{for(var af=0;ah[af]!=null;af++){if(ah[af]&&ah[af].nodeType===1){aa.push(Y[af])}}}}}else{D(ah,aa)}if(R){E(R,S,aa,V)}return aa};E.matches=function(P,Q){return E(P,null,null,Q)};E.find=function(V,S){var W,Q;if(!V){return[]}for(var R=0,P=G.order.length;R<P;R++){var T=G.order[R],Q;if((Q=G.match[T].exec(V))){var U=RegExp.leftContext;if(U.substr(U.length-1)!=="\\"){Q[1]=(Q[1]||"").replace(/\\/g,"");W=G.find[T](Q,S);if(W!=null){V=V.replace(G.match[T],"");break}}}}if(!W){W=S.getElementsByTagName("*")}return{set:W,expr:V}};E.filter=function(S,ac,ad,T){var Q=S,Y=[],ah=ac,V,ab;while(S&&ac.length){for(var U in G.filter){if((V=G.match[U].exec(S))!=null){var Z=G.filter[U],R=null,X=0,aa,ag;ab=false;if(ah==Y){Y=[]}if(G.preFilter[U]){V=G.preFilter[U](V,ah,ad,Y,T);if(!V){ab=aa=true}else{if(V===true){continue}else{if(V[0]===true){R=[];var W=null,af;for(var ae=0;(af=ah[ae])!==g;ae++){if(af&&W!==af){R.push(af);W=af}}}}}}if(V){for(var ae=0;(ag=ah[ae])!==g;ae++){if(ag){if(R&&ag!=R[X]){X++}aa=Z(ag,V,X,R);var P=T^!!aa;if(ad&&aa!=null){if(P){ab=true}else{ah[ae]=false}}else{if(P){Y.push(ag);ab=true}}}}}if(aa!==g){if(!ad){ah=Y}S=S.replace(G.match[U],"");if(!ab){return[]}break}}}S=S.replace(/\s*,\s*/,"");if(S==Q){if(ab==null){throw"Syntax error, unrecognized expression: "+S}else{break}}Q=S}return ah};var G=E.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(P){return P.getAttribute("href")}},relative:{"+":function(T,Q){for(var R=0,P=T.length;R<P;R++){var S=T[R];if(S){var U=S.previousSibling;while(U&&U.nodeType!==1){U=U.previousSibling}T[R]=typeof Q==="string"?U||false:U===Q}}if(typeof Q==="string"){E.filter(Q,T,true)}},">":function(U,Q,V){if(typeof Q==="string"&&!/\W/.test(Q)){Q=V?Q:Q.toUpperCase();for(var R=0,P=U.length;R<P;R++){var T=U[R];if(T){var S=T.parentNode;U[R]=S.nodeName===Q?S:false}}}else{for(var R=0,P=U.length;R<P;R++){var T=U[R];if(T){U[R]=typeof Q==="string"?T.parentNode:T.parentNode===Q}}if(typeof Q==="string"){E.filter(Q,U,true)}}},"":function(S,Q,U){var R="done"+(I++),P=O;if(!Q.match(/\W/)){var T=Q=U?Q:Q.toUpperCase();P=L}P("parentNode",Q,R,S,T,U)},"~":function(S,Q,U){var R="done"+(I++),P=O;if(typeof Q==="string"&&!Q.match(/\W/)){var T=Q=U?Q:Q.toUpperCase();P=L}P("previousSibling",Q,R,S,T,U)}},find:{ID:function(Q,R){if(R.getElementById){var P=R.getElementById(Q[1]);return P?[P]:[]}},NAME:function(P,Q){return Q.getElementsByName?Q.getElementsByName(P[1]):null},TAG:function(P,Q){return Q.getElementsByTagName(P[1])}},preFilter:{CLASS:function(S,Q,R,P,U){S=" "+S[1].replace(/\\/g,"")+" ";for(var T=0;Q[T];T++){if(U^(" "+Q[T].className+" ").indexOf(S)>=0){if(!R){P.push(Q[T])}}else{if(R){Q[T]=false}}}return false},ID:function(P){return P[1].replace(/\\/g,"")},TAG:function(Q,P){for(var R=0;!P[R];R++){}return M(P[R])?Q[1]:Q[1].toUpperCase()},CHILD:function(P){if(P[1]=="nth"){var Q=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(P[2]=="even"&&"2n"||P[2]=="odd"&&"2n+1"||!/\D/.test(P[2])&&"0n+"+P[2]||P[2]);P[2]=(Q[1]+(Q[2]||1))-0;P[3]=Q[3]-0}P[0]="done"+(I++);return P},ATTR:function(Q){var P=Q[1];if(G.attrMap[P]){Q[1]=G.attrMap[P]}if(Q[2]==="~="){Q[4]=" "+Q[4]+" "}return Q},PSEUDO:function(T,Q,R,P,U){if(T[1]==="not"){if(T[3].match(N).length>1){T[3]=E(T[3],null,null,Q)}else{var S=E.filter(T[3],Q,R,true^U);if(!R){P.push.apply(P,S)}return false}}else{if(G.match.POS.test(T[0])){return true}}return T},POS:function(P){P.unshift(true);return P}},filters:{enabled:function(P){return P.disabled===false&&P.type!=="hidden"},disabled:function(P){return P.disabled===true},checked:function(P){return P.checked===true},selected:function(P){P.parentNode.selectedIndex;return P.selected===true},parent:function(P){return !!P.firstChild},empty:function(P){return !P.firstChild},has:function(R,Q,P){return !!E(P[3],R).length},header:function(P){return/h\d/i.test(P.nodeName)},text:function(P){return"text"===P.type},radio:function(P){return"radio"===P.type},checkbox:function(P){return"checkbox"===P.type},file:function(P){return"file"===P.type},password:function(P){return"password"===P.type},submit:function(P){return"submit"===P.type},image:function(P){return"image"===P.type},reset:function(P){return"reset"===P.type},button:function(P){return"button"===P.type||P.nodeName.toUpperCase()==="BUTTON"},input:function(P){return/input|select|textarea|button/i.test(P.nodeName)}},setFilters:{first:function(Q,P){return P===0},last:function(R,Q,P,S){return Q===S.length-1},even:function(Q,P){return P%2===0},odd:function(Q,P){return P%2===1},lt:function(R,Q,P){return Q<P[3]-0},gt:function(R,Q,P){return Q>P[3]-0},nth:function(R,Q,P){return P[3]-0==Q},eq:function(R,Q,P){return P[3]-0==Q}},filter:{CHILD:function(P,S){var V=S[1],W=P.parentNode;var U="child"+W.childNodes.length;if(W&&(!W[U]||!P.nodeIndex)){var T=1;for(var Q=W.firstChild;Q;Q=Q.nextSibling){if(Q.nodeType==1){Q.nodeIndex=T++}}W[U]=T-1}if(V=="first"){return P.nodeIndex==1}else{if(V=="last"){return P.nodeIndex==W[U]}else{if(V=="only"){return W[U]==1}else{if(V=="nth"){var Y=false,R=S[2],X=S[3];if(R==1&&X==0){return true}if(R==0){if(P.nodeIndex==X){Y=true}}else{if((P.nodeIndex-X)%R==0&&(P.nodeIndex-X)/R>=0){Y=true}}return Y}}}}},PSEUDO:function(V,R,S,W){var Q=R[1],T=G.filters[Q];if(T){return T(V,S,R,W)}else{if(Q==="contains"){return(V.textContent||V.innerText||"").indexOf(R[3])>=0}else{if(Q==="not"){var U=R[3];for(var S=0,P=U.length;S<P;S++){if(U[S]===V){return false}}return true}}}},ID:function(Q,P){return Q.nodeType===1&&Q.getAttribute("id")===P},TAG:function(Q,P){return(P==="*"&&Q.nodeType===1)||Q.nodeName===P},CLASS:function(Q,P){return P.test(Q.className)},ATTR:function(T,R){var P=G.attrHandle[R[1]]?G.attrHandle[R[1]](T):T[R[1]]||T.getAttribute(R[1]),U=P+"",S=R[2],Q=R[4];return P==null?false:S==="="?U===Q:S==="*="?U.indexOf(Q)>=0:S==="~="?(" "+U+" ").indexOf(Q)>=0:!R[4]?P:S==="!="?U!=Q:S==="^="?U.indexOf(Q)===0:S==="$="?U.substr(U.length-Q.length)===Q:S==="|="?U===Q||U.substr(0,Q.length+1)===Q+"-":false},POS:function(T,Q,R,U){var P=Q[2],S=G.setFilters[P];if(S){return S(T,R,Q,U)}}}};for(var K in G.match){G.match[K]=RegExp(G.match[K].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var D=function(Q,P){Q=Array.prototype.slice.call(Q);if(P){P.push.apply(P,Q);return P}return Q};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(J){D=function(T,S){var Q=S||[];if(F.call(T)==="[object Array]"){Array.prototype.push.apply(Q,T)}else{if(typeof T.length==="number"){for(var R=0,P=T.length;R<P;R++){Q.push(T[R])}}else{for(var R=0;T[R];R++){Q.push(T[R])}}}return Q}}(function(){var Q=document.createElement("form"),R="script"+(new Date).getTime();Q.innerHTML="<input name='"+R+"'/>";var P=document.documentElement;P.insertBefore(Q,P.firstChild);if(!!document.getElementById(R)){G.find.ID=function(T,U){if(U.getElementById){var S=U.getElementById(T[1]);return S?S.id===T[1]||S.getAttributeNode&&S.getAttributeNode("id").nodeValue===T[1]?[S]:g:[]}};G.filter.ID=function(U,S){var T=U.getAttributeNode&&U.getAttributeNode("id");return U.nodeType===1&&T&&T.nodeValue===S}}P.removeChild(Q)})();(function(){var P=document.createElement("div");P.appendChild(document.createComment(""));if(P.getElementsByTagName("*").length>0){G.find.TAG=function(Q,U){var T=U.getElementsByTagName(Q[1]);if(Q[1]==="*"){var S=[];for(var R=0;T[R];R++){if(T[R].nodeType===1){S.push(T[R])}}T=S}return T}}P.innerHTML="<a href='#'></a>";if(P.firstChild.getAttribute("href")!=="#"){G.attrHandle.href=function(Q){return Q.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var P=E;E=function(T,S,Q,R){S=S||document;if(!R&&S.nodeType===9){try{return D(S.querySelectorAll(T),Q)}catch(U){}}return P(T,S,Q,R)};E.find=P.find;E.filter=P.filter;E.selectors=P.selectors;E.matches=P.matches})()}if(document.documentElement.getElementsByClassName){G.order.splice(1,0,"CLASS");G.find.CLASS=function(P,Q){return Q.getElementsByClassName(P[1])}}function L(Q,W,V,Z,X,Y){for(var T=0,R=Z.length;T<R;T++){var P=Z[T];if(P){P=P[Q];var U=false;while(P&&P.nodeType){var S=P[V];if(S){U=Z[S];break}if(P.nodeType===1&&!Y){P[V]=T}if(P.nodeName===W){U=P;break}P=P[Q]}Z[T]=U}}}function O(Q,V,U,Y,W,X){for(var S=0,R=Y.length;S<R;S++){var P=Y[S];if(P){P=P[Q];var T=false;while(P&&P.nodeType){if(P[U]){T=Y[P[U]];break}if(P.nodeType===1){if(!X){P[U]=S}if(typeof V!=="string"){if(P===V){T=true;break}}else{if(E.filter(V,[P]).length>0){T=P;break}}}P=P[Q]}Y[S]=T}}}var H=document.compareDocumentPosition?function(Q,P){return Q.compareDocumentPosition(P)&16}:function(Q,P){return Q!==P&&(Q.contains?Q.contains(P):true)};var M=function(P){return P.documentElement&&!P.body||P.tagName&&P.ownerDocument&&!P.ownerDocument.body};n.find=E;n.filter=E.filter;n.expr=E.selectors;n.expr[":"]=n.expr.filters;E.selectors.filters.hidden=function(P){return"hidden"===P.type||n.css(P,"display")==="none"||n.css(P,"visibility")==="hidden"};E.selectors.filters.visible=function(P){return"hidden"!==P.type&&n.css(P,"display")!=="none"&&n.css(P,"visibility")!=="hidden"};E.selectors.filters.animated=function(P){return n.grep(n.timers,function(Q){return P===Q.elem}).length};n.multiFilter=function(R,P,Q){if(Q){R=":not("+R+")"}return E.matches(R,P)};n.dir=function(R,Q){var P=[],S=R[Q];while(S&&S!=document){if(S.nodeType==1){P.push(S)}S=S[Q]}return P};n.nth=function(T,P,R,S){P=P||1;var Q=0;for(;T;T=T[R]){if(T.nodeType==1&&++Q==P){break}}return T};n.sibling=function(R,Q){var P=[];for(;R;R=R.nextSibling){if(R.nodeType==1&&R!=Q){P.push(R)}}return P};return;l.Sizzle=E})();n.event={add:function(H,E,G,J){if(H.nodeType==3||H.nodeType==8){return}if(H.setInterval&&H!=l){H=l}if(!G.guid){G.guid=this.guid++}if(J!==g){var F=G;G=this.proxy(F);G.data=J}var D=n.data(H,"events")||n.data(H,"events",{}),I=n.data(H,"handle")||n.data(H,"handle",function(){return typeof n!=="undefined"&&!n.event.triggered?n.event.handle.apply(arguments.callee.elem,arguments):g});I.elem=H;n.each(E.split(/\s+/),function(L,M){var N=M.split(".");M=N.shift();G.type=N.slice().sort().join(".");var K=D[M];if(n.event.specialAll[M]){n.event.specialAll[M].setup.call(H,J,N)}if(!K){K=D[M]={};if(!n.event.special[M]||n.event.special[M].setup.call(H,J,N)===false){if(H.addEventListener){H.addEventListener(M,I,false)}else{if(H.attachEvent){H.attachEvent("on"+M,I)}}}}K[G.guid]=G;n.event.global[M]=true});H=null},guid:1,global:{},remove:function(J,G,I){if(J.nodeType==3||J.nodeType==8){return}var F=n.data(J,"events"),E,D;if(F){if(G===g||(typeof G==="string"&&G.charAt(0)==".")){for(var H in F){this.remove(J,H+(G||""))}}else{if(G.type){I=G.handler;G=G.type}n.each(G.split(/\s+/),function(L,N){var P=N.split(".");N=P.shift();var M=RegExp("(^|\\.)"+P.slice().sort().join(".*\\.")+"(\\.|$)");if(F[N]){if(I){delete F[N][I.guid]}else{for(var O in F[N]){if(M.test(F[N][O].type)){delete F[N][O]}}}if(n.event.specialAll[N]){n.event.specialAll[N].teardown.call(J,P)}for(E in F[N]){break}if(!E){if(!n.event.special[N]||n.event.special[N].teardown.call(J,P)===false){if(J.removeEventListener){J.removeEventListener(N,n.data(J,"handle"),false)}else{if(J.detachEvent){J.detachEvent("on"+N,n.data(J,"handle"))}}}E=null;delete F[N]}}})}for(E in F){break}if(!E){var K=n.data(J,"handle");if(K){K.elem=null}n.removeData(J,"events");n.removeData(J,"handle")}}},trigger:function(H,J,G,D){var F=H.type||H;if(!D){H=typeof H==="object"?H[h]?H:n.extend(n.Event(F),H):n.Event(F);if(F.indexOf("!")>=0){H.type=F=F.slice(0,-1);H.exclusive=true}if(!G){H.stopPropagation();if(this.global[F]){n.each(n.cache,function(){if(this.events&&this.events[F]){n.event.trigger(H,J,this.handle.elem)}})}}if(!G||G.nodeType==3||G.nodeType==8){return g}H.result=g;H.target=G;J=n.makeArray(J);J.unshift(H)}H.currentTarget=G;var I=n.data(G,"handle");if(I){I.apply(G,J)}if((!G[F]||(n.nodeName(G,"a")&&F=="click"))&&G["on"+F]&&G["on"+F].apply(G,J)===false){H.result=false}if(!D&&G[F]&&!H.isDefaultPrevented()&&!(n.nodeName(G,"a")&&F=="click")){this.triggered=true;try{G[F]()}catch(K){}}this.triggered=false;if(!H.isPropagationStopped()){var E=G.parentNode||G.ownerDocument;if(E){n.event.trigger(H,J,E,true)}}},handle:function(J){var I,D;J=arguments[0]=n.event.fix(J||l.event);var K=J.type.split(".");J.type=K.shift();I=!K.length&&!J.exclusive;var H=RegExp("(^|\\.)"+K.slice().sort().join(".*\\.")+"(\\.|$)");D=(n.data(this,"events")||{})[J.type];for(var F in D){var G=D[F];if(I||H.test(G.type)){J.handler=G;J.data=G.data;var E=G.apply(this,arguments);if(E!==g){J.result=E;if(E===false){J.preventDefault();J.stopPropagation()}}if(J.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(G){if(G[h]){return G}var E=G;G=n.Event(E);for(var F=this.props.length,I;F;){I=this.props[--F];G[I]=E[I]}if(!G.target){G.target=G.srcElement||document}if(G.target.nodeType==3){G.target=G.target.parentNode}if(!G.relatedTarget&&G.fromElement){G.relatedTarget=G.fromElement==G.target?G.toElement:G.fromElement}if(G.pageX==null&&G.clientX!=null){var H=document.documentElement,D=document.body;G.pageX=G.clientX+(H&&H.scrollLeft||D&&D.scrollLeft||0)-(H.clientLeft||0);G.pageY=G.clientY+(H&&H.scrollTop||D&&D.scrollTop||0)-(H.clientTop||0)}if(!G.which&&((G.charCode||G.charCode===0)?G.charCode:G.keyCode)){G.which=G.charCode||G.keyCode}if(!G.metaKey&&G.ctrlKey){G.metaKey=G.ctrlKey}if(!G.which&&G.button){G.which=(G.button&1?1:(G.button&2?3:(G.button&4?2:0)))}return G},proxy:function(E,D){D=D||function(){return E.apply(this,arguments)};D.guid=E.guid=E.guid||D.guid||this.guid++;return D},special:{ready:{setup:A,teardown:function(){}}},specialAll:{live:{setup:function(D,E){n.event.add(this,E[0],c)},teardown:function(F){if(F.length){var D=0,E=RegExp("(^|\\.)"+F[0]+"(\\.|$)");n.each((n.data(this,"events").live||{}),function(){if(E.test(this.type)){D++}});if(D<1){n.event.remove(this,F[0],c)}}}}}};n.Event=function(D){if(!this.preventDefault){return new n.Event(D)}if(D&&D.type){this.originalEvent=D;this.type=D.type;this.timeStamp=D.timeStamp}else{this.type=D}if(!this.timeStamp){this.timeStamp=e()}this[h]=true};function k(){return false}function t(){return true}n.Event.prototype={preventDefault:function(){this.isDefaultPrevented=t;var D=this.originalEvent;if(!D){return}if(D.preventDefault){D.preventDefault()}D.returnValue=false},stopPropagation:function(){this.isPropagationStopped=t;var D=this.originalEvent;if(!D){return}if(D.stopPropagation){D.stopPropagation()}D.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=t;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(E){var D=E.relatedTarget;while(D&&D!=this){try{D=D.parentNode}catch(F){D=this}}if(D!=this){E.type=E.data;n.event.handle.apply(this,arguments)}};n.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(E,D){n.event.special[D]={setup:function(){n.event.add(this,E,a,D)},teardown:function(){n.event.remove(this,E,a)}}});n.fn.extend({bind:function(E,F,D){return E=="unload"?this.one(E,F,D):this.each(function(){n.event.add(this,E,D||F,D&&F)})},one:function(F,G,E){var D=n.event.proxy(E||G,function(H){n(this).unbind(H,D);return(E||G).apply(this,arguments)});return this.each(function(){n.event.add(this,F,D,E&&G)})},unbind:function(E,D){return this.each(function(){n.event.remove(this,E,D)})},trigger:function(D,E){return this.each(function(){n.event.trigger(D,E,this)})},triggerHandler:function(D,F){if(this[0]){var E=n.Event(D);E.preventDefault();E.stopPropagation();n.event.trigger(E,F,this[0]);return E.result}},toggle:function(F){var D=arguments,E=1;while(E<D.length){n.event.proxy(F,D[E++])}return this.click(n.event.proxy(F,function(G){this.lastToggle=(this.lastToggle||0)%E;G.preventDefault();return D[this.lastToggle++].apply(this,arguments)||false}))},hover:function(D,E){return this.mouseenter(D).mouseleave(E)},ready:function(D){A();if(n.isReady){D.call(document,n)}else{n.readyList.push(D)}return this},live:function(F,E){var D=n.event.proxy(E);D.guid+=this.selector+F;n(document).bind(i(F,this.selector),this.selector,D);return this},die:function(E,D){n(document).unbind(i(E,this.selector),D?{guid:D.guid+this.selector+E}:null);return this}});function c(G){var D=RegExp("(^|\\.)"+G.type+"(\\.|$)"),F=true,E=[];n.each(n.data(this,"events").live||[],function(H,I){if(D.test(I.type)){var J=n(G.target).closest(I.data)[0];if(J){E.push({elem:J,fn:I})}}});n.each(E,function(){if(!G.isImmediatePropagationStopped()&&this.fn.call(this.elem,G,this.fn.data)===false){F=false}});return F}function i(E,D){return["live",E,D.replace(/\./g,"`").replace(/ /g,"|")].join(".")}n.extend({isReady:false,readyList:[],ready:function(){if(!n.isReady){n.isReady=true;if(n.readyList){n.each(n.readyList,function(){this.call(document,n)});n.readyList=null}n(document).triggerHandler("ready")}}});var w=false;function A(){if(w){return}w=true;if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);n.ready()},false)}else{if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);n.ready()}});if(document.documentElement.doScroll&&!l.frameElement){(function(){if(n.isReady){return}try{document.documentElement.doScroll("left")}catch(D){setTimeout(arguments.callee,0);return}n.ready()})()}}}n.event.add(l,"load",n.ready)}n.each(("blur,focus,load,resize,scroll,unload,click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave,change,select,submit,keydown,keypress,keyup,error").split(","),function(E,D){n.fn[D]=function(F){return F?this.bind(D,F):this.trigger(D)}});n(l).bind("unload",function(){for(var D in n.cache){if(D!=1&&n.cache[D].handle){n.event.remove(n.cache[D].handle.elem)}}});(function(){n.support={};var E=document.documentElement,F=document.createElement("script"),J=document.createElement("div"),I="script"+(new Date).getTime();J.style.display="none";J.innerHTML=' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>';var G=J.getElementsByTagName("*"),D=J.getElementsByTagName("a")[0];if(!G||!G.length||!D){return}n.support={leadingWhitespace:J.firstChild.nodeType==3,tbody:!J.getElementsByTagName("tbody").length,objectAll:!!J.getElementsByTagName("object")[0].getElementsByTagName("*").length,htmlSerialize:!!J.getElementsByTagName("link").length,style:/red/.test(D.getAttribute("style")),hrefNormalized:D.getAttribute("href")==="/a",opacity:D.style.opacity==="0.5",cssFloat:!!D.style.cssFloat,scriptEval:false,noCloneEvent:true,boxModel:null};F.type="text/javascript";try{F.appendChild(document.createTextNode("window."+I+"=1;"))}catch(H){}E.insertBefore(F,E.firstChild);if(l[I]){n.support.scriptEval=true;delete l[I]}E.removeChild(F);if(J.attachEvent&&J.fireEvent){J.attachEvent("onclick",function(){n.support.noCloneEvent=false;J.detachEvent("onclick",arguments.callee)});J.cloneNode(true).fireEvent("onclick")}n(function(){var K=document.createElement("div");K.style.width="1px";K.style.paddingLeft="1px";document.body.appendChild(K);n.boxModel=n.support.boxModel=K.offsetWidth===2;document.body.removeChild(K)})})();var v=n.support.cssFloat?"cssFloat":"styleFloat";n.props={"for":"htmlFor","class":"className","float":v,cssFloat:v,styleFloat:v,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",tabindex:"tabIndex"};n.fn.extend({_load:n.fn.load,load:function(F,I,J){if(typeof F!=="string"){return this._load(F)}var H=F.indexOf(" ");if(H>=0){var D=F.slice(H,F.length);F=F.slice(0,H)}var G="GET";if(I){if(n.isFunction(I)){J=I;I=null}else{if(typeof I==="object"){I=n.param(I);G="POST"}}}var E=this;n.ajax({url:F,type:G,dataType:"html",data:I,complete:function(L,K){if(K=="success"||K=="notmodified"){E.html(D?n("<div/>").append(L.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(D):L.responseText)}if(J){E.each(J,[L.responseText,K,L])}}});return this},serialize:function(){return n.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?n.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type))}).map(function(D,E){var F=n(this).val();return F==null?null:n.isArray(F)?n.map(F,function(H,G){return{name:E.name,value:H}}):{name:E.name,value:F}}).get()}});n.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(D,E){n.fn[E]=function(F){return this.bind(E,F)}});var q=e();n.extend({get:function(D,F,G,E){if(n.isFunction(F)){G=F;F=null}return n.ajax({type:"GET",url:D,data:F,success:G,dataType:E})},getScript:function(D,E){return n.get(D,null,E,"script")},getJSON:function(D,E,F){return n.get(D,E,F,"json")},post:function(D,F,G,E){if(n.isFunction(F)){G=F;F={}}return n.ajax({type:"POST",url:D,data:F,success:G,dataType:E})},ajaxSetup:function(D){n.extend(n.ajaxSettings,D)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return l.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(L){L=n.extend(true,L,n.extend(true,{},n.ajaxSettings,L));var V,E=/=\?(&|$)/g,Q,U,F=L.type.toUpperCase();if(L.data&&L.processData&&typeof L.data!=="string"){L.data=n.param(L.data)}if(L.dataType=="jsonp"){if(F=="GET"){if(!L.url.match(E)){L.url+=(L.url.match(/\?/)?"&":"?")+(L.jsonp||"callback")+"=?"}}else{if(!L.data||!L.data.match(E)){L.data=(L.data?L.data+"&":"")+(L.jsonp||"callback")+"=?"}}L.dataType="json"}if(L.dataType=="json"&&(L.data&&L.data.match(E)||L.url.match(E))){V="jsonp"+q++;if(L.data){L.data=(L.data+"").replace(E,"="+V+"$1")}L.url=L.url.replace(E,"="+V+"$1");L.dataType="script";l[V]=function(W){U=W;H();K();l[V]=g;try{delete l[V]}catch(X){}if(G){G.removeChild(S)}}}if(L.dataType=="script"&&L.cache==null){L.cache=false}if(L.cache===false&&F=="GET"){var D=e();var T=L.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+D+"$2");L.url=T+((T==L.url)?(L.url.match(/\?/)?"&":"?")+"_="+D:"")}if(L.data&&F=="GET"){L.url+=(L.url.match(/\?/)?"&":"?")+L.data;L.data=null}if(L.global&&!n.active++){n.event.trigger("ajaxStart")}var P=/^(\w+:)?\/\/([^\/?#]+)/.exec(L.url);if(L.dataType=="script"&&F=="GET"&&P&&(P[1]&&P[1]!=location.protocol||P[2]!=location.host)){var G=document.getElementsByTagName("head")[0];var S=document.createElement("script");S.src=L.url;if(L.scriptCharset){S.charset=L.scriptCharset}if(!V){var N=false;S.onload=S.onreadystatechange=function(){if(!N&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){N=true;H();K();G.removeChild(S)}}}G.appendChild(S);return g}var J=false;var I=L.xhr();if(L.username){I.open(F,L.url,L.async,L.username,L.password)}else{I.open(F,L.url,L.async)}try{if(L.data){I.setRequestHeader("Content-Type",L.contentType)}if(L.ifModified){I.setRequestHeader("If-Modified-Since",n.lastModified[L.url]||"Thu, 01 Jan 1970 00:00:00 GMT")}I.setRequestHeader("X-Requested-With","XMLHttpRequest");I.setRequestHeader("Accept",L.dataType&&L.accepts[L.dataType]?L.accepts[L.dataType]+", */*":L.accepts._default)}catch(R){}if(L.beforeSend&&L.beforeSend(I,L)===false){if(L.global&&!--n.active){n.event.trigger("ajaxStop")}I.abort();return false}if(L.global){n.event.trigger("ajaxSend",[I,L])}var M=function(W){if(I.readyState==0){if(O){clearInterval(O);O=null;if(L.global&&!--n.active){n.event.trigger("ajaxStop")}}}else{if(!J&&I&&(I.readyState==4||W=="timeout")){J=true;if(O){clearInterval(O);O=null}Q=W=="timeout"?"timeout":!n.httpSuccess(I)?"error":L.ifModified&&n.httpNotModified(I,L.url)?"notmodified":"success";if(Q=="success"){try{U=n.httpData(I,L.dataType,L)}catch(Y){Q="parsererror"}}if(Q=="success"){var X;try{X=I.getResponseHeader("Last-Modified")}catch(Y){}if(L.ifModified&&X){n.lastModified[L.url]=X}if(!V){H()}}else{n.handleError(L,I,Q)}K();if(L.async){I=null}}}};if(L.async){var O=setInterval(M,13);if(L.timeout>0){setTimeout(function(){if(I){if(!J){M("timeout")}if(I){I.abort()}}},L.timeout)}}try{I.send(L.data)}catch(R){n.handleError(L,I,null,R)}if(!L.async){M()}function H(){if(L.success){L.success(U,Q)}if(L.global){n.event.trigger("ajaxSuccess",[I,L])}}function K(){if(L.complete){L.complete(I,Q)}if(L.global){n.event.trigger("ajaxComplete",[I,L])}if(L.global&&!--n.active){n.event.trigger("ajaxStop")}}return I},handleError:function(E,G,D,F){if(E.error){E.error(G,D,F)}if(E.global){n.event.trigger("ajaxError",[G,E,F])}},active:0,httpSuccess:function(E){try{return !E.status&&location.protocol=="file:"||(E.status>=200&&E.status<300)||E.status==304||E.status==1223}catch(D){}return false},httpNotModified:function(F,D){try{var G=F.getResponseHeader("Last-Modified");return F.status==304||G==n.lastModified[D]}catch(E){}return false},httpData:function(I,G,F){var E=I.getResponseHeader("content-type"),D=G=="xml"||!G&&E&&E.indexOf("xml")>=0,H=D?I.responseXML:I.responseText;if(D&&H.documentElement.tagName=="parsererror"){throw"parsererror"}if(F&&F.dataFilter){H=F.dataFilter(H,G)}if(typeof H==="string"){if(G=="script"){n.globalEval(H)}if(G=="json"){H=l["eval"]("("+H+")")}}return H},param:function(D){var F=[];function G(H,I){F[F.length]=encodeURIComponent(H)+"="+encodeURIComponent(I)}if(n.isArray(D)||D.jquery){n.each(D,function(){G(this.name,this.value)})}else{for(var E in D){if(n.isArray(D[E])){n.each(D[E],function(){G(E,this)})}else{G(E,n.isFunction(D[E])?D[E]():D[E])}}}return F.join("&").replace(/%20/g,"+")}});var m={},d=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function s(E,D){var F={};n.each(d.concat.apply([],d.slice(0,D)),function(){F[this]=E});return F}n.fn.extend({show:function(I,K){if(I){return this.animate(s("show",3),I,K)}else{for(var G=0,E=this.length;G<E;G++){var D=n.data(this[G],"olddisplay");this[G].style.display=D||"";if(n.css(this[G],"display")==="none"){var F=this[G].tagName,J;if(m[F]){J=m[F]}else{var H=n("<"+F+" />").appendTo("body");J=H.css("display");if(J==="none"){J="block"}H.remove();m[F]=J}this[G].style.display=n.data(this[G],"olddisplay",J)}}return this}},hide:function(G,H){if(G){return this.animate(s("hide",3),G,H)}else{for(var F=0,E=this.length;F<E;F++){var D=n.data(this[F],"olddisplay");if(!D&&D!=="none"){n.data(this[F],"olddisplay",n.css(this[F],"display"))}this[F].style.display="none"}return this}},_toggle:n.fn.toggle,toggle:function(F,E){var D=typeof F==="boolean";return n.isFunction(F)&&n.isFunction(E)?this._toggle.apply(this,arguments):F==null||D?this.each(function(){var G=D?F:n(this).is(":hidden");n(this)[G?"show":"hide"]()}):this.animate(s("toggle",3),F,E)},fadeTo:function(D,F,E){return this.animate({opacity:F},D,E)},animate:function(H,E,G,F){var D=n.speed(E,G,F);return this[D.queue===false?"each":"queue"](function(){var J=n.extend({},D),L,K=this.nodeType==1&&n(this).is(":hidden"),I=this;for(L in H){if(H[L]=="hide"&&K||H[L]=="show"&&!K){return J.complete.call(this)}if((L=="height"||L=="width")&&this.style){J.display=n.css(this,"display");J.overflow=this.style.overflow}}if(J.overflow!=null){this.style.overflow="hidden"}J.curAnim=n.extend({},H);n.each(H,function(N,R){var Q=new n.fx(I,J,N);if(/toggle|show|hide/.test(R)){Q[R=="toggle"?K?"show":"hide":R](H)}else{var P=R.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),S=Q.cur(true)||0;if(P){var M=parseFloat(P[2]),O=P[3]||"px";if(O!="px"){I.style[N]=(M||1)+O;S=((M||1)/Q.cur(true))*S;I.style[N]=S+O}if(P[1]){M=((P[1]=="-="?-1:1)*M)+S}Q.custom(S,M,O)}else{Q.custom(S,R,"")}}});return true})},stop:function(E,D){var F=n.timers;if(E){this.queue([])}this.each(function(){for(var G=F.length-1;G>=0;G--){if(F[G].elem==this){if(D){F[G](true)}F.splice(G,1)}}});if(!D){this.dequeue()}return this}});n.each({slideDown:s("show",1),slideUp:s("hide",1),slideToggle:s("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(D,E){n.fn[D]=function(F,G){return this.animate(E,F,G)}});n.extend({speed:function(F,G,E){var D=typeof F==="object"?F:{complete:E||!E&&G||n.isFunction(F)&&F,duration:F,easing:E&&G||G&&!n.isFunction(G)&&G};D.duration=n.fx.off?0:typeof D.duration==="number"?D.duration:n.fx.speeds[D.duration]||n.fx.speeds._default;D.old=D.complete;D.complete=function(){if(D.queue!==false){n(this).dequeue()}if(n.isFunction(D.old)){D.old.call(this)}};return D},easing:{linear:function(F,G,D,E){return D+E*F},swing:function(F,G,D,E){return((-Math.cos(F*Math.PI)/2)+0.5)*E+D}},timers:[],timerId:null,fx:function(E,D,F){this.options=D;this.elem=E;this.prop=F;if(!D.orig){D.orig={}}}});n.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(n.fx.step[this.prop]||n.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(E){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var D=parseFloat(n.css(this.elem,this.prop,E));return D&&D>-10000?D:parseFloat(n.curCSS(this.elem,this.prop))||0},custom:function(H,G,F){this.startTime=e();this.start=H;this.end=G;this.unit=F||this.unit||"px";this.now=this.start;this.pos=this.state=0;var D=this;function E(I){return D.step(I)}E.elem=this.elem;n.timers.push(E);if(E()&&n.timerId==null){n.timerId=setInterval(function(){var J=n.timers;for(var I=0;I<J.length;I++){if(!J[I]()){J.splice(I--,1)}}if(!J.length){clearInterval(n.timerId);n.timerId=null}},13)}},show:function(){this.options.orig[this.prop]=n.attr(this.elem.style,this.prop);this.options.show=true;this.custom(this.prop=="width"||this.prop=="height"?1:0,this.cur());n(this.elem).show()},hide:function(){this.options.orig[this.prop]=n.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(G){var F=e();if(G||F>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var D=true;for(var E in this.options.curAnim){if(this.options.curAnim[E]!==true){D=false}}if(D){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(n.css(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide){n(this.elem).hide()}if(this.options.hide||this.options.show){for(var H in this.options.curAnim){n.attr(this.elem.style,H,this.options.orig[H])}}}if(D){this.options.complete.call(this.elem)}return false}else{var I=F-this.startTime;this.state=I/this.options.duration;this.pos=n.easing[this.options.easing||(n.easing.swing?"swing":"linear")](this.state,I,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};n.extend(n.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(D){n.attr(D.elem.style,"opacity",D.now)},_default:function(D){if(D.elem.style&&D.elem.style[D.prop]!=null){D.elem.style[D.prop]=D.now+D.unit}else{D.elem[D.prop]=D.now}}}});if(document.documentElement.getBoundingClientRect){n.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return n.offset.bodyOffset(this[0])}var F=this[0].getBoundingClientRect(),I=this[0].ownerDocument,E=I.body,D=I.documentElement,K=D.clientTop||E.clientTop||0,J=D.clientLeft||E.clientLeft||0,H=F.top+(self.pageYOffset||n.boxModel&&D.scrollTop||E.scrollTop)-K,G=F.left+(self.pageXOffset||n.boxModel&&D.scrollLeft||E.scrollLeft)-J;return{top:H,left:G}}}else{n.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return n.offset.bodyOffset(this[0])}n.offset.initialized||n.offset.initialize();var I=this[0],F=I.offsetParent,E=I,N=I.ownerDocument,L,G=N.documentElement,J=N.body,K=N.defaultView,D=K.getComputedStyle(I,null),M=I.offsetTop,H=I.offsetLeft;while((I=I.parentNode)&&I!==J&&I!==G){L=K.getComputedStyle(I,null);M-=I.scrollTop,H-=I.scrollLeft;if(I===F){M+=I.offsetTop,H+=I.offsetLeft;if(n.offset.doesNotAddBorder&&!(n.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(I.tagName))){M+=parseInt(L.borderTopWidth,10)||0,H+=parseInt(L.borderLeftWidth,10)||0}E=F,F=I.offsetParent}if(n.offset.subtractsBorderForOverflowNotVisible&&L.overflow!=="visible"){M+=parseInt(L.borderTopWidth,10)||0,H+=parseInt(L.borderLeftWidth,10)||0}D=L}if(D.position==="relative"||D.position==="static"){M+=J.offsetTop,H+=J.offsetLeft}if(D.position==="fixed"){M+=Math.max(G.scrollTop,J.scrollTop),H+=Math.max(G.scrollLeft,J.scrollLeft)}return{top:M,left:H}}}n.offset={initialize:function(){if(this.initialized){return}var K=document.body,E=document.createElement("div"),G,F,M,H,L,D,I=K.style.marginTop,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>';L={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};for(D in L){E.style[D]=L[D]}E.innerHTML=J;K.insertBefore(E,K.firstChild);G=E.firstChild,F=G.firstChild,H=G.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(F.offsetTop!==5);this.doesAddBorderForTableAndCells=(H.offsetTop===5);G.style.overflow="hidden",G.style.position="relative";this.subtractsBorderForOverflowNotVisible=(F.offsetTop===-5);K.style.marginTop="1px";this.doesNotIncludeMarginInBodyOffset=(K.offsetTop===0);K.style.marginTop=I;K.removeChild(E);this.initialized=true},bodyOffset:function(D){n.offset.initialized||n.offset.initialize();var F=D.offsetTop,E=D.offsetLeft;if(n.offset.doesNotIncludeMarginInBodyOffset){F+=parseInt(n.curCSS(D,"marginTop",true),10)||0,E+=parseInt(n.curCSS(D,"marginLeft",true),10)||0}return{top:F,left:E}}};n.fn.extend({position:function(){var H=0,G=0,E;if(this[0]){var F=this.offsetParent(),I=this.offset(),D=/^body|html$/i.test(F[0].tagName)?{top:0,left:0}:F.offset();I.top-=j(this,"marginTop");I.left-=j(this,"marginLeft");D.top+=j(F,"borderTopWidth");D.left+=j(F,"borderLeftWidth");E={top:I.top-D.top,left:I.left-D.left}}return E},offsetParent:function(){var D=this[0].offsetParent||document.body;while(D&&(!/^body|html$/i.test(D.tagName)&&n.css(D,"position")=="static")){D=D.offsetParent}return n(D)}});n.each(["Left","Top"],function(E,D){var F="scroll"+D;n.fn[F]=function(G){if(!this[0]){return null}return G!==g?this.each(function(){this==l||this==document?l.scrollTo(!E?G:n(l).scrollLeft(),E?G:n(l).scrollTop()):this[F]=G}):this[0]==l||this[0]==document?self[E?"pageYOffset":"pageXOffset"]||n.boxModel&&document.documentElement[F]||document.body[F]:this[0][F]}});n.each(["Height","Width"],function(G,E){var D=G?"Left":"Top",F=G?"Right":"Bottom";n.fn["inner"+E]=function(){return this[E.toLowerCase()]()+j(this,"padding"+D)+j(this,"padding"+F)};n.fn["outer"+E]=function(I){return this["inner"+E]()+j(this,"border"+D+"Width")+j(this,"border"+F+"Width")+(I?j(this,"margin"+D)+j(this,"margin"+F):0)};var H=E.toLowerCase();n.fn[H]=function(I){return this[0]==l?document.compatMode=="CSS1Compat"&&document.documentElement["client"+E]||document.body["client"+E]:this[0]==document?Math.max(document.documentElement["client"+E],document.body["scroll"+E],document.documentElement["scroll"+E],document.body["offset"+E],document.documentElement["offset"+E]):I===g?(this.length?n.css(this[0],H):null):this.css(H,typeof I==="string"?I:I+"px")}})})();

$j = jQuery.noConflict();

$j(document).ready(function(){ 

 $j(".breadcrumbs, .cat_filtre h2, .col_plan h2, .b_index h3").ieffembedfix();

 /* roll nav*/ 
 $j(".roll").parent().parent().hover(
 function(){
 $j(this).find(".roll").attr("src", $j(this).find(".roll").attr("src").split('_0').join('_1'))
 },
 function(){
 $j(this).find(".roll").attr("src", $j(this).find(".roll").attr("src").split('_1').join('_0'))
 }
 ); 
 
 $j(".active img").attr('class','');
 $j(".active img").parent().parent().hover(
 function(){
 $j(this).find("img").attr("src", $j(this).find("img").attr("src").split('_0').join('_1'))
 },
 function(){
 $j(this).find("img").attr("src", $j(this).find("img").attr("src").split('_0').join('_1'))
 }
 );
 
 

 // sous menu
 /*
 $j('#nav li').mouseenter(function(){
 if($j(this).children('.sous-menu').length){
 $j('#pusher').html($j(this).children('.sous-menu').html());
 if(!$j('#pusher:animated').length){
 $j('#pusher').slideDown();
 }
 }
 });
 $j('.header-container').mouseleave(function(){
 $j('#pusher').slideUp();
 });
 */
 
 // nouveau sous menu
 $j('.sous-menu').hide();
 $j('.menu_eboutique').hover(
 function(){
 $j(this).find('.sous-menu').show();
 },
 function(){
 $j(this).find('.sous-menu').hide();
 }
 );

/***************** gestion vignettes et zoom fiche produits v2 ***************/
//$j(".product-image-zoom img").css('width','400px');
//$j(".product-image-zoom img").css('height','403px');

/***************** gestion vignettes et zoom fiche produits v2 ***************/

 /* gestion quantite produit */
 $j("img.quantite").click(function(){
 champ = $j(this).parents('.structure_plus_moins').find('input');
 if($j(this).attr("alt")=="moins"){
 if(parseInt(champ.val()) > 0){
 champ.val(parseInt(champ.val()) - 1);
 }
 } else {
 champ.val(parseInt(champ.val()) + 1);
 } 
 });
 
 // effet hover sur la partie points de vente
 $j('.ville_result').hover(
 function(){
 $j(this).css("background", "#f5f5f5");
 },
 function(){
 $j(this).css("background", "#ffffff");
 }
 );
 
 $j('.select_color ol li a').tooltip({
 track: true,
 delay: 0,
 showURL: false,
 showBody: " - ",
 extraClass: "couleur",
 fixPNG: true,
 opacity: 0.8,
 left: 12,
 top: 22
 });
 
 
 /********** FILTRE CATALOGUE **********/
 $j('.select_color ol').wrap('<div id="select_couleur_col"></div>');
 $j('#select_couleur_col').prepend('<div class="faux_select">Choisissez une couleur</div>');
 $j('.select_color ol').append('<li style="clear:both; float:none;"></li>');
 
 $j('.select_color ol').hide();
 $j('.select_color .faux_select').toggle(
 function(){
 $j('.select_color ol').slideDown();
 },
 function(){
 $j('.select_color ol').slideUp();
 }
 );
 
 // affiche le nom de la couleur
 if($j('.select_color .on').length){
 $j('.select_color .faux_select').html('<strong>' + $j('.select_color .on img').attr('alt') + '</strong>');
 }
 // ajoute l'image à côté du nom de la couleur
 $j('.select_color .on img').clone().prependTo('.select_color .faux_select');
 
 
 
 
 $j('.select_taille ol').wrap('<div id="select_taille_col"></div>');
 $j('#select_taille_col').prepend('<div class="faux_select">Choisissez une taille</div>');
 $j('.select_taille ol').append('<li style="clear:both; float:none;"></li>');
 
 $j('.select_taille ol').hide();
 $j('.select_taille .faux_select').toggle(
 function(){
 $j('.select_taille ol').slideDown();
 },
 function(){
 $j('.select_taille ol').slideUp();
 }
 );
 
 // affiche la taille
 if($j('.select_taille .on').length){
 $j('.select_taille .faux_select').html('<strong>' + $j('.select_taille .on').html() + '</strong>');
 }
 
 
 
 $j('.select_categorie ol').wrap('<div id="select_categorie_col"></div>');
 $j('#select_categorie_col').prepend('<div class="faux_select">Choisissez une catégorie</div>');
 $j('.select_categorie ol').append('<li style="clear:both; float:none;"></li>');
 
 $j('.select_categorie ol').hide();
 $j('.select_categorie .faux_select').toggle(
 function(){
 $j('.select_categorie ol').slideDown();
 },
 function(){
 $j('.select_categorie ol').slideUp();
 }
 );
 
 // affiche la catégorie
 if($j('.select_categorie .on').length){
 $j('.select_categorie .faux_select').html('<strong>' + $j('.select_categorie .on').html() + '</strong>');
 }
 
 
 // si un filtre couleur est actif
 if($j('.currently .Color').length){
 // bloque la liste déroulante
 $j('.select_color .faux_select').unbind();
 $j('.select_color .faux_select').addClass('actif');
 $j('.select_color .faux_select').click(function(){
 // enlève le filtre (simule un clic sur la croix)
 document.location.href = $j('.currently .Color a').attr('href');
 });
 }
 
 // si un filtre taille est actif
 if($j('.currently .taille').length){
 // bloque la liste déroulante
 $j('.select_taille .faux_select').unbind();
 $j('.select_taille .faux_select').addClass('actif');
 $j('.select_taille .faux_select').click(function(){
 // enlève le filtre (simule un clic sur la croix)
 document.location.href = $j('.currently .taille a').attr('href');
 });
 }
 
 

 // si un filtre categorie est actif
 if($j('.select_categorie .on').length){
 // bloque la liste déroulante
 $j('.select_categorie .faux_select').unbind();
 $j('.select_categorie .faux_select').addClass('actif');
 $j('.select_categorie .faux_select').click(function(){
 // enlève le filtre (simule un clic sur le nom de la catégorie)
 document.location.href = $j('.select_categorie h2 a').attr('href');
 });
 }

 
 
 // masque le panier et la liste d'envies
 $j('.block-cart').hide();
 $j('.block-wishlist').hide();
 
 // affiche le panier
 $j('.top-link-cart').toggle(
 function(){
 if($j('.block-wishlist:visible').length){
 $j('.top-link-wishlist').click();
 }
 $j('.block-cart').slideDown();
 timeoutID = window.setTimeout(function(){
 if($j('.block-cart:visible').length){
 $j('.top-link-cart').click();
 }
 }, 5000);
 },
 function(){
 $j('.block-cart').slideUp();
 window.clearTimeout(timeoutID);
 }
 );
 
 // affiche la liste d'envies
 $j('.top-link-wishlist').toggle(
 function(){
 if($j('.block-cart:visible').length){
 $j('.top-link-cart').click();
 }
 $j('.block-wishlist').slideDown();
 timeoutID = window.setTimeout(function(){
 if($j('.block-wishlist:visible').length){
 $j('.top-link-wishlist').click();
 }
 }, 5000);
 },
 function(){
 $j('.block-wishlist').slideUp();
 window.clearTimeout(timeoutID);
 }
 );
 
 // affiche le formulaire de la newsletter
 $j('#lien_newsletter').toggle(
 function(){
 $j('.block-subscribe').slideDown();
 },
 function(){
 $j('.block-subscribe').slideUp();
 }
 );
 
 // effet hover sur les boutons atos
 $j('#atosButtons input').hover(
 function(){
 $j(this).attr('src', $j(this).attr('src').replace(/.gif/g, '_on.gif'));
 },
 function(){
 $j(this).attr('src', $j(this).attr('src').replace(/_on.gif/g, '.gif'));
 }
 );
 
 // lance la popup
 $j('#lien_playlist').click(function(){
 window.open($j(this).attr("href"), "popup_playlist", "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no,width=500,height=410");
 return false;
 });
 
 //lien vente prive - gauche
 $j('.push-vp-gauche a').hover(
 function(){
 $j(".push-vp-gauche a").animate({"left": "+=4px"}, "fast");
 
 },
 function(){
 $j(".push-vp-gauche a").animate({"left": "-=4px"}, "fast");
 }
 );

});

//Mise à jour de la média gallerie lors du clic sur le "1", "2" ou "3"
function reload_image(img, obj )
{
 var u = $(obj).readAttribute('src');
 var url = u.split('_');
 var url_img = url[0].substring(0,(url[0].length-1))
 url_img;
 //On supprime l'état actif des 3 vignettes
 $('images_1').src=url_img+'1_0.gif';
 $('images_2').src=url_img+'2_0.gif';
 if($('images_3') != null) { $('images_3').src=url_img+'3_0.gif';}
 //On modifie la vignette avec le chiffre qui spécifier l'état actif
 var uri = url[0]+'_1.gif';
 $(obj).writeAttribute('src',uri);
 $('image').src = img;
 //remise à zero de la taille de l'image
 $('image').style.width='auto';
 //Update de la visionneuse
 $('image').onload = function() {
 product_zoom = new Product.Zoom('image', 'track', 'handle', 'zoom_in', 'zoom_out', 'track_hint');
 }
 return false;
}


/**
 * jCarousel - Riding carousels with jQuery
 * http://sorgalla.com/jcarousel/
 *
 * Copyright (c) 2006 Jan Sorgalla (http://sorgalla.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * Built on top of the jQuery library
 * http://jquery.com
 *
 * Inspired by the "Carousel Component" by Bill Scott
 * http://billwscott.com/carousel/
 */

(function($) {
 /**
 * Creates a carousel for all matched elements.
 *
 * @example $("#mycarousel").jcarousel();
 * @before <ul id="mycarousel" class="jcarousel-skin-name"><li>First item</li><li>Second item</li></ul>
 * @result
 *
 * <div class="jcarousel-skin-name">
 * <div class="jcarousel-container">
 * <div disabled="disabled" class="jcarousel-prev jcarousel-prev-disabled"></div>
 * <div class="jcarousel-next"></div>
 * <div class="jcarousel-clip">
 * <ul class="jcarousel-list">
 * <li class="jcarousel-item-1">First item</li>
 * <li class="jcarousel-item-2">Second item</li>
 * </ul>
 * </div>
 * </div>
 * </div>
 *
 * @name jcarousel
 * @type jQuery
 * @param Hash o A set of key/value pairs to set as configuration properties.
 * @cat Plugins/jCarousel
 */
 $.fn.jcarousel = function(o) {
 return this.each(function() {
 new $jc(this, o);
 });
 };

 // Default configuration properties.
 var defaults = {
 vertical: false,
 start: 1,
 offset: 1,
 size: null,
 scroll: 3,
 visible: null,
 animation: 'normal',
 easing: 'swing',
 auto: 0,
 wrap: null,
 initCallback: null,
 reloadCallback: null,
 itemLoadCallback: null,
 itemFirstInCallback: null,
 itemFirstOutCallback: null,
 itemLastInCallback: null,
 itemLastOutCallback: null,
 itemVisibleInCallback: null,
 itemVisibleOutCallback: null,
 buttonNextHTML: '<div></div>',
 buttonPrevHTML: '<div></div>',
 buttonNextEvent: 'click',
 buttonPrevEvent: 'click',
 buttonNextCallback: null,
 buttonPrevCallback: null
 };

 /**
 * The jCarousel object.
 *
 * @constructor
 * @name $.jcarousel
 * @param Object e The element to create the carousel for.
 * @param Hash o A set of key/value pairs to set as configuration properties.
 * @cat Plugins/jCarousel
 */
 $.jcarousel = function(e, o) {
 this.options = $.extend({}, defaults, o || {});

 this.locked = false;

 this.container = null;
 this.clip = null;
 this.list = null;
 this.buttonNext = null;
 this.buttonPrev = null;

 this.wh = !this.options.vertical ? 'width' : 'height';
 this.lt = !this.options.vertical ? 'left' : 'top';

 // Extract skin class
 var skin = '', split = e.className.split(' ');

 for (var i = 0; i < split.length; i++) {
 if (split[i].indexOf('jcarousel-skin') != -1) {
 $(e).removeClass(split[i]);
 var skin = split[i];
 break;
 }
 }

 if (e.nodeName == 'UL' || e.nodeName == 'OL') {
 this.list = $(e);
 this.container = this.list.parent();

 if (this.container.hasClass('jcarousel-clip')) {
 if (!this.container.parent().hasClass('jcarousel-container'))
 this.container = this.container.wrap('<div></div>');

 this.container = this.container.parent();
 } else if (!this.container.hasClass('jcarousel-container'))
 this.container = this.list.wrap('<div></div>').parent();
 } else {
 this.container = $(e);
 this.list = $(e).find('>ul,>ol,div>ul,div>ol');
 }

 if (skin != '' && this.container.parent()[0].className.indexOf('jcarousel-skin') == -1)
 this.container.wrap('<div class=" '+ skin + '"></div>');

 this.clip = this.list.parent();

 if (!this.clip.length || !this.clip.hasClass('jcarousel-clip'))
 this.clip = this.list.wrap('<div></div>').parent();

 this.buttonPrev = $('.jcarousel-prev', this.container);

 if (this.buttonPrev.size() == 0 && this.options.buttonPrevHTML != null)
 this.buttonPrev = this.clip.before(this.options.buttonPrevHTML).prev();

 this.buttonPrev.addClass(this.className('jcarousel-prev'));

 this.buttonNext = $('.jcarousel-next', this.container);

 if (this.buttonNext.size() == 0 && this.options.buttonNextHTML != null)
 this.buttonNext = this.clip.before(this.options.buttonNextHTML).prev();

 this.buttonNext.addClass(this.className('jcarousel-next'));

 this.clip.addClass(this.className('jcarousel-clip'));
 this.list.addClass(this.className('jcarousel-list'));
 this.container.addClass(this.className('jcarousel-container'));

 var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null;
 var li = this.list.children('li');

 var self = this;

 if (li.size() > 0) {
 var wh = 0, i = this.options.offset;
 li.each(function() {
 self.format(this, i++);
 wh += self.dimension(this, di);
 });

 this.list.css(this.wh, wh + 'px');

 // Only set if not explicitly passed as option
 if (!o || o.size === undefined)
 this.options.size = li.size();
 }

 // For whatever reason, .show() does not work in Safari...
 this.container.css('display', 'block');
 this.buttonNext.css('display', 'block');
 this.buttonPrev.css('display', 'block');

 this.funcNext = function() { self.next(); };
 this.funcPrev = function() { self.prev(); };
 this.funcResize = function() { self.reload(); };

 if (this.options.initCallback != null)
 this.options.initCallback(this, 'init');

 if ($.browser.safari) {
 this.buttons(false, false);
 $(window).bind('load', function() { self.setup(); });
 } else
 this.setup();
 };

 // Create shortcut for internal use
 var $jc = $.jcarousel;

 $jc.fn = $jc.prototype = {
 jcarousel: '0.2.3'
 };

 $jc.fn.extend = $jc.extend = $.extend;

 $jc.fn.extend({
 /**
 * Setups the carousel.
 *
 * @name setup
 * @type undefined
 * @cat Plugins/jCarousel
 */
 setup: function() {
 this.first = null;
 this.last = null;
 this.prevFirst = null;
 this.prevLast = null;
 this.animating = false;
 this.timer = null;
 this.tail = null;
 this.inTail = false;

 if (this.locked)
 return;

 this.list.css(this.lt, this.pos(this.options.offset) + 'px');
 var p = this.pos(this.options.start);
 this.prevFirst = this.prevLast = null;
 this.animate(p, false);

 $(window).unbind('resize', this.funcResize).bind('resize', this.funcResize);
 },

 /**
 * Clears the list and resets the carousel.
 *
 * @name reset
 * @type undefined
 * @cat Plugins/jCarousel
 */
 reset: function() {
 this.list.empty();

 this.list.css(this.lt, '0px');
 this.list.css(this.wh, '10px');

 if (this.options.initCallback != null)
 this.options.initCallback(this, 'reset');

 this.setup();
 },

 /**
 * Reloads the carousel and adjusts positions.
 *
 * @name reload
 * @type undefined
 * @cat Plugins/jCarousel
 */
 reload: function() {
 if (this.tail != null && this.inTail)
 this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + this.tail);

 this.tail = null;
 this.inTail = false;

 if (this.options.reloadCallback != null)
 this.options.reloadCallback(this);

 if (this.options.visible != null) {
 var self = this;
 var di = Math.ceil(this.clipping() / this.options.visible), wh = 0, lt = 0;
 $('li', this.list).each(function(i) {
 wh += self.dimension(this, di);
 if (i + 1 < self.first)
 lt = wh;
 });

 this.list.css(this.wh, wh + 'px');
 this.list.css(this.lt, -lt + 'px');
 }

 this.scroll(this.first, false);
 },

 /**
 * Locks the carousel.
 *
 * @name lock
 * @type undefined
 * @cat Plugins/jCarousel
 */
 lock: function() {
 this.locked = true;
 this.buttons();
 },

 /**
 * Unlocks the carousel.
 *
 * @name unlock
 * @type undefined
 * @cat Plugins/jCarousel
 */
 unlock: function() {
 this.locked = false;
 this.buttons();
 },

 /**
 * Sets the size of the carousel.
 *
 * @name size
 * @type undefined
 * @param Number s The size of the carousel.
 * @cat Plugins/jCarousel
 */
 size: function(s) {
 if (s != undefined) {
 this.options.size = s;
 if (!this.locked)
 this.buttons();
 }

 return this.options.size;
 },

 /**
 * Checks whether a list element exists for the given index (or index range).
 *
 * @name get
 * @type bool
 * @param Number i The index of the (first) element.
 * @param Number i2 The index of the last element.
 * @cat Plugins/jCarousel
 */
 has: function(i, i2) {
 if (i2 == undefined || !i2)
 i2 = i;

 if (this.options.size !== null && i2 > this.options.size)
 i2 = this.options.size;

 for (var j = i; j <= i2; j++) {
 var e = this.get(j);
 if (!e.length || e.hasClass('jcarousel-item-placeholder'))
 return false;
 }

 return true;
 },

 /**
 * Returns a jQuery object with list element for the given index.
 *
 * @name get
 * @type jQuery
 * @param Number i The index of the element.
 * @cat Plugins/jCarousel
 */
 get: function(i) {
 return $('.jcarousel-item-' + i, this.list);
 },

 /**
 * Adds an element for the given index to the list.
 * If the element already exists, it updates the inner html.
 * Returns the created element as jQuery object.
 *
 * @name add
 * @type jQuery
 * @param Number i The index of the element.
 * @param String s The innerHTML of the element.
 * @cat Plugins/jCarousel
 */
 add: function(i, s) {
 var e = this.get(i), old = 0, add = 0;

 if (e.length == 0) {
 var c, e = this.create(i), j = $jc.intval(i);
 while (c = this.get(--j)) {
 if (j <= 0 || c.length) {
 j <= 0 ? this.list.prepend(e) : c.after(e);
 break;
 }
 }
 } else
 old = this.dimension(e);

 e.removeClass(this.className('jcarousel-item-placeholder'));
 typeof s == 'string' ? e.html(s) : e.empty().append(s);

 var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null;
 var wh = this.dimension(e, di) - old;

 if (i > 0 && i < this.first)
 this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - wh + 'px');

 this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) + wh + 'px');

 return e;
 },

 /**
 * Removes an element for the given index from the list.
 *
 * @name remove
 * @type undefined
 * @param Number i The index of the element.
 * @cat Plugins/jCarousel
 */
 remove: function(i) {
 var e = this.get(i);

 // Check if item exists and is not currently visible
 if (!e.length || (i >= this.first && i <= this.last))
 return;

 var d = this.dimension(e);

 if (i < this.first)
 this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + d + 'px');

 e.remove();

 this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) - d + 'px');
 },

 /**
 * Moves the carousel forwards.
 *
 * @name next
 * @type undefined
 * @cat Plugins/jCarousel
 */
 next: function() {
 this.stopAuto();

 if (this.tail != null && !this.inTail)
 this.scrollTail(false);
 else
 this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'last') && this.options.size != null && this.last == this.options.size) ? 1 : this.first + this.options.scroll);
 },

 /**
 * Moves the carousel backwards.
 *
 * @name prev
 * @type undefined
 * @cat Plugins/jCarousel
 */
 prev: function() {
 this.stopAuto();

 if (this.tail != null && this.inTail)
 this.scrollTail(true);
 else
 this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'first') && this.options.size != null && this.first == 1) ? this.options.size : this.first - this.options.scroll);
 },

 /**
 * Scrolls the tail of the carousel.
 *
 * @name scrollTail
 * @type undefined
 * @param Bool b Whether scroll the tail back or forward.
 * @cat Plugins/jCarousel
 */
 scrollTail: function(b) {
 if (this.locked || this.animating || !this.tail)
 return;

 var pos = $jc.intval(this.list.css(this.lt));

 !b ? pos -= this.tail : pos += this.tail;
 this.inTail = !b;

 // Save for callbacks
 this.prevFirst = this.first;
 this.prevLast = this.last;

 this.animate(pos);
 },

 /**
 * Scrolls the carousel to a certain position.
 *
 * @name scroll
 * @type undefined
 * @param Number i The index of the element to scoll to.
 * @param Bool a Flag indicating whether to perform animation.
 * @cat Plugins/jCarousel
 */
 scroll: function(i, a) {
 if (this.locked || this.animating)
 return;

 this.animate(this.pos(i), a);
 },

 /**
 * Prepares the carousel and return the position for a certian index.
 *
 * @name pos
 * @type Number
 * @param Number i The index of the element to scoll to.
 * @cat Plugins/jCarousel
 */
 pos: function(i) {
 if (this.locked || this.animating)
 return;

 if (this.options.wrap != 'circular')
 i = i < 1 ? 1 : (this.options.size && i > this.options.size ? this.options.size : i);

 var back = this.first > i;
 var pos = $jc.intval(this.list.css(this.lt));

 // Create placeholders, new list width/height
 // and new list position
 var f = this.options.wrap != 'circular' && this.first <= 1 ? 1 : this.first;
 var c = back ? this.get(f) : this.get(this.last);
 var j = back ? f : f - 1;
 var e = null, l = 0, p = false, d = 0;

 while (back ? --j >= i : ++j < i) {
 e = this.get(j);
 p = !e.length;
 if (e.length == 0) {
 e = this.create(j).addClass(this.className('jcarousel-item-placeholder'));
 c[back ? 'before' : 'after' ](e);
 }

 c = e;
 d = this.dimension(e);

 if (p)
 l += d;

 if (this.first != null && (this.options.wrap == 'circular' || (j >= 1 && (this.options.size == null || j <= this.options.size))))
 pos = back ? pos + d : pos - d;
 }

 // Calculate visible items
 var clipping = this.clipping();
 var cache = [];
 var visible = 0, j = i, v = 0;
 var c = this.get(i - 1);

 while (++visible) {
 e = this.get(j);
 p = !e.length;
 if (e.length == 0) {
 e = this.create(j).addClass(this.className('jcarousel-item-placeholder'));
 // This should only happen on a next scroll
 c.length == 0 ? this.list.prepend(e) : c[back ? 'before' : 'after' ](e);
 }

 c = e;
 var d = this.dimension(e);
 if (d == 0) {
 alert('jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...');
 return 0;
 }

 if (this.options.wrap != 'circular' && this.options.size !== null && j > this.options.size)
 cache.push(e);
 else if (p)
 l += d;

 v += d;

 if (v >= clipping)
 break;

 j++;
 }

 // Remove out-of-range placeholders
 for (var x = 0; x < cache.length; x++)
 cache[x].remove();

 // Resize list
 if (l > 0) {
 this.list.css(this.wh, this.dimension(this.list) + l + 'px');

 if (back) {
 pos -= l;
 this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - l + 'px');
 }
 }

 // Calculate first and last item
 var last = i + visible - 1;
 if (this.options.wrap != 'circular' && this.options.size && last > this.options.size)
 last = this.options.size;

 if (j > last) {
 visible = 0, j = last, v = 0;
 while (++visible) {
 var e = this.get(j--);
 if (!e.length)
 break;
 v += this.dimension(e);
 if (v >= clipping)
 break;
 }
 }

 var first = last - visible + 1;
 if (this.options.wrap != 'circular' && first < 1)
 first = 1;

 if (this.inTail && back) {
 pos += this.tail;
 this.inTail = false;
 }

 this.tail = null;
 if (this.options.wrap != 'circular' && last == this.options.size && (last - visible + 1) >= 1) {
 var m = $jc.margin(this.get(last), !this.options.vertical ? 'marginRight' : 'marginBottom');
 if ((v - m) > clipping)
 this.tail = v - clipping - m;
 }

 // Adjust position
 while (i-- > first)
 pos += this.dimension(this.get(i));

 // Save visible item range
 this.prevFirst = this.first;
 this.prevLast = this.last;
 this.first = first;
 this.last = last;

 return pos;
 },

 /**
 * Animates the carousel to a certain position.
 *
 * @name animate
 * @type undefined
 * @param mixed p Position to scroll to.
 * @param Bool a Flag indicating whether to perform animation.
 * @cat Plugins/jCarousel
 */
 animate: function(p, a) {
 if (this.locked || this.animating)
 return;

 this.animating = true;

 var self = this;
 var scrolled = function() {
 self.animating = false;

 if (p == 0)
 self.list.css(self.lt, 0);

 if (self.options.wrap == 'both' || self.options.wrap == 'last' || self.options.size == null || self.last < self.options.size)
 self.startAuto();

 self.buttons();
 self.notify('onAfterAnimation');
 };

 this.notify('onBeforeAnimation');

 // Animate
 if (!this.options.animation || a == false) {
 this.list.css(this.lt, p + 'px');
 scrolled();
 } else {
 var o = !this.options.vertical ? {'left': p} : {'top': p};
 this.list.animate(o, this.options.animation, this.options.easing, scrolled);
 }
 },

 /**
 * Starts autoscrolling.
 *
 * @name auto
 * @type undefined
 * @param Number s Seconds to periodically autoscroll the content.
 * @cat Plugins/jCarousel
 */
 startAuto: function(s) {
 if (s != undefined)
 this.options.auto = s;

 if (this.options.auto == 0)
 return this.stopAuto();

 if (this.timer != null)
 return;

 var self = this;
 this.timer = setTimeout(function() { self.next(); }, this.options.auto * 1000);
 },

 /**
 * Stops autoscrolling.
 *
 * @name stopAuto
 * @type undefined
 * @cat Plugins/jCarousel
 */
 stopAuto: function() {
 if (this.timer == null)
 return;

 clearTimeout(this.timer);
 this.timer = null;
 },

 /**
 * Sets the states of the prev/next buttons.
 *
 * @name buttons
 * @type undefined
 * @cat Plugins/jCarousel
 */
 buttons: function(n, p) {
 if (n == undefined || n == null) {
 var n = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'first') || this.options.size == null || this.last < this.options.size);
 if (!this.locked && (!this.options.wrap || this.options.wrap == 'first') && this.options.size != null && this.last >= this.options.size)
 n = this.tail != null && !this.inTail;
 }

 if (p == undefined || p == null) {
 var p = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'last') || this.first > 1);
 if (!this.locked && (!this.options.wrap || this.options.wrap == 'last') && this.options.size != null && this.first == 1)
 p = this.tail != null && this.inTail;
 }

 var self = this;

 this.buttonNext[n ? 'bind' : 'unbind'](this.options.buttonNextEvent, this.funcNext)[n ? 'removeClass' : 'addClass'](this.className('jcarousel-next-disabled')).attr('disabled', n ? false : true);
 this.buttonPrev[p ? 'bind' : 'unbind'](this.options.buttonPrevEvent, this.funcPrev)[p ? 'removeClass' : 'addClass'](this.className('jcarousel-prev-disabled')).attr('disabled', p ? false : true);

 if (this.buttonNext.length > 0 && (this.buttonNext[0].jcarouselstate == undefined || this.buttonNext[0].jcarouselstate != n) && this.options.buttonNextCallback != null) {
 this.buttonNext.each(function() { self.options.buttonNextCallback(self, this, n); });
 this.buttonNext[0].jcarouselstate = n;
 }

 if (this.buttonPrev.length > 0 && (this.buttonPrev[0].jcarouselstate == undefined || this.buttonPrev[0].jcarouselstate != p) && this.options.buttonPrevCallback != null) {
 this.buttonPrev.each(function() { self.options.buttonPrevCallback(self, this, p); });
 this.buttonPrev[0].jcarouselstate = p;
 }
 },

 notify: function(evt) {
 var state = this.prevFirst == null ? 'init' : (this.prevFirst < this.first ? 'next' : 'prev');

 // Load items
 this.callback('itemLoadCallback', evt, state);

 if (this.prevFirst !== this.first) {
 this.callback('itemFirstInCallback', evt, state, this.first);
 this.callback('itemFirstOutCallback', evt, state, this.prevFirst);
 }

 if (this.prevLast !== this.last) {
 this.callback('itemLastInCallback', evt, state, this.last);
 this.callback('itemLastOutCallback', evt, state, this.prevLast);
 }

 this.callback('itemVisibleInCallback', evt, state, this.first, this.last, this.prevFirst, this.prevLast);
 this.callback('itemVisibleOutCallback', evt, state, this.prevFirst, this.prevLast, this.first, this.last);
 },

 callback: function(cb, evt, state, i1, i2, i3, i4) {
 if (this.options[cb] == undefined || (typeof this.options[cb] != 'object' && evt != 'onAfterAnimation'))
 return;

 var callback = typeof this.options[cb] == 'object' ? this.options[cb][evt] : this.options[cb];

 if (!$.isFunction(callback))
 return;

 var self = this;

 if (i1 === undefined)
 callback(self, state, evt);
 else if (i2 === undefined)
 this.get(i1).each(function() { callback(self, this, i1, state, evt); });
 else {
 for (var i = i1; i <= i2; i++)
 if (i !== null && !(i >= i3 && i <= i4))
 this.get(i).each(function() { callback(self, this, i, state, evt); });
 }
 },

 create: function(i) {
 return this.format('<li></li>', i);
 },

 format: function(e, i) {
 var $e = $(e).addClass(this.className('jcarousel-item')).addClass(this.className('jcarousel-item-' + i));
 $e.attr('jcarouselindex', i);
 return $e;
 },

 className: function(c) {
 return c + ' ' + c + (!this.options.vertical ? '-horizontal' : '-vertical');
 },

 dimension: function(e, d) {
 var el = e.jquery != undefined ? e[0] : e;

 var old = !this.options.vertical ?
 el.offsetWidth + $jc.margin(el, 'marginLeft') + $jc.margin(el, 'marginRight') :
 el.offsetHeight + $jc.margin(el, 'marginTop') + $jc.margin(el, 'marginBottom');

 if (d == undefined || old == d)
 return old;

 var w = !this.options.vertical ?
 d - $jc.margin(el, 'marginLeft') - $jc.margin(el, 'marginRight') :
 d - $jc.margin(el, 'marginTop') - $jc.margin(el, 'marginBottom');

 $(el).css(this.wh, w + 'px');

 return this.dimension(el);
 },

 clipping: function() {
 return !this.options.vertical ?
 this.clip[0].offsetWidth - $jc.intval(this.clip.css('borderLeftWidth')) - $jc.intval(this.clip.css('borderRightWidth')) :
 this.clip[0].offsetHeight - $jc.intval(this.clip.css('borderTopWidth')) - $jc.intval(this.clip.css('borderBottomWidth'));
 },

 index: function(i, s) {
 if (s == undefined)
 s = this.options.size;

 return Math.round((((i-1) / s) - Math.floor((i-1) / s)) * s) + 1;
 }
 });

 $jc.extend({
 /**
 * Gets/Sets the global default configuration properties.
 *
 * @name defaults
 * @descr Gets/Sets the global default configuration properties.
 * @type Hash
 * @param Hash d A set of key/value pairs to set as configuration properties.
 * @cat Plugins/jCarousel
 */
 defaults: function(d) {
 return $.extend(defaults, d || {});
 },

 margin: function(e, p) {
 if (!e)
 return 0;

 var el = e.jquery != undefined ? e[0] : e;

 if (p == 'marginRight' && $.browser.safari) {
 var old = {'display': 'block', 'float': 'none', 'width': 'auto'}, oWidth, oWidth2;

 $.swap(el, old, function() { oWidth = el.offsetWidth; });

 old['marginRight'] = 0;
 $.swap(el, old, function() { oWidth2 = el.offsetWidth; });

 return oWidth2 - oWidth;
 }

 return $jc.intval($.css(el, p));
 },

 intval: function(v) {
 v = parseInt(v);
 return isNaN(v) ? 0 : v;
 }
 });

})(jQuery);

/*
 * jQuery Tooltip plugin 1.3
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
 * http://docs.jquery.com/Plugins/Tooltip
 *
 * Copyright (c) 2006 - 2008 Jörn Zaefferer
 *
 * $Id: jquery.tooltip.js 5741 2008-06-21 15:22:16Z joern.zaefferer $
 * 
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
 
;(function($) {
 
 // the tooltip element
 var helper = {},
 // the current tooltipped element
 current,
 // the title of the current element, used for restoring
 title,
 // timeout id for delayed tooltips
 tID,
 // IE 5.5 or 6
 IE = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent),
 // flag for mouse tracking
 track = false;
 
 $.tooltip = {
 blocked: false,
 defaults: {
 delay: 200,
 fade: false,
 showURL: true,
 extraClass: "",
 top: 15,
 left: 15,
 id: "tooltip"
 },
 block: function() {
 $.tooltip.blocked = !$.tooltip.blocked;
 }
 };
 
 $.fn.extend({
 tooltip: function(settings) {
 settings = $.extend({}, $.tooltip.defaults, settings);
 createHelper(settings);
 return this.each(function() {
 $.data(this, "tooltip", settings);
 this.tOpacity = helper.parent.css("opacity");
 // copy tooltip into its own expando and remove the title
 this.tooltipText = this.title;
 $(this).removeAttr("title");
 // also remove alt attribute to prevent default tooltip in IE
 this.alt = "";
 })
 .mouseover(save)
 .mouseout(hide)
 .click(hide);
 },
 fixPNG: IE ? function() {
 return this.each(function () {
 var image = $(this).css('backgroundImage');
 if (image.match(/^url\(["']?(.*\.png)["']?\)$/i)) {
 image = RegExp.$1;
 $(this).css({
 'backgroundImage': 'none',
 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
 }).each(function () {
 var position = $(this).css('position');
 if (position != 'absolute' && position != 'relative')
 $(this).css('position', 'relative');
 });
 }
 });
 } : function() { return this; },
 unfixPNG: IE ? function() {
 return this.each(function () {
 $(this).css({'filter': '', backgroundImage: ''});
 });
 } : function() { return this; },
 hideWhenEmpty: function() {
 return this.each(function() {
 $(this)[ $(this).html() ? "show" : "hide" ]();
 });
 },
 url: function() {
 return this.attr('href') || this.attr('src');
 }
 });
 
 function createHelper(settings) {
 // there can be only one tooltip helper
 if( helper.parent )
 return;
 // create the helper, h3 for title, div for url
 helper.parent = $('<div id="' + settings.id + '"><h3></h3><div class="body"></div><div class="url"></div></div>')
 // add to document
 .appendTo(document.body)
 // hide it at first
 .hide();
 
 // apply bgiframe if available
 if ( $.fn.bgiframe )
 helper.parent.bgiframe();
 
 // save references to title and url elements
 helper.title = $('h3', helper.parent);
 helper.body = $('div.body', helper.parent);
 helper.url = $('div.url', helper.parent);
 }
 
 function settings(element) {
 return $.data(element, "tooltip");
 }
 
 // main event handler to start showing tooltips
 function handle(event) {
 // show helper, either with timeout or on instant
 if( settings(this).delay )
 tID = setTimeout(show, settings(this).delay);
 else
 show();
 
 // if selected, update the helper position when the mouse moves
 track = !!settings(this).track;
 $(document.body).bind('mousemove', update);
 
 // update at least once
 update(event);
 }
 
 // save elements title before the tooltip is displayed
 function save() {
 // if this is the current source, or it has no title (occurs with click event), stop
 if ( $.tooltip.blocked || this == current || (!this.tooltipText && !settings(this).bodyHandler) )
 return;

 // save current
 current = this;
 title = this.tooltipText;
 
 if ( settings(this).bodyHandler ) {
 helper.title.hide();
 var bodyContent = settings(this).bodyHandler.call(this);
 if (bodyContent.nodeType || bodyContent.jquery) {
 helper.body.empty().append(bodyContent)
 } else {
 helper.body.html( bodyContent );
 }
 helper.body.show();
 } else if ( settings(this).showBody ) {
 var parts = title.split(settings(this).showBody);
 helper.title.html(parts.shift()).show();
 helper.body.empty();
 for(var i = 0, part; (part = parts[i]); i++) {
 if(i > 0)
 helper.body.append("<br/>");
 helper.body.append(part);
 }
 helper.body.hideWhenEmpty();
 } else {
 helper.title.html(title).show();
 helper.body.hide();
 }
 
 // if element has href or src, add and show it, otherwise hide it
 if( settings(this).showURL && $(this).url() )
 helper.url.html( $(this).url().replace('http://', '') ).show();
 else 
 helper.url.hide();
 
 // add an optional class for this tip
 helper.parent.addClass(settings(this).extraClass);

 // fix PNG background for IE
 if (settings(this).fixPNG )
 helper.parent.fixPNG();
 
 handle.apply(this, arguments);
 }
 
 // delete timeout and show helper
 function show() {
 tID = null;
 if ((!IE || !$.fn.bgiframe) && settings(current).fade) {
 if (helper.parent.is(":animated"))
 helper.parent.stop().show().fadeTo(settings(current).fade, current.tOpacity);
 else
 helper.parent.is(':visible') ? helper.parent.fadeTo(settings(current).fade, current.tOpacity) : helper.parent.fadeIn(settings(current).fade);
 } else {
 helper.parent.show();
 }
 update();
 }
 
 /**
 * callback for mousemove
 * updates the helper position
 * removes itself when no current element
 */
 function update(event) {
 if($.tooltip.blocked)
 return;
 
 if (event && event.target.tagName == "OPTION") {
 return;
 }
 
 // stop updating when tracking is disabled and the tooltip is visible
 if ( !track && helper.parent.is(":visible")) {
 $(document.body).unbind('mousemove', update)
 }
 
 // if no current element is available, remove this listener
 if( current == null ) {
 $(document.body).unbind('mousemove', update);
 return; 
 }
 
 // remove position helper classes
 helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");
 
 var left = helper.parent[0].offsetLeft;
 var top = helper.parent[0].offsetTop;
 if (event) {
 // position the helper 15 pixel to bottom right, starting from mouse position
 left = event.pageX + settings(current).left;
 top = event.pageY + settings(current).top;
 var right='auto';
 if (settings(current).positionLeft) {
 right = $(window).width() - left;
 left = 'auto';
 }
 helper.parent.css({
 left: left,
 right: right,
 top: top
 });
 }
 
 var v = viewport(),
 h = helper.parent[0];
 // check horizontal position
 if (v.x + v.cx < h.offsetLeft + h.offsetWidth) {
 left -= h.offsetWidth + 20 + settings(current).left;
 helper.parent.css({left: left + 'px'}).addClass("viewport-right");
 }
 // check vertical position
 if (v.y + v.cy < h.offsetTop + h.offsetHeight) {
 top -= h.offsetHeight + 20 + settings(current).top;
 helper.parent.css({top: top + 'px'}).addClass("viewport-bottom");
 }
 }
 
 function viewport() {
 return {
 x: $(window).scrollLeft(),
 y: $(window).scrollTop(),
 cx: $(window).width(),
 cy: $(window).height()
 };
 }
 
 // hide helper and restore added classes and the title
 function hide(event) {
 if($.tooltip.blocked)
 return;
 // clear timeout if possible
 if(tID)
 clearTimeout(tID);
 // no more current element
 current = null;
 
 var tsettings = settings(this);
 function complete() {
 helper.parent.removeClass( tsettings.extraClass ).hide().css("opacity", "");
 }
 if ((!IE || !$.fn.bgiframe) && tsettings.fade) {
 if (helper.parent.is(':animated'))
 helper.parent.stop().fadeTo(tsettings.fade, 0, complete);
 else
 helper.parent.stop().fadeOut(tsettings.fade, complete);
 } else
 complete();
 
 if( settings(this).fixPNG )
 helper.parent.unfixPNG();
 }
 
})(jQuery);

(function($) {
 $.fn.ieffembedfix = function() {
 
 // CONFIGURE THE PATH TO YOUR 1BY1 PNG HERE, RELATIVE TO THE LOCATION OF THIS JS FILE.
 
 var pngimgurl = "hIEfix.png";
 
 return this.each(function() {
 //check for IE7/8
 if (jQuery.support.objectAll == false) {
 $(this).css({
 
 filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + pngimgurl + ",sizingMethod=crop',
 zoom: '1'
 });
 }
 });
 }
})(jQuery);
/**
 * Flash (http://jquery.lukelutman.com/plugins/flash)
 * A jQuery plugin for embedding Flash movies.
 * 
 * Version 1.0
 * November 9th, 2006
 *
 * Copyright (c) 2006 Luke Lutman (http://www.lukelutman.com)
 * Dual licensed under the MIT and GPL licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.opensource.org/licenses/gpl-license.php
 * 
 * Inspired by:
 * SWFObject (http://blog.deconcept.com/swfobject/)
 * UFO (http://www.bobbyvandersluis.com/ufo/)
 * sIFR (http://www.mikeindustries.com/sifr/)
 * 
 * IMPORTANT: 
 * The packed version of jQuery breaks ActiveX control
 * activation in Internet Explorer. Use JSMin to minifiy
 * jQuery (see: http://jquery.lukelutman.com/plugins/flash#activex).
 *
 **/ 
;(function(){
 
var $$;

/**
 * 
 * @desc Replace matching elements with a flash movie.
 * @author Luke Lutman
 * @version 1.0.1
 *
 * @name flash
 * @param Hash htmlOptions Options for the embed/object tag.
 * @param Hash pluginOptions Options for detecting/updating the Flash plugin (optional).
 * @param Function replace Custom block called for each matched element if flash is installed (optional).
 * @param Function update Custom block called for each matched if flash isn't installed (optional).
 * @type jQuery
 *
 * @cat plugins/flash
 * 
 * @example $('#hello').flash({ src: 'hello.swf' });
 * @desc Embed a Flash movie.
 *
 * @example $('#hello').flash({ src: 'hello.swf' }, { version: 8 });
 * @desc Embed a Flash 8 movie.
 *
 * @example $('#hello').flash({ src: 'hello.swf' }, { expressInstall: true });
 * @desc Embed a Flash movie using Express Install if flash isn't installed.
 *
 * @example $('#hello').flash({ src: 'hello.swf' }, { update: false });
 * @desc Embed a Flash movie, don't show an update message if Flash isn't installed.
 *
**/
$$ = jQuery.fn.flash = function(htmlOptions, pluginOptions, replace, update) {
 
 // Set the default block.
 var block = replace || $$.replace;
 
 // Merge the default and passed plugin options.
 pluginOptions = $$.copy($$.pluginOptions, pluginOptions);
 
 // Detect Flash.
 if(!$$.hasFlash(pluginOptions.version)) {
 // Use Express Install (if specified and Flash plugin 6,0,65 or higher is installed).
 if(pluginOptions.expressInstall && $$.hasFlash(6,0,65)) {
 // Add the necessary flashvars (merged later).
 var expressInstallOptions = {
 flashvars: { 
 MMredirectURL: location,
 MMplayerType: 'PlugIn',
 MMdoctitle: jQuery('title').text() 
 } 
 };
 // Ask the user to update (if specified).
 } else if (pluginOptions.update) {
 // Change the block to insert the update message instead of the flash movie.
 block = update || $$.update;
 // Fail
 } else {
 // The required version of flash isn't installed.
 // Express Install is turned off, or flash 6,0,65 isn't installed.
 // Update is turned off.
 // Return without doing anything.
 return this;
 }
 }
 
 // Merge the default, express install and passed html options.
 htmlOptions = $$.copy($$.htmlOptions, expressInstallOptions, htmlOptions);
 
 // Invoke $block (with a copy of the merged html options) for each element.
 return this.each(function(){
 block.call(this, $$.copy(htmlOptions));
 });
 
};
/**
 *
 * @name flash.copy
 * @desc Copy an arbitrary number of objects into a new object.
 * @type Object
 * 
 * @example $$.copy({ foo: 1 }, { bar: 2 });
 * @result { foo: 1, bar: 2 };
 *
**/
$$.copy = function() {
 var options = {}, flashvars = {};
 for(var i = 0; i < arguments.length; i++) {
 var arg = arguments[i];
 if(arg == undefined) continue;
 jQuery.extend(options, arg);
 // don't clobber one flash vars object with another
 // merge them instead
 if(arg.flashvars == undefined) continue;
 jQuery.extend(flashvars, arg.flashvars);
 }
 options.flashvars = flashvars;
 return options;
};
/*
 * @name flash.hasFlash
 * @desc Check if a specific version of the Flash plugin is installed
 * @type Boolean
 *
**/
$$.hasFlash = function() {
 // look for a flag in the query string to bypass flash detection
 if(/hasFlash\=true/.test(location)) return true;
 if(/hasFlash\=false/.test(location)) return false;
 var pv = $$.hasFlash.playerVersion().match(/\d+/g);
 var rv = String([arguments[0], arguments[1], arguments[2]]).match(/\d+/g) || String($$.pluginOptions.version).match(/\d+/g);
 for(var i = 0; i < 3; i++) {
 pv[i] = parseInt(pv[i] || 0);
 rv[i] = parseInt(rv[i] || 0);
 // player is less than required
 if(pv[i] < rv[i]) return false;
 // player is greater than required
 if(pv[i] > rv[i]) return true;
 }
 // major version, minor version and revision match exactly
 return true;
};
/**
 *
 * @name flash.hasFlash.playerVersion
 * @desc Get the version of the installed Flash plugin.
 * @type String
 *
**/
$$.hasFlash.playerVersion = function() {
 // ie
 try {
 try {
 // avoid fp6 minor version lookup issues
 // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
 var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
 try { axo.AllowScriptAccess = 'always'; } 
 catch(e) { return '6,0,0'; } 
 } catch(e) {}
 return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
 // other browsers
 } catch(e) {
 try {
 if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
 return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
 }
 } catch(e) {} 
 }
 return '0,0,0';
};
/**
 *
 * @name flash.htmlOptions
 * @desc The default set of options for the object or embed tag.
 *
**/
$$.htmlOptions = {
 height: 240,
 flashvars: {},
 pluginspage: 'http://www.adobe.com/go/getflashplayer',
 src: '#',
 type: 'application/x-shockwave-flash',
 width: 320 
};
/**
 *
 * @name flash.pluginOptions
 * @desc The default set of options for checking/updating the flash Plugin.
 *
**/
$$.pluginOptions = {
 expressInstall: false,
 update: true,
 version: '6.0.65'
};
/**
 *
 * @name flash.replace
 * @desc The default method for replacing an element with a Flash movie.
 *
**/
$$.replace = function(htmlOptions) {
 this.innerHTML = '<div class="alt">'+this.innerHTML+'</div>';
 jQuery(this)
 .addClass('flash-replaced')
 .prepend($$.transform(htmlOptions));
};
/**
 *
 * @name flash.update
 * @desc The default method for replacing an element with an update message.
 *
**/
$$.update = function(htmlOptions) {
 var url = String(location).split('?');
 url.splice(1,0,'?hasFlash=true&');
 url = url.join('');
 var msg = '<p>This content requires the Flash Player. <a href="http://www.adobe.com/go/getflashplayer">Download Flash Player</a>. Already have Flash Player? <a href="'+url+'">Click here.</a></p>';
 this.innerHTML = '<span class="alt">'+this.innerHTML+'</span>';
 jQuery(this)
 .addClass('flash-update')
 .prepend(msg);
};
/**
 *
 * @desc Convert a hash of html options to a string of attributes, using Function.apply(). 
 * @example toAttributeString.apply(htmlOptions)
 * @result foo="bar" foo="bar"
 *
**/
function toAttributeString() {
 var s = '';
 for(var key in this)
 if(typeof this[key] != 'function')
 s += key+'="'+this[key]+'" ';
 return s; 
};
/**
 *
 * @desc Convert a hash of flashvars to a url-encoded string, using Function.apply(). 
 * @example toFlashvarsString.apply(flashvarsObject)
 * @result foo=bar&foo=bar
 *
**/
function toFlashvarsString() {
 var s = '';
 for(var key in this)
 if(typeof this[key] != 'function')
 s += key+'='+encodeURIComponent(this[key])+'&';
 //s += key+'='+this[key]+'&';
 return s.replace(/&$/, ''); 
};
/**
 *
 * @name flash.transform
 * @desc Transform a set of html options into an embed tag.
 * @type String 
 *
 * @example $$.transform(htmlOptions)
 * @result <embed src="foo.swf" ... />
 *
 * Note: The embed tag is NOT standards-compliant, but it 
 * works in all current browsers. flash.transform can be
 * overwritten with a custom function to generate more 
 * standards-compliant markup.
 *
**/
$$.transform = function(htmlOptions) {
 htmlOptions.toString = toAttributeString;
 if(htmlOptions.flashvars) htmlOptions.flashvars.toString = toFlashvarsString;
 return '<embed ' + String(htmlOptions) + '/>'; 
};

/**
 *
 * Flash Player 9 Fix (http://blog.deconcept.com/2006/07/28/swfobject-143-released/)
 *
**/
if (window.attachEvent) {
 window.attachEvent("onbeforeunload", function(){
 __flash_unloadHandler = function() {};
 __flash_savedUnloadHandler = function() {};
 });
}
 
})();
/*
 * nyroModal - jQuery Plugin
 * http://nyromodal.nyrodev.com
 *
 * Copyright (c) 2008 Cedric Nirousset (nyrodev.com)
 * Licensed under the MIT license
 *
 * $Date: 2008-11-29 (Sat, 29 Nov 2008) $
 * $version: 1.3.1
 */
jQuery(function($) {

 // -------------------------------------------------------
 // Private Variables
 // -------------------------------------------------------

 var isIE6 = ($.browser.msie && parseInt($.browser.version.substr(0,1)) < 7);
 var body = $('body');

 var currentSettings;

 // To know if the fix for the Issue 10 should be applied (or has been applied)
 var fixFF = false;

 // Used for retrieve the content from an hidden div
 var contentElt;
 var contentEltLast;

 // Contains info about nyroModal state and all div references
 var modal = {
 started: false,
 ready: false,
 dataReady: false,
 anim: false,
 loadingShown: false,
 transition: false,
 error: false,
 full: null,
 bg: null,
 loading: null,
 tmp: null,
 content: null,
 wrapper: null,
 closing: false,
 contentWrapper: null,
 scripts: new Array()
 };

 // Indicate of the height or the width was resized, to reinit the currentsettings related to null
 var resized = {
 width: false,
 height: false
 };


 // -------------------------------------------------------
 // Public function
 // -------------------------------------------------------

 // jQuery extension function. A paramater object could be used to overwrite the default settings
 $.fn.nyroModal = function(settings) {
 if (!this)
 return false;
 return this.each(function(){
 if (this.nodeName.toLowerCase() == 'form') {
 $(this).submit(function(e) {
 if (this.enctype == 'multipart/form-data') {
 processModal($.extend(settings, {
 from: this
 }));
 return true;
 }
 e.preventDefault();
 processModal($.extend(settings, {
 from: this
 }));
 return false;
 });
 } else {
 $(this).click(function(e) {
 e.preventDefault();
 processModal($.extend(settings, {
 from: this
 }));
 return false;
 });
 }
 });
 };

 // jQuery extension function to call manually the modal. A paramater object could be used to overwrite the default settings
 $.fn.nyroModalManual = function(settings) {
 if (!this.length)
 processModal(settings);
 return this.each(function(){
 processModal($.extend(settings, {
 from: this
 }));
 });
 };

 $.nyroModalManual = function(settings) {
 processModal(settings);
 };

 // Update the current settings
 // object settings
 // string deep1 first key where overwrite the settings
 // string deep2 second key where overwrite the settings
 $.nyroModalSettings = function(settings, deep1, deep2) {
 setCurrentSettings(settings, deep1, deep2);
 if (!deep1 && modal.started) {
 if (modal.bg && settings.bgColor)
 currentSettings.updateBgColor(modal, currentSettings, function(){});

 if (modal.contentWrapper && settings.title) {
 title = $('h1#nyroModalTitle', modal.contentWrapper);
 if (title.length)
 title.text(settings.title);
 else
 modal.contentWrapper.prepend('<h1 id="nyroModalTitle">'+settings.title+'</h1>');
 }

 if (modal.content && (modal.dataReady && !modal.anim && !modal.transition) && (settings.width || settings.height)) {
 calculateSize(true);

 if (fixFF)
 modal.content.css({position: ''});
 currentSettings.resize(modal, currentSettings, function() {
 if (fixFF)
 modal.content.css({position: 'fixed'});
 if ($.isFunction(currentSettings.endResize))
 currentSettings.endResize(modal, currentSettings);
 });
 }
 }
 };

 // Remove the modal function
 $.nyroModalRemove = function() {
 removeModal();
 };

 // Go to the next image for a gallery
 // return false if nothing was done
 $.nyroModalNext = function() {
 var link = getGalleryLink(1);
 if (link)
 return link.nyroModalManual(currentSettings);
 return false;
 };

 // Go to the previous image for a gallery
 // return false if nothing was done
 $.nyroModalPrev = function() {
 var link = getGalleryLink(-1);
 if (link)
 return link.nyroModalManual(currentSettings);
 return false;
 };


 // -------------------------------------------------------
 // Default Settings
 // -------------------------------------------------------

 $.fn.nyroModal.settings = {
 debug: false, // Show the debug in the background

 modal: false, // Esc key or click backgrdound enabling or not

 type: '', // nyroModal type (form, formData, iframe, image, etc...)
 from: '', // Dom object where the call come from
 hash: '', // Eventual hash in the url

 processHandler: null, // Handler just before the real process

 selIndicator: 'nyroModalSel', // Value added when a form or Ajax is sent with a filter content

 formIndicator: 'nyroModal', // Value added when a form is sent

 content: null, // Raw content if type content is used

 bgColor: '#000000', // Background color

 ajax: {}, // Ajax option (url, data, type, success will be overwritten for a form, url and success only for an ajax call)

 swf: { // Swf player options if swf type is used.
 wmode: 'transparent'
 },

 width: null, // default Width If null, will be calculate automatically
 height: null, // default Height If null, will be calculate automatically

 minWidth: 400, // Minimum width
 minHeight: 300, // Minimum height

 resizable: true, // Indicate if the content is resizable. Will be set to false for swf
 autoSizable: true, // Indicate if the content is auto sizable. If not, the min size will be used

 padding: 25, // padding for the max modal size

 regexImg: '[^\.]\.(jpg|jpeg|png|tiff|gif|bmp)\s*$', // Regex to find images
 defaultImgAlt: 'Image', // Default alt attribute for the images
 setWidthImgTitle: true, // Set the width to the image title
 ltr: true, // Left to Right by default. Put to false for Hebrew or Right to Left language

 css: { // Default CSS option for the nyroModal Div. Some will be overwritten or updated when using IE6
 bg: {
 zIndex: 100,
 position: 'fixed',
 top: 0,
 left: 0,
 height: '100%',
 width: '100%'
 },
 wrapper: {
 zIndex: 101,
 position: 'fixed',
 top: '50%',
 left: '50%'
 },
 wrapper2: {
 },
 content: {
 overflow: 'auto'
 },
 loading: {
 zIndex: 102,
 position: 'fixed',
 top: '50%',
 left: '50%',
 marginTop: '-50px',
 marginLeft: '-50px'
 }
 },

 wrap: { // Wrapper div used to style the modal regarding the content type
 div: '<div class="wrapper"></div>',
 ajax: '<div class="wrapper"></div>',
 form: '<div class="wrapper"></div>',
 formData: '<div class="wrapper"></div>',
 image: '<div class="wrapperImg"></div>',
 gallery: '<div class="wrapperImg"><a href="#" class="nyroModalPrev">Prev</a><a href="#" class="nyroModalNext">Next</a></div>', // Use .nyroModalPrev and .nyroModalNext to set the navigation link
 swf: '<div class="wrapperSwf"></div>',
 iframe: '<div class="wrapperIframe"></div>',
 manual: '<div class="wrapper"></div>'
 },

 closeButton: '<a href="#" class="nyroModalClose" id="closeBut" title="close">Close</a>', // Adding automaticly as the first child of #nyroModalWrapper
 
 title: null, // Modal title
 titleFromIframe: true, // When using iframe in the same domain, try to get the title from it

 openSelector: '.nyroModal', // selector for open a new modal. will be used to parse automaticly at page loading
 closeSelector: '.nyroModalClose', // selector to close the modal

 contentLoading: '<a href="#" class="nyroModalClose">Cancel</a>', // Loading div content

 errorClass: 'error', // CSS Error class added to the loading div in case of error
 contentError: 'The requested content cannot be loaded.<br />Please try again later.<br /><a href="#" class="nyroModalClose">Close</a>', // Content placed in the loading div in case of error

 handleError: null, // Callback in case of error

 showBackground: showBackground, // Show background animation function
 hideBackground: hideBackground, // Hide background animation function

 endFillContent: null, // Will be called after filling and wraping the content, before parsing closeSelector and openSelector and showing the content
 showContent: showContent, // Show content animation function
 endShowContent: null, // Will be called once the content is shown
 beforeHideContent: null, // Will be called just before the modal closing
 hideContent: hideContent, // Hide content animation function

 showTransition: showTransition, // Show the transition animation (a modal is already shown and a new one is requested)
 hideTransition: hideTransition, // Hide the transition animation to show the content

 showLoading: showLoading, // show loading animation function
 hideLoading: hideLoading, // hide loading animation function

 resize: resize, // Resize animation function
 endResize: null, // Will be called one the content is resized

 updateBgColor: updateBgColor, // Change background color animation function

 endRemove: null // Will be called once the modal is totally gone
 };


 // -------------------------------------------------------
 // Private function
 // -------------------------------------------------------

 // Main function
 function processModal(settings) {
 if (modal.loadingShown || modal.transition || modal.anim)
 return;
 debug('processModal');
 modal.started = true;
 setDefaultCurrentSettings(settings);
 modal.error = false;
 modal.closing = false;
 modal.dataReady = false;
 modal.scripts = new Array();

 currentSettings.type = fileType();

 if ($.isFunction(currentSettings.processHandler))
 currentSettings.processHandler(currentSettings);

 from = currentSettings.from;
 url = currentSettings.url;

 if (currentSettings.type == 'swf') {
 // Swf is transforming as a raw content
 currentSettings.resizable = false;
 setCurrentSettings({overflow: 'hidden'}, 'css', 'content');
 currentSettings.content = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+currentSettings.width+'" height="'+currentSettings.height+'"><param name="movie" value="'+url+'"></param>';
 var tmp = '';
 $.each(currentSettings.swf, function(name, val) {
 currentSettings.content+= '<param name="'+name+'" value="'+val+'"></param>';
 tmp+= ' '+name+'="'+val+'"';
 });
 currentSettings.content+= '<embed src="'+url+'" type="application/x-shockwave-flash" width="'+currentSettings.width+'" height="'+currentSettings.height+'"'+tmp+'></embed></object>';
 }

 if (from) {
 var jFrom = $(from);
 if (currentSettings.type == 'form') {
 var data = $(from).serializeArray();
 data.push({name: currentSettings.formIndicator, value: 1});
 if (currentSettings.selector)
 data.push({name: currentSettings.selIndicator, value: currentSettings.selector.substring(1)});
 $.ajax($.extend({}, currentSettings.ajax, {
 url: url,
 data: data,
 type: from.method,
 success: ajaxLoaded,
 error: loadingError
 }));
 debug('Form Ajax Load: '+jFrom.attr('action'));
 showModal();
 } else if (currentSettings.type == 'formData') {
 // Form with data. We're using a hidden iframe
 initModal();
 jFrom.attr('target', 'nyroModalIframe');
 jFrom.attr('action', url);
 jFrom.prepend('<input type="hidden" name="'+currentSettings.formIndicator+'" value="1" />');
 if (currentSettings.selector)
 jFrom.prepend('<input type="hidden" name="'+currentSettings.selIndicator+'" value="'+currentSettings.selector.substring(1)+'" />');
 modal.tmp.html('<iframe frameborder="0" hspace="0" name="nyroModalIframe"></iframe>');
 $('iframe', modal.tmp)
 .css({
 width: currentSettings.width,
 height: currentSettings.height
 })
 .error(loadingError)
 .load(formDataLoaded);
 debug('Form Data Load: '+jFrom.attr('action'));
 showModal();
 showContentOrLoading();
 } else if (currentSettings.type == 'image' || currentSettings.type == 'gallery') {
 var title = jFrom.attr('title') || currentSettings.defaultImgAlt;
 initModal();
 modal.tmp.html('<img id="nyroModalImg" />').find('img').attr('alt', title);
 debug('Image Load: '+url);
 modal.tmp.css({lineHeight: 0});
 $('img', modal.tmp)
 .error(loadingError)
 .load(function() {
 debug('Image Loaded: '+this.src);
 $(this).unbind('load');
 var w = modal.tmp.width();
 var h = modal.tmp.height();
 modal.tmp.css({lineHeight: ''});
 setCurrentSettings({
 width: w,
 height: h,
 imgWidth: w,
 imgHeight: h
 });
 setCurrentSettings({overflow: 'hidden'}, 'css', 'content');
 modal.dataReady = true;
 if (modal.loadingShown || modal.transition)
 showContentOrLoading();
 })
 .attr('src', url);
 showModal();
 } else if (currentSettings.type == 'iframe') {
 initModal();
 modal.tmp.html('<iframe frameborder="0" hspace="0" src="'+url+'" name="nyroModalIframe"></iframe>');
 debug('Iframe Load: '+url);
 $('iframe', modal.tmp).eq(0)
 .css({
 width: '100%',
 height: isDoctypeStrict()? '99%' : '100%'
 })
 .load(function(e) {
 if (currentSettings.titleFromIframe && url.indexOf(window.location.hostname) > -1)
 $.nyroModalSettings({title: $('iframe', modal.full).contents().find('title').text()});
 });
 currentSettings.autoSizable = false;
 modal.dataReady = true;
 showModal();
 } else if (currentSettings.type) {
 // Could be every other kind of type or a dom selector
 debug('Content: '+currentSettings.type);
 initModal();
 modal.tmp.html(currentSettings.content);
 var w = modal.tmp.width();
 var h = modal.tmp.height();
 var div = $(currentSettings.type);
 if (div.length) {
 setCurrentSettings({type: 'div'});
 w = div.width();
 h = div.height();
 if (contentElt)
 contentEltLast = contentElt;
 contentElt = div;
 modal.tmp.append(div.contents());
 }
 setCurrentSettings({
 width: w,
 height: h
 });
 if (modal.tmp.html())
 modal.dataReady = true;
 else
 loadingError();
 showModal();
 showContentOrLoading();
 } else {
 debug('Ajax Load: '+url);
 setCurrentSettings({type: 'ajax'});
 var data = currentSettings.ajax.data || {};
 if (currentSettings.selector) {
 if (typeof data == "string") {
 data+= '&'+currentSettings.selIndicator+'='+currentSettings.selector.substring(1);
 } else {
 data[currentSettings.selIndicator] = currentSettings.selector.substring(1);
 }
 }
 $.ajax($.extend(true, currentSettings.ajax, {
 url: url,
 success: ajaxLoaded,
 error: loadingError,
 data: data
 }));
 showModal();
 }
 } else if (currentSettings.content) {
 // Raw content not from a DOM element
 debug('Content: '+currentSettings.type);
 setCurrentSettings({type: 'manual'});
 initModal();
 modal.tmp.html($('<div/>').html(currentSettings.content).contents());
 if (modal.tmp.html())
 modal.dataReady = true;
 else
 loadingError();
 showModal();
 } else {
 // What should we show here? nothing happen
 }
 }

 // Update the current settings
 // object settings
 // string deep1 first key where overwrite the settings
 // string deep2 second key where overwrite the settings
 function setDefaultCurrentSettings(settings) {
 debug('setDefaultCurrentSettings');
 currentSettings = $.extend({}, $.fn.nyroModal.settings, settings);
 currentSettings.selector = '';
 currentSettings.borderW = 0;
 currentSettings.borderH = 0;
 currentSettings.resizable = true;
 setMargin();
 }

 function setCurrentSettings(settings, deep1, deep2) {
 if (modal.started) {
 if (deep1 && deep2) {
 $.extend(currentSettings[deep1][deep2], settings);
 } else if (deep1) {
 $.extend(currentSettings[deep1], settings);
 } else {
 $.extend(currentSettings, settings);
 }
 } else {
 if (deep1 && deep2) {
 $.extend($.fn.nyroModal.settings[deep1][deep2], settings);
 } else if (deep1) {
 $.extend($.fn.nyroModal.settings[deep1], settings);
 } else {
 $.extend($.fn.nyroModal.settings, settings);
 }
 }
 }

 // Set the margin for postionning the element. Useful for IE6
 function setMarginScroll() {
 if (isIE6) {
 if (document.documentElement) {
 currentSettings.marginScrollLeft = document.documentElement.scrollLeft;
 currentSettings.marginScrollTop = document.documentElement.scrollTop;
 } else {
 currentSettings.marginScrollLeft = document.body.scrollLeft;
 currentSettings.marginScrollTop = document.body.scrollTop;
 }
 } else {
 currentSettings.marginScrollLeft = 0;
 currentSettings.marginScrollTop = 0;
 }
 }

 // Set the margin for the content
 function setMargin() {
 setMarginScroll();
 currentSettings.marginLeft = -(currentSettings.width+currentSettings.borderW)/2 + currentSettings.marginScrollLeft;
 currentSettings.marginTop = -(currentSettings.height+currentSettings.borderH)/2 + currentSettings.marginScrollTop;
 }

 // Set the margin for the current loading
 function setMarginloading() {
 setMarginScroll();
 var outer = getOuter(modal.loading);
 currentSettings.marginTopLoading = -(modal.loading.height() + outer.h.border + outer.h.padding)/2 + currentSettings.marginScrollTop;
 currentSettings.marginLeftLoading = -(modal.loading.width() + outer.w.border + outer.w.padding)/2 + currentSettings.marginScrollLeft;
 }

 // Init the nyroModal div by settings the CSS elements and hide needed elements
 function initModal() {
 debug('initModal');
 if (!modal.full) {
 if (currentSettings.debug)
 setCurrentSettings({color: 'white'}, 'css', 'bg');

 var iframeHideIE = '';
 if (isIE6) {
 body.css({
 height: body.height()+'px',
 width: body.width()+'px',
 position: 'static',
 overflow: 'hidden'
 });
 $('html').css({overflow: 'hidden'});
 setCurrentSettings({
 position: 'absolute',
 height: '110%',
 width: '110%',
 top: currentSettings.marginScrollTop+'px',
 left: currentSettings.marginScrollLeft+'px'
 }, 'css', 'bg');

 setCurrentSettings({position: 'absolute'}, 'css', 'loading');
 setCurrentSettings({position: 'absolute'}, 'css', 'wrapper');

 iframeHideIE = $('<iframe id="nyroModalIframeHideIe"></iframe>')
 .css($.extend({},
 currentSettings.css.bg, {
 opacity: 0,
 zIndex: 50,
 border: 'none'
 }));
 }

 body.append($('<div id="nyroModalFull"><div id="nyroModalBg"></div><div id="nyroModalWrapper"><div id="nyroModalContent"></div></div><div id="nyrModalTmp"></div><div id="nyroModalLoading"></div></div>').hide());

 modal.full = $('#nyroModalFull').show();
 modal.bg = $('#nyroModalBg')
 .css($.extend({
 backgroundColor: currentSettings.bgColor
 }, currentSettings.css.bg))
 .before(iframeHideIE);
 if (!currentSettings.modal)
 modal.bg.click(removeModal);
 modal.loading = $('#nyroModalLoading')
 .css(currentSettings.css.loading)
 .hide();
 modal.contentWrapper = $('#nyroModalWrapper')
 .css(currentSettings.css.wrapper)
 .hide();
 modal.content = $('#nyroModalContent');
 modal.tmp = $('#nyrModalTmp').hide();

 // To stop the mousewheel if the the plugin is available
 if ($.isFunction($.fn.mousewheel)) {
 modal.content.mousewheel(function(e, d) {
 var elt = modal.content.get(0);
 if ((d > 0 && elt.scrollTop == 0) ||
 (d < 0 && elt.scrollHeight - elt.scrollTop == elt.clientHeight)) {
 e.preventDefault();
 e.stopPropagation();
 }
 });
 }

 $(document).keydown(keyHandler);
 modal.content.css({width: 'auto', height: 'auto'});
 modal.contentWrapper.css({width: 'auto', height: 'auto'});
 }
 }

 // Show the modal (ie: the background and then the loading if needed or the content directly)
 function showModal() {
 debug('showModal');
 if (!modal.ready) {
 initModal();
 modal.anim = true;
 currentSettings.showBackground(modal, currentSettings, endBackground);
 } else {
 modal.anim = true;
 modal.transition = true;
 currentSettings.showTransition(modal, currentSettings, function(){endHideContent();modal.anim=false;showContentOrLoading();});
 }
 }

 // Used for the escape key or the arrow in the gallery type
 function keyHandler(e) {
 if (e.keyCode == 27) {
 if (!currentSettings.modal)
 removeModal();
 } else if (currentSettings.type == 'gallery' && modal.ready && modal.dataReady && !modal.anim && !modal.transition) {
 if (e.keyCode == 39 || e.keyCode == 40) {
 e.preventDefault();
 $('.nyroModalNext', modal.content).eq(0).trigger('click');
 return false;
 } else if (e.keyCode == 37 || e.keyCode == 38) {
 e.preventDefault();
 $('.nyroModalPrev', modal.content).eq(0).trigger('click');
 return false;
 }
 }
 }

 // Determine the filetype regarding the link DOM element
 function fileType() {
 if (currentSettings.forceType) {
 var tmp = currentSettings.forceType;
 if (!currentSettings.content)
 currentSettings.from = true;
 currentSettings.forceType = null;
 return tmp;
 }

 var from = currentSettings.from;

 var url;

 if (from && from.nodeName) {
 var jFrom = $(from);
 currentSettings.url = url = from.nodeName.toLowerCase() == 'form'? jFrom.attr('action') : from.href;

 if (jFrom.attr('rev') == 'modal')
 currentSettings.modal = true;

 if (jFrom.attr('title'))
 currentSettings.title = jFrom.attr('title');

 var imgType = imageType(url, from);
 if (imgType)
 return imgType;

 if (from.target && from.target.toLowerCase() == '_blank' || (from.hostname && from.hostname.replace(/:\d*$/,'') != window.location.hostname.replace(/:\d*$/,''))) {
 return 'iframe';
 } else if (from.nodeName.toLowerCase() == 'form') {
 setCurrentSettings(extractUrlSel(url));
 if (jFrom.attr('enctype') == 'multipart/form-data')
 return 'formData';
 return 'form';
 }
 } else {
 url = currentSettings.url;
 if (!currentSettings.content)
 currentSettings.from = true;

 if (!url)
 return null;

 var reg1 = new RegExp("^http://", "g");
 if (url.match(reg1))
 return 'iframe';
 }

 var imgType = imageType(url, from);
 if (imgType)
 return imgType;

 var swf = new RegExp('[^\.]\.(swf)\s*$', 'i');
 if (swf.test(url))
 return 'swf';

 var tmp = extractUrlSel(url);
 setCurrentSettings(tmp);

 if (!tmp.url)
 return tmp.selector;
 }

 function imageType(url, from) {
 var image = new RegExp(currentSettings.regexImg, 'i');
 if (image.test(url)) {
 if (from && from.rel)
 return 'gallery';
 else
 return 'image';
 }
 }

 function extractUrlSel(url) {
 var ret = {
 url: null,
 selector: null
 };

 if (url) {
 var hash = getHash(url);
 var hashLoc = getHash(window.location.href);
 var curLoc = window.location.href.substring(0, window.location.href.length - hashLoc.length);
 var req = url.substring(0, url.length - hash.length);

 if (req == curLoc) {
 ret.selector = hash;
 } else {
 ret.url = req;
 ret.selector = hash;
 }
 }
 return ret;
 }

 // Called when the content cannot be loaded or tiemout reached
 function loadingError() {
 debug('loadingError');

 modal.error = true;

 if (!modal.ready)
 return;

 if ($.isFunction(currentSettings.handleError))
 currentSettings.handleError(modal, currentSettings);

 modal.loading
 .addClass(currentSettings.errorClass)
 .html(currentSettings.contentError);
 $(currentSettings.closeSelector, modal.loading).click(removeModal);
 setMarginloading();
 modal.loading
 .css({
 marginTop: currentSettings.marginTopLoading+'px',
 marginLeft: currentSettings.marginLeftLoading+'px'
 });
 }

 // Put the content from modal.tmp to modal.content
 function fillContent() {
 debug('fillContent');
 if (!modal.tmp.html())
 return;

 modal.content.html(modal.tmp.contents());
 modal.tmp.empty();
 wrapContent();

 if ($.isFunction(currentSettings.endFillContent))
 currentSettings.endFillContent(modal, currentSettings);

 modal.content.append(modal.scripts);

 var currentSettingsNew = $.extend({}, currentSettings);
 if (resized.width)
 currentSettingsNew.width = null;
 if (resized.height)
 currentSettingsNew.height = null;
 $(currentSettings.closeSelector, modal.contentWrapper).click(removeModal);
 $(currentSettings.openSelector, modal.contentWrapper).nyroModal(currentSettingsNew);
 }

 // Wrap the content and update the modal size if needed
 function wrapContent() {
 debug('wrapContent');

 var wrap = $(currentSettings.wrap[currentSettings.type]);
 modal.content.append(wrap.children().remove());
 modal.contentWrapper.wrapInner(wrap);

 if (currentSettings.type == 'gallery') {
 // Set the action for the next and prev button (or remove them)

 var linkPrev = getGalleryLink(-1);
 if (linkPrev) {
 $('.nyroModalPrev', modal.contentWrapper)
 .attr('href', linkPrev.attr('href'))
 .click(function(e) {
 e.preventDefault();
 linkPrev.nyroModalManual(currentSettings);
 return false;
 });
 } else {
 $('.nyroModalPrev', modal.contentWrapper).remove();
 }
 var linkNext = getGalleryLink(1);
 if (linkNext) {
 $('.nyroModalNext', modal.contentWrapper)
 .attr('href', linkNext.attr('href'))
 .click(function(e) {
 e.preventDefault();
 linkNext.nyroModalManual(currentSettings);
 return false;
 });
 } else {
 $('.nyroModalNext', modal.contentWrapper).remove();
 }
 }

 calculateSize();
 }

 function getGalleryLink(dir) {
 if (currentSettings.type == 'gallery') {
 if (!currentSettings.ltr)
 dir *= -1;
 // next
 var gallery = $('[rel="'+currentSettings.from.rel+'"]');
 var currentIndex = gallery.index(currentSettings.from);
 var index = currentIndex + dir;
 if (index >= 0 && index < gallery.length)
 return gallery.eq(index);
 }
 return false;
 }

 // Calculate the size for the contentWrapper
 function calculateSize(resizing) {
 debug('calculateSize');

 if (!modal.wrapper)
 modal.wrapper = modal.contentWrapper.children(':first');

 resized.width = false;
 resized.height = false;
 if (currentSettings.autoSizable && (!currentSettings.width || !currentSettings.height)) {
 modal.contentWrapper.css({opacity: 0}).show();
 var tmp = {
 width: 'auto',
 height: 'auto'
 };
 if (currentSettings.width)
 tmp.width = currentSettings.width;
 if (currentSettings.height)
 tmp.height = currentSettings.height;
 modal.content.css(tmp);
 if (!currentSettings.width) {
 currentSettings.width = modal.content.width();
 resized.width = true;
 }
 if (!currentSettings.height) {
 currentSettings.height = modal.content.height();
 resized.height = true;
 }
 modal.contentWrapper.hide().css({opacity: 1});
 }

 currentSettings.width = Math.max(currentSettings.width, currentSettings.minWidth);
 currentSettings.height = Math.max(currentSettings.height, currentSettings.minHeight);

 var outerWrapper = getOuter(modal.contentWrapper);
 var outerWrapper2 = getOuter(modal.wrapper);
 var outerContent = getOuter(modal.content);

 var tmp = {
 content: {
 width: currentSettings.width,
 height: currentSettings.height
 },
 wrapper2: {
 width: currentSettings.width + outerContent.w.total,
 height: currentSettings.height + outerContent.h.total
 },
 wrapper: {
 width: currentSettings.width + outerContent.w.total + outerWrapper2.w.total,
 height: currentSettings.height + outerContent.h.total + outerWrapper2.h.total
 }
 };

 if (currentSettings.resizable) {
 var maxHeight = $(window).height()
 - currentSettings.padding*2
 - outerWrapper.h.border
 - (tmp.wrapper.height - currentSettings.height);
 var maxWidth = $(window).width()
 - currentSettings.padding*2
 - outerWrapper.w.border
 - (tmp.wrapper.width - currentSettings.width);

 if (tmp.content.height > maxHeight || tmp.content.width > maxWidth) {
 // We're gonna resize the modal as it will goes outside the view port
 if (currentSettings.type == 'image' || currentSettings.type == 'gallery') {
 // An image is resized proportionnaly
 var diffW = tmp.content.width - currentSettings.imgWidth;
 var diffH = tmp.content.height - currentSettings.imgHeight;
 if (diffH < 0) diffH = 0;
 if (diffW < 0) diffW = 0;
 var calcH = maxHeight - diffH;
 var calcW = maxWidth - diffW;
 var ratio = Math.min(calcH/currentSettings.imgHeight, calcW/currentSettings.imgWidth);

 calcH = Math.floor(currentSettings.imgHeight*ratio);
 calcW = Math.floor(currentSettings.imgWidth*ratio);
 $('img#nyroModalImg', modal.content).css({
 height: calcH+'px',
 width: calcW+'px'
 });
 tmp.content.height = calcH + diffH;
 tmp.content.width = calcW + diffW;
 } else {
 // For an HTML content, we simply decrease the size
 tmp.content.height = Math.min(tmp.content.height, maxHeight);
 tmp.content.width = Math.min(tmp.content.width, maxWidth);
 }
 tmp.wrapper2 = {
 width: tmp.content.width + outerContent.w.total,
 height: tmp.content.height + outerContent.h.total
 };
 tmp.wrapper = {
 width: tmp.content.width + outerContent.w.total + outerWrapper2.w.total,
 height: tmp.content.height + outerContent.h.total + outerWrapper2.h.total
 };
 }
 }

 modal.content.css($.extend({}, tmp.content, currentSettings.css.content));
 modal.wrapper.css($.extend({}, tmp.wrapper2, currentSettings.css.wrapper2));

 if (!resizing) {
 modal.contentWrapper.css($.extend({}, tmp.wrapper, currentSettings.css.wrapper));
 if (currentSettings.type == 'image' || currentSettings.type == 'gallery') {
 // Adding the title for the image
 var title = $('img', modal.content).attr('alt');
 $('img', modal.content).removeAttr('alt');
 if (title != currentSettings.defaultImgAlt) {
 var divTitle = $('<div>'+title+'</div>');
 modal.content.append(divTitle);
 if (currentSettings.setWidthImgTitle) {
 var outerDivTitle = getOuter(divTitle);
 divTitle.css({width: (tmp.content.width + outerContent.w.padding - outerDivTitle.w.total)+'px'});
 }
 }
 }

 if (!currentSettings.modal)
 modal.contentWrapper.prepend(currentSettings.closeButton);
 }

 if (currentSettings.title)
 modal.contentWrapper.prepend('<h1 id="nyroModalTitle">'+currentSettings.title+'</h1>');

 tmp.wrapper.borderW = outerWrapper.w.border;
 tmp.wrapper.borderH = outerWrapper.h.border;

 setCurrentSettings(tmp.wrapper);
 setMargin();
 }

 function removeModal(e) {
 debug('removeModal');
 if (e)
 e.preventDefault();
 if (modal.full && modal.ready) {
 modal.ready = false;
 modal.anim = true;
 modal.closing = true;
 if (modal.loadingShown || modal.transition) {
 currentSettings.hideLoading(modal, currentSettings, function() {
 modal.loading.hide();
 modal.loadingShown = false;
 modal.transition = false;
 currentSettings.hideBackground(modal, currentSettings, endRemove);
 });
 } else {
 if (fixFF)
 modal.content.css({position: ''}); // Fix Issue #10, remove the attribute
 modal.wrapper.css({overflow: 'hidden'}); // Used to fix a visual issue when hiding
 modal.content.css({overflow: 'hidden'}); // Used to fix a visual issue when hiding
 if ($.isFunction(currentSettings.beforeHideContent)) {
 currentSettings.beforeHideContent(modal, currentSettings, function() {
 currentSettings.hideContent(modal, currentSettings, function() {
 endHideContent();
 currentSettings.hideBackground(modal, currentSettings, endRemove);
 });
 });
 } else {
 currentSettings.hideContent(modal, currentSettings, function() {
 endHideContent();
 currentSettings.hideBackground(modal, currentSettings, endRemove);
 });
 }
 }
 }
 if (e)
 return false;
 }

 function showContentOrLoading() {
 debug('showContentOrLoading');
 if (modal.ready && !modal.anim) {
 if (modal.dataReady) {
 if (modal.tmp.html()) {
 modal.anim = true;
 if (modal.transition) {
 fillContent();
 currentSettings.hideTransition(modal, currentSettings, function() {
 modal.loading.hide();
 modal.transition = false;
 modal.loadingShown = false;
 endShowContent();
 });
 } else {
 currentSettings.hideLoading(modal, currentSettings, function() {
 modal.loading.hide();
 modal.loadingShown = false;
 fillContent();
 setMarginloading();
 currentSettings.showContent(modal, $.extend({}, currentSettings), endShowContent);
 });
 }
 }
 } else if (!modal.loadingShown && !modal.transition) {
 modal.anim = true;
 modal.loadingShown = true;
 if (modal.error)
 loadingError();
 else
 modal.loading.html(currentSettings.contentLoading);
 $(currentSettings.closeSelector, modal.loading).click(removeModal);
 setMarginloading();
 currentSettings.showLoading(modal, currentSettings, function(){modal.anim=false;showContentOrLoading();});
 }
 }
 }


 // -------------------------------------------------------
 // Private Data Loaded callback
 // -------------------------------------------------------

 function ajaxLoaded(data) {
 debug('AjaxLoaded: '+this.url);
 modal.tmp.html(currentSettings.selector
 ?filterScripts($('<div>'+data+'</div>').find(currentSettings.selector).contents())
 :filterScripts(data));
 if (modal.tmp.html()) {
 modal.dataReady = true;
 showContentOrLoading();
 } else
 loadingError();
 }

 function formDataLoaded() {
 debug('formDataLoaded');
 var jFrom = $(currentSettings.from);
 jFrom.attr('action', jFrom.attr('action')+currentSettings.selector);
 jFrom.attr('target', '');
 $('input[name='+currentSettings.formIndicator+']', currentSettings.from).remove();
 var iframe = modal.tmp.children('iframe');
 var iframeContent = iframe.unbind('load').contents().find(currentSettings.selector || 'body').not('script[src]');
 iframe.attr('src', 'about:blank'); // Used to stop the loading in FF
 modal.tmp.html(iframeContent.html());
 if (modal.tmp.html()) {
 modal.dataReady = true;
 showContentOrLoading();
 } else
 loadingError();
 }


 // -------------------------------------------------------
 // Private Animation callback
 // -------------------------------------------------------

 function endHideContent() {
 debug('endHideContent');
 modal.anim = false;
 if (contentEltLast) {
 contentEltLast.append(modal.content.contents());
 contentEltLast= null;
 } else if (contentElt) {
 contentElt.append(modal.content.contents());
 contentElt= null;
 }
 modal.content.empty();
 modal.contentWrapper
 .empty()
 .removeAttr('style');

 if (modal.closing || modal.transition)
 modal.contentWrapper.hide();

 modal.contentWrapper
 .css(currentSettings.css.wrapper)
 .append(modal.content);
 showContentOrLoading();
 }

 function endRemove() {
 debug('endRemove');
 $(document).unbind('keydown', keyHandler);
 modal.anim = false;
 modal.full.remove();
 modal.full = null;
 if (isIE6) {
 body.css({height: '', width: '', position: '', overflow: ''});
 $('html').css({overflow: ''});
 }
 if ($.isFunction(currentSettings.endRemove))
 currentSettings.endRemove(modal, currentSettings);
 }

 function endBackground() {
 debug('endBackground');
 modal.ready = true;
 modal.anim = false;
 showContentOrLoading();
 }

 function endShowContent() {
 debug('endShowContent');
 modal.anim = false;
 modal.contentWrapper.css({opacity: ''}); // for the close button in IE
 fixFF = $.browser.mozilla && parseFloat($.browser.version) < 1.9 && currentSettings.type != 'gallery' && currentSettings.type != 'image';
 if (fixFF)
 modal.content.css({position: 'fixed'}); // Fix Issue #10
 if ($.isFunction(currentSettings.endShowContent))
 currentSettings.endShowContent(modal, currentSettings);
 if (resized.width)
 setCurrentSettings({width: null});
 if (resized.height)
 setCurrentSettings({height: null});
 }


 // -------------------------------------------------------
 // Utilities
 // -------------------------------------------------------

 // Get the selector from an url (as string)
 function getHash(url) {
 if (typeof url == 'string') {
 var hashPos = url.indexOf('#');
 if (hashPos > -1)
 return url.substring(hashPos);
 }
 return '';
 }

 // Filter an html content to remove the script[src]
 function filterScripts(data) {
 // Removing the body, head and html tag
 if (typeof data == 'string')
 data = data.replace(/<\/?(html|head|body)([^>]*)>/gi, '');
 var tmp = new Array();
 $.each($.clean({0:data}, this.ownerDocument), function() {
 if ($.nodeName(this, "script")) {
 if (!this.src || $(this).attr('rel') == 'forceLoad')
 modal.scripts.push(this);
 } else
 tmp.push(this);
 });
 return tmp;
 }

 // Get the vertical and horizontal margin, padding and border dimension
 function getOuter(elm) {
 elm = elm.get(0);
 var ret = {
 h: {
 margin: getCurCSS(elm, 'marginTop') + getCurCSS(elm, 'marginBottom'),
 border: getCurCSS(elm, 'borderTopWidth') + getCurCSS(elm, 'borderBottomWidth'),
 padding: getCurCSS(elm, 'paddingTop') + getCurCSS(elm, 'paddingBottom')
 },
 w: {
 margin: getCurCSS(elm, 'marginLeft') + getCurCSS(elm, 'marginRight'),
 border: getCurCSS(elm, 'borderLeftWidth') + getCurCSS(elm, 'borderRightWidth'),
 padding: getCurCSS(elm, 'paddingLeft') + getCurCSS(elm, 'paddingRight')
 }
 };

 ret.h.outer = ret.h.margin + ret.h.border;
 ret.w.outer = ret.w.margin + ret.w.border;

 ret.h.inner = ret.h.padding + ret.h.border;
 ret.w.inner = ret.w.padding + ret.w.border;

 ret.h.total = ret.h.outer + ret.h.padding;
 ret.w.total = ret.w.outer + ret.w.padding;

 return ret;
 }

 function getCurCSS(elm, name) {
 var ret = parseInt($.curCSS(elm, name, true));
 if (isNaN(ret))
 ret = 0;
 return ret;
 }

 function isDoctypeStrict() {
 var doctype = '';
 if ($.browser.opera) {
 return true;
 } else if ($.browser.msie) {
 var re = /\s+(X?HTML)\s+([\d\.]+)\s*([^\/]+)*\//gi;
 var res = false;
 if($.browser.msie)
 res = document.all[0].nodeType == 8 ? re.test(document.all[0].nodeValue) : false;
 if (res)
 doctype = RegExp.$3;
 } else
 doctype = document.doctype.systemId;
 return doctype.toLowerCase().indexOf('strict') > -1
 }

 // Proxy Debug function
 function debug(msg) {
 if ($.fn.nyroModal.settings.debug || currentSettings && currentSettings.debug)
 nyroModalDebug(msg, modal, currentSettings || {});
 }

 // -------------------------------------------------------
 // Default animation function
 // -------------------------------------------------------

 function showBackground(elts, settings, callback) {
 elts.bg.css({opacity:0}).fadeTo(500, 0.75, callback);
 }

 function hideBackground(elts, settings, callback) {
 elts.bg.fadeOut(300, callback);
 }

 function showLoading(elts, settings, callback) {
 elts.loading
 .css({
 marginTop: settings.marginTopLoading+'px',
 marginLeft: settings.marginLeftLoading+'px',
 opacity: 0
 })
 .show()
 .animate({
 opacity: 1
 }, {complete: callback, duration: 400});
 }

 function hideLoading(elts, settings, callback) {
 callback();
 }

 function showContent(elts, settings, callback) {
 elts.loading
 .css({
 marginTop: settings.marginTopLoading+'px',
 marginLeft: settings.marginLeftLoading+'px'
 })
 .show()
 .animate({
 width: settings.width+'px',
 height: settings.height+'px',
 marginTop: settings.marginTop+'px',
 marginLeft: settings.marginLeft+'px'
 }, {duration: 350, complete: function() {
 elts.contentWrapper
 .css({
 width: settings.width+'px',
 height: settings.height+'px',
 marginTop: settings.marginTop+'px',
 marginLeft: settings.marginLeft+'px'
 })
 .show();
 elts.loading.fadeOut(200, callback);
 }
 });
 }

 function hideContent(elts, settings, callback) {
 elts.contentWrapper
 .animate({
 height: '50px',
 width: '50px',
 marginTop: (-(25+settings.borderH)/2 + settings.marginScrollTop)+'px',
 marginLeft: (-(25+settings.borderW)/2 + settings.marginScrollLeft)+'px'
 }, {duration: 350, complete: function() {
 elts.contentWrapper.hide();
 callback();
 }});
 }

 function showTransition(elts, settings, callback) {
 // Put the loading with the same dimensions of the current content
 elts.loading
 .css({
 marginTop: elts.contentWrapper.css('marginTop'),
 marginLeft: elts.contentWrapper.css('marginLeft'),
 height: elts.contentWrapper.css('height'),
 width: elts.contentWrapper.css('width'),
 opacity: 0
 })
 .show()
 .fadeTo(400, 1, function() {
 elts.contentWrapper.hide();
 callback();
 });
 }

 function hideTransition(elts, settings, callback) {
 // Place the content wrapper underneath the the loading with the right dimensions
 elts.contentWrapper
 .hide()
 .css({
 width: settings.width+'px',
 marginLeft: settings.marginLeft+'px',
 height: settings.height+'px',
 marginTop: settings.marginTop+'px',
 opacity: 1
 });
 elts.loading
 .animate({
 width: settings.width+'px',
 marginLeft: settings.marginLeft+'px',
 height: settings.height+'px',
 marginTop: settings.marginTop+'px'
 }, {complete: function() {
 elts.contentWrapper.show();
 elts.loading.fadeOut(400, function() {
 elts.loading.hide();
 callback();
 });
 }, duration: 350});
 }

 function resize(elts, settings, callback) {
 elts.contentWrapper
 .animate({
 width: settings.width+'px',
 marginLeft: settings.marginLeft+'px',
 height: settings.height+'px',
 marginTop: settings.marginTop+'px'
 }, {complete: callback, duration: 400});
 }

 function updateBgColor(elts, settings, callback) {
 if (!$.fx.step.backgroundColor) {
 elts.bg.css({backgroundColor: settings.bgColor});
 callback();
 } else
 elts.bg
 .animate({
 backgroundColor: settings.bgColor
 }, {complete: callback, duration: 400});
 }

 // -------------------------------------------------------
 // Default initialization
 // -------------------------------------------------------

 $($.fn.nyroModal.settings.openSelector).nyroModal();

});

// Default debug function, to be overwritten if needed
// Be aware that the settings parameter could be empty
function nyroModalDebug(msg, elts, settings) {
 //console.log(msg);
 if (elts.full)
 elts.bg.prepend(msg+'<br />');
}
/*
 * jQuery UI 1.6rc6
 *
 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */
;(function($) {

var _remove = $.fn.remove,
 isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9);

//Helper functions and ui object
$.ui = {
 version: "1.6rc6",

 // $.ui.plugin is deprecated. Use the proxy pattern instead.
 plugin: {
 add: function(module, option, set) {
 var proto = $.ui[module].prototype;
 for(var i in set) {
 proto.plugins[i] = proto.plugins[i] || [];
 proto.plugins[i].push([option, set[i]]);
 }
 },
 call: function(instance, name, args) {
 var set = instance.plugins[name];
 if(!set) { return; }

 for (var i = 0; i < set.length; i++) {
 if (instance.options[set[i][0]]) {
 set[i][1].apply(instance.element, args);
 }
 }
 }
 },

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

 cssCache: {},
 css: function(name) {
 if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; }
 var tmp = $('<div class="ui-gen"></div>').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body');

 //if (!$.browser.safari)
 //tmp.appendTo('body');

 //Opera and Safari set width and height to 0px instead of auto
 //Safari returns rgba(0,0,0,0) when bgcolor is not set
 $.ui.cssCache[name] = !!(
 (!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) ||
 !(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor')))
 );
 try { $('body').get(0).removeChild(tmp.get(0)); } catch(e){}
 return $.ui.cssCache[name];
 },

 hasScroll: function(el, a) {

 //If overflow is hidden, the element might have extra content, but the user wants to hide it
 if ($(el).css('overflow') == 'hidden') { return false; }

 var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
 has = false;

 if (el[scroll] > 0) { return true; }

 // TODO: determine which cases actually cause this to happen
 // if the element doesn't have the scroll set, see if it's possible to
 // set the scroll
 el[scroll] = 1;
 has = (el[scroll] > 0);
 el[scroll] = 0;
 return has;
 },

 isOverAxis: function(x, reference, size) {
 //Determines when x coordinate is over "b" element axis
 return (x > reference) && (x < (reference + size));
 },

 isOver: function(y, x, top, left, height, width) {
 //Determines when x, y coordinates is over "b" element
 return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
 },

 keyCode: {
 BACKSPACE: 8,
 CAPS_LOCK: 20,
 COMMA: 188,
 CONTROL: 17,
 DELETE: 46,
 DOWN: 40,
 END: 35,
 ENTER: 13,
 ESCAPE: 27,
 HOME: 36,
 INSERT: 45,
 LEFT: 37,
 NUMPAD_ADD: 107,
 NUMPAD_DECIMAL: 110,
 NUMPAD_DIVIDE: 111,
 NUMPAD_ENTER: 108,
 NUMPAD_MULTIPLY: 106,
 NUMPAD_SUBTRACT: 109,
 PAGE_DOWN: 34,
 PAGE_UP: 33,
 PERIOD: 190,
 RIGHT: 39,
 SHIFT: 16,
 SPACE: 32,
 TAB: 9,
 UP: 38
 }
};

// WAI-ARIA normalization
if (isFF2) {
 var attr = $.attr,
 removeAttr = $.fn.removeAttr,
 ariaNS = "http://www.w3.org/2005/07/aaa",
 ariaState = /^aria-/,
 ariaRole = /^wairole:/;

 $.attr = function(elem, name, value) {
 var set = value !== undefined;

 return (name == 'role'
 ? (set
 ? attr.call(this, elem, name, "wairole:" + value)
 : (attr.apply(this, arguments) || "").replace(ariaRole, ""))
 : (ariaState.test(name)
 ? (set
 ? elem.setAttributeNS(ariaNS,
 name.replace(ariaState, "aaa:"), value)
 : attr.call(this, elem, name.replace(ariaState, "aaa:")))
 : attr.apply(this, arguments)));
 };

 $.fn.removeAttr = function(name) {
 return (ariaState.test(name)
 ? this.each(function() {
 this.removeAttributeNS(ariaNS, name.replace(ariaState, ""));
 }) : removeAttr.call(this, name));
 };
}

//jQuery plugins
$.fn.extend({
 remove: function() {
 // Safari has a native remove event which actually removes DOM elements,
 // so we have to use triggerHandler instead of trigger (#3037).
 $("*", this).add(this).each(function() {
 $(this).triggerHandler("remove");
 });
 return _remove.apply(this, arguments );
 },

 enableSelection: function() {
 return this
 .attr('unselectable', 'off')
 .css('MozUserSelect', '')
 .unbind('selectstart.ui');
 },

 disableSelection: function() {
 return this
 .attr('unselectable', 'on')
 .css('MozUserSelect', 'none')
 .bind('selectstart.ui', function() { return false; });
 },

 scrollParent: function() {
 var scrollParent;
 if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
 scrollParent = this.parents().filter(function() {
 return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
 }).eq(0);
 } else {
 scrollParent = this.parents().filter(function() {
 return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
 }).eq(0);
 }

 return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
 }
});


//Additional selectors
$.extend($.expr[':'], {
 data: function(elem, i, match) {
 return !!$.data(elem, match[3]);
 },

 focusable: function(element) {
 var nodeName = element.nodeName.toLowerCase(),
 tabIndex = $.attr(element, 'tabindex');
 return (/input|select|textarea|button|object/.test(nodeName)
 ? !element.disabled
 : 'a' == nodeName || 'area' == nodeName
 ? element.href || !isNaN(tabIndex)
 : !isNaN(tabIndex))
 // the element and all of its ancestors must be visible
 // the browser may report that the area is hidden
 && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length;
 },

 tabbable: function(element) {
 var tabIndex = $.attr(element, 'tabindex');
 return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable');
 }
});


// $.widget is a factory to create jQuery plugins
// taking some boilerplate code out of the plugin code
function getter(namespace, plugin, method, args) {
 function getMethods(type) {
 var methods = $[namespace][plugin][type] || [];
 return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
 }

 var methods = getMethods('getter');
 if (args.length == 1 && typeof args[0] == 'string') {
 methods = methods.concat(getMethods('getterSetter'));
 }
 return ($.inArray(method, methods) != -1);
}

$.widget = function(name, prototype) {
 var namespace = name.split(".")[0];
 name = name.split(".")[1];

 // create plugin method
 $.fn[name] = function(options) {
 var isMethodCall = (typeof options == 'string'),
 args = Array.prototype.slice.call(arguments, 1);

 // prevent calls to internal methods
 if (isMethodCall && options.substring(0, 1) == '_') {
 return this;
 }

 // handle getter methods
 if (isMethodCall && getter(namespace, name, options, args)) {
 var instance = $.data(this[0], name);
 return (instance ? instance[options].apply(instance, args)
 : undefined);
 }

 // handle initialization and non-getter methods
 return this.each(function() {
 var instance = $.data(this, name);

 // constructor
 (!instance && !isMethodCall &&
 $.data(this, name, new $[namespace][name](this, options))._init());

 // method call
 (instance && isMethodCall && $.isFunction(instance[options]) &&
 instance[options].apply(instance, args));
 });
 };

 // create widget constructor
 $[namespace] = $[namespace] || {};
 $[namespace][name] = function(element, options) {
 var self = this;

 this.namespace = namespace;
 this.widgetName = name;
 this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
 this.widgetBaseClass = namespace + '-' + name;

 this.options = $.extend({},
 $.widget.defaults,
 $[namespace][name].defaults,
 $.metadata && $.metadata.get(element)[name],
 options);

 this.element = $(element)
 .bind('setData.' + name, function(event, key, value) {
 if (event.target == element) {
 return self._setData(key, value);
 }
 })
 .bind('getData.' + name, function(event, key) {
 if (event.target == element) {
 return self._getData(key);
 }
 })
 .bind('remove', function() {
 return self.destroy();
 });
 };

 // add widget prototype
 $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);

 // TODO: merge getter and getterSetter properties from widget prototype
 // and plugin prototype
 $[namespace][name].getterSetter = 'option';
};

$.widget.prototype = {
 _init: function() {},
 destroy: function() {
 this.element.removeData(this.widgetName)
 .removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled')
 .removeAttr('aria-disabled');
 },

 option: function(key, value) {
 var options = key,
 self = this;

 if (typeof key == "string") {
 if (value === undefined) {
 return this._getData(key);
 }
 options = {};
 options[key] = value;
 }

 $.each(options, function(key, value) {
 self._setData(key, value);
 });
 },
 _getData: function(key) {
 return this.options[key];
 },
 _setData: function(key, value) {
 this.options[key] = value;

 if (key == 'disabled') {
 this.element
 [value ? 'addClass' : 'removeClass'](
 this.widgetBaseClass + '-disabled' + ' ' +
 this.namespace + '-state-disabled')
 .attr("aria-disabled", value);
 }
 },

 enable: function() {
 this._setData('disabled', false);
 },
 disable: function() {
 this._setData('disabled', true);
 },

 _trigger: function(type, event, data) {
 var callback = this.options[type],
 eventName = (type == this.widgetEventPrefix
 ? type : this.widgetEventPrefix + type);

 event = $.Event(event);
 event.type = eventName;

 // copy original event properties over to the new event
 // this would happen if we could call $.event.fix instead of $.Event
 // but we don't have a way to force an event to be fixed multiple times
 if (event.originalEvent) {
 for (var i = $.event.props.length, prop; i;) {
 prop = $.event.props[--i];
 event[prop] = event.originalEvent[prop];
 }
 }

 this.element.trigger(event, data);

 return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false
 || event.isDefaultPrevented());
 }
};

$.widget.defaults = {
 disabled: false
};


/** Mouse Interaction Plugin **/

$.ui.mouse = {
 _mouseInit: function() {
 var self = this;

 this.element
 .bind('mousedown.'+this.widgetName, function(event) {
 return self._mouseDown(event);
 })
 .bind('click.'+this.widgetName, function(event) {
 if(self._preventClickEvent) {
 self._preventClickEvent = false;
 return false;
 }
 });

 // Prevent text selection in IE
 if ($.browser.msie) {
 this._mouseUnselectable = this.element.attr('unselectable');
 this.element.attr('unselectable', 'on');
 }

 this.started = false;
 },

 // TODO: make sure destroying one instance of mouse doesn't mess with
 // other instances of mouse
 _mouseDestroy: function() {
 this.element.unbind('.'+this.widgetName);

 // Restore text selection in IE
 ($.browser.msie
 && this.element.attr('unselectable', this._mouseUnselectable));
 },

 _mouseDown: function(event) {
 // don't let more than one widget handle mouseStart
 if (event.originalEvent.mouseHandled) { return; }

 // we may have missed mouseup (out of window)
 (this._mouseStarted && this._mouseUp(event));

 this._mouseDownEvent = event;

 var self = this,
 btnIsLeft = (event.which == 1),
 elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
 if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
 return true;
 }

 this.mouseDelayMet = !this.options.delay;
 if (!this.mouseDelayMet) {
 this._mouseDelayTimer = setTimeout(function() {
 self.mouseDelayMet = true;
 }, this.options.delay);
 }

 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
 this._mouseStarted = (this._mouseStart(event) !== false);
 if (!this._mouseStarted) {
 event.preventDefault();
 return true;
 }
 }

 // these delegates are required to keep context
 this._mouseMoveDelegate = function(event) {
 return self._mouseMove(event);
 };
 this._mouseUpDelegate = function(event) {
 return self._mouseUp(event);
 };
 $(document)
 .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
 .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);

 // preventDefault() is used to prevent the selection of text here -
 // however, in Safari, this causes select boxes not to be selectable
 // anymore, so this fix is needed
 ($.browser.safari || event.preventDefault());

 event.originalEvent.mouseHandled = true;
 return true;
 },

 _mouseMove: function(event) {
 // IE mouseup check - mouseup happened when mouse was out of window
 if ($.browser.msie && !event.button) {
 return this._mouseUp(event);
 }

 if (this._mouseStarted) {
 this._mouseDrag(event);
 return event.preventDefault();
 }

 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
 this._mouseStarted =
 (this._mouseStart(this._mouseDownEvent, event) !== false);
 (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
 }

 return !this._mouseStarted;
 },

 _mouseUp: function(event) {
 $(document)
 .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
 .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);

 if (this._mouseStarted) {
 this._mouseStarted = false;
 this._preventClickEvent = true;
 this._mouseStop(event);
 }

 return false;
 },

 _mouseDistanceMet: function(event) {
 return (Math.max(
 Math.abs(this._mouseDownEvent.pageX - event.pageX),
 Math.abs(this._mouseDownEvent.pageY - event.pageY)
 ) >= this.options.distance
 );
 },

 _mouseDelayMet: function(event) {
 return this.mouseDelayMet;
 },

 // These are placeholder methods, to be overriden by extending plugin
 _mouseStart: function(event) {},
 _mouseDrag: function(event) {},
 _mouseStop: function(event) {},
 _mouseCapture: function(event) { return true; }
};

$.ui.mouse.defaults = {
 cancel: null,
 distance: 1,
 delay: 0
};

})(jQuery);

/*
 * jQuery UI Datepicker 1.6rc6
 *
 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Datepicker
 *
 * Depends:
 * ui.core.js
 */

(function($) { // hide the namespace

$.extend($.ui, { datepicker: { version: "1.6rc6" } });

var PROP_NAME = 'datepicker';

/* Date picker manager.
 Use the singleton instance of this class, $.datepicker, to interact with the date picker.
 Settings for (groups of) date pickers are maintained in an instance object,
 allowing multiple different settings on the same page. */

function Datepicker() {
 this.debug = false; // Change this to true to start debugging
 this._curInst = null; // The current instance in use
 this._keyEvent = false; // If the last event was a key event
 this._disabledInputs = []; // List of date picker inputs that have been disabled
 this._datepickerShowing = false; // True if the popup picker is showing , false if not
 this._inDialog = false; // True if showing within a "dialog", false if not
 this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
 this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
 this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
 this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
 this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
 this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
 this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
 this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
 this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
 this.regional = []; // Available regional settings, indexed by language code
 this.regional[''] = { // Default regional settings
 closeText: 'Done', // Display text for close link
 prevText: 'Prev', // Display text for previous month link
 nextText: 'Next', // Display text for next month link
 currentText: 'Today', // Display text for current month link
 monthNames: ['January','February','March','April','May','June',
 'July','August','September','October','November','December'], // Names of months for drop-down and formatting
 monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
 dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
 dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
 dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
 dateFormat: 'mm/dd/yy', // See format options on parseDate
 firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
 isRTL: false // True if right-to-left language, false if left-to-right
 };
 this._defaults = { // Global defaults for all the date picker instances
 showOn: 'focus', // 'focus' for popup on focus,
 // 'button' for trigger button, or 'both' for either
 showAnim: 'show', // Name of jQuery animation for popup
 showOptions: {}, // Options for enhanced animations
 defaultDate: null, // Used when field is blank: actual date,
 // +/-number for offset from today, null for today
 appendText: '', // Display text following the input box, e.g. showing the format
 buttonText: '...', // Text for trigger button
 buttonImage: '', // URL for trigger button image
 buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
 hideIfNoPrevNext: false, // True to hide next/previous month links
 // if not applicable, false to just disable them
 navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
 gotoCurrent: false, // True if today link goes back to current selection instead
 changeMonth: false, // True if month can be selected directly, false if only prev/next
 changeYear: false, // True if year can be selected directly, false if only prev/next
 showMonthAfterYear: false, // True if the year select precedes month, false for month then year
 yearRange: '-10:+10', // Range of years to display in drop-down,
 // either relative to current year (-nn:+nn) or absolute (nnnn:nnnn)
 showOtherMonths: false, // True to show dates in other months, false to leave blank
 calculateWeek: this.iso8601Week, // How to calculate the week of the year,
 // takes a Date and returns the number of the week for it
 shortYearCutoff: '+10', // Short year values < this are in the current century,
 // > this are in the previous century,
 // string value starting with '+' for current year + value
 minDate: null, // The earliest selectable date, or null for no limit
 maxDate: null, // The latest selectable date, or null for no limit
 duration: 'normal', // Duration of display/closure
 beforeShowDay: null, // Function that takes a date and returns an array with
 // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
 // [2] = cell title (optional), e.g. $.datepicker.noWeekends
 beforeShow: null, // Function that takes an input field and
 // returns a set of custom settings for the date picker
 onSelect: null, // Define a callback function when a date is selected
 onChangeMonthYear: null, // Define a callback function when the month or year is changed
 onClose: null, // Define a callback function when the datepicker is closed
 numberOfMonths: 1, // Number of months to show at a time
 showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
 stepMonths: 1, // Number of months to step back/forward
 stepBigMonths: 12, // Number of months to step back/forward for the big links
 altField: '', // Selector for an alternate field to store selected dates into
 altFormat: '', // The date format to use for the alternate field
 constrainInput: true, // The input is constrained by the current date format
 showButtonPanel: false // True to show button panel, false to not show it
 };
 $.extend(this._defaults, this.regional['']);
 this.dpDiv = $('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible"></div>');
}

$.extend(Datepicker.prototype, {
 /* Class name added to elements to indicate already configured with a date picker. */
 markerClassName: 'hasDatepicker',

 /* Debug logging (if enabled). */
 log: function () {
 if (this.debug)
 console.log.apply('', arguments);
 },

 /* Override the default settings for all instances of the date picker.
 @param settings object - the new settings to use as defaults (anonymous object)
 @return the manager object */
 setDefaults: function(settings) {
 extendRemove(this._defaults, settings || {});
 return this;
 },

 /* Attach the date picker to a jQuery selection.
 @param target element - the target input field or division or span
 @param settings object - the new settings to use for this date picker instance (anonymous) */
 _attachDatepicker: function(target, settings) {
 // check for settings on the control itself - in namespace 'date:'
 var inlineSettings = null;
 for (var attrName in this._defaults) {
 var attrValue = target.getAttribute('date:' + attrName);
 if (attrValue) {
 inlineSettings = inlineSettings || {};
 try {
 inlineSettings[attrName] = eval(attrValue);
 } catch (err) {
 inlineSettings[attrName] = attrValue;
 }
 }
 }
 var nodeName = target.nodeName.toLowerCase();
 var inline = (nodeName == 'div' || nodeName == 'span');
 if (!target.id)
 target.id = 'dp' + (++this.uuid);
 var inst = this._newInst($(target), inline);
 inst.settings = $.extend({}, settings || {}, inlineSettings || {});
 if (nodeName == 'input') {
 this._connectDatepicker(target, inst);
 } else if (inline) {
 this._inlineDatepicker(target, inst);
 }
 },

 /* Create a new instance object. */
 _newInst: function(target, inline) {
 var id = target[0].id.replace(/([:\[\]\.])/g, '\\\\$1'); // escape jQuery meta chars
 return {id: id, input: target, // associated target
 selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
 drawMonth: 0, drawYear: 0, // month being drawn
 inline: inline, // is datepicker inline or not
 dpDiv: (!inline ? this.dpDiv : // presentation div
 $('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))};
 },

 /* Attach the date picker to an input field. */
 _connectDatepicker: function(target, inst) {
 var input = $(target);
 if (input.hasClass(this.markerClassName))
 return;
 var appendText = this._get(inst, 'appendText');
 var isRTL = this._get(inst, 'isRTL');
 if (appendText)
 input[isRTL ? 'before' : 'after']('<span class="' + this._appendClass + '">' + appendText + '</span>');
 var showOn = this._get(inst, 'showOn');
 if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
 input.focus(this._showDatepicker);
 if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
 var buttonText = this._get(inst, 'buttonText');
 var buttonImage = this._get(inst, 'buttonImage');
 var trigger = $(this._get(inst, 'buttonImageOnly') ?
 $('<img/>').addClass(this._triggerClass).
 attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
 $('<button type="button"></button>').addClass(this._triggerClass).
 html(buttonImage == '' ? buttonText : $('<img/>').attr(
 { src:buttonImage, alt:buttonText, title:buttonText })));
 input[isRTL ? 'before' : 'after'](trigger);
 trigger.click(function() {
 if ($.datepicker._datepickerShowing && $.datepicker._lastInput == target)
 $.datepicker._hideDatepicker();
 else
 $.datepicker._showDatepicker(target);
 return false;
 });
 }
 input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).
 bind("setData.datepicker", function(event, key, value) {
 inst.settings[key] = value;
 }).bind("getData.datepicker", function(event, key) {
 return this._get(inst, key);
 });
 $.data(target, PROP_NAME, inst);
 },

 /* Attach an inline date picker to a div. */
 _inlineDatepicker: function(target, inst) {
 var divSpan = $(target);
 if (divSpan.hasClass(this.markerClassName))
 return;
 divSpan.addClass(this.markerClassName).append(inst.dpDiv).
 bind("setData.datepicker", function(event, key, value){
 inst.settings[key] = value;
 }).bind("getData.datepicker", function(event, key){
 return this._get(inst, key);
 });
 $.data(target, PROP_NAME, inst);
 this._setDate(inst, this._getDefaultDate(inst));
 this._updateDatepicker(inst);
 this._updateAlternate(inst);
 },

 /* Pop-up the date picker in a "dialog" box.
 @param input element - ignored
 @param dateText string - the initial date to display (in the current format)
 @param onSelect function - the function(dateText) to call when a date is selected
 @param settings object - update the dialog date picker instance's settings (anonymous object)
 @param pos int[2] - coordinates for the dialog's position within the screen or
 event - with x/y coordinates or
 leave empty for default (screen centre)
 @return the manager object */
 _dialogDatepicker: function(input, dateText, onSelect, settings, pos) {
 var inst = this._dialogInst; // internal instance
 if (!inst) {
 var id = 'dp' + (++this.uuid);
 this._dialogInput = $('<input type="text" id="' + id +
 '" size="1" style="position: absolute; top: -100px;"/>');
 this._dialogInput.keydown(this._doKeyDown);
 $('body').append(this._dialogInput);
 inst = this._dialogInst = this._newInst(this._dialogInput, false);
 inst.settings = {};
 $.data(this._dialogInput[0], PROP_NAME, inst);
 }
 extendRemove(inst.settings, settings || {});
 this._dialogInput.val(dateText);

 this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
 if (!this._pos) {
 var browserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
 var browserHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
 var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
 var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
 this._pos = // should use actual width/height below
 [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
 }

 // move input on screen for focus, but hidden behind dialog
 this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px');
 inst.settings.onSelect = onSelect;
 this._inDialog = true;
 this.dpDiv.addClass(this._dialogClass);
 this._showDatepicker(this._dialogInput[0]);
 if ($.blockUI)
 $.blockUI(this.dpDiv);
 $.data(this._dialogInput[0], PROP_NAME, inst);
 return this;
 },

 /* Detach a datepicker from its control.
 @param target element - the target input field or division or span */
 _destroyDatepicker: function(target) {
 var $target = $(target);
 if (!$target.hasClass(this.markerClassName)) {
 return;
 }
 var nodeName = target.nodeName.toLowerCase();
 $.removeData(target, PROP_NAME);
 if (nodeName == 'input') {
 $target.siblings('.' + this._appendClass).remove().end().
 siblings('.' + this._triggerClass).remove().end().
 removeClass(this.markerClassName).
 unbind('focus', this._showDatepicker).
 unbind('keydown', this._doKeyDown).
 unbind('keypress', this._doKeyPress);
 } else if (nodeName == 'div' || nodeName == 'span')
 $target.removeClass(this.markerClassName).empty();
 },

 /* Enable the date picker to a jQuery selection.
 @param target element - the target input field or division or span */
 _enableDatepicker: function(target) {
 var $target = $(target);
 if (!$target.hasClass(this.markerClassName)) {
 return;
 }
 var nodeName = target.nodeName.toLowerCase();
 if (nodeName == 'input') {
 target.disabled = false;
 $target.siblings('button.' + this._triggerClass).
 each(function() { this.disabled = false; }).end().
 siblings('img.' + this._triggerClass).
 css({opacity: '1.0', cursor: ''});
 }
 else if (nodeName == 'div' || nodeName == 'span') {
 var inline = $target.children('.' + this._inlineClass);
 inline.children().removeClass('ui-state-disabled');
 }
 this._disabledInputs = $.map(this._disabledInputs,
 function(value) { return (value == target ? null : value); }); // delete entry
 },

 /* Disable the date picker to a jQuery selection.
 @param target element - the target input field or division or span */
 _disableDatepicker: function(target) {
 var $target = $(target);
 if (!$target.hasClass(this.markerClassName)) {
 return;
 }
 var nodeName = target.nodeName.toLowerCase();
 if (nodeName == 'input') {
 target.disabled = true;
 $target.siblings('button.' + this._triggerClass).
 each(function() { this.disabled = true; }).end().
 siblings('img.' + this._triggerClass).
 css({opacity: '0.5', cursor: 'default'});
 }
 else if (nodeName == 'div' || nodeName == 'span') {
 var inline = $target.children('.' + this._inlineClass);
 inline.children().addClass('ui-state-disabled');
 }
 this._disabledInputs = $.map(this._disabledInputs,
 function(value) { return (value == target ? null : value); }); // delete entry
 this._disabledInputs[this._disabledInputs.length] = target;
 },

 /* Is the first field in a jQuery collection disabled as a datepicker?
 @param target element - the target input field or division or span
 @return boolean - true if disabled, false if enabled */
 _isDisabledDatepicker: function(target) {
 if (!target) {
 return false;
 }
 for (var i = 0; i < this._disabledInputs.length; i++) {
 if (this._disabledInputs[i] == target)
 return true;
 }
 return false;
 },

 /* Retrieve the instance data for the target control.
 @param target element - the target input field or division or span
 @return object - the associated instance data
 @throws error if a jQuery problem getting data */
 _getInst: function(target) {
 try {
 return $.data(target, PROP_NAME);
 }
 catch (err) {
 throw 'Missing instance data for this datepicker';
 }
 },

 /* Update the settings for a date picker attached to an input field or division.
 @param target element - the target input field or division or span
 @param name object - the new settings to update or
 string - the name of the setting to change or
 @param value any - the new value for the setting (omit if above is an object) */
 _optionDatepicker: function(target, name, value) {
 var settings = name || {};
 if (typeof name == 'string') {
 settings = {};
 settings[name] = value;
 }
 var inst = this._getInst(target);
 if (inst) {
 if (this._curInst == inst) {
 this._hideDatepicker(null);
 }
 extendRemove(inst.settings, settings);
 var date = new Date();
 extendRemove(inst, {rangeStart: null, // start of range
 endDay: null, endMonth: null, endYear: null, // end of range
 selectedDay: date.getDate(), selectedMonth: date.getMonth(),
 selectedYear: date.getFullYear(), // starting point
 currentDay: date.getDate(), currentMonth: date.getMonth(),
 currentYear: date.getFullYear(), // current selection
 drawMonth: date.getMonth(), drawYear: date.getFullYear()}); // month being drawn
 this._updateDatepicker(inst);
 }
 },

 // change method deprecated
 _changeDatepicker: function(target, name, value) {
 this._optionDatepicker(target, name, value);
 },

 /* Redraw the date picker attached to an input field or division.
 @param target element - the target input field or division or span */
 _refreshDatepicker: function(target) {
 var inst = this._getInst(target);
 if (inst) {
 this._updateDatepicker(inst);
 }
 },

 /* Set the dates for a jQuery selection.
 @param target element - the target input field or division or span
 @param date Date - the new date
 @param endDate Date - the new end date for a range (optional) */
 _setDateDatepicker: function(target, date, endDate) {
 var inst = this._getInst(target);
 if (inst) {
 this._setDate(inst, date, endDate);
 this._updateDatepicker(inst);
 this._updateAlternate(inst);
 }
 },

 /* Get the date(s) for the first entry in a jQuery selection.
 @param target element - the target input field or division or span
 @return Date - the current date or
 Date[2] - the current dates for a range */
 _getDateDatepicker: function(target) {
 var inst = this._getInst(target);
 if (inst && !inst.inline)
 this._setDateFromField(inst);
 return (inst ? this._getDate(inst) : null);
 },

 /* Handle keystrokes. */
 _doKeyDown: function(event) {
 var inst = $.datepicker._getInst(event.target);
 var handled = true;
 var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
 inst._keyEvent = true;
 if ($.datepicker._datepickerShowing)
 switch (event.keyCode) {
 case 9: $.datepicker._hideDatepicker(null, '');
 break; // hide on tab out
 case 13: var sel = $('td.' + $.datepicker._dayOverClass +
 ', td.' + $.datepicker._currentClass, inst.dpDiv);
 if (sel[0])
 $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
 else
 $.datepicker._hideDatepicker(null, $.datepicker._get(inst, 'duration'));
 return false; // don't submit the form
 break; // select the value on enter
 case 27: $.datepicker._hideDatepicker(null, $.datepicker._get(inst, 'duration'));
 break; // hide on escape
 case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
 -$.datepicker._get(inst, 'stepBigMonths') :
 -$.datepicker._get(inst, 'stepMonths')), 'M');
 break; // previous month/year on page up/+ ctrl
 case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
 +$.datepicker._get(inst, 'stepBigMonths') :
 +$.datepicker._get(inst, 'stepMonths')), 'M');
 break; // next month/year on page down/+ ctrl
 case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
 handled = event.ctrlKey || event.metaKey;
 break; // clear on ctrl or command +end
 case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
 handled = event.ctrlKey || event.metaKey;
 break; // current on ctrl or command +home
 case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
 handled = event.ctrlKey || event.metaKey;
 // -1 day on ctrl or command +left
 if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
 -$.datepicker._get(inst, 'stepBigMonths') :
 -$.datepicker._get(inst, 'stepMonths')), 'M');
 // next month/year on alt +left on Mac
 break;
 case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
 handled = event.ctrlKey || event.metaKey;
 break; // -1 week on ctrl or command +up
 case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
 handled = event.ctrlKey || event.metaKey;
 // +1 day on ctrl or command +right
 if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
 +$.datepicker._get(inst, 'stepBigMonths') :
 +$.datepicker._get(inst, 'stepMonths')), 'M');
 // next month/year on alt +right
 break;
 case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
 handled = event.ctrlKey || event.metaKey;
 break; // +1 week on ctrl or command +down
 default: handled = false;
 }
 else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
 $.datepicker._showDatepicker(this);
 else {
 handled = false;
 }
 if (handled) {
 event.preventDefault();
 event.stopPropagation();
 }
 },

 /* Filter entered characters - based on date format. */
 _doKeyPress: function(event) {
 var inst = $.datepicker._getInst(event.target);
 if ($.datepicker._get(inst, 'constrainInput')) {
 var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
 var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
 return event.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
 }
 },

 /* Pop-up the date picker for a given input field.
 @param input element - the input field attached to the date picker or
 event - if triggered by focus */
 _showDatepicker: function(input) {
 input = input.target || input;
 if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
 input = $('input', input.parentNode)[0];
 if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
 return;
 var inst = $.datepicker._getInst(input);
 var beforeShow = $.datepicker._get(inst, 'beforeShow');
 extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {}));
 $.datepicker._hideDatepicker(null, '');
 $.datepicker._lastInput = input;
 $.datepicker._setDateFromField(inst);
 if ($.datepicker._inDialog) // hide cursor
 input.value = '';
 if (!$.datepicker._pos) { // position below input
 $.datepicker._pos = $.datepicker._findPos(input);
 $.datepicker._pos[1] += input.offsetHeight; // add the height
 }
 var isFixed = false;
 $(input).parents().each(function() {
 isFixed |= $(this).css('position') == 'fixed';
 return !isFixed;
 });
 if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
 $.datepicker._pos[0] -= document.documentElement.scrollLeft;
 $.datepicker._pos[1] -= document.documentElement.scrollTop;
 }
 var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
 $.datepicker._pos = null;
 inst.rangeStart = null;
 // determine sizing offscreen
 inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
 $.datepicker._updateDatepicker(inst);
 // fix width for dynamic number of date pickers
 // and adjust position before showing
 offset = $.datepicker._checkOffset(inst, offset, isFixed);
 inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
 'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
 left: offset.left + 'px', top: offset.top + 'px'});
 if (!inst.inline) {
 var showAnim = $.datepicker._get(inst, 'showAnim') || 'show';
 var duration = $.datepicker._get(inst, 'duration');
 var postProcess = function() {
 $.datepicker._datepickerShowing = true;
 if ($.browser.msie && parseInt($.browser.version,10) < 7) // fix IE < 7 select problems
 $('iframe.ui-datepicker-cover').css({width: inst.dpDiv.width() + 4,
 height: inst.dpDiv.height() + 4});
 };
 if ($.effects && $.effects[showAnim])
 inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
 else
 inst.dpDiv[showAnim](duration, postProcess);
 if (duration == '')
 postProcess();
 if (inst.input[0].type != 'hidden')
 inst.input[0].focus();
 $.datepicker._curInst = inst;
 }
 },

 /* Generate the date picker content. */
 _updateDatepicker: function(inst) {
 var dims = {width: inst.dpDiv.width() + 4,
 height: inst.dpDiv.height() + 4};
 var self = this;
 inst.dpDiv.empty().append(this._generateHTML(inst))
 .find('iframe.ui-datepicker-cover').
 css({width: dims.width, height: dims.height})
 .end()
 .find('button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a')
 .bind('mouseout', function(){
 $(this).removeClass('ui-state-hover');
 if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover');
 if(this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover');
 })
 .bind('mouseover', function(){
 if (!self._isDisabledDatepicker( inst.inline ? inst.dpDiv.parent()[0] : inst.input[0])) {
 $(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
 $(this).addClass('ui-state-hover');
 if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover');
 if(this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover');
 }
 })
 .end()
 .find('.' + this._dayOverClass + ' a')
 .trigger('mouseover')
 .end();
 var numMonths = this._getNumberOfMonths(inst);
 var cols = numMonths[1];
 var width = 17;
 if (cols > 1) {
 inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em');
 } else {
 inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
 }
 inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
 'Class']('ui-datepicker-multi');
 inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
 'Class']('ui-datepicker-rtl');
 if (inst.input && inst.input[0].type != 'hidden' && inst == $.datepicker._curInst)
 $(inst.input[0]).focus();
 },

 /* Check positioning to remain on screen. */
 _checkOffset: function(inst, offset, isFixed) {
 var dpWidth = inst.dpDiv.outerWidth();
 var dpHeight = inst.dpDiv.outerHeight();
 var inputWidth = inst.input ? inst.input.outerWidth() : 0;
 var inputHeight = inst.input ? inst.input.outerHeight() : 0;
 var viewWidth = (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) + $(document).scrollLeft();
 var viewHeight = (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight) + $(document).scrollTop();

 offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
 offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
 offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;

 // now check if datepicker is showing outside window viewport - move to a better place if so.
 offset.left -= (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ? Math.abs(offset.left + dpWidth - viewWidth) : 0;
 offset.top -= (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ? Math.abs(offset.top + dpHeight + inputHeight*2 - viewHeight) : 0;

 return offset;
 },

 /* Find an object's position on the screen. */
 _findPos: function(obj) {
 while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) {
 obj = obj.nextSibling;
 }
 var position = $(obj).offset();
 return [position.left, position.top];
 },

 /* Hide the date picker from view.
 @param input element - the input field attached to the date picker
 @param duration string - the duration over which to close the date picker */
 _hideDatepicker: function(input, duration) {
 var inst = this._curInst;
 if (!inst || (input && inst != $.data(input, PROP_NAME)))
 return;
 if (inst.stayOpen)
 this._selectDate('#' + inst.id, this._formatDate(inst,
 inst.currentDay, inst.currentMonth, inst.currentYear));
 inst.stayOpen = false;
 if (this._datepickerShowing) {
 duration = (duration != null ? duration : this._get(inst, 'duration'));
 var showAnim = this._get(inst, 'showAnim');
 var postProcess = function() {
 $.datepicker._tidyDialog(inst);
 };
 if (duration != '' && $.effects && $.effects[showAnim])
 inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'),
 duration, postProcess);
 else
 inst.dpDiv[(duration == '' ? 'hide' : (showAnim == 'slideDown' ? 'slideUp' :
 (showAnim == 'fadeIn' ? 'fadeOut' : 'hide')))](duration, postProcess);
 if (duration == '')
 this._tidyDialog(inst);
 var onClose = this._get(inst, 'onClose');
 if (onClose)
 onClose.apply((inst.input ? inst.input[0] : null),
 [(inst.input ? inst.input.val() : ''), inst]); // trigger custom callback
 this._datepickerShowing = false;
 this._lastInput = null;
 if (this._inDialog) {
 this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
 if ($.blockUI) {
 $.unblockUI();
 $('body').append(this.dpDiv);
 }
 }
 this._inDialog = false;
 }
 this._curInst = null;
 },

 /* Tidy up after a dialog display. */
 _tidyDialog: function(inst) {
 inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
 },

 /* Close date picker if clicked elsewhere. */
 _checkExternalClick: function(event) {
 if (!$.datepicker._curInst)
 return;
 var $target = $(event.target);
 if (($target.parents('#' + $.datepicker._mainDivId).length == 0) &&
 !$target.hasClass($.datepicker.markerClassName) &&
 !$target.hasClass($.datepicker._triggerClass) &&
 $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
 $.datepicker._hideDatepicker(null, '');
 },

 /* Adjust one of the date sub-fields. */
 _adjustDate: function(id, offset, period) {
 var target = $(id);
 var inst = this._getInst(target[0]);
 if (this._isDisabledDatepicker(target[0])) {
 return;
 }
 this._adjustInstDate(inst, offset +
 (period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
 period);
 this._updateDatepicker(inst);
 },

 /* Action for current link. */
 _gotoToday: function(id) {
 var target = $(id);
 var inst = this._getInst(target[0]);
 if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
 inst.selectedDay = inst.currentDay;
 inst.drawMonth = inst.selectedMonth = inst.currentMonth;
 inst.drawYear = inst.selectedYear = inst.currentYear;
 }
 else {
 var date = new Date();
 inst.selectedDay = date.getDate();
 inst.drawMonth = inst.selectedMonth = date.getMonth();
 inst.drawYear = inst.selectedYear = date.getFullYear();
 }
 this._notifyChange(inst);
 this._adjustDate(target);
 },

 /* Action for selecting a new month/year. */
 _selectMonthYear: function(id, select, period) {
 var target = $(id);
 var inst = this._getInst(target[0]);
 inst._selectingMonthYear = false;
 inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
 inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
 parseInt(select.options[select.selectedIndex].value,10);
 this._notifyChange(inst);
 this._adjustDate(target);
 },

 /* Restore input focus after not changing month/year. */
 _clickMonthYear: function(id) {
 var target = $(id);
 var inst = this._getInst(target[0]);
 if (inst.input && inst._selectingMonthYear && !$.browser.msie)
 inst.input[0].focus();
 inst._selectingMonthYear = !inst._selectingMonthYear;
 },

 /* Action for selecting a day. */
 _selectDay: function(id, month, year, td) {
 var target = $(id);
 if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
 return;
 }
 var inst = this._getInst(target[0]);
 inst.selectedDay = inst.currentDay = $('a', td).html();
 inst.selectedMonth = inst.currentMonth = month;
 inst.selectedYear = inst.currentYear = year;
 if (inst.stayOpen) {
 inst.endDay = inst.endMonth = inst.endYear = null;
 }
 this._selectDate(id, this._formatDate(inst,
 inst.currentDay, inst.currentMonth, inst.currentYear));
 if (inst.stayOpen) {
 inst.rangeStart = this._daylightSavingAdjust(
 new Date(inst.currentYear, inst.currentMonth, inst.currentDay));
 this._updateDatepicker(inst);
 }
 },

 /* Erase the input field and hide the date picker. */
 _clearDate: function(id) {
 var target = $(id);
 var inst = this._getInst(target[0]);
 inst.stayOpen = false;
 inst.endDay = inst.endMonth = inst.endYear = inst.rangeStart = null;
 this._selectDate(target, '');
 },

 /* Update the input field with the selected date. */
 _selectDate: function(id, dateStr) {
 var target = $(id);
 var inst = this._getInst(target[0]);
 dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
 if (inst.input)
 inst.input.val(dateStr);
 this._updateAlternate(inst);
 var onSelect = this._get(inst, 'onSelect');
 if (onSelect)
 onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
 else if (inst.input)
 inst.input.trigger('change'); // fire the change event
 if (inst.inline)
 this._updateDatepicker(inst);
 else if (!inst.stayOpen) {
 this._hideDatepicker(null, this._get(inst, 'duration'));
 this._lastInput = inst.input[0];
 if (typeof(inst.input[0]) != 'object')
 inst.input[0].focus(); // restore focus
 this._lastInput = null;
 }
 },

 /* Update any alternate field to synchronise with the main field. */
 _updateAlternate: function(inst) {
 var altField = this._get(inst, 'altField');
 if (altField) { // update alternate field too
 var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
 var date = this._getDate(inst);
 dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
 $(altField).each(function() { $(this).val(dateStr); });
 }
 },

 /* Set as beforeShowDay function to prevent selection of weekends.
 @param date Date - the date to customise
 @return [boolean, string] - is this date selectable?, what is its CSS class? */
 noWeekends: function(date) {
 var day = date.getDay();
 return [(day > 0 && day < 6), ''];
 },

 /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
 @param date Date - the date to get the week for
 @return number - the number of the week within the year that contains this date */
 iso8601Week: function(date) {
 var checkDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
 var firstMon = new Date(checkDate.getFullYear(), 1 - 1, 4); // First week always contains 4 Jan
 var firstDay = firstMon.getDay() || 7; // Day of week: Mon = 1, ..., Sun = 7
 firstMon.setDate(firstMon.getDate() + 1 - firstDay); // Preceding Monday
 if (firstDay < 4 && checkDate < firstMon) { // Adjust first three days in year if necessary
 checkDate.setDate(checkDate.getDate() - 3); // Generate for previous year
 return $.datepicker.iso8601Week(checkDate);
 } else if (checkDate > new Date(checkDate.getFullYear(), 12 - 1, 28)) { // Check last three days in year
 firstDay = new Date(checkDate.getFullYear() + 1, 1 - 1, 4).getDay() || 7;
 if (firstDay > 4 && (checkDate.getDay() || 7) < firstDay - 3) { // Adjust if necessary
 return 1;
 }
 }
 return Math.floor(((checkDate - firstMon) / 86400000) / 7) + 1; // Weeks to given date
 },

 /* Parse a string value into a date object.
 See formatDate below for the possible formats.

 @param format string - the expected format of the date
 @param value string - the date in the above format
 @param settings Object - attributes include:
 shortYearCutoff number - the cutoff year for determining the century (optional)
 dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
 dayNames string[7] - names of the days from Sunday (optional)
 monthNamesShort string[12] - abbreviated names of the months (optional)
 monthNames string[12] - names of the months (optional)
 @return Date - the extracted date value or null if value is blank */
 parseDate: function (format, value, settings) {
 if (format == null || value == null)
 throw 'Invalid arguments';
 value = (typeof value == 'object' ? value.toString() : value + '');
 if (value == '')
 return null;
 var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
 var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
 var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
 var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
 var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
 var year = -1;
 var month = -1;
 var day = -1;
 var doy = -1;
 var literal = false;
 // Check whether a format character is doubled
 var lookAhead = function(match) {
 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
 if (matches)
 iFormat++;
 return matches;
 };
 // Extract a number from the string value
 var getNumber = function(match) {
 lookAhead(match);
 var origSize = (match == '@' ? 14 : (match == 'y' ? 4 : (match == 'o' ? 3 : 2)));
 var size = origSize;
 var num = 0;
 while (size > 0 && iValue < value.length &&
 value.charAt(iValue) >= '0' && value.charAt(iValue) <= '9') {
 num = num * 10 + parseInt(value.charAt(iValue++),10);
 size--;
 }
 if (size == origSize)
 throw 'Missing number at position ' + iValue;
 return num;
 };
 // Extract a name from the string value and convert to an index
 var getName = function(match, shortNames, longNames) {
 var names = (lookAhead(match) ? longNames : shortNames);
 var size = 0;
 for (var j = 0; j < names.length; j++)
 size = Math.max(size, names[j].length);
 var name = '';
 var iInit = iValue;
 while (size > 0 && iValue < value.length) {
 name += value.charAt(iValue++);
 for (var i = 0; i < names.length; i++)
 if (name == names[i])
 return i + 1;
 size--;
 }
 throw 'Unknown name at position ' + iInit;
 };
 // Confirm that a literal character matches the string value
 var checkLiteral = function() {
 if (value.charAt(iValue) != format.charAt(iFormat))
 throw 'Unexpected literal at position ' + iValue;
 iValue++;
 };
 var iValue = 0;
 for (var iFormat = 0; iFormat < format.length; iFormat++) {
 if (literal)
 if (format.charAt(iFormat) == "'" && !lookAhead("'"))
 literal = false;
 else
 checkLiteral();
 else
 switch (format.charAt(iFormat)) {
 case 'd':
 day = getNumber('d');
 break;
 case 'D':
 getName('D', dayNamesShort, dayNames);
 break;
 case 'o':
 doy = getNumber('o');
 break;
 case 'm':
 month = getNumber('m');
 break;
 case 'M':
 month = getName('M', monthNamesShort, monthNames);
 break;
 case 'y':
 year = getNumber('y');
 break;
 case '@':
 var date = new Date(getNumber('@'));
 year = date.getFullYear();
 month = date.getMonth() + 1;
 day = date.getDate();
 break;
 case "'":
 if (lookAhead("'"))
 checkLiteral();
 else
 literal = true;
 break;
 default:
 checkLiteral();
 }
 }
 if (year == -1)
 year = new Date().getFullYear();
 else if (year < 100)
 year += new Date().getFullYear() - new Date().getFullYear() % 100 +
 (year <= shortYearCutoff ? 0 : -100);
 if (doy > -1) {
 month = 1;
 day = doy;
 do {
 var dim = this._getDaysInMonth(year, month - 1);
 if (day <= dim)
 break;
 month++;
 day -= dim;
 } while (true);
 }
 var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
 if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
 throw 'Invalid date'; // E.g. 31/02/*
 return date;
 },

 /* Standard date formats. */
 ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
 COOKIE: 'D, dd M yy',
 ISO_8601: 'yy-mm-dd',
 RFC_822: 'D, d M y',
 RFC_850: 'DD, dd-M-y',
 RFC_1036: 'D, d M y',
 RFC_1123: 'D, d M yy',
 RFC_2822: 'D, d M yy',
 RSS: 'D, d M y', // RFC 822
 TIMESTAMP: '@',
 W3C: 'yy-mm-dd', // ISO 8601

 /* Format a date object into a string value.
 The format can be combinations of the following:
 d - day of month (no leading zero)
 dd - day of month (two digit)
 o - day of year (no leading zeros)
 oo - day of year (three digit)
 D - day name short
 DD - day name long
 m - month of year (no leading zero)
 mm - month of year (two digit)
 M - month name short
 MM - month name long
 y - year (two digit)
 yy - year (four digit)
 @ - Unix timestamp (ms since 01/01/1970)
 '...' - literal text
 '' - single quote

 @param format string - the desired format of the date
 @param date Date - the date value to format
 @param settings Object - attributes include:
 dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
 dayNames string[7] - names of the days from Sunday (optional)
 monthNamesShort string[12] - abbreviated names of the months (optional)
 monthNames string[12] - names of the months (optional)
 @return string - the date in the above format */
 formatDate: function (format, date, settings) {
 if (!date)
 return '';
 var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
 var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
 var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
 var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
 // Check whether a format character is doubled
 var lookAhead = function(match) {
 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
 if (matches)
 iFormat++;
 return matches;
 };
 // Format a number, with leading zero if necessary
 var formatNumber = function(match, value, len) {
 var num = '' + value;
 if (lookAhead(match))
 while (num.length < len)
 num = '0' + num;
 return num;
 };
 // Format a name, short or long as requested
 var formatName = function(match, value, shortNames, longNames) {
 return (lookAhead(match) ? longNames[value] : shortNames[value]);
 };
 var output = '';
 var literal = false;
 if (date)
 for (var iFormat = 0; iFormat < format.length; iFormat++) {
 if (literal)
 if (format.charAt(iFormat) == "'" && !lookAhead("'"))
 literal = false;
 else
 output += format.charAt(iFormat);
 else
 switch (format.charAt(iFormat)) {
 case 'd':
 output += formatNumber('d', date.getDate(), 2);
 break;
 case 'D':
 output += formatName('D', date.getDay(), dayNamesShort, dayNames);
 break;
 case 'o':
 var doy = date.getDate();
 for (var m = date.getMonth() - 1; m >= 0; m--)
 doy += this._getDaysInMonth(date.getFullYear(), m);
 output += formatNumber('o', doy, 3);
 break;
 case 'm':
 output += formatNumber('m', date.getMonth() + 1, 2);
 break;
 case 'M':
 output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
 break;
 case 'y':
 output += (lookAhead('y') ? date.getFullYear() :
 (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
 break;
 case '@':
 output += date.getTime();
 break;
 case "'":
 if (lookAhead("'"))
 output += "'";
 else
 literal = true;
 break;
 default:
 output += format.charAt(iFormat);
 }
 }
 return output;
 },

 /* Extract all possible characters from the date format. */
 _possibleChars: function (format) {
 var chars = '';
 var literal = false;
 for (var iFormat = 0; iFormat < format.length; iFormat++)
 if (literal)
 if (format.charAt(iFormat) == "'" && !lookAhead("'"))
 literal = false;
 else
 chars += format.charAt(iFormat);
 else
 switch (format.charAt(iFormat)) {
 case 'd': case 'm': case 'y': case '@':
 chars += '0123456789';
 break;
 case 'D': case 'M':
 return null; // Accept anything
 case "'":
 if (lookAhead("'"))
 chars += "'";
 else
 literal = true;
 break;
 default:
 chars += format.charAt(iFormat);
 }
 return chars;
 },

 /* Get a setting value, defaulting if necessary. */
 _get: function(inst, name) {
 return inst.settings[name] !== undefined ?
 inst.settings[name] : this._defaults[name];
 },

 /* Parse existing date and initialise date picker. */
 _setDateFromField: function(inst) {
 var dateFormat = this._get(inst, 'dateFormat');
 var dates = inst.input ? inst.input.val() : null;
 inst.endDay = inst.endMonth = inst.endYear = null;
 var date = defaultDate = this._getDefaultDate(inst);
 var settings = this._getFormatConfig(inst);
 try {
 date = this.parseDate(dateFormat, dates, settings) || defaultDate;
 } catch (event) {
 this.log(event);
 date = defaultDate;
 }
 inst.selectedDay = date.getDate();
 inst.drawMonth = inst.selectedMonth = date.getMonth();
 inst.drawYear = inst.selectedYear = date.getFullYear();
 inst.currentDay = (dates ? date.getDate() : 0);
 inst.currentMonth = (dates ? date.getMonth() : 0);
 inst.currentYear = (dates ? date.getFullYear() : 0);
 this._adjustInstDate(inst);
 },

 /* Retrieve the default date shown on opening. */
 _getDefaultDate: function(inst) {
 var date = this._determineDate(this._get(inst, 'defaultDate'), new Date());
 var minDate = this._getMinMaxDate(inst, 'min', true);
 var maxDate = this._getMinMaxDate(inst, 'max');
 date = (minDate && date < minDate ? minDate : date);
 date = (maxDate && date > maxDate ? maxDate : date);
 return date;
 },

 /* A date may be specified as an exact value or a relative one. */
 _determineDate: function(date, defaultDate) {
 var offsetNumeric = function(offset) {
 var date = new Date();
 date.setDate(date.getDate() + offset);
 return date;
 };
 var offsetString = function(offset, getDaysInMonth) {
 var date = new Date();
 var year = date.getFullYear();
 var month = date.getMonth();
 var day = date.getDate();
 var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
 var matches = pattern.exec(offset);
 while (matches) {
 switch (matches[2] || 'd') {
 case 'd' : case 'D' :
 day += parseInt(matches[1],10); break;
 case 'w' : case 'W' :
 day += parseInt(matches[1],10) * 7; break;
 case 'm' : case 'M' :
 month += parseInt(matches[1],10);
 day = Math.min(day, getDaysInMonth(year, month));
 break;
 case 'y': case 'Y' :
 year += parseInt(matches[1],10);
 day = Math.min(day, getDaysInMonth(year, month));
 break;
 }
 matches = pattern.exec(offset);
 }
 return new Date(year, month, day);
 };
 date = (date == null ? defaultDate :
 (typeof date == 'string' ? offsetString(date, this._getDaysInMonth) :
 (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : date)));
 date = (date && date.toString() == 'Invalid Date' ? defaultDate : date);
 if (date) {
 date.setHours(0);
 date.setMinutes(0);
 date.setSeconds(0);
 date.setMilliseconds(0);
 }
 return this._daylightSavingAdjust(date);
 },

 /* Handle switch to/from daylight saving.
 Hours may be non-zero on daylight saving cut-over:
 > 12 when midnight changeover, but then cannot generate
 midnight datetime, so jump to 1AM, otherwise reset.
 @param date (Date) the date to check
 @return (Date) the corrected date */
 _daylightSavingAdjust: function(date) {
 if (!date) return null;
 date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
 return date;
 },

 /* Set the date(s) directly. */
 _setDate: function(inst, date, endDate) {
 var clear = !(date);
 var origMonth = inst.selectedMonth;
 var origYear = inst.selectedYear;
 date = this._determineDate(date, new Date());
 inst.selectedDay = inst.currentDay = date.getDate();
 inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth();
 inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear();
 if (origMonth != inst.selectedMonth || origYear != inst.selectedYear)
 this._notifyChange(inst);
 this._adjustInstDate(inst);
 if (inst.input) {
 inst.input.val(clear ? '' : this._formatDate(inst));
 }
 },

 /* Retrieve the date(s) directly. */
 _getDate: function(inst) {
 var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
 this._daylightSavingAdjust(new Date(
 inst.currentYear, inst.currentMonth, inst.currentDay)));
 return startDate;
 },

 /* Generate the HTML for the current state of the date picker. */
 _generateHTML: function(inst) {
 var today = new Date();
 today = this._daylightSavingAdjust(
 new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
 var isRTL = this._get(inst, 'isRTL');
 var showButtonPanel = this._get(inst, 'showButtonPanel');
 var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
 var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
 var numMonths = this._getNumberOfMonths(inst);
 var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
 var stepMonths = this._get(inst, 'stepMonths');
 var stepBigMonths = this._get(inst, 'stepBigMonths');
 var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
 var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
 new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
 var minDate = this._getMinMaxDate(inst, 'min', true);
 var maxDate = this._getMinMaxDate(inst, 'max');
 var drawMonth = inst.drawMonth - showCurrentAtPos;
 var drawYear = inst.drawYear;
 if (drawMonth < 0) {
 drawMonth += 12;
 drawYear--;
 }
 if (maxDate) {
 var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
 maxDate.getMonth() - numMonths[1] + 1, maxDate.getDate()));
 maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
 while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
 drawMonth--;
 if (drawMonth < 0) {
 drawMonth = 11;
 drawYear--;
 }
 }
 }
 inst.drawMonth = drawMonth;
 inst.drawYear = drawYear;
 var prevText = this._get(inst, 'prevText');
 prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
 this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
 this._getFormatConfig(inst)));
 var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
 '<a class="ui-datepicker-prev ui-corner-all" onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' +
 ' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
 (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+ prevText +'"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>'));
 var nextText = this._get(inst, 'nextText');
 nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
 this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
 this._getFormatConfig(inst)));
 var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
 '<a class="ui-datepicker-next ui-corner-all" onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' +
 ' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
 (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+ nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>'));
 var currentText = this._get(inst, 'currentText');
 var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
 currentText = (!navigationAsDateFormat ? currentText :
 this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
 var controls = '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="jQuery.datepicker._hideDatepicker();">' + this._get(inst, 'closeText') + '</button>';
 var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
 (this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="jQuery.datepicker._gotoToday(\'#' + inst.id + '\');"' +
 '>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
 var firstDay = parseInt(this._get(inst, 'firstDay'),10);
 firstDay = (isNaN(firstDay) ? 0 : firstDay);
 var dayNames = this._get(inst, 'dayNames');
 var dayNamesShort = this._get(inst, 'dayNamesShort');
 var dayNamesMin = this._get(inst, 'dayNamesMin');
 var monthNames = this._get(inst, 'monthNames');
 var monthNamesShort = this._get(inst, 'monthNamesShort');
 var beforeShowDay = this._get(inst, 'beforeShowDay');
 var showOtherMonths = this._get(inst, 'showOtherMonths');
 var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
 var endDate = inst.endDay ? this._daylightSavingAdjust(
 new Date(inst.endYear, inst.endMonth, inst.endDay)) : currentDate;
 var defaultDate = this._getDefaultDate(inst);
 var html = '';
 for (var row = 0; row < numMonths[0]; row++) {
 var group = '';
 for (var col = 0; col < numMonths[1]; col++) {
 var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
 var cornerClass = ' ui-corner-all';
 var calender = '';
 if (isMultiMonth) {
 calender += '<div class="ui-datepicker-group ui-datepicker-group-';
 switch (col) {
 case 0: calender += 'first'; cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break;
 case numMonths[1]-1: calender += 'last'; cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break;
 default: calender += 'middle'; cornerClass = ''; break;
 }
 calender += '">';
 }
 calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' +
 (/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') +
 (/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') +
 this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
 selectedDate, row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
 '</div><table class="ui-datepicker-calendar"><thead>' +
 '<tr>';
 var thead = '';
 for (var dow = 0; dow < 7; dow++) { // days of the week
 var day = (dow + firstDay) % 7;
 thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' +
 '<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>';
 }
 calender += thead + '</tr></thead><tbody>';
 var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
 if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
 inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
 var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
 var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate
 var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
 for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
 calender += '<tr>';
 var tbody = '';
 for (var dow = 0; dow < 7; dow++) { // create date picker days
 var daySettings = (beforeShowDay ?
 beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
 var otherMonth = (printDate.getMonth() != drawMonth);
 var unselectable = otherMonth || !daySettings[0] ||
 (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
 tbody += '<td class="' +
 ((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends
 (otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
 ((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key
 (defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ?
 // or defaultDate is current printedDate and defaultDate is selectedDate
 ' ' + this._dayOverClass : '') + // highlight selected day
 (unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') + // highlight unselectable days
 (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
 (printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ? // in current range
 ' ' + this._currentClass : '') + // highlight selected day
 (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
 ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
 (unselectable ? '' : ' onclick="jQuery.datepicker._selectDay(\'#' +
 inst.id + '\',' + drawMonth + ',' + drawYear + ', this);return false;"') + '>' + // actions
 (otherMonth ? (showOtherMonths ? printDate.getDate() : '&#xa0;') : // display for other months
 (unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
 (printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') +
 (printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ? // in current range
 ' ui-state-active' : '') + // highlight selected day
 '" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display for this month
 printDate.setDate(printDate.getDate() + 1);
 printDate = this._daylightSavingAdjust(printDate);
 }
 calender += tbody + '</tr>';
 }
 drawMonth++;
 if (drawMonth > 11) {
 drawMonth = 0;
 drawYear++;
 }
 calender += '</tbody></table>' + (isMultiMonth ? '</div>' : '');
 group += calender;
 }
 html += group;
 }
 html += (!inst.inline ? buttonPanel : '') +
 ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ?
 '<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : '');
 inst._keyEvent = false;
 return html;
 },

 /* Generate the month and year header. */
 _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
 selectedDate, secondary, monthNames, monthNamesShort) {
 minDate = (inst.rangeStart && minDate && selectedDate < minDate ? selectedDate : minDate);
 var changeMonth = this._get(inst, 'changeMonth');
 var changeYear = this._get(inst, 'changeYear');
 var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
 var html = '<div class="ui-datepicker-title">';
 var monthHtml = '';
 // month selection
 if (secondary || !changeMonth)
 monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span> ';
 else {
 var inMinYear = (minDate && minDate.getFullYear() == drawYear);
 var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
 monthHtml += '<select class="ui-datepicker-month" ' +
 'onchange="jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' +
 'onclick="jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
 '>';
 for (var month = 0; month < 12; month++) {
 if ((!inMinYear || month >= minDate.getMonth()) &&
 (!inMaxYear || month <= maxDate.getMonth()))
 monthHtml += '<option value="' + month + '"' +
 (month == drawMonth ? ' selected="selected"' : '') +
 '>' + monthNamesShort[month] + '</option>';
 }
 monthHtml += '</select>';
 }
 if (!showMonthAfterYear)
 html += monthHtml + ((secondary || changeMonth || changeYear) && (!(changeMonth && changeYear)) ? '&#xa0;' : '');
 // year selection
 if (secondary || !changeYear)
 html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
 else {
 // determine range of years to display
 var years = this._get(inst, 'yearRange').split(':');
 var year = 0;
 var endYear = 0;
 if (years.length != 2) {
 year = drawYear - 10;
 endYear = drawYear + 10;
 } else if (years[0].charAt(0) == '+' || years[0].charAt(0) == '-') {
 year = drawYear + parseInt(years[0], 10);
 endYear = drawYear + parseInt(years[1], 10);
 } else {
 year = parseInt(years[0], 10);
 endYear = parseInt(years[1], 10);
 }
 year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
 endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
 html += '<select class="ui-datepicker-year" ' +
 'onchange="jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
 'onclick="jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
 '>';
 for (; year <= endYear; year++) {
 html += '<option value="' + year + '"' +
 (year == drawYear ? ' selected="selected"' : '') +
 '>' + year + '</option>';
 }
 html += '</select>';
 }
 if (showMonthAfterYear)
 html += (secondary || changeMonth || changeYear ? '&#xa0;' : '') + monthHtml;
 html += '</div>'; // Close datepicker_header
 return html;
 },

 /* Adjust one of the date sub-fields. */
 _adjustInstDate: function(inst, offset, period) {
 var year = inst.drawYear + (period == 'Y' ? offset : 0);
 var month = inst.drawMonth + (period == 'M' ? offset : 0);
 var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
 (period == 'D' ? offset : 0);
 var date = this._daylightSavingAdjust(new Date(year, month, day));
 // ensure it is within the bounds set
 var minDate = this._getMinMaxDate(inst, 'min', true);
 var maxDate = this._getMinMaxDate(inst, 'max');
 date = (minDate && date < minDate ? minDate : date);
 date = (maxDate && date > maxDate ? maxDate : date);
 inst.selectedDay = date.getDate();
 inst.drawMonth = inst.selectedMonth = date.getMonth();
 inst.drawYear = inst.selectedYear = date.getFullYear();
 if (period == 'M' || period == 'Y')
 this._notifyChange(inst);
 },

 /* Notify change of month/year. */
 _notifyChange: function(inst) {
 var onChange = this._get(inst, 'onChangeMonthYear');
 if (onChange)
 onChange.apply((inst.input ? inst.input[0] : null),
 [inst.selectedYear, inst.selectedMonth + 1, inst]);
 },

 /* Determine the number of months to show. */
 _getNumberOfMonths: function(inst) {
 var numMonths = this._get(inst, 'numberOfMonths');
 return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
 },

 /* Determine the current maximum date - ensure no time components are set - may be overridden for a range. */
 _getMinMaxDate: function(inst, minMax, checkRange) {
 var date = this._determineDate(this._get(inst, minMax + 'Date'), null);
 return (!checkRange || !inst.rangeStart ? date :
 (!date || inst.rangeStart > date ? inst.rangeStart : date));
 },

 /* Find the number of days in a given month. */
 _getDaysInMonth: function(year, month) {
 return 32 - new Date(year, month, 32).getDate();
 },

 /* Find the day of the week of the first of a month. */
 _getFirstDayOfMonth: function(year, month) {
 return new Date(year, month, 1).getDay();
 },

 /* Determines if we should allow a "next/prev" month display change. */
 _canAdjustMonth: function(inst, offset, curYear, curMonth) {
 var numMonths = this._getNumberOfMonths(inst);
 var date = this._daylightSavingAdjust(new Date(
 curYear, curMonth + (offset < 0 ? offset : numMonths[1]), 1));
 if (offset < 0)
 date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
 return this._isInRange(inst, date);
 },

 /* Is the given date in the accepted range? */
 _isInRange: function(inst, date) {
 // during range selection, use minimum of selected date and range start
 var newMinDate = (!inst.rangeStart ? null : this._daylightSavingAdjust(
 new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay)));
 newMinDate = (newMinDate && inst.rangeStart < newMinDate ? inst.rangeStart : newMinDate);
 var minDate = newMinDate || this._getMinMaxDate(inst, 'min');
 var maxDate = this._getMinMaxDate(inst, 'max');
 return ((!minDate || date >= minDate) && (!maxDate || date <= maxDate));
 },

 /* Provide the configuration settings for formatting/parsing. */
 _getFormatConfig: function(inst) {
 var shortYearCutoff = this._get(inst, 'shortYearCutoff');
 shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
 new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
 return {shortYearCutoff: shortYearCutoff,
 dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
 monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
 },

 /* Format the given date for display. */
 _formatDate: function(inst, day, month, year) {
 if (!day) {
 inst.currentDay = inst.selectedDay;
 inst.currentMonth = inst.selectedMonth;
 inst.currentYear = inst.selectedYear;
 }
 var date = (day ? (typeof day == 'object' ? day :
 this._daylightSavingAdjust(new Date(year, month, day))) :
 this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
 return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
 }
});

/* jQuery extend now ignores nulls! */
function extendRemove(target, props) {
 $.extend(target, props);
 for (var name in props)
 if (props[name] == null || props[name] == undefined)
 target[name] = props[name];
 return target;
};

/* Determine whether an object is an array. */
function isArray(a) {
 return (a && (($.browser.safari && typeof a == 'object' && a.length) ||
 (a.constructor && a.constructor.toString().match(/\Array\(\)/))));
};

/* Invoke the datepicker functionality.
 @param options string - a command, optionally followed by additional parameters or
 Object - settings for attaching new datepicker functionality
 @return jQuery object */
$.fn.datepicker = function(options){

 /* Initialise the date picker. */
 if (!$.datepicker.initialized) {
 $(document).mousedown($.datepicker._checkExternalClick).
 find('body').append($.datepicker.dpDiv);
 $.datepicker.initialized = true;
 }

 var otherArgs = Array.prototype.slice.call(arguments, 1);
 if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate'))
 return $.datepicker['_' + options + 'Datepicker'].
 apply($.datepicker, [this[0]].concat(otherArgs));
 return this.each(function() {
 typeof options == 'string' ?
 $.datepicker['_' + options + 'Datepicker'].
 apply($.datepicker, [this].concat(otherArgs)) :
 $.datepicker._attachDatepicker(this, options);
 });
};

$.datepicker = new Datepicker(); // singleton instance
$.datepicker.initialized = false;
$.datepicker.uuid = new Date().getTime();
$.datepicker.version = "1.6rc6";

})(jQuery);

