String.prototype.urlparam = function(param)
{
    param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+param+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( this );
    if( results == null ){
        return "";
    }
    else {
        return results[1];
    }
};

/* jQuery/DOM ready */
jQuery(function() {

    /* if webkit based */
    if (jQuery.browser.webkit) {
        jQuery('body').addClass('webkit');
    }
    /* If IE */
    if (jQuery.browser.msie) {
        jQuery('.btm-rad-7').append('<span class="corner bl" /><span class="corner br" />');
        jQuery('.rad-7').append('<span class="corner tl" /><span class="corner tr" /><span class="corner bl" /><span class="corner br" />');
    }
    /* If IE 7 */
    if (jQuery.browser.version == 7) {
        jQuery('body').addClass('ie7');
    }
    /* If IE 6 */
    if (jQuery.browser.version == 6) {
        jQuery('body').addClass('ie6').prepend('<div class="ie6-user">This site has been optimised for <a href="http://www.getfirefox.com" target="_blank">Firefox</a>, <a href="http://www.apple.com/safari" target="_blank">Safari</a>, <a href="http://www.google.com/chrome" target="_blank">Google Chrome</a> and <a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx" target="_blank">Internet Explorer 7/8</a>.<br />For the best viewing experience we highly recommend that you upgrade your browser</div>');
    }

    $(".nav ul li a").corner();

    ReplaceText();

    jQuery("a[rel^='prettyPhoto']").prettyPhoto({ theme: 'light_rounded' });

});

/*Replace Text with Font Images*/
function ReplaceText() {
    // H Tags
    jQuery("h1.im").each(function() {
        $this = jQuery(this);
        imageinfo = 'text=' + escape($this.text()) + '&size=16';
        $this.html('<img src="/resources/image.php?' + imageinfo + '" alt="' + $this.attr("title") + '" title="' + $this.attr("title") + '" />')
    });

    jQuery("h2").each(function() {
        $this = jQuery(this);
        imageinfo = 'text=' + escape($this.text()) + '&size=14';
        $this.html('<img src="/resources/image.php?' + imageinfo + '" alt="' + $this.attr("title") + '" title="' + $this.attr("title") + '" />')
    });

    jQuery("#site-header ul li a").each(function() {
        $this = jQuery(this);
        imageinfo = 'text=' + escape($this.text()) + '&size=11';
        if ($this.hasClass("selected"))
            imageinfo += '&colour=8f1b8c';
        else
            imageinfo += '&colour=666666';
        $this.html('<img src="/resources/image.php?' + imageinfo + '" alt="' + $this.attr("title") + '" title="' + $this.attr("title") + '" />')
    });
}

/* Create product scrollers */
function MakeProductScoller(el, itemPerPage)
{  
    circular = false;
    /* Create scroller */
    jQuery(el)
        .data('page', 0)
        .data('items', jQuery('li', this).size())
        .jCarouselLite({
            btnNext: jQuery('.btn.next', el),
            btnPrev: jQuery('.btn.prev', el),
            visible: itemPerPage,
            scroll: itemPerPage,
            circular: circular,
            afterEnd: function(el, i, s){             
                /*Only get's triggered when valid click*/
                carousel = jQuery(el).parents('.jCarousel:first'); /*Gets carousel parent*/
                currpage = carousel.data('page') + carousel.data('move'); /*Get current page and move dir*/
                carousel.data('page', currpage); /*Change carousel current page*/
                jQuery('.pages .btn:eq('+(i)+')', carousel).addClass('active').siblings().removeClass('active'); /*Set active page*/
            }
        }).width(700);
    /* How many pages do we need */
    if (circular)
    {
        pages = Math.ceil( Math.ceil(jQuery('li', el).size()/2) / itemPerPage);
    }
    else
    {
        pages = Math.ceil((jQuery('li', el).size()) / itemPerPage);
    }
    for (i=0;i<pages;i++) {
        jQuery('.pages', el).append('<span class="btn page"></span>'); /*Append a page button*/
    }
    jQuery('.pages .btn:first', el).addClass('active'); /*Set first page active*/
}

/* Init Image rotator */
function InitImageRotator()
{
    images = jQuery('.imagerotator a').show();
    i = 0;
    jQuery('.imagerotator a').each(function(){
        jQuery(this).css("z-index", images.length-i);
        i++;
    });
    jQuery('.imagerotator a .overlay').css("z-index", images.length+1);
    
    var img = new Image();
    img.onload = function(){
        jQuery('.imagerotator a .overlay').fadeOut(1000);
        if (images.length > 1)
        {
            setInterval(function(){
                i = 0;
                img = jQuery('.imagerotator a:eq(0)').fadeOut(600, function(){
                    jQuery(this)
                        .nextAll().each(function(){ jQuery(this).css({"z-index":images.length-(i++)}) })
                        .end().css({"z-index":images.length-(i++)}).show()
                        .parent().append(jQuery(this));
                });
            }, 5000);
        }
    };
    img.src  = jQuery('.imagerotator a:eq(0) img').attr('src');
}

/* Sky Checkout */
var Sky_Checkout = {
    Basket: {
        Item: {
            Quantity: {
                timeout: null,
                el: null,
                Change: function(){
                    /* Get qty change */
                    var change = jQuery(this).hasClass('up') ? 1 : -1;
                    
                    /* Current qty */
                    currQty = parseInt(jQuery(this).siblings('input.req-qty').val());    
                    newQty = currQty;
                    
                    /* If valid change */
                    if ( (currQty > 1 && change < 0) || (currQty >= 1 && change > 0) )
                    {
                        /* Set new qty */
                        newQty = currQty + change;
                    }
                    /* set input qty */
                    jQuery(this).siblings('input.req-qty').val(newQty);
                    
                    /* If we have have clicked on a qty-change a el already */
                    if (Sky_Checkout.Basket.Item.Quantity.el != null)
                    {
                        /* Is it a different basket item? */
                        if (Sky_Checkout.Basket.Item.Quantity.el.attr("id") != jQuery(this).siblings('input.req-qty').attr("id"))
                        {
                            /* Yes, update previous el */
                            Sky_Checkout.Basket.Item.Quantity.Update(Sky_Checkout.Basket.Item.Quantity.el);
                        }    
                    }
                    /* Set "active" item */
                    Sky_Checkout.Basket.Item.Quantity.el = jQuery(this).siblings('input.req-qty');
                    
                    /* Clear timeout - so it doesn't fire multiple times */
                    clearTimeout(Sky_Checkout.Basket.Item.Quantity.timeout);
                    
                    /* Set timeout */
                    Sky_Checkout.Basket.Item.Quantity.timeout = setTimeout(function(){
                        /* Update basket item */
                        Sky_Checkout.Basket.Item.Quantity.Update(Sky_Checkout.Basket.Item.Quantity.el);
                        Sky_Checkout.Basket.Item.Quantity.timeout = null;
                    },500);
                    
                    return false;
                },
                Update: function(qtyEl){
                    /* Set ajax data */
                    dataOpts = JSON.stringify({ SKU_Code: qtyEl.siblings('input.sku-code').val(), Quantity: qtyEl.val(), UpdateEl: qtyEl.attr("id") });
                        
                    /* Update item qty in basket */
                    jQuery.ajax({
                        type: "POST",
                        cache   : false,
                        beforeSend: function(){
                            /* Set buy button to "processing" */
                            qtyEl.parents('.qty:first').append('<img src="/assets/visual/ajax-loader.gif" alt="Updating" title="Updating" class="updating" />');
                        },
                        url: "/shop/basket/update_item",
                        data: dataOpts,
                        contentType: "application/json; charset=utf-8",
                        dataType: "string",
                        success: function(data){
                        
                            /* get el updated (input id) from data */
                            
                            /* remove updating image */
                            qtyEl.parents('.qty:first').children('img').remove();
                            
                            /* Change line-total */
                            var price = qtyEl.parents('.item:first').find('> div.price:first').html();
                            price = parseFloat(price.substring(1, price.length));
                            var linetotal = (price * parseInt(qtyEl.val())).toFixed(2);
                            qtyEl.parents('.item:first').find('> div.line-total').html("&pound;"+linetotal );
                            
                            /* Update totals html */
                            jQuery('#my-basket > div > .footer').find('.totals').remove().end().append(data);
                        },
                        error: function(err)
                        {
                            /* remove updating image */
                            qtyEl.parents('.qty:first').children('img').remove();
                            alert(err.responseText);
                        }
                    });
                }
            },
            Remove: function(){
                removeEl = jQuery(this);
        
                /* Set ajax data */
                dataOpts = JSON.stringify({ SKU_Code: removeEl.siblings('.change').find('input.sku-code').val() });
                    
                /* Update item qty in basket */
                jQuery.ajax({
                    type: "POST",
                    cache   : false,
                    beforeSend: function(){
                        /* Set buy button to "processing" */
                        removeEl.parents('.qty:first').append('<img src="/assets/visual/ajax-loader.gif" alt="Removing" title="Removing" />');
                    },
                    url: "/shop/basket/remove_item",
                    data: dataOpts,
                    contentType: "application/json; charset=utf-8",
                    dataType: "string",
                    success: function(data){            
                        /* remove updating image */
                        removeEl.parents('.qty:first').children('img').remove();
                        removeEl.parents('.item:first').fadeOut(250, function(){ jQuery(this).remove(); });
                        
                        /* Update totals html */
                        jQuery('#my-basket > div > .footer').find('.totals').remove().end().append(data);
                    },
                    error: function(err)
                    {
                        /* remove updating image */
                        removeEl.parents('.qty:first').children('img').remove();
                        alert(err.responseText);
                    }
                });
                
                return false;
            }
        },
        CheckPromoCode: function(){
            var el = jQuery(this).html('checking... <img src="/assets/visual/ajax-loader-bluebg.gif" alt="" title="Checking Code..." />');
    
            /* Set ajax data */
            dataOpts = JSON.stringify({ PromoCode: jQuery(this).prev().find('input').val() });
                
            /* Apply promo code */
            jQuery.ajax({
                type: "POST",
                cache: false,
                url: "/shop/basket/apply_promotion",
                data: dataOpts,
                contentType: "application/json; charset=utf-8",
                dataType: "string",
                success: function(data){
                    el.addClass('valid').html('Code Valid!')
                        .nextAll('.action-message.error').remove();
                    /* Update totals html */
                    jQuery('#my-basket > div > .footer').find('.totals').remove().end().append(data);
                },
                error: function(err)
                {
                    el.removeClass('valid').html('Apply Code');
                    el.nextAll('.action-message').remove().end().after('<div class="action-message error">' + err.responseText + '</div>');
                    var t = setTimeout(function(){
                        jQuery(el).nextAll('.action-message').css("overflow", "hidden").animate({ height: 0, opacity: 0 }, 350, function(){ jQuery(this).remove(); });
                        t = null;
                    }, 5000);
                }
            });
            return false;
        },
        ChangeDelivery: function(){
            var DelID = jQuery('option:selected', this).val();
    
            if (DelID > 0)
            {
                var el = jQuery(this).after('<img src="/assets/visual/ajax-loader.gif" alt="" class="updating" title="Updating..." />');
                
                /* Set ajax data */
                dataOpts = JSON.stringify({ DeliveryOption: DelID });
                    
                /* Update delivery */
                jQuery.ajax({
                    type: "POST",
                    cache: false,
                    url: "/shop/basket/change_delivery",
                    data: dataOpts,
                    contentType: "application/json; charset=utf-8",
                    dataType: "string",
                    success: function(data){
                        el.nextAll('.action-message.error, img').remove();
                        jQuery('.checkout').show().filter('.no-delivery-method').hide();
                        /* Update totals html */
                        jQuery('#my-basket > div > .footer').find('.totals').remove().end().append(data);
                    },
                    error: function(err)
                    {
                        el.nextAll('.action-message, img').remove().end().after('<div class="action-message error">' + err.responseText + '</div>');
                    }
                });
            }
            return false;
        }
    }
};

/* Sky Shop */
var Sky_Shop = {
    Product: {
        OptionSelect: function(){  
        },
        ShowTotal: function(){            
        },
        CalculateCost: function(){
        },
        AddToBasket: function(btnEl, paramsEl){
            ProductID = jQuery('.input_productID', paramsEl).val();
            SKU_Code = jQuery('.input_SKU', paramsEl).val().replace("S","");
            Options = jQuery('.input_OptionsExtra', paramsEl).val();
            Quantity = jQuery('.options .quantity').val();
            Quantity = parseInt(Quantity == '' ? 1 : Quantity);
            buy_img = jQuery(btnEl).find('img');
            
            /* if we have a sku_code and a quantity > 0, AND not currently adding to basket */
            if ( SKU_Code > 0 && Quantity > 0 && (!buy_img.hasClass('processing')))
            {            
                /* Set ajax data */
                dataOpts = JSON.stringify({ SKU_Code: SKU_Code, Quantity: Quantity }); 
                
                /* Add product to basket */
                jQuery.ajax({
                    type: "POST",
                    cache   : false,
                    beforeSend: function(){
                        /* Set buy button to "processing" */
                        buy_img
                            .addClass('processing')
                            .data('img', buy_img.attr('src'))
                            .attr('src', '/assets/visual/ajax-loader.gif');
                    },
                    url: "/shop/basket/add_item",
                    data: dataOpts,
                    contentType: "application/json; charset=utf-8",
                    dataType: "string",
                    success: function(data){
                        /* Update quick-look basket */
                        jQuery('#header .basket').html(data);
                        
                        jQuery.prettyPhoto.open('/my-basket/item-added/?ajax=true&width=450&height=100', 'Added To Basket', '');
                        
                        setTimeout(function(){
                            /* Set buy button to normal state */
                            buy_img.removeClass('processing').attr('src', buy_img.data('img'));
                        }, 1000);
                    },
                    error: function(err)
                    {
                        /* Set buy button to normal state */
                        buy_img.removeClass('processing').attr('src', buy_img.data('img'));
                        
                        alert(err.responseText);                        
                    }
                });
            }
            
            if (!(Quantity > 0))
            {
                alert("Please make sure a selection has been made for each option and a quantity greater than 0 has been entered");
            }
            
            return false;
        }
    }
};

/* jCarousel Lite */
(function($){$.fn.jCarouselLite=function(o){o=$.extend({btnPrev:null,btnNext:null,btnGo:null,mouseWheel:false,auto:null,speed:200,easing:null,vertical:false,circular:true,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null,indx:0},o||{});return this.each(function(){var running=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var div=$(this),ul=$("ul",div),tLi=$("li",ul),tl=tLi.size(),v=o.visible;if(o.circular){ul.prepend(tLi.slice(tl-v-1+1).clone()).append(tLi.slice(0,v).clone());o.start+=v}var li=$("li",ul),itemLength=li.size(),curr=o.start;div.css("visibility","visible");li.css({overflow:"hidden",float:o.vertical?"none":"left"});ul.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});div.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"});var liSize=o.vertical?height(li):width(li);var ulSize=liSize*itemLength;var divSize=liSize*v;li.css({width:li.width(),height:li.height()});ul.css(sizeCss,ulSize+"px").css(animCss,-(curr*liSize));div.css(sizeCss,divSize+"px");if(tl<=o.visible){$(o.btnNext).addClass("disabled")}else{$(o.btnNext).removeClass("disabled")}if(o.btnPrev)$(o.btnPrev).click(function(){if(!$(this).hasClass("disabled")){o.indx>0?o.indx--:o.indx=0;return go(curr-o.scroll)}else{return false}});if(o.btnNext)$(o.btnNext).click(function(){if(!$(this).hasClass("disabled")){o.indx<Math.ceil(tl/o.visible)-2?o.indx++:o.indx=Math.ceil(tl/o.visible)-1;return go(curr+o.scroll)}else{return false}});if(o.btnGo)$.each(o.btnGo,function(i,val){$(val).click(function(){return go(o.circular?o.visible+i:i)})});if(o.mouseWheel&&div.mousewheel)div.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll)});if(o.auto)setInterval(function(){go(curr+o.scroll)},o.auto+o.speed);function vis(){return li.slice(curr).slice(0,v)};function go(to){if(!running){if(o.beforeStart)o.beforeStart.call(this,vis());if(o.circular){if(to<=o.start-v-1){ul.css(animCss,-((itemLength-(v*2))*liSize)+"px");curr=to==o.start-v-1?itemLength-(v*2)-1:itemLength-(v*2)-o.scroll}else if(to>=itemLength-v+1){ul.css(animCss,-((v)*liSize)+"px");curr=to==itemLength-v+1?v+1:v+o.scroll}else curr=to}else{if(to<0||to>itemLength)return;else curr=to}running=true;ul.animate(animCss=="left"?{left:-(curr*liSize)}:{top:-(curr*liSize)},o.speed,o.easing,function(){if(o.afterEnd!=null){o.afterEnd(this,o.indx,vis())}running=false});if(!o.circular){$(o.btnPrev).removeClass("disabled");$(o.btnNext).removeClass("disabled");if(o.indx==0){$(o.btnPrev).addClass("disabled")}if(o.indx==Math.ceil(tl/o.visible)-1){$(o.btnNext).addClass("disabled")}}}return false}})};function css(el,prop){return parseInt($.css(el[0],prop))||0};function width(el){return el[0].offsetWidth+css(el,'marginLeft')+css(el,'marginRight')};function height(el){return el[0].offsetHeight+css(el,'marginTop')+css(el,'marginBottom')}})(jQuery);

/*
 * jQuery BBQ: Back Button & Query Library - v1.0.2 - 10/10/2009
 * http://benalman.com/projects/jquery-bbq-plugin/
 * 
 * Copyright (c) 2009 "Cowboy" Ben Alman
 * Licensed under the MIT license
 * http://benalman.com/about/license/
 */
(function($,c){var g,k=document.location,i=Array.prototype.slice,E=decodeURIComponent,a=$.param,m,d,p,n=$.bbq=$.bbq||{},o,e,z,b="hashchange",v="querystring",y="fragment",q="hash",x="elemUrlAttr",h="href",D="src",C=$.browser,l=C.msie&&C.version<8,j="on"+b in c&&!l,r=/^.*\?|#.*$/g,A=/^.*\#/,t={};function s(F){return typeof F==="string"}function w(G){var F=i.call(arguments,1);return function(){return G.apply(this,F.concat(i.call(arguments)))}}function f(G,O,F,H,K){var M,L,J,N,I;if(H!==g){J=F.match(G?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);I=J[3]||"";if(K===2&&s(H)){L=H.replace(O,"")}else{N=d(J[2]);H=s(H)?d[G?y:v](H):H;L=K===2?H:K===1?$.extend({},H,N):$.extend({},N,H);L=a(L)}M=J[1]+(G?"#":L||!J[1]?"?":"")+L+I}else{if(F){M=F.replace(O,"")}else{M=G?k[q]?k[h].replace(O,""):"":k.search.replace(/^\??/,"")}}return M}a[v]=w(f,0,r);a[y]=m=w(f,1,A);$.deparam=d=function(I,G){var H={},F={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(M,O){var L=O.split("="),P=E(L[0]),K,Q=H,N=0,R=P.split("]["),J=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[J])){R[J]=R[J].replace(/\]$/,"");R=R.shift().split("[").concat(R);J=R.length-1}else{J=0}if(L.length===2){K=E(L[1]);if(G){K=K&&!isNaN(K)?+K:K==="undefined"?g:F[K]!==g?F[K]:K}if(J){for(;N<=J;N++){P=R[N]===""?Q.length:R[N];Q=Q[P]=N<J?Q[P]||(R[N+1]&&isNaN(R[N+1])?{}:[]):K}}else{if($.isArray(H[P])){H[P].push(K)}else{if(H[P]!==g){H[P]=[H[P],K]}else{H[P]=K}}}}else{if(P){H[P]=G?g:""}}});return H};function u(I,H,G,F){if(G===g||typeof G==="boolean"){F=G;G=a[I]()}else{G=s(G)?G.replace(H,""):G}return d(G,F)}d[v]=w(u,v,r);d[y]=p=w(u,y,A);$[x]||($[x]=function(F){return $.extend(t,F)})({a:h,base:h,iframe:D,img:D,input:D,form:"action",link:h,script:D});e=$[x];function B(I,F,H,G){if(!s(H)&&typeof H!=="object"){G=H;H=F;F=g}return this.each(function(){var L=$(this),J=F||e()[(this.nodeName||"").toLowerCase()]||"",K=J&&L.attr(J)||"";L.attr(J,a[I](K,H,G))})}$.fn[v]=w(B,v);$.fn[y]=w(B,y);n.pushState=o=function(I,H){if(s(I)&&/^#/.test(I)&&H===g){H=2}var G=I!==g,F=m(k[h],G?I:{},G?H:2);k[h]=F+(/#/.test(F)?"":"#")};n.getState=function(G,F){return G===g||typeof G==="boolean"?p(G):p(F)[G]};n.pollDelay=100;$.event.special[b]={setup:function(){if(j){return false}z.start()},teardown:function(){if(j){return false}z.stop()},add:function(F,H,G){return function(J){var I=J[y]=m();J.getState=function(L,K){return L===g||typeof L==="boolean"?d(I,L):d(I,K)[L]};F.apply(this,arguments)}}};z=(function(){var G={},K,F,H,J;function I(){H=J=function(L){return L};if(l){F=$('<iframe src="javascript:0"/>').hide().appendTo("body")[0].contentWindow;J=function(){return F.document.location[q].replace(/^#/,"")};H=function(N,L){if(N!==L){var M=F.document;M.open();M.close();M.location[q]="#"+N}};H(m())}}G.start=function(){if(K){return}var M=m();H||I();(function L(){var O=m(),N=J(M);if(O!==M){H(M=O,N);$(c).trigger(b)}else{if(N!==M){o("#"+N)}}K=setTimeout(L,n.pollDelay)})()};G.stop=function(){if(!F){K&&clearTimeout(K);K=0}};return G})()})(jQuery,this);

/* Copyright (c) 2006 Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * 
 * See http://kelvinluck.com/assets/jquery/jScrollPane/
 * $Id: jScrollPane.js 33 2008-12-10 22:55:28Z kelvin.luck $
 */
(function(A){A.jScrollPane={active:[]};A.fn.jScrollPane=function(C){C=A.extend({},A.fn.jScrollPane.defaults,C);var B=function(){return false};return this.each(function(){var O=A(this);O.css("overflow","hidden");var X=this;if(A(this).parent().is(".jScrollPaneContainer")){var Ac=C.maintainPosition?O.position().top:0;var L=A(this).parent();var d=L.innerWidth();var Ad=L.outerHeight();var M=Ad;A(">.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown",L).remove();O.css({top:0})}else{var Ac=0;this.originalPadding=O.css("paddingTop")+" "+O.css("paddingRight")+" "+O.css("paddingBottom")+" "+O.css("paddingLeft");this.originalSidePaddingTotal=(parseInt(O.css("paddingLeft"))||0)+(parseInt(O.css("paddingRight"))||0);var d=O.innerWidth();var Ad=O.innerHeight();var M=Ad;O.wrap(A("<div></div>").attr({className:"jScrollPaneContainer"}).css({height:Ad+"px",width:d+"px"}));A(document).bind("emchange",function(Ae,Af,p){O.jScrollPane(C)})}if(C.reinitialiseOnImageLoad){var N=A.data(X,"jScrollPaneImagesToLoad")||A("img",O);var G=[];if(N.length){N.each(function(p,Ae){A(this).bind("load",function(){if(A.inArray(p,G)==-1){G.push(Ae);N=A.grep(N,function(Ag,Af){return Ag!=Ae});A.data(X,"jScrollPaneImagesToLoad",N);C.reinitialiseOnImageLoad=false;O.jScrollPane(C)}}).each(function(Af,Ag){if(this.complete||this.complete===undefined){this.src=this.src}})})}}var o=this.originalSidePaddingTotal;var l={height:"auto",width:d-C.scrollbarWidth-C.scrollbarMargin-o+"px"};if(C.scrollbarOnLeft){l.paddingLeft=C.scrollbarMargin+C.scrollbarWidth+"px"}else{l.paddingRight=C.scrollbarMargin+"px"}O.css(l);var m=O.outerHeight();var i=Ad/m;if(i<0.99){var H=O.parent();H.append(A("<div></div>").attr({className:"jScrollPaneTrack"}).css({width:C.scrollbarWidth+"px"}).append(A("<div></div>").attr({className:"jScrollPaneDrag"}).css({width:C.scrollbarWidth+"px"}).append(A("<div></div>").attr({className:"jScrollPaneDragTop"}).css({width:C.scrollbarWidth+"px"}),A("<div></div>").attr({className:"jScrollPaneDragBottom"}).css({width:C.scrollbarWidth+"px"}))));var z=A(">.jScrollPaneTrack",H);var P=A(">.jScrollPaneTrack .jScrollPaneDrag",H);if(C.showArrows){var g;var Ab;var S;var r;var j=function(){if(r>4||r%4==0){y(u+Ab*b)}r++};var K=function(p){A("html").unbind("mouseup",K);g.removeClass("jScrollActiveArrowButton");clearInterval(S)};var Z=function(){A("html").bind("mouseup",K);g.addClass("jScrollActiveArrowButton");r=0;j();S=setInterval(j,100)};H.append(A("<a></a>").attr({href:"javascript:;",className:"jScrollArrowUp"}).css({width:C.scrollbarWidth+"px"}).html("Scroll up").bind("mousedown",function(){g=A(this);Ab=-1;Z();this.blur();return false}).bind("click",B),A("<a></a>").attr({href:"javascript:;",className:"jScrollArrowDown"}).css({width:C.scrollbarWidth+"px"}).html("Scroll down").bind("mousedown",function(){g=A(this);Ab=1;Z();this.blur();return false}).bind("click",B));var Q=A(">.jScrollArrowUp",H);var J=A(">.jScrollArrowDown",H);if(C.arrowSize){M=Ad-C.arrowSize-C.arrowSize;z.css({height:M+"px",top:C.arrowSize+"px"})}else{var s=Q.height();C.arrowSize=s;M=Ad-s-J.height();z.css({height:M+"px",top:s+"px"})}}var w=A(this).css({position:"absolute",overflow:"visible"});var D;var Y;var b;var u=0;var V=i*Ad/2;var a=function(Ae,Ag){var Af=Ag=="X"?"Left":"Top";return Ae["page"+Ag]||(Ae["client"+Ag]+(document.documentElement["scroll"+Af]||document.body["scroll"+Af]))||0};var f=function(){return false};var v=function(){n();D=P.offset(false);D.top-=u;Y=M-P[0].offsetHeight;b=2*C.wheelSpeed*Y/m};var E=function(p){v();V=a(p,"Y")-u-D.top;A("html").bind("mouseup",T).bind("mousemove",h);if(A.browser.msie){A("html").bind("dragstart",f).bind("selectstart",f)}return false};var T=function(){A("html").unbind("mouseup",T).unbind("mousemove",h);V=i*Ad/2;if(A.browser.msie){A("html").unbind("dragstart",f).unbind("selectstart",f)}};var y=function(Ae){Ae=Ae<0?0:(Ae>Y?Y:Ae);u=Ae;P.css({top:Ae+"px"});var Af=Ae/Y;w.css({top:((Ad-m)*Af)+"px"});O.trigger("scroll");if(C.showArrows){Q[Ae==0?"addClass":"removeClass"]("disabled");J[Ae==Y?"addClass":"removeClass"]("disabled")}};var h=function(p){y(a(p,"Y")-D.top-V)};var q=Math.max(Math.min(i*(Ad-C.arrowSize*2),C.dragMaxHeight),C.dragMinHeight);P.css({height:q+"px"}).bind("mousedown",E);var k;var R;var I;var t=function(){if(R>8||R%4==0){y((u-((u-I)/2)))}R++};var Aa=function(){clearInterval(k);A("html").unbind("mouseup",Aa).unbind("mousemove",e)};var e=function(p){I=a(p,"Y")-D.top-V};var U=function(p){v();e(p);R=0;A("html").bind("mouseup",Aa).bind("mousemove",e);k=setInterval(t,100);t()};z.bind("mousedown",U);H.bind("mousewheel",function(Ae,Ag){v();n();var Af=u;y(u-Ag*b);var p=Af!=u;return !p});var F;var W;function c(){var p=(F-u)/C.animateStep;if(p>1||p<-1){y(u+p)}else{y(F);n()}}var n=function(){if(W){clearInterval(W);delete F}};var x=function(Af,p){if(typeof Af=="string"){$e=A(Af,O);if(!$e.length){return}Af=$e.offset().top-O.offset().top}H.scrollTop(0);n();var Ae=-Af/(Ad-m)*Y;if(p||!C.animateTo){y(Ae)}else{F=Ae;W=setInterval(c,C.animateInterval)}};O[0].scrollTo=x;O[0].scrollBy=function(Ae){var p=-parseInt(w.css("top"))||0;x(p+Ae)};v();x(-Ac,true);A("*",this).bind("focus",function(Ah){var Ag=A(this);var Aj=0;while(Ag[0]!=O[0]){Aj+=Ag.position().top;Ag=Ag.offsetParent()}var p=-parseInt(w.css("top"))||0;var Ai=p+Ad;var Af=Aj>p&&Aj<Ai;if(!Af){var Ae=Aj-C.scrollbarMargin;if(Aj>p){Ae+=A(this).height()+15+C.scrollbarMargin-Ad}x(Ae)}});if(location.hash){x(location.hash)}A(document).bind("click",function(Ae){$target=A(Ae.target);if($target.is("a")){var p=$target.attr("href");if(p.substr(0,1)=="#"){x(p)}}});A.jScrollPane.active.push(O[0])}else{O.css({height:Ad+"px",width:d-this.originalSidePaddingTotal+"px",padding:this.originalPadding});O.parent().unbind("mousewheel")}})};A.fn.jScrollPane.defaults={scrollbarWidth:10,scrollbarMargin:5,wheelSpeed:18,showArrows:false,arrowSize:0,animateTo:false,dragMinHeight:1,dragMaxHeight:99999,animateInterval:100,animateStep:3,maintainPosition:true,scrollbarOnLeft:false,reinitialiseOnImageLoad:false};A(window).bind("unload",function(){var C=A.jScrollPane.active;for(var B=0;B<C.length;B++){C[B].scrollTo=C[B].scrollBy=null}})})(jQuery);

/* json2.js 
 * 2008-01-17
 * Public Domain
 * No warranty expressed or implied. Use at your own risk.
 * See http://www.JSON.org/js.html
*/
if(!this.JSON){JSON=function(){function f(n){return n<10?'0'+n:n;}
Date.prototype.toJSON=function(){return this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z';};var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};function stringify(value,whitelist){var a,i,k,l,r=/["\\\x00-\x1f\x7f-\x9f]/g,v;switch(typeof value){case'string':return r.test(value)?'"'+value.replace(r,function(a){var c=m[a];if(c){return c;}
c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+
(c%16).toString(16);})+'"':'"'+value+'"';case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
if(typeof value.toJSON==='function'){return stringify(value.toJSON());}
a=[];if(typeof value.length==='number'&&!(value.propertyIsEnumerable('length'))){l=value.length;for(i=0;i<l;i+=1){a.push(stringify(value[i],whitelist)||'null');}
return'['+a.join(',')+']';}
if(whitelist){l=whitelist.length;for(i=0;i<l;i+=1){k=whitelist[i];if(typeof k==='string'){v=stringify(value[k],whitelist);if(v){a.push(stringify(k)+':'+v);}}}}else{for(k in value){if(typeof k==='string'){v=stringify(value[k],whitelist);if(v){a.push(stringify(k)+':'+v);}}}}
return'{'+a.join(',')+'}';}}
return{stringify:stringify,parse:function(text,filter){var j;function walk(k,v){var i,n;if(v&&typeof v==='object'){for(i in v){if(Object.prototype.hasOwnProperty.apply(v,[i])){n=walk(i,v[i]);if(n!==undefined){v[i]=n;}}}}
return filter(k,v);}
if(/^[\],:{}\s]*$/.test(text.replace(/\\./g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof filter==='function'?walk('',j):j;}
throw new SyntaxError('parseJSON');}};}();}
