$(document).ready(function() {	
    
    // header gallery slideshow
    $('#header_gallery img:gt(0)').hide();
    setInterval(function(){
        $('#header_gallery :first-child').fadeOut()
        .next('img').fadeIn()
        .end().appendTo('#header_gallery');}, 
    7000);
    
    $('.block').hover(
        function () {
            $(this).addClass('block_over');
        }, 
        function () {
            $(this).removeClass('block_over');
        }
    );    

    
/*    // Clear search bar on click and add/remove class
    var defaultValue = $('.widget-container #s').val();
    $('.widget-container #s').click(function(){
        $('.widget-container #s').removeClass("blur");
        if(this.value == defaultValue){
            $('.widget-container #s').val("");
        }
        return false;
    });
    $('.widget-container #s').blur(function(){
        $('.widget-container #s').addClass("blur");
        if(this.value == ""){
            $('#s').val(defaultValue);
        }
    });    
    
    // Center Menu and define hover action
    var maxWidth = $('.menu-header').width();    
    var menuWidth = $('#menu-top_navigation').width();  
    var newMarginLeft = (maxWidth/2)-(menuWidth/2);
    
    $('#menu-top_navigation').css('margin-left', newMarginLeft+'px'); 
    
    $('#menu-top_navigation li').hover(
        function () {
            $(this).addClass('hover');
        }, 
        function () {
            $(this).removeClass('hover');
        }
    ); */
	
});

//runs only after page is completey loaded with graphics etc.
$(window).load(function () {
     
    var content_h = $('#content').height();
    var primary_h = $('.widget-container > div').height();  
    var primary_new_h = primary_h; //default height

    if ( primary_h > 300 && content_h <= 300 ) {
        primary_new_h = 300; //minimum height if content is short but sidebar is long
    }      

    if ( content_h > 300 ) {
        primary_new_h = content_h-36; //max height
    }

    $('.widget-container > div').css({height:primary_new_h+'px'});    
  
});    
