
/*---- clear inputs ---*/
function clearInputs() {
    $('input:text, input:password, textarea').each(function() {
        var _el = $(this);
        _el.data('val', _el.val());

        _el.bind('focus', function() {
            if (_el.val() == _el.data('val')) _el.val('');
        }).bind('blur', function() {
            if (_el.val() == '') _el.val(_el.data('val'));
        });
    });
}
/*--- IE6 hover ---*/
function ieHover(h_list, h_class) {
    if ($.browser.msie && $.browser.version < 7) {
        if (!h_class) var h_class = 'hover';
        $(h_list).mouseenter(function() {
            $(this).addClass(h_class);
        }).mouseleave(function() {
            $(this).removeClass(h_class);
        });
    }
}
/*--- tabs ---*/
function initTabs(h_hold) {
    $(h_hold).each(function(_ind, _el) {
        var btn_h = $(_el);
        var _btn = $(_el).find('a.tab');
        var _a = 0;
        _btn.each(function(_ind, _el) {
            this._box = $('#' + _el.href.substr(_el.href.indexOf("#") + 1));
            if ($(_el).hasClass('active')) {
                this._box.css({ display: 'block' });
                _a = _ind;
            }
            else {
                this._box.css({ display: 'none' });
            }
            _el.onclick = function() {
                if (!$(this).hasClass('active')) {
                    _btn.get(_a)._box.css({ display: 'none' });
                    _btn.eq(_a).removeClass('active');
                    this._box.css({ display: 'block' });
                    $(this).addClass('active');
                    _a = _ind;
                    this._box.find(".hold").customScrollV();
                }
                return false;
            }
        });
    });
}
/*--- news animation ---*/
function initNews() {
    var _speed = 300; //in ms
    $('div.news-list').each(function() {
        var _hold = $(this);
        var _img = _hold.find('div.img-frame img');
        var _btn = _hold.find('div.hold li');
        var _a = (_btn.index(_btn.filter('.active:eq(0)')) != -1) ? (_btn.index(_btn.filter('.active:eq(0)'))) : (0);

        _btn.removeClass('active').eq(_a).addClass('active');
        _img.removeClass('active').css('opacity', 0).eq(_a).addClass('active').css('opacity', 1);

        _btn.mouseenter(function() {
            changeEl(_btn.index(this));
        });
        function changeEl(_ind) {
            if (_ind != _a) {
                _btn.eq(_a).removeClass('active');
                _btn.eq(_ind).addClass('active');
                _img.eq(_a).removeClass('active').animate({ opacity: 0 }, { queue: false, duration: _speed });
                _img.eq(_ind).addClass('active').animate({ opacity: 1 }, { queue: false, duration: _speed });
                $('div.news div.scrollable').customScrollV();
                _a = _ind;
            }
        }
    });
}
/*--- different slides ---*/
function diffSlides() {
    var _speed = 300; //in ms
    $('div.form-holder').each(function() {
        var _hold = $(this);
        var _sel = _hold.find('select.open-button');
        var sel_btn = _sel.children();
        var _a = _sel.attr('selectedIndex');
        var _h = 0;
        for (var i = 0; i < sel_btn.length; i++) {
            if (sel_btn.eq(i).val().indexOf('#') != -1) {
                sel_btn.eq(i).data('box', $(sel_btn.eq(i).val()));
                if (_a == i) sel_btn.eq(i).data('box').show();
                else sel_btn.eq(i).data('box').hide();
            }
        }
        _sel.change(function() {
            changeEl(_sel.attr('selectedIndex'));
        });
        function changeEl(_ind) {
            if (_a != _ind) {
                if (sel_btn.eq(_a).data('box')) {
                    sel_btn.eq(_a).data('box').stop().animate({ height: 0 }, _speed, function() {
                        $(this).css({ display: 'none', height: 'auto' });
                    });
                }
                if (sel_btn.eq(_ind).data('box')) {
                    if (sel_btn.eq(_ind).data('box').is(':hidden')) {
                        sel_btn.eq(_ind).data('box').show();
                        _h = sel_btn.eq(_ind).data('box').height();
                        sel_btn.eq(_ind).data('box').height(0);
                    }
                    sel_btn.eq(_ind).data('box').stop().animate({ height: _h }, _speed, function() { $(this).height('auto'); });
                }
                _a = _ind;
            }
        }
    });
    /*--- ---*/
    $('div.color-box').each(function() {
        var _hold = $(this);
        var _btn = _hold.children('a.btn-color-choice');
        var _box = _hold.children('div.holder');
        var _t;
        if (_btn.length && _box.length) {
            var _h = _box.height();
            if (_hold.hasClass('active')) _box.show();
            else _box.hide();
            _btn.click(function() {
                if (_t) clearTimeout(_t);
                if (_hold.hasClass('active')) {
                    _hold.removeClass('active');
                    _box.stop().animate({ height: 0 }, _speed, function() { $(this).css({ display: 'none', height: 'auto' }); });
                }
                else {
                    _hold.addClass('active');
                    if (_box.is(':hidden')) {
                        _box.show();
                        _h = _box.height();
                        _box.height(0);
                    }
                    _box.stop().animate({ height: _h }, _speed, function() { $(this).height('auto'); });
                }
                return false;
            });
            _hold.mouseleave(function() {
                if (_t) clearTimeout(_t);
                _t = setTimeout(function() {
                    if (_hold.hasClass('active')) {
                        _hold.removeClass('active');
                        _box.stop().animate({ height: 0 }, _speed, function() { $(this).css({ display: 'none', height: 'auto' }); });
                    }
                }, 1000);
            }).mouseenter(function() {
                if (_t) clearTimeout(_t);
            });
            $('body').bind('mousedown', function(e) {
                if (_hold.hasClass('active')) {
                    e = e || event;
                    var t = e.target || e.srcElement;
                    t = $(t);
                    if (t.parents().filter(_hold).length == 0) {
                        if (_t) clearTimeout(_t);
                        _hold.removeClass('active');
                        _box.stop().animate({ height: 0 }, _speed, function() { $(this).css({ display: 'none', height: 'auto' }); });
                    }
                }
            });
        }
    });
    /*--- ---*/
    $('div.quick-specs').each(function() {
        var _hold = $(this);
        var _btn = _hold.children('a.btn-quick-specs');
        var _box = _hold.children('div.holder');
        var _t;
        if (_btn.length && _box.length) {
            var _h = _box.height();
            if (_hold.hasClass('active')) _box.show();
            else _box.hide();
            _btn.click(function() {
                if (_t) clearTimeout(_t);
                if (_hold.hasClass('active')) {
                    _hold.removeClass('active');
                    _box.stop().animate({ height: 0 }, _speed, function() { $(this).css({ display: 'none', height: 'auto' }); });
                }
                else {
                    _hold.addClass('active');
                    if (_box.is(':hidden')) {
                        _box.show();
                        _h = _box.height();
                        _box.height(0);
                    }
                    _box.stop().animate({ height: _h }, _speed, function() { $(this).height('auto'); });
                }
                return false;
            });
            _hold.mouseleave(function() {
                if (_t) clearTimeout(_t);
                _t = setTimeout(function() {
                    if (_hold.hasClass('active')) {
                        _hold.removeClass('active');
                        _box.stop().animate({ height: 0 }, _speed, function() { $(this).css({ display: 'none', height: 'auto' }); });
                    }
                }, 1000);
            }).mouseenter(function() {
                if (_t) clearTimeout(_t);
            });
            $('body').bind('mousedown', function(e) {
                if (_hold.hasClass('active')) {
                    e = e || event;
                    var t = e.target || e.srcElement;
                    t = $(t);
                    if (t.parents().filter(_hold).length == 0) {
                        if (_t) clearTimeout(_t);
                        _hold.removeClass('active');
                        _box.stop().animate({ height: 0 }, _speed, function() { $(this).css({ display: 'none', height: 'auto' }); });
                    }
                }
            });
        }
    });
    /*--- ---*/
    $('ul.run-list > li').each(function() {
        var _hold = $(this);
        var _btn = _hold.children('a');
        var _box = _hold.children('div.refine-popup');
        var _t;
        if (_btn.length && _box.length) {
            var _h = _box.height();
            if (_hold.hasClass('opened')) _box.show();
            else _box.hide();
            _btn.click(function() {
                if (_t) clearTimeout(_t);
                if (_hold.hasClass('opened')) {
                    _hold.removeClass('opened');
                    _box.stop().animate({ height: 0 }, _speed, function() { $(this).css({ display: 'none', height: 'auto' }); });
                }
                else {
                    _hold.addClass('opened');
                    if (_box.is(':hidden')) {
                        _box.show();
                        _h = _box.height();
                        _box.height(0);
                        $('div.refine-el').customSlider2();
                    }
                    _box.stop().animate({ height: _h }, _speed, function() { $(this).height('auto'); });
                }
                return false;
            });
            _hold.mouseleave(function() {
                if (_t) clearTimeout(_t);
                _t = setTimeout(function() {
                    if (_hold.hasClass('opened')) {
                        _hold.removeClass('opened');
                        _box.stop().animate({ height: 0 }, _speed, function() { $(this).css({ display: 'none', height: 'auto' }); });
                    }
                }, 1000);
            }).mouseenter(function() {
                if (_t) clearTimeout(_t);
            });
            $('body').bind('mousedown', function(e) {
                if (_hold.hasClass('opened')) {
                    e = e || event;
                    var t = e.target || e.srcElement;
                    t = $(t);
                    if (t.parents().filter(_hold).length == 0) {
                        if (_t) clearTimeout(_t);
                        _hold.removeClass('opened');
                        _box.stop().animate({ height: 0 }, _speed, function() { $(this).css({ display: 'none', height: 'auto' }); });
                    }
                }
            });
        }
    });
    /*--- ---*/
    var prod_btn = $('#btn-view-prod');
    var prod_hold = $('#prod-hold');
    if (prod_btn.length && prod_hold.length) {
        var prod_f = true;
        var prod_h = prod_hold.outerHeight();
        if (prod_btn.hasClass('active')) {
            prod_hold.addClass('product-active');
            prod_f = true;
        }
        else {
            prod_hold.removeClass('product-active');
            prod_f = false;
        }
        $('#prod-hold div.scroll-content').scrollLeft(0);
        if (typeof (HSA_handleResize) == 'function') HSA_handleResize();
        prod_btn.click(function() {
            if (prod_f) {
                prod_f = false;
                prod_hold.stop().animate({ height: 0 }, 300, function() {
                    prod_btn.removeClass('active');
                    prod_hold.removeClass('product-active').height('auto');
                });
            }
            else {
                prod_f = true;
                prod_btn.addClass('active');
                if (!prod_hold.is(':animated')) {
                    prod_h = prod_hold.height();
                    prod_hold.height(0);
                }
                $('#prod-hold div.scroll-content').scrollLeft(0);
                if (typeof (HSA_handleResize) == 'function') HSA_handleResize();
                prod_hold.stop().addClass('product-active').animate({ height: prod_h }, 300, function() { prod_hold.height('auto'); });
            }
            return false;
        });
    }
}
/*--- kit functions ---*/
var kitFunctions = {
    gall_f: false,
    _speed: 500,
    _hold: null,
    gall_hold: null,
    gall_info: null,
    list_hold: null,
    _list: null,
    btn_prev: null,
    btn_next: null,
    _info: null,
    _step: null,
    _a: 0,
    num_inf: null,
    init: function() {
        var _this = this;
        _this._hold = $('div.top-box div.kit:eq(0)');
        if (_this._hold.length) {
            _this.list_hold = _this._hold.find('div.kit-gallery ul');
            _this.btn_prev = _this._hold.find('div.kit-gallery a.link-prev');
            _this.btn_next = _this._hold.find('div.kit-gallery a.link-next');
            _this._info = _this._hold.find('.gall-info');
            _this.num_inf = _this._hold.find('div.kit-items strong');

            if (_this.list_hold.length) {
                _this._hold.parent().removeClass('no-items');
                _this._list = _this.list_hold.children();
                _this._step = _this._list.outerWidth();
                _this._a = (_this._list.index(_this._list.filter('.active-el:eq(0)')) != -1) ? (_this._list.index(_this._list.filter('.active-el:eq(0)'))) : (0);

                _this._list.removeClass('active-el').eq(_this._a).addClass('active-el');
                if (_this._list.length == 1) _this._info.html('<strong>1</strong> item');
                else _this._info.html('<strong>' + (_this._a + 1) + '</strong> of <strong>' + (_this._list.length) + '</strong> of items');
                if (_this._a == 0) _this.btn_prev.hide();
                else _this.btn_prev.show();
                if (_this._a == _this._list.length - 1) _this.btn_next.hide();
                else _this.btn_next.show();

                if (_this._list.length < 10) _this.num_inf.text('0' + _this._list.length);
                else _this.num_inf.text(_this._list.length);
            }
            else {
                _this.num_inf.text('00');
                _this._hold.parent().addClass('no-items');
            }
            _this._hold.find('div.kit-items').click(function() {
                if (_this._hold.hasClass('active')) {
                    _this._hold.removeClass('active');
                }
                else {
                    _this._hold.addClass('active');
                    if (_this.list_hold.length) _this.gall();
                }
                return false;
            });
            $('body').bind('mousedown', function(e) {
                if (_this._hold.hasClass('active')) {
                    e = e || event;
                    var t = e.target || e.srcElement;
                    t = $(t);
                    if (t.parents('div.kit').length == 0 && (t.hasClass('btn-add-item') || t.parents('a.btn-add-item').length == 0)) {
                        _this._hold.removeClass('active');
                    }
                }
            });
            $('a.btn-add-item').click(function() {
                var _lnk = $(this);
                $.ajax({
                    url: this.href,
                    dataType: 'html',
                    success: function(_html) {
                        if (_html != '0' && _html != '') _this.update(_html);
                        _lnk.attr('href', _lnk.attr('rel')).unbind('click').find('span').text('VIEW IN MYKIT');
                    }
                });
                return false;
            });
        }
    },
    gall: function() {
        var _this = this;
        if (!_this.gall_f && _this._hold.find('div.kit-gallery').is(':visible')) {
            _this.gall_f = true;
            _this._step = _this._list.outerWidth();

            _this._list.removeClass('active-el').eq(_this._a).addClass('active-el');
            if (_this._list.length == 1) _this._info.html('<strong>1</strong> item');
            else _this._info.html('<strong>' + (_this._a + 1) + '</strong> of <strong>' + (_this._list.length) + '</strong> of items');
            if (_this._a == 0) _this.btn_prev.hide();
            else _this.btn_prev.show();
            if (_this._a == _this._list.length - 1) _this.btn_next.hide();
            else _this.btn_next.show();

            _this.btn_prev.click(function() {
                if (_this._a > 0) moveList(_this._a - 1);
                return false;
            });
            _this.btn_next.click(function() {
                if (_this._a < _this._list.length - 1) moveList(_this._a + 1);
                return false;
            });
            function moveList(_ind) {
                if (_ind != _this._a) {
                    if (_ind == 0) _this.btn_prev.hide();
                    else _this.btn_prev.show();
                    if (_ind == _this._list.length - 1) _this.btn_next.hide();
                    else _this.btn_next.show();
                    _this._info.html('<strong>' + (_ind + 1) + '</strong> of <strong>' + (_this._list.length) + '</strong> of items');
                    _this._list.eq(_this._a).removeClass('active-el');
                    _this._list.eq(_ind).addClass('active-el');
                    _this.list_hold.animate({ left: -_ind * _this._step }, { queue: false, duration: _this._speed });
                    _this._a = _ind;
                }
            }
        }
        else if (_this.gall_f && _this._hold.find('div.kit-gallery').is(':visible')) {
            _this._list = _this.list_hold.children();
            _this._info.html('<strong>' + (_this._a + 1) + '</strong> of <strong>' + (_this._list.length) + '</strong> of items');
            if (_this._a == 0) _this.btn_prev.hide();
            else _this.btn_prev.show();
            if (_this._a == _this._list.length - 1) _this.btn_next.hide();
            else _this.btn_next.show();
        }
    },
    update: function(_html) {
        var _this = this;
        if (_this.list_hold.length == 0) {
            _this.list_hold = $('<ul></ul>');
            _this._hold.find('div.kit-gallery div.box').append(_this.list_hold);
            _this._hold.parent().removeClass('no-items');
            _this._a = 0;
        }
        _this.list_hold.append('<li>' + _html + '</li>');
        _this._list = _this.list_hold.children();
        if (_this._list.length < 10) _this.num_inf.text('0' + _this._list.length);
        else _this.num_inf.text(_this._list.length);
        _this._hold.addClass('active');
        _this.gall();
    }
}
/*--- promo gallery ---*/
function promoGallery() {
    var _speed = 500; //in ms
    var stay_time = 5000; //in ms or 'false' if not needed
    $('div.promo-gallery, div.shoes-promo').each(function() {
        var _hold = $(this);
        var list_hold = _hold.find('div ul').not('ul.events-promo-date');
        var _list = list_hold.children();
        var btn_prev = _hold.find('a.link-prev').empty();
        var prev_img = $('<span></span>').appendTo(btn_prev);
        var btn_next = _hold.find('a.link-next').empty();
        var next_img = $('<span></span>').appendTo(btn_next);
        var list_w = list_hold.children().length * list_hold.children().outerWidth();
        var hold_w = list_hold.parent().width();
        var _step = list_hold.children().outerWidth();
        var _a = (_list.index(_list.filter('.active:eq(0)')) != -1) ? (_list.index(_list.filter('.active:eq(0)'))) : (0);
        var _t, _f = true;

        var text_hold = _hold.find('ul.events-promo-date');
        if (text_hold.length) {
            var text_f = true;
            var text_list = text_hold.children();
            if ($.browser.msie) text_list.hide().removeClass('active').eq(_a).show().addClass('active');
            else text_list.css({ opacity: 0, display: 'none' }).removeClass('active').eq(_a).css({ opacity: 1, display: 'block' }).addClass('active');
        }

        list_hold.css('left', _a * _step);
        if (_list.length <= 1) {
            btn_prev.hide();
            btn_next.hide();
            stay_time = false;
        }
        else if (_a == 0) {
            prev_img.html(_list.eq(_list.length - 1).find('img.thumbnail').clone());
            next_img.html(_list.eq(_a + 1).find('img.thumbnail').clone());
        }
        else if (_a == _list.length - 1) {
            next_img.html(_list.eq(0).find('img.thumbnail').clone());
            prev_img.html(_list.eq(_a - 1).find('img.thumbnail').clone());
        }
        else {
            prev_img.html(_list.eq(_a - 1).find('img.thumbnail').clone());
            next_img.html(_list.eq(_a + 1).find('img.thumbnail').clone());
        }
        btn_prev.click(function() {
            if (_a > 0) moveList(_a - 1);
            else moveList(_list.length - 1);
            return false;
        });
        btn_next.click(function() {
            if (_a < _list.length - 1) moveList(_a + 1);
            else moveList(0);
            return false;
        });
        _hold.mouseenter(function() {
            _f = false;
            if (_t) clearTimeout(_t);
        }).mouseleave(function() {
            _f = true;
            if (_t) clearTimeout(_t);
            if (_f && stay_time) {
                _t = setTimeout(function() {
                    if (_a < _list.length - 1) moveList(_a + 1);
                    else moveList(0);
                }, stay_time);
            }
        });
        if (_f && stay_time) {
            _t = setTimeout(function() {
                if (_a < _list.length - 1) moveList(_a + 1);
                else moveList(0);
            }, stay_time);
        }
        function moveList(_ind) {
            if (_t) clearTimeout(_t);
            if (_ind != _a) {
                _list.eq(_a).removeClass('active');
                _list.eq(_ind).addClass('active');
                if (_ind == 0) prev_img.html(_list.eq(_list.length - 1).find('img.thumbnail').clone());
                else prev_img.html(_list.eq(_ind - 1).find('img.thumbnail').clone());
                if (_ind == _list.length - 1) next_img.html(_list.eq(0).find('img.thumbnail').clone());
                else next_img.html(_list.eq(_ind + 1).find('img.thumbnail').clone());
                if (text_f) {
                    if ($.browser.msie) {
                        text_list.eq(_a).removeClass('active').hide();
                        text_list.eq(_ind).addClass('active').show();
                    }
                    else {
                        text_hold.stop().width(text_hold.width());
                        text_list.eq(_a).stop().removeClass('active').animate({ opacity: 0 }, _speed, function() { $(this).hide(); });
                        text_list.eq(_ind).stop().addClass('active').show().animate({ opacity: 1 }, _speed);
                        text_hold.animate({ width: text_list.eq(_ind).outerWidth() }, _speed, function() { $(this).width('auto'); });
                    }
                }
                list_hold.animate({ left: -_ind * _step }, { queue: false, duration: _speed });
                _a = _ind;
            }
            if (_f && stay_time) {
                _t = setTimeout(function() {
                    if (_a < _list.length - 1) moveList(_a + 1);
                    else moveList(0);
                }, stay_time + _speed);
            }
        }
    });
}
/*--- technology gallery ---*/
function technologyGallery() {
    var move_speed = 300; //in ms
    var stay_time = 4000; //in ms or 'false' if not needed
    $('div.technology div.gallery').each(function() {
        var _hold = $(this);
        var btn_prev = _hold.find('a.prev');
        var btn_next = _hold.find('a.next');
        var list_hold = _hold.find('div.box > ul');
        var _list = list_hold.children();

        var list_w = _list.length * _list.outerWidth();
        var hold_w = list_hold.parent().width();
        var _step = _list.outerWidth();

        var stay_f = true, _t;
        if (list_w > hold_w) {
            var _m = list_w;
            list_hold.append(_list.clone()).append(_list.clone());
            list_hold.css('left', -_m);
            btn_prev.click(function() {
                moveList(false);
                return false;
            });
            btn_next.click(function() {
                moveList(true);
                return false;
            });
            _hold.mouseenter(function() {
                stay_f = false;
                if (_t) clearTimeout(_t);
            }).mouseleave(function() {
                stay_f = true;
                if (_t) clearTimeout(_t);
                if (stay_f && stay_time) {
                    _t = setTimeout(function() {
                        moveList(true);
                    }, stay_time);
                }
            });
            if (stay_f && stay_time) {
                _t = setTimeout(function() {
                    moveList(true);
                }, stay_time);
            }
        }
        else {
            stay_time = false;
            btn_prev.hide();
            btn_next.hide();
        }
        var _flag = true;
        function moveList(_f) {
            if (_t) clearTimeout(_t);
            if (_flag) {
                _flag = false;
                if (_f) {
                    if (_m + _step > list_w * 3 - hold_w) {
                        _m -= list_w;
                        list_hold.css('left', -_m);
                    }
                    _m += _step;
                }
                else {
                    if (_m - _step < 0) {
                        _m += list_w;
                        list_hold.css('left', -_m);
                    }
                    _m -= _step;
                }
                list_hold.animate({ left: -_m }, move_speed, function() {
                    _flag = true;
                });
            }
            if (stay_f && stay_time) {
                _t = setTimeout(function() {
                    moveList(true);
                }, stay_time);
            }
        }

        var _popup = $('<div class="tech-pop-up"><div class="t">&nbsp;</div><div class="c"><div class="bg"></div></div><div class="b">&nbsp;</div></div>');
        var popup_cont = _popup.find('div.bg');
        _popup.css('display', 'none');
        if (!$.browser.msie) _popup.css('opacity', 0);
        $('body').append(_popup);
        var popup_t;
        list_hold.children(':has("div.tooltip-cont")').each(function() {
            var _el = $(this);
            var _text = _el.find('div.tooltip-cont');

            _el.mouseenter(function() {
                if (popup_t) clearTimeout(popup_t);
                stay_f = false;
                if (_t) clearTimeout(_t);
                popup_cont.html(_text.html());
                _popup.stop().show();
                _popup.css({ top: _el.offset().top - _popup.outerHeight(), left: _el.offset().left });
                if (!$.browser.msie) _popup.animate({ opacity: 1 }, 200);
            }).mouseleave(function() {
                if (popup_t) clearTimeout(popup_t);
                popup_t = setTimeout(function() {
                    if ($.browser.msie) _popup.hide();
                    else _popup.stop().animate({ opacity: 0 }, 200, function() { $(this).hide(); });
                }, 100);
            });
        });
        _popup.mouseenter(function() {
            if (popup_t) clearTimeout(popup_t);
            stay_f = false;
            if (_t) clearTimeout(_t);
        }).mouseleave(function() {
            if (popup_t) clearTimeout(popup_t);
            popup_t = setTimeout(function() {
                if ($.browser.msie) _popup.hide();
                else _popup.stop().animate({ opacity: 0 }, 200, function() { $(this).hide(); });
            }, 100);
            stay_f = true;
            if (_t) clearTimeout(_t);
            if (stay_f && stay_time) {
                _t = setTimeout(function() {
                    moveList(true);
                }, stay_time);
            }
        });
    });
}
/*--- tooltips ---*/
function initTooltips(h_hold) {
    h_hold = h_hold || $('body');
    function tooltip1() {
        if ($('div.product-pop-up').length == 0) {
            $('<div class="product-pop-up"><div class="t">&nbsp;</div><div class="c"><div class="bg"></div></div><div class="b">&nbsp;</div><div class="arrow"></div>').appendTo('body');

            var _tooltip = $('div.product-pop-up');
            _tooltip.data('cont', _tooltip.find('div.bg'));
            _tooltip.css('display', 'none');
            if (!$.browser.msie) _tooltip.css('opacity', 0);
            _tooltip.get(0).tooltip_t = false;

            _tooltip.mouseenter(function() {
                if (_tooltip.get(0).tooltip_t) clearTimeout(_tooltip.get(0).tooltip_t);
            }).mouseleave(function() {
                if (_tooltip.get(0).tooltip_t) clearTimeout(_tooltip.get(0).tooltip_t);
                _tooltip.get(0).tooltip_t = setTimeout(function() {
                    if ($.browser.msie) _tooltip.hide();
                    else _tooltip.stop().animate({ opacity: 0 }, 200, function() { $(this).hide(); });
                }, 100);
            });
        }
        else {
            var _tooltip = $('div.product-pop-up');
        }
        h_hold.find('ul.product-list li:has("div.tooltip-cont")').each(function() {
            if (!this._tooltip) {
                this._tooltip = true;
                var _el = $(this);
                var _text = _el.find('div.tooltip-cont');

                _el.mouseenter(function() {
                    if (_tooltip.get(0).tooltip_t) clearTimeout(_tooltip.get(0).tooltip_t);
                    _tooltip.data('cont').html(_text.html());
                    _tooltip.stop().removeClass('tooltip-left').removeClass('tooltip-right').show();
                    _tooltip.css({ top: _el.offset().top + parseInt(_el.css('paddingTop')) - _tooltip.outerHeight(), left: _el.offset().left + _el.outerWidth() / 2 });
                    if (_tooltip.offset().left < 50) _tooltip.addClass('tooltip-right');
                    else if ($(window).width() - _tooltip.offset().left - _tooltip.outerWidth() < 50) _tooltip.addClass('tooltip-left');
                    if (!$.browser.msie) _tooltip.animate({ opacity: 1 }, 200);
                }).mouseleave(function() {
                    if (_tooltip.get(0).tooltip_t) clearTimeout(_tooltip.get(0).tooltip_t);
                    _tooltip.get(0).tooltip_t = setTimeout(function() {
                        if ($.browser.msie) _tooltip.hide();
                        else _tooltip.stop().animate({ opacity: 0 }, 200, function() { $(this).hide(); });
                    }, 100);
                });
            }
        });
    }
    function tooltip2() {
        if ($('div.athlete-info').length == 0) {
            $('<div class="athlete-info"><div class="t">&nbsp;</div><div class="c"><div class="bg"></div></div><div class="b">&nbsp;</div></div>').appendTo('body');

            var _tooltip = $('div.athlete-info');
            _tooltip.data('cont', _tooltip.find('div.bg'));
            _tooltip.css('display', 'none');
            if (!$.browser.msie) _tooltip.css('opacity', 0);
            _tooltip.get(0).tooltip_t = false;

            _tooltip.mouseenter(function() {
                if (_tooltip.get(0).tooltip_t) clearTimeout(_tooltip.get(0).tooltip_t);
            }).mouseleave(function() {
                if (_tooltip.get(0).tooltip_t) clearTimeout(_tooltip.get(0).tooltip_t);
                _tooltip.get(0).tooltip_t = setTimeout(function() {
                    if ($.browser.msie) _tooltip.hide();
                    else _tooltip.stop().animate({ opacity: 0 }, 200, function() { $(this).hide(); });
                }, 100);
            });
        }
        else {
            _tooltip = $('div.athlete-info');
        }

        var el_list = $('ul.athlete-list li:has("div.tooltip-cont")');
        $('ul.athlete-list li:has("div.tooltip-cont")').each(function() {
            if (!this._tooltip) {
                this._tooltip = true;
                var _el = $(this);
                var _text = _el.find('div.tooltip-cont');

                _el.mouseenter(function() {
                    if (_tooltip.get(0).tooltip_t) clearTimeout(_tooltip.get(0).tooltip_t);
                    _tooltip.data('cont').html(_text.html());
                    _tooltip.stop().show();
                    _tooltip.css({ top: _el.offset().top - _tooltip.outerHeight(), left: _el.offset().left + _el.outerWidth() / 2 });
                    if (!$.browser.msie) _tooltip.animate({ opacity: 1 }, 200);
                    el_list.removeClass('actived');
                    _el.addClass('actived');
                }).mouseleave(function() {
                    if (_tooltip.get(0).tooltip_t) clearTimeout(_tooltip.get(0).tooltip_t);
                    _tooltip.get(0).tooltip_t = setTimeout(function() {
                        if ($.browser.msie) _tooltip.hide();
                        else _tooltip.stop().animate({ opacity: 0 }, 200, function() { $(this).hide(); });
                        el_list.removeClass('actived');
                    }, 100);
                });
            }
        });
        _tooltip.mouseenter(function() {
            if (_tooltip.get(0).tooltip_t) clearTimeout(_tooltip.get(0).tooltip_t);
        }).mouseleave(function() {
            if (_tooltip.get(0).tooltip_t) clearTimeout(_tooltip.get(0).tooltip_t);
            _tooltip.get(0).tooltip_t = setTimeout(function() {
                if ($.browser.msie) _tooltip.hide();
                else _tooltip.stop().animate({ opacity: 0 }, 200, function() { $(this).hide(); });
                el_list.removeClass('actived');
            }, 100);
        });
    }
    function tooltip3() {
        var _tip3items = $('ul.features-icons');
        var _popup = $('<div class="tech-pop-up"><div class="t">&nbsp;</div><div class="c"><div class="bg"></div></div><div class="b">&nbsp;</div></div>');
        var popup_cont = _popup.find('div.bg');
        _popup.css('display', 'none');
        if (!$.browser.msie) _popup.css('opacity', 0);
        $('body').append(_popup);
        var popup_t;
        var stay_f = true;
        var _t;

        _tip3items.children(':has("div.tooltip-cont")').each(function() {
            var _el = $(this);
            var _text = _el.find('div.tooltip-cont');

            _el.mouseenter(function() {
                if (popup_t) clearTimeout(popup_t);
                stay_f = false;
                if (_t) clearTimeout(_t);
                popup_cont.html(_text.html());
                _popup.stop().show();
                _popup.css({ top: _el.offset().top - _popup.outerHeight(), left: _el.offset().left });
                if (!$.browser.msie) _popup.animate({ opacity: 1 }, 200);
            }).mouseleave(function() {
                if (popup_t) clearTimeout(popup_t);
                popup_t = setTimeout(function() {
                    if ($.browser.msie) _popup.hide();
                    else _popup.stop().animate({ opacity: 0 }, 200, function() { $(this).hide(); });
                }, 100);
            });
        });
        _popup.mouseenter(function() {
            if (popup_t) clearTimeout(popup_t);
            stay_f = false;
            if (_t) clearTimeout(_t);
        }).mouseleave(function() {
            if (popup_t) clearTimeout(popup_t);
            popup_t = setTimeout(function() {
                if ($.browser.msie) _popup.hide();
                else _popup.stop().animate({ opacity: 0 }, 200, function() { $(this).hide(); });
            }, 100);
            stay_f = true;
            if (_t) clearTimeout(_t);
            if (stay_f && stay_time) {
                _t = setTimeout(function() {
                    moveList(true);
                }, stay_time);
            }
        });
    }
    tooltip1();
    tooltip2();
    tooltip3();
}
/*--- products photo ---*/
function prodPhoto() {
    var change_speed = 500; //in ms
    var img_hold = $('#product-photo');
    var _btn = $('#prog-photo-list a.btn-prod-photo');
    if (_btn.length && img_hold.length) {
        var _a = (_btn.index(_btn.filter('.active:eq(0)')) != -1) ? (_btn.index(_btn.filter('.active:eq(0)'))) : (0);
        _btn.removeClass('active').eq(_a).addClass('active');
        _btn.eq(_a).data('img', $('<img src="' + _btn.eq(_a).attr('href') + '" alt="' + _btn.eq(_a).attr('rel') + '"/>'));
        _btn.eq(_a).data('img').addClass('active').css('opacity', 1).appendTo(img_hold);

        _btn.click(function() {
            changeEl(_btn.index(this));
            return false;
        });

        var fade_f = true;
        function changeEl(_ind) {
            if (fade_f && _ind != _a) {
                fade_f = false;
                img_hold.stop().height(img_hold.height());
                _btn.eq(_a).removeClass('active');
                _btn.eq(_ind).addClass('active');
                _btn.eq(_a).data('img').removeClass('active').animate({ opacity: 0 }, { queue: false, duration: change_speed });
                if (_btn.eq(_ind).data('img')) {
                    _btn.eq(_ind).data('img').addClass('active').animate({ opacity: 1 }, { queue: false, duration: change_speed });
                    img_hold.animate({ height: _btn.eq(_ind).data('img').height() }, change_speed / 2, function() { $(this).height('auto'); });
                    _a = _ind;
                    fade_f = true;
                }
                else {
                    _btn.eq(_ind).data('img', $('<img />'));
                    _btn.eq(_ind).data('img').load(function() {
                        _btn.eq(_ind).data('img').addClass('active').animate({ opacity: 1 }, { queue: false, duration: change_speed });
                        img_hold.animate({ height: _btn.eq(_ind).data('img').height() }, change_speed / 2, function() { $(this).height('auto'); });
                        _a = _ind;
                        fade_f = true;
                    });
                    _btn.eq(_ind).data('img').css('opacity', 0);
                    img_hold.append(_btn.eq(_ind).data('img'));
                    _btn.eq(_ind).data('img').attr('src', _btn.eq(_ind).attr('href')).attr('alt', _btn.eq(_ind).attr('rel'));
                }
            }
        }
    }
}
/*--- review info ---*/
function reviewInfo() {
    $('.review-info').each(function() {
        var _hold = $(this);
        var btn_yes = _hold.find('a.yes');
        var btn_no = _hold.find('a.no');
        var box_yes = _hold.find('.yes-info');
        var box_no = _hold.find('.no-info');
        $.ajax({
            type: 'GET',
            data: '&yes=0&no=0',
            url: btn_yes.attr('href'),
            success: function(_text) {
                box_yes.text(parseInt(_text.split('yes=')[1]));
                box_no.text(parseInt(_text.split('no=')[1]));
            }
        });
        btn_yes.click(function() {
            $.ajax({
                type: 'GET',
                data: '&yes=1&no=0',
                url: this.href,
                success: function(_text) {
                    box_yes.text(parseInt(_text.split('yes=')[1]));
                    box_no.text(parseInt(_text.split('no=')[1]));
                }
            });
            return false;
        });
        btn_no.click(function() {
            $.ajax({
                type: 'GET',
                data: '&yes=0&no=1',
                url: this.href,
                success: function(_text) {
                    box_yes.text(parseInt(_text.split('yes=')[1]));
                    box_no.text(parseInt(_text.split('no=')[1]));
                }
            });
            return false;
        });
    });
}
/*--- rating ---*/
function initRating() {
    var t_w = 31;
    $('div.rating-holder').each(function() {
        var _hold = $(this);
        var _list = _hold.find('ul.star-rating > li');
        var info_hold = _hold.find('p.stars-col');
        var _info = _hold.find('input.rating-info');
        var _a = parseInt(_info.val());
        _list.removeClass('active');
        if (!isNaN(_a)) {
            _list.eq(_a - 1).addClass('active');
            if (_a == 1) info_hold.html('<strong>1</strong> star');
            else info_hold.html('<strong>' + _a + '</strong> stars');
            info_hold.css('marginLeft', t_w * (_a - 1));
        }
        else {
            _a = -1;
            info_hold.html('');
        }
        _list.mouseenter(function() {
            if (_a != -1) _list.eq(_a - 1).removeClass('active');
            $(this).addClass('active');
            if (_list.index(this) == 0) info_hold.html('<strong>1</strong> star');
            else info_hold.html('<strong>' + (_list.index(this) + 1) + '</strong> stars');
            info_hold.css('marginLeft', t_w * _list.index(this));
        }).mouseleave(function() {
            $(this).removeClass('active');
            if (_a != -1) {
                _list.eq(_a - 1).addClass('active');
                if (_a == 1) info_hold.html('<strong>1</strong> star');
                else info_hold.html('<strong>' + _a + '</strong> stars');
                info_hold.css('marginLeft', t_w * (_a - 1));
            }
            else {
                info_hold.html('');
            }
        }).click(function() {
            _a = _list.index(this) + 1;
            _info.val(_a);
            return false;
        });
    });
}
/*--- initReviews ---*/
function initReviews() {
    var _speed = 500; //in ms
    var _hold = $('#reviews');
    if (_hold.length) {
        var _btn = _hold.find('a.btn-review');
        var _box = _hold.find('div.add-review-hold');
        var _h = _box.outerHeight();
        if (_hold.hasClass('opened')) _box.show();
        else _box.hide();
        _btn.click(function() {
            if (_hold.hasClass('opened')) {
                _hold.removeClass('opened');
                _box.stop().animate({ height: 0 }, _speed, function() { _box.css({ display: 'none', height: 'auto' }); });
            }
            else {
                _hold.addClass('opened');
                if (_box.is(':hidden')) {
                    _box.css({ height: 0, display: 'block' });
                    $('div.reviews input:radio').customRadio();
                    $('div.reviews select').customSelect({ maxHeight: 197 });
                    $('div.progress-el').customSlider();
                    _h = _box.children().outerHeight(true);
                }
                _box.stop().animate({ height: _h }, _speed, function() {
                    _box.height('auto');
                    $('body').scrollTo(_box.offset().top, _speed);
                });
            }
            return false;
        });
    }
}
/*---- popups ---*/
function initPopups() {
    if ($('#fader').length == 0) $('body').append('<div id="fader"></div>');
    var _fader = $('#fader');
    _fader.hide();
    var popup_f = false;
    var _popup = $('<div class="popup"><a href="#" class="btn-close"><span>close</span></a><div class="c"><iframe align="left" frameborder="0">no iframe</iframe></div><div class="b">&nbsp;</div></div>');
    var popup_iframe = _popup.find('iframe');
    _popup.hide().appendTo('body');

    $('a.with-popup').live('click', function() {
        genPopup(this.href);
        return false;
    });
    _popup.find('a.btn-close').click(function() {
        closePopup();
        return false;
    });
    _fader.click(function() {
        closePopup();
        return false;
    });
    $(document).keydown(function(e) {
        if (!e) evt = window.event;
        if (e.keyCode == 27) closePopup();
    });

    /*--- generate popup ---*/
    function genPopup(_href) {
        var _url = '';
        var _width = 0;
        var _height = 0;
        var _class = '';
        if (_href.indexOf('?') != -1) _url = _href.split('?')[0];
        if (_href.indexOf('width=') != -1) _width = parseInt(_href.split('width=')[1].substr(0, (_href.split('width=')[1].indexOf('&') != -1) ? (_href.split('width=')[1].indexOf('&')) : (_href.split('width=')[1].length)));
        if (isNaN(_width)) _width = 777;
        if (_href.indexOf('height=') != -1) _height = parseInt(_href.split('height=')[1].substr(0, (_href.split('height=')[1].indexOf('&') != -1) ? (_href.split('height=')[1].indexOf('&')) : (_href.split('height=')[1].length)));
        if (isNaN(_height)) _height = 486;
        if (_href.indexOf('class=') != -1) _class = _href.split('class=')[1].substr(0, (_href.split('class=')[1].indexOf('&') != -1) ? (_href.split('class=')[1].indexOf('&')) : (_href.split('class=')[1].length));

        if (_url != '' && _width != 0 && _height != 0) {
            _popup.removeAttr('class').addClass('popup')
            if (_class != '') _popup.addClass(_class);
            popup_iframe.attr('width', _width).attr('height', _height).get(0).contentWindow.location.replace(_url);
            popup_f = true;
            showPopup();
        }
    }
    /*--- close popup ---*/
    function closePopup() {
        if (popup_f) {
            if ($.browser.msie) {
                _popup.hide();
                _fader.fadeOut(200);
                popup_f = false;
            }
            else {
                _popup.fadeOut(400, function() {
                    _fader.fadeOut(200);
                    popup_f = false;
                });
            }
        }
    }
    /*--- show popup ---*/
    function showPopup() {
        _fader.css({
            opacity: 0,
            height: initH(),
            display: 'block'
        });
        _popup.css({ top: $(window).scrollTop() });
        _fader.fadeTo(400, 0.5, function() {
            if (popup_f) {
                if ($.browser.msie) _popup.show();
                else _popup.fadeIn(200, function() {
                    if (initH() < _popup.outerHeight() + _popup.offset().top) _fader.height(_popup.outerHeight() + _popup.offset().top);
                });
                _popup.css({ top: $(window).scrollTop() + ($(window).height() - _popup.outerHeight()) / 2 });
                if (initH() < _popup.outerHeight() + _popup.offset().top) _fader.height(_popup.outerHeight() + _popup.offset().top);
            }
        });
    }
    /*--- get height ---*/
    function initH() {
        var _h = $('#wrapper').outerHeight();
        if (_h < $(window).height()) _h = $(window).height();
        if (_h < $('body').height()) _h = $('body').height();
        return _h;
    }
}
/*--- initKitItems ---*/
function initKitItems() {
    $('div.kit-item-list').each(function() {
        var _hold = $(this);
        var _num = _hold.find('.kit-numb');
        var _list = _hold.find('>ul > li');
        if (_list.length < 10) _num.text('0' + _list.length);
        else _num.text(_list.length);
        _list.each(function() {
            var _el = $(this);
            var btn_remove = _el.find('a.btn-remove');
            btn_remove.click(function() {
                $.ajax({
                    url: this.href,
                    success: function() {
                        _el.animate({ height: 0, opacity: 0 }, 300, function() {
                            $(this).remove();
                            _list = _hold.find('>ul > li');
                            if (_list.length < 10) _num.text('0' + _list.length);
                            else _num.text(_list.length);
                            if (_list.length == 0) _hold.find('>ul').remove();
                        });
                    }
                });
                return false;
            });
        });
    });
}
/*--- initCompareItems ---*/
function initCompareItems() {
    $('div.compare-block').each(function() {
        var _hold = $(this);
        var _list1 = _hold.find('div.col2');
        var _list2 = _hold.find('div.col3');
        var _list3 = _hold.find('div.col4');

        _list1.find('a.btn-remove').click(function() {
            _remove(this.href, _list1);
            return false;
        });
        _list2.find('a.btn-remove').click(function() {
            _remove(this.href, _list2);
            return false;
        });
        _list3.find('a.btn-remove').click(function() {
            _remove(this.href, _list3);
            return false;
        });

        function _remove(_url, _list) {
            $.ajax({
                url: _url,
                success: function() {
                    for (var i = 0; i < _list.length; i++) {
                        _list.eq(i).css({
                            width: _list.eq(i).width(),
                            height: _list.eq(i).height(),
                            overflow: 'hidden'
                        });
                    }
                    _list.animate({ width: 0, opacity: 0 }, 300, function() { $(this).remove(); });
                }
            });
        }
    });
}
/*--- running items ---*/
function runningItems() {
    var _hold = $('#running-items');
    if (_hold.length) {
        var box_hold = _hold.find('div.product-holder');
        var _fader = $('<div class="running-fader"></div>').css({ display: 'none', opacity: 0 }).appendTo(box_hold);
        var a_box = box_hold.children('div.product-box');
        var ajax_f = true;

        _hold.find('ul.run-list a.btn-refine').click(function() {
            $(this).after('<img class="preloader" src="images/ajax-loader.gif" alt="image" />');
            if (ajax_f) {
                ajax_f = false;
                box_hold.height(box_hold.height());
                _fader.show().animate({ opacity: 0.3 }, 400);
                $(this).parents('li:eq(0)').children('a:eq(0)').trigger('click');
                a_box.removeClass('active-box').animate({ opacity: 0 }, 400, function() { $(this).remove(); });
                $.ajax({
                    url: $(this).parents('form:eq(0)').attr('action'),
                    type: 'POST',
                    data: $(this).parents('form:eq(0)').serialize(),
                    dataType: 'html',
                    success: function(_html) {
                        a_box = $(_html);
                        _fader.stop().css({ display: 'none', opacity: 0 });
                        a_box.css({ opacity: 0, display: 'block' }).appendTo(box_hold);
                        box_hold.animate({ height: a_box.outerHeight() }, 400);
                        initTooltips(a_box);
                        a_box.addClass('active-box').animate({ opacity: 1 }, 400, function() {
                            ajax_f = true;
                        });
                        $('img.preloader').remove();
                    }
                });
            }
            return false;
        });

        //KidsLanding.html
        $('.sport-select select').each(function() {
            var _f = 0;
            $(this).change(function() {
                var _this = this;
                _f++;
                if (_this.value != -1) {
                    if (_f % 2 == 1) {
                        if (ajax_f) {
                            ajax_f = false;
                            box_hold.height(box_hold.height());
                            _fader.show().animate({ opacity: 0.3 }, 400);
                            a_box.removeClass('active-box').animate({ opacity: 0 }, 400, function() { $(this).remove(); });
                            $.ajax({
                                url: _this.value,
                                type: 'POST',
                                data: 'selectedSport=' + _this.innerHTML,
                                dataType: 'html',
                                success: function(_html) {
                                    a_box = $(_html);
                                    _fader.stop().css({ display: 'none', opacity: 0 });
                                    a_box.css({ opacity: 0, display: 'block' }).appendTo(box_hold);
                                    box_hold.animate({ height: a_box.outerHeight() }, 400);
                                    initTooltips(a_box);
                                    a_box.addClass('active-box').animate({ opacity: 1 }, 400, function() {
                                        ajax_f = true;
                                    });
                                    $('img.preloader').remove();
                                }
                            });
                        }
                    }
                }
            });
        });
    }
}
$('document').ready(function() {
    $('div.news div.scrollable,div.results-scroll,.sports-news-list .scrollable').customScrollV();
    $('div.reviews input:radio').customRadio();
    $('.interests input:checkbox').customCheckbox();
    $('div.reviews select, .newsletter-signup select, .wufoo select,.sport-select select').customSelect({ maxHeight: 197 });
    $('div.map-tools select').customSelect({ maxHeight: 197 });
    $('div.progress-el').customSlider();
    $('div.refine-el').customSlider2();
    $('a.btn-return').click(function() {
        window.history.go($(this).attr('rel')); //vinh
        return false;
    });
    $('a.btn-add-comment').click(function() {
        $('body').scrollTo($('.add-comment').offset().top - 10, 400);
        return false;
    });
    $('ul.about-links a.reviews').click(function() {
        if (this.hash && this.hash.length != 1) {
            $('ul.info-tabs a.tab[hash=' + this.hash + ']').trigger('click');
            $('body').scrollTo($(this.hash).offset().top - 10, 400);
            return false;
        }
    });
    $('a.btn-print').click(function() {
        window.print(false);
        return false;
    });
    //initNewsletterSignup();
    initKitItems();
    initCompareItems();
    initPopups();
    initReviews();
    initNews();
    diffSlides();
    clearInputs();
    initTabs('.news-tabs, .info-tabs,.agenda-tabs');
    kitFunctions.init();
    promoGallery();
    technologyGallery();
    initTooltips();
    prodPhoto();
    reviewInfo();
    initRating();
    //runningItems();
    ieHover('.no-dropdown', 'first-hover');
    ieHover('.dropdown', 'second-hover');
	 ieHover('.solution', 'second-hover');
    ieHover('.accessories', 'third-hover');
    ieHover('.sports', 'forth-hover');
    ieHover('.scroll-bar .scroll-slider, .promo-box, .ads-list .col, .product-list li, .video-list li, .color-box li, .run-list li,div.map-tools span.submit-field,.athlete-list li,.add-comment .submit,.event-location,.newsletter-signup .submit,.wufoo .submit', 'hover');
    //initMap1();
    //initMap2();
});

/*--- custom scroll ---*/
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 args = [].slice.call(arguments, 1), delta = 0, returnValue = true;
    event = $.event.fix(event || window.event);
    event.type = "mousewheel";
    if (event.wheelDelta) delta = event.wheelDelta / 120;
    if (event.detail) delta = -event.detail / 3;
    args.unshift(event, delta);
    return $.event.handle.apply(this, args);
}
jQuery.fn.customScrollV = function(_options) {
    var _options = jQuery.extend({
        lineWidth: 12
    }, _options);
    return this.each(function() {
        var _box = jQuery(this);
        if (_box.is(':visible')) {
            if (_box.children('.scroll-content').length == 0) {
                var line_w = _options.lineWidth;
                /*--- init part ---*/
                var scrollBar = jQuery('<div class="scroll-bar"><div class="scroll-up"></div><div class="scroll-line"><div class="scroll-slider"></div></div><div class="scroll-down"></div></div>');
                _box.wrapInner('<div class="scroll-content"><div class="scroll-hold"></div></div>').append(scrollBar);
                var scrollContent = _box.children('.scroll-content');
                var scrollSlider = scrollBar.find('.scroll-slider');
                var scrollSliderH = scrollSlider.parent();
                var scrollUp = scrollBar.find('.scroll-up');
                var scrollDown = scrollBar.find('.scroll-down');
                /*--- different variables ---*/
                var box_h = _box.height();
                var slider_h = 0;
                var slider_f = 0;
                var cont_h = scrollContent.height();
                var _f = false;
                var _f1 = false;
                var _f2 = true;
                var _t1, _t2, _s1, _s2;
                /*--- set styles ---*/
                _box.css({
                    position: 'relative',
                    overflow: 'hidden',
                    height: box_h
                });
                scrollContent.css({
                    position: 'absolute',
                    top: 0,
                    left: 0,
                    zIndex: 1,
                    height: 'auto'
                });
                scrollBar.css({
                    position: 'absolute',
                    top: 0,
                    right: 0,
                    zIndex: 2,
                    width: line_w,
                    height: box_h,
                    overflow: 'hidden'
                });
                scrollUp.css({
                    width: line_w,
                    height: line_w,
                    overflow: 'hidden',
                    cursor: 'pointer'
                });
                scrollDown.css({
                    width: line_w,
                    height: line_w,
                    overflow: 'hidden',
                    cursor: 'pointer'
                });
                slider_h = scrollBar.height();
                if (scrollUp.is(':visible')) slider_h -= scrollUp.height();
                if (scrollDown.is(':visible')) slider_h -= scrollDown.height();
                scrollSliderH.css({
                    position: 'relative',
                    width: line_w,
                    height: slider_h,
                    overflow: 'hidden'
                });
                slider_h = 0;
                scrollSlider.css({
                    position: 'absolute',
                    top: 0,
                    left: 0,
                    width: line_w,
                    height: slider_h,
                    overflow: 'hidden',
                    cursor: 'pointer'
                });
                box_h = _box.height();
                cont_h = scrollContent.height();
                if (box_h < cont_h) {
                    _f = true;
                    slider_h = Math.round(box_h / cont_h * scrollSliderH.height());
                    if (slider_h < 5) slider_h = 5;
                    scrollSlider.height(slider_h);
                    slider_h = scrollSlider.outerHeight();
                    slider_f = (cont_h - box_h) / (scrollSliderH.height() - slider_h);
                    _s1 = (scrollSliderH.height() - slider_h) / 10;
                    _s2 = (scrollSliderH.height() - slider_h) / 3;
                    scrollContent.children('.scroll-hold').css('padding-right', scrollSliderH.width());
                }
                else {
                    _f = false;
                    scrollBar.hide();
                    scrollContent.css({ width: _box.width(), top: 0, left: 0 });
                    scrollContent.children('.scroll-hold').css('padding-right', 0);
                }
                var _top = 0;
                /*--- element's events ---*/
                scrollUp.mousedown(function() {
                    _top -= _s1;
                    scrollCont();
                    _t1 = setTimeout(function() {
                        _t2 = setInterval(function() {
                            _top -= 4 / slider_f;
                            scrollCont();
                        }, 20);
                    }, 500);
                }).mouseup(function() {
                    if (_t1) clearTimeout(_t1);
                    if (_t2) clearInterval(_t2);
                }).mouseleave(function() {
                    if (_t1) clearTimeout(_t1);
                    if (_t2) clearInterval(_t2);
                });
                scrollDown.mousedown(function() {
                    _top += _s1;
                    scrollCont();
                    _t1 = setTimeout(function() {
                        _t2 = setInterval(function() {
                            _top += 4 / slider_f;
                            scrollCont();
                        }, 20);
                    }, 500);
                }).mouseup(function() {
                    if (_t1) clearTimeout(_t1);
                    if (_t2) clearInterval(_t2);
                }).mouseleave(function() {
                    if (_t1) clearTimeout(_t1);
                    if (_t2) clearInterval(_t2);
                });
                scrollSliderH.click(function(e) {
                    if (_f2) {
                        _top = e.pageY - scrollSliderH.offset().top;
                        /*
                        if(scrollSlider.offset().top + slider_h < e.pageY) _top += _s2;
                        else if(scrollSlider.offset().top > e.pageY) _top -= _s2;
                        */
                        scrollCont();
                    }
                    else {
                        _f2 = true;
                    }
                });
                var t_y = 0;
                scrollSlider.mousedown(function(e) {
                    t_y = e.pageY - $(this).position().top;
                    _f1 = true;
                }).mouseup(function() {
                    _f1 = false;
                });
                $('body').mousemove(function(e) {
                    if (_f1) {
                        _f2 = false;
                        _top = e.pageY - t_y;
                        scrollCont();
                    }
                }).mouseup(function() {
                    _f1 = false;
                });
                document.body.onselectstart = function() {
                    if (_f1) return false;
                }
                _box.bind('mousewheel', function(event, delta) {
                    if (_f) {
                        _top -= delta * _s1;
                        scrollCont();
                        if ((_top > 0) && (_top + slider_h < scrollSliderH.height())) return false;
                    }
                });
                function scrollCont() {
                    if (_top < 0) _top = 0;
                    else if (_top + slider_h > scrollSliderH.height()) _top = scrollSliderH.height() - slider_h;
                    scrollSlider.css('top', _top);
                    scrollContent.css('top', -_top * slider_f);
                }
                this.scrollResize = function() {
                    box_h = _box.height();
                    cont_h = scrollContent.height();
                    if (box_h < cont_h) {
                        _f = true;
                        scrollBar.show();
                        slider_h = Math.round(box_h / cont_h * scrollSliderH.height());
                        if (slider_h < 5) slider_h = 5;
                        scrollSlider.height(slider_h);
                        slider_h = scrollSlider.outerHeight();
                        slider_f = (cont_h - box_h) / (scrollSliderH.height() - slider_h);
                        if (cont_h + scrollContent.position().top < box_h) scrollContent.css('top', -(cont_h - box_h));
                        _top = -scrollContent.position().top / slider_f;
                        scrollSlider.css('top', _top);
                        _s1 = (scrollSliderH.height() - slider_h) / 15;
                        _s2 = (scrollSliderH.height() - slider_h) / 3;
                        scrollContent.children('.scroll-hold').css('padding-right', scrollSliderH.width());
                    }
                    else {
                        _f = false;
                        scrollBar.hide();
                        scrollContent.css({ top: 0, left: 0 });
                        scrollContent.children('.scroll-hold').css('padding-right', 0);
                    }
                }
                /*
                setInterval(function(){
                if(_box.is(':visible') && cont_h != scrollContent.height()) _box.get(0).scrollResize();
                }, 200);
                */
            }
            else {
                this.scrollResize();
            }
        }
    });
}
/*--- custom checkbox's ---*/
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) {
        if (_this.is(':checked')) _this.get(0)._replaced.removeClass().addClass(_options.checkboxChecked);
        else _this.get(0)._replaced.removeClass().addClass(_options.checkboxDefault);
        if (typeof (_this.change) == 'function') _this.change();
        if (typeof (_this.get(0).onchange) == 'function') _this.get(0).onchange();
    }
}
/*--- custom radio's ---*/
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) {
        $('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);
        if (typeof ($(_this).change) == 'function') $(_this).change();
        if (typeof (_this.onchange) == 'function') _this.onchange();
    }
}
/*--- custom select's ---*/
jQuery.fn.customSelect = function(_options) {
    var _options = jQuery.extend({
        selectStructure: '<div class="selectArea"><div class="left"></div><div class="center"></div><a href="#" class="selectButton">&nbsp;</a><div class="disabled"></div></div>',
        selectText: '.center',
        selectBtn: '.selectButton',
        selectDisabled: '.disabled',
        optStructure: '<div class="selectOptions"><div class="select-top"></div><div class="select-list"><ul></ul></div><div class="select-bottom"></div></div>',
        optList: 'ul',
        maxHeight: 99999
    }, _options);
    return this.each(function() {
        var select = jQuery(this);
        if (!select.hasClass('outtaHere')) {
            if (select.is(':visible')) {
                var replaced = jQuery(_options.selectStructure);
                var selectText = replaced.find(_options.selectText);
                var selectBtn = replaced.find(_options.selectBtn);
                var selectDisabled = replaced.find(_options.selectDisabled).hide();
                var optHolder = jQuery(_options.optStructure);
                var optList = optHolder.find(_options.optList);
                var maxH = _options.maxHeight;
                if (select.attr('disabled')) selectDisabled.show();
                select.find('option').each(function() {
                    var selOpt = $(this);
                    var _opt = jQuery('<li><a href="#"><span>' + selOpt.html() + '</span></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('selectAreaActive');
                        if (typeof (select.change) == 'function') select.change();
                        if (typeof (select.get(0).onchange) == 'function') select.get(0).onchange();
                        return false;
                    });
                    optList.append(_opt);
                });
                replaced.width(select.outerWidth());
                replaced.insertBefore(select);
                optHolder.css({
                    width: select.outerWidth(),
                    display: 'none',
                    position: 'absolute'
                });
                if (select.attr('class') && select.attr('class') != '')
                    optHolder.addClass('drop-' + select.attr('class').split(' ')[0]);
                jQuery(document.body).append(optHolder);

                var optTimer;
                replaced.hover(function() {
                    if (optTimer) clearTimeout(optTimer);
                }, function() {
                    optTimer = setTimeout(function() {
                        optHolder.hide();
                        replaced.removeClass('selectAreaActive');
                    }, 200);
                });
                optHolder.hover(function() {
                    if (optTimer) clearTimeout(optTimer);
                }, function() {
                    optTimer = setTimeout(function() {
                        optHolder.hide();
                        replaced.removeClass('selectAreaActive');
                    }, 200);
                });
                selectBtn.click(function() {
                    if (optHolder.is(':visible')) {
                        optHolder.hide();
                        replaced.removeClass('selectAreaActive');
                    }
                    else {
                        replaced.addClass('selectAreaActive');
                        optHolder.css({
                            top: replaced.offset().top + replaced.outerHeight(),
                            left: replaced.offset().left,
                            display: 'block'
                        });
                        if (optHolder.children('div.select-list').height() > maxH) optHolder.children('div.select-list').css({ height: maxH, overflow: 'auto' }).customScrollV();
                    }
                    return false;
                });
                select.addClass('outtaHere');
            }
        }
    });
}
/*--- custom slider ---*/
jQuery.fn.customSlider = function(_options) {
    var _options = jQuery.extend({
        sliderStructure: '<div class="progress-holder"></div>',
        sliderLine: '<div class="status"><div>&nbsp;</div><span>&nbsp;</span></div>',
        sliderBtn: '<span class="slider">button</span>',
        min: 0,
        max: 100
    }, _options);
    return this.each(function() {
        var slider_hold = jQuery(this);
        if (!slider_hold.data('slider_f') && slider_hold.is(':visible')) {
            slider_hold.data('slider_f', true);
            var _hold = jQuery(_options.sliderStructure);
            var _line = jQuery(_options.sliderLine);
            var _btn = jQuery(_options.sliderBtn);
            var _info = slider_hold.find('input');
            var _min = _options.min;
            var _max = _options.max;
            _hold.append(_line).append(_btn);
            slider_hold.append(_hold);

            var _curr = parseInt(_info.val());

            if (_min > _max) {
                _min = _options.max;
                _max = _options.min;
            }
            if (!_curr || isNaN(_curr)) _curr = _min;
            if (_curr < _min) _curr = _min;
            else if (_curr > _max) _curr = _max;

            var _step = _hold.outerWidth() / (_max - _min);

            _line.css('width', (_curr - _min) * _step);
            _btn.css('left', (_curr - _min) * _step);
            _info.val(_curr);

            var _f = false;
            _btn.mousedown(function(e) {
                _f = true;
            }).mouseup(function() {
                _f = true;
            });
            _hold.click(function(e) {
                _curr = _min + Math.round((e.pageX - _hold.offset().left) / _step);
                if (_curr < _min) _curr = _min;
                else if (_curr > _max) _curr = _max;
                _line.css('width', (_curr - _min) * _step);
                _btn.css('left', (_curr - _min) * _step);
                _info.val(_curr);
                return false;
            }).mousemove(function(e) {
                if (_f) {
                    _curr = _min + Math.round((e.pageX - _hold.offset().left) / _step);
                    if (_curr < _min) _curr = _min;
                    else if (_curr > _max) _curr = _max;
                    _line.css('width', (_curr - _min) * _step);
                    _btn.css('left', (_curr - _min) * _step);
                    _info.val(_curr);
                }
            });
            jQuery('body').mouseup(function() {
                if (_f) _f = false;
            });
            if (window.attachEvent && !window.opera) document.body.attachEvent('onselectstart', function() { if (_f) return false; });
            _hold.css({ '-moz-user-select': 'none', '-khtml-user-select': 'none', 'user-select': 'none' });
        }
    });
}
/*--- custom slider 2 ---*/
jQuery.fn.customSlider2 = function(_options) {
    var _options = jQuery.extend({
        sliderStructure: '<div class="refine-slider"></div>',
        sliderLine: '<div class="line"></div>',
        sliderEl: '<span class="text-el"></span>',
        sliderBtn: '<span class="slider">slider</span>',
        btnPrev: '<a href="#" class="left">left</a>',
        btnNext: '<a href="#" class="right">right</a>',
        activeClass: 'active-el'
    }, _options);
    return this.each(function() {
        var slider_hold = jQuery(this);
        if (!slider_hold.data('slider_f') && slider_hold.is(':visible')) {
            slider_hold.data('slider_f', true);
            var _hold = jQuery(_options.sliderStructure);
            var _line = jQuery(_options.sliderLine);
            var _slider = jQuery(_options.sliderBtn);
            var btn_prev = jQuery(_options.btnPrev);
            var btn_next = jQuery(_options.btnNext);
            var activeClass = _options.activeClass;
            var _list = slider_hold.find('select option');
            var _a = (_list.index(_list.filter(':selected')) != -1) ? (_list.index(_list.filter(':selected'))) : (0);

            for (var i = 0; i < _list.length; i++) {
                jQuery(_options.sliderEl).text(_list.eq(i).text()).appendTo(_line);
            }
            var _btn = _line.find('.' + jQuery(_options.sliderEl).attr('class'));
            _line.append(_slider);
            _hold.append(_line).append(btn_prev).append(btn_next);
            slider_hold.append(_hold);

            var t_w = _line.width();
            for (var i = 0; i < _btn.length; i++) {
                t_w -= _btn.eq(i).outerWidth();
            }
            if (t_w > 0) {
                var t_p = Math.floor(t_w / _btn.length / 2);
                t_w = _line.width();
                if (t_p * 2 + _btn.filter(':first').width() < _slider.outerWidth()) {
                    _btn.filter(':first').width(_slider.outerWidth());
                    _btn = _btn.not(':first');
                    t_w -= _slider.outerWidth();
                }
                if (t_p * 2 + _btn.filter(':last').width() < _slider.outerWidth()) {
                    _btn.filter(':last').width(_slider.outerWidth());
                    _btn = _btn.not(':last');
                    t_w -= _slider.outerWidth();
                }
                for (var i = 0; i < _btn.length; i++) {
                    t_w -= _btn.eq(i).outerWidth();
                }
                if (t_w > 0) {
                    t_p = Math.ceil(t_w / _btn.length / 2);
                    _btn.css({ paddingLeft: t_p, paddingRight: t_p });

                    t_w -= _btn.length * 2 * t_p;
                    if (t_w < 0) {
                        for (var i = 0; i < Math.ceil(-t_w / 2); i++) {
                            _btn.eq(i).css({ paddingLeft: t_p - 1, paddingRight: t_p - 1 });
                        }
                    }
                }
            }
            _btn = _line.find('.' + jQuery(_options.sliderEl).attr('class'));
            _list.removeAttr('selected').eq(_a).attr('selected', true);
            _btn.eq(_a).addClass(activeClass);

            for (var i = 0; i < _btn.length; i++) {
                _btn.eq(i).data('pos', _btn.eq(i).position().left + _btn.eq(i).outerWidth() / 2);
            }
            var _f = false, t_l = 0, slider_l = 0, t_pos = 0, slider_w = _slider.outerWidth(), line_w = _line.outerWidth(), t_a = -1;
            _slider.css('left', _btn.eq(_a).data('pos') - 5 - slider_w / 2);


            _btn.click(function() {
                changeEl(_btn.index(this));
            });
            btn_prev.click(function() {
                if (_a > 0) changeEl(_a - 1);
                return false;
            });
            btn_next.click(function() {
                if (_a < _list.length - 1) changeEl(_a + 1);
                return false;
            });
            function changeEl(_ind) {
                if (_a != _ind) {
                    _list.eq(_a).removeAttr('selected');
                    _list.eq(_ind).attr('selected', true);
                    _btn.eq(_a).removeClass(activeClass);
                    _btn.eq(_ind).addClass(activeClass);
                    _slider.animate({ left: _btn.eq(_ind).data('pos') - slider_w / 2 }, { queue: false, duration: 200 });
                    _a = _ind;
                }
            }
            _line.mousedown(function(e) {
                if (e.pageX > _slider.offset().left && e.pageX < _slider.offset().left + _slider.outerWidth()) {
                    _f = true;
                    t_l = e.pageX;
                    slider_l = _slider.position().left;
                    _hold.addClass('moved');
                }
                return false;
            }).mousemove(function(e) {
                if (_f) {
                    t_pos = e.pageX - t_l + slider_l;
                    if (t_pos < 0) t_pos = 0;
                    else if (t_pos + slider_w > line_w) t_pos = line_w - slider_w;
                    _slider.css('left', t_pos);
                    t_a = -1;
                    for (var i = 0; i < _btn.length - 1; i++) {
                        if (t_pos + slider_w / 2 >= _btn.eq(i).data('pos') && t_pos + slider_w / 2 < _btn.eq(i + 1).data('pos')) {
                            if (t_pos + slider_w / 2 - _btn.eq(i).data('pos') > _btn.eq(i + 1).data('pos') - t_pos - slider_w / 2) t_a = i + 1;
                            else t_a = i;
                            break;
                        }
                    }
                    if (t_a == -1) t_a = _list.length - 1;
                    if (t_a != _a) {
                        _list.eq(_a).removeAttr('selected');
                        _list.eq(t_a).attr('selected', true);
                        _btn.eq(_a).removeClass(activeClass);
                        _btn.eq(t_a).addClass(activeClass);
                        _a = t_a;
                    }
                }
            }).mouseup(function() {
                _f = false;
                _hold.removeClass('moved');
                _slider.animate({ left: _btn.eq(_a).data('pos') - slider_w / 2 }, { queue: false, duration: 100 });
                return false;
            });
            $('body').mouseup(function() {
                if (_f) {
                    _f = false;
                    _hold.removeClass('moved');
                    _slider.animate({ left: _btn.eq(_a).data('pos') - slider_w / 2 }, { queue: false, duration: 100 });
                }
            });

            if (window.attachEvent && !window.opera) document.body.attachEvent('onselectstart', function() { if (_f) return false; });
            _hold.css({ '-moz-user-select': 'none', '-khtml-user-select': 'none', 'user-select': 'none' });
        }
    });
}

/**
* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
* Author: Drew Diller
* Email: drew.diller@gmail.com
* URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/
* Version: 0.0.8a
* Licensed under the MIT License: http://dillerdesign.com/experiment/DD_belatedPNG/#license
*
* Example usage:
* DD_belatedPNG.fix('.png_bg'); // argument is a CSS selector
* DD_belatedPNG.fixPng( someNode ); // argument is an HTMLDomElement
**/
//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('.product-img');
