// Initialize the Scripts for this site.

$(document).ready(function() {
    
    // To open new windows.
    $('.lnkBlank').click(function() {
        window.open($(this).attr('href'), 'newWindow', '');
        return false;
    });
    
    // Select the text in the search box:
    $('input.txtSearch').focus(function() {
        $(this).select();
    });
    
    // Hides list item images if no src is defined:
    $('img.listItemImage').each(function() {
        if ($(this).attr('src') == '') {
            $(this).hide();
        }
    });
    
    // Social Media / Links in left column:
    $('#socialMedia ul li:not(:last)').each(function() {
        $(this).after('<li class="separator">|</li>');
    });
    
    var buttonLink;
    $('#slideTabs div.slides div.item').each(function() {
        buttonLink = $(this).attr('id');
        buttonText = $(this).find('img').attr('alt');
        $('#slideTabs div.tabLinks').append('<div class="tab"><a href="#' + buttonLink + '">' + buttonText + '</a></div>');
        $(this).hide(); // Hide the slide.
    });
    
    
    $('#slideTabs div.slides div.item:first').fadeIn().addClass('current');
    $('#slideTabs div.tabLinks div.tab:first').addClass('current');
    
    var slideLink;
    $('#slideTabs div.tabLinks div.tab').click(function() {
        $('#slideTabs div.tabLinks div.tab').removeClass('current');
        slideLink = $(this).find('a').attr('href');
        $(this).addClass('current');
        
        //$('#slideTabs div.slides div.current').fadeOut(5000).removeClass('current');
        
        $('#slideTabs div.slides div.current')
            .animate({opacity:0}, 1000)
            .removeClass('current');
        
        //$('#slideTabs div.slides div#' + slideLink).fadeIn(5000).addClass('current');
        
        $('#slideTabs div.slides div#' + slideLink)
            .animate({opacity:1}, 1000)
            .addClass('current');
        
        return false;
    });
});
