﻿/// <reference path="libs/jquery-1.4.2-vsdoc.js" />
/// <reference path="libs/jquery-1.4.2.js" />

// o n document ready
// using the $ alias, without relying on the global alias.

jQuery(function ($) {
    /// <param name="j" type="jQuery" />

    // Show/hide Myprofile page
    if ($('#ctl00_MainContentPlaceHolder_LeftColumnPlaceHolder_myprofileOpenSection').val() != '') {
        $($('#ctl00_MainContentPlaceHolder_LeftColumnPlaceHolder_myprofileOpenSection').val()).show();

    }

    $('#ShowPassword').click(function () {
        $('#fsUserInformation').hide();
        $('#fsUserChangePassword').show();
        $('#ctl00_MainContentPlaceHolder_LeftColumnPlaceHolder_myprofileOpenSection').val('#fsUserChangePassword');
        $('#ShowPassword').addClass('selected');
        $('#ShowUserInformation').removeClass('selected');

    });
    $('#ShowUserInformation').click(function () {
        $('#fsUserChangePassword').hide();
        $('#fsUserInformation').show();
        $('#ctl00_MainContentPlaceHolder_LeftColumnPlaceHolder_myprofileOpenSection').val('#fsUserInformation');
        $('#ShowUserInformation').addClass('selected');
        $('#ShowPassword').removeClass('selected');
    });

    $('.HideMyProfileControls').click(function () {
        $('#fsUserChangePassword').hide();
        $('#fsUserInformation').hide();
        $('#ctl00_MainContentPlaceHolder_LeftColumnPlaceHolder_myprofileOpenSection').val('');
        $('#ShowPassword').removeClass('selected');
        $('#ShowUserInformation').removeClass('selected');

    });


    // 
    $('a[href$=watching]').attr('href', '#watching');

    //**** glowmenu ***************************************************************************************
    $('.glowmenu li a').not('.selected').hover(function () {
        $(this).css({ opacity: 0 });
        $(this).stop().dequeue().animate({ opacity: 1 }, 350, 'swing')
        $(this).addClass('hover');
    }, function () {
        $(this).animate({ opacity: 0 }, 500, 'swing', function () {
            $(this).removeClass('hover');
        });
    });

    //**** 3step guide *****************************************************************************

    $('#OrderStepsContainer > div').hover(function () {
        $(this).addClass('hover');
    }, function () {
        $(this).removeClass('hover');
    }); /*.click(function () {
        var thisURL = $(this).find('a').attr('href');
        window.location = thisURL;
    });*/

    //**** article slideshow *****************************************************************************

    $('.ArticleSlideShow').slides({
        pagination: true,
        generatePagination: true,
        play: 5000,
        pause: 2500,
        hoverPause: true
    });

    $('.ArticleSlideShow').hover(function () {
        $(this).find('.prev, .next').animate({ opacity: 1 }, 350, 'swing');
    }, function () {
        $(this).find('.prev, .next').animate({ opacity: 0 }, 350, 'swing');
    });

    //**** CustomerServiceBar arrow mouseover ************************************************************

    $('#CustomerServiceBar .Arrow').hover(function () {
        $(this).find('a').addClass('hover');
        $(this).dequeue().animate({
            backgroundPosition: "16px 31px"
        }, 100, 'swing');
    }, function () {
        $(this).find('a').removeClass('hover');
        $(this).animate({
            backgroundPosition: "16px 28px"
        }, 100, 'swing');
    });

    // ****************** ChannelOverview ****************************************************************

    // Show dropdown menu on mouseover
    $('#ChannelFilter ul li').hover(function () {
        $(this).find('ul').slideDown(250, 'easeInQuad');
    }, function () {
        $(this).find('ul').hide();
    });

    // get channels and clone when page loads
    var channels = $('.HiddenChannels');
    var channelsclone = channels.find('li').clone();

    // declare global variables (values are calculated in the AddChannelEvents function)
    var channelWidth = $('.Channel .ChannelInfo').width();
    var channelHeight = $('.Channel .ChannelInfo').height();
    var channelExpandedWidth;
    var channelExpandedHeight;

    if ($('.Channels').parent().is('#BundleChannels')) {
        channelExpandedHeight = (130);
        channelExpandedWidth = (200);
        AddChannelEvents();
    } else {
        channelExpandedHeight = (220);
        channelExpandedWidth = (225);
    };


    // when page loads -> populate and sort the channels into .Channels and add click and hover listeners
    $('.ChannelSorter .Channels').quicksand(channelsclone, {
        duration: 200,
        adjustHeight: 'true'
    }, AddChannelEvents);

    $('#ChannelFilter ul li ul li').click(function (e) {
        var genre = $(this).find('a').attr('data-genre');
        var bundle = $(this).find('a').attr('data-bundle');
        var allChannels = $(this).find('a').attr('data-all');
        var thisTxt = $(this).find('a').html();
        if (thisTxt.length > 15) {
            thisTxt = thisTxt.substr(0, 14);
        };
        // alert(thisTxt);
        $(this).parent().parent().children('a').html(thisTxt);
        var data = channels.clone();
        if (genre) {
            var selector = '.genre-' + genre;
        } else if (bundle) {
            var selector = '.bundle-' + bundle;
        } else if (allChannels) {
            var selector = 'li';
        } else return;

        var selectedChannels = data.find(selector);

        $('.Channels').quicksand(selectedChannels, {
            duration: 500,
            adjustHeight: 'true'
        }, AddChannelEvents);
        e.preventDefault();

    });

    function ExpandChannel(channel) {
        var thisIsExpanded = $(this).hasClass('expanded');
        if (!thisIsExpanded) {
            var thisChannel = $(this);
            var thisWidth = $(this).width();
            var wrapperWidth = $(this).parent().parent().width();
            var wrapperOffset = $(this).parent().parent().offset();
            var thisOffset = $(this).offset();
            var rightBorderOffset = wrapperWidth + wrapperOffset.left;
            var limit = rightBorderOffset - (channelExpandedWidth);

            if (limit <= thisOffset.left) {
                $(this).css({ right: '6px' });
            } else {
                $(this).css({ left: '6px' });
            };

            CloseAllExpandedChannels();
            AnimateChannel(thisChannel, 'open');
        };
    };

    $('.closelink').live('click', function (e) {
        e.preventDefault();
        CloseAllExpandedChannels();
    });

    function AnimateChannel(channel, animation) {
        var CheckThisWidth = $(this).width();
        if (animation == 'open') {
            channel.css({
                position: 'absolute',
                top: '0',
                'z-index': '1000'
            });
            channel.animate({
                height: channelExpandedHeight,
                width: channelExpandedWidth
            }, 400).addClass('expanded');
            channel.css({ cursor: 'default' });
            channel.find('h2.ChannelName').hide();
            channel.find('.closelink').fadeIn();
            channel.find('.MoreInfo').delay(300).fadeIn();
        } else if (animation == 'close') {
            channel.find('.MoreInfo').hide();
            channel.css({
                'z-index': '500'
            }).animate({
                height: channelHeight,
                width: channelWidth
            }, 400, 'swing', function () {
                channel.removeClass('expanded');
                channel.find('.closelink').fadeOut();
            });
        } else return;
    };

    function CloseAllExpandedChannels(e) {
        var AllExpandedChannels = $('.expanded');
        AnimateChannel(AllExpandedChannels, 'close');
    };

    function ChannelHover() {
        if (!$(this).hasClass('expanded')) {
            $(this).find('h2.ChannelName').fadeIn();
            $(this).css({ cursor: 'pointer' });
        };
    };

    function ChannelMouseOut() {
        $(this).find('h2.ChannelName').fadeOut();
    };

    function AddChannelEvents() {
        $('.Channel .ChannelInfo').click(ExpandChannel);
        $('.Channel .ChannelInfo').hover(ChannelHover, ChannelMouseOut);
    };


    // ****************** BundleSelector ****************************************************************

    if ($(".BundleSelector").length > 0) {
        var BundleHeight = $('.BundleSelector img').height();
        var BundleWidth = $('.BundleSelector img').width();
        var BundleMagnification = '1.2';
        var BundleTopMargin = $('.BundleSelector img').css("margin-top").replace("px", "");
        var BundleMaxHeight = BundleHeight * BundleMagnification;
        var BundleMaxWidth = BundleWidth * BundleMagnification;
    }
    $('.BundleSelector img').hover(function () {
        $(this).animate({
            'height': BundleMaxHeight,
            'width': BundleMaxWidth,
            'margin-top': '0'
        });
    }, function () {
        $(this).animate({
            'height': BundleHeight,
            'width': BundleWidth,
            'margin-top': BundleTopMargin
        });
    });

    $('.BundleSelector img').click(function () {
        closeSelectedBundle();
        $(this).parent().parent().addClass('selected');
        var thisURL = $(this).parent().attr('href');
        window.location(thisURL);
    })

    function closeSelectedBundle() {
        $('.BundleSelector .selected img').animate({
            height: BundleHeight,
            width: BundleWidth
        }).parent().parent().removeClass('selected');
    };

    // ****************** BundleSLideDeck ************************************************************

    $('.slidedeck').slidedeck({
        index: false,
        before: makeSlide,
        autoPlay: true,
        cycle: true
    });

    function makeSlide() {
        // nothing here yet
    };




    // ****************** OrderPage Functions ***************************************************************
    $(".Validate").click(function () {
        var invalid = true;
        var invalidLength = false
        var $activeObject = null;
        var $objectLength = null;
        $("[class*=Required_Phone]").each(function (index) {
            var value = jQuery.trim($(this).val());
            if (value.length > 0) {
                invalid = false;
                $("[class*=Required_Phone]").next("span.ErrorMessage").hide();
                if (value.length > 7 && value.length < 9) {
                    invalidLength = false;
                    $("[class*=Required_Phone]").nextAll("span.ErrorMessageLength:first").hide();
                    return false;
                }
                else {
                    invalidLength = true;
                    $objectLength = $(this);
                }
            }
            else {
                $activeObject = $(this);
            }

        });
        if (invalid == true && $activeObject != null) {
            $activeObject.next("span.ErrorMessage").show();
            return false;
        }
        else if (invalidLength == true && $objectLength != null) {
            $objectLength.nextAll("span.ErrorMessageLength:first").show();
            return false;
        }

        return true;

    });

    $(".OrderForm input.date").focus(function () {
        if (jQuery.trim($(this).val()) == "ddmmåååå") {
            $(this).val("");
        }
    });

    $(".OrderForm input.date").blur(function () {
        if (jQuery.trim($(this).val()) == 0) $(this).val("ddmmåååå");
    });

    $(".RoomControl input[type='text']").focus(function () {
        if (jQuery.trim($(this).val()) == "Skriv inn et nytt navn") {
            $(this).val("");
        }
    });

    $(".RoomControl input[type='text']").blur(function () {
        if (jQuery.trim($(this).val()) == 0) $(this).val("Skriv inn et nytt navn");
    });

    $(".CDInstall > input[type='radio'], .SelfInstall >input[type='radio']").change(function () {
        if ($(this).parent().hasClass("SelfInstall") && $(this).is(":checked")) $(".CDInstallFieldset").find("input").attr("disabled", "disabled");
        else $(".CDInstallFieldset").find("input").removeAttr("disabled");
    });

    //$(".WizardSteps > li.selected").nextAll("li").addClass("TBSelected");

    $("#DecoderProductList").find("input[type=radio]").attr("name", "DecoderGroup");

    /*Hover for product page*/

    //$(".BundlePacks > li").hoverIntent(ShowInfoBox, HideInfoBox);

    //Hack to add hoverintent to dynamically loaded html 
    $(".BundlePacks > li").live("mouseover", function () {
        if (!$(this).data('init')) {
            $(this).data('init', true);
            $(this).hoverIntent(ShowInfoBox, HideInfoBox);
            $(this).trigger('mouseover');
        }
    });

    /*
    $(".BundlePacks > li").not(".disabled").hover(function () {
    var $hoverBlock = $(this).find(".ChannelsHover");
    if ($hoverBlock.length < 1) return;
    $hoverBlock.css("top", (-(($hoverBlock.height() / 2) - ($(this).height() / 2) - 9)));
    $hoverBlock.fadeIn(400);

    },
    function () {
    $(this).find(".ChannelsHover").hide();
    });

    */
    function HideInfoBox() {
        $(this).find(".ChannelsHover").hide();
    }

    function ShowInfoBox() {
        if ($(this).hasClass("disabled")) var $hoverBlock = $(this).find(".InfoHover");
        else var $hoverBlock = $(this).find(".ChannelsHover").not(".InfoHover");
        if ($hoverBlock.length < 1) return;
        $hoverBlock.css("top", (-(($hoverBlock.height() / 2) - ($(this).height() / 2) - 9)));
        //adjusting inner arrow as well
        $hoverBlock.find(".Arrow").css("top", ((($hoverBlock.height() - 9) / 2) - 18));
        $hoverBlock.show();
    }

    // ****************** OrderPage Calculator ***************************************************************

    // checks if #ProductCalculator exists and runs code specific to the calculator
    if ($('#ProductCalculator')[0]) {

        // sets initial calculator values when page is loaded
        setInitialCalculatorValues();

        // runs the endrequesthandler when room is added
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(RefreshCalculatorValuesInNewRoom);

        // sets the height of the sidebar so that the calculator will stop at the bottom
        var maincolumnheight = $('#MainContent').height();
        $('#SideBar').height(maincolumnheight - 70);

        // adds the stickyfloat plugin to the calculator
        $('#ProductCalculator').stickyfloat({ duration: 500, startOffset: 200, offsetY: 30, lockBottom: true });
    };

    function RefreshCalculatorValuesInNewRoom() {
        setInitialCalculatorValues();
        $('html, body').animate({ scrollTop: 0 }, 'slow');
    };

    // function for logging prices in firebug console - remove in production
    function logPrices(message) {
        if (window['console'] !== undefined) {
            console.log('-------------- new values: -------------------');
            console.log('Message: ' + message);
            console.log('thisRoomMonthlyPrice: ' + thisRoomMonthlyPrice +
            ' | thisRoomDecoderPrice: ' + thisRoomDecoderPrice +
            ' | TotalMonthlyPrice: ' + TotalMonthlyPrice +
            ' | TotalYearlyPrice: ' + TotalYearlyPrice +
            ' | TotalYearlyPriceOtherRooms: ' + TotalYearlyPriceOtherRooms);
        };
    };

    // sets global variables for OrderPage Calculator
    var thisRoomMonthlyPrice,
        thisRoomDiscount,
        thisRoomCampaignDiscount,
        thisRoomDecoderPrice,
        TotalMonthlyPrice,
        TotalYearlyPrice,
        TotalYearlyPriceOtherRooms,
        TotalMonthlyPriceOtherRooms,
        TotalFreeMonthsSum;

    // sets initial values in variables
    // runs when the order process starts and when new room is added
    function setInitialCalculatorValues() {
        thisRoomMonthlyPrice = parseInt($('#CalculatorBundleTotalPrice').text().replace(' ', ''));
        thisRoomDiscount = parseInt($('#CalculatorBundleDiscount').text().replace(' ', '')) || 0;
        thisRoomCampaignDiscount = 0;
        $('#ProductCalculator .Campaigns .campaignDiscount').each(function () {
            thisRoomCampaignDiscount += parseInt($(this).text().replace(' ', '')) || 0;
        });
        thisRoomDecoderPrice = parseInt($('#CalculatorDecoderTotalPrice').text().replace(' ', ''));

        TotalMonthlyPrice = parseInt($('#CalculatorTotalPrice').text().replace(' ', ''));
        TotalYearlyPrice = parseInt($('#CalculatorTotalPriceFirstYear').text().replace(' ', ''));
        TotalFreeMonthsSum = parseInt($('#CalculatorTotalSumFreeMonths').text().replace(' ', ''));        
        TotalYearlyPriceOtherRooms = ((TotalYearlyPrice - (thisRoomMonthlyPrice * 12) - thisRoomDecoderPrice)+TotalFreeMonthsSum);
        TotalMonthlyPriceOtherRooms = (TotalMonthlyPrice - thisRoomMonthlyPrice);
        // logPrices('setInitialCalculatorValues()');

        //Set correct yearlyprice if a product is default choosen
        //TotalYearlyPrice = TotalYearlyPrice-TotalFreeMonthsSum;
        //$('#CalculatorTotalPriceFirstYear').text(makeNumber(TotalYearlyPrice));
    };

    // number formatting function copyright Stephen Chapman 24th March 2006, 22nd August 2008 permission to use this function is granted provided that this copyright notice is retained intact
    function formatNumber(num, dec, thou, pnt, curr1, curr2, n1, n2) { var x = Math.round(num * Math.pow(10, dec)); if (x >= 0) n1 = n2 = ''; var y = ('' + Math.abs(x)).split(''); var z = y.length - dec; if (z < 0) z--; for (var i = z; i < 0; i++) y.unshift('0'); if (z < 0) z = 1; y.splice(z, 0, pnt); if (y[0] == pnt) y.unshift('0'); while (z > 3) { z -= 3; y.splice(z, 0, thou); } var r = curr1 + n1 + y.join('') + n2 + curr2; return r; }

    function makeNumber(number) {
        var newnumber = formatNumber(number, 0, ' ', '', '', '', '-', '');
        return newnumber;
    };

    function UpdateBundlePrice(amount, discount, campaignDiscount) {
        thisRoomMonthlyPrice = thisRoomMonthlyPrice + amount;
        thisRoomDiscount = thisRoomDiscount + discount;
        thisRoomCampaignDiscount = thisRoomCampaignDiscount + campaignDiscount;
    };

    function UpdateDecoderPrice(amount) {
        thisRoomDecoderPrice = amount;
    };

    function UpdateMonthlyFreeSum(amount) {
        TotalFreeMonthsSum = TotalFreeMonthsSum + amount;
    };

    function CalculateTotalPrices() {
        TotalMonthlyPrice = TotalMonthlyPriceOtherRooms + thisRoomMonthlyPrice - thisRoomDiscount;
        TotalYearlyPrice = (TotalYearlyPriceOtherRooms + ((thisRoomMonthlyPrice - thisRoomDiscount) * 12) + thisRoomDecoderPrice - thisRoomCampaignDiscount - TotalFreeMonthsSum);

    };

    function PopulatePrices() {
        // logPrices('In PopulatePrices before CalculateTotalPrices');

        CalculateTotalPrices();

        $('.ExpandedRoom .RoomBundlePrice').text(makeNumber(thisRoomMonthlyPrice - thisRoomDiscount));
        $('#CalculatorBundleTotalPrice').text(makeNumber(thisRoomMonthlyPrice - thisRoomDiscount));
        $('#CalculatorDecoderTotalPrice').text(makeNumber(thisRoomDecoderPrice));
        $('.ExpandedRoom .RoomDecoderPrice').text(makeNumber(thisRoomDecoderPrice));
        $('#CalculatorTotalPrice').text(makeNumber(TotalMonthlyPrice));
        $('#CalculatorMonthlyPrice').text(makeNumber(TotalMonthlyPrice));
        $('#CalculatorTotalPriceFirstYear').text(makeNumber(TotalYearlyPrice));
        $('#CalculatorTotalSumFreeMonths').text(makeNumber(TotalFreeMonthsSum));
        $('#CalculatorBundleDiscount').text(makeNumber(thisRoomDiscount));
        
        if (TotalFreeMonthsSum == 0) {
            $('.FinalFreeMonths').hide();
        } else {
            $('.FinalFreeMonths').show();
        }

        // logPrices('After PopulatePrices');

    };

    function UpdateProductlineInCalculator(ProductID, UpdateType, ProductType, thisProductName, thisProductPrice, thisProductDiscount, thisProductCampaignDiscount, thisProductCampaignDiscountName) {

        UpdateDiscount();

        if (UpdateType == 'remove') {

            $('#ProductCalculator ul > li[data-bundleid="' + ProductID + '"]').remove();
            return true;

        } else if (UpdateType == 'add') {

            if (ProductType == 'decoder') {

                var perMonth = '',
                    calculatorList = '.CalculatorDecoderList';

            } else if (ProductType == 'channelbundle') {

                var perMonth = '/mnd',
                    calculatorList = '.CalculatorBundleList';

            };

            var thisProductLineString = '<li data-bundleid="' + ProductID + '">' + '<span class="left">' + thisProductName + '</span>' + ' <span class="right">' + makeNumber(thisProductPrice) + ',- ' + perMonth + '</span></li>';

            $(calculatorList).prepend(thisProductLineString);

            if (thisProductCampaignDiscount) {
                var thisDiscountLineString = '<li data-bundleid="' + ProductID + '">' + '<span class="left">' + thisProductCampaignDiscountName + '</span>' + ' <span class="right">-<span class="campaignDiscount">' + makeNumber(thisProductCampaignDiscount) + '</span>,-</span></li>';

                var $ul = $('#ProductCalculator .Campaigns ul');
                if (!$ul.length) {
                    $('#ProductCalculator .Campaigns').append('<ul/>');
                    $ul = $('#ProductCalculator .Campaigns ul');
                }
                $ul.prepend(thisDiscountLineString);
            }

        }

        // adds the stickyfloat plugin to the calculator
        $('#ProductCalculator').stickyfloat({ duration: 500, startOffset: 200, offsetY: 30, lockBottom: true });
    };

    function UpdateDiscount() {
        if (thisRoomDiscount > 0) {
            $('#CalculatorBundleDiscount').text(thisRoomDiscount);
            $('#ProductCalculator .BundleDiscount').show();
        }
        else {
            $('#ProductCalculator .BundleDiscount').hide();
        }

        if (thisRoomCampaignDiscount > 0) {
            $('#ProductCalculator .Campaigns').show();
        }
        else {
            $('#ProductCalculator .Campaigns').hide();
        }
    }

    $('.BundlePacks.Selectable > li, .BundlePacks.Selectable > li input').live("click", function (e) {
        if (e.target.nodeName == 'A') return true;

        var $this = $(this),
            $input = $this.find('input'),
            methodName = "/HandleRoomChanges",
            isDecoder = false;

        // If target was input, reassign $input and $this
        if (e.target.nodeName == 'INPUT') {
            $input = $this;
            $this = $this.parent('li');
        }

        if ($this.hasClass("disabled")) {
            return false;
        }

        if ($this.parent('#DecoderProductList').length) {
            methodName = "/HandleDecoderChange";
            isDecoder = true;
        }

        // Reverting state of checkbox/radio because we wish to do a servercall before allowing that to happen
        if (e.target.nodeName == 'INPUT') {
            if ($input.is(':checked')) $input.attr('checked', false);
            else $input.attr('checked', true);
        }

        var thisProductID = $input.attr('data-bundleid');

        if ($input.is(':checked') || isDecoder) {
            var pageurl = $("#pageurl").text();
            if (pageurl != null && pageurl != "") {
                $.ajax({
                    type: "POST",
                    url: pageurl + methodName,
                    async: true,
                    data: "{'mpid':" + thisProductID + "}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                        if (data.d != null) {
                            confirm(data.d, function () {
                                //here we wish to continue things only on callback 'yes' (see confirm function)
                                handleProductUpdate($this);
                            });
                        }
                        else {
                            handleProductUpdate($this);
                        }
                    },
                    error: function (ex) {
                        //Even though we get an error we will still allow user to update rather than hinder functionality
                        handleProductUpdate($this);
                    }
                });
            }
            else {
                handleProductUpdate($this); //Even though we haven|t been able to call the server we allow user to update
            }
        }
        else handleProductUpdate($this);
    });

    function setDisabled(obj) {
        if (obj.length < 1) return;
        if (obj.hasClass("disabled")) return;
        obj.addClass("disabled");
        if (obj.find(".fade-overlay").length < 1) obj.append("<span class='fade-overlay'></span>");
        obj.find("input").attr("disabled", "disabled");
        obj.find(".InfoHover").remove();

        //We also need to remove it from the basket if it has already been chosen
        if (obj.hasClass("selected")) {
            var thisProductName = obj.find('.ChannelName span').text(),
                thisProductPrice = parseInt(obj.find('.price span').text()),
                thisProductDisount = parseInt(obj.find('.disount').text()) || 0,
                thisProductCampaignDisount = parseInt(obj.find('.campaignDisount').text()) || 0,
                thisProductCampaignDisountName = obj.find('.campaignDisountName').text(),
                thisProductID = obj.find('input').attr('data-bundleid');
                thisProductFreemonths = parseInt(obj.find('.freemonths').text()) || 0;

            obj.removeClass('selected');
            obj.find('input').attr('checked', false);
            UpdateBundlePrice(thisProductPrice * -1, thisProductDisount * -1, thisProductCampaignDisount * -1);
            UpdateMonthlyFreeSum(thisProductFreemonths * -1);
            UpdateProductlineInCalculator(thisProductID, 'remove', "channelbundle", thisProductName, thisProductPrice, thisProductDisount, thisProductCampaignDisount, thisProductCampaignDisountName);
        }
    }

    function setEnabled(obj) {
        if (obj.length < 1) return;
        if (obj.hasClass("issubjectofrequirements")) return;
        obj.removeClass("disabled");
        obj.find(".fade-overlay").remove();
        obj.find("input").removeAttr("disabled");
    }

    function handleProductUpdate(obj) {

        //Quick fix for subbundes (this whole method should be optimizied)
        if (!obj.hasClass('selected') && obj.parent().hasClass("ChannelBundles")) {
            if (obj.hasClass("subbundle")) {
                var sid = obj.attr("class").match(/sid\d+/);
                //Checking if other subbundle siblings are selected as well, and if they are: select containerbundle and disable subbundles
                var $siblings = obj.siblings(".subbundle." + sid);
                if (obj.siblings(".subbundle." + sid + ".selected").length == $siblings.length) {
                    $siblings.each(function () { setDisabled($(this)); });
                    //setting containingbundle as object;
                    obj = obj.siblings(".containingbundle." + sid);
                }
            }
        }
        var thisProductName = obj.find('.ChannelName span').text(),
            thisProductPrice = parseInt(obj.find('.price span').text()),
            thisProductDisount = parseInt(obj.find('.disount').text()) || 0,
            thisProductCampaignDisount = parseInt(obj.find('.campaignDisount').text()) || 0,
            thisProductCampaignDisountName = obj.find('.campaignDisountName').text(),
            thisProductID = obj.find('input').attr('data-bundleid'),
            thisProductFreeMonthsSum = parseInt(obj.find('.freemonths').text()) || 0;


        if (obj.parent().is('#DecoderProductList')) {

            var productType = 'decoder';

        } else if (obj.parent().hasClass('ChannelBundles')) {

            var productType = 'channelbundle';
        };

        if (!obj.hasClass('selected')) {

            if (productType == 'channelbundle') {

                //Checking if product is containingbundle

                if (obj.hasClass("containingbundle")) {
                    //find sub-bundles and disable them
                    obj.siblings(".sid" + thisProductID).each(function () {
                        setDisabled($(this));
                    });
                }



                obj.addClass('selected');
                obj.find('input').attr('checked', true);
                UpdateMonthlyFreeSum(thisProductFreeMonthsSum);
                UpdateBundlePrice(thisProductPrice, thisProductDisount, thisProductCampaignDisount);

            } else if (productType == 'decoder') {

                $('#DecoderProductList').find('.selected').removeClass('selected');
                $('#DecoderProductList input:radio[checked]').each(function () {
                    $(this).attr('checked', false);
                });
                obj.find('input').attr('checked', true);
                obj.addClass('selected');
                $('#ProductCalculator .CalculatorDecoderList li').not('.BundleTotal').remove();
                $('input#HiddenDecoderValue').attr('value', thisProductID);
                UpdateDecoderPrice(parseInt(thisProductPrice));

            };

            UpdateProductlineInCalculator(thisProductID, 'add', productType, thisProductName, thisProductPrice, thisProductDisount, thisProductCampaignDisount, thisProductCampaignDisountName);

        } else if (obj.hasClass('selected')) {

            if (productType == 'channelbundle') {

                //Checking if product is containingbundle

                if (obj.hasClass("containingbundle")) {
                    //find sub-bundles and enable them
                    obj.siblings(".sid" + thisProductID).each(function () {
                        setEnabled($(this));
                    });
                }

                obj.removeClass('selected');
                obj.find('input').attr('checked', false);
                UpdateMonthlyFreeSum(thisProductFreeMonthsSum * -1);
                UpdateBundlePrice(thisProductPrice * -1, thisProductDisount * -1, thisProductCampaignDisount * -1);

            };

            UpdateProductlineInCalculator(thisProductID, 'remove', productType, thisProductName, thisProductPrice, thisProductDisount, thisProductCampaignDisount, thisProductCampaignDisountName)

        };

        PopulatePrices();
    };




    //***************************************LIGHTBOX FUNCTIONS************************************/


    function confirm(message, callback) {
        $('#confirm').modal({
            closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>",
            position: ["20%", ],
            overlayId: 'confirm-overlay',
            containerId: 'confirm-container',
            onShow: function (dialog) {
                var modal = this;

                $('.message', dialog.data[0]).append(message);

                // if the user clicks "yes"
                $('.yes', dialog.data[0]).click(function () {
                    // call the callback
                    if ($.isFunction(callback)) {
                        callback.apply();
                    }
                    // close the dialog
                    modal.close(); // or $.modal.close();
                });
            }
        });
    };


    /*FAQ Hide/Show*/

    $('.FaqList').find('dt').click(function () {

        $(this).next("dd").slideToggle('fast');
        $(this).toggleClass("expanded");
    });


    //***************************************FORM VALIDATION************************************/

    function ValidateForm() {
        var isValid = true;
        $('.ValidateForm').find('input.required').each(function () {
            if (jQuery.trim($(this).val()) == "") {
                isValid = false;
                if ($(this).next(".ErrorMessage").length <= 0) $(this).after("<span class='ErrorMessage'>Du må fylle ut dette feltet</span>");
            }
            else $(this).next('.ErrorMessage').remove();
        });
        return isValid;
    }

    $('.CustomerContact').find('input.Validate').click(function () {
        return ValidateForm();
    });

    $('.ValidateForm').find('input.required').focusout(function () {
        if (jQuery.trim($(this).val()) == "") {
            if ($(this).next(".ErrorMessage").length <= 0) $(this).after("<span class='ErrorMessage'>Du må fylle ut dette feltet</span>");
            return false;
        }
        $(this).next('.ErrorMessage').remove();
    });

    function AuthorityRequiredClient(sender, e) {
        e.IsValid = jQuery("#Authority").is(':checked');
    }

    //$('.ValidateForm').find('input.required').

    //Disabling enter key event to stop forms from submitting except on button clicks
    //    $('.OrderPage').find('input').keydown(function (event) {
    //        alert('you pressed key' + event.keyCode);
    //        if (event.KeyCode == '13') {
    //            alert('you pressed enter');
    //            event.stopPropagation();
    //            return false;
    //        }
    //    });



    //    $('.forgot_username, .forgot_password').click(function () {
    //        $('#login').fadeOut(500, function () {
    //            $('#ForgotPassword').fadeIn();
    //        });
    //        return false;
    //    });

    //    $('.register').click(function () {
    //        $('#login').fadeOut(500, function () {
    //            $('#RegisterUser').fadeIn();
    //        });
    //        return false;
    //    });

    //    $('.backlink').click(function () {
    //        $('#ForgotPassword').fadeOut(500, function () {
    //            $('#login').fadeIn();
    //        });
    //        return false;
    //    });

    //    $('.registerbacklink').click(function () {
    //        $('#RegisterUser').fadeOut(500, function () {
    //            $('#login').fadeIn();
    //        });
    //        return false;
    //    });

    $('.SubscriptionSubService').hover(function () {
        $(this).parent().css({ 'background': 'none' });
    }, function () {
        $(this).parent().removeAttr('style');
    });

    if ($('#dustediv')[0]) {
        var dustedivheight = $('#dustediv').height();
        $('#MainColumn').css({
            'margin-bottom': dustedivheight + 10
        });
    };


    if ($('#SideBar')[0]) {
        var SideBarHeight = $('#SideBar').height();
        var MainColumnHeight = $('#MainColumn').height();
        //console.log(SideBarHeight);
        //console.log(MainColumnHeight);
        if (MainColumnHeight < SideBarHeight) {
            $('#MainColumn').css({
                'min-height': SideBarHeight
            });
        };

    };


});                                                                                                                   // end document ready






// ******************************************* PLUGINS ****************************************************************

/*
* stickyfloat - jQuery plugin for verticaly floating anything in a constrained area
* 
* Example: jQuery('#menu').stickyfloat({duration: 400});
* parameters:
* 		duration 	- the duration of the animation
*		startOffset - the amount of scroll offset after it the animations kicks in
*		offsetY		- the offset from the top when the object is animated
*		lockBottom	- 'true' by default, set to false if you don't want your floating box to stop at parent's bottom
* $Version: 05.16.2009 r1
* Copyright (c) 2009 Yair Even-Or
* vsync.design@gmail.com
*/

$.fn.stickyfloat = function (options, lockBottom) {
    var $obj = this;
    var parentPaddingTop = parseInt($obj.parent().css('padding-top'));
    var startOffset = $obj.parent().offset().top;
    var opts = $.extend({ startOffset: startOffset, offsetY: parentPaddingTop, duration: 200, lockBottom: true }, options);

    $obj.css({ position: 'absolute' });

    if (opts.lockBottom) {
        var bottomPos = $obj.parent().height() - $obj.height() + parentPaddingTop; //get the maximum scrollTop value
        if (bottomPos < 0)
            bottomPos = 0;
    }

    $(window).scroll(function () {
        $obj.stop(); // stop all calculations on scroll event

        var pastStartOffset = $(document).scrollTop() > opts.startOffset; // check if the window was scrolled down more than the start offset declared.
        var objFartherThanTopPos = $obj.offset().top > startOffset; // check if the object is at it's top position (starting point)
        var objBiggerThanWindow = $obj.outerHeight() < $(window).height(); // if the window size is smaller than the Obj size, then do not animate.

        // if window scrolled down more than startOffset OR obj position is greater than
        // the top position possible (+ offsetY) AND window size must be bigger than Obj size
        if ((pastStartOffset || objFartherThanTopPos) && objBiggerThanWindow) {
            var newpos = ($(document).scrollTop() - startOffset + opts.offsetY);
            if (newpos > bottomPos)
                newpos = bottomPos;
            if ($(document).scrollTop() < opts.startOffset) // if window scrolled < starting offset, then reset Obj position (opts.offsetY);
                newpos = parentPaddingTop;

            $obj.animate({ top: newpos }, opts.duration);
        }
    });
};




/**************************** plugins *******************************************************************/

    /**
    * SlideDeck 1.1.5 Pro - 2010-05-11
    * Copyright (c) 2010 digital-telepathy (http://www.dtelepathy.com)
    * 
    * BY USING THIS SOFTWARE, YOU AGREE TO THE TERMS OF THE SLIDEDECK 
    * LICENSE AGREEMENT FOUND AT http://www.slidedeck.com/license. 
    * IF YOU DO NOT AGREE TO THESE TERMS, DO NOT USE THE SOFTWARE.
    * 
    * More information on this project:
    * http://www.slidedeck.com/
    * 
    * Requires: jQuery v1.3+
    * 
    * Full Usage Documentation: http://www.slidedeck.com/usage-documentation 
    * Usage:
    *     $(el).slidedeck(opts);
    * 
    * @param {HTMLObject} el	The <DL> element to extend as a SlideDeck
    * @param {Object} opts		An object to pass custom override options to
    */

    eval((function (s) { var a, c, e, i, j, o = "", r, t = "@^`~"; for (i = 0; i < s.length; i++) { r = t + s[i][2]; a = s[i][1].split(""); for (j = a.length - 1; j >= 0; j--) { s[i][0] = s[i][0].split(r.charAt(j)).join(a[j]); } o += s[i][0]; } var p = 11007; var x = function (r) { var c, p, s, l = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789'; if (r < 63) c = l.charAt(r); else { r -= 63; p = Math.floor(r / 63); s = r % 63; c = l.charAt(p) + l.charAt(s) } return c }; a = o.substr(p).split(':'); r = a[1].split('?'); a = a[0].split('?'); o = o.substr(0, p); if (!''.replace(/^/, String)) { var z = {}; for (i = 0; i < 268; i++) { var y = x(i); z[y] = r[i] || y } t = /\b\w\w?\b/g; y = function (a) { return z[a] || a }; o = o.replace(t, y) } else { for (j = a[a.length - 1] - 1; j >= 0; j--) { if (r[j]) o = o.replace(new RegExp('\b' + (j < 63 ? c.charAt(j) : c.charAt((j - 63) / 63) + c.charAt((j - 63) % 63)) + '\b', 'g'), r[j]) } } return o.replace(//g, "\"") })([["String.prototype.z~v=al;aD v.df().reverse().join(;bX;(_($bX~d,fc=al,d=$(d);j=1.1.5j={bJ:500,be:'swingcy:1,au:ap,aS:ap,bj:ap,cO:ap,b7:as,b0:5000,ar:as,bU:as,a3:as}k={bE:'bEaA:'aAde:'deaS:'aSaL:'aLcw:'cwau:'aubK:'bKaM:lacitreVsedils}o=1;al1=dy=d4('dt')B=d4('dd');alI=1;alF=[]E=[]X=as;l=navigator.userAgentp();={bh:bh/bo:bo/cF:bo\\/2/cD:bo\\/3\\.0/aW:aW/c6:(aW 6/)&&!aW 7|8/)msie7:aW 7/c5:aW 8/cf:cf/bz:(bz/)&&!bh/))?ap:as};br(b cV [b]." +
"_this=b;}}h@bh\\/];}o@bo\\/];}W@aW ];}.cf@a1\\/];}z@a1\\/];}m;n;o,p,q,s;u~aAcmWP=aAN(c4-dnuorgkcab);Q=P;Q==transparentP=#ffffff;}aQ{QJ('\\ci')Qq<7t=\\ci+Q9(112233,1);P=t;}}}P=P.replace(\\ci,);a8={r:P9(0,2),g:P9(2,2),b:P9(4,2)};R=\\ci;S=FEDCBA09876543210;br(k cV a8=aPY(0,(ax(,dl)-1));=S.c_((-%dl)/dl)+S.c_(%dl);R+=;}aA4('\\bt'+ckS)N({'c0':=c4(amorhc )1=cH(cs.cC_:c1+R+'\\x29backgroundColor:R}};w~av(cB)!=aCcB.DO" +
"M.ready(_(avj0)!=aCP=[];avj0)==cjPRj0aQ{P=cj0;}br(i=0;i<Pq;i++cB.refresh(P[i]}awjr===asQ=0;awm.c5Q=aP.cA().cq()-$)4('cz')[0])Z())/2awmz||cmhaI.doctype.publicIdp()J(/transitional/)Q=aP.cA()O()-$)4('cz')[0])Z())/2}cy4('>cz')N('cg-bkQ}};z=as;A~z===asz=ap;P=cU Image();P.src=(aI.location.protocol==da:?da::http:)+/0dffa540f75499d537c9385e34013f6848585886/moc.kcededils.www//+j+/pro;}};B~cj3br(i=0;i<cyq;i++i<cI$y[i])akK" +
"aQ{$y[i]^K}}};C~atP=as;avH)!='aC'avM()j)!='aC'cM()jj===ap&&$(at.c3)G('\\bt'+ckM)q>0P=ap;}}}aD P;};D={bV:_(P=cU Date();Q=TCFullYear()+\\x2d+TCMonth()+\\x2d+TCDate()+\\x20+TCHours()+\\dc+TCMinutes()+\\dc+TCSeconds();R=(0-P.getTimezoneOffset()/60);S=aP.cA(R);T=00;S!=RT=(R-S)*60;}aD Q+S+\\dc+T;},cv:_(PcFq===0||cF[cFq-1]E!=PcFR({bE:P,bV:alV()}}};E~cE~cX===ascjU===as&&co==cBqcX=ap;}aQ{cg(}};setInterval(cE,cj0;F~$2(dN('aK" +
"'),['aK'aV'fixed'])dN('aK'relative'dN('b6'ch');br(i=0;i<cBq;i++P=$B[i]);awyq>iaA=$y[i]Q={bk'bQ-bk'),bW),blca-bn`,a7b2-bn`,aTcm-bn`};R={bkbs-pot-bi`,blbs-ca-bi`,a7bs-b2-bi`,aTbs-cm-bi`};br(k cV RR[k]=ct(R[k])?0:R[k];}i<coi==co-1cjr!==apaAFkLPFkLbq=i*p;awjrbq=0-(i*db()}aQ{bq=i*p+q;awjrbq=i*db(}cM=(q-QT-Ql-RT-Rl);PN({aK:'aVaT:bq,by:1,aZ:(n-Qk-Q7-Rk-R7)bb:cMcg:0,paddingLeft:QT+p+bx}^E^E+\\di+(i+1));awjr!==apaAN" +
"({aK:'aVby:3,cM:'djaT:bq,bb:(n-20)aZ:obQ:'0 10pxcK:'270deg'-bZ-aG':)ck(bB,'-bZ-aG-bA':s+'bx bT'-cL-aG':)ck(bB,'-cL-aG-bA':s+'bx bT'-o-aG':)ck(bB,'-o-aG-bA':s+'bx bTcu:'blbk:cmW?0:(n-s)marginLeft:mW?0:(0-s))c0:)3=cH(cs.cC_:c1}^A^A+\\di+(i+1)aQ{av(aA)!=aCaA.cR(}i==c",
")?ap:as,===ap){l.aJ(/){aw((c.aan .a:ax(PN(.z()),P.getU.z()alm);}.b([0-9\\.]+)/)[1+bx,a8[k];alaw(){,1)+Q9(($y[0]1=)FkbW)=_(',",
""],
["Bq-1PF('dp'@aAF('dp'}au=ap&&ar=asS=aIO('DIV');SY=u;aAfter(S);N({aK:'aV',bk:'25px',aT:bq+p,b6:ch,by:20000}).cR(aA.hasClass(L).dm(}aran T=aIO('DIV');TY=S;aS!asU;aS~'cc'U=aS[i%aSq];}aQ{U=+(i+1TU(aIw(U)aA.cZ(T);aA4S)N({aK:'aV',by:2,cM:'dj',bb:o,aZ:o,cu:'center',a7:(mW?0:(0-s)),aT:(mW?5:20),cK:90deg,'-bZ-aG':)cx(bB.z(),'-bZ-aG-bA':s+'bx bT','-cL-aG':)cx(bB.z(),'-cL-aG-bA':s+'bx bT','-o-aG':)cx(bB.z(),'-o-aG-bA':s+'bx bT'});u(aA}A(@y." +
"co('db;cH(yS(al)+1cO!as$(aI).co('keydown$(at.c3)G()S(c1)-1at.cN39cg(aQ at.cN37cL(}}$t.cQv~aCd.co(bv,_(atbj!as!C(at)Y=at3?at3:at.cr;mW||mz||mhY=0-Y;}an Z=as;$(atc)G(c1)qatc.cGp(),['c9','cX','cY','cJ']~-1Z=ap;}}ZY>0b4(bjbS:;a6;aR ap:cP:o<Bq^}cg(aQ{b4(bjbS:;a6;aR ap:cP:o!=1^}cL(}}}}mWan V={x:0,y:0}W={x:0,y:0}X={x:50,y:30};d[0]m('touchstartV.x#.c8;V.y#.c7;},as);d[0]m('touchmove;W.x#.c8;W.y#.c7;},as)" +
";d[0]m('touchendan Y=V.x-W.xZ=V.y-W.y;Y<(0-X.x)cL(aQ Y>X.xcg(Z<(0-X.y)M()L(aQ Z>X.yM()g(},asw();B();D.cv(o);b7=apE(}G`P=aPY(1,P-1);P,E~-1P1P=1;}aQ{P=G(P}aD P;}H`P=aP9(Bq,P+1);P,E~-1PBqP=o;}aQ{P=H(P}aD P;}I`P=aP9(Bq,aPY(1,P));P,E~-1P<oP=G(PaQ{P=H(P}aD P;}J`,QP=I(P(P<=cI||a3!ap)bP)_bP(cQ~aCQP)_QP(c}an R=ap;P<oR=as;}o=P;ya(L);Ba(L);d4u).cR();br(an i=0;i<Bq;i++S=0;aran aA=$(y[i]an T=$(B[i" +
"]i<oi(o-1)TF(L@aAF(L);.dm(w(S=i*p;}aQ{S=i*p+q;}ar=apS=(i-o+1)*db(an U={b8:bJ,cl:be};i(R=ap&&o-1)||i(R=as&&o)V=[];bu)_VR(_(bu(cb4(av(Q)_:VR(_(Q(c);a6;c2:VR(_(Qu(c);a6;}D.cv(o);Uu=_(br(an i=0;i<Vq;i++V[i](};}T({aT:S,bb:cM},U@u(aAaAN('aT'~SaA({aT:S},{b8:bJ,cl:be});({aT:S+p},{b8:bJ,cl:be}}}A(}K`,QR=P;P)=cjR={};R[P]=Q;}br(an S cV RQ=R[S];b4(SbJ:cy:Q=parseFloat(Qct(Q)^bj:cO:au:a3:ar:b7:bU/cc^a0" +
":be/cj^bu:bP/_^aS/cc!$.isArray(Q);}}a6;}j[S]=Q;}}L`P,E)-1&&P!1&&P!0ER(P}M`Q=$2(P,EQ!=-1E.splice(Q,1}N`,Q,Rc=alP=$(P)S=P.children()T=SqU=PG('ddE')V=P.parent()W=U.innerHeight()X=100;Q14('\\bt'+Qku)qX=Q14('\\bt'+Qku)N('z-aS')-1;}al.navParent=dk;al5=dk;alo=0;alj={bJ:500,bj:ap};R)'c2'br(an k cV Ralj[k]=R[k];}}alk={a_:vaNedilSlacitrev.z(),ce:'ce',cW:edilSlacitrev.z()}Y=_(bN,cpo=bNcS=bJ;cp~'aC'cS=0;}$('ul.'+_+' li.'+k.ce)(" +
"{bk:$(5[o])K()k+'bx'},250);5a('aL');$(5[o])F('aL');P({bk:0-(o*W)+'bx'},cSZ=_(bN=aIO('UL');bNY=_;bN.cdK='a",
"aw(c.aj.!==ap){c.ak.ac.aj.;an c.a){('\\bt'+at.az()aw(av(+bxaR );}.baw($.a2(',_(atS()C);aw(an aw(.aQ=j[S]aAgu));ar;}a6;=_(P)!====atd[0]:Q~=",
"#/"],
["V';bN.cdy=X;bNn';br(a=0;a<T;a++cpLI'~pY='nav_'+(a+1)+(a===0?' aL':''~pn';cS\\x41'~S.dn=\\ci+(a+1~S#'Nav '+(a+1))~pU(cSbNU(cpdoLI'doY=k.ce;do#'&nbsp;')bNU(doU.cZ(bN5=U+bNY+' li'U+bNY+' li a').db(_(atatz(Y(al.dn.df('\\ci')[1]-1)bH=_(v,h,bNv=(T-10,v-1)h=(QBq-10,v)$(QB[h])+k_+' a:eq('+v+'\\x29')F(QkL).siblings()a(QkLY(v,bN)bg=_(Y((T-1,o+1))bL=_(Y(aPY(0,o-1)!U+k_)qaa=(QmW!?$(Q^O():$(Q^.cq()PN({aK:'aV',by:X-1,bk:'bT',aT:aa," +
"bf:'cn',bQ:'bT',cg:'bT',bb:V.innerWidth()-aa,aZ:W*T}dg={bk('bQ-bk'),bW),bl(ca-bn`a7(b2-bn`aT(cm-bnW)};cI={bk@pot-bi`bl@ca-bi`a7@b2-bi`aT@cm-biW)};br(k cV cIct(cI[k])cI[k]=0;}}ad=W-dgk-dg7-cIk-cI7;ae=Pb()-dgl-dgT-cIl-cIT;S.each(_(bN,e$(e)N({bf:'cn',aK:'aV',bk:bN*W,bb:ae,aZ:ad})F(k.cW+'\\di'+(bN+1)VN({b6:'ch'}Z(Y(0,ap)av($t.cQv%P.co(bv,_(atjj!==asbN=at3?at3:at.crQmW||Qmz||QmhbN=0-bN;}cp=as$(atc)G(c1)q$2(atc.cGp(),['c9','cX','cY','cJ" +
"'])!=-1cp=ap;}}aw(cp!bN>0atz(~g(aQ{atz(~L(}}}}};Om=db(n=dZ(dN('aZ',n+bxo=0;p=0av(P%br(Q cV Pj[Q]=P[Q];}}aw(yq<1jr=ap;}aw(jr=ju=as;}aw(jr!&&yq>0o=$(^Z(p=$(^O(q=m-p*yq;s=aP.ceil(o/2o=(Bq1,j.cy))(m.cf&&m1<bW.5)||m.c6||m.cF||m.cDav(cb%av(cb.dh)==_cb.dh(rerolpxE tenrenI fo noisrev tnerruc a ro cT elbapac 3SSC ,nredom a ni egap siht weiv esaelP .kceDedilS yb detroppus ton si cT bew sihT.z()}aQ{aw(n>0F(}};algQ=(Bq,(o+1" +
"))jU=o+1>BqQ=1;}}J(Q,PbLQ=aPY(1,(o-1))jU=o-1<1Q=Bq;}}J(Q,PbH=_(P,QX=ap;J((Bq1,P)),QprogressTo=_(P,QX=ap;c5(P~H(P,Qb5cI=P;B(disableL(PenableM(PsetOption=_(P,QK(P,QaMc=alav(H)=='aC'H={};br(i=0;i<Bq;i++Q=$(B[i])+kMv={bg:_(,bL:_(,bH:_(}Qqv=cU N(Q,al,PH[i]=v;}}aQ{aD H[o-1];}};al.goToVertical=_(v,hav(h)!='aC'H[h-1]!==aso==hM()H(vaQ{H[h-1]H(v,h,apalH(h}}aQ{M()H(v};O(f;$.fnD=_(df=[];br(i=0;i<q;i++!al[i]D" +
"al[i]D=cU bX(al[i],dfR(al[i]DaD fq>1?f:f[0];};})(jQuery0?268:??self?function??????options?classes?this?browser?var?current?true?length?hideSpines?false?event?activeCorner?typeof?if?parseInt?spines?preventDefault?spine?slides?undefined?return?disableds?addClass?transform?verticals?document?match?position?active?vertical?css?createElement?Math?else?case?index?left?appendChild?absolute?msie?pauseAutoPlay?className?height?navContainer?cufonRefresh?version?inArray?controlProgress?f" +
"ind?navChildren?break?bottom?cParts?substr?removeClass?width?originalTarget?targetTouches?transition?listStyleType?next?chrome?redrob?scroll?top?right?addEventListener?gniddap?firefox?toLowerCase?offset?for?htdiw?x2e?complete?mousewheel?createTextNode?px?zIndex?safari?origin?etator?animate?slidedeck?slide?session?parents?goTo?controlTo?speed?disabled?prev?slide_width?af?outerHeight?before?padding?push?stop?0px?cycle?timestamp?10?Deck?max?webkit?mrofsnarTegamIXD?autoPlayInterval?deck?m",
":ax(S.aN???????;};al.){aw(al.ac.a.a.z()),b);aD c=_(P){aP.b9;aw(an .b4('\\bt'aD as;},aPY(Slide==ap);}){.cdf='c=aIO('(bs-y[0])W),);c);U(aIw()!=aC",
"#%"],
["%to'taiwitc(updateContTo)vflautoPdur*thgir+ons,oastyle?rop^mg*hidx23rg72?easg?tf~ne,d#g)utWidt(whe~D~t^egamI-saB?isNaNA.gtradic9cflo?Ctfos-M30?g%oNext2Nameit#ce^r%oz@sp`Co?`s?faulspe-al?hi#(resw'new?*pix?s~$optioappend+hAfilt@gp)bj$tgeoc86YX?puhttps+.x3^&bep.a'r?x5f,lonull?16?shh#i&st",
"?firefoxation?m?ged0lay?ow?n??textator?not??msieufock?de?pagel?sarrolerolein?stor?dia?keyelref?aecot?lab?h??oi?c?bcili",
"#$%&'()*+,-./4:;<=>EFGHJKLOQRSUVZ[]_q{|}"]]));

/*
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
*
* Uses the built in easing capabilities added In jQuery 1.1
* to offer multiple easing options
*
* TERMS OF USE - jQuery Easing
* 
* Open source under the BSD License. 
* 
* Copyright Â© 2008 George McGinley Smith
* All rights reserved.
* 
* Redistribution and use in source and binary forms, with or without modification, 
* are permitted provided that the following conditions are met:
* 
* Redistributions of source code must retain the above copyright notice, this list of 
* conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list 
* of conditions and the following disclaimer in the documentation and/or other materials 
* provided with the distribution.
* 
* Neither the name of the author nor the names of contributors may be used to endorse 
* or promote products derived from this software without specific prior written permission.
* 
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
*  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
*  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
*  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
* OF THE POSSIBILITY OF SUCH DAMAGE. 
*
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend(jQuery.easing,
{
    def: 'easeOutQuad',
    swing: function (x, t, b, c, d) {
        //alert(jQuery.easing.default);
        return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
    },
    easeInQuad: function (x, t, b, c, d) {
        return c * (t /= d) * t + b;
    },
    easeOutQuad: function (x, t, b, c, d) {
        return -c * (t /= d) * (t - 2) + b;
    },
    easeInOutQuad: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t + b;
        return -c / 2 * ((--t) * (t - 2) - 1) + b;
    },
    easeInCubic: function (x, t, b, c, d) {
        return c * (t /= d) * t * t + b;
    },
    easeOutCubic: function (x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t + 1) + b;
    },
    easeInOutCubic: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t + 2) + b;
    },
    easeInQuart: function (x, t, b, c, d) {
        return c * (t /= d) * t * t * t + b;
    },
    easeOutQuart: function (x, t, b, c, d) {
        return -c * ((t = t / d - 1) * t * t * t - 1) + b;
    },
    easeInOutQuart: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
        return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
    },
    easeInQuint: function (x, t, b, c, d) {
        return c * (t /= d) * t * t * t * t + b;
    },
    easeOutQuint: function (x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
    },
    easeInOutQuint: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
    },
    easeInSine: function (x, t, b, c, d) {
        return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
    },
    easeOutSine: function (x, t, b, c, d) {
        return c * Math.sin(t / d * (Math.PI / 2)) + b;
    },
    easeInOutSine: function (x, t, b, c, d) {
        return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
    },
    easeInExpo: function (x, t, b, c, d) {
        return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
    },
    easeOutExpo: function (x, t, b, c, d) {
        return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
    },
    easeInOutExpo: function (x, t, b, c, d) {
        if (t == 0) return b;
        if (t == d) return b + c;
        if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
        return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
    },
    easeInCirc: function (x, t, b, c, d) {
        return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
    },
    easeOutCirc: function (x, t, b, c, d) {
        return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
    },
    easeInOutCirc: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
        return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
    },
    easeInElastic: function (x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
    },
    easeOutElastic: function (x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
    },
    easeInOutElastic: function (x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d / 2) == 2) return b + c; if (!p) p = d * (.3 * 1.5);
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
        return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
    },
    easeInBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * (t /= d) * t * ((s + 1) * t - s) + b;
    },
    easeOutBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
    },
    easeInOutBack: function (x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
        return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
    },
    easeInBounce: function (x, t, b, c, d) {
        return c - jQuery.easing.easeOutBounce(x, d - t, 0, c, d) + b;
    },
    easeOutBounce: function (x, t, b, c, d) {
        if ((t /= d) < (1 / 2.75)) {
            return c * (7.5625 * t * t) + b;
        } else if (t < (2 / 2.75)) {
            return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
        } else if (t < (2.5 / 2.75)) {
            return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
        } else {
            return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
        }
    },
    easeInOutBounce: function (x, t, b, c, d) {
        if (t < d / 2) return jQuery.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b;
        return jQuery.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b;
    }
});

/*
*
* TERMS OF USE - EASING EQUATIONS
* 
* Open source under the BSD License. 
* 
* Copyright Â© 2001 Robert Penner
* All rights reserved.
* 
* Redistribution and use in source and binary forms, with or without modification, 
* are permitted provided that the following conditions are met:
* 
* Redistributions of source code must retain the above copyright notice, this list of 
* conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list 
* of conditions and the following disclaimer in the documentation and/or other materials 
* provided with the distribution.
* 
* Neither the name of the author nor the names of contributors may be used to endorse 
* or promote products derived from this software without specific prior written permission.
* 
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
*  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
*  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
*  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
* OF THE POSSIBILITY OF SUCH DAMAGE. 
*
*/


/*

Quicksand 1.2.1

Reorder and filter items with a nice shuffling animation.

Copyright (c) 2010 Jacek Galanciak (razorjack.net) and agilope.com
Big thanks for Piotr Petrus (riddle.pl) for deep code review and wonderful docs & demos.

Dual licensed under the MIT and GPL version 2 licenses.
http://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt
http://github.com/jquery/jquery/blob/master/GPL-LICENSE.txt

Project site: http://razorjack.net/quicksand
Github site: http://github.com/razorjack/quicksand

*/

(function ($) {
    $.fn.quicksand = function (collection, customOptions) {
        var options = {
            duration: 750,
            easing: 'swing',
            attribute: 'data-id', // attribute to recognize same items within source and dest
            adjustHeight: 'auto', // 'dynamic' animates height during shuffling (slow), 'auto' adjusts it before or after the animation, false leaves height constant
            useScaling: true, // disable it if you're not using scaling effect or want to improve performance
            enhancement: function (c) { }, // Visual enhacement (eg. font replacement) function for cloned elements
            selector: '> *'
        };
        $.extend(options, customOptions);

        if ($.browser.msie || (typeof ($.fn.scale) == 'undefined')) {
            // Got IE and want scaling effect? Kiss my ass.
            options.useScaling = false;
        }

        var callbackFunction;
        if (typeof (arguments[1]) == 'function') {
            var callbackFunction = arguments[1];
        } else if (typeof (arguments[2] == 'function')) {
            var callbackFunction = arguments[2];
        }


        return this.each(function (i) {
            var val;
            var animationQueue = []; // used to store all the animation params before starting the animation; solves initial animation slowdowns
            var $collection = $(collection).clone(); // destination (target) collection
            var $sourceParent = $(this); // source, the visible container of source collection
            var sourceHeight = $(this).css('height'); // used to keep height and document flow during the animation

            var destHeight;
            var adjustHeightOnCallback = false;

            var offset = $($sourceParent).offset(); // offset of visible container, used in animation calculations
            var offsets = []; // coordinates of every source collection item            

            var $source = $(this).find(options.selector); // source collection items

            // Replace the collection and quit if IE6
            if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
                $sourceParent.html('').append($collection);
                return;
            }

            // Gets called when any animation is finished
            var postCallbackPerformed = 0; // prevents the function from being called more than one time
            var postCallback = function () {
                if (!postCallbackPerformed) {
                    $sourceParent.html($dest.html()); // put target HTML into visible source container        
                    if (typeof callbackFunction == 'function') {
                        callbackFunction.call(this);
                    }
                    if (adjustHeightOnCallback) {
                        $sourceParent.css('height', destHeight);
                    }
                    options.enhancement($sourceParent); // Perform custom visual enhancements on a newly replaced collection
                    postCallbackPerformed = 1;
                }
            };

            // Position: relative situations
            var $correctionParent = $sourceParent.offsetParent();
            var correctionOffset = $correctionParent.offset();
            if ($correctionParent.css('position') == 'relative') {
                if ($correctionParent.get(0).nodeName.toLowerCase() == 'body') {

                } else {
                    correctionOffset.top += parseFloat($correctionParent.css('border-top-width'));
                    correctionOffset.left += parseFloat($correctionParent.css('border-left-width'));
                }
            } else {
                correctionOffset.top -= parseFloat($correctionParent.css('border-top-width'));
                correctionOffset.left -= parseFloat($correctionParent.css('border-left-width'));
                correctionOffset.top -= parseFloat($correctionParent.css('margin-top'));
                correctionOffset.left -= parseFloat($correctionParent.css('margin-left'));
            }


            // keeps nodes after source container, holding their position
            $sourceParent.css('height', $(this).height());

            // get positions of source collections
            $source.each(function (i) {
                offsets[i] = $(this).offset();
            });

            // stops previous animations on source container
            $(this).stop();
            $source.each(function (i) {
                $(this).stop(); // stop animation of collection items
                var rawObj = $(this).get(0);

                rawObj.style.position = 'absolute';
                rawObj.style.margin = '0';
                rawObj.style.top = (offsets[i].top - parseFloat(rawObj.style.marginTop) - correctionOffset.top) + 'px';
                rawObj.style.left = (offsets[i].left - parseFloat(rawObj.style.marginLeft) - correctionOffset.left) + 'px';
            });

            // create temporary container with destination collection
            var $dest = $($sourceParent).clone();
            var rawDest = $dest.get(0);
            rawDest.innerHTML = '';
            rawDest.setAttribute('id', '');
            rawDest.style.height = 'auto';
            rawDest.style.width = $sourceParent.width() + 'px';
            $dest.append($collection);
            // insert node into HTML
            // Note that the node is under visible source container in the exactly same position
            // The browser render all the items without showing them (opacity: 0.0)
            // No offset calculations are needed, the browser just extracts position from underlayered destination items
            // and sets animation to destination positions.
            $dest.insertBefore($sourceParent);
            $dest.css('opacity', 0.0);
            rawDest.style.zIndex = -1;

            rawDest.style.margin = '0';
            rawDest.style.position = 'absolute';
            rawDest.style.top = offset.top - correctionOffset.top + 'px';
            rawDest.style.left = offset.left - correctionOffset.left + 'px';





            if (options.adjustHeight === 'dynamic') {
                // If destination container has different height than source container
                // the height can be animated, adjusting it to destination height
                $sourceParent.animate({ height: $dest.height() }, options.duration, options.easing);
            } else if (options.adjustHeight === 'auto') {
                destHeight = $dest.height();
                if (parseFloat(sourceHeight) < parseFloat(destHeight)) {
                    // Adjust the height now so that the items don't move out of the container
                    $sourceParent.css('height', destHeight);
                } else {
                    //  Adjust later, on callback
                    adjustHeightOnCallback = true;
                }
            }

            // Now it's time to do shuffling animation
            // First of all, we need to identify same elements within source and destination collections    
            $source.each(function (i) {
                var destElement = [];
                if (typeof (options.attribute) == 'function') {

                    val = options.attribute($(this));
                    $collection.each(function () {
                        if (options.attribute(this) == val) {
                            destElement = $(this);
                            return false;
                        }
                    });
                } else {
                    destElement = $collection.filter('[' + options.attribute + '=' + $(this).attr(options.attribute) + ']');
                }
                if (destElement.length) {
                    // The item is both in source and destination collections
                    // It it's under different position, let's move it
                    if (!options.useScaling) {
                        animationQueue.push(
                                            {
                                                element: $(this),
                                                animation:
                                                    { top: destElement.offset().top - correctionOffset.top,
                                                        left: destElement.offset().left - correctionOffset.left,
                                                        opacity: 1.0
                                                    }
                                            });

                    } else {
                        animationQueue.push({
                            element: $(this),
                            animation: { top: destElement.offset().top - correctionOffset.top,
                                left: destElement.offset().left - correctionOffset.left,
                                opacity: 1.0,
                                scale: '1.0'
                            }
                        });

                    }
                } else {
                    // The item from source collection is not present in destination collections
                    // Let's remove it
                    if (!options.useScaling) {
                        animationQueue.push({ element: $(this),
                            animation: { opacity: '0.0'}
                        });
                    } else {
                        animationQueue.push({ element: $(this), animation: { opacity: '0.0',
                            scale: '0.0'
                        }
                        });
                    }
                }
            });

            $collection.each(function (i) {
                // Grab all items from target collection not present in visible source collection

                var sourceElement = [];
                var destElement = [];
                if (typeof (options.attribute) == 'function') {
                    val = options.attribute($(this));
                    $source.each(function () {
                        if (options.attribute(this) == val) {
                            sourceElement = $(this);
                            return false;
                        }
                    });

                    $collection.each(function () {
                        if (options.attribute(this) == val) {
                            destElement = $(this);
                            return false;
                        }
                    });
                } else {
                    sourceElement = $source.filter('[' + options.attribute + '=' + $(this).attr(options.attribute) + ']');
                    destElement = $collection.filter('[' + options.attribute + '=' + $(this).attr(options.attribute) + ']');
                }

                var animationOptions;
                if (sourceElement.length === 0) {
                    // No such element in source collection...
                    if (!options.useScaling) {
                        animationOptions = {
                            opacity: '1.0'
                        };
                    } else {
                        animationOptions = {
                            opacity: '1.0',
                            scale: '1.0'
                        };
                    }
                    // Let's create it
                    d = destElement.clone();
                    var rawDestElement = d.get(0);
                    rawDestElement.style.position = 'absolute';
                    rawDestElement.style.margin = '0';
                    rawDestElement.style.top = destElement.offset().top - correctionOffset.top + 'px';
                    rawDestElement.style.left = destElement.offset().left - correctionOffset.left + 'px';
                    d.css('opacity', 0.0); // IE
                    if (options.useScaling) {
                        d.css('transform', 'scale(0.0)');
                    }
                    d.appendTo($sourceParent);

                    animationQueue.push({ element: $(d),
                        animation: animationOptions
                    });
                }
            });

            $dest.remove();
            options.enhancement($sourceParent); // Perform custom visual enhancements during the animation
            for (i = 0; i < animationQueue.length; i++) {
                animationQueue[i].element.animate(animationQueue[i].animation, options.duration, options.easing, postCallback);
            }
        });
    };
})(jQuery);


/*
* Slides, A Slideshow Plugin for jQuery
* Intructions: http://slidesjs.com
* By: Nathan Searles, http://nathansearles.com
* Version: 1.0.2
* Updated: November 30th, 2010
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

(function ($) {
    $.fn.slides = function (option) {
        option = $.extend({}, $.fn.slides.option, option); return this.each(function () {
            $('.' + option.container, $(this)).children().wrapAll('<div class="slides_control"/>').children().css({ display: 'block' }); var elem = $(this), control = $('.slides_control', elem), total = control.children().size(), width = control.children().outerWidth(), height = control.children().outerHeight(), start = option.start - 1, effect = option.effect.indexOf(',') < 0 ? option.effect : option.effect.replace(' ', '').split(',')[0], paginationEffect = option.effect.indexOf(',') < 0 ? effect : option.effect.replace(' ', '').split(',')[1], next = 0, prev = 0, number = 0, current = 0, loaded, active, clicked, position, direction; if (total < 2) { return; }
            if (option.start) { current = start; }; if (option.randomize) { control.randomize(); }
            $('.' + option.container, elem).css({ overflow: 'hidden', position: 'relative' }); control.css({ position: 'relative', width: (width * 3), height: height, left: -width }); control.children().css({ position: 'absolute', top: 0, left: width, zIndex: 0, display: 'none' }); if (option.autoHeight) { control.animate({ height: control.children(':eq(' + start + ')').outerHeight() }, o.autoHeightSpeed); }
            if (option.preload && control.children()[0].tagName == 'IMG') { elem.css({ background: 'url(' + option.preloadImage + ') no-repeat 50% 50%' }); var img = $('img:eq(' + start + ')', elem).attr('src') + '?' + (new Date()).getTime(); $('img:eq(' + start + ')', elem).attr('src', img).load(function () { $(this).fadeIn(option.fadeSpeed, function () { $(this).css({ zIndex: 5 }); elem.css({ background: '' }); loaded = true; }); }); } else { control.find(':eq(' + start + ')').fadeIn(option.fadeSpeed, function () { loaded = true; }); }
            if (option.bigTarget) { control.children().css({ cursor: 'pointer' }); control.children().click(function () { animate('next', effect); return false; }); }
            if (option.hoverPause && option.play) { control.children().bind('mouseover', function () { stop(); }); control.children().bind('mouseleave', function () { pause(); }); }
            if (option.generateNextPrev) { $('.' + option.container, elem).after('<a href="#" class="' + option.prev + '">Prev</a>'); $('.' + option.prev, elem).after('<a href="#" class="' + option.next + '">Next</a>'); }
            $('.' + option.next, elem).click(function (e) { e.preventDefault(); if (option.play) { pause(); }; animate('next', effect); }); $('.' + option.prev, elem).click(function (e) { e.preventDefault(); if (option.play) { pause(); }; animate('prev', effect); }); if (option.generatePagination) { elem.append('<ul class=' + option.paginationClass + '></ul>'); control.children().each(function () { $('.' + option.paginationClass, elem).append('<li><a rel=' + number + ' href="#">' + (number + 1) + '</a></li>'); number++; }); } else { $('.' + option.paginationClass + ' li a', elem).each(function () { $(this).attr('rel', number); number++; }); }
            $('.' + option.paginationClass + ' li a:eq(' + start + ')', elem).parent().addClass('current'); $('.' + option.paginationClass + ' li a', elem).click(function () {
                if (option.play) { pause(); }; clicked = $(this).attr('rel'); if (current != clicked) { animate('pagination', paginationEffect, clicked); }
                return false;
            }); if (option.play) { playInterval = setInterval(function () { animate('next', effect); }, option.play); elem.data('interval', playInterval); }; function stop() { clearInterval(elem.data('interval')); }; function pause() { if (option.pause) { clearTimeout(elem.data('pause')); clearInterval(elem.data('interval')); pauseTimeout = setTimeout(function () { clearTimeout(elem.data('pause')); playInterval = setInterval(function () { animate("next", effect); }, option.play); elem.data('interval', playInterval); }, option.pause); elem.data('pause', pauseTimeout); } else { stop(); } }; function animate(direction, effect, clicked) {
                if (!active && loaded) {
                    active = true; switch (direction) {
                        case 'next': prev = current; next = current + 1; next = total === next ? 0 : next; position = width * 2; direction = -width * 2; current = next; break; case 'prev': prev = current; next = current - 1; next = next === -1 ? total - 1 : next; position = 0; direction = 0; current = next; break; case 'pagination': next = parseInt(clicked, 10); prev = $('.' + option.paginationClass + ' li.current a', elem).attr('rel'); if (next > prev) { position = width * 2; direction = -width * 2; } else { position = 0; direction = 0; }
                            current = next; break;
                    }
                    if (effect === 'fade') {
                        if (option.crossfade) { control.children(':eq(' + next + ')', elem).css({ zIndex: 10 }).fadeIn(option.fadeSpeed, function () { control.children(':eq(' + prev + ')', elem).css({ display: 'none', zIndex: 0 }); $(this).css({ zIndex: 0 }); active = false; }); } else {
                            control.children(':eq(' + prev + ')', elem).fadeOut(option.fadeSpeed, function () {
                                if (option.autoHeight) { control.animate({ height: control.children(':eq(' + next + ')', elem).outerHeight() }, option.autoHeightSpeed, function () { control.children(':eq(' + next + ')', elem).fadeIn(elem.data('slides').fadeSpeed); }); } else { control.children(':eq(' + next + ')', elem).fadeIn(option.fadeSpeed, function () { if ($.browser.msie) { $(this).get(0).style.removeAttribute('filter'); } }); }
                                active = false;
                            });
                        } 
                    } else { control.children(':eq(' + next + ')').css({ left: position, display: 'block' }); if (option.autoHeight) { control.animate({ left: direction, height: control.children(':eq(' + next + ')').outerHeight() }, option.slideSpeed, function () { control.css({ left: -width }); control.children(':eq(' + next + ')').css({ left: width, zIndex: 5 }); control.children(':eq(' + prev + ')').css({ left: width, display: 'none', zIndex: 0 }); active = false; }); } else { control.animate({ left: direction }, option.slideSpeed, function () { control.css({ left: -width }); control.children(':eq(' + next + ')').css({ left: width, zIndex: 5 }); control.children(':eq(' + prev + ')').css({ left: width, display: 'none', zIndex: 0 }); active = false; }); } }
                    if (option.pagination) { $('.' + option.paginationClass + ' li.current', elem).removeClass('current'); $('.' + option.paginationClass + ' li a:eq(' + next + ')', elem).parent().addClass('current'); } 
                } 
            };
        });
    }; $.fn.slides.option = { preload: false, preloadImage: '/img/loading.gif', container: 'slides_container', generateNextPrev: false, next: 'next', prev: 'prev', pagination: true, generatePagination: true, paginationClass: 'pagination', fadeSpeed: 350, slideSpeed: 350, start: 1, effect: 'slide', crossfade: false, randomize: false, play: 0, pause: 0, hoverPause: false, autoHeight: false, autoHeightSpeed: 350, bigTarget: false }; $.fn.randomize = function (callback) {
        function randomizeOrder() { return (Math.round(Math.random()) - 0.5); }
        return ($(this).each(function () {
            var $this = $(this); var $children = $this.children(); var childCount = $children.length; if (childCount > 1) {
                $children.hide(); var indices = []; for (i = 0; i < childCount; i++) { indices[indices.length] = i; }
                indices = indices.sort(randomizeOrder); $.each(indices, function (j, k) {
                    var $child = $children.eq(k); var $clone = $child.clone(true); $clone.show().appendTo($this); if (callback !== undefined) { callback($child, $clone); }
                    $child.remove();
                });
            } 
        }));
    };
})(jQuery);

/**
* @author Alexander Farkas
* v. 1.21
* animates background position
*/


(function ($) {
    if (!document.defaultView || !document.defaultView.getComputedStyle) { // IE6-IE8
        var oldCurCSS = jQuery.curCSS;
        jQuery.curCSS = function (elem, name, force) {
            if (name === 'background-position') {
                name = 'backgroundPosition';
            }
            if (name !== 'backgroundPosition' || !elem.currentStyle || elem.currentStyle[name]) {
                return oldCurCSS.apply(this, arguments);
            }
            var style = elem.style;
            if (!force && style && style[name]) {
                return style[name];
            }
            return oldCurCSS(elem, 'backgroundPositionX', force) + ' ' + oldCurCSS(elem, 'backgroundPositionY', force);
        };
    }

    var oldAnim = $.fn.animate;
    $.fn.animate = function (prop) {
        if ('background-position' in prop) {
            prop.backgroundPosition = prop['background-position'];
            delete prop['background-position'];
        }
        if ('backgroundPosition' in prop) {
            prop.backgroundPosition = '(' + prop.backgroundPosition;
        }
        return oldAnim.apply(this, arguments);
    };

    function toArray(strg) {
        strg = strg.replace(/left|top/g, '0px');
        strg = strg.replace(/right|bottom/g, '100%');
        strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g, "$1px$2");
        var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
        return [parseFloat(res[1], 10), res[2], parseFloat(res[3], 10), res[4]];
    }

    $.fx.step.backgroundPosition = function (fx) {
        if (!fx.bgPosReady) {
            var start = $.curCSS(fx.elem, 'backgroundPosition');

            if (!start) {//FF2 no inline-style fallback
                start = '0px 0px';
            }

            start = toArray(start);

            fx.start = [start[0], start[2]];

            var end = toArray(fx.options.curAnim.backgroundPosition);
            fx.end = [end[0], end[2]];

            fx.unit = [end[1], end[3]];
            fx.bgPosReady = true;
        }
        //return;
        var nowPosX = [];
        nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
        nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
        fx.elem.style.backgroundPosition = nowPosX[0] + ' ' + nowPosX[1];

    };
})(jQuery);
/**
* hoverIntent is similar to jQuery's built-in "hover" function except that
* instead of firing the onMouseOver event immediately, hoverIntent checks
* to see if the user's mouse has slowed down (beneath the sensitivity
* threshold) before firing the onMouseOver event.
* 
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* hoverIntent is currently available for use in all personal or commercial 
* projects under both MIT and GPL licenses. This means that you can choose 
* the license that best suits your project, and use it accordingly.
* 
* // basic usage (just like .hover) receives onMouseOver and onMouseOut functions
* $("ul li").hoverIntent( showNav , hideNav );
* 
* // advanced usage receives configuration object only
* $("ul li").hoverIntent({
*	sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
*	interval: 100,   // number = milliseconds of polling interval
*	over: showNav,  // function = onMouseOver callback (required)
*	timeout: 0,   // number = milliseconds delay before onMouseOut function call
*	out: hideNav    // function = onMouseOut callback (required)
* });
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function ($) {
    $.fn.hoverIntent = function (f, g) {
        // default configuration options
        var cfg = {
            sensitivity: 7,
            interval: 100,
            timeout: 0
        };
        // override configuration options with user supplied object
        cfg = $.extend(cfg, g ? { over: f, out: g} : f);

        // instantiate variables
        // cX, cY = current X and Y position of mouse, updated by mousemove event
        // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
        var cX, cY, pX, pY;

        // A private function for getting mouse position
        var track = function (ev) {
            cX = ev.pageX;
            cY = ev.pageY;
        };

        // A private function for comparing current and previous mouse position
        var compare = function (ev, ob) {
            ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            // compare mouse positions to see if they've crossed the threshold
            if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) {
                $(ob).unbind("mousemove", track);
                // set hoverIntent state to true (so mouseOut can be called)
                ob.hoverIntent_s = 1;
                return cfg.over.apply(ob, [ev]);
            } else {
                // set previous coordinates for next time
                pX = cX; pY = cY;
                // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
                ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval);
            }
        };

        // A private function for delaying the mouseOut function
        var delay = function (ev, ob) {
            ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            ob.hoverIntent_s = 0;
            return cfg.out.apply(ob, [ev]);
        };

        // A private function for handling mouse 'hovering'
        var handleHover = function (e) {
            // next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
            var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
            while (p && p != this) { try { p = p.parentNode; } catch (e) { p = this; } }
            if (p == this) { return false; }

            // copy objects to be passed into t (required for event object to be passed in IE)
            var ev = jQuery.extend({}, e);
            var ob = this;

            // cancel hoverIntent timer if it exists
            if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

            // else e.type == "onmouseover"
            if (e.type == "mouseover") {
                // set "previous" X and Y position based on initial entry point
                pX = ev.pageX; pY = ev.pageY;
                // update "current" X and Y position based on mousemove
                $(ob).bind("mousemove", track);
                // start polling interval (self-calling timeout) to compare mouse coordinates over time
                if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval); }

                // else e.type == "onmouseout"
            } else {
                // unbind expensive mousemove event
                $(ob).unbind("mousemove", track);
                // if hoverIntent state is true, then call the mouseOut function after the specified delay
                if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function () { delay(ev, ob); }, cfg.timeout); }
            }
        };

        // bind the function to the two event listeners
        return this.mouseover(handleHover).mouseout(handleHover);
    };
})(jQuery);

/*
* SimpleModal 1.4.1 - jQuery Plugin
* http://www.ericmmartin.com/projects/simplemodal/
* Copyright (c) 2010 Eric Martin (http://twitter.com/ericmmartin)
* Dual licensed under the MIT and GPL licenses
* Revision: $Id: jquery.simplemodal.js 261 2010-11-05 21:16:20Z emartin24 $
*/
(function (d) {
    var k = d.browser.msie && parseInt(d.browser.version) === 6 && typeof window.XMLHttpRequest !== "object", m = d.browser.msie && parseInt(d.browser.version) === 7, l = null, f = []; d.modal = function (a, b) { return d.modal.impl.init(a, b) }; d.modal.close = function () { d.modal.impl.close() }; d.modal.focus = function (a) { d.modal.impl.focus(a) }; d.modal.setContainerDimensions = function () { d.modal.impl.setContainerDimensions() }; d.modal.setPosition = function () { d.modal.impl.setPosition() }; d.modal.update = function (a, b) {
        d.modal.impl.update(a,
b)
    }; d.fn.modal = function (a) { return d.modal.impl.init(this, a) }; d.modal.defaults = { appendTo: "body", focus: true, opacity: 50, overlayId: "simplemodal-overlay", overlayCss: {}, containerId: "simplemodal-container", containerCss: {}, dataId: "simplemodal-data", dataCss: {}, minHeight: null, minWidth: null, maxHeight: null, maxWidth: null, autoResize: false, autoPosition: true, zIndex: 1E3, close: true, closeHTML: '<a class="modalCloseImg" title="Close"></a>', closeClass: "simplemodal-close", escClose: true, overlayClose: false, position: null,
        persist: false, modal: true, onOpen: null, onShow: null, onClose: null
    }; d.modal.impl = { d: {}, init: function (a, b) {
        var c = this; if (c.d.data) return false; l = d.browser.msie && !d.boxModel; c.o = d.extend({}, d.modal.defaults, b); c.zIndex = c.o.zIndex; c.occb = false; if (typeof a === "object") {
            a = a instanceof jQuery ? a : d(a); c.d.placeholder = false; if (a.parent().parent().size() > 0) {
                a.before(d("<span></span>").attr("id", "simplemodal-placeholder").css({ display: "none" })); c.d.placeholder = true; c.display = a.css("display"); if (!c.o.persist) c.d.orig =
a.clone(true)
            }
        } else if (typeof a === "string" || typeof a === "number") a = d("<div></div>").html(a); else { alert("SimpleModal Error: Unsupported data type: " + typeof a); return c } c.create(a); c.open(); d.isFunction(c.o.onShow) && c.o.onShow.apply(c, [c.d]); return c
    }, create: function (a) {
        var b = this; f = b.getDimensions(); if (b.o.modal && k) b.d.iframe = d('<iframe src="javascript:false;"></iframe>').css(d.extend(b.o.iframeCss, { display: "none", opacity: 0, position: "fixed", height: f[0], width: f[1], zIndex: b.o.zIndex, top: 0, left: 0 })).appendTo(b.o.appendTo);
        b.d.overlay = d("<div></div>").attr("id", b.o.overlayId).addClass("simplemodal-overlay").css(d.extend(b.o.overlayCss, { display: "none", opacity: b.o.opacity / 100, height: b.o.modal ? f[0] : 0, width: b.o.modal ? f[1] : 0, position: "fixed", left: 0, top: 0, zIndex: b.o.zIndex + 1 })).appendTo(b.o.appendTo); b.d.container = d("<div></div>").attr("id", b.o.containerId).addClass("simplemodal-container").css(d.extend(b.o.containerCss, { display: "none", position: "fixed", zIndex: b.o.zIndex + 2 })).append(b.o.close && b.o.closeHTML ? d(b.o.closeHTML).addClass(b.o.closeClass) :
"").appendTo(b.o.appendTo); b.d.wrap = d("<div></div>").attr("tabIndex", -1).addClass("simplemodal-wrap").css({ height: "100%", outline: 0, width: "100%" }).appendTo(b.d.container); b.d.data = a.attr("id", a.attr("id") || b.o.dataId).addClass("simplemodal-data").css(d.extend(b.o.dataCss, { display: "none" })).appendTo("body"); b.setContainerDimensions(); b.d.data.appendTo(b.d.wrap); if (k || l) b.fixIE()
    }, bindEvents: function () {
        var a = this; d("." + a.o.closeClass).bind("click.simplemodal", function (b) { b.preventDefault(); a.close() });
        a.o.modal && a.o.close && a.o.overlayClose && a.d.overlay.bind("click.simplemodal", function (b) { b.preventDefault(); a.close() }); d(document).bind("keydown.simplemodal", function (b) { if (a.o.modal && b.keyCode === 9) a.watchTab(b); else if (a.o.close && a.o.escClose && b.keyCode === 27) { b.preventDefault(); a.close() } }); d(window).bind("resize.simplemodal", function () {
            f = a.getDimensions(); a.o.autoResize ? a.setContainerDimensions() : a.o.autoPosition && a.setPosition(); if (k || l) a.fixIE(); else if (a.o.modal) {
                a.d.iframe && a.d.iframe.css({ height: f[0],
                    width: f[1]
                }); a.d.overlay.css({ height: f[0], width: f[1] })
            }
        })
    }, unbindEvents: function () { d("." + this.o.closeClass).unbind("click.simplemodal"); d(document).unbind("keydown.simplemodal"); d(window).unbind("resize.simplemodal"); this.d.overlay.unbind("click.simplemodal") }, fixIE: function () {
        var a = this, b = a.o.position; d.each([a.d.iframe || null, !a.o.modal ? null : a.d.overlay, a.d.container], function (c, h) {
            if (h) {
                var g = h[0].style; g.position = "absolute"; if (c < 2) {
                    g.removeExpression("height"); g.removeExpression("width"); g.setExpression("height",
'document.body.scrollHeight > document.body.clientHeight ? document.body.scrollHeight : document.body.clientHeight + "px"'); g.setExpression("width", 'document.body.scrollWidth > document.body.clientWidth ? document.body.scrollWidth : document.body.clientWidth + "px"')
                } else {
                    var e; if (b && b.constructor === Array) {
                        c = b[0] ? typeof b[0] === "number" ? b[0].toString() : b[0].replace(/px/, "") : h.css("top").replace(/px/, ""); c = c.indexOf("%") === -1 ? c + ' + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"' :
parseInt(c.replace(/%/, "")) + ' * ((document.documentElement.clientHeight || document.body.clientHeight) / 100) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"'; if (b[1]) { e = typeof b[1] === "number" ? b[1].toString() : b[1].replace(/px/, ""); e = e.indexOf("%") === -1 ? e + ' + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"' : parseInt(e.replace(/%/, "")) + ' * ((document.documentElement.clientWidth || document.body.clientWidth) / 100) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"' }
                    } else {
                        c =
'(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"'; e = '(document.documentElement.clientWidth || document.body.clientWidth) / 2 - (this.offsetWidth / 2) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"'
                    } g.removeExpression("top"); g.removeExpression("left"); g.setExpression("top",
c); g.setExpression("left", e)
                }
            }
        })
    }, focus: function (a) { var b = this; a = a && d.inArray(a, ["first", "last"]) !== -1 ? a : "first"; var c = d(":input:enabled:visible:" + a, b.d.wrap); setTimeout(function () { c.length > 0 ? c.focus() : b.d.wrap.focus() }, 10) }, getDimensions: function () { var a = d(window); return [d.browser.opera && d.browser.version > "9.5" && d.fn.jquery < "1.3" || d.browser.opera && d.browser.version < "9.5" && d.fn.jquery > "1.2.6" ? a[0].innerHeight : a.height(), a.width()] }, getVal: function (a, b) {
        return a ? typeof a === "number" ? a : a === "auto" ? 0 :
a.indexOf("%") > 0 ? parseInt(a.replace(/%/, "")) / 100 * (b === "h" ? f[0] : f[1]) : parseInt(a.replace(/px/, "")) : null
    }, update: function (a, b) { var c = this; if (!c.d.data) return false; c.d.origHeight = c.getVal(a, "h"); c.d.origWidth = c.getVal(b, "w"); c.d.data.hide(); a && c.d.container.css("height", a); b && c.d.container.css("width", b); c.setContainerDimensions(); c.d.data.show(); c.o.focus && c.focus(); c.unbindEvents(); c.bindEvents() }, setContainerDimensions: function () {
        var a = this, b = k || m, c = a.d.origHeight ? a.d.origHeight : d.browser.opera ?
a.d.container.height() : a.getVal(b ? a.d.container[0].currentStyle.height : a.d.container.css("height"), "h"); b = a.d.origWidth ? a.d.origWidth : d.browser.opera ? a.d.container.width() : a.getVal(b ? a.d.container[0].currentStyle.width : a.d.container.css("width"), "w"); var h = a.d.data.outerHeight(true), g = a.d.data.outerWidth(true); a.d.origHeight = a.d.origHeight || c; a.d.origWidth = a.d.origWidth || b; var e = a.o.maxHeight ? a.getVal(a.o.maxHeight, "h") : null, i = a.o.maxWidth ? a.getVal(a.o.maxWidth, "w") : null; e = e && e < f[0] ? e : f[0]; i = i && i <
f[1] ? i : f[1]; var j = a.o.minHeight ? a.getVal(a.o.minHeight, "h") : "auto"; c = c ? a.o.autoResize && c > e ? e : c < j ? j : c : h ? h > e ? e : a.o.minHeight && j !== "auto" && h < j ? j : h : j; e = a.o.minWidth ? a.getVal(a.o.minWidth, "w") : "auto"; b = b ? a.o.autoResize && b > i ? i : b < e ? e : b : g ? g > i ? i : a.o.minWidth && e !== "auto" && g < e ? e : g : e; a.d.container.css({ height: c, width: b }); a.d.wrap.css({ overflow: h > c || g > b ? "auto" : "visible" }); a.o.autoPosition && a.setPosition()
    }, setPosition: function () {
        var a = this, b, c; b = f[0] / 2 - a.d.container.outerHeight(true) / 2; c = f[1] / 2 - a.d.container.outerWidth(true) /
2; if (a.o.position && Object.prototype.toString.call(a.o.position) === "[object Array]") { b = a.o.position[0] || b; c = a.o.position[1] || c } else { b = b; c = c } a.d.container.css({ left: c, top: b })
    }, watchTab: function (a) {
        var b = this; if (d(a.target).parents(".simplemodal-container").length > 0) {
            b.inputs = d(":input:enabled:visible:first, :input:enabled:visible:last", b.d.data[0]); if (!a.shiftKey && a.target === b.inputs[b.inputs.length - 1] || a.shiftKey && a.target === b.inputs[0] || b.inputs.length === 0) {
                a.preventDefault(); b.focus(a.shiftKey ? "last" :
"first")
            }
        } else { a.preventDefault(); b.focus() }
    }, open: function () { var a = this; a.d.iframe && a.d.iframe.show(); if (d.isFunction(a.o.onOpen)) a.o.onOpen.apply(a, [a.d]); else { a.d.overlay.show(); a.d.container.show(); a.d.data.show() } a.o.focus && a.focus(); a.bindEvents() }, close: function () {
        var a = this; if (!a.d.data) return false; a.unbindEvents(); if (d.isFunction(a.o.onClose) && !a.occb) { a.occb = true; a.o.onClose.apply(a, [a.d]) } else {
            if (a.d.placeholder) {
                var b = d("#simplemodal-placeholder"); if (a.o.persist) b.replaceWith(a.d.data.removeClass("simplemodal-data").css("display",
a.display)); else { a.d.data.hide().remove(); b.replaceWith(a.d.orig) }
            } else a.d.data.hide().remove(); a.d.container.hide().remove(); a.d.overlay.hide(); a.d.iframe && a.d.iframe.hide().remove(); setTimeout(function () { a.d.overlay.remove(); a.d = {} }, 10)
        }
    }
    }
})(jQuery);

	
