// The cookie name to use for storing the blog-side comment session cookie.
var mtCookieName = "mt_blog2_user";
var mtCookieDomain = ".summerzipper.com";
var mtCookiePath = "/";
var mtCookieTimeout = 14400;


function mtHide(id) {
    var el = (typeof id == "string") ? document.getElementById(id) : id;
    if (el) el.style.display = 'none';
}


function mtShow(id) {
    var el = (typeof id == "string") ? document.getElementById(id) : id;
    if (el) el.style.display = 'block';
}


function mtAttachEvent(eventName,func) {
    var onEventName = 'on' + eventName;
    var old = window[onEventName];
    if( typeof old != 'function' )
        window[onEventName] = func;
    else {
        window[onEventName] = function( evt ) {
            old( evt );
            return func( evt );
        };
    }
}


function mtFireEvent(eventName,param) {
    var fn = window['on' + eventName];
    if (typeof fn == 'function') return fn(param);
    return;
}


function mtRelativeDate(ts, fds) {
    var now = new Date();
    var ref = ts;
    var delta = Math.floor((now.getTime() - ref.getTime()) / 1000);

    var str;
    if (delta < 60) {
        str = '直前';
    } else if (delta <= 86400) {
        // less than 1 day
        var hours = Math.floor(delta / 3600);
        var min = Math.floor((delta % 3600) / 60);
        if (hours == 1)
            str = '1 時間前';
        else if (hours > 1)
            str = '2 時間前'.replace(/2/, hours);
        else if (min == 1)
            str = '1 分前';
        else
            str = '2 分前'.replace(/2/, min);
    } else if (delta <= 604800) {
        // less than 1 week
        var days = Math.floor(delta / 86400);
        var hours = Math.floor((delta % 86400) / 3600);
        if (days == 1)
            str = '1 日前';
        else if (days > 1)
            str = '2 日前'.replace(/2/, days);
        else if (hours == 1)
            str = '1 時間前';
        else
            str = '2 時間前'.replace(/2/, hours);
    }
    return str ? str : fds;
}


function mtEditLink(entry_id, author_id) {
    var u = mtGetUser();
    if (! u) return;
    if (! entry_id) return;
    if (! author_id) return;
    if (u.id != author_id) return;
    var link = '<a href="mt.cgi?__mode=view&amp;_type=entry&amp;id=' + entry_id + '">編集</a>';
    document.write(link);
}


function mtCommentFormOnFocus() {
    // if CAPTCHA is enabled, this causes the captcha image to be
    // displayed if it hasn't been already.
    mtShowCaptcha();
}


var mtCaptchaVisible = false;
function mtShowCaptcha() {
    var u = mtGetUser();
    if ( u && u.is_authenticated ) return;
    if (mtCaptchaVisible) return;
    var div = document.getElementById('comments-open-captcha');
    if (div) {
        div.innerHTML = '';
        mtCaptchaVisible = true;
    }
}



var is_preview;
var user;

function mtSetUser(u) {
    if (u) {
        // persist this
        user = u;
        mtSaveUser();
        // sync up user greeting
        mtFireEvent('usersignin');
    }
}


function mtEscapeJS(s) {
    s = s.replace(/'/g, "&apos;");
    return s;
}


function mtUnescapeJS(s) {
    s = s.replace(/&apos;/g, "'");
    return s;
}


function mtBakeUserCookie(u) {
    var str = "";
    if (u.name) str += "name:'" + mtEscapeJS(u.name) + "';";
    if (u.url) str += "url:'" + mtEscapeJS(u.url) + "';";
    if (u.email) str += "email:'" + mtEscapeJS(u.email) + "';";
    if (u.is_authenticated) str += "is_authenticated:'1';";
    if (u.profile) str += "profile:'" + mtEscapeJS(u.profile) + "';";
    if (u.userpic) str += "userpic:'" + mtEscapeJS(u.userpic) + "';";
    if (u.sid) str += "sid:'" + mtEscapeJS(u.sid) + "';";
    str += "is_trusted:'" + (u.is_trusted ? "1" : "0") + "';";
    str += "is_author:'" + (u.is_author ? "1" : "0") + "';";
    str += "is_banned:'" + (u.is_banned ? "1" : "0") + "';";
    str += "can_post:'" + (u.can_post ? "1" : "0") + "';";
    str += "can_comment:'" + (u.can_comment ? "1" : "0") + "';";
    str = str.replace(/;$/, '');
    return str;
}


function mtUnbakeUserCookie(s) {
    if (!s) return;

    var u = {};
    var m;
    while (m = s.match(/^((name|url|email|is_authenticated|profile|userpic|sid|is_trusted|is_author|is_banned|can_post|can_comment):'([^']+?)';?)/)) {
        s = s.substring(m[1].length);
        if (m[2].match(/^(is|can)_/)) // boolean fields
            u[m[2]] = m[3] == '1' ? true : false;
        else
            u[m[2]] = mtUnescapeJS(m[3]);
    }
    if (u.is_authenticated) {
        u.is_anonymous = false;
    } else {
        u.is_anonymous = true;
        u.can_post = false;
        u.is_author = false;
        u.is_banned = false;
        u.is_trusted = false;
    }
    return u;
}


function mtGetUser() {
    if (!user) {
        var cookie = mtGetCookie(mtCookieName);
        if (!cookie) return;
        user = mtUnbakeUserCookie(cookie);
        if (! user) {
            user = {};
            user.is_anonymous = true;
            user.can_post = false;
            user.is_author = false;
            user.is_banned = false;
            user.is_trusted = false;
        }
    }
    return user;
}


var mtFetchedUser = false;

function mtFetchUser(cb) {
    if (!cb) cb = 'mtSetUser';
    if ( ( cb == 'mtSetUser' ) && mtGetUser() ) {
        var url = document.URL;
        url = url.replace(/#.+$/, '');
        url += '#comments-open';
        location.href = url;
    } else {
        // we aren't using AJAX for this, since we may have to request
        // from a different domain. JSONP to the rescue.
        mtFetchedUser = true;
        var script = document.createElement('script');
        var ts = new Date().getTime();
        script.src = 'http://www.summerzipper.com/mt/mt-comments.cgi?__mode=session_js&blog_id=2&jsonp=' + cb + '&ts=' + ts;
        (document.getElementsByTagName('head'))[0].appendChild(script);
    }
}



function mtRememberMeOnClick(b) {
    if (!b.checked)
        mtClearUser(b.form);
    return true;
}



var mtRequestSubmitted = false;
function mtCommentOnSubmit(f) {
    if (!mtRequestSubmitted) {
        mtRequestSubmitted = true;

        if (f.armor)
            f.armor.value = '1703f9e28380b48e3d73b307c931a7e95aaf0dc7';
        if (f.bakecookie && f.bakecookie.checked)
            mtSaveUser(f);

        // disable submit buttons
        if (f.preview_button) f.preview_button.disabled = true;
        if (f.post) f.post.disabled = true;

        var u = mtGetUser();
        if ( !is_preview && ( u && u.is_authenticated ) ) {
            // validate session; then submit
            mtFetchedUser = false;
            mtFetchUser('mtCommentSessionVerify');
            return false;
        }

        return true;
    }
    return false;
}

function mtCommentSessionVerify(app_user) {
    var u = mtGetUser();
    var f = document['comments_form'];
    if ( u && app_user && app_user.sid && ( u.sid == app_user.sid ) ) {
        f.submit();
    } else {
        alert('セッションの有効期限が切れています。再度サインインしてください。');
        mtClearUser();
        mtFireEvent('usersignin');

    }
}

function mtUserOnLoad() {
    var u = mtGetUser();

    // if the user is authenticated, hide the 'anonymous' fields
    // and any captcha input if already shown
    if ( document.getElementById('comments-form')) {
        if ( u && u.is_authenticated ) {
            mtShow('comments-form');
            mtHide('comments-open-data');
            if (mtCaptchaVisible)
                mtHide('comments-open-captcha');
        } else {

        }
        if ( u && u.is_banned )
            mtHide('comments-form');

        // if we're previewing a comment, make sure the captcha
        // field is visible
        if (is_preview)
            mtShowCaptcha();
        else
            mtShowGreeting();

        // populate anonymous comment fields if user is cookied as anonymous
        var cf = document['comments_form'];
        if (cf) {
            if (u && u.is_anonymous) {
                if (u.email) cf.email.value = u.email;
                if (u.name) cf.author.value = u.name;
                if (u.url) cf.url.value = u.url;
                if (cf.bakecookie)
                    cf.bakecookie.checked = u.name || u.email;
            } else {
                if (u && u.sid && cf.sid)
                    cf.sid.value = u.sid;
            }
            if (cf.post.disabled)
                cf.post.disabled = false;
            if (cf.preview_button.disabled)
                cf.preview_button.disabled = false;
            mtRequestSubmitted = false;
        }
    }
}




function mtEntryOnLoad() {
    mtHide('trackbacks-info');
    mtHide('comments-open');
    mtFireEvent('usersignin');
}

function mtEntryOnUnload() {
    if (mtRequestSubmitted) {
        var cf = document['comments_form'];
        if (cf) {
            if (cf.post && cf.post.disabled)
                cf.post.disabled = false;
            if (cf.preview_button && cf.preview_button.disabled)
                cf.preview_button.disabled = false;
        }
        mtRequestSubmitted = false;
    }
    return true;
}

mtAttachEvent('usersignin', mtUserOnLoad);



function mtSignIn() {
    var doc_url = document.URL;
    doc_url = doc_url.replace(/#.+/, '');
    var url = 'http://www.summerzipper.com/mt/mt-comments.cgi?__mode=login&blog_id=2';
    if (is_preview) {
        if ( document['comments_form'] ) {
            var entry_id = document['comments_form'].entry_id.value;
            url += '&entry_id=' + entry_id;
        } else {
            url += '&return_url=http%3A%2F%2Fwww.summerzipper.com%2F';
        }
    } else {
        url += '&return_url=' + encodeURIComponent(doc_url);
    }
    mtClearUser();
    location.href = url;
}

function mtSignInOnClick(sign_in_element) {
    var el;
    if (sign_in_element) {
        // display throbber
        el = document.getElementById(sign_in_element);
        if (!el)  // legacy MT 4.x element id
            el = document.getElementById('comment-form-external-auth');
    }
    if (el)
        el.innerHTML = 'サインインします... <span class="status-indicator">&nbsp;</span>';

    mtClearUser(); // clear any 'anonymous' user cookie to allow sign in
    mtFetchUser('mtSetUserOrLogin');
    return false;
}

function mtSetUserOrLogin(u) {
    if (u && u.is_authenticated) {
        mtSetUser(u);
    } else {
        // user really isn't logged in; so let's do this!
        mtSignIn();
    }
}


function mtSignOut(entry_id) {
    mtClearUser();
    var doc_url = document.URL;
    doc_url = doc_url.replace(/#.+/, '');
    var url = 'http://www.summerzipper.com/mt/mt-comments.cgi?__mode=handle_sign_in&static=0&logout=1';
    if (is_preview) {
        if ( document['comments_form'] ) {
            var entry_id = document['comments_form'].entry_id.value;
            url += '&entry_id=' + entry_id;
        } else {
            url += '&return_url=http%3A%2F%2Fwww.summerzipper.com%2F';
        }
    } else {
        url += '&return_url=' + encodeURIComponent(doc_url);
    }
    location.href = url;
}


function mtSignOutOnClick() {
    mtSignOut();
    return false;
}



function mtShowGreeting() {

    mtShowCaptcha();

}



function mtReplyCommentOnClick(parent_id, author) {
    mtShow('comment-form-reply');

    var checkbox = document.getElementById('comment-reply');
    var label = document.getElementById('comment-reply-label');
    var text = document.getElementById('comment-text');

    // Populate label with new values
    var reply_text = '\<a href=\"#comment-__PARENT__\" onclick=\"location.href=this.href; return false\"\>__AUTHOR__からのコメント\<\/a\>に返信';
    reply_text = reply_text.replace(/__PARENT__/, parent_id);
    reply_text = reply_text.replace(/__AUTHOR__/, author);
    label.innerHTML = reply_text;

    checkbox.value = parent_id; 
    checkbox.checked = true;
    try {
        // text field may be hidden
        text.focus();
    } catch(e) {
    }

    mtSetCommentParentID();
}


function mtSetCommentParentID() {
    var checkbox = document.getElementById('comment-reply');
    var parent_id_field = document.getElementById('comment-parent-id');
    if (!checkbox || !parent_id_field) return;

    var pid = 0;
    if (checkbox.checked == true)
        pid = checkbox.value;
    parent_id_field.value = pid;
}


function mtSaveUser(f) {
    // We can't reliably store the user cookie during a preview.
    if (is_preview) return;

    var u = mtGetUser();

    if (f && (!u || u.is_anonymous)) {
        if ( !u ) {
            u = {};
            u.is_authenticated = false;
            u.can_comment = true;
            u.is_author = false;
            u.is_banned = false;
            u.is_anonymous = true;
            u.is_trusted = false;
        }
        if (f.author != undefined) u.name = f.author.value;
        if (f.email != undefined) u.email = f.email.value;
        if (f.url != undefined) u.url = f.url.value;
    }

    if (!u) return;

    var cache_period = mtCookieTimeout * 1000;

    // cache anonymous user info for a long period if the
    // user has requested to be remembered
    if (u.is_anonymous && f && f.bakecookie && f.bakecookie.checked)
        cache_period = 365 * 24 * 60 * 60 * 1000;

    var now = new Date();
    mtFixDate(now);
    now.setTime(now.getTime() + cache_period);

    var cmtcookie = mtBakeUserCookie(u);
    mtSetCookie(mtCookieName, cmtcookie, now, mtCookiePath, mtCookieDomain,
        location.protocol == 'https:');
}


function mtClearUser() {
    user = null;
    mtDeleteCookie(mtCookieName, mtCookiePath, mtCookieDomain,
        location.protocol == 'https:');
}


function mtSetCookie(name, value, expires, path, domain, secure) {
    if (domain && domain.match(/^\.?localhost$/))
        domain = null;
    var curCookie = name + "=" + escape(value) +
        (expires ? "; expires=" + expires.toGMTString() : "") +
        (path ? "; path=" + path : "") +
        (domain ? "; domain=" + domain : "") +
        (secure ? "; secure" : "");
    document.cookie = curCookie;
}


function mtGetCookie(name) {
    var prefix = name + '=';
    var c = document.cookie;
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return '';
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}


function mtDeleteCookie(name, path, domain, secure) {
    if (mtGetCookie(name)) {
        if (domain && domain.match(/^\.?localhost$/))
            domain = null;
        document.cookie = name + "=" +
            (path ? "; path=" + path : "") +
            (domain ? "; domain=" + domain : "") +
            (secure ? "; secure" : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function mtFixDate(date) {
    var skew = (new Date(0)).getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}


function mtGetXmlHttp() {
    if ( !window.XMLHttpRequest ) {
        window.XMLHttpRequest = function() {
            var types = [
                "Microsoft.XMLHTTP",
                "MSXML2.XMLHTTP.5.0",
                "MSXML2.XMLHTTP.4.0",
                "MSXML2.XMLHTTP.3.0",
                "MSXML2.XMLHTTP"
            ];

            for ( var i = 0; i < types.length; i++ ) {
                try {
                    return new ActiveXObject( types[ i ] );
                } catch( e ) {}
            }

            return undefined;
        };
    }
    if ( window.XMLHttpRequest )
        return new XMLHttpRequest();
}

// BEGIN: fast browser onload init
// Modifications by David Davis, DWD
// Dean Edwards/Matthias Miller/John Resig
// http://dean.edwards.name/weblog/2006/06/again/?full#comment5338

function mtInit() {
    // quit if this function has already been called
    if (arguments.callee.done) return;

    // flag this function so we don't do the same thing twice
    arguments.callee.done = true;

    // kill the timer
    // DWD - check against window
    if ( window._timer ) clearInterval(window._timer);

    // DWD - fire the window onload now, and replace it
    if ( window.onload && ( window.onload !== window.mtInit ) ) {
        window.onload();
        window.onload = function() {};
    }
}

/* for Mozilla/Opera9 */
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", mtInit, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
    if (this.readyState == "complete") {
        mtInit(); // call the onload handler
    }
};
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
    _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            mtInit(); // call the onload handler
        }
    }, 10);
}

/* for other browsers */
window.onload = mtInit;

// END: fast browser onload init







(function(b){b.fn.sudoSlider=function(e){var d=true;var c=!d;var h={prevNext:d,prevHtml:'<a href="#" class="prevBtn"> previous </a>',nextHtml:'<a href="#" class="nextBtn"> next </a>',controlsShow:d,controlsAttr:'id="controls"',controlsFadeSpeed:"400",controlsFade:d,insertAfter:d,firstShow:c,firstHtml:'<a href="#" class="firstBtn"> first </a>',lastShow:c,lastHtml:'<a href="#" class="lastBtn"> last </a>',numericAttr:'class="controls"',numericText:["1"],vertical:c,speed:"800",ease:"swing",auto:c,pause:"2000",continuous:c,clickableAni:c,numeric:c,updateBefore:c,history:c,speedhistory:"400",autoheight:d,customLink:c,fade:c,crossFade:d,fadespeed:"1000",ajax:c,loadingText:"Loading Content...",preloadAjax:c,startSlide:c,ajaxLoadFunction:c,beforeAniFunc:c,afterAniFunc:c,uncurrentFunc:c,currentFunc:c,autowidth:d,slideCount:1,resumePause:false};var e=b.extend(h,e);var f=[e.controlsShow,e.controlsFadeSpeed,e.controlsFade,e.insertAfter,e.firstShow,e.lastShow,e.vertical,e.speed,e.ease,e.auto,e.pause,e.continuous,e.prevNext,e.numeric,e.numericAttr,e.numericText,e.clickableAni,e.history,e.speedhistory,e.autoheight,e.customLink,e.fade,e.crossFade,e.fadespeed,e.updateBefore,e.ajax,e.preloadAjax,e.startSlide,e.ajaxLoadFunction,e.beforeAniFunc,e.afterAniFunc,e.uncurrentFunc,e.currentFunc,e.prevHtml,e.nextHtml,e.loadingText,e.firstHtml,e.controlsAttr,e.lastHtml,e.autowidth,e.slideCount,e.resumePause];var g=this;return this.each(function(){var an,W,V,k,af,ac,ap,ae,O,am,av,ao,ak,j,m,E,u,G,aw,A,M,N,P,D,ar,B,ai,x,p,X,J,n=b(this);ad(n,c,c);function ad(az,ay,w){aw=c;an=d;if(f[9]){f[11]=d}W=az.children("ul");V=W.children("li");k=V;af=V.length;ac=V.eq(0).outerWidth(d);ap=V.eq(0).outerHeight(d);if(f[25]){if(W.length==0){az.append("<ul></ul>");W=az.children("ul")}if(f[25].length>af){for(var ax=1;ax<=f[25].length-af;ax++){W.append("<li><p>"+f[35]+"</p></li>")}V=W.children("li");af=V.length;ac=V.eq(0).width()}}ae=0;O=ae;am=ae;av=af-1;ao=d;ak=c;j=c;m=c;E=0;u=new Array();G=c;aw=c;A=screen.fontSmoothingEnabled;az.css("overflow","hidden");if(az.css("position")=="static"){az.css("position","relative")}V.css("float","left");if(w||w===0){if(J){J--}if(!J){f[25]=false}}else{if(f[25]&&f[11]&&f[40]!=1){J=0;for(var t=0;t<af;t++){if(f[25][t]){Y(t,t,c,0,function(){ad(az,ay,t)});f[25][t]=c;J++}}}}if(!J){for(var ax=0;ax<af;ax++){if(f[15][ax]==undefined){f[15][ax]=(ax+1)}if(f[25]&&f[25][ax]==undefined){f[25][ax]=c}}if(f[11]){t=0;if(f[6]){for(ax=f[40];ax>=1;ax--){var aA=V.eq(-f[40]+ax-1).clone();t=t+aA.outerWidth(d);aA.css("margin-top","-"+t+"px");W.prepend(aA);W.append(V.eq(f[40]-ax).clone().css({"z-index":"0"}))}}if(!f[6]){for(ax=f[40];ax>=1;ax--){var aA=V.eq(-f[40]+ax-1).clone();t=t+aA.outerWidth(d);aA.css("margin-left","-"+t+"px");W.prepend(aA);W.append(V.eq(f[40]-ax).clone().css({"z-index":"0"}))}}if(f[25]){if(f[25][0]){Y("last",0,c,0,c)}if(f[25][af-1]){Y("first",(af-1),c,0,c);Y(av,av,c,0,c);f[25][af-1]=c}}}au();k=W.children("li");M=c;if(f[0]){M=b("<span "+f[37]+"></span>");if(f[3]){b(az).after(M)}else{b(az).before(M)}if(f[13]){G=M.prepend("<ol "+f[14]+"></ol>").children();var s=f[11]?1:f[40];for(var ax=0;ax<af-s+1;ax++){u[ax]=b(document.createElement("li")).attr({rel:(ax+1)}).html('<a href="#"><span>'+f[15][ax]+"</span></a>").appendTo(G).click(function(){ag(b(this).attr("rel")-1,d);return c})}}if(f[4]){P=ab(f[36],"first")}if(f[5]){D=ab(f[38],"last")}if(f[12]){ar=ab(f[34],"next");B=ab(f[33],"prev")}}if(f[26]){r()}f[1]=l(f[1]);f[7]=l(f[7]);f[10]=l(f[10]);f[18]=l(f[18]);f[23]=l(f[23]);if(f[9]){ai=L(f[10])}if(f[20]){b(f[20]).live("click",function(){t=b(this).attr("rel");if(t){if(t=="stop"){clearTimeout(ai)}else{if(t=="start"){ai=L(f[10]);f[9]=d}else{if(t=="block"){ao=c}else{if(t=="unblock"){ao=d}else{if(ao){ag((t==parseInt(t))?t-1:t,d)}}}}}}return c})}if(ay){aj(ay,c,c,c)}else{if(f[17]){b.address.init(function(aB){if(!ay){aj(I(aB.value),c,c,c)}}).change(function(aC){var aB=I(aC.value);if(aB!=ae){ag(aB,c)}})}else{if(f[27]){aj(f[27]-1,c,c,c)}else{aj(0,c,c,c)}}}}}function r(){for(var s=0;s<=av;s++){if(f[25][s]){Y(s,s,c,0,c);f[25][s]=c}}}function au(){a=0;if(f[6]){for(var s=-1;s<=af;s++){a=a+V.eq(s).outerHeight(d)}W.height(a*4)}else{for(var s=-1;s<=af;s++){a=a+V.eq(s).outerWidth(d)}W.width(a*4)}}function L(s){return setTimeout(function(){ag("next",c)},s)}function l(s){if(parseInt(s)){var t=parseInt(s)}else{var t=400;switch(s){case"fast":t=200;case"normal":t=400;case"medium":t=400;case"slow":t=600}}return t}function ab(s,t){return b(s).prependTo(M).click(function(){ag(t,d);return c})}function ag(w,t){if(!aw){if(f[9]){var s=f[7];if(j&&f[22]){s=parseInt((s)*(3/5))}else{if(j){s=0}}if(t){clearTimeout(ai);if(f[41]){ai=L(s+f[41])}}else{ai=L(f[10]+s)}}if(f[21]){F(w,t)}else{if(f[11]){a=ae;if(a<0){a=a+af}if(a>av){a=a-af}if(w==a+1){w="next"}if(w==a-1){w="prev"}if(a==0&&w==av){w="prev"}if(a==av&&w==0){w="next"}}aj(w,t,d,c)}}}function K(t,s){t.each(function(){var ax=(this.tagName.toLowerCase()==="img")?b(this):b("img",this),ay=this,w=0,az=function(){if(typeof s==="function"){s(ay)}};if(ax.length){ax.each(function(){var aA=this,aB=function(aC){if((aA.complete)||(aA.readyState=="complete"&&aC.type=="readystatechange")){if(++w===ax.length){az()}}else{if(aA.readyState===undefined){b(aA).attr("src",b(aA).attr("src"))}}};b(aA).bind("load readystatechange",function(aC){aB(aC)});aB({type:"readystatechange"})})}else{az()}})}function H(t){var ax=c;var s=t.length;var w=t.substr(s-4,4);if(w==".jpg"||w==".png"||w==".bmp"||w==".gif"){ax=d}var w=t.substr(s-5,5);if(w==".jpeg"){ax=d}return ax}function T(az,ay,s){if(!f[11]){if(s){var ax=ar,t=D,aA="next",w="last",aB=f[5]}else{var ax=B,t=P,aA="prev",w="first",aB=f[4]}if(f[12]){if(az==0){ax.fadeOut(ay)}else{ax.fadeIn(ay)}}if(aB){if(az==0){t.fadeOut(ay)}else{t.fadeIn(ay)}}if(f[20]){b(f[20]).filter(function(aC){return(b(this).attr("rel")==aA||b(this).attr("rel")==w)}).fadeTo(ay,az,function(){if(az==0){b(this).hide()}})}}}function q(s,t){if(s==0){T(0,t,c)}else{T(1,t,c)}if(s>=af-parseInt(f[40],10)){T(0,t,d)}if(s<af-parseInt(f[40],10)){T(1,t,d)}}function z(t){t=parseInt((t>av)?t=0:((t<0)?t=av+t+1:t))+1;for(var s=0;s<u.length;s++){ah(u[s],t)}if(f[20]){ah(f[20],t)}}function ah(t,s){b(t).filter(".current").removeClass("current").each(function(){if(b.isFunction(f[31])){f[31].call(this,b(this).attr("rel"))}});b(t).filter(function(){return b(this).attr("rel")==s}).addClass("current").each(function(w){if(b.isFunction(f[32])){f[32].call(this,s)}})}function I(w){var ax=0;for(var s=0;s<=af;s=s+1){if(f[15][s]==w){ax=s}}return ax}function y(s,t){if(f[19]){C(s,t)}if(f[39]){o(s,t)}}function C(s,t){n.ready(function(){if(s==af){s=0}var w=V.eq(s).height();if(w!=0){aa(w,t)}K(V.eq(s),function(ax){n.ready(function(){w=b(ax).height();if(w!=0){aa(w,t)}})})})}function o(s,t){n.ready(function(){if(s==af){s=0}var w=V.eq(s).width();if(w!=0){al(w,t)}K(V.eq(s),function(ax){n.ready(function(){w=b(ax).width();if(w!=0){al(w,t)}})})})}function al(t,s){n.animate({width:t},{queue:c,duration:s,easing:f[8]})}function aa(s,t){n.animate({height:s},{queue:c,duration:t,easing:f[8]})}function S(){if(f[6]){W.css("margin-top",Z(ae,c))}else{W.css("margin-left",Z(ae,d))}}function Z(s,ax){var az=0;var t=1;if(f[11]){t=1-f[40]}var ay=0;if(f[11]){ay=f[40]}for(var w=0;w<=s-t;w++){if(ax){az=az-k.eq(w+ay).outerWidth(d)}else{az=az-k.eq(w+ay).outerHeight(d)}}return az}function aq(){if(f[11]){if(ae>av){ae=0}if(ae<1-f[40]){ae=af-f[40]}}else{if(ae>av){ae=0}if(ae<0){ae=av}}if(ae==av&&!f[21]){r()}if(!f[24]){z(ae)}S();ao=d;if(f[17]&&ak){window.location.hash=f[15][ae]}if(!j){a=ae+1;if(a<1){a=a+af}if(a>af){a=a-af}at(V.eq(ae),a);if(f[11]&&!f[21]){if(ae<f[40]){at(k.eq((ae<0)?ae+f[40]:ae-f[40]),a)}if(ae>av-f[40]){at(k.eq(f[40]+ae-av-1),a)}}}}function at(t,s){if(b.isFunction(f[30])){f[30].call(t,s)}}function v(t,s){if(b.isFunction(f[29])){f[29].call(t,s)}}function U(s,w){var t=ae;switch(s){case"next":t=(w>=av)?(f[11]?t+1:av):t+1;break;case"prev":t=(t<=0)?(f[11]?t-1:0):t-1;break;case"first":t=0;break;case"last":t=av;break;default:t=parseInt(s);break}return t}function Y(ay,ax,aC,t,s){var w=c;if(parseInt(ay)||ay==0){w=V.eq(ay)}else{if(ay=="last"){w=b("li:last",n)}else{w=b("li:first",n)}var az=d}var aB=(j)?(!f[22]?parseInt(f[23]*(2/5)):f[23]):t;var aA=ax+1;if(H(f[25][ax])){w.html(" ").append(b(new Image()).attr("src",f[25][ax]));K(w,function(aE){var aF=b(aE).children();aD(aF);function aD(aJ){var aI=aJ.width(),aG=aJ.height(),aH=aJ.parent().width();if(aI==0){setTimeout(function(){aD(aJ)},1)}else{aJ.attr({oldheight:aG,oldwidth:aI});if(aI>aH){aJ.animate({width:aH,height:(aG/aI)*aH},0).parent().animate({height:(aG/aI)*aH},0).css("height","auto")}if(b.isFunction(f[28])){f[28].call(b(aE),aA,d)}R(aJ.parent(),az,s);if(aC){y(ay,aB)}}}})}else{w.load(f[25][ax],function(aE,aD,aF){R(b(this),az,s);if(aC){S()}if(aD=="error"||!b(this).html()){b(this).html("Sorry but there was an error: "+(aF.status?aF.status:"no content")+" "+aF.statusText)}if(aD!="error"&&b.isFunction(f[28])){f[28].call(b(this),aA,c)}if(aC){y(ax,aB)}})}}function R(w,t,s){if(b.isFunction(s)){s()}if(t){S()}au()}function F(ay,ax){if(ay!=ae&&!aw&&ao){m=c;if(f[24]){z(U(ay,O))}ao=!ax;var az=(!ax&&!f[9]&&f[17])?f[23]*(f[18]/f[7]):f[23];var aB=U(ay,O);if(aB>av){aB=0}if(aB<0){aB=av}if(f[2]){q(aB,f[1])}if(f[25]&&f[25][aB]){Y(aB,aB,c,az,function(){f[25][aB]=c;ao=d;S();F(aB,d)})}else{y(aB,f[23]);var aA=V.eq(aB);v(aA,aB+1);if(f[22]){aA.clone().prependTo(n).css({"z-index":"100000",position:"absolute","list-style":"none",top:"0",left:"0"}).hide().fadeIn(f[23],function(){if(A){this.style.removeAttribute("filter")}ao=d;j=d;aj(aB,c,c,c);b(this).remove();if(f[17]&&ax){window.location.hash=f[15][ae]}j=c;at(aA,aB+1)})}else{var w=parseInt((az)*(3/5)),t=az-w,s=V.children();s.stop().fadeTo(t,0.0001,function(){ao=d;j=d;aj(aB,c,c,c);ao=!ax;s.add(V).stop().fadeTo(w,1,function(){if(A){this.style.removeAttribute("filter")}if(f[17]&&ax){window.location.hash=f[15][ae]}ao=d;j=c;at(aA,aB+1)})})}}}}function aj(az,aC,ax,aG){if((ao&&!aw&&(U(az,O)!=ae||an))||aG){m=c;ao=(!aC&&!f[9])?d:f[16];ak=aC;O=ae;ae=U(az,O);if(f[24]){z(ae)}var aE=Math.sqrt(Math.abs(O-ae)),ay=parseInt(aE*f[7]);if(!aC&&!f[9]){ay=parseInt(aE*f[18])}if(!ax){ay=0}var aA=ae;if(aA<0){aA=aA+af}if(aA>av){aA=aA-af}if(aG){ay=p;if(X){X--}}else{if(f[25]){if(f[25][aA]){Y(aA,aA,d,ay,c);f[25][aA]=c;m=d}if(!j){var s=(O>ae)?ae:O,aF=(O>ae)?O:ae;X=0;p=ay;for(var aD=s;aD<=aF;aD++){if(aD<=av&&aD>=0&&f[25][aD]){Y(aD,aD,c,ay,function(){aj(az,aC,ax,aD)});f[25][aD]=c;X++}}}if(aA+1<=av&&f[25][aA+1]){Y(aA+1,aA+1,c,0,c);f[25][aA+1]=c}}}if(!X){if(ae<1-1){var t=k.eq(f[40]+ae)}if(ae>av){var t=k.eq(ae-af-f[40])}if(!j){v(V.eq(aA),aA+1);if(f[11]){if(ae<f[40]){v(k.eq((ae<0)?ae+f[40]:ae-f[40]),aA+1)}if(ae>av-f[40]||ae==-f[40]){v(k.eq((ae==-f[40])?-1:f[40]+ae-av-1),aA+1)}}}if(!j&&!m){y(ae,ay)}if(!f[6]){var w=Z(ae,true);W.animate({marginLeft:w},{queue:c,duration:ay,easing:f[8],complete:aq})}else{var w=Z(ae,false);W.animate({marginTop:w},{queue:c,duration:ay,easing:f[8],complete:aq})}if(f[2]){var aB=f[1];if(!aC&&!f[9]){aB=(f[18]/f[7])*f[1]}if(!ax){aB=0}if(j){aB=parseInt((f[23])*(3/5))}q(ae,aB)}an=c}}}function Q(s){var ax=["controlsShow","controlsFadeSpeed","controlsFade","insertAfter","firstShow","lastShow","vertical","speed","ease","auto","pause","continuous","prevNext","numeric","numericAttr","numericText","clickableAni","history","speedhistory","autoheight","customLink","fade","crossFade","fadespeed","updateBefore","ajax","preloadAjax","startSlide","ajaxLoadFunction","beforeAniFunc","afterAniFunc","uncurrentFunc","currentFunc","prevHtml","nextHtml","loadingText","firstHtml","controlsAttr","lastHtml","autowidth","slideCount","resumePause"];for(var t=0;t<ax.length;t++){if(ax[t]==s){var w=t}}return w}g.getOption=function(s){return f[Q(s)]};g.setOption=function(s,t){g.destroy();f[Q(s)]=t;g.init()};g.insertSlide=function(t,w,s){g.destroy();if(w>af){w=af}var t="<li>"+t+"</li>";if(!w||w==0){W.prepend(t)}else{V.eq(w-1).after(t)}if(w<x||(!w||w==0)){x++}if(f[15].length<w){f[15].length=w}if(!s){s=parseInt(w,10)+1}f[15].splice(w,0,s);g.init()};g.removeSlide=function(s){s--;g.destroy();V.eq(s).remove();f[15].splice(s,1);if(s<x){x--}g.init()};g.goToSlide=function(s){ag((s==parseInt(s))?s-1:s,d)};g.block=function(){ao=c};g.unblock=function(){ao=d};g.startAuto=function(){f[9]=d;ai=L(f[10])};g.stopAuto=function(){clearTimeout(ai)};g.destroy=function(){x=ae;if(M){M.remove()}aw=d;b(f[20]).die("click");if(f[11]){for(a=1;a<=f[40];a++){k.eq(a-1).remove();k.eq(-a).remove()}}};g.init=function(){if(aw){ad(n,x,c)}};g.adjust=function(s){if(!s){s=0}au();y(i,s)};g.getValue=function(s){switch(s){case"currentSlide":return ae+1;case"totalSlides":return af;case"clickable":return ao;case"destroyed":return aw}return undefined}})}})(jQuery);
