﻿///<reference path="jquery-1.3.2-vsdoc.js"/>
/* +++ GENERAL ALL-PAGE JS +++ */
$j(document).ready(function() {
    // Replace links with buttons (do before Cufon and DD_belated)
    $j('a[class^=BTNbtn]').each(function(i, e) {
        $j(this).wrap('<span class="' + $j(this).attr('class').substr(3) + '"></span>')
        .after('<span class="right"></span>')
        .attr('class', '');
        if ($j.browser.msie && parseInt($j.browser.version) <= 6) {
            $j(this).hover(function() {
                $j(this).add($j(this).parent().add($j(this).next())).css('background-position', 'left bottom');
            }, function() {
                $j(this).add($j(this).parent().add($j(this).next())).css('background-position', 'left top');
            });
        }
    });
    if ($j.browser.msie && parseInt($j.browser.version) <= 6) {
        // Apply PNG-fix for IE6
        $j("img[src$j='png']").each(function() {
            if (!$j(this).hasClass('noPngFix')) {
                DD_belatedPNG.fixPng(this);
            }
        });
        $j('div, span, a, input, li, dt, ul, #slideSearch, #slideSearch div.i1, #slideSearch div.i2').filter(function() {
            if ($j(this).css('backgroundImage').match('.png') == '.png')
                return true;
            else
                return false;
        }).not('#topPlaceholder').each(function() {
            DD_belatedPNG.fixPng(this);
        });
        $j('.navigationSearchSubmit, .footerSubmit input').hover(function() {
            $j(this).css('background-position', 'left bottom !important');
        }, function() {
            $j(this).css('background-position', 'left top !important');
        });
        // Fix init scrollable prevPage
        var prevPage = $j('.prevPage');
        if (prevPage.length > 0) {
            prevPage.css('background-position', 'bottom');
            prevPage.attr('style', prevPage.attr('style').replace(/background-position.*m;/i, ''));
        }
    }
    $j('.prevPage, .nextPage').click(function() {
        return false;
    });
    Cufon.replace('.btnGreyPlain a, .btnGrey a, .btnGreySmall a, .btnGreyMedium a, .btnGreyPlainTiny a', {
        fontFamily: 'boton',
        textShadow: '1px 1px #ffffff',
        hover: true
    });
    Cufon.replace('.btnBlackBig a, .btnBlack a, .btnBlackHalf a, .btnBlackOversized a', {
        fontFamily: 'boton',
        textShadow: '1px 1px #444444'
    });
    Cufon.replace('.btnGreen a, .btnGreenSmall a, .btnGreenMedium a, .btnGreenBig a', {
        fontFamily: 'boton',
        textShadow: '1px 1px #05540a'
    });
    
    //Startpage buttons
    Cufon.replace('.startpage-puff .button.redPlain a', {
        fontFamily: 'boton',
        textShadow: '1px 1px #960224',
        hover: true
    });
    Cufon.replace('.startpage-puff .button.orangePlain a', {
        fontFamily: 'boton',
        textShadow: '1px 1px #963502',
        hover: true
    });
    Cufon.replace('.startpage-puff .button.pinkPlain a', {
        fontFamily: 'boton',
        textShadow: '1px 1px #8c084b',
        hover: true
    });
    //End startpagebuttons
    Cufon.replace('.footer h4, .navigationLeftMenu span.top a, .t1000Carousel .menu a', { fontFamily: 'boton', hover: true });
    Cufon.replace('h1[class!=noCufon], h2[class!=noCufon], h3[class!=noCufon], h4[class!=noCufon], h5[class!=noCufon]', { fontFamily: 'boton' });
    Cufon.replace('#t4400 #login label, #t4400 .menu > a, .navigationDetails a, .navigationSubMenu a, .mainContentTopTabbs ul li h5', { fontFamily: 'botonRegular', hover: true });
    Cufon.replace('h3.nobold, h4.nobold,h5.nobold', { fontFamily: 'botonRegular' });
    Cufon.replace('.size1, .size2, .size3, .size4, .size5, .size6, .size7, ,.mainContentTopTabbs ul .selected h5', { fontFamily: 'boton', hover: true });
    Cufon.replace('.navigationPrePostPaid a', { fontFamily: 'boton', hover: true });
    String.prototype.trim = function() {
        return this.replace(/^\s+|\s+$j/g, '');
    }
    // Text boxes and textfields
    $j("input[type!='submit'], textarea").focus(function() {
        if (this.value == this.defaultValue)
            this.value = '';
    }).blur(function() {
        if (this.value.trim() == '')
            this.value = this.defaultValue;
    });
    // Select boxes
    $j('select[class!=noSelect]').selectBox({
        'callOnLoad': function() { if ($j.browser.msie && parseInt($j.browser.version) <= 6) { DD_belatedPNG.fix('.sb-btn, .sb-top'); } },
        'callBack': function() { if ($j.browser.msie && parseInt($j.browser.version) <= 6) { DD_belatedPNG.fix('.sb-list , .sb-slideBottom'); } }
    });
    // Checkboxes and radio buttons
    if ($j.fn.checkbox) {
        // disable for IE6 
        if (!$j.browser.msie || ($j.browser.msie && parseInt($j.browser.version) > 6)) {
            $j('input:checkbox').checkbox({
                empty: '/system_images/empty.png'
            });
            $j('input:radio').checkbox({
                empty: '/system_images/empty.png',
                cls: 'jquery-radiobutton'
            });
        }
    }
    /* +++ DROP-DOWN-MENU +++ */
    var closeDropDownTimeOut;
    var closeDropDownWaitCount = 0;
    var closeDropDownWaitCountMax = 8;
    var delay = 100; // e.g. 200 ms * 10 = 2 sec
    var cS = { isHoveringSomething: 0, isHoveringDropDown: 1, isHoveringNothing: 2 };
    var cursorStatus = cS.isHoveringNothing;
    $j('.navigationSubMenu a').hover(function() {
        cursorStatus = cS.isHoveringSomething;
        openDropDown(this);
    }, function() {
        cursorStatus = cS.isHoveringNothing;
        closeDropDown();
    });
    $j('.navigationDropDown').hover(function() {
        cursorStatus = cS.isHoveringSomething;
    }, function() {
        cursorStatus = cS.isHoveringNothing;
        closeDropDown();
    });
    var openDropDown = function(obj) {
        var dropDown = $j('.navigationDropDown');
        if ($j('.navigation').offset().left > 0)
            var newLeft = $j(obj).offset().left - $j('.navigation').offset().left - 10 + 'px';
        else
            var newLeft = $j(obj).offset().left - $j('.navigationBusinessWrapper').offset().left - 10 + 'px';
        if (dropDown.css('top') != '117px' || dropDown.css('left') != newLeft) {
            var arr = $j(obj).attr('class').split(' '), foundClass;
            for (var i = 0; i < arr.length; i++) {
                if (arr[i].match('navigationSubMenuItem') == 'navigationSubMenuItem') {
                    foundClass = arr[i];
                    break;
                }
            }
            $j('.navigationDropDownContent:visible').hide();
            $j('.' + foundClass + ':last').show();
            dropDown.queue([]).stop()
            .css({ 'left': newLeft, 'top': '-' + $j('.navigationDropDown').height() + 'px' })
            .animate({
                top: '117px'
            }, 300, 'easeOutExpo');
        }

    };
    var closeDropDown = function() {
        if (cursorStatus != cS.isHoveringSomething) {
            clearTimeout(closeDropDownTimeOut);
            if (closeDropDownWaitCount >= closeDropDownWaitCountMax) {
                closeDropDownWaitCount = 0;
                closeDropDownDefinitely();
            }
            else if (closeDropDownWaitCount > 0) {
                closeDropDownWaitCount++;
                closeDropDownTimeOut = setTimeout(closeDropDown, delay);
            }
            else {
                closeDropDownWaitCount++;
                closeDropDownTimeOut = setTimeout(closeDropDown, delay);
            }
        }
    };
    var closeDropDownDefinitely = function() {
        $j('.navigationDropDown').queue([]).stop().animate({
            top: '-' + $j('.navigationDropDown').height() + 'px'
        }, 300, 'easeInExpo');
    };
    $j('.navigationDropDownContent:visible').hide();
    /* --- DROP-DOWN-MENU --- */
    $j(".lightBoxLayer .close").live("click", function() {
        hideLightBox();
        return false;
    });
    $j('.shadowedTabs').tabs({
        collapsible: false,
        selected: 0,
        show: function() {
            Cufon.replace('.shadowedTabs .panelWrapper h5', { fontFamily: 'botonRegular' });
            Cufon.replace('.shadowedTabs .panelWrapper .ui-tabs-selected h5', { fontFamily: 'boton' });
            fixShowIE6();
            if($j(".shadowedTabs a[href='#tab5']").parent().parent('li').hasClass('ui-tabs-selected')){
                rnd = function(mi, ma) {
                    return Math.floor((ma-(mi-1))*Math.random()) + mi
                };
                $j(".cordovan-bargraph .bars").cordovanBars([rnd(250, 500), rnd(250, 500), rnd(250, 500), rnd(250, 500), rnd(250, 500)], 10);
            }
        }
    });
    $j(window).scroll(function() {
        positionLightBox();
    }).resize(function() {
        positionLightBox(true);
    });
    $j(".lightBoxCurtainLayer").click(function() {
        hideLightBox();
    });
});

var T7100 = function() {
    $j(".signInBox a").click(function(){
        $j(".signInBox form").submit();
    });
};
t4050 = function(){
    $j("#t4050 td").hover(function(){
        $j(this).addClass("hoverBg");
    }, function(){
        $j(this).removeClass("hoverBg");
    });
    $j("#t4050 .big li:first").show();
    $j("#t4050 td a").click(function(){
        a = $j(this);
        $j("#t4050 .big li").hide();
        href = a.attr("href");
        $j("#t4050 .big #" + href.substr(1, href.length)).show();
        return false;
    });
    
};
t7000 = function(){
    
    $j(".createWrapperHtml").cordovanTicker({
        wrapperClass: "cordovan-ticker"
    });
};

// var positionLightBox = function(setPos) {
//     if ($j(".lightBoxLayer").is(":visible")) {
//         win = jsTools.windowSize();
//         div = jsTools.size($j(".lightBoxLayer"));
// 
//         pos = {
//             x: ((win.w / 2) - (div.w / 2)) + jsTools.scrollOffsetX(),
//             y: ((win.h / 2) - (div.h / 2)) + jsTools.scrollOffsetY()
//         };
// 
//         if (setPos) {
//             $j(".lightBoxLayer").css({
//                 "top": pos.y + "px",
//                 "left": pos.x + "px"
//             });
//         } else {
//             $j(".lightBoxLayer").stop().animate({
//                 "top": pos.y + "px",
//                 "left": pos.x + "px"
//             });
//         }
//     }
// };
var jsTools = {
    scrollOffsetY: function() {
        if (document.body.scrollTop == 0) {
            if (window.pageYOffset) {
                return window.pageYOffset;
            } else {
                return (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
            }
        }
        return document.body.scrollTop;
    },
    scrollOffsetX: function() {
        if (document.body.scrollLeft == 0) {
            if (window.pageXOffset) {
                return window.pageXOffset;
            } else {
                return (document.body.parentElement) ? document.body.parentElement.scrollLeft : 0;
            }
        }
        return document.body.scrollLeft;
    },
    scrollOffset: function() {
        return { x: jsTools.scrollOffsetX(), y: jsTools.scrollOffsetY() };
    },
    size: function(obj) {
        return { w: $j(obj).width(), h: $j(obj).height() };
    },
    windowSize: function() {
        return jsTools.size(window);
    }
};
var fixSeekIE6 = function() {
    if ($j.browser.msie && parseInt($j.browser.version) <= 6) {
        if (this.getRoot().parent().find('.prevPage').length > 0) {
            var prevPage = this.getRoot().parent().find('.prevPage');
            var nextPage = this.getRoot().parent().find('.nextPage');
        }
        else if (this.getRoot().parent().parent().find('.prevPage').length > 0) {
            var prevPage = this.getRoot().parent().parent().find('.prevPage');
            var nextPage = this.getRoot().parent().parent().find('.nextPage');
        }
        else if (this.getRoot().find('.prevPage').length > 0) {
            var prevPage = this.getRoot().find('.prevPage');
            var nextPage = this.getRoot().find('.nextPage');
        }
        else
            return true;
        // if active page is on the right - enable prevPage btn
        if (this.getPageIndex() > 0) {
            prevPage.css('background-position', 'top');
            prevPage.attr('style', prevPage.attr('style').replace(/background-position.*p;/i, ''));
        }
        else { // if active page is first page - disable prevPage btn
            prevPage.css('background-position', 'bottom');
            prevPage.attr('style', prevPage.attr('style').replace(/background-position.*m;/i, ''));
        }
        // if it's the last page - disable nextPage btn
        if (this.getPageIndex() == this.getPageAmount() - 1) {
            nextPage.css('background-position', 'bottom');
            nextPage.attr('style', nextPage.attr('style').replace(/background-position.*m;/i, ''));
        }
        else { // else, enable nextPage btn
            nextPage.css('background-position', 'top');
            nextPage.attr('style', nextPage.attr('style').replace(/background-position.*p;/i, ''));
        }
    }
};
var fixShowIE6 = function() {
    if ($j.browser.msie && parseInt($j.browser.version) <= 6) {
        $j('.genericTabs > shape').hide();
        $j('.genericTabs > shape:first').show().next().show();
        $j('.genericTabs .content:visible, .genericTabs .contentNoPadding:visible').prev().show().prev().show();
    }
};
var showLightBox = function() {
    $j(".lightBoxCurtainLayer").css("height", $j(document).height() + "px").fadeIn("slow");
    $j(".lightBoxLayer").fadeIn("slow");
    positionLightBox(true);
};
var hideLightBox = function() {
    $j(".lightBoxLayer, .lightBoxCurtainLayer").fadeOut("slow");
};
/* --- GENERAL ALL-PAGE JS --- */
/* +++ TEMPLATE SPECIFIC +++ */
var T100 = function() {
    $j('.smallGenericCarousel .nextPage, .smallGenericCarousel .prevPage').click(function() {
        return false;
    });
    $j('.smallGenericCarousel .scrollPhones').scrollable({
        size: 5,
        prevPage: '.prevPage',
        nextPage: '.nextPage',
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        onSeek: fixSeekIE6
    });
    $j('#accordion100 .header').click(function() {
        var that = $j(this);
        var thatCH = that.children('.arrow');
        that.next().slideToggle('fast');
        if (thatCH.hasClass('openContainer')) {
            thatCH.removeClass('openContainer');
        } else {
            thatCH.addClass('openContainer');
        }
        return false;
    });
    /*   Carousel phone fix   */
    $j('.expandBox').hide();
    var swi = false, memEle = false, leftOut = false, isCorner = false;
    var lastEle = $j('#t100 .smallGenericCarousel .genericScrollable .items .products');
    if (lastEle.length <= 5) { $j('.nextPage, .prevPage').hide() }
    var eleNr = (lastEle.length - 2);
    $j('#t100 .smallGenericCarousel .genericScrollable .items div').click(function() {
        var that = $j(this);
        $j('.expandBox').hide();
        var thatExpobox = that.children('.expandBox');
        var hitNow = lastEle.index(this);
        //alert(hitNow);
        var theArr = [3, 4, 8, 9, 13, 14, 18, 19, 23, 24, 28, 29, 33, 34, 38, 39, 43, 44], theArrNr = $j.inArray(hitNow, theArr);
        isCorner = (theArrNr == -1) ? false : true;
        if (that.width() < 180 && swi === false) {
            if (hitNow > eleNr || isCorner) {
                var item = $j('.items');
                var itemOff = item.position().left;
                item.animate({ 'left': (itemOff - 135) + 'px' }, 300);
                leftOut = true;
            }
            that.animate({ 'width': '250px' }, 300);
            thatExpobox.show();
            swi = true;
            memEle = that;
        } else if (that.width() < 180 && swi === true) {
            if (leftOut) {
                var item = $j('.items');
                var itemOff = item.position().left;
                item.animate({ 'left': (itemOff + 135) + 'px' }, 300);
                leftOut = false;
            }
            memEle.animate({ 'width': '116px' }, 300, function() {
                that.animate({ 'width': '250px' }, 300);
                if (hitNow > eleNr || isCorner) {
                    var item = $j('.items');
                    var itemOff = item.position().left;
                    item.animate({ 'left': (itemOff - 135) + 'px' }, 300);
                    leftOut = true;
                }
                thatExpobox.show();
            });
            memEle = that;
            swi = true;
        } else if (that.width() > 180 && swi === true) {
            if (leftOut) {
                var item = $j('.items');
                var itemOff = item.position().left;
                item.animate({ 'left': (itemOff + 135) + 'px' }, 300);
                leftOut = false;
            }
            that.animate({ 'width': '116px' }, 300, function() {
            });
            swi = false;
        }
    });
};

var T1000 = function() {
    swfobject.embedSWF("flash/carouselBgColorFade.swf", "topPlaceholder", "100%", "340", "8.0.0", false, { backgroundcolor: '0x00FF00' }, { wmode: 'opaque' });
    /* Scroll start */
    var scrolls = { Phones: 4, Subscriptions: 3, Bundles: 3, Accessories: 3 };
    var scrollNumber = 1;
    var timeout = 5000;
    var isClicked = false;
    $j.each(scrolls, function(key, value) {
        $j('.t1000Carousel .menu a[href=#' + key.toLowerCase() + ']').click(function() {
            showScroll(key);
            if (key == 'Phones') {
                scrollNumber = 1;
            }
            else if (key == 'Subscriptions') {
                scrollNumber = 2;
            }
            else if (key == 'Bundles') {
                scrollNumber = 3;
            }
            else if (key == 'Accessories') {
                scrollNumber = 0;
            }
            return false;
        });
        $j('.t1000Carousel #scroll' + key).scrollable({
            size: value,
            prevPage: '#' + key.toLowerCase() + ' .prevPage',
            nextPage: '#' + key.toLowerCase() + ' .nextPage',
            easing: 'easeOutCirc',
            speed: 1000,
            keyboard: false,
            clickable: false,
            onSeek: fixSeekIE6
        });
        var itemsLength = $j('.t1000Carousel #scroll' + key + ' .items > *').length;
        if (itemsLength <= value) {
            $j('#' + key.toLowerCase() + ' .prevPage, #' + key.toLowerCase() + ' .nextPage').addClass('disabled');
        }
    });

    var showScroll = function(scroll) {
        $j('.menu ul li').removeClass('selected');
        if ($j.browser.msie && parseInt($j.browser.version) <= 6) {
            $j('.menu ul li[class!=selected] a').css('background-position', '-9999px');
        }
        $j('.t1000Carousel .menu a[href=#' + scroll.toLowerCase() + ']').parent('h5').parent('li').addClass('selected');
        if ($j.browser.msie && parseInt($j.browser.version) <= 6) {
            $j('.menu ul a[href=#' + scroll.toLowerCase() + ']').css('background-position', 'left');
        }
        $j(".t1000Carousel .scroll").children().hide();
        $j('#' + scroll.toLowerCase()).show();
        Cufon.replace('h5[class!=noCufon]', { fontFamily: 'boton' });
    }
    $j('.t1000Carousel').hover(function() {
        clearTimeout(hoverCarousel);
    }, function() {
        if (isClicked != true) {
            clearTimeout(hoverCarousel);
            hoverCarousel = setTimeout(rollCarousel, timeout);
        }
    });
    $j('.menu ul li a').click(function() {
        hoverCarousel = '';
        clearTimeout(hoverCarousel);
        isClicked = true;
    });
    var rollCarousel = function() {
        switch (scrollNumber) {
            case 0:
                showScroll('Phones');
                break;
            case 1:
                showScroll('Subscriptions');
                break;
            case 2:
                showScroll('Bundles');
                break;
            case 3:
                showScroll('Accessories');
                break;
            default:
                return false;
                break;
        }
        scrollNumber = scrollNumber + 1;
        if (scrollNumber == 4) {
            scrollNumber = 0;
        }
        clearTimeout(hoverCarousel);
        hoverCarousel = setTimeout(rollCarousel, timeout);
    };
    var hoverCarousel = setTimeout(rollCarousel, timeout);
    /* Scroll end */
    /* Plus Start */
    $j('#plus .items div a ').tooltip({
        'calling': function() {
            Cufon.replace('.tooltipTitle', { fontFamily: 'boton' });
            if ($j.browser.msie && parseInt($j.browser.version) <= 6) { DD_belatedPNG.fix('.tooltipTop,.tooltipFoot'); }
        },
        'delayIn': 120,
        'title': true,
        'y': -36,
        'yPop': 10,
        'yOut': 60
    });
    $j('#plus').scrollable({
        size: 7,
        prevPage: '.t1000CarouselPlus .prevPage',
        nextPage: '.t1000CarouselPlus .nextPage',
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        onSeek: fixSeekIE6
    });
    /* Plus End */
};
var T1100 = function() {
    $j('.genericCarousel .nextPage, .genericCarousel .prevPage').click(function() {
        return false;
    });
    $j('.genericCarousel .scrollSubscriptions, .genericCarousel .scrollPlusServices ').scrollable({
        size: 3,
        prevPage: '.prevPage',
        nextPage: '.nextPage',
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        onSeek: fixSeekIE6
    });
    $j('.genericCarousel .scrollPhones').scrollable({
        size: 4,
        prevPage: '.prevPage',
        nextPage: '.nextPage',
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        onSeek: fixSeekIE6
    });
};
var T1110 = function() {
    $j('.genericCarousel .nextPage, .genericCarousel .prevPage').click(function() {
        return false;
    });
    $j('.genericCarousel .genericScrollable').scrollable({
        size: 3,
        prevPage: '.prevPage',
        nextPage: '.nextPage',
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        onSeek: fixSeekIE6
    });
};
var T1111 = function() {
    $j('.genericCarousel .nextPage, .genericCarousel .prevPage').click(function() {
        return false;
    });
    $j('.genericCarousel .genericScrollable').scrollable({
        size: 3,
        prevPage: '.prevPage',
        nextPage: '.nextPage',
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        onSeek: fixSeekIE6
    });
};
var T11111 = function() {
    $j('.genericCarousel .nextPage, .genericCarousel .prevPage').click(function() {
        return false;
    });
    $j('.genericCarousel .genericScrollable').scrollable({
        size: 3,
        prevPage: '.prevPage',
        nextPage: '.nextPage',
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        onSeek: fixSeekIE6
    });
    $j('#tabBox').tabs({
        collapsible: false,
        selected: 0,
        show: function() {
            Cufon.replace('.genericTabs .top h5', { fontFamily: 'botonRegular' });
            Cufon.replace('.genericTabs .top .ui-tabs-selected h5', { fontFamily: 'boton' });
            fixShowIE6();
        }
    });
    $j('#productScroll').scrollable({
        size: 1,
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        interval: 10000,
        loop: true
    });

    if ($j('#productScroll .items div').size() <= 1) {
        $j('.navi').hide();
    }
    $j("#t11111 .compareToOther").click(function() {
        $j(".lightBoxLayer").load("11111-HR-Mobile-Hero-Priceplan-Leve-AjaxPopup.htm", false, function() {
            showLightBox();
            Cufon.replace('h1[class!=noCufon], h2[class!=noCufon], h3[class!=noCufon], h4[class!=noCufon], h5[class!=noCufon]', { fontFamily: 'boton' });
            $j(".lightBoxLayer .top, .lightBoxLayer .bottom, .lightBoxLayer .middle, .lightBoxLayer .close").each(function() {
                if (!$j(this).hasClass('noPngFix')) {
                    DD_belatedPNG.fixPng(this);
                }
            });
        });
        return false;
    });
};
var T1150 = function() {
    $j('.genericCarousel .nextPage, .genericCarousel .prevPage').click(function() {
        return false;
    });
    $j(' .genericCarousel .scrollPlusServices,.genericCarousel .scrollPlusServicesBig').scrollable({
        size: 3,
        prevPage: ' .prevPage',
        nextPage: ' .nextPage',
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        onSeek: fixSeekIE6
    });
    $j('#tabBox').tabs({
        collapsible: false,
        selected: 0,
        show: function() {
            Cufon.replace('.genericTabs .top h5', { fontFamily: 'botonRegular' });
            Cufon.replace('.genericTabs .top .ui-tabs-selected h5', { fontFamily: 'boton' });
            fixShowIE6();
        }
    });
};

var T1200 = function() {
    $j('.genericCarousel .nextPage, .genericCarousel .prevPage').click(function() {
        return false;
    });
    $j('.genericCarousel .scrollSubscriptions, .genericCarousel .scrollPlusServices, .genericCarousel .scrollHardware').scrollable({
        size: 3,
        prevPage: ' .prevPage',
        nextPage: '.nextPage',
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        onSeek: fixSeekIE6
    });
};
var T1210 = function() {
    $j('.genericCarousel .nextPage, .genericCarousel .prevPage').click(function() {
        return false;
    });
    $j('.genericCarousel .genericScrollable').scrollable({
        size: 3,
        prevPage: '.prevPage',
        nextPage: '.nextPage',
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        onSeek: fixSeekIE6
    });
};
var T1120 = function() {
    $j('.genericCarousel .nextPage, .genericCarousel .prevPage').click(function() {
        return false;
    });
    $j('.genericCarousel .scrollPhones').scrollable({
        size: 3,
        prevPage: '.prevPage',
        nextPage: '.nextPage',
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        onSeek: fixSeekIE6
    });
    $j('#showFilteredSelection').click(function() {
        /* NOT YET IMPLEMENTED (add slash at end of this line to enable) *
        $j('#filteredResultContainer').load('http://url', function() {
        $j(this).slideDown();
        });
        // */
        $j('#filteredResultContainer').slideDown();
        return false;
    });
};
var T1130 = function() {
    T1120();
};
var T2000 = function() {
    T1000();
};
var T600 = function() {
    $j("#t600 .article a").click(function() {
        $j(".lightBoxLayer").load("600-News-Article.htm", false, function() {
            showLightBox();
        });
        return false;
    });
};
var T3000 = function() {
    $j('.header').click(function() {
        var that = $j(this);
        var thatCH = that.children('.arrow');
        that.next().slideToggle('fast');
        if (thatCH.hasClass('.openContainer')) {
            thatCH.removeClass('openContainer');
        } else {
            thatCH.addClass('openContainer');
        }
        return false;
    });
}
var T3100 = function() {
    $j("#t3100 dl dt a").click(function() {
        $j(this).closest("dl").children().removeClass("active");
        $j(this).parent().next().andSelf().addClass("active");
        return false;
    });
};
var T21111 = function() {
    $j('.genericCarousel .nextPage, .genericCarousel .prevPage').click(function() {
        return false;
    });
    $j('.genericCarousel .genericScrollable').scrollable({
        size: 3,
        prevPage: '.prevPage',
        nextPage: '.nextPage',
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        onSeek: fixSeekIE6
    });
    $j('#tabBox').tabs({
        collapsible: false,
        selected: 0,
        show: function() {
            Cufon.replace('.genericTabs .top h5', { fontFamily: 'botonRegular' });
            Cufon.replace('.genericTabs .top .ui-tabs-selected h5', { fontFamily: 'boton' });
            fixShowIE6();
        }
    });
    $j('#productScroll').scrollable({
        size: 1,
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        interval: 10000,
        loop: true
    });

    if ($j('#productScroll .items div').size() <= 1) {
        $j('.navi').hide();
    }
};
var T1131 = function() {
    $j('.thumbs li').click(function() {
        var obj = $j(this);
        if (!obj.hasClass('selected')) {
            obj.parent().find('li').removeClass('selected');
            obj.parent().find('span').remove();
            if ($j.browser.msie && parseInt($j.browser.version) <= 8) {
                if ($j.browser.msie && parseInt($j.browser.version) <= 6) {
                    obj.parent().find('shape').remove();
                    var source = obj.find('img').attr('src');
                    obj.parent().prev().find('shape').remove().find('img').remove();
                    obj.parent().prev().append('<img class=\"preview\" src=\"' + source + '" alt=\"\" />');
                    DD_belatedPNG.fix('.preview, .thumbs span');
                }
                else {
                    obj.parent().prev('div').find('img').attr('src', obj.find('img').attr('src'));
                }
            }
            else {
                obj.parent().prev('div').find('img').fadeTo(400, 0.1, function() {
                    obj.parent().prev('div').find('img').attr('src', obj.find('img').attr('src')).fadeTo(400, 1);
                });
            }
            obj.addClass('selected');
            obj.find('img').after('<span></span>');
        }
    });
    $j('.genericCarousel .nextPage, .genericCarousel .prevPage').click(function() {
        return false;
    });
    $j('.genericCarousel .genericScrollable').scrollable({
        size: 3,
        prevPage: '.prevPage',
        nextPage: '.nextPage',
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        onSeek: fixSeekIE6
    });
    $j('#tabBox').tabs({
        collapsible: false,
        selected: 0,
        show: function() {
            Cufon.replace('.genericTabs .top h5', { fontFamily: 'botonRegular' });
            Cufon.replace('.genericTabs .top .ui-tabs-selected h5', { fontFamily: 'boton' });
            fixShowIE6();
        }
    });
    $j('#productScroll').scrollable({
        size: 1,
        easing: 'easeOutCirc',
        speed: 1000,
        keyboard: false,
        clickable: false,
        interval: 10000,
        loop: true
    });
    if ($j('#productScroll .items div').size() <= 1) {
        $j('.navi').hide();
    }
};
var T3000cs = function() {
    $j("#t3000cs dl dt a").click(function() {
        $j(this).closest("dl").children().removeClass("active");
        $j(this).parent().next().andSelf().addClass("active");
        return false;
    });
    $j("#t3000cs .navigationSearchBox").bind("focus blur keyup", false, function() {
        var popupLayer = $j("#t3000cs .popupLayer");
        if ($j(this).val().length > 3) {
            popupLayer.show(500);
        } else {
            popupLayer.hide(500);
        }
    });
};
var T3160 = function() {
    $j("#t3160 dl dt a").click(function() {
        $j(this).closest("dl").children().removeClass("active");
        $j(this).parent().next().andSelf().addClass("active");
        return false;
    });
};
var T9100 = function() {
        $j("input").click(function(){
                            $j(".cordovan-bargraph .bars").cordovanBars([rnd(250, 500), rnd(250, 500), rnd(250, 500), rnd(250, 500), rnd(250, 500)], 10);    
        })
        
        $j(".cordovan-slider").cordovanSlider({
                    "callback": function(slider, percent){
                        
                        percent *= 100;
                        
                        if(percent > 66.6) {
                            realValue = (3 * 66.6) + (24 * (percent-66.6))
                        } else {
                            realValue = (3 * percent);
                        }
                        
                        realValue = Math.round(realValue);
                        
                        if(realValue >= 1000)
                            realValue = 1000;
                        
                        $j(slider).parent().children("input").val(realValue + ' (' + Math.round(percent) + ' %)');
                    }
        });
    };
var cufonDatePicker = function() {
    Cufon.replace('.ui-datepicker span, .ui-datepicker a', { fontFamily: 'boton' });
};
var T4020 = function() {
    $j('#startTime, #endTime').datepicker({
        buttonText: 'Pick date',
        closeText: "<img src='/system_images/0-calClose.png'>",
        prevText: "<script type='text/javascript'>cufonDatePicker();if(DD_belatedPNG) DD_belatedPNG.fix('.ui-datepicker, #arrowLeft, #arrowRight');<\/script><img src='/system_images/0-calPrev.png' id='arrowLeft' />",
        nextText: "<img src='/system_images/0-calNext.png' id='arrowRight' />",
        dateFormat: 'yyyy-mm-dd', // DO NOT CHANGE (OR ALSO CHANGE FORMAT IN onSelect)
        dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
        dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
        monthNames: ['January', 'February', 'Mars', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
        gotoCurrent: true,
        firstDay: 0,
        currentText: 'Today',
        showOn: 'both',
        showAnim: 'show',
        duration: '',
        buttonImage: '/system_images/0-dateTimeIcon.png',
        buttonImageOnly: true,
        showButtonPanel: true,
        onSelect: function(dateText, inst) {
            if (inst.currentDay.length > 2) {
                var correctDay = $j(inst.currentDay).text();
                var correctMonth = inst.currentMonth + 1;
                if (correctDay < 10)
                    correctDay = '0' + correctDay;
                if (correctMonth < 10)
                    correctMonth = '0' + correctMonth;
                inst.input.val(inst.currentYear + '-' + correctMonth + '-' + correctDay);
            }
        }
    });
};
var T4400 = function() {
    $j('.accordion4400 .header').click(function() {
        var that = $j(this);
        var thatCH = that.children('.arrow');
        that.next().slideToggle('fast');
        if (thatCH.hasClass('openContainer')) {
            thatCH.removeClass('openContainer');
        } else {
            thatCH.addClass('openContainer');
        }
        return false;
    });
    $j('#t4400 .menu .login').click(function() {
        $j('#t4400 #login').toggle();
        return false;
    });
};
/* --- TEMPLATE SPECIFIC --- */
/*********** EXTRA ADDED BY TELE2 BIT TEAM *************/
$j(document).ready(function() {
    $j('.rightContent').find('div.H-devideLine:last').remove();
    $j('select.dropnav').change(function() { window.location.href = $j(this).val(); });
});
$j(document).ready(function() {
    if ($j('.timeTable').length === 0) { return; }
    if ($j('.serviceSelect').length === 0) { return; }
    var dropHtml = '<select class="dropcontact">';
    var i = 0;
    $j('.timeTable').each(function() {
        if (i !== 0) {
            $j(this).hide();
        }
        dropHtml += '<option>' + $j(this).attr('summary') + '</option>';
        i++;
    });
    dropHtml += '</select>';
    $j('div.serviceCenterAddresses div.serviceSelect').html(dropHtml);
    $j('select.dropcontact').change(function() {
        $j('.timeTable:visible').hide();
        $j("table[summary='" + $j(this).val() + "']").show();
    });
    $j('select[class!=noSelect]').selectBox({
        'callOnLoad': function() { if ($j.browser.msie && parseInt($j.browser.version) <= 6) { DD_belatedPNG.fix('.sb-btn, .sb-top'); } },
        'callBack': function() { if ($j.browser.msie && parseInt($j.browser.version) <= 6) { DD_belatedPNG.fix('.sb-list , .sb-slideBottom'); } }
    });
});
$j(document).ready(function() {
    if ($j('#t600').length === 0) { return; }
    var tempYear;
    var yearCounter = 0;
    var articleYears = new Array();
    var articles = $j("#t600 .article").each(function() {
        var curYear = $j(this).find('strong').text().substring(0, 4);
        if (tempYear !== curYear) {
            articleYears[yearCounter] = curYear;
            tempYear = curYear;
            yearCounter++;
        }
        $j(this).next().remove();
        $j(this).remove();
    });
    var tabsHTML = "";
    tabsHTML += '<div class="shadowedTabs">';
    tabsHTML += '<ul>';
    for (var i = 0; i < articleYears.length; i++) {
        tabsHTML += '<li><h5><a href="#year-' + articleYears[i] + '">' + articleYears[i] + '</a></h5></li>';
    }
    tabsHTML += '</ul>';
    for (var i = 0; i < articleYears.length; i++) {
        tabsHTML += '<div id="year-' + articleYears[i] + '"></div>';
    }
    $j('#articles').html(tabsHTML);
    $j(articles).each(function() {
        var curYear = $j(this).find('strong').text().substring(0, 4);
        $j('#articles').find('div[id=year-' + curYear + ']').append('<div class="article">' + $j(this).html() + '</div><hr />');
    });
    $j('.shadowedTabs').tabs({
        collapsible: false,
        selected: 0,
        show: function() {
            Cufon.replace('.shadowedTabs .panelWrapper h5', { fontFamily: 'botonRegular' });
            Cufon.replace('.shadowedTabs .panelWrapper .ui-tabs-selected h5', { fontFamily: 'boton' });
            fixShowIE6();
        }
    });
    $j("#t600 .article a").click(function() {
        $j(".lightBoxLayer").load($j(this).attr('href') + '#newsView #t600lightbox', false, function() {
            showLightBox();
        });
        return false;
    });
});
