// 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();
        }
    });
    
    // Remove bottom border on last menu item:
    $('#Menu li.item:last').css('border-bottom','0px');
    
    $('#column2 div.heading').each(function() {
        if ($(this).height() >= 242) {
            $(this).wrapInner('<div class="hwrap"></div>');
            $(this).css({'height':'120px', 'line-height':'25px'});
            $('.hwrap').css({'padding':'30px 0 0'});
        } else if ($(this).height() >= 121) {
            $(this).wrapInner('<div class="hwrap"></div>');
            $(this).css({'height':'120px', 'line-height':'35px'});
            $('.hwrap').css({'padding':'25px 0 0'});
        }
    });
    
    //$('dl#homeBlock dt').append('<img src="/home-tab-top.gif" width="148" height="10" alt="" class="homeTabCorner" />');
    
    var link = '';
    var theClass = '';
    var clickLink = '';
    $('dl#homeBlock dt').each(function() {
        link = $(this).find('a').attr('href');
        theClass = $(this).attr('class');
        $(this).append('<a href="' + link + '"><img src="/home-tab-top.gif" width="148" height="10" alt="" class="homeTabCorner" /></a>');
        $(this).parent().find("dd." + theClass + ":not('.testimonies')").click(function() {
            theClass = $(this).attr('class');
            location.href = $(this).parent().find('dt.' + theClass).find('a').attr('href');
        });
        $(this).parent().find("dd:not('.testimonies')").css('cursor','pointer');
    });
    
    // Corners for bottom left area:
    $('#bottomLeft').append('<img src="left-corner-top-left.gif" width="10" height="10" alt="" class="cornerTopLeft" /><img src="left-corner-top-right.gif" width="10" height="10" alt="" class="cornerTopRight" />')
    $('#bottomLeft img.cornerTopLeft').css({'position':'absolute','top':'0px','left':'0px'});
    $('#bottomLeft img.cornerTopRight').css({'position':'absolute','top':'0px','right':'0px'});
    
    // Staff Section Scripts:
    
        // Main Staff List Page:
        $('.staffList div.item').each(function() {
            if ($(this).find('div.jobTitle').html() == '') {
                $(this).find('div.jobTitle').remove();
            }
            if ($(this).find('div.phoneNumber').html() == '') {
                $(this).find('div.phoneNumber').remove();
            }
            if ($(this).find('div.emailAddress').html() == '') {
                $(this).find('div.emailAddress').remove();
            }
        });
        
        // Staff Detail Page:
        $('.staffDetail').each(function() {
            if ($(this).find('div.jobTitle').html() == '') {
                $(this).find('div.jobTitle').remove();
            }
            if ($(this).find('div.phoneNumber').html() == '') {
                $(this).find('div.phoneNumber').remove();
            }
            if ($(this).find('div.emailAddress').html() == '') {
                $(this).find('div.emailAddress').remove();
            }
        });
    
    $('body').ieDetector();
    
    //alert($('body#page').height());
    
});
