﻿$(document).ready(function() {

    //preload the images and work out the startItem
    var startItem = 0;
    var counter = 0;
    $("h3.IH_link").each(function() {
        jQuery("<img>").attr("src", BaseLocPath + $(this).attr('imgSrc'));
        if ($(this).attr('startItem') == 'true')
            startItem = counter;
        counter++;
    });

    jQuery.fadeBackIn = function() {
        $("#IH_hero-image").attr("src", currentimg);
        $("#IH_hero-image").fadeIn("slow");
    }

    //set initial image to second one in collection
    var currentimg = BaseLocPath + $($("h3.IH_link")[startItem]).attr('imgSrc');
    $("#IH_hero-image").fadeOut("fast", $.fadeBackIn);

    $('#IH_accordion').accordion({ active: startItem, header: "h3", autoHeight: false });

    $("h3.IH_link").click(function() {
        currentimg = BaseLocPath + $(this).attr('imgSrc');
        $("#IH_hero-image").fadeOut("fast", $.fadeBackIn);
    });

    //fix the arrow bg image in ie6
    if ($.browser.msie && $.browser.version < 7) {
        $('.ui-state-active span').each(function() {
            //$(this).css('background-image', 'url(/windowsmobile/components/WMTAHP/InsiderHeader/img/arrow.gif)');
//            $(this).css({ filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,src=\'/windowsmobile/components/WMTAHP/InsiderHeader/img/arrow.png\', sizingMethod=\'image\')' });
//            $(this).css('background-image', 'none');
//            $(this).css('margin-left', '20px');
//            $(this).css('width', '16px');
        });
    }
});
            