﻿/* Dom Ready */
$(document).ready(function(){ 
    $(".accordion").accordion({ autoHeight: false });
    $("a[rel^='prettyPhoto']").prettyPhoto();
    $(".breadcrumNavigation ul li:first").css("padding-left", "0px");
    $("img.readmoreImage")
    .mouseover(function() { 
	    var src = $(this).attr("src").match(/[^\.]+/) + "over.jpg";
		    $(this).attr("src", src);
	    })
    .mouseout(function() {
	    var src = $(this).attr("src").replace("over", "");
	    $(this).attr("src", src);
    });       			
    $(".searchInputBox td.ms-sbcell:first").css({border: 'none'});
    $(".searchInputBox td.ms-sbcell:last").css({border: 'none'});
    $(".searchInputBox td.ms-sbcell input:first").css({border: 'solid 1px #DEDEDE', height: '14px'});
    $(document).pngFix();
}); 

/* Custom Dropdown Script*/
$(function() {
    var dd = $('.customDropdown');
    if(dd.find('li').length > 15){
        dd.addClass('long');
    }
    dd.click(function(event) {
        dd.toggleClass('selected');
        event.stopPropagation();
    });
    $(document).click(function() {
        dd.removeClass('selected');
    });
});

// Make sure the thin grey top lines are aligned
$(function(){
    // If not framed
    if (window.location === top.location) {
        // Find container
        var  headingContainer = $('.contentRightSubPage .headingContainer');
        if(headingContainer.length > 0) {
            // Calculate padding top for the nav panel
            var oneLineHeight = 37,
                oneLinePadding = 82,
                height = headingContainer.height(),
                diff = height - oneLineHeight;
            $('.contentLeftNavigation').css('padding-top', oneLinePadding + diff);
        }
    }
});

// Another fix
$(function (){
    var pageImage = $('.pageImage');
    if(pageImage.find('img').length < 1){
        pageImage.css('display', 'none');
    }
});

// ...and another one
$(function (){
    if ($('.frontPageBottomContainer .frontPageBottomLeft').find().length === 0 && 
        $('.frontPageBottomContainer .frontPageBottomLeft').text().length === 0 && 
        $('.frontPageBottomContainer .frontPageBottomRight').find().length === 0 && 
        $('.frontPageBottomContainer .frontPageBottomRight').text().length === 0) {
        $('.frontPageBottomContainer').css('display', 'none');
    }
});
