﻿(function($) {
    $.fn.adaptLightBox = function() {
        return this.each(function() {
            var aTag = $(this);
            var imgs = $('img', aTag);
            var img = imgs.eq(0);
            var theClass = img.attr("class");
            img.removeClass(theClass);
            aTag.addClass(theClass);
            var width = img.width();

            var theTitle = aTag.attr("title").toString();
            if (theTitle != "") {
                var str = "<p>" + theTitle + "</p>";
                aTag.append(str);
            }
            else {
                aTag.addClass("empty");
            }
            aTag.width(width);
        });
    };
})(jQuery);

$(function() {

    $("#col-mid a:has(img)").filter('[href$=.jpg],[href$=.gif],[href$=.bmp],[href$=.png],[href$=.JPG],[href$=.GIF],[href$=.BMP],[href$=.PNG]').addClass('lightbox');
    $("#col-mid table tr:nth-child(even)").addClass('oddrow');
    $("#slideHeader").scrollable({ circular: true, mousewheel: true }).autoscroll(7000).navigator();
    var phashString = window.location.hash;
    if (phashString.length > 1) {
        $("#promoslideheader").scrollable({ circular: true, speed: 1200 }).navigator({navi:"#promonav",naviItem: 'a',activeClass: 'active',history: true});
        $("#expertslideheader").scrollable({ circular: true, speed: 1200}).navigator({navi:"#promonav",naviItem: 'a',activeClass: 'active',history: true});
    } else {
        $("#promoslideheader").scrollable({ circular: true, speed: 1200 }).autoscroll({autopause:false, interval:10000}).navigator({navi:"#promonav",naviItem: 'a',activeClass: 'active',history: true});
        $("#expertslideheader").scrollable({ circular: true, speed: 1200 }).autoscroll({autopause:false, interval:10000}).navigator({navi:"#promonav",naviItem: 'a',activeClass: 'active',history: true});
    }
    $(".tabs").tabs(".panes > div");
    $(".ceebox").ceebox();
    $("#qualificationSummaryList").tabs("#qualificationSummaryList div.pane", { tabs: 'h3', effect: 'slide' });
    tabSelect();
});

addLoadEvent(function() {
$("#col-mid a.lightbox").adaptLightBox();
$("#col-mid a.lightbox").lightBox();
});

//lightbox javascript for image gallery
$(function() {

    $(".galleryContainer a:has(img)").filter('[href$=.jpg],[href$=.gif],[href$=.bmp],[href$=.png],[href$=.JPG],[href$=.GIF],[href$=.BMP],[href$=.PNG]').addClass('lightbox');
    $(".galleryContainer table tr:nth-child(even)").addClass('oddrow');
});

addLoadEvent(function() {
    $(".galleryContainer a.lightbox").adaptLightBox();
    $(".galleryContainer a.lightbox").lightBox();
    formPopulate();

});
