function setup() {
    // Cycle through each element with the class of "tabs"
    $.each($('.tabs'), function() {
        var thisObj = $(this);

        // Replace the list with just the links.
            thisObj.find('ul').replaceWith(
                    thisObj.find('li:first').html()
                    + thisObj.find('li:last').html());

            // Wrap the links with the table information.
            thisObj.find('a:first').wrap(
                    '<td class="tdLeft tdLeftActive"></td>');
            thisObj.find('a:last').wrap('<td class="tdRight"></td>');
            thisObj.find('td').wrapAll('<table ><tr></tr></table>');

            // alert(thisObj.html());

            // Setup the click events for showing and hiding the correct tab.
            thisObj.find('a').click( function() {
                // Check that the user hasn't clicked on an already active tab
                    // by the td's class.
                
                    if (!$(this).parent().hasClass('tdLeftActive')
                            && !$(this).parent().hasClass('tdRightActive')) {
                        // Get the div parent
                        var divGroupHolder = $(this).parent().parent().parent()
                                .parent().parent();
                        // Toggle its siblings to show or hide
                        $(divGroupHolder).siblings().find('div.hpApplicationBox').toggle();
                        //$(divGroupHolder).parent().find('div.cq-editbar-placeholder').toggle();
                        //$(divGroupHolder).parent().find('div.cq-editbar').toggle();
                        // cq-editbar-placeholder
                        
                        // Toggle the active class for these links.
                        divGroupHolder.find('td:eq(0)').toggleClass(
                                'tdLeftActive');
                        divGroupHolder.find('td:eq(1)').toggleClass(
                                'tdRightActive');
                        //checkboxFix();
                    }
                    return false;
                });
        });

    // Fix the buttons for firefox so it isn't jagged.
    if (jQuery.browser.mozilla == true) {
        $('button').addClass('FireFoxButton');
    }

    if (jQuery.browser.msie) {
        $('.hpBody').find('button').mousedown( function() {
            width = $(this).width();
            if (parseInt(jQuery.browser.version) < 7) {
                width = width - 12;
            }
            $(this).css('background-position-y', '1px');
            $(this).css('background-position-x', width + 1 + 'px');
        });
        $('.hpBody').find('button').mouseup( function() {
            width = $(this).width();
            if (parseInt(jQuery.browser.version) < 7) {
                width = width - 12;
            }
            $(this).css('background-position-y', '0px');
            $(this).css('background-position-x', width + 'px');
        });
        $('.hpBody').find('button').mouseout( function() {
            width = $(this).width();
            if (parseInt(jQuery.browser.version) < 7) {
                width = width - 12;
            }
            $(this).css('background-position-y', '0px');
            $(this).css('background-position-x', width + 'px');
        });
    }
    
    // see: cookies.js
    setHomepageCookies();
}

var expiredays = 31;

function saveLogonDetailsMyTnt() {
    var userId = document.getElementById("userid").value;
    var password = document.getElementById("password").value;

    if (((null != userId) && ("" != userId)) || ((null != password) && ("" != password))) {
        document.getElementById("myTntCmd").value = 1;
    } else {
        document.getElementById("myTntCmd").value = 0;
    }

    if ((document.getElementById("storecookie").checked)
            && (navigator.cookieEnabled)) {
        setCookie("myTNT_userid", userId, expiredays);
        setCookie("myTNT_password", password, expiredays);
    } else {
        setCookie("myTNT_userid", "");
        setCookie("myTNT_password", "");
    }
}

function onLoadFunctionMyTnt() {
    if (navigator.cookieEnabled) {
        var cookieUid = getCookie("myTNT_userid");
        var cookiePswd = getCookie("myTNT_password");
        if (cookieUid != null) {
            document.getElementById('userid').value = cookieUid;
        }
        if (cookiePswd != null) {
            document.getElementById('password').value = cookiePswd;
        }
        if ((cookieUid != null) && (cookiePswd != null)) {
            if ((cookieUid != '') && (cookiePswd != '')) {
                document.getElementById('storecookie').checked = true;
            }
        }

    }
}

// Prep the setup routine
$(document).ready(setup);