jQuery(document).ready(function() {
    initBrowserDetect();
    initTabs();
    initBreadcrumbs();
    initIE();
    clearForms();
    initScrollTo();
    scrollPageToTop();
    jQuery('div.visual').gallery({
        duration: 500,
        autoRotation: 12000,
        listOfSlides: '.slideshow>ul > li',
        switcher: '.listing>li'
    });
    jQuery('div.gallery').each(function() {
        jQuery(this).gallery({
            duration: 500,
            disableBtn: 'dis',
            circle: false,
            stopDrop: '.select-box',
            listOfSlides: '.gallery-list > li'
        });
    })

    jQuery('div.product-gallery').each(function() {
        jQuery(this).gallery({
            duration: 500,
            disableBtn: 'dis',
            circle: false,
            stopDrop: '.select-box',
            listOfSlides: '.gallery-list > li'
        });
    })
    
    jQuery('div.gallery-bar').gallery({
        duration: 500,
        listOfSlides: 'li',
        disableBtn: 'dis',
        circle: false
    });
    jQuery('.image-gallery').gallery({
        duration: 500,
        disableBtn: 'dis',
        circle: false,
        listOfSlides: 'li',
        overlay: 4
    });
    initDrop();
    initCustomForms();
    initSelectBox();

    initNews();
    initAddShortList();
    jQuery('.lightbox-opener').simplebox();
    initIframeHeight(jQuery('.lightbox-wrapper'));
    initEmailOpenClose();
    window.closeLightbox = function() {
        jQuery('.lightbox .close').trigger('click');
    }
    initPrint();
    initSpecific();
    initLightboxWidth();
    initRemoveItem();
    initNavPopup();
    jQuery('.scrollable').jScrollPane({
        verticalDragMinHeight: 75,
        verticalDragMaxHeight: 75
    });
    initFind();
    initCarrersTabs();
});

function initBrowserDetect() {
    var u = navigator.userAgent.toLowerCase();
    var _html = document.getElementsByTagName("html")[0];

    if (is("win")) addClass("win");
    else if (is("mac")) addClass("mac");
    else if (is("linux") || is("x11")) addClass("linux");

    if (is("msie 8.0")) addClass("ie8");
    else if (is("msie 7.0")) addClass("ie7");
    else if (is("msie 6.0")) addClass("ie6");
    else if (is("firefox/2")) addClass("ff2");
    else if (is("firefox/3")) addClass("ff3");
    else if (is("opera") && is("version/10")) addClass("opera10");
    else if (is("opera/9")) addClass("opera9");
    else if (is("safari") && is("version/3")) addClass("safari3");
    else if (is("safari") && is("version/4")) addClass("safari4");
    else if (is("safari") && is("version/5")) addClass("safari5");
    else if (is("chrome")) addClass("chrome");
    else if (is("safari")) addClass("safari2");
    else if (is("unknown")) addClass("unknown");

    if (is("msie")) addClass("trident");
    else if (is("applewebkit")) addClass("webkit");
    else if (is("gecko")) addClass("gecko");
    else if (is("opera")) addClass("presto");

    function is(browser) {
        if (u.indexOf(browser) != -1) return true;
    }
    function addClass(_class) {
        _html.className += (" " + _class);
    }
}

function initScrollTo() {
    var link = $('a.scroll-to');
    var _d = 300;
    link.click(function() {
        var _top = $($(this).attr('href')).length ? $($(this).attr('href')).offset().top : 0;
        $('body, html').animate({ scrollTop: _top }, { duration: _d })
        return false;
    });
}
function scrollPageToTop() {
    $('a.topscroll').click(function() {
        if ($.browser.safari) {
            $('body').animate({
                'scrollTop': 0
            }, 750)
        }
        else $('html').animate({
            'scrollTop': 0
        }, 750)
        return false;
    })
}

function initCarrersTabs() {
    var holder = $('.gallery-section');
    holder.each(function() {
        var _this = $(this);
        var btnPrev = _this.find('.btn-prev');
        var btnNext = _this.find('.btn-next');
        var tabset = _this.find('.tabset-bar');
        var tabsetEls = tabset.find('a.tab');
        var tabsetLenght = tabsetEls.length;
        btnPrev.click(function() {
            tabsetEls.eq(0).trigger('click');
            return false;
        });
        btnNext.click(function() {
            tabsetEls.eq(tabsetLenght - 1).trigger('click');
            return false;
        });
    });
}
function initFind() {
    var holder = jQuery('.find-block');
    holder.each(function() {
        var opener = $(this).find('a.more');
        var slider = $(this).find('.results-holder');
        var sliderHeight = slider.outerHeight();
        slider.css({
            position: 'relative',
            left: 0,
            height: 0
        });
        opener.click(function() {
            if (!$(this).hasClass('opened')) {
                $(this).addClass('opened');
                slider.animate({
                    height: sliderHeight
                }, {
                    queue: false,
                    duration: 1000
                })
            }
            return false;
        });
    });
}
function initNavPopup() {
    var nav = $('.top-nav');
    var _class = 'hover';
    var t;
    nav.each(function() {
        var li = $(this).find('li:has(.popup)');
        li.each(function() {
            var _this = $(this);
            var popup = _this.find('.popup,.arrow');
            if (!($.browser.msie && $.browser.version == '6.0')) popup.css({ opacity: 0 });
            _this.mouseenter(function() {
                if (!$(this).hasClass(_class)) $(this).addClass(_class);
                if (!($.browser.msie && $.browser.version == '6.0')) {
                    t = setTimeout(function() {
                        popup.animate({
                            opacity: 1
                        }, {
                            quequ: false,
                            duration: 500
                        });
                    }, 500);
                }
            }).mouseleave(function() {
                if ($(this).hasClass(_class)) $(this).removeClass(_class);
                if (!($.browser.msie && $.browser.version == '6.0')) {
                    if (t) clearTimeout(t);
                    popup.stop().css({ opacity: 0 });
                }
            });
        });
    });
}
function initRemoveItem() {
    var holder = $('.product-holder');
    var _duration = 1000;
    holder.each(function() {
        var _this = $(this);
        var btnRemove = _this.find('.btn-remove');
        btnRemove.click(function() {
            _this.animate({
                opacity: 0,
                width: 0
            }, {
                queue: false,
                duration: _duration,
                complete: function() {
                    $(this).remove();
                }
            });
            return false;
        });
    });
}
function initSelectBox() {
    var holder = $('.select-box');
    var activeClass = 'select-box-active';
    var outClass = 'out-select-box';
    holder.each(function() {
        var _this = $(this);
        var drop = _this.find('.select-section');
        var opener = _this.find('.btn-select');
        var closer = drop.find('a');
        var input = _this.find('input[type=hidden]');
        var clone;
        if (_this.hasClass(outClass)) {
            clone = drop.clone();
            clone.addClass('select-out-section');
            $('body').append(clone);
            closer = clone.find('a');
        }
        opener.click(function() {
            OpenClose();
            return false;
        });
        closer.click(function() {
            input.val($(this).text());
            OpenClose();
			return drop.hasClass("training");
        });
        function OpenClose() {
            if (_this.hasClass(activeClass)) {
                if (_this.hasClass(outClass)) {
                    clone.css({
                        left: -9999,
                        top: -9999
                    });
                }
                _this.removeClass(activeClass);
            }
            else {
                $('.select-out-section').css({
                    left: -9999,
                    top: -9999
                });
                if (_this.hasClass(outClass)) {
                    clone.css({
                        left: _this.offset().left + 1,
                        top: _this.offset().top + _this.outerHeight() - 1
                    });
                }
                holder.removeClass(activeClass);
                _this.addClass(activeClass);
            }
        }
    });
}
function initBreadcrumbs() {
    var holder = $('.breadcrumbs');
    var activeClass = 'drop-active';
    var maxHeight = 290;
    holder.each(function() {
        var li = $(this).find('li:has(.drop-box)');
        li.each(function() {
            var _this = $(this);
            var drop = _this.find('.drop-box');
            var scroll = drop.find('.scrollable');
            var opener = _this.find('.btn-breadcrumbs');
            if (scroll.outerHeight() > maxHeight) scroll.css('height', maxHeight);
            opener.click(function() {
                if (_this.hasClass(activeClass)) _this.removeClass(activeClass);
                else {
                    li.removeClass(activeClass);
                    _this.addClass(activeClass);
                }
                return false;
            });
            $(document).bind('mousedown', function(e) {
                if (drop && _this.hasClass(activeClass)) {
                    e = e || event;
                    var t = e.target || e.srcElement;
                    t = $(t);

                    if (t.parents('.drop-active').length == 0) {
                        _this.removeClass(activeClass)
                    } 
                }
            });
        });
    });
}
function initLightboxWidth() {
    var holder = $('.lightbox ');
    holder.each(function() {
        $(this).css({
            width: $(this).outerWidth()
        });
    });
}
function initSpecific() {
    var holder = $('.specific-box');
    var activeClass = 'active';
    var _duration = 500;
    holder.each(function() {
        var _this = $(this);
        var opener = _this.find('.btn-open-close');
        var slide = _this.find('.info');
        var slideHeight = slide.outerHeight();
        var slideMaxHeight = slide.find('dl').outerHeight();
        opener.click(function() {
            if (!$(this).hasClass('disable')) {
                if (_this.hasClass(activeClass)) {
                    slide.animate({
                        height: slideHeight
                    }, {
                        queue: false,
                        duration: _duration
                    });
                    _this.removeClass(activeClass);
                } else {
                    slide.animate({
                        height: slideMaxHeight
                    }, {
                        queue: false,
                        duration: _duration
                    });
                    _this.addClass(activeClass);
                }
            }
            return false;
        });
    });
}
function initPrint() {
    var btn = jQuery('.print');
    btn.click(function() {
        window.print();
        return false;
    });
}
function initEmailOpenClose() {
    var holder = jQuery('.lightbox-wrapper');
    holder.each(function() {
        var _holder = jQuery(this);
        var opener = _holder.find('.mail-opener');
        var sendtofriendchk = holder.find('#sendtofriendchk input');
        var btn = _holder.find('');
        var btnAnother = _holder.find('');
        var slide = _holder.find('.mail-slide');
        var _box = _holder.find('.box-container');
        var _success = _holder.find('.success-area');
        var _close = _holder.find('.btn-close');
        _close.click(function() {
            window.parent.closeLightbox();
            return false;
        });
        opener.click(function() {
            slide.show();
            initIframeHeight(_holder);
            slide.hide().slideDown(500);
            jQuery(this).hide();
            return false;
        });
        btn.click(function() {
            _box.hide();
            _success.show();
            initIframeHeight(_holder);
            return false;
        });
        btnAnother.click(function() {
            _box.show();
            _success.hide();
            initIframeHeight(_holder);
            return false;
        });
    });
}
function initIframeHeight(_holder) {
    var holder = _holder;
    holder.each(function() {
        var _height = jQuery(this).outerHeight();
        var _id = jQuery(this).parents('body').attr('id');
        if (_id) {
            var _iframe = window.parent.document.getElementById(_id);
            if (_iframe) //_iframe.style.height = _height + 'px';
                $(_iframe).animate({
                    height: _height
                }, {
                    queue: false,
                    duration: 500
                });
        }
    });
}
function initAddShortList() {
    jQuery('div.table-shortlist').each(function() {
        var set = jQuery(this);
        var btn = set.find('a.add-to-shortlist', set);
        var ind;
        var numBar = jQuery('#numbers');
        btn.bind('click', function() {
            if (!$(this).hasClass('added-view')) {
                var _href = jQuery(this).attr('href');
                numBar.empty().load(_href);
                jQuery(this).text('ADDED - VIEW LIST').addClass('added-view').attr('href', '#');
            }
            return false;
        })
    })
}
function initTabs() {
    var _tabset = jQuery('.tabset,.tabset-parent, .video-tabset');

    _tabset.each(function() {
        var _tabsetEl = jQuery(this).find('a.tab');
        hideTabs();
        _tabsetEl.each(function() {
            if (jQuery(this).parent().hasClass('active')) jQuery(jQuery(this).attr('href')).removeClass('tab-hide');
        });
        _tabsetEl.click(function() {
            if (!jQuery(this).parent().hasClass('active')) {
                _tabsetEl.parent().removeClass('active');
                jQuery(this).parent().addClass('active');
                hideTabs();
                jQuery(jQuery(this).attr('href')).removeClass('tab-hide');
            }
            else {
                $('#t2 a.tab:eq(0)').click();
            }
            return false;
        });
        function hideTabs() {
            _tabsetEl.each(function() {
                jQuery(jQuery(this).attr('href')).addClass('tab-hide');
            });
        }
    });
}
function clearForms() {
    var input = jQuery('input,textarea').not('[type="submit"]');
    input.focus(function() {
        var field = jQuery(this);
        var value = jQuery(this).val();
        var title = jQuery(this).attr('title');
        if (value == title) field.val('');
    });
    input.blur(function() {
        var field = jQuery(this);
        var value = jQuery(this).val();
        if (value != '') {
            return false;
        } else {
            field.val(field.attr('title'));
        }
    });
}
function initNews() {
    var gallery = jQuery('.news-gallery');
    var activeClass = 'active';
    gallery.each(function() {
        var links = jQuery(this).find('.news-list>li');
        var activeLink = links.filter('.' + activeClass);
        var images = jQuery(this).find('.img-list>li');
        if (activeLink.length) images.removeClass(activeClass).eq(links.index(activeLink)).addClass(activeClass);
        links.mouseenter(function() {
            links.filter('.' + activeClass).removeClass(activeClass);
            images.removeClass(activeClass).eq(links.index(jQuery(this))).addClass(activeClass);
            jQuery(this).addClass(activeClass);
        });
    });
}
/*ie hover*/
function initIE() {
    if (jQuery.browser.msie && jQuery.browser.version == '6.0') {
        var el = jQuery('.btn-search input, .btn-find input, .btn-subscribe input, .btn-arrow input, .btn-submit input, .btn-find-sm input, .btn-send-phone input, .btn-go input, .btn-email-product input, .btn-email-shortlist2 input, .btn-submit-enquiry input, .top-nav li');
        var className = 'hover';
        el.each(function() {
            jQuery(this).mouseenter(function() {
                if (!jQuery(this).hasClass(className)) jQuery(this).addClass(className);
            }).mouseleave(function() {
                if (jQuery(this).hasClass(className)) jQuery(this).removeClass(className);
            });
        });
    }
}
/*main dropdown*/
function initDrop() {
    var opener = jQuery('.drop-opener');
    var drops = jQuery('.drop-bar');
    var els = drops.find('li');
    var actveClass = 'opened';
    var flag = true;
    var slideDuration = 500;
    els.mouseenter(function() {
        els.removeClass('hover');
        $(this).addClass('hover');
    });
    opener.each(function() {
        var _drop = jQuery(jQuery(this).attr('rel')).css({
            position: 'absolute',
            left: '-9999px'
        });
        var _dropHeight = _drop.outerHeight();
        _drop.css({
            height: 0,
            position: 'relative',
            left: 'auto'
        });
        jQuery(this).click(function() {
            var _parent = jQuery(this).parent();
            if (_parent.hasClass(actveClass)) {
                if (flag) {
                    flag = false;
                    _drop.animate({
                        height: 0
                    }, {
                        duration: slideDuration,
                        queue: false,
                        complete: function() {
                            jQuery(this).removeClass(actveClass);
                            _parent.removeClass(actveClass);
                            flag = true;
                        }
                    });
                }
            } else {
                if (drops.filter('.' + actveClass).length && flag) {
                    flag = false;
                    drops.animate({
                        height: 0
                    }, {
                        duration: slideDuration,
                        queue: false,
                        complete: function() {
                            opener.parent().removeClass(actveClass);
                            _parent.addClass(actveClass);
                            _drop.animate({
                                height: _dropHeight
                            }, {
                                duration: slideDuration,
                                queue: false,
                                complete: function() {
                                    flag = true;
                                }
                            }).addClass(actveClass);
                        }
                    });
                } else {
                    if (flag) {
                        flag = false;
                        _parent.addClass(actveClass);
                        _drop.animate({
                            height: _dropHeight
                        }, {
                            duration: slideDuration,
                            queue: false,
                            complete: function() {
                                flag = true;
                            }
                        }).addClass(actveClass);
                    }
                }
            }
            return false;
        });
    });

}
/*gallery*/
(function($) {
    $.fn.gallery = function(options) { return new Gallery(this.get(0), options); };

    function Gallery(context, options) { this.init(context, options); };

    Gallery.prototype = {
        options: {},
        init: function(context, options) {
            this.options = $.extend({
                duration: 700,
                slideElement: 1,
                autoRotation: false,
                effect: false,
                listOfSlides: 'ul > li',
                switcher: false,
                stopDrop: false,
                disableBtn: false,
                diff: false,
                overlay: false,
                nextBtn: 'a.link-next, a.btn-next, a.next',
                prevBtn: 'a.link-prev, a.btn-prev, a.prev',
                circle: true,
                direction: false,
                event: 'click',
                IE: false
            }, options || {});
            var _el = $(context).find(this.options.listOfSlides);
            if (this.options.effect) this.list = _el;
            else this.list = _el.parent();
            this.elements = $(context).find(this.options.listOfSlides);
            this.switcher = $(context).find(this.options.switcher);
            this.nextBtn = $(context).find(this.options.nextBtn);
            this.prevBtn = $(context).find(this.options.prevBtn);
            this.count = _el.index(_el.filter(':last'));
            this.overlay = parseInt(this.options.overlay);

            if (this.options.switcher) this.active = this.switcher.index(this.switcher.filter('.active:eq(0)'));
            else this.active = _el.index(_el.filter('.active:eq(0)'));
            if (this.active < 0) this.active = 0;
            this.last = this.active;

            if (this.options.stopDrop) {
                this.stopDrop = $(context).find(this.options.stopDrop);
            }

            this.woh = _el.outerWidth(true);
            if (!this.options.direction) this.installDirections(this.list.parent().width());
            else {
                this.woh = _el.outerHeight(true);
                this.installDirections(this.list.parent().height());
            }

            if (!this.options.effect) {
                this.rew = this.count - this.wrapHolderW + 1;
                if (!this.options.direction) this.list.css({ marginLeft: -(this.woh * this.active) });
                else this.list.css({ marginTop: -(this.woh * this.active) });
            }
            else {
                this.rew = this.count;
                this.list.css({ opacity: 0 }).removeClass('active').eq(this.active).addClass('active').css({ opacity: 1 }).css('opacity', 'auto');
                this.switcher.removeClass('active').eq(this.active).addClass('active');
            }

            if (this.options.disableBtn) {
                if (this.count < this.wrapHolderW) this.nextBtn.addClass(this.options.disableBtn);
                if (this.active == 0) this.prevBtn.addClass(this.options.disableBtn);
            }

            this.initEvent(this, this.nextBtn, this.prevBtn, true);
            this.initEvent(this, this.prevBtn, this.nextBtn, false);

            if (this.options.autoRotation) this.runTimer(this);

            if (this.options.switcher) this.initEventSwitcher(this, this.switcher);
            if (this.options.diff) this.list.css({ position: 'relative' });

            if (this.options.overlay) this.initOverlay(this);
        },
        installDirections: function(temp) {
            this.wrapHolderW = Math.ceil(temp / this.woh);
            if (((this.wrapHolderW - 1) * this.woh + this.woh / 2) > temp) this.wrapHolderWwrapHolderW--;
        },
        fadeElement: function() {
            if ($.browser.msie && this.options.IE) {
                this.list.eq(this.last).css({ opacity: 0 });
                this.list.removeClass('active').eq(this.active).addClass('active').css({ opacity: 'auto' });
            }
            else {
                this.list.eq(this.last).animate({ opacity: 0 }, { queue: false, duration: this.options.duration });
                this.list.removeClass('active').eq(this.active).addClass('active').animate({
                    opacity: 1
                }, { queue: false, duration: this.options.duration, complete: function() {
                    $(this).css('opacity', 'auto');
                } 
                });
            }
            if (this.options.switcher) this.switcher.removeClass('active').eq(this.active).addClass('active');
            this.last = this.active;
        },
        scrollElement: function() {
            if (!this.options.direction) {
                if (this.options.diff && this.elements.eq(this.active).length) this.list.animate({ marginLeft: -(this.elements.eq(this.active).position().left) }, { queue: false, duration: this.options.duration });
                else this.list.animate({ marginLeft: -(this.woh * this.active) }, { queue: false, duration: this.options.duration });
            }
            else this.list.animate({ marginTop: -(this.woh * this.active) }, { queue: false, duration: this.options.duration });
            if (this.options.switcher) this.switcher.removeClass('active').eq(this.active).addClass('active');
        },
        runTimer: function($this) {
            if ($this._t) clearTimeout($this._t);
            $this._t = setInterval(function() {
                $this.toPrepare($this, true);
            }, this.options.autoRotation);
        },
        initEventSwitcher: function($this, el) {
            el.bind($this.options.event, function() {
                $this.active = $this.switcher.index($(this));
                if ($this._t) clearTimeout($this._t);
                if (!$this.options.effect) $this.scrollElement();
                else $this.fadeElement();
                if ($this.options.autoRotation) $this.runTimer($this);
                return false;
            });
        },
        initEvent: function($this, addEventEl, addDisClass, dir) {
            addEventEl.bind($this.options.event, function() {
                if ($this._t) clearTimeout($this._t);
                if ($this.options.disableBtn && ($this.count > $this.wrapHolderW)) addDisClass.removeClass($this.options.disableBtn);
                $this.toPrepare($this, dir);
                if ($this.options.autoRotation) $this.runTimer($this);
                return false;
            });
        },
        initOverlay: function($this) {
            if (this.options.overlay) {
                this.elements.not(this.elements.eq(this.active)).not(this.elements.eq(this.active + this.overlay)).animate({
                    paddingRight: 20,
                    marginRight: 0,
                    marginLeft: 0
                }, { queue: false, duration: this.options.duration });
                this.elements.eq(this.active).animate({
                    paddingRight: 0,
                    marginRight: 20,
                    marginLeft: 20
                }, { queue: false, duration: this.options.duration });
                this.elements.eq(this.active + this.overlay).animate({
                    marginLeft: -40
                }, { queue: false, duration: this.options.duration });
            }
        },
        toPrepare: function($this, side) {
            if (($this.active == $this.rew) && $this.options.circle && side) $this.active = -$this.options.slideElement;
            if (($this.active == 0) && $this.options.circle && !side) $this.active = $this.rew + $this.options.slideElement;
            for (var i = 0; i < $this.options.slideElement; i++) {
                if (side) {
                    if ($this.active + 1 > $this.rew) {
                        if ($this.options.disableBtn && ($this.count > $this.wrapHolderW)) $this.nextBtn.addClass($this.options.disableBtn);
                    }
                    else $this.active++;
                }
                else {
                    if ($this.active - 1 < 0) {
                        if ($this.options.disableBtn && ($this.count > $this.wrapHolderW)) $this.prevBtn.addClass($this.options.disableBtn);
                    }
                    else $this.active--;
                }
            };
            if ($this.active == $this.rew && side) if ($this.options.disableBtn && ($this.count > $this.wrapHolderW)) $this.nextBtn.addClass($this.options.disableBtn);
            if ($this.active == 0 && !side) if ($this.options.disableBtn && ($this.count > $this.wrapHolderW)) $this.prevBtn.addClass($this.options.disableBtn);
            if ($this.options.overlay) $this.initOverlay($this);
            if ($this.options.stopDrop) {
                if ($this.stopDrop.hasClass('select-box-active')) {

                } else {
                    if (!$this.options.effect) $this.scrollElement();
                    else $this.fadeElement();
                }
            } else {
                if (!$this.options.effect) $this.scrollElement();
                else $this.fadeElement();
            }
        },
        stop: function() {
            if (this._t) clearTimeout(this._t);
        },
        play: function() {
            if (this._t) clearTimeout(this._t);
            if (this.options.autoRotation) this.runTimer(this);
        }
    }
} (jQuery));
/*custom forms*/
// page init
function initCustomForms() {
    $('select').customSelect();
    $('input:radio').customRadio();
    $('input:checkbox').customCheckbox();
}

// custom selects module
jQuery.fn.customSelect = function(_options) {
    var _options = jQuery.extend({
        selectStructure: '<div class="selectArea"><span class="left"></span><span class="center"></span><a href="#" class="selectButton"></a><div class="disabled"></div></div>',
        hideOnMouseOut: false,
        copyClass: true,
        selectText: '.center',
        selectBtn: '.selectButton',
        selectDisabled: '.disabled',
        optStructure: '<div class="optionsDivVisible"><div class="select-center"><ul></ul></div><div class="select-bottom"></div></div>',
        optList: 'ul'
    }, _options);
    return this.each(function() {
        var select = jQuery(this);
        if (!select.hasClass('outtaHere')) {
            if (select.is(':visible')) {
                var hideOnMouseOut = _options.hideOnMouseOut;
                var copyClass = _options.copyClass;
                var replaced = jQuery(_options.selectStructure);
                var selectText = replaced.find(_options.selectText);
                var selectBtn = replaced.find(_options.selectBtn);
                var clickClass = 'activeArea';
                var selectDisabled = replaced.find(_options.selectDisabled).hide();
                var optHolder = jQuery(_options.optStructure);
                var optList = optHolder.find(_options.optList);
                if (copyClass) {
                    optHolder.addClass('drop-' + select.attr('class'));
                    replaced.addClass(select.attr('class'));
                }

                if (select.attr('disabled')) selectDisabled.show();
                select.find('option').each(function() {
                    var selOpt = $(this);
                    var _opt = jQuery('<li><a href="#">' + selOpt.html() + '</a></li>');
                    if (selOpt.attr('selected')) {
                        selectText.html(selOpt.html());
                        _opt.addClass('selected');
                    }
                    _opt.children('a').click(function() {
                        optList.find('li').removeClass('selected');
                        select.find('option').removeAttr('selected');
                        $(this).parent().addClass('selected');
                        selOpt.attr('selected', 'selected');
                        selectText.html(selOpt.html());
                        select.change();
                        optHolder.hide();
                        replaced.removeClass(clickClass);
                        return false;
                    });
                    optList.append(_opt);
                });
                replaced.width(select.outerWidth());
                replaced.insertBefore(select);
                optHolder.css({
                    width: select.outerWidth(),
                    position: 'absolute'
                });
                jQuery(document.body).append(optHolder);

                optHolder.find('.select-center').jScrollPane({
                    verticalDragMinHeight: 75,
                    verticalDragMaxHeight: 75
                });
                optHolder.css({
                    display: 'none'
                });

                var optTimer;
                replaced.hover(function() {
                    if (optTimer) clearTimeout(optTimer);
                }, function() {
                    if (hideOnMouseOut) {
                        optTimer = setTimeout(function() {
                            optHolder.hide();
                            replaced.removeClass(clickClass);
                        }, 200);
                    }
                });
                optHolder.hover(function() {
                    if (optTimer) clearTimeout(optTimer);
                }, function() {
                    if (hideOnMouseOut) {
                        optTimer = setTimeout(function() {
                            optHolder.hide();
                            replaced.removeClass(clickClass);
                        }, 200);
                    }
                });
                selectBtn.click(function() {
                    if (optHolder.is(':visible')) {
                        optHolder.hide();
                        replaced.removeClass(clickClass);
                    }
                    else {
                        replaced.addClass(clickClass);
                        optHolder.children('ul').css({ height: 'auto', overflow: 'hidden' });
                        optHolder.css({
                            top: replaced.offset().top + replaced.outerHeight(),
                            left: replaced.offset().left,
                            display: 'block'
                        });
                        if (optHolder.children('ul').height() > 200) optHolder.children('ul').css({ height: 200, overflow: 'auto' });
                    }
                    return false;
                });

                $(document).bind('click', function(e) {
                    if (optHolder && optHolder.is(':visible')) {
                        e = e || event;
                        var t = e.target || e.srcElement;
                        t = $(t);
                        if (t.parents('div.optionsDivVisible').length == 0) {
                            $('.activeArea').find('.selectButton').trigger('click');
                        } 
                    }
                });

                $(window).resize(function() {
                    optHolder.css({
                        top: replaced.offset().top + replaced.outerHeight(),
                        left: replaced.offset().left
                    });
                })
                select.addClass('outtaHere');
            }
        }
    });
}

// custom radios module
jQuery.fn.customRadio = function(_options) {
    var _options = jQuery.extend({
        radioStructure: '<div></div>',
        radioDisabled: 'disabled',
        radioDefault: 'radioArea',
        radioChecked: 'radioAreaChecked'
    }, _options);
    return this.each(function() {
        var radio = jQuery(this);
        if (!radio.hasClass('outtaHere') && radio.is(':radio')) {
            var replaced = jQuery(_options.radioStructure);
            this._replaced = replaced;
            if (radio.is(':disabled')) replaced.addClass(_options.radioDisabled);
            else if (radio.is(':checked')) replaced.addClass(_options.radioChecked);
            else replaced.addClass(_options.radioDefault);
            replaced.click(function() {
                if ($(this).hasClass(_options.radioDefault)) {
                    radio.attr('checked', 'checked');
                    changeRadio(radio.get(0));
                }
            });
            radio.click(function() {
                changeRadio(this);
            });
            replaced.insertBefore(radio);
            radio.addClass('outtaHere');
        }
    });
    function changeRadio(_this) {
        $(_this).change();
        $('input:radio[name=' + $(_this).attr("name") + ']').not(_this).each(function() {
            if (this._replaced && !$(this).is(':disabled')) this._replaced.removeClass().addClass(_options.radioDefault);
        });
        _this._replaced.removeClass().addClass(_options.radioChecked);
    }
}

// custom checkboxes module
jQuery.fn.customCheckbox = function(_options) {
    var _options = jQuery.extend({
        checkboxStructure: '<div></div>',
        checkboxDisabled: 'disabled',
        checkboxDefault: 'checkboxArea',
        checkboxChecked: 'checkboxAreaChecked'
    }, _options);
    return this.each(function() {
        var checkbox = jQuery(this);
        if (!checkbox.hasClass('outtaHere') && checkbox.is(':checkbox')) {
            var replaced = jQuery(_options.checkboxStructure);
            this._replaced = replaced;
            if (checkbox.is(':disabled')) replaced.addClass(_options.checkboxDisabled);
            else if (checkbox.is(':checked')) replaced.addClass(_options.checkboxChecked);
            else replaced.addClass(_options.checkboxDefault);

            replaced.click(function() {
                if (checkbox.is(':checked')) checkbox.removeAttr('checked');
                else checkbox.attr('checked', 'checked');
                changeCheckbox(checkbox);
            });
            checkbox.click(function() {
                changeCheckbox(checkbox);
            });
            replaced.insertBefore(checkbox);
            checkbox.addClass('outtaHere');
        }
    });
    function changeCheckbox(_this) {
        _this.change();
        if (_this.is(':checked')) _this.get(0)._replaced.removeClass().addClass(_options.checkboxChecked);
        else _this.get(0)._replaced.removeClass().addClass(_options.checkboxDefault);
    }
}

/*png fix*/
if (jQuery.browser.msie && jQuery.browser.version == '6.0') {
    var DD_belatedPNG = { ns: "DD_belatedPNG", imgSize: {}, delay: 10, nodesFixed: 0, createVmlNameSpace: function() { if (document.namespaces && !document.namespaces[this.ns]) { document.namespaces.add(this.ns, "urn:schemas-microsoft-com:vml") } }, createVmlStyleSheet: function() { var b, a; b = document.createElement("style"); b.setAttribute("media", "screen"); document.documentElement.firstChild.insertBefore(b, document.documentElement.firstChild.firstChild); if (b.styleSheet) { b = b.styleSheet; b.addRule(this.ns + "\\:*", "{behavior:url(#default#VML)}"); b.addRule(this.ns + "\\:shape", "position:absolute;"); b.addRule("img." + this.ns + "_sizeFinder", "behavior:none; border:none; position:absolute; z-index:-1; top:-10000px; visibility:hidden;"); this.screenStyleSheet = b; a = document.createElement("style"); a.setAttribute("media", "print"); document.documentElement.firstChild.insertBefore(a, document.documentElement.firstChild.firstChild); a = a.styleSheet; a.addRule(this.ns + "\\:*", "{display: none !important;}"); a.addRule("img." + this.ns + "_sizeFinder", "{display: none !important;}") } }, readPropertyChange: function() { var b, c, a; b = event.srcElement; if (!b.vmlInitiated) { return } if (event.propertyName.search("background") != -1 || event.propertyName.search("border") != -1) { DD_belatedPNG.applyVML(b) } if (event.propertyName == "style.display") { c = (b.currentStyle.display == "none") ? "none" : "block"; for (a in b.vml) { if (b.vml.hasOwnProperty(a)) { b.vml[a].shape.style.display = c } } } if (event.propertyName.search("filter") != -1) { DD_belatedPNG.vmlOpacity(b) } }, vmlOpacity: function(b) { if (b.currentStyle.filter.search("lpha") != -1) { var a = b.currentStyle.filter; a = parseInt(a.substring(a.lastIndexOf("=") + 1, a.lastIndexOf(")")), 10) / 100; b.vml.color.shape.style.filter = b.currentStyle.filter; b.vml.image.fill.opacity = a } }, handlePseudoHover: function(a) { setTimeout(function() { DD_belatedPNG.applyVML(a) }, 1) }, fix: function(a) { if (this.screenStyleSheet) { var c, b; c = a.split(","); for (b = 0; b < c.length; b++) { this.screenStyleSheet.addRule(c[b], "behavior:expression(DD_belatedPNG.fixPng(this))") } } }, applyVML: function(a) { a.runtimeStyle.cssText = ""; this.vmlFill(a); this.vmlOffsets(a); this.vmlOpacity(a); if (a.isImg) { this.copyImageBorders(a) } }, attachHandlers: function(i) { var d, c, g, e, b, f; d = this; c = { resize: "vmlOffsets", move: "vmlOffsets" }; if (i.nodeName == "A") { e = { mouseleave: "handlePseudoHover", mouseenter: "handlePseudoHover", focus: "handlePseudoHover", blur: "handlePseudoHover" }; for (b in e) { if (e.hasOwnProperty(b)) { c[b] = e[b] } } } for (f in c) { if (c.hasOwnProperty(f)) { g = function() { d[c[f]](i) }; i.attachEvent("on" + f, g) } } i.attachEvent("onpropertychange", this.readPropertyChange) }, giveLayout: function(a) { a.style.zoom = 1; if (a.currentStyle.position == "static") { a.style.position = "relative" } }, copyImageBorders: function(b) { var c, a; c = { borderStyle: true, borderWidth: true, borderColor: true }; for (a in c) { if (c.hasOwnProperty(a)) { b.vml.color.shape.style[a] = b.currentStyle[a] } } }, vmlFill: function(e) { if (!e.currentStyle) { return } else { var d, f, g, b, a, c; d = e.currentStyle } for (b in e.vml) { if (e.vml.hasOwnProperty(b)) { e.vml[b].shape.style.zIndex = d.zIndex } } e.runtimeStyle.backgroundColor = ""; e.runtimeStyle.backgroundImage = ""; f = true; if (d.backgroundImage != "none" || e.isImg) { if (!e.isImg) { e.vmlBg = d.backgroundImage; e.vmlBg = e.vmlBg.substr(5, e.vmlBg.lastIndexOf('")') - 5) } else { e.vmlBg = e.src } g = this; if (!g.imgSize[e.vmlBg]) { a = document.createElement("img"); g.imgSize[e.vmlBg] = a; a.className = g.ns + "_sizeFinder"; a.runtimeStyle.cssText = "behavior:none; position:absolute; left:-10000px; top:-10000px; border:none; margin:0; padding:0;"; c = function() { this.width = this.offsetWidth; this.height = this.offsetHeight; g.vmlOffsets(e) }; a.attachEvent("onload", c); a.src = e.vmlBg; a.removeAttribute("width"); a.removeAttribute("height"); document.body.insertBefore(a, document.body.firstChild) } e.vml.image.fill.src = e.vmlBg; f = false } e.vml.image.fill.on = !f; e.vml.image.fill.color = "none"; e.vml.color.shape.style.backgroundColor = d.backgroundColor; e.runtimeStyle.backgroundImage = "none"; e.runtimeStyle.backgroundColor = "transparent" }, vmlOffsets: function(d) { var h, n, a, e, g, m, f, l, j, i, k; h = d.currentStyle; n = { W: d.clientWidth + 1, H: d.clientHeight + 1, w: this.imgSize[d.vmlBg].width, h: this.imgSize[d.vmlBg].height, L: d.offsetLeft, T: d.offsetTop, bLW: d.clientLeft, bTW: d.clientTop }; a = (n.L + n.bLW == 1) ? 1 : 0; e = function(b, p, q, c, s, u) { b.coordsize = c + "," + s; b.coordorigin = u + "," + u; b.path = "m0,0l" + c + ",0l" + c + "," + s + "l0," + s + " xe"; b.style.width = c + "px"; b.style.height = s + "px"; b.style.left = p + "px"; b.style.top = q + "px" }; e(d.vml.color.shape, (n.L + (d.isImg ? 0 : n.bLW)), (n.T + (d.isImg ? 0 : n.bTW)), (n.W - 1), (n.H - 1), 0); e(d.vml.image.shape, (n.L + n.bLW), (n.T + n.bTW), (n.W), (n.H), 1); g = { X: 0, Y: 0 }; if (d.isImg) { g.X = parseInt(h.paddingLeft, 10) + 1; g.Y = parseInt(h.paddingTop, 10) + 1 } else { for (j in g) { if (g.hasOwnProperty(j)) { this.figurePercentage(g, n, j, h["backgroundPosition" + j]) } } } d.vml.image.fill.position = (g.X / n.W) + "," + (g.Y / n.H); m = h.backgroundRepeat; f = { T: 1, R: n.W + a, B: n.H, L: 1 + a }; l = { X: { b1: "L", b2: "R", d: "W" }, Y: { b1: "T", b2: "B", d: "H"} }; if (m != "repeat" || d.isImg) { i = { T: (g.Y), R: (g.X + n.w), B: (g.Y + n.h), L: (g.X) }; if (m.search("repeat-") != -1) { k = m.split("repeat-")[1].toUpperCase(); i[l[k].b1] = 1; i[l[k].b2] = n[l[k].d] } if (i.B > n.H) { i.B = n.H } d.vml.image.shape.style.clip = "rect(" + i.T + "px " + (i.R + a) + "px " + i.B + "px " + (i.L + a) + "px)" } else { d.vml.image.shape.style.clip = "rect(" + f.T + "px " + f.R + "px " + f.B + "px " + f.L + "px)" } }, figurePercentage: function(d, c, f, a) { var b, e; e = true; b = (f == "X"); switch (a) { case "left": case "top": d[f] = 0; break; case "center": d[f] = 0.5; break; case "right": case "bottom": d[f] = 1; break; default: if (a.search("%") != -1) { d[f] = parseInt(a, 10) / 100 } else { e = false } } d[f] = Math.ceil(e ? ((c[b ? "W" : "H"] * d[f]) - (c[b ? "w" : "h"] * d[f])) : parseInt(a, 10)); if (d[f] % 2 === 0) { d[f]++ } return d[f] }, fixPng: function(c) { c.style.behavior = "none"; var g, b, f, a, d; if (c.nodeName == "BODY" || c.nodeName == "TD" || c.nodeName == "TR") { return } c.isImg = false; if (c.nodeName == "IMG") { if (c.src.toLowerCase().search(/\.png$/) != -1) { c.isImg = true; c.style.visibility = "hidden" } else { return } } else { if (c.currentStyle.backgroundImage.toLowerCase().search(".png") == -1) { return } } g = DD_belatedPNG; c.vml = { color: {}, image: {} }; b = { shape: {}, fill: {} }; for (a in c.vml) { if (c.vml.hasOwnProperty(a)) { for (d in b) { if (b.hasOwnProperty(d)) { f = g.ns + ":" + d; c.vml[a][d] = document.createElement(f) } } c.vml[a].shape.stroked = false; c.vml[a].shape.appendChild(c.vml[a].fill); c.parentNode.insertBefore(c.vml[a].shape, c) } } c.vml.image.shape.fillcolor = "none"; c.vml.image.fill.type = "tile"; c.vml.color.fill.on = false; g.attachHandlers(c); g.giveLayout(c); g.giveLayout(c.offsetParent); c.vmlInitiated = true; g.applyVML(c) } }; try { document.execCommand("BackgroundImageCache", false, true) } catch (r) { } DD_belatedPNG.createVmlNameSpace(); DD_belatedPNG.createVmlStyleSheet();
    DD_belatedPNG.fix('.slideshow-btns .btn-prev, .slideshow-btns .btn-next, .gallery05 .btn-next, .gallery05 .btn-prev, .listing a, .image-gallery .btn-next, .image-gallery .btn-prev, .about-area img ');
}
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.4
* 
* Requires: 1.2.2+
*/

(function($) {

    var types = ['DOMMouseScroll', 'mousewheel'];

    $.event.special.mousewheel = {
        setup: function() {
            if (this.addEventListener) {
                for (var i = types.length; i; ) {
                    this.addEventListener(types[--i], handler, false);
                }
            } else {
                this.onmousewheel = handler;
            }
        },

        teardown: function() {
            if (this.removeEventListener) {
                for (var i = types.length; i; ) {
                    this.removeEventListener(types[--i], handler, false);
                }
            } else {
                this.onmousewheel = null;
            }
        }
    };

    $.fn.extend({
        mousewheel: function(fn) {
            return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
        },

        unmousewheel: function(fn) {
            return this.unbind("mousewheel", fn);
        }
    });


    function handler(event) {
        var orgEvent = event || window.event, args = [].slice.call(arguments, 1), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
        event = $.event.fix(orgEvent);
        event.type = "mousewheel";

        // Old school scrollwheel delta
        if (event.wheelDelta) { delta = event.wheelDelta / 120; }
        if (event.detail) { delta = -event.detail / 3; }

        // New school multidimensional scroll (touchpads) deltas
        deltaY = delta;

        // Gecko
        if (orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS) {
            deltaY = 0;
            deltaX = -1 * delta;
        }

        // Webkit
        if (orgEvent.wheelDeltaY !== undefined) { deltaY = orgEvent.wheelDeltaY / 120; }
        if (orgEvent.wheelDeltaX !== undefined) { deltaX = -1 * orgEvent.wheelDeltaX / 120; }

        // Add event and delta to the front of the arguments
        args.unshift(event, delta, deltaX, deltaY);

        return $.event.handle.apply(this, args);
    }

})(jQuery);
/*
* jScrollPane - v2.0.0beta5 - 2010-10-18
* http://jscrollpane.kelvinluck.com/
*
* Copyright (c) 2010 Kelvin Luck
* Dual licensed under the MIT and GPL licenses.
*/
(function(b, a, c) {
    b.fn.jScrollPane = function(f) {
        function d(C, L) {
            var au, N = this, V, ah, v, aj, Q, W, y, q, av, aB, ap, i, H, h, j, X, R, al, U, t, A, am, ac, ak, F, l, ao, at, x, aq, aE, g, aA, ag = true, M = true, aD = false, k = false, Z = b.fn.mwheelIntent ? "mwheelIntent.jsp" : "mousewheel.jsp"; aE = C.css("paddingTop") + " " + C.css("paddingRight") + " " + C.css("paddingBottom") + " " + C.css("paddingLeft"); g = (parseInt(C.css("paddingLeft")) || 0) + (parseInt(C.css("paddingRight")) || 0); an(L); function an(aH) { var aL, aK, aJ, aG, aF, aI; au = aH; if (V == c) { C.css({ overflow: "hidden", padding: 0 }); ah = C.innerWidth() + g; v = C.innerHeight(); C.width(ah); V = b('<div class="jspPane" />').wrap(b('<div class="jspContainer" />').css({ width: ah + "px", height: v + "px" })); C.wrapInner(V.parent()); aj = C.find(">.jspContainer"); V = aj.find(">.jspPane"); V.css("padding", aE) } else { C.css("width", ""); aI = C.outerWidth() + g != ah || C.outerHeight() != v; if (aI) { ah = C.innerWidth() + g; v = C.innerHeight(); aj.css({ width: ah + "px", height: v + "px" }) } aA = V.innerWidth(); if (!aI && V.outerWidth() == Q && V.outerHeight() == W) { if (aB || av) { V.css("width", aA + "px"); C.css("width", (aA + g) + "px") } return } V.css("width", ""); C.css("width", (ah) + "px"); aj.find(">.jspVerticalBar,>.jspHorizontalBar").remove().end() } aL = V.clone().css("position", "absolute"); aK = b('<div style="width:1px; position: relative;" />').append(aL); b("body").append(aK); Q = Math.max(V.outerWidth(), aL.outerWidth()); aK.remove(); W = V.outerHeight(); y = Q / ah; q = W / v; av = q > 1; aB = y > 1; if (!(aB || av)) { C.removeClass("jspScrollable"); V.css({ top: 0, width: aj.width() - g }); n(); D(); O(); w(); af() } else { C.addClass("jspScrollable"); aJ = au.maintainPosition && (H || X); if (aJ) { aG = ay(); aF = aw() } aC(); z(); E(); if (aJ) { K(aG); J(aF) } I(); ad(); if (au.enableKeyboardNavigation) { P() } if (au.clickOnTrack) { p() } B(); if (au.hijackInternalLinks) { m() } } if (au.autoReinitialise && !aq) { aq = setInterval(function() { an(au) }, au.autoReinitialiseDelay) } else { if (!au.autoReinitialise && aq) { clearInterval(aq) } } C.trigger("jsp-initialised", [aB || av]) } function aC() { if (av) { aj.append(b('<div class="jspVerticalBar" />').append(b('<div class="jspCap jspCapTop" />'), b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragTop" />'), b('<div class="jspDragBottom" />'))), b('<div class="jspCap jspCapBottom" />'))); R = aj.find(">.jspVerticalBar"); al = R.find(">.jspTrack"); ap = al.find(">.jspDrag"); if (au.showArrows) { am = b('<a class="jspArrow jspArrowUp" />').bind("mousedown.jsp", az(0, -1)).bind("click.jsp", ax); ac = b('<a class="jspArrow jspArrowDown" />').bind("mousedown.jsp", az(0, 1)).bind("click.jsp", ax); if (au.arrowScrollOnHover) { am.bind("mouseover.jsp", az(0, -1, am)); ac.bind("mouseover.jsp", az(0, 1, ac)) } ai(al, au.verticalArrowPositions, am, ac) } t = v; aj.find(">.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow").each(function() { t -= b(this).outerHeight() }); ap.hover(function() { ap.addClass("jspHover") }, function() { ap.removeClass("jspHover") }).bind("mousedown.jsp", function(aF) { b("html").bind("dragstart.jsp selectstart.jsp", function() { return false }); ap.addClass("jspActive"); var s = aF.pageY - ap.position().top; b("html").bind("mousemove.jsp", function(aG) { S(aG.pageY - s, false) }).bind("mouseup.jsp mouseleave.jsp", ar); return false }); o() } } function o() { al.height(t + "px"); H = 0; U = au.verticalGutter + al.outerWidth(); V.width(ah - U - g); if (R.position().left == 0) { V.css("margin-left", U + "px") } } function z() {
                if (aB) {
                    aj.append(b('<div class="jspHorizontalBar" />').append(b('<div class="jspCap jspCapLeft" />'), b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragLeft" />'), b('<div class="jspDragRight" />'))), b('<div class="jspCap jspCapRight" />'))); ak = aj.find(">.jspHorizontalBar"); F = ak.find(">.jspTrack"); h = F.find(">.jspDrag"); if (au.showArrows) {
                        at = b('<a class="jspArrow jspArrowLeft" />').bind("mousedown.jsp", az(-1, 0)).bind("click.jsp", ax); x = b('<a class="jspArrow jspArrowRight" />').bind("mousedown.jsp", az(1, 0)).bind("click.jsp", ax); if (au.arrowScrollOnHover) {
                            at.bind("mouseover.jsp", az(-1, 0, at));
                            x.bind("mouseover.jsp", az(1, 0, x))
                        } ai(F, au.horizontalArrowPositions, at, x)
                    } h.hover(function() { h.addClass("jspHover") }, function() { h.removeClass("jspHover") }).bind("mousedown.jsp", function(aF) { b("html").bind("dragstart.jsp selectstart.jsp", function() { return false }); h.addClass("jspActive"); var s = aF.pageX - h.position().left; b("html").bind("mousemove.jsp", function(aG) { T(aG.pageX - s, false) }).bind("mouseup.jsp mouseleave.jsp", ar); return false }); l = aj.innerWidth(); ae()
                } else { } 
            } function ae() { aj.find(">.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow").each(function() { l -= b(this).outerWidth() }); F.width(l + "px"); X = 0 } function E() { if (aB && av) { var aF = F.outerHeight(), s = al.outerWidth(); t -= aF; b(ak).find(">.jspCap:visible,>.jspArrow").each(function() { l += b(this).outerWidth() }); l -= s; v -= s; ah -= aF; F.parent().append(b('<div class="jspCorner" />').css("width", aF + "px")); o(); ae() } if (aB) { V.width((aj.outerWidth() - g) + "px") } W = V.outerHeight(); q = W / v; if (aB) { ao = 1 / y * l; if (ao > au.horizontalDragMaxWidth) { ao = au.horizontalDragMaxWidth } else { if (ao < au.horizontalDragMinWidth) { ao = au.horizontalDragMinWidth } } h.width(ao + "px"); j = l - ao; ab(X) } if (av) { A = 1 / q * t; if (A > au.verticalDragMaxHeight) { A = au.verticalDragMaxHeight } else { if (A < au.verticalDragMinHeight) { A = au.verticalDragMinHeight } } ap.height(A + "px"); i = t - A; aa(H) } } function ai(aG, aI, aF, s) { var aK = "before", aH = "after", aJ; if (aI == "os") { aI = /Mac/.test(navigator.platform) ? "after" : "split" } if (aI == aK) { aH = aI } else { if (aI == aH) { aK = aI; aJ = aF; aF = s; s = aJ } } aG[aK](aF)[aH](s) } function az(aF, s, aG) { return function() { G(aF, s, this, aG); this.blur(); return false } } function G(aH, aF, aK, aJ) { aK = b(aK).addClass("jspActive"); var aI, s = function() { if (aH != 0) { T(X + aH * au.arrowButtonSpeed, false) } if (aF != 0) { S(H + aF * au.arrowButtonSpeed, false) } }, aG = setInterval(s, au.arrowRepeatFreq); s(); aI = aJ == c ? "mouseup.jsp" : "mouseout.jsp"; aJ = aJ || b("html"); aJ.bind(aI, function() { aK.removeClass("jspActive"); clearInterval(aG); aJ.unbind(aI) }) } function p() { w(); if (av) { al.bind("mousedown.jsp", function(aH) { if (aH.originalTarget == c || aH.originalTarget == aH.currentTarget) { var aG = b(this), s = setInterval(function() { var aI = aG.offset(), aJ = aH.pageY - aI.top; if (H + A < aJ) { S(H + au.trackClickSpeed) } else { if (aJ < H) { S(H - au.trackClickSpeed) } else { aF() } } }, au.trackClickRepeatFreq), aF = function() { s && clearInterval(s); s = null; b(document).unbind("mouseup.jsp", aF) }; b(document).bind("mouseup.jsp", aF); return false } }) } if (aB) { F.bind("mousedown.jsp", function(aH) { if (aH.originalTarget == c || aH.originalTarget == aH.currentTarget) { var aG = b(this), s = setInterval(function() { var aI = aG.offset(), aJ = aH.pageX - aI.left; if (X + ao < aJ) { T(X + au.trackClickSpeed) } else { if (aJ < X) { T(X - au.trackClickSpeed) } else { aF() } } }, au.trackClickRepeatFreq), aF = function() { s && clearInterval(s); s = null; b(document).unbind("mouseup.jsp", aF) }; b(document).bind("mouseup.jsp", aF); return false } }) } } function w() { F && F.unbind("mousedown.jsp"); al && al.unbind("mousedown.jsp") } function ar() { b("html").unbind("dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp"); ap && ap.removeClass("jspActive"); h && h.removeClass("jspActive") } function S(s, aF) { if (!av) { return } if (s < 0) { s = 0 } else { if (s > i) { s = i } } if (aF == c) { aF = au.animateScroll } if (aF) { N.animate(ap, "top", s, aa) } else { ap.css("top", s); aa(s) } } function aa(aF) { if (aF == c) { aF = ap.position().top } aj.scrollTop(0); H = aF; var aI = H == 0, aG = H == i, aH = aF / i, s = -aH * (W - v); if (ag != aI || aD != aG) { ag = aI; aD = aG; C.trigger("jsp-arrow-change", [ag, aD, M, k]) } u(aI, aG); V.css("top", s); C.trigger("jsp-scroll-y", [-s, aI, aG]) } function T(aF, s) { if (!aB) { return } if (aF < 0) { aF = 0 } else { if (aF > j) { aF = j } } if (s == c) { s = au.animateScroll } if (s) { N.animate(h, "left", aF, ab) } else { h.css("left", aF); ab(aF) } } function ab(aF) { if (aF == c) { aF = h.position().left } aj.scrollTop(0); X = aF; var aI = X == 0, aH = X == j, aG = aF / j, s = -aG * (Q - ah); if (M != aI || k != aH) { M = aI; k = aH; C.trigger("jsp-arrow-change", [ag, aD, M, k]) } r(aI, aH); V.css("left", s); C.trigger("jsp-scroll-x", [-s, aI, aH]) } function u(aF, s) { if (au.showArrows) { am[aF ? "addClass" : "removeClass"]("jspDisabled"); ac[s ? "addClass" : "removeClass"]("jspDisabled") } } function r(aF, s) {
                if (au.showArrows) {
                    at[aF ? "addClass" : "removeClass"]("jspDisabled");
                    x[s ? "addClass" : "removeClass"]("jspDisabled")
                } 
            } function J(s, aF) { var aG = s / (W - v); S(aG * i, aF) } function K(aF, s) { var aG = aF / (Q - ah); T(aG * j, s) } function Y(aN, aL, aF) { var aJ, aH, s = 0, aG, aK, aM; try { aJ = b(aN) } catch (aI) { return } aH = aJ.outerHeight(); aj.scrollTop(0); while (!aJ.is(".jspPane")) { s += aJ.position().top; aJ = aJ.offsetParent(); if (/^body|html$/i.test(aJ[0].nodeName)) { return } } aG = aw(); aK = aG + v; if (s < aG || aL) { aM = s - au.verticalGutter } else { if (s + aH > aK) { aM = s - v + aH + au.verticalGutter } } if (aM) { J(aM, aF) } } function ay() { return -V.position().left } function aw() { return -V.position().top } function ad() { aj.unbind(Z).bind(Z, function(aI, aJ, aH, aF) { var aG = X, s = H; T(X + aH * au.mouseWheelSpeed, false); S(H - aF * au.mouseWheelSpeed, false); return aG == X && s == H }) } function n() { aj.unbind(Z) } function ax() { return false } function I() { V.unbind("focusin.jsp").bind("focusin.jsp", function(s) { if (s.target === V[0]) { return } Y(s.target, false) }) } function D() { V.unbind("focusin.jsp") } function P() { var aF, s; C.attr("tabindex", 0).unbind("keydown.jsp").bind("keydown.jsp", function(aJ) { if (aJ.target !== C[0]) { return } var aH = X, aG = H, aI = aF ? 2 : 16; switch (aJ.keyCode) { case 40: S(H + aI, false); break; case 38: S(H - aI, false); break; case 34: case 32: J(aw() + Math.max(32, v) - 16); break; case 33: J(aw() - v + 16); break; case 35: J(W - v); break; case 36: J(0); break; case 39: T(X + aI, false); break; case 37: T(X - aI, false); break } if (!(aH == X && aG == H)) { aF = true; clearTimeout(s); s = setTimeout(function() { aF = false }, 260); return false } }); if (au.hideFocus) { C.css("outline", "none"); if ("hideFocus" in aj[0]) { C.attr("hideFocus", true) } } else { C.css("outline", ""); if ("hideFocus" in aj[0]) { C.attr("hideFocus", false) } } } function O() { C.attr("tabindex", "-1").removeAttr("tabindex").unbind("keydown.jsp") } function B() { if (location.hash && location.hash.length > 1) { var aG, aF; try { aG = b(location.hash) } catch (s) { return } if (aG.length && V.find(aG)) { if (aj.scrollTop() == 0) { aF = setInterval(function() { if (aj.scrollTop() > 0) { Y(location.hash, true); b(document).scrollTop(aj.position().top); clearInterval(aF) } }, 50) } else { Y(location.hash, true); b(document).scrollTop(aj.position().top) } } } } function af() { b("a.jspHijack").unbind("click.jsp-hijack").removeClass("jspHijack") } function m() { af(); b("a[href^=#]").addClass("jspHijack").bind("click.jsp-hijack", function() { var s = this.href.split("#"), aF; if (s.length > 1) { aF = s[1]; if (aF.length > 0 && V.find("#" + aF).length > 0) { Y("#" + aF, true); return false } } }) } b.extend(N, { reinitialise: function(aF) { aF = b.extend({}, aF, au); an(aF) }, scrollToElement: function(aG, aF, s) { Y(aG, aF, s) }, scrollTo: function(aG, s, aF) { K(aG, aF); J(s, aF) }, scrollToX: function(aF, s) { K(aF, s) }, scrollToY: function(s, aF) { J(s, aF) }, scrollBy: function(aF, s, aG) { N.scrollByX(aF, aG); N.scrollByY(s, aG) }, scrollByX: function(s, aG) { var aF = ay() + s, aH = aF / (Q - ah); T(aH * j, aG) }, scrollByY: function(s, aG) { var aF = aw() + s, aH = aF / (W - v); S(aH * i, aG) }, animate: function(aF, aI, s, aH) { var aG = {}; aG[aI] = s; aF.animate(aG, { duration: au.animateDuration, ease: au.animateEase, queue: false, step: aH }) }, getContentPositionX: function() { return ay() }, getContentPositionY: function() { return aw() }, getIsScrollableH: function() { return aB }, getIsScrollableV: function() { return av }, getContentPane: function() { return V }, scrollToBottom: function(s) { S(i, s) }, hijackInternalLinks: function() { m() } })
        } f = b.extend({}, b.fn.jScrollPane.defaults, f); var e; this.each(function() { var g = b(this), h = g.data("jsp"); if (h) { h.reinitialise(f) } else { h = new d(g, f); g.data("jsp", h) } e = e ? e.add(g) : g }); return e
    }; b.fn.jScrollPane.defaults = { showArrows: false, maintainPosition: true, clickOnTrack: true, autoReinitialise: false, autoReinitialiseDelay: 500, verticalDragMinHeight: 0, verticalDragMaxHeight: 99999, horizontalDragMinWidth: 0, horizontalDragMaxWidth: 99999, animateScroll: false, animateDuration: 300, animateEase: "linear", hijackInternalLinks: false, verticalGutter: 4, horizontalGutter: 4, mouseWheelSpeed: 10, arrowButtonSpeed: 10, arrowRepeatFreq: 100, arrowScrollOnHover: false, trackClickSpeed: 30, trackClickRepeatFreq: 100, verticalArrowPositions: "split", horizontalArrowPositions: "split", enableKeyboardNavigation: true, hideFocus: false}
})(jQuery, this);
/*lightbox*/
(function($) {
    $.fn.simplebox = function(options) {
        return new Simplebox(this, options);
    };

    function Simplebox(context, options) { this.init(context, options); };

    Simplebox.prototype = {
        options: {},
        init: function(context, options) {
            this.options = $.extend({
                duration: 300,
                linkClose: 'a.close, a.btn-close',
                divFader: 'fader',
                faderColor: 'black',
                opacity: 0.7,
                wrapper: '#wrapper',
                linkPopap: '.link-submit'
            }, options || {});
            this.btn = $(context);
            this.select = $(this.options.wrapper).find('select');
            this.initFader();
            this.btnEvent(this, this.btn);
        },
        btnEvent: function($this, el) {
            el.click(function() {
                if ($(this).attr('href')) $this.toPrepare($(this).attr('href'));
                else $this.toPrepare($(this).attr('title'));
                return false;
            });
        },
        calcWinWidth: function() {
            this.winWidth = $('body').width();
            if ($(this.options.wrapper).width() > this.winWidth) this.winWidth = $(this.options.wrapper).width();
        },
        toPrepare: function(obj) {
            this.popup = $(obj);
            this.btnClose = this.popup.find(this.options.linkClose);
            this.submitBtn = this.popup.find(this.options.linkPopap);

            if ($.browser.msie) this.select.css({ visibility: 'hidden' });
            this.calcWinWidth();
            this.winHeight = $(window).height();
            this.winScroll = $(window).scrollTop();

            this.popupTop = this.winScroll + (this.winHeight / 2) - this.popup.outerHeight(true) / 2;
            if (this.popupTop < 0) this.popupTop = 0;
            this.faderHeight = $(this.options.wrapper).outerHeight();
            if ($(window).height() > this.faderHeight) this.faderHeight = $(window).height();

            this.popup.css({
                top: this.popupTop,
                left: this.winWidth / 2 - this.popup.outerWidth(true) / 2
            }).hide();
            this.fader.css({
                width: this.winWidth,
                height: this.faderHeight
            });
            this.initAnimate(this);
            this.initCloseEvent(this, this.btnClose, true);
            this.initCloseEvent(this, this.submitBtn, false);
            this.initCloseEvent(this, this.fader, true);
        },
        initCloseEvent: function($this, el, flag) {
            el.click(function() {
                $('.activeArea').find('.selectButton').trigger('click');
                $this.popup.fadeOut($this.options.duration, function() {
                    $this.popup.css({ left: '-9999px' }).show();
                    if ($.browser.msie) $this.select.css({ visibility: 'visible' });
                    $this.submitBtn.unbind('click');
                    $this.fader.unbind('click');
                    $this.btnClose.unbind('click');
                    $(window).unbind('resize');
                    if (flag) $this.fader.fadeOut($this.options.duration);
                    else {
                        if ($this.submitBtn.attr('href')) $this.toPrepare($this.submitBtn.attr('href'));
                        else $this.toPrepare($this.submitBtn.attr('title'));
                    }
                });
                return false;
            });
        },
        initAnimate: function($this) {
            $this.fader.fadeIn($this.options.duration, function() {
                $this.popup.fadeIn($this.options.duration);
            });
            $(window).resize(function() {
                $this.calcWinWidth();
                $this.popup.animate({
                    left: $this.winWidth / 2 - $this.popup.outerWidth(true) / 2
                }, { queue: false, duration: $this.options.duration });
                $this.fader.css({ width: $this.winWidth });
            });
        },
        initFader: function() {
            if ($(this.options.divFader).length > 0) this.fader = $(this.options.divFader);
            else {
                this.fader = $('<div class="' + this.options.divFader + '"></div>');
                $('body').append(this.fader);
                this.fader.css({
                    position: 'absolute',
                    zIndex: 999,
                    left: 0,
                    top: 0,
                    background: this.options.faderColor,
                    opacity: this.options.opacity
                }).hide();
            }
        }
    }
} (jQuery));
