		
	
	
	
var pageToolsEmailLink = "#Needs to be defined within a portal specific JS";
var rightToLeftOffset;
var ver = getInternetExplorerVersion();
var defaultFontSize = 12;
var smallFontSize = parseFloat(defaultFontSize, 10) * 0.8;
var largeFontSize = parseFloat(defaultFontSize, 10) * 1.2;
var currentPage = 0;
var articlesPerPage = 10;
var paginationLimit = 8;
var startPage = 0;
var listItem = 0;
var numOfArticles = 0;
var numOfPages = 0;
var list = null;
var container = null;

//can namesspace this later on						

//add the attribute to the first ul so that we can initialise the dropdown menu
//hide this from IE so we don't have the content falling o0ut all over the place
(function() {
 $.initMenu = function() { 
	if (jQuery('div#VC-siteWideHeaderRight').length > 0) {
		jQuery("div.VC-siteWideHeaderRight").show();
		jQuery('div#VC-siteWideHeaderRight ul:first').attr("class","sf-menu");	
	}	
 }
})(jQuery);



$(document).ready(function () {
	//call the initialise menu funtion
 	$.initMenu();
	
	jQuery(function(){ 
	$("ul.sf-menu").superfish({ 
		    delay:       0,  
			animation:   {opacity:'100',height:'toggle'},
			speed:       'normal',                  
			autoArrows:  true,                        
			dropShadows: true,
			disableHI: true
	 });
   });   
						
							
    initBreadcrumb();
    initTabs();
    initPagination();
    initResizeFontTool();
    initPageTools();
    formatTable();
    topTabSpacerRemover();
    initGeneralStyles();
    initThickBox();
    getYear();
    $('.VC-graphicSelect').selectbox({
        inputClass: 'selectbox'
    });
    expandCollapseParagraphs();
    $("textarea").html($.trim($("textarea").html()))
});


$(window).load(function () {
  applyLinkEvents();
  applyTooltipEvents();
  applyTableSorterEvents();
  forceRedrawForIE();
});

function initArticleListPagination() {
    list = $(".VC-articleList li");
    listItem = 0;
    numOfArticles = list.length;
    numOfPages = Math.ceil(numOfArticles / articlesPerPage) - 1;
    var paginationDiv = "<div id='VC-pagination' class='VC-pagination'></div>";
    $("#VC-mainContent").append(paginationDiv);
    container = $("#VC-pagination");
    renderList();
    generatePagination();
}

function initBreadcrumb() {
    var breadcrumbStartSlicing = 2;
    var breadcrumbEndSlicing = 1;
    var maxBreadcrumbMaxSize = 130;
    var isFirstElement = true;
    if (!$.browser.msie) {
        $(".siteBreadCrumb .breadcrumbLabel").css("display", "inline")
    };
    var $elements = $(".VC-breadcrumbs a,.VC-breadcrumbs .breadcrumbLabel");
    var bc_removed_text = 0;
    var bc_initial_length = $elements.totalTextLength();
    var startElement = 0;
    while (bc_initial_length - bc_removed_text > maxBreadcrumbMaxSize && breadcrumbStartSlicing < $elements.length && $elements.length > breadcrumbStartSlicing + breadcrumbEndSlicing && breadcrumbStartSlicing < 30) {
        var $selectedElements = $elements.slice(breadcrumbStartSlicing, $elements.length - breadcrumbEndSlicing);
        if (isFirstElement) {
            isFirstElement = false;
            startElement = breadcrumbStartSlicing;
        }
        bc_removed_text += $selectedElements.eq(0).html().length;
        breadcrumbStartSlicing++;
    }
    if (!isFirstElement) {
        $elements.slice(breadcrumbStartSlicing - 1, breadcrumbStartSlicing).textEllipsis("...");
        $elements.slice(breadcrumbStartSlicing - 1, breadcrumbStartSlicing).tooltip({
            track: true,
            delay: 500,
            showURL: false,
            showBody: " - ",
            fade: 250
        });
        $elements.slice(startElement, breadcrumbStartSlicing - 1).next("span").remove();
        $elements.slice(startElement, breadcrumbStartSlicing - 1).remove();
    }
}



function initGeneralStyles() {
    $(".documentLink").prepend("<span class='documentLinkIcon'> </span>");
    $(".externalLink").append("<span class='externalLinkIcon'> </span>");
    $(".linkList li").prepend("<span class='linkListIcon'> </span>");
}

function initNewsArticlePagination() {
    var paginatedArticles = $(".VC-articlepagination .VC-articlePage");
    numOfPages = paginatedArticles.length - 1;
    if (paginatedArticles.length > 0) {
        paginatedArticles.slice(1).hide();
        var paginationDiv = "<div id='VC-pagination' class='VC-pagination'></div>";
        $("#VC-mainContent").append(paginationDiv);
        navigateNewsArticlePagination();
    }
}

function initPageTools() {
   $(".VC-pagetools").html('<a href="#" title="print this page" class="printPage"><span>print</span></a>'); 
}

function initPagination() {
    if ($("#VC-articleList").length > 0) {
        initArticleListPagination();
    }
    if ($(".VC-articlepagination").length > 0) {
        initNewsArticlePagination();
    }
}




function initResizeFontTool() {
    $(".VC-fontResizeTool").css("display", "block");
    $(".defaultFont").click(function () {
        resizeFontsFunction(defaultFontSize);
        $.cookie("VCFontResizerSelection", "" + defaultFontSize, {
            path: '/mgl/au',
            expires: 7
        });
        return false;
    });
    $(".largeFont").click(function () {
        resizeFontsFunction(largeFontSize);
        $.cookie("VCFontResizerSelection", "" + largeFontSize, {
            path: '/mgl/au',
            expires: 7
        });
        return false;
    });
    $(".smallFont").click(function () {
        resizeFontsFunction(smallFontSize);
        $.cookie("VCFontResizerSelection", "" + smallFontSize, {
            path: '/mgl/au',
            expires: 7
        });
        return false;
    });
    var currentVCFontSize = $.cookie("VCFontResizerSelection");
    if (currentVCFontSize) {
        resizeFontsFunction(parseFloat(currentVCFontSize));
    }
}

function initTabs() {
    $(".VC-tabModule ul li a").wrapInner(document.createElement("span"));
		if ( $('div.VC-tabModule').length >0 ) {
			$('div.VC-tabModule ul li a span').each(function(index) { //get each span
				var $tabText = $(this).text(); //get its inner text
				 $(this).parents(".VC-tabModule") //find the parent elemet
					.find('div.tabs-container:eq(' + index + ')') //the the corresponding div by index			
					 .find("div:first") // get the first div inside the div
					  .before("<h2>" + $tabText + "</h2>");  //insert the inner text from the corresponding anchor
			});	
		}
	
	
    $(".VC-tabModule").tabs();
    $(".researchInsights ul li a").wrapInner(document.createElement("span"));
    $(".researchInsights").tabs();
    if (ver < 8.0 && ver > 0) {
        $(".tabs-nav").css("display", "inline-block");
        $(".tabs-nav .tabs-disabled").css({
            'position': 'relative',
            'filter': 'alpha(opacity=40)'
        });
        $(".tabs-nav .tabs-disabled a span").css({
            'height': '23px',
            'min-height': '23px'
        });
    }
}

function initThickBox() {
    tb_init('a.thickbox, area.thickbox, input.thickbox');
    imgLoader = new Image();
    imgLoader.src = tb_pathToImage;
}


function setupLightbox() {
    var lightboxes = $(".VC-modalLightbox");
    lightboxes.each(function () {
        if (!$(this).hasClass("setupApplied")) {
            $(this).addClass("roundCorners setupApplied");
            $(this).wrapInner($("<div class='modalBody'></div>"));
            $(this).prepend("<div class='modalHeader'><div class='modalLogo'></div><a class='modalCloseBt' href='#'></a></div><div class='modalDecorBanner'></div>");
            $(".modalCloseBt").click(tb_remove);
            roundCorners('#2D2D2D', '#ffffff');
            $("#TB_ajaxContent").css("height", "100%");
        }
    });
}

function setupLoginLightbox() {
    $("#VC-loginLightbox .adviser li").mouseover(function () {
        $(this).css("background-color", "#003366");
    });
    $("#VC-loginLightbox .business li").mouseover(function () {
        $(this).css("background-color", "#666633");
    });
    $("#VC-loginLightbox .corporate li").mouseover(function () {
        $(this).css("background-color", "#333333");
    });
    $("#VC-loginLightbox li").mouseout(function () {
        $(this).css("background-color", "#5B5B5B");
    });
    $("#VC-loginLightbox a").tooltip({
        track: true,
        delay: 500,
        showURL: false,
        fade: 250
    });
}

function setupSwLoginLightbox() {
    var appsList = $(".appsList");
    appsList.hide();
    $(".appsLink").click(function () {
        var all = $(".appsList");
        var selected = $(this).next();
        var ver = getInternetExplorerVersion();
        if (ver < 7.0 && ver > 0) {} else {
            $(this).next().css('display', 'block');
            var openingDivHeight = $(this).next().height();
            $(this).next().hide();
            var closingDivHeight = all.filter('.selected').height();
            if (null == closingDivHeight) {
                closingDivHeight = 0;
                if (ver <= 7.0) {
                    $("#TB_window").css("top", $(window).height() / 2);
                }
            }
            var offsetHeight = (closingDivHeight - openingDivHeight) / 2;
            if ($("#TB_window").css("top") == "50%") {
                $("#TB_window").css("top", $(window).height() / 2);
            }
            $("#TB_window").animate({
                "top": "+=" + offsetHeight
            }, "slow");
        }
        all.removeClass('selected');
        $(selected).addClass('selected');
        all.filter(':not(.selected)').slideUp("slow");
        $(selected).slideDown("slow");
        return false;
    });
}

function applyLinkEvents() {
    $('.documentLink').click(function ($e) {
        $e.preventDefault();
        openNewWindow(this.href);
    });
    $('.externalLink').click(function ($e) {
        $e.preventDefault();
        window.open(this.href);
    });
    $(".printPage").click(function () {
        window.print();
        return false;
    });
    $('.openNewWindow').click(function ($e) {
        $e.preventDefault();
        openNewWindow(this.href);
    });
    $(".rollovermenu a").blur(function () {
        var portalNavHeaders = $(".rollovermenu a.header");
        portalNavHeaders.each(function () {
            $(this).css({
                'background-color': 'transparent',
                color: '#fff'
            });
            if ($(this).hasClass('current')) {
                $(this).css({
                    "background-color": "#fff",
                    "color": "#000"
                });
            }
            $(this).next("ul").css("left", "-9999px");
        });
    });
    $(".rollovermenu a").focus(function () {
        var elFocus = $(this);
        if (elFocus.hasClass("header")) {
            elFocus.addClass("open");
        } else {
            elFocus.closest("ul").prev("a").addClass("open");
        }
        var portalNavHeaders = $(".rollovermenu a.header");
        portalNavHeaders.each(function () {
            if ($(this).hasClass("open")) {
                $(this).css({
                    'background-color': '#eae9e9',
                    color: '#000'
                });
                if ($(this).next("ul").hasClass("rightToLeft")) {
                    $(this).next("ul").css("left", rightToLeftOffset);
                } else {
                    $(this).next("ul").css("left", "0px");
                }
            }
        });
        if (elFocus.hasClass("header")) {
            elFocus.removeClass("open");
        } else {
            elFocus.closest("ul").prev("a").removeClass("open");
        }
    });
}

function applyTableSorterEvents() {
    $(".productComparison").tablesorter();
}

function applyTooltipEvents() {
    $(".tooltip").tooltip({
        track: true,
        delay: 500,
        showURL: false,
        showBody: " - ",
        fade: 250
    });
}

function bindPaginationEvents(fnToInvoke) {
    $("#VC-pagination a.firstPage").bind("click", function (e) {
        currentPage = 0;
        listItem = 0;
        renderList();
        fnToInvoke();
    });
    $("#VC-pagination a.previousPage").bind("click", function (e) {
        currentPage -= 1;
        listItem = currentPage * articlesPerPage;
        renderList();
        fnToInvoke();
    });
    $("#VC-pagination a.nextPage").bind("click", function (e) {
        currentPage += 1;
        renderList();
        fnToInvoke();
    });
    $("#VC-pagination a.lastPage").bind("click", function (e) {
        currentPage = numOfPages;
        listItem = (currentPage * articlesPerPage);
        renderList();
        fnToInvoke();
    });
    $("#VC-pagination a.pageLink").bind("click", function (e) {
        currentPage = parseInt($(this).text(), 10) - 1;
        listItem = (currentPage * articlesPerPage);
        renderList();
        fnToInvoke();
    });
    $("#VC-pagination select").change(function () {
        $('html, body').animate({
            scrollTop: '0px'
        }, 0);
        currentPage = 0;
        listItem = 0;
        articlesPerPage = $(this).val();
        numOfPages = Math.ceil(numOfArticles / articlesPerPage) - 1;
        renderList();
        fnToInvoke();
    });
}

function forceRedrawForIE() {
    if (ver < 8.0 && ver > 0) {
        $(".VC-tabModule").addClass("forceRedraw");
    }
}

function formatTable() {
    $(".VC-subChannelSummary").addClass("noFormat stripe");
    stripeTable();
    var tables = $("#VC-mainContent table").not(".noFormat");
    tables.each(function () {
        $("tr td:first-child", this).addClass("firstCol");
        $("tr th:first-child", this).addClass("firstCol");
    });
}

function generatePagination() {
    if (currentPage <= Math.ceil(paginationLimit / 2)) {
        startPage = 0;
    } else {
        startPage = currentPage - Math.ceil(paginationLimit / 2);
    }
    container.empty();
    var html = "";
    var className = "";
    if (startPage >= 0 && startPage <= numOfPages) {
        html = "<div>";
        if (currentPage > 0) {
            html += "<a class='arrows firstPage' href='#VC-header' title='Click here to go to the first page'>\<\<</a>";
            html += "<a class='arrows previousPage' href='#VC-header' title='Click here to go to the previous page'>\< previous</a>";
        }
        for (i = startPage; i < startPage + paginationLimit; i++) {
            var page = i + 1;
            html += "<a class='pageLink page" + i.toString() + "' href='#VC-header'>" + page + "</a>";
            if (i == currentPage) {
                className = ".page" + currentPage.toString();
            }
            if (i == numOfPages) {
                break;
            }
        }
        if (currentPage < numOfPages) {
            html += "<a class='arrows nextPage' href='#VC-header' title='Click here to go to the next page'>next \></a>";
            html += "<a class='arrows lastPage' href='#VC-header' title='Click here to go to the last page'>\>\></a>";
        }
        html += "</div>";
        html += "<select><option value='10'>10 </option><option value='30'>30 </option><option value='50'>50 </option></select>";
        container.append(html);
        $(className).addClass("current");
        $("#VC-pagination select").val(articlesPerPage);
    }
    bindPaginationEvents(generatePagination);
}

function navigateNewsArticlePagination() {
    if (currentPage <= Math.ceil(paginationLimit / 2)) {
        startPage = 0;
    } else {
        startPage = currentPage - Math.ceil(paginationLimit / 2);
    }
    var paginatedArticles = $(".VC-articlepagination .VC-articlePage");
    container = $("#VC-pagination");
    var html = "<div>";
    var className = "";
    container.empty();
    paginatedArticles.hide();
    paginatedArticles.slice(currentPage, currentPage + 1).show();
    if (currentPage > 0) {
        html += "<a class='arrows firstPage' href='#VC-header' title='Click here to go to the first page'>\<\<</a>";
        html += "<a class='arrows previousPage' href='#VC-header' title='Click here to go to the previous page'>\< previous</a>";
    }
    for (i = startPage; i < startPage + paginationLimit; i++) {
        var page = i + 1;
        html += "<a class='pageLink page" + i.toString() + "' href='#VC-header'>" + page + "</a>";
        if (i == currentPage) {
            className = ".page" + currentPage.toString();
        }
        if (i == paginatedArticles.length - 1) {
            break;
        }
    }
    if (currentPage < paginatedArticles.length - 1) {
        html += "<a class='arrows nextPage' href='#VC-header' title='Click here to go to the next page'>next \></a>";
        html += "<a class='arrows lastPage' href='#VC-header' title='Click here to go to the last page'>\>\></a>";
    }
    html += "</div>";
    container.append(html);
    $(className).addClass("current");
    $(".pagePaginationCount").html("|  Page " + (Number(currentPage + 1)) + " of " + paginatedArticles.length);
    bindPaginationEvents(navigateNewsArticlePagination);
}

function renderList() {
    if (list) {
        list.css("display", "none");
        for (i = 1; i <= articlesPerPage; i++) {
            list.eq(listItem).css("display", "list-item");
            listItem++;
        }
    }
}

function resizeFontsFunction(fontDimension) {
    $("#VC-pageBody, #VC-breadcrumbs").css('font-size', fontDimension);
    $("#VC-pageBody .ui-tabs-nav, .VC-noResize").css('font-size', defaultFontSize);
    $("#VC-pageBody .loginButton.noFontResize").css('font-size', "14px");
    if (fontDimension == smallFontSize) {
        $("#VC-fontResizeTool a.smallFont").css("background-position", "0px -23px");
        $("#VC-fontResizeTool a.defaultFont").css("background-position", "-18px 0px");
        $("#VC-fontResizeTool a.largeFont").css("background-position", "-36px 0px");
    } else if (fontDimension == defaultFontSize) {
        $("#VC-fontResizeTool a.smallFont").css("background-position", "0px 0px");
        $("#VC-fontResizeTool a.defaultFont").css("background-position", "-18px -23px");
        $("#VC-fontResizeTool a.largeFont").css("background-position", "-36px 0px");
    } else if (fontDimension == largeFontSize) {
        $("#VC-fontResizeTool a.smallFont").css("background-position", "0px 0px");
        $("#VC-fontResizeTool a.defaultFont").css("background-position", "-18px 0px");
        $("#VC-fontResizeTool a.largeFont").css("background-position", "-36px -23px");
    }
}

function roundCorners(topColour, bottomColour) {
    $(".roundCorners").not(".rcApplied").each(function () {
        $(this).addClass("rcApplied");
        if (topColour === null) {
            topColour = $(this).css("background-color");
        }
        if (bottomColour === null) {
            bottomColour = $(this).css("background-color");
        }
        var topClassname = "rc" + topColour.replace(/[^a-zA-Z 0-9]+/g, '');
        topClassname = topClassname.replace(/ /g, '');
        var bottomClassname = "rc" + bottomColour.replace(/[^a-zA-Z 0-9]+/g, '');
        bottomClassname = bottomClassname.replace(/ /g, '');
        $(this).before("<b class=\"rc1 " + topClassname + "\"></b><b class=\"rc2 " + topClassname + "\"></b><b class=\"rc3 " + topClassname + "\"></b><b class=\"rc4 " + topClassname + "\"></b>");
        $(this).after("<b class=\"rc4 " + bottomClassname + "\"></b><b class=\"rc3 " + bottomClassname + "\"></b><b class=\"rc2 " + bottomClassname + "\"></b><b class=\"rc1 " + bottomClassname + "\"></b>");
        $("." + topClassname).css("background-color", topColour);
        $("." + bottomClassname).css("background-color", bottomColour);
    });
}

function stripeTable() {
    var el = $("#VC-mainContent table.stripe");
    el.each(function () {
        $("tr:odd", this).removeClass("even").addClass("odd");
        $("tr:even", this).removeClass("odd").addClass("even");
    });
}

function topTabSpacerRemover() {
    $(".VC-links li .selected").parent("li").prev("li").removeClass("spacer");
    $(".VC-links li a").mouseover(function (event) {
        $(this).parent("li").prev("li.spacer").addClass("spacerRepacement");
        $(this).parent("li").prev("li.spacer").removeClass("spacer");
    });
    $(".VC-links li a").mouseleave(function (event) {
        $(this).parent("li").prev("li.spacerRepacement").addClass("spacer");
    });
}

function getYear() {
    var d = new Date();
    $(".year").text(d.getFullYear() + " ");
}

function getRightToLeftOffset(el) {
    var dropdown = el.children("ul");
    var offset = el.width() - dropdown.width();
    return offset < 0 ? offset : 0;
}
jQuery.cookie = function (name, value, options) {
    if (typeof value != 'undefined') {
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString();
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else {
        var cookieValue = null;
        if (document.cookie && document.cookie !== '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

function getInternetExplorerVersion() {
    var rv = -1;
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) !== null) {
            rv = parseFloat(RegExp.$1);
        }
    }
    return rv;
}(

function () {
    var m = document.uniqueID && document.compatMode && !window.XMLHttpRequest && document.execCommand;
    try {
        if ( !! m) {
            m("BackgroundImageCache", false, true);
        }
    } catch (oh) {}
})();

function expandCollapseParagraphs() {
    $(".VC-expandCollapse").hide();
    $(".VC-expandCollapse").prev("h4").wrap('<a href="" class="VC-expandCollapseButton" />');
    $(".VC-expandCollapseButton").prepend('<ins>&nbsp;</ins>');
    $(".VC-expandCollapseButton").wrap('<div class="VC-expandCollapseButtonWrapper" />');
    $(".VC-expandCollapseButtonWrapper").prev("h3").addClass("VC-expandCollapseTitle");
    $(".VC-expandCollapseButton").click(function (event) {
        event.preventDefault();
        if ($(this).hasClass("VC-expandCollapseButtonExpanded")) {
            $(this).removeClass("VC-expandCollapseButtonExpanded");
            $(this).parent("div").next(".VC-expandCollapse").hide();
        } else {
            $(this).addClass("VC-expandCollapseButtonExpanded");
            $(this).parent("div").next(".VC-expandCollapse").slideDown('slow');
        }
    })
}

function openpopup(theAtag, optionalParameters) {
    if (!optionalParameters) {
        optionalParameters = "width=800,height=700,scrollbars=yes,toolbar=no,status=yes,directories=no";
    }
    currentLink = theAtag.href;
    window.open(currentLink, 'Popup', optionalParameters);
}

function openNewWindow(currentLink) {
    if (currentLink !== null || currentLink !== 'undefined') {
        window.open(currentLink, '_blank');
    }
} /* Macquarie extensions and utilities */
$.fn.extend({
    tablesorter: function () {
        $(this).tablesorterOriginal({
            textExtraction: function (node) {
                var resultingText = jQuery.trim($.string(node.innerHTML).stripTags().str).toUpperCase();
                if (resultingText != "") {
                    return resultingText;
                } else {
                    return node.innerHTML;
                }
            }, sortList: [
                [0, 0]
            ]
        });
        $(this).bind("sortEnd", function () {
            var ascSort = "th.headerSortUp";
            var descSort = "th.headerSortDown";
            var table = this;
            $(table).find("td").removeClass("firstCol");
            $(table).find(ascSort).add($(table).find(descSort)).each(function () {
                $(table).find("td:nth-child(" + ($("thead th").index(this) + 1) + ")").addClass("firstCol");
            });
        });
        $(".titleField").addClass("firstCol").removeClass("titleField")
    }
});
var formValidationUtils = {
    insertCaptcha: function () {
        document.write('<table class="noFormat"><tr><td class="rightAlign">&nbsp;</td><td><div class="VC-CaptchaContainer"><img id="captchaImage" src="/vgn-ext-templating/Captcha" alt="Captcha image" /><div class="VC-captchaInput">Type the word<span class="mandatory">*</span><br/><input type="text" id="captchaID" name="captchaID" class="mediumInputSize" /></div><div class="VC-CaptchaButtons"><a href="javascript:void(formValidationUtils.refreshCaptcha(\'captchaImage\'));" class="VC-refreshCaptcha"><ins>New&nbsp;challenge</ins></a><br/><a href="javascript:void(formValidationUtils.captchaHelp());" class="VC-elpCaptcha"><ins>Help</ins></a></div></div></td></tr></table>')
    }, captchaHelp: function () {
        alert("-Please enter the word you see in the box.\n Doing so helps prevent automated programs from abusing this service. \n-If you are not sure what the word is, click the 'New challenge' link.");
    }, ajaxValidateCaptcha: function (formId, captchaImageId, captchaId, callBackFn) {
        var captchaValidationUrl = "/vgn-ext-templating/FormAction?captchaCheck=" + escape($("#" + captchaId).val());
        try {
            $.ajax({
                url: captchaValidationUrl,
                context: document,
                success: function (data) {
                    if (data != "1") {
                        formValidationUtils.refreshCaptcha(captchaImageId);
                        if (callBackFn) {
                            callBackFn();
                        }
                        return false;
                    } else {
                        document.getElementById(formId).submit();
                    }
                }
            });
        } catch (err) {
            txt = "Error on this page.\n\n";
            txt += "Error description: " + err.description + "\n\n";
            alert(txt);
            return false;
        }
        return false;
    }, refreshCaptcha: function (captchaImageId) {
        var numRand = Math.floor(Math.random() * 100000);
        var newImage = "/vgn-ext-templating/Captcha?random=" + numRand;
        $("#" + captchaImageId).attr("src", newImage);
    }
} /* Tracking related extensions */

function om_calculator(calculatorName) {
    var s = s_gi(s_account);
    s.linkTrackVars = 'prop5,eVar5,events';
    s.linkTrackEvents = 'event5';
    s.events = 'event5';
    s.prop5 = s.eVar5 = calculatorName;
    if (s.pageName && !s.eVar15) s.eVar15 = s.pageName;
    s.tl(this, 'o', calculatorName);
}

function om_promo(promotionName) {
    var s = s_gi(s_account);
    s.linkTrackVars = 'prop5,eVar5,events';
    s.linkTrackEvents = 'event5';
    s.events = 'event5';
    s.prop5 = s.eVar5 = promotionName;
    if (s.pageName && !s.eVar15) s.eVar15 = s.pageName;
    s.tl(this, 'o', promotionName);
}

function om_download(downloadName) {
    var s = s_gi(s_account);
    s.linkTrackVars = 'eVar14,events';
    s.linkTrackEvents = 'event7';
    s.events = 'event7';
    s.eVar14 = downloadName;
    if (s.pageName && !s.eVar15) s.eVar15 = s.pageName;
    s.tl(this, 'd', downloadName);
}
jQuery.fn.textEllipsis = function (text) {
    return this.each(function () {
        this.title = this.innerHTML;
        this.innerHTML = text;
    });
};
jQuery.fn.totalTextLength = function () {
    var totalLength = 0;
    this.each(function () {
        totalLength += this.innerHTML.length;
    });
    return totalLength;
};
/* commented by sean 
if (s && s.pageName && !s.eVar15) {
    s.eVar15 = s.pageName;
}
*/

/*
 * Thickbox 3.1 - One Box To Rule Them All.
 * By Cody Lindley (http://www.codylindley.com)
 * Copyright (c) 2007 cody lindley
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/
var tb_pathToImage = "/dafiles/Internet/co/sbimgl/furniture/img/bkg/loadingAnimation.gif";

function tb_init(domChunk) {
    $(domChunk).click(function () {
        var t = this.title || this.name || null;
        var a = this.href || this.alt;
        var g = this.rel || false;
        tb_show(t, a, g);
        this.blur();
        return false;
    });
}

function tb_show(caption, url, imageGroup) {
    try {
        if (typeof document.body.style.maxHeight === "undefined") {
            $("body", "html").css({
                height: "100%",
                width: "100%"
            });
            $("html").css("overflow", "hidden");
            if (document.getElementById("TB_HideSelect") === null) {
                $("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
                $("#TB_overlay").click(tb_remove);
            }
        } else {
            if (document.getElementById("TB_overlay") === null) {
                $("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
                $("#TB_overlay").click(tb_remove);
            }
        }
        if (tb_detectMacXFF()) {
            $("#TB_overlay").addClass("TB_overlayMacFFBGHack");
        } else {
            $("#TB_overlay").addClass("TB_overlayBG");
        }
        if (caption === null) {
            caption = "";
        }
        $("body").append("<div id='TB_load'><img src='" + imgLoader.src + "' /></div>");
        $('#TB_load').show();
        var baseURL;
        if (url.indexOf("?") !== -1) {
            baseURL = url.substr(0, url.indexOf("?"));
        } else {
            baseURL = url;
        }
        var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
        var urlType = baseURL.toLowerCase().match(urlString);
        if (urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp') {
            TB_PrevCaption = "";
            TB_PrevURL = "";
            TB_PrevHTML = "";
            TB_NextCaption = "";
            TB_NextURL = "";
            TB_NextHTML = "";
            TB_imageCount = "";
            TB_FoundURL = false;
            if (imageGroup) {
                TB_TempArray = $("a[@rel=" + imageGroup + "]").get();
                for (TB_Counter = 0;
                ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
                    var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
                    if (!(TB_TempArray[TB_Counter].href == url)) {
                        if (TB_FoundURL) {
                            TB_NextCaption = TB_TempArray[TB_Counter].title;
                            TB_NextURL = TB_TempArray[TB_Counter].href;
                            TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;></a></span>";
                        } else {
                            TB_PrevCaption = TB_TempArray[TB_Counter].title;
                            TB_PrevURL = TB_TempArray[TB_Counter].href;
                            TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'><&lt; Prev</a></span>";
                        }
                    } else {
                        TB_FoundURL = true;
                        TB_imageCount = "Image " + (TB_Counter + 1) + " of " + (TB_TempArray.length);
                    }
                }
            }
            imgPreloader = new Image();
            imgPreloader.onload = function () {
                imgPreloader.onload = null;
                var pagesize = tb_getPageSize();
                var x = pagesize[0] - 150;
                var y = pagesize[1] - 150;
                var imageWidth = imgPreloader.width;
                var imageHeight = imgPreloader.height;
                if (imageWidth > x) {
                    imageHeight = imageHeight * (x / imageWidth);
                    imageWidth = x;
                    if (imageHeight > y) {
                        imageWidth = imageWidth * (y / imageHeight);
                        imageHeight = y;
                    }
                } else if (imageHeight > y) {
                    imageWidth = imageWidth * (y / imageHeight);
                    imageHeight = y;
                    if (imageWidth > x) {
                        imageHeight = imageHeight * (x / imageWidth);
                        imageWidth = x;
                    }
                }
                TB_WIDTH = imageWidth + 30;
                TB_HEIGHT = imageHeight + 60;
                $("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='" + url + "' width='" + imageWidth + "' height='" + imageHeight + "' alt='" + caption + "'/></a>" + "<div id='TB_caption'>" + caption + "<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div>");
                $("#TB_closeWindowButton").click(tb_remove);
                if (!(TB_PrevHTML === "")) {
                    function goPrev() {
                        if ($(document).unbind("click", goPrev)) {
                            $(document).unbind("click", goPrev);
                        }
                        $("#TB_window").remove();
                        $("body").append("<div id='TB_window'></div>");
                        tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
                        return false;
                    }
                    $("#TB_prev").click(goPrev);
                }
                if (!(TB_NextHTML === "")) {
                    function goNext() {
                        $("#TB_window").remove();
                        $("body").append("<div id='TB_window'></div>");
                        tb_show(TB_NextCaption, TB_NextURL, imageGroup);
                        return false;
                    }
                    $("#TB_next").click(goNext);
                }
                document.onkeydown = function (e) {
                    if (e === null) {
                        keycode = event.keyCode;
                    } else {
                        keycode = e.which;
                    }
                    if (keycode == 27) {
                        tb_remove();
                    } else if (keycode == 190) {
                        if (!(TB_NextHTML === "")) {
                            document.onkeydown = "";
                            goNext();
                        }
                    } else if (keycode == 188) {
                        if (!(TB_PrevHTML === "")) {
                            document.onkeydown = "";
                            goPrev();
                        }
                    }
                };
                tb_position();
                $("#TB_load").remove();
                $("#TB_ImageOff").click(tb_remove);
                $("#TB_window").css({
                    display: "block"
                });
            };
            imgPreloader.src = url;
        } else {
            var queryString = url.replace(/^[^\?]+\??/, '');
            var params = tb_parseQuery(queryString);
            TB_WIDTH = (params['width'] * 1) + 30 || 630;
            TB_HEIGHT = (params['height'] * 1) + 40 || 440;
            ajaxContentW = TB_WIDTH - 30;
            ajaxContentH = TB_HEIGHT - 45;
            if (url.indexOf('TB_iframe') != -1) {
                urlNoQuery = url.split('TB_');
                $("#TB_iframeContent").remove();
                if (params['modal'] != "true") {
                    $("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>" + caption + "</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div></div><iframe frameborder='0' hspace='0' src='" + urlNoQuery[0] + "' id='TB_iframeContent' name='TB_iframeContent" + Math.round(Math.random() * 1000) + "' onload='tb_showIframe()' style='width:" + (ajaxContentW + 29) + "px;height:" + (ajaxContentH + 17) + "px;' > </iframe>");
                } else {
                    $("#TB_overlay").unbind();
                    $("#TB_window").append("<iframe frameborder='0' hspace='0' src='" + urlNoQuery[0] + "' id='TB_iframeContent' name='TB_iframeContent" + Math.round(Math.random() * 1000) + "' onload='tb_showIframe()' style='width:" + (ajaxContentW + 29) + "px;height:" + (ajaxContentH + 17) + "px;'> </iframe>");
                }
            } else {
                if ($("#TB_window").css("display") != "block") {
                    if (params['modal'] != "true") {
                        $("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>" + caption + "</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a> or Esc Key</div></div><div id='TB_ajaxContent' style='width:" + ajaxContentW + "px;height:" + ajaxContentH + "px'></div>");
                    } else {
                        $("#TB_overlay").unbind();
                        $("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:" + ajaxContentW + "px;height:" + ajaxContentH + "px;'></div>");
                    }
                } else {
                    $("#TB_ajaxContent")[0].style.width = ajaxContentW + "px";
                    $("#TB_ajaxContent")[0].style.height = ajaxContentH + "px";
                    $("#TB_ajaxContent")[0].scrollTop = 0;
                    $("#TB_ajaxWindowTitle").html(caption);
                }
            }
            $("#TB_closeWindowButton").click(tb_remove);
            if (url.indexOf('TB_inline') != -1) {
                $("#TB_ajaxContent").append($('#' + params['inlineId']).children());
                $("#TB_window").unload(function () {
                    $('#' + params['inlineId']).append($("#TB_ajaxContent").children());
                });
                tb_position();
                $("#TB_load").remove();
                $("#TB_window").css({
                    display: "block"
                });
                setupLightbox();
            } else if (url.indexOf('TB_iframe') != -1) {
                tb_position();
                if ($.browser.safari) {
                    $("#TB_load").remove();
                    $("#TB_window").css({
                        display: "block"
                    });
                    setupLightbox();
                }
            } else {
                $("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()) + " #VC-modalLightbox", function () {
                    setupLightbox();
                    setupLoginLightbox();
                    if (url.indexOf("swLogin=true") != -1) {
                        setupSwLoginLightbox();
                    }
                    tb_position();
                    $("#TB_load").remove();
                    tb_init("#TB_ajaxContent a.thickbox");
                    $("#TB_window").css({
                        display: "block"
                    });
                });
            }
        }
        if (!params['modal']) {
            document.onkeyup = function (e) {
                if (e === null) {
                    keycode = event.keyCode;
                } else {
                    keycode = e.which;
                }
                if (keycode == 27) {
                    tb_remove();
                }
            };
        }
    } catch (e) {}
}

function tb_showIframe() {
    $("#TB_load").remove();
    $("#TB_window").css({
        display: "block"
    });
}

function tb_remove() {
    $("#TB_imageOff").unbind("click");
    $("#TB_closeWindowButton").unbind("click");
    $("#TB_window").fadeOut("fast", function () {
        $('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();
    });
    $("#TB_load").remove();
    if (typeof document.body.style.maxHeight == "undefined") {
        $("body", "html").css({
            height: "auto",
            width: "auto"
        });
        $("html").css("overflow", "");
    }
    document.onkeydown = "";
    document.onkeyup = "";
    return false;
}

function tb_position() {
    $("#TB_window").css({
        marginLeft: '-' + parseInt((TB_WIDTH / 2), 10) + 'px',
        width: TB_WIDTH + 'px'
    });
    if (!(jQuery.browser.msie && jQuery.browser.version < 7)) {
        $("#TB_window").css({
            marginTop: '-' + parseInt((TB_HEIGHT / 2), 10) + 'px'
        });
    }
}

function tb_parseQuery(query) {
    var Params = {};
    if (!query) {
        return Params;
    }
    var Pairs = query.split(/[;&]/);
    for (var i = 0; i < Pairs.length; i++) {
        var KeyVal = Pairs[i].split('=');
        if (!KeyVal || KeyVal.length != 2) {
            continue;
        }
        var key = unescape(KeyVal[0]);
        var val = unescape(KeyVal[1]);
        val = val.replace(/\+/g, ' ');
        Params[key] = val;
    }
    return Params;
}

function tb_getPageSize() {
    var de = document.documentElement;
    var w = window.innerWidth || self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
    var h = window.innerHeight || self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
    arrayPageSize = [w, h];
    return arrayPageSize;
}

function tb_detectMacXFF() {
    var userAgent = navigator.userAgent.toLowerCase();
    if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox') != -1) {
        return true;
    }
}
    



/*
 * Superfish v1.4.8 - jQuery menu widget
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
 
 <img height=\"4\" width=\"7\" alt=\"Arrow\" src=\"/dafiles/Internet/co/sbimgl/furniture/img/icons/top_nav_down_arrow_icon.gif\" class=\"menudownarrowclass\" style=\"border: 0pt none;\">"
 
 
 */

;(function($){
	$.fn.superfish = function(op){

		var sf = $.fn.superfish,
			c = sf.c,
			$arrow = $(['<span class="',c.arrowClass,'"> &#160; </span>'].join('')),
			over = function(){
				var $$ = $(this), menu = getMenu($$);
				clearTimeout(menu.sfTimer);
				$$.showSuperfishUl().siblings().hideSuperfishUl();
			},
			out = function(){
				var $$ = $(this), menu = getMenu($$), o = sf.op;
				clearTimeout(menu.sfTimer);
				menu.sfTimer=setTimeout(function(){
					o.retainPath=($.inArray($$[0],o.$path)>-1);
					$$.hideSuperfishUl();
					if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
				},o.delay);	
			},
			getMenu = function($menu){
				var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
				sf.op = sf.o[menu.serial];
				return menu;
			},
			addArrow = function($a){ 
				$a.addClass(c.anchorClass).append($arrow.clone()); 	
			};
			
		return this.each(function() {
			var s = this.serial = sf.o.length;
			var o = $.extend({},sf.defaults,op);
			o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
				$(this).addClass([o.hoverClass,c.bcClass].join(' '))
					.filter('li:has(ul)').removeClass(o.pathClass);
			});
			sf.o[s] = sf.op = o;
			
			$('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {																									
				if (o.autoArrows) 
				addArrow( $('>div a:last-child',this)); //changes made by Sean Kerr to incorporate the new structure
			})
			.not('.'+c.bcClass)
				.hideSuperfishUl();
			
			var $a = $('a',this);
			$a.each(function(i){
				var $li = $a.eq(i).parents('li');
				$a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
			});
			o.onInit.call(this);
			
		}).each(function() {
			var menuClasses = [c.menuClass];
			if (sf.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
			$(this).addClass(menuClasses.join(' '));
		});
	};

	var sf = $.fn.superfish;
	sf.o = [];
	sf.op = {};
	sf.IE7fix = function(){
		var o = sf.op;
		if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
			this.toggleClass(sf.c.shadowClass+'-off');
		};
	sf.c = {
		bcClass     : 'sf-breadcrumb',
		menuClass   : 'sf-js-enabled',
		anchorClass : 'sf-with-ul',
		arrowClass  : 'menu-arrow',
		shadowClass : 'sf-shadow'
	};
	sf.defaults = {
		hoverClass	: 'sfHover',
		pathClass	: 'overideThisToUse',
		pathLevels	: 1,
		delay		: 800,
		animation	: {opacity:'show'},
		speed		: 'normal',
		autoArrows	: true,
		dropShadows : true,
		disableHI	: false,		// true disables hoverIntent detection
		onInit		: function(){}, // callback functions
		onBeforeShow: function(){},
		onShow		: function(){},
		onHide		: function(){}
	};
	$.fn.extend({
		hideSuperfishUl : function(){
			var o = sf.op,
				not = (o.retainPath===true) ? o.$path : '';
			o.retainPath = false;
			var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
					.find('>ul').hide().css('visibility','hidden');
			o.onHide.call($ul);
			return this;
		},
		showSuperfishUl : function(){
			var o = sf.op,
				sh = sf.c.shadowClass+'-off',
				$ul = this.addClass(o.hoverClass)
					.find('>ul:hidden').css('visibility','visible');
			sf.IE7fix.call($ul);
			o.onBeforeShow.call($ul);
			$ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
			return this;
		}
	});

})(jQuery);



