/*
 * jQuery JSON Plugin
 * version: 1.0 (2008-04-17)
 *
 * This document is licensed as free software under the terms of the
 * MIT License: http://www.opensource.org/licenses/mit-license.php
 *
 * Brantley Harris technically wrote this plugin, but it is based somewhat
 * on the JSON.org website's http://www.json.org/json2.js, which proclaims:
 * "NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.", a sentiment that
 * I uphold.  I really just cleaned it up.
 *
 * It is also based heavily on MochiKit's serializeJSON, which is 
 * copywrited 2005 by Bob Ippolito.
 */
 
(function($) {   
    function toIntegersAtLease(n) 
    // Format integers to have at least two digits.
    {    
        return n < 10 ? '0' + n : n;
    }

    Date.prototype.toJSON = function(date)
    // Yes, it polutes the Date namespace, but we'll allow it here, as
    // it's damned usefull.
    {
        return this.getUTCFullYear()   + '-' +
             toIntegersAtLease(this.getUTCMonth()) + '-' +
             toIntegersAtLease(this.getUTCDate());
    };

    var escapeable = /["\\\x00-\x1f\x7f-\x9f]/g;
    var meta = {    // table of character substitutions
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        };
        
    $.quoteString = function(string)
    // Places quotes around a string, inteligently.
    // If the string contains no control characters, no quote characters, and no
    // backslash characters, then we can safely slap some quotes around it.
    // Otherwise we must also replace the offending characters with safe escape
    // sequences.
    {
        if (escapeable.test(string))
        {
            return '"' + string.replace(escapeable, function (a) 
            {
                var c = meta[a];
                if (typeof c === 'string') {
                    return c;
                }
                c = a.charCodeAt();
                return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
            }) + '"';
        }
        return '"' + string + '"';
    };
    
    $.toJSON = function(o, compact)
    {
        var type = typeof(o);
        
        if (type == "undefined")
            return "undefined";
        else if (type == "number" || type == "boolean")
            return o + "";
        else if (o === null)
            return "null";
        
        // Is it a string?
        if (type == "string") 
        {
            return $.quoteString(o);
        }
        
        // Does it have a .toJSON function?
        if (type == "object" && typeof o.toJSON == "function") 
            return o.toJSON(compact);
        
        // Is it an array?
        if (type != "function" && typeof(o.length) == "number") 
        {
            var ret = [];
            for (var i = 0; i < o.length; i++) {
                ret.push( $.toJSON(o[i], compact) );
            }
            if (compact)
                return "[" + ret.join(",") + "]";
            else
                return "[" + ret.join(", ") + "]";
        }
        
        // If it's a function, we have to warn somebody!
        if (type == "function") {
            throw new TypeError("Unable to convert object of type 'function' to json.");
        }
        
        // It's probably an object, then.
        var ret = [];
        for (var k in o) {
            var name;
            type = typeof(k);
            
            if (type == "number")
                name = '"' + k + '"';
            else if (type == "string")
                name = $.quoteString(k);
            else
                continue;  //skip non-string or number keys
            
            var val = $.toJSON(o[k], compact);
            if (typeof(val) != "string") {
                // skip non-serializable values
                continue;
            }
            
            if (compact)
                ret.push(name + ":" + val);
            else
                ret.push(name + ": " + val);
        }
        return "{" + ret.join(", ") + "}";
    };
    
    $.compactJSON = function(o)
    {
        return $.toJSON(o, true);
    };
    
    $.evalJSON = function(src)
    // Evals JSON that we know to be safe.
    {
        return eval("(" + src + ")");
    };
    
    $.secureEvalJSON = function(src)
    // Evals JSON in a way that is *more* secure.
    {
        var filtered = src;
        filtered = filtered.replace(/\\["\\\/bfnrtu]/g, '@');
        filtered = filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']');
        filtered = filtered.replace(/(?:^|:|,)(?:\s*\[)+/g, '');
        
        if (/^[\],:{}\s]*$/.test(filtered))
            return eval("(" + src + ")");
        else
            throw new SyntaxError("Error parsing JSON, source is not valid.");
    };
})(jQuery);

/* ------------------------------------------------------------------------
	Class: prettyPhoto
	Use: Lightbox clone for jQuery
	Author: Stephane Caron (http://www.no-margin-for-errors.com)
	Version: 2.2.2
------------------------------------------------------------------------- */

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('$.2L.2M=5(j){E k=F;E l=0;E m=0;E n=0;E o=F;E p=0;E q=V;E r=[];$(B).2N(5(){1w()});$(B).2O(5(){1w();29()});$(1i).2P(5(e){2Q(e.2R){1J 37:8(m==1)L;15(\'R\');1K;1J 39:8(m==l)L;15(\'W\');1K;1J 27:X();1K}});j=2S.2T({A:\'2U\',O:2V,1j:0.35,1L:V,2a:V,1x:\'/\'},j);$(S).2b(5(){r[r.1k]=S;$(S).Y(\'P\',5(){2c(S);L F})});5 2c(a){p=$(a);2d=$(p).w(\'1M\');2e=/\\[(?:.*)\\]/;2f=2e.2W(2d);1N="1O";8($(p).w(\'D\').Z(\'.2X\')>0){o=F;1N=\'2g\'};k=F;l=0;2Y(i=0;i<r.1k;i++){8($(r[i]).w(\'1M\').Z(2f)!=-1){l++;8(l>1)k=V;8($(r[i]).w(\'D\')==$(a).w(\'D\')){m=l;n=i}}};2h(k);$(\'3.4 p.1P\').1Q(m+j.1x+l);1w();$(\'3.4 #1a\').1l();$(\'.1y\').1R();(1N==\'1O\')?1z():2i()};1S=5(a,b,c,d,e,f,g){$(\'.1y\').1l();E h=1T();8($.16.1U){J=B.1V;K=B.1W}H{J=$(B).s();K=$(B).t()};$(\'3.4 .1m\').1A({\'s\':e,\'t\':c},j.A);11=h[\'1b\']+((J/2)-(d/2));8(11<0)11=0+$(\'3.C\').s();$(\'3.4\').1A({\'z\':11,\'I\':((K/2)-(c/2)),\'t\':c},j.A,5(){$(\'#1n\').w({\'t\':a,\'s\':b});$(\'3.4\').t(c);$(\'3.4 .17\').s(b).t(a);2j();$(\'3.4 #1a\').1o(j.A);8(g)$(\'a.12,a.1p\').1o(j.A)})};5 15(a){8(a==\'R\'){n--;m--}H{n++;m++};8(!q)q=V;$(\'3.4 .17,3.4 .y\').18(j.A);$(\'3.4 #1a\').18(j.A,5(){$(\'.1y\').1R();1z()});1X();$(\'a.12,a.1p\').18(j.A,5(){$(S).1q(\'1p\').1r(\'12\')})};5 X(){$(\'3.4,3.C\').18(j.A,5(){$(\'3.1c\').18(j.A,5(){$(\'3.1c,3.4,3.C\').2Z();8($.16.2k&&$.16.2l==6){$(\'2m\').9(\'1d\',\'1Y\')}})})};5 2n(){8(m==l){$(\'3.4 a.W\').9(\'1d\',\'1B\');$(\'3.4 a.1C\').1r(\'1e\').2o(\'P\')}H{$(\'3.4 a.W\').9(\'1d\',\'1Y\');$(\'3.4 a.1C.1e\').1q(\'1e\').Y(\'P\',5(){15(\'W\');L F})};8(m==1){$(\'3.4 a.R\').9(\'1d\',\'1B\');$(\'3.4 a.1D\').1r(\'1e\').2o(\'P\')}H{$(\'3.4 a.R\').9(\'1d\',\'1Y\');$(\'3.4 a.1D.1e\').1q(\'1e\').Y(\'P\',5(){15(\'R\');L F})};$(\'3.4 p.1P\').1Q(m+j.1x+l);(k)?$c=$(r[n]):$c=$(p);8($c.w(\'1Z\')){$(\'3.4 .1s\').1R().2p(2q($c.w(\'1Z\')))}H{$(\'3.4 .1s\').1l().1Q(\'\')};8($c.2r(\'20\').w(\'2s\')&&j.1L){o=V;$(\'3.C .1t\').2p(2q($c.2r(\'20\').w(\'2s\')))}H{o=F}};5 2t(a,b){21=F;$(\'3.4 .y\').t(a);$(\'3.4 .y p.1s\').t(a-u($(\'3.4 a.X\').9(\'t\')));13=b+u($(\'3.4 .y\').s())+u($(\'3.4 .y\').9(\'T-z\'))+u($(\'3.4 .y\').9(\'T-19\'));U=a;M=b+u($(\'3.C\').s())+u($(\'3.4 .z\').s())+u($(\'3.4 .19\').s());N=a+j.O;1f=a;1g=b;8($.16.1U){J=B.1V;K=B.1W}H{J=$(B).s();K=$(B).t()};8(((N>K)||(M>J))&&q&&j.2a){21=V;8((N>K)&&(M>J)){E c=(N+2u)/K;E d=(M+2u)/J}H{E c=K/N;E d=J/M}8(d>c){1f=1E.1F(a*(1/d));1g=1E.1F(b*(1/d))}H{1f=1E.1F(a*(1/c));1g=1E.1F(b*(1/c))};13=1g+u($(\'3.4 .y\').s())+u($(\'3.4 .y\').9(\'T-z\'))+u($(\'3.4 .y\').9(\'T-19\'));U=1f;M=1g+u($(\'3.C\').s())+u($(\'3.4 .z\').s())+u($(\'3.4 .19\').s());N=1f+j.O;$(\'3.4 .y\').t(U);$(\'3.4 .y p.1s\').t(U-u($(\'3.4 a.X\').9(\'t\')))};L{t:1f,s:1g,M:M,N:N,13:13,U:U,2v:21}};5 1w(){8($(\'3.4\').30()>0){E a=1T();8($.16.1U){J=B.1V;K=B.1W}H{J=$(B).s();K=$(B).t()};8(q){11=(J/2)+a[\'1b\']-($(\'3.4\').s()/2);8(11<0)11=0+$(\'3.C\').s();$(\'3.4\').9({\'z\':11,\'I\':(K/2)+a[\'1u\']-($(\'3.4\').t()/2)});$(\'3.C\').9({\'z\':$(\'3.4\').1h().z-$(\'3.C\').s(),\'I\':$(\'3.4\').1h().I+(j.O/2)})}}};5 2j(){8(k)$(\'3.4 .17\').1o(j.A);$(\'3.4 .y\').1o(j.A);2w()};5 2w(){8(j.1L&&o){$(\'3.C\').9({\'z\':$(\'3.4\').1h().z,\'I\':$(\'3.4\').1h().I+(j.O/2),\'2x\':\'31\'});$(\'3.C 3.1t\').9(\'t\',\'32\');8($(\'3.C\').t()>$(\'3.4\').t()){$(\'3.C 3.1t\').9(\'t\',$(\'3.4\').t()-(j.O*2))}H{$(\'3.C 3.1t\').9(\'t\',\'\')};$(\'3.C\').1A({\'z\':($(\'3.4\').1h().z-22)},j.A)}};5 1X(){$(\'3.C\').1A({\'z\':($(\'3.4\').1h().z)},j.A,5(){$(S).9(\'2x\',\'33\')})};5 1z(){2n();Q=23 24();2y=23 24();8(k)2y.14=$(r[n+1]).w(\'D\');2z=23 24();8(k&&r[n-1])2z.14=$(r[n-1]).w(\'D\');$(\'3.4 .1m\').9(\'34\',\'1B\');8(k){$(\'3.4 #1n\').w(\'14\',$(r[n]).w(\'D\'))}H{$(\'3.4 #1n\').w(\'14\',$(p).w(\'D\'))};Q.36=5(){E a=2t(Q.t,Q.s);Q.t=a[\'t\'];Q.s=a[\'s\'];2A(\'1S(Q.t,Q.s,\'+a["N"]+\',\'+a["M"]+\',\'+a["13"]+\',\'+a["U"]+\',\'+a["2v"]+\')\',2B)};(k)?Q.14=$(r[n]).w(\'D\'):Q.14=$(p).w(\'D\')};5 1T(){1b=B.38||1i.2C.1b||0;1u=B.3a||1i.2C.1u||0;L{1b:1b,1u:1u}};5 29(){$(\'3.1c\').9({\'s\':$(1i).s(),\'t\':$(B).t()})};5 2i(){G=$(p).w(\'1M\').3b(\';\');$(G).2b(5(i){8(G[i].Z(\'t\')>=0)1v=G[i].25(G[i].Z(\'t\')+6,G[i].1k);8(G[i].Z(\'s\')>=0)1G=G[i].25(G[i].Z(\'s\')+7,G[i].1k);8(G[i].Z(\'26\')>=0)2D=G[i].25(G[i].Z(\'26\')+10,G[i].1k)});$(\'.4 #1a\').1H(\'<3c t="\'+1v+\'" s="\'+1G+\'" 3d="3e://3f.3g.3h/2E/3i/3j.3k?3l=3m" 3n="3o/x-2E-2g" 3p="3q" 3r="3s" 26="\'+2D+\'" 3t="3u" 3v="#3w" 3x="3y" 14="\'+$(p).w(\'D\')+\'"/>\');$(\'#1n\').1l();13=u(1G)+u($(\'3.4 .y\').s())+u($(\'3.4 .y\').9(\'T-z\'))+u($(\'3.4 .y\').9(\'T-19\'));U=u(1v)+u($(\'3.4 .y\').t())+u($(\'3.4 .y\').9(\'T-I\'))+u($(\'3.4 .y\').9(\'T-1I\'));M=13+u($(\'3.4 .z\').s())+u($(\'3.4 .19\').s());N=u(1v)+u($(\'3.4 .1m\').9("O-I"))+u($(\'3.4 .1m\').9("O-1I"))+j.O;2A(\'1S(\'+1v+\',\'+1G+\',\'+N+\',\'+M+\',\'+13+\',\'+U+\')\',2B)};5 2h(){2F="<3 v=\'1c\'></3>";$(\'2G\').1H(2F);$(\'3.1c\').9(\'s\',$(1i).s()).Y(\'P\',5(){X()});4=\'<3 v="4"><3 v="z"><3 v="I"></3><3 v="2H"></3><3 v="1I"></3></3><3 v="1m"><a D="#" v="12" 1Z="2I 3z 1O">2I</a><3 v="1y"></3><3 v="17"><a v="W" D="#">W</a><a v="R" D="#">R</a></3><3 2J="1a"><20 2J="1n" 14="" /></3><3 v="y 3A"><a v="X" D="#">3B</a><p v="1s"></p><3 v="2K"><a D="#" v="1D">3C</a><p v="1P">0\'+j.1x+\'0</p><a D="#" v="1C">3D</a></3></3></3><3 v="19"><3 v="I"></3><3 v="2H"></3><3 v="1I"></3></3></3>\';28=\'<3 v="C"><3 v="3E"></3><3 v="1t"></3><3 v="3F"></3></3>\';$(\'2G\').1H(4).1H(28);$(\'.4,.28\').9({\'1j\':0});$(\'a.X\').Y(\'P\',5(){X();L F});$(\'a.12\').Y(\'P\',5(){8($(S).3G(\'12\')){$(S).1q(\'12\').1r(\'1p\');q=F}H{$(S).1q(\'1p\').1r(\'12\');q=V};1X();$(\'3.4 .17,3.4 #1a\').18(j.A);$(\'3.4 .y\').18(j.A,5(){1z()});L F});$(\'.4 .R,.4 .1D\').Y(\'P\',5(){15(\'R\');L F});$(\'.4 .W,.4 .1C\').Y(\'P\',5(){15(\'W\');L F});$(\'.17\').9({\'T-I\':j.O/2});8(!k){$(\'.17,.2K\').1l()};8($.16.2k&&$.16.2l==6){$(\'2m\').9(\'1d\',\'1B\')};$(\'3.1c\').9(\'1j\',0).3H(j.A,j.1j,5(){$(\'3.4\').9(\'1j\',0).1o(j.A,5(){$(\'3.4\').w(\'3I\',\'I:\'+$(\'3.4\').9(\'I\')+\';z:\'+$(\'3.4\').9(\'z\')+\';\')})})}};',62,231,'|||div|pictureHolder|function|||if|css|||||||||||||||||||height|width|parseFloat|class|attr||details|top|animationSpeed|window|prettyPhotoTitle|href|var|false|flashParams|else|left|windowHeight|windowWidth|return|containerHeight|containerWidth|padding|click|imgPreloader|previous|this|margin|contentWidth|true|next|close|bind|indexOf||projectedTop|expand|contentHeight|src|changePicture|browser|hoverContainer|fadeOut|bottom|fullResImageContainer|scrollTop|prettyPhotoOverlay|visibility|disabled|imageWidth|imageHeight|offset|document|opacity|length|hide|content|fullResImage|fadeIn|contract|removeClass|addClass|description|prettyPhotoTitleContent|scrollLeft|flashWidth|_centerPicture|counter_separator_label|loaderIcon|_preload|animate|hidden|arrow_next|arrow_previous|Math|round|flashHeight|append|right|case|break|showTitle|rel|contentType|image|currentTextHolder|text|show|showimage|_getScroll|opera|innerHeight|innerWidth|_hideTitle|visible|title|img|hasBeenResized||new|Image|substring|flashvars||titleHolder|_resizeOverlay|allowresize|each|open|theRel|galleryRegExp|theGallery|flash|_buildOverlay|_writeFlash|_shownav|msie|version|select|_checkPosition|unbind|html|unescape|find|alt|_fitToViewport|200|resized|_showTitle|display|nextImage|prevImage|setTimeout|500|documentElement|flashVars|shockwave|backgroundDiv|body|middle|Expand|id|nav|fn|prettyPhoto|scroll|resize|keyup|switch|keyCode|jQuery|extend|normal|40|exec|swf|for|remove|size|block|auto|none|overflow||onload||pageYOffset||pageXOffset|split|embed|pluginspage|http|www|macromedia|com|download|index|cgi|P1_Prod_Version|ShockwaveFlash|type|application|wmode|opaque|name|prettyFlash|allowscriptaccess|always|bgcolor|FFFFFF|quality|high|the|clearfix|Close|Previous|Next|prettyPhotoTitleLeft|prettyPhotoTitleRight|hasClass|fadeTo|style'.split('|'),0,{}));

// condense
(function($){$.fn.condense=function(options){$.metadata?debug('metadata plugin detected'):debug('metadata plugin not present');var opts=$.extend({},$.fn.condense.defaults,options);return this.each(function(){$this=$(this);var o=$.metadata?$.extend({},opts,$this.metadata()):opts;debug('Condensing ['+$this.text().length+']: '+$this.text());var clone=cloneCondensed($this,o);if(clone){$this.attr('id')?$this.attr('id','condensed_'+$this.attr('id')):false;var controlMore=" <span class='condense_control condense_control_more' style='cursor:pointer;'>"+o.moreText+"</span>";var controlLess=" <span class='condense_control condense_control_less' style='cursor:pointer;'>"+o.lessText+"</span>";clone.append(o.ellipsis+controlMore);$this.after(clone).hide().append(controlLess);$('.condense_control_more',clone).click(function(){debug('moreControl clicked.');triggerExpand($(this),o)});$('.condense_control_less',$this).click(function(){debug('lessControl clicked.');triggerCondense($(this),o)})}})};function cloneCondensed(elem,opts){if($.trim(elem.text()).length<=opts.condensedLength+opts.minTrail){debug('element too short: skipping.');return false}var fullbody=$.trim(elem.html());var fulltext=$.trim(elem.text());var delim=opts.delim;var clone=elem.clone();var delta=0;do{var loc=findDelimiterLocation(fullbody,opts.delim,(opts.condensedLength+delta));clone.html($.trim(fullbody.substring(0,(loc+1))));var cloneTextLength=clone.text().length;var cloneHtmlLength=clone.html().length;delta=clone.html().length-cloneTextLength;debug("condensing... [html-length:"+cloneHtmlLength+" text-length:"+cloneTextLength+" delta: "+delta+" break-point: "+loc+"]")}while(clone.text().length<opts.condensedLength)if((fulltext.length-cloneTextLength)<opts.minTrail){debug('not enough trailing text: skipping.');return false}debug('clone condensed. [text-length:'+cloneTextLength+']');return clone}function findDelimiterLocation(html,delim,startpos){var foundDelim=false;var loc=startpos;do{var loc=html.indexOf(delim,loc);if(loc<0){debug("No delimiter found.");return html.length}foundDelim=true;while(isInsideTag(html,loc)){loc++;foundDelim=false}}while(!foundDelim)debug("Delimiter found in html at: "+loc);return loc}function isInsideTag(html,loc){return(html.indexOf('>',loc)<html.indexOf('<',loc))}function triggerCondense(control,opts){debug('Condense Trigger: '+control.html());var orig=control.parent();var condensed=orig.next();condensed.show();var con_w=condensed.width();var con_h=condensed.height();condensed.hide();var orig_w=orig.width();var orig_h=orig.height();orig.animate({height:con_h,width:con_w,opacity:1},opts.lessSpeed,opts.easing,function(){orig.height(orig_h).width(orig_w).hide();condensed.show()})}function triggerExpand(control,opts){debug('Expand Trigger: '+control.html());var condensed=control.parent();var orig=condensed.prev();orig.show();var orig_w=orig.width();var orig_h=orig.height();orig.width(condensed.width()+"px").height(condensed.height()+"px");condensed.hide();orig.animate({height:orig_h,width:orig_w,opacity:1},opts.moreSpeed,opts.easing);if(condensed.attr('id')){var idAttr=condensed.attr('id');condensed.attr('id','condensed_'+idAttr);orig.attr('id',idAttr)}}function debug($obj){if(window.console&&window.console.log){window.console.log($obj)}};$.fn.condense.defaults={condensedLength:200,minTrail:20,delim:" ",moreText:"[more]",lessText:"[less]",ellipsis:" ( ... )",moreSpeed:"normal",lessSpeed:"normal",easing:"linear"}})(jQuery);

/*
 * jQuery blockUI plugin
 * Version 2.14 (18-JAN-2009)
 * @requires jQuery v1.2.3 or later
 *
 * Examples at: http://malsup.com/jquery/block/
 * Copyright (c) 2007-2008 M. Alsup
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Thanks to Amir-Hossein Sobhi for some excellent contributions!
 */
;(function($){if(/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery)||/^1.1/.test($.fn.jquery)){alert('blockUI requires jQuery v1.2.3 or later!  You are using v'+$.fn.jquery);return}$.blockUI=function(opts){install(window,opts)};$.unblockUI=function(opts){remove(window,opts)};$.growlUI=function(title,message,timeout){var $m=$('<div class="growlUI"></div>');if(title)$m.append('<h1>'+title+'</h1>');if(message)$m.append('<h2>'+message+'</h2>');if(timeout==undefined)timeout=3000;$.blockUI({message:$m,fadeIn:700,fadeOut:1000,centerY:false,timeout:timeout,showOverlay:false,css:$.blockUI.defaults.growlCSS})};$.fn.block=function(opts){return this.each(function(){if($.css(this,'position')=='static')this.style.position='relative';if($.browser.msie)this.style.zoom=1;install(this,opts)})};$.fn.unblock=function(opts){return this.each(function(){remove(this,opts)})};$.blockUI.version=2.14;$.blockUI.defaults={message:'<h1>Please wait...</h1>',css:{padding:0,margin:0,width:'30%',top:'40%',left:'35%',textAlign:'center',color:'#000',border:'3px solid #aaa',backgroundColor:'#fff',cursor:'wait'},overlayCSS:{backgroundColor:'#000',opacity:'0.6'},growlCSS:{width:'350px',top:'10px',left:'',right:'10px',border:'none',padding:'5px',opacity:'0.6',cursor:null,color:'#fff',backgroundColor:'#000','-webkit-border-radius':'10px','-moz-border-radius':'10px'},baseZ:1000,centerX:true,centerY:true,allowBodyStretch:true,constrainTabKey:true,fadeIn:200,fadeOut:400,timeout:0,showOverlay:true,focusInput:true,applyPlatformOpacityRules:true,onUnblock:null,quirksmodeOffsetHack:4};var ie6=$.browser.msie&&/MSIE 6.0/.test(navigator.userAgent);var pageBlock=null;var pageBlockEls=[];function install(el,opts){var full=(el==window);var msg=opts&&opts.message!==undefined?opts.message:undefined;opts=$.extend({},$.blockUI.defaults,opts||{});opts.overlayCSS=$.extend({},$.blockUI.defaults.overlayCSS,opts.overlayCSS||{});var css=$.extend({},$.blockUI.defaults.css,opts.css||{});msg=msg===undefined?opts.message:msg;if(full&&pageBlock)remove(window,{fadeOut:0});if(msg&&typeof msg!='string'&&(msg.parentNode||msg.jquery)){var node=msg.jquery?msg[0]:msg;var data={};$(el).data('blockUI.history',data);data.el=node;data.parent=node.parentNode;data.display=node.style.display;data.position=node.style.position;if(data.parent)data.parent.removeChild(node)}var z=opts.baseZ;var lyr1=($.browser.msie)?$('<iframe class="blockUI" style="z-index:'+z++ +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="javascript:false;"></iframe>'):$('<div class="blockUI" style="display:none"></div>');var lyr2=$('<div class="blockUI blockOverlay" style="z-index:'+z++ +';display:none;cursor:wait;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');var lyr3=full?$('<div class="blockUI blockMsg blockPage" style="z-index:'+z+';display:none;position:fixed"></div>'):$('<div class="blockUI blockMsg blockElement" style="z-index:'+z+';display:none;position:absolute"></div>');if(msg)lyr3.css(css);if(!opts.applyPlatformOpacityRules||!($.browser.mozilla&&/Linux/.test(navigator.platform)))lyr2.css(opts.overlayCSS);lyr2.css('position',full?'fixed':'absolute');if($.browser.msie)lyr1.css('opacity','0.0');$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full?'body':el);var expr=$.browser.msie&&(!$.boxModel||$('object,embed',full?null:el).length>0);if(ie6||expr){if(full&&opts.allowBodyStretch&&$.boxModel)$('html,body').css('height','100%');if((ie6||!$.boxModel)&&!full){var t=sz(el,'borderTopWidth'),l=sz(el,'borderLeftWidth');var fixT=t?'(0 - '+t+')':0;var fixL=l?'(0 - '+l+')':0}$.each([lyr1,lyr2,lyr3],function(i,o){var s=o[0].style;s.position='absolute';if(i<2){full?s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"'):s.setExpression('height','this.parentNode.offsetHeight + "px"');full?s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'):s.setExpression('width','this.parentNode.offsetWidth + "px"');if(fixL)s.setExpression('left',fixL);if(fixT)s.setExpression('top',fixT)}else if(opts.centerY){if(full)s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');s.marginTop=0}else if(!opts.centerY&&full){var top=(opts.css&&opts.css.top)?parseInt(opts.css.top):0;var expression='((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';s.setExpression('top',expression)}})}lyr3.append(msg);if(msg&&(msg.jquery||msg.nodeType))$(msg).show();if(opts.fadeIn){if($.browser.msie&&opts.showOverlay)lyr1.fadeIn(opts.fadeIn);if(opts.showOverlay)lyr2.fadeIn(opts.fadeIn);lyr3.fadeIn(opts.fadeIn)}else{if($.browser.msie&&opts.showOverlay)lyr1.show();if(opts.showOverlay)lyr2.show();lyr3.show()}bind(1,el,opts);if(full){pageBlock=lyr3[0];pageBlockEls=$(':input:enabled:visible',pageBlock);if(opts.focusInput)setTimeout(focus,20)}else center(lyr3[0],opts.centerX,opts.centerY);if(opts.timeout){setTimeout(function(){full?$.unblockUI(opts):$(el).unblock(opts)},opts.timeout)}};function remove(el,opts){var full=el==window;var data=$(el).data('blockUI.history');opts=$.extend({},$.blockUI.defaults,opts||{});bind(0,el,opts);var els=full?$('body').children().filter('.blockUI'):$('.blockUI',el);if(full)pageBlock=pageBlockEls=null;if(opts.fadeOut){els.fadeOut(opts.fadeOut);setTimeout(function(){reset(els,data,opts,el)},opts.fadeOut)}else reset(els,data,opts,el)};function reset(els,data,opts,el){els.each(function(i,o){if(this.parentNode)this.parentNode.removeChild(this)});if(data&&data.el){data.el.style.display=data.display;data.el.style.position=data.position;if(data.parent)data.parent.appendChild(data.el);$(data.el).removeData('blockUI.history')}if(typeof opts.onUnblock=='function')opts.onUnblock(el,opts)};function bind(b,el,opts){var full=el==window,$el=$(el);if(!b&&(full&&!pageBlock||!full&&!$el.data('blockUI.isBlocked')))return;if(!full)$el.data('blockUI.isBlocked',b);if(b&&!opts.showOverlay)return;var events='mousedown mouseup keydown keypress';b?$(document).bind(events,opts,handler):$(document).unbind(events,handler)};function handler(e){if(e.keyCode&&e.keyCode==9){if(pageBlock&&e.data.constrainTabKey){var els=pageBlockEls;var fwd=!e.shiftKey&&e.target==els[els.length-1];var back=e.shiftKey&&e.target==els[0];if(fwd||back){setTimeout(function(){focus(back)},10);return false}}}if($(e.target).parents('div.blockMsg').length>0)return true;return $(e.target).parents().children().filter('div.blockUI').length==0};function focus(back){if(!pageBlockEls)return;var e=pageBlockEls[back===true?pageBlockEls.length-1:0];if(e)e.focus()};function center(el,x,y){var p=el.parentNode,s=el.style;var l=((p.offsetWidth-el.offsetWidth)/2)-sz(p,'borderLeftWidth');var t=((p.offsetHeight-el.offsetHeight)/2)-sz(p,'borderTopWidth');if(x)s.left=l>0?(l+'px'):'0';if(y)s.top=t>0?(t+'px'):'0'};function sz(el,p){return parseInt($.css(el,p))||0}})(jQuery);

/*
 *
 * jQuery listnav plugin
 * Copyright (c) 2008 iHwy, Inc.
 * Author: Jack Killpatrick
 *
 * Version 1.0.1 (10/07/2008)
 * Requires jquery 1.2+ and jquery dimensions plugin OR jquery 1.2.6 (which includes dimensions plugin)
 *
 * Visit http://www.ihwy.com/labs/jquery-listnav-plugin.aspx for more information.
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
*/

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(2($){$.16.17=2(f){3 g=$.1G({},$.16.17.1i,f);3 h=[\'A\',\'B\',\'C\',\'D\',\'E\',\'F\',\'G\',\'H\',\'I\',\'J\',\'K\',\'L\',\'M\',\'N\',\'O\',\'P\',\'Q\',\'R\',\'S\',\'T\',\'U\',\'V\',\'W\',\'X\',\'Y\',\'Z\'];10 7.1j(2(){3 d,6,$6,$4,$9,11;11=7.11;d=$(\'#\'+11+\'-1H\');$6=$(7);3 e,12,p,q;e=[];12=0;p=j;q=\'\';2 1k(){d.1l(1m());$4=$(\'.k-4\',d).m(0,1);5(g.r)$9=$(\'.k-9\',d).m(0,1);$(\'.z\',$4).t(g.1n);1o();1p();1q();1r();5(!g.13)$6.u();5(!g.13)$(\'.v\',$4).n();5(g.18!=\'\')$(\'.\'+g.18,$4).m(0,1).19();w{5(g.13)$(\'.v\',$4).t(g.x);w{1a(3 i=0;i<e.y;i++){5(e[i]>0){$(\'.\'+h[i].14(),$4).m(0,1).19();1I}}}}}2 1s(){$9.1t({1b:$(\'.a\',$4).m(0,1).1J({1c:1d,1K:j}).1b-$9.1L({1c:j})})}2 1o(){3 a;$(\'>8\',$6).1j(2(){a=$(7).1u().1M(/\\s+/g,\'\').14();5(a!=\'\')$(7).t(a.m(0,1))})}2 1q(){3 a=0;3 b;1a(3 i=0;i<h.y;i++){b=h[i].14();a=$(\'>8.\'+b,$6).y;e.1e(a);12+=a;5(g.1v&&(a==0))$(\'.\'+b,$4).t(g.1w)}}2 1p(){$6.1l(\'<8 l="15" 1f="1x:1y">\'+g.1z+\'</8>\')}2 1g(a){10($(a).1N(\'v\'))?12:e[$.1O($(a).1A(\'l\').1B(\' \')[0].1P(),h)]}2 1r(){5(g.r){d.1C(2(){1s()})}5(g.r){$(\'a\',$4).1C(2(){3 a=$(7).1D().1h;3 b=($(7).1Q({1c:j})-1)+\'1R\';3 c=1g(7);$9.1t({1h:a,1E:b}).1u(c).u()});$(\'a\',$4).1S(2(){$9.n()})}$(\'a\',$4).19(2(){$(\'a.\'+g.x,$4).1T(g.x);3 a=$(7).1A(\'l\').1B(\' \')[0];5(a==\'v\'){$(\'>8\',$6).u();$(\'>8.15\',$6).n();p=j}w{5(p){$(\'>8\',$6).n();p=1d}w 5(q!=\'\')$(\'>8.\'+q,$6).n();3 b=1g(7);5(b>0){$(\'>8.15\',$6).n();$(\'>8.\'+a,$6).u()}w $(\'>8.15\',$6).u();q=a}$(7).t(g.x);$(7).1U();10 1d})}2 1m(){3 a=[];1a(3 i=0;i<h.y;i++){5(a.y==0)a.1e(\'<a l="v" 1F="#">1V</a>\');a.1e(\'<a l="\'+h[i].14()+\'" 1F="#">\'+h[i]+\'</a>\')}10\'<o l="k-4">\'+a.1W(\'\')+\'</o><o 1f="1X:1Y"></o>\'+((g.r)?\'<o l="k-9" 1f="1x:1y; 1D:1Z; 1b:0; 1h:0; 1E:20;">0</o>\':\'\')}1k()})};$.16.17.1i={18:\'\',13:j,1v:j,1z:\'21 22 23\',1n:\'k-24\',x:\'k-25\',1w:\'k-26\',r:j}})(27);',62,132,'||function|var|letters|if|list|this|li|letterCount||||||||||true|ln|class|slice|hide|div|isAll|prevLetter|showCounts||addClass|show|all|else|selectedClass|length||||||||||||||||||||||||||||return|id|allCount|includeAll|toLowerCase|noMatch|fn|listnav|initLetter|click|for|top|margin|false|push|style|getLetterCount|left|defaults|each|init|append|createLettersHtml|lastClass|addLIClasses|addNoMatchLI|storeLetterCounts|bindHandlers|setLetterCountTop|css|text|flagDisabled|disabledClass|display|none|noMatchText|attr|split|mouseover|position|width|href|extend|nav|break|offset|border|outerHeight|replace|hasClass|inArray|toUpperCase|outerWidth|px|mouseout|removeClass|blur|ALL|join|clear|both|absolute|20px|No|matching|entries|last|selected|disabled|jQuery'.split('|'),0,{}));

/*
 * jQuery UI 1.5.3
 *
 * Copyright (c) 2008 Paul Bakaus (ui.jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */
;(function($) {

$.ui = {
	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);
				}
			}
		}	
	},
	cssCache: {},
	css: function(name) {
		if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; }
		var tmp = $('<div class="ui-gen">').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];
	},
	disableSelection: function(el) {
		$(el).attr('unselectable', 'on').css('MozUserSelect', 'none');
	},
	enableSelection: function(el) {
		$(el).attr('unselectable', 'off').css('MozUserSelect', '');
	},
	hasScroll: function(e, a) {
		var scroll = /top/.test(a||"top") ? 'scrollTop' : 'scrollLeft', has = false;
		if (e[scroll] > 0) return true; e[scroll] = 1;
		has = e[scroll] > 0 ? true : false; e[scroll] = 0;
		return has;
	}
};


/** jQuery core modifications and additions **/

var _remove = $.fn.remove;
$.fn.remove = function() {
	$("*", this).add(this).triggerHandler("remove");
	return _remove.apply(this, arguments );
};

// $.widget is a factory to create jQuery plugins
// taking some boilerplate code out of the plugin code
// created by Scott González and Jörn Zaefferer
function getter(namespace, plugin, method) {
	var methods = $[namespace][plugin].getter || [];
	methods = (typeof methods == "string" ? methods.split(/,?\s+/) : methods);
	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);
		
		if (isMethodCall && getter(namespace, name, options)) {
			var instance = $.data(this[0], name);
			return (instance ? instance[options].apply(instance, args)
				: undefined);
		}
		
		return this.each(function() {
			var instance = $.data(this, name);
			if (isMethodCall && instance && $.isFunction(instance[options])) {
				instance[options].apply(instance, args);
			} else if (!isMethodCall) {
				$.data(this, name, new $[namespace][name](this, options));
			}
		});
	};
	
	// create widget constructor
	$[namespace][name] = function(element, options) {
		var self = this;
		
		this.widgetName = name;
		this.widgetBaseClass = namespace + '-' + name;
		
		this.options = $.extend({}, $.widget.defaults, $[namespace][name].defaults, options);
		this.element = $(element)
			.bind('setData.' + name, function(e, key, value) {
				return self.setData(key, value);
			})
			.bind('getData.' + name, function(e, key) {
				return self.getData(key);
			})
			.bind('remove', function() {
				return self.destroy();
			});
		this.init();
	};
	
	// add widget prototype
	$[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
};

$.widget.prototype = {
	init: function() {},
	destroy: function() {
		this.element.removeData(this.widgetName);
	},
	
	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');
		}
	},
	
	enable: function() {
		this.setData('disabled', false);
	},
	disable: function() {
		this.setData('disabled', true);
	}
};

$.widget.defaults = {
	disabled: false
};


/** Mouse Interaction Plugin **/

$.ui.mouse = {
	mouseInit: function() {
		var self = this;
	
		this.element.bind('mousedown.'+this.widgetName, function(e) {
			return self.mouseDown(e);
		});
		
		// 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(e) {
		// we may have missed mouseup (out of window)
		(this._mouseStarted && this.mouseUp(e));
		
		this._mouseDownEvent = e;
		
		var self = this,
			btnIsLeft = (e.which == 1),
			elIsCancel = (typeof this.options.cancel == "string" ? $(e.target).parents().add(e.target).filter(this.options.cancel).length : false);
		if (!btnIsLeft || elIsCancel || !this.mouseCapture(e)) {
			return true;
		}
		
		this._mouseDelayMet = !this.options.delay;
		if (!this._mouseDelayMet) {
			this._mouseDelayTimer = setTimeout(function() {
				self._mouseDelayMet = true;
			}, this.options.delay);
		}
		
		if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) {
			this._mouseStarted = (this.mouseStart(e) !== false);
			if (!this._mouseStarted) {
				e.preventDefault();
				return true;
			}
		}
		
		// these delegates are required to keep context
		this._mouseMoveDelegate = function(e) {
			return self.mouseMove(e);
		};
		this._mouseUpDelegate = function(e) {
			return self.mouseUp(e);
		};
		$(document)
			.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
			.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
		
		return false;
	},
	
	mouseMove: function(e) {
		// IE mouseup check - mouseup happened when mouse was out of window
		if ($.browser.msie && !e.button) {
			return this.mouseUp(e);
		}
		
		if (this._mouseStarted) {
			this.mouseDrag(e);
			return false;
		}
		
		if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) {
			this._mouseStarted =
				(this.mouseStart(this._mouseDownEvent, e) !== false);
			(this._mouseStarted ? this.mouseDrag(e) : this.mouseUp(e));
		}
		
		return !this._mouseStarted;
	},
	
	mouseUp: function(e) {
		$(document)
			.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
			.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
		
		if (this._mouseStarted) {
			this._mouseStarted = false;
			this.mouseStop(e);
		}
		
		return false;
	},
	
	mouseDistanceMet: function(e) {
		return (Math.max(
				Math.abs(this._mouseDownEvent.pageX - e.pageX),
				Math.abs(this._mouseDownEvent.pageY - e.pageY)
			) >= this.options.distance
		);
	},
	
	mouseDelayMet: function(e) {
		return this._mouseDelayMet;
	},
	
	// These are placeholder methods, to be overriden by extending plugin
	mouseStart: function(e) {},
	mouseDrag: function(e) {},
	mouseStop: function(e) {},
	mouseCapture: function(e) { return true; }
};

$.ui.mouse.defaults = {
	cancel: null,
	distance: 1,
	delay: 0
};

})(jQuery);
/*
 * jQuery UI Accordion
 * 
 * Copyright (c) 2007, 2008 Jörn Zaefferer
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Accordion
 *
 * Depends:
 *	ui.core.js
 */
(function($) {

$.widget("ui.accordion", {
	init: function() {
		var options = this.options;
		
		if ( options.navigation ) {
			var current = this.element.find("a").filter(options.navigationFilter);
			if ( current.length ) {
				if ( current.filter(options.header).length ) {
					options.active = current;
				} else {
					options.active = current.parent().parent().prev();
					current.addClass("current");
				}
			}
		}
		
		// calculate active if not specified, using the first header
		options.headers = this.element.find(options.header);
		options.active = findActive(options.headers, options.active);
		
		// IE7-/Win - Extra vertical space in Lists fixed
		if ($.browser.msie) {
			this.element.find('a').css('zoom', '1');
		}
		
		if (!this.element.hasClass("ui-accordion")) {
			this.element.addClass("ui-accordion");
			$("<span class='ui-accordion-left'/>").insertBefore(options.headers);
			$("<span class='ui-accordion-right'/>").appendTo(options.headers);
			options.headers.addClass("ui-accordion-header").attr("tabindex", "0");
		}
		
		var maxHeight;
		if ( options.fillSpace ) {
			maxHeight = this.element.parent().height();
			options.headers.each(function() {
				maxHeight -= $(this).outerHeight();
			});
			var maxPadding = 0;
			options.headers.next().each(function() {
				maxPadding = Math.max(maxPadding, $(this).innerHeight() - $(this).height());
			}).height(maxHeight - maxPadding);
		} else if ( options.autoHeight ) {
			maxHeight = 0;
			options.headers.next().each(function() {
				maxHeight = Math.max(maxHeight, $(this).outerHeight());
			}).height(maxHeight);
		}
	
		options.headers
			.not(options.active || "")
			.next()
			.hide();
		options.active.parent().andSelf().addClass(options.selectedClass);
		
		if (options.event) {
			this.element.bind((options.event) + ".accordion", clickHandler);
		}
	},
	activate: function(index) {
		// call clickHandler with custom event
		clickHandler.call(this.element[0], {
			target: findActive( this.options.headers, index )[0]
		});
	},
	destroy: function() {
		this.options.headers.next().css("display", "");
		if ( this.options.fillSpace || this.options.autoHeight ) {
			this.options.headers.next().css("height", "");
		}
		$.removeData(this.element[0], "accordion");
		this.element.removeClass("ui-accordion").unbind(".accordion");
	}
});

function scopeCallback(callback, scope) {
	return function() {
		return callback.apply(scope, arguments);
	};
};

function completed(cancel) {
	// if removed while animated data can be empty
	if (!$.data(this, "accordion")) {
		return;
	}
	
	var instance = $.data(this, "accordion");
	var options = instance.options;
	options.running = cancel ? 0 : --options.running;
	if ( options.running ) {
		return;
	}
	if ( options.clearStyle ) {
		options.toShow.add(options.toHide).css({
			height: "",
			overflow: ""
		});
	}
	$(this).triggerHandler("accordionchange", [$.event.fix({type: 'accordionchange', target: instance.element[0]}), options.data], options.change);
}

function toggle(toShow, toHide, data, clickedActive, down) {
	var options = $.data(this, "accordion").options;
	options.toShow = toShow;
	options.toHide = toHide;
	options.data = data;
	var complete = scopeCallback(completed, this);
	
	// count elements to animate
	options.running = toHide.size() === 0 ? toShow.size() : toHide.size();
	
	if ( options.animated ) {
		if ( !options.alwaysOpen && clickedActive ) {
			$.ui.accordion.animations[options.animated]({
				toShow: jQuery([]),
				toHide: toHide,
				complete: complete,
				down: down,
				autoHeight: options.autoHeight
			});
		} else {
			$.ui.accordion.animations[options.animated]({
				toShow: toShow,
				toHide: toHide,
				complete: complete,
				down: down,
				autoHeight: options.autoHeight
			});
		}
	} else {
		if ( !options.alwaysOpen && clickedActive ) {
			toShow.toggle();
		} else {
			toHide.hide();
			toShow.show();
		}
		complete(true);
	}
}

function clickHandler(event) {
	var options = $.data(this, "accordion").options;
	if (options.disabled) {
		return false;
	}
	
	// called only when using activate(false) to close all parts programmatically
	if ( !event.target && !options.alwaysOpen ) {
		options.active.parent().andSelf().toggleClass(options.selectedClass);
		var toHide = options.active.next(),
			data = {
				options: options,
				newHeader: jQuery([]),
				oldHeader: options.active,
				newContent: jQuery([]),
				oldContent: toHide
			},
			toShow = (options.active = $([]));
		toggle.call(this, toShow, toHide, data );
		return false;
	}
	// get the click target
	var clicked = $(event.target);
	
	// due to the event delegation model, we have to check if one
	// of the parent elements is our actual header, and find that
	// otherwise stick with the initial target
	clicked = $( clicked.parents(options.header)[0] || clicked );
	
	var clickedActive = clicked[0] == options.active[0];
	
	// if animations are still active, or the active header is the target, ignore click
	if (options.running || (options.alwaysOpen && clickedActive)) {
		return false;
	}
	if (!clicked.is(options.header)) {
		return;
	}
	
	// switch classes
	options.active.parent().andSelf().toggleClass(options.selectedClass);
	if ( !clickedActive ) {
		clicked.parent().andSelf().addClass(options.selectedClass);
	}
	
	// find elements to show and hide
	var toShow = clicked.next(),
		toHide = options.active.next(),
		//data = [clicked, options.active, toShow, toHide],
		data = {
			options: options,
			newHeader: clicked,
			oldHeader: options.active,
			newContent: toShow,
			oldContent: toHide
		},
		down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] );
	
	options.active = clickedActive ? $([]) : clicked;
	toggle.call(this, toShow, toHide, data, clickedActive, down );

	return false;
};

function findActive(headers, selector) {
	return selector != undefined
		? typeof selector == "number"
			? headers.filter(":eq(" + selector + ")")
			: headers.not(headers.not(selector))
		: selector === false
			? $([])
			: headers.filter(":eq(0)");
}

$.extend($.ui.accordion, {
	defaults: {
		selectedClass: "selected",
		alwaysOpen: true,
		animated: 'slide',
		event: "click",
		header: "a",
		autoHeight: true,
		running: 0,
		navigationFilter: function() {
			return this.href.toLowerCase() == location.href.toLowerCase();
		}
	},
	animations: {
		slide: function(options, additions) {
			options = $.extend({
				easing: "swing",
				duration: 300
			}, options, additions);
			if ( !options.toHide.size() ) {
				options.toShow.animate({height: "show"}, options);
				return;
			}
			var hideHeight = options.toHide.height(),
				showHeight = options.toShow.height(),
				difference = showHeight / hideHeight;
			options.toShow.css({ height: 0, overflow: 'hidden' }).show();
			options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate({height:"hide"},{
				step: function(now) {
					var current = (hideHeight - now) * difference;
					if ($.browser.msie || $.browser.opera) {
						current = Math.ceil(current);
					}
					options.toShow.height( current );
				},
				duration: options.duration,
				easing: options.easing,
				complete: function() {
					if ( !options.autoHeight ) {
						options.toShow.css("height", "auto");
					}
					options.complete();
				}
			});
		},
		bounceslide: function(options) {
			this.slide(options, {
				easing: options.down ? "bounceout" : "swing",
				duration: options.down ? 1000 : 200
			});
		},
		easeslide: function(options) {
			this.slide(options, {
				easing: "easeinout",
				duration: 700
			});
		}
	}
});

// deprecated, use accordion("activate", index) instead
$.fn.activate = function(index) {
	return this.accordion("activate", index);
};

})(jQuery);
