$(function(){


    $.vegas({
        src:'/de-wAssets/img/layout/background.jpg',
        valign: 'top'
    });



    $('input[name="searchTerm"]').bind(
    {
        focus : function()
        {
            if($(this).val() == _trans['search'])
            {
                $(this).val('');
            }
        },
        blur : function()
        {
            if($(this).val() == '' || $(this).val() == ' ')
            {
                $(this).val(_trans['search']);
            }
        }
    });

    $('.searchBtn').click(function()
    {
        if( $('input[name="search"]').val() != '' &&
            $('input[name="search"]').val() != ' ' &&
            $('input[name="search"]').val() != _trans['search'] )
        {
            $('#searchForm').submit();
        }
        else
        {
            alert(_trans['enterTerm']);
        }
    });
    
    
    
    
    $('.imgFade').css({ position : 'absolute' });
    $('.imgFade').hide();
    $('.imgFade:first').show();
    $('.imgFade:first').attr('rel','active');
    
    setInterval(function(){
        $this = $('.imgFade[rel="active"]');
        $this.fadeOut('slow').attr('rel','');
        if( typeof $this.next('.imgFade').attr('src') == 'undefined' ){
            $('.imgFade:first').fadeIn(750);
            $('.imgFade:first').attr('rel','active');
        }else{
            $this.next('.imgFade').fadeIn(750);
            $this.next('.imgFade').attr('rel','active');    
        }
    },5000);
    



    
    setWindow();
    $(window).resize(setWindow);
});

function getColHeight()
{
    $length = $('.content').find('.col');
    $height = 0;
    for(i=0;i<$length.length;i++)
    {
        if($('.col:eq('+i+')').height() > $height ) $height = $('.col:eq('+i+')').height();
    }

    $('.col').height( $height );
}


function setWindow()
{
    _defaults = {
        'maxContentWidth' : 950,
        'maxBlockWidth' : 200
    };

    $client = {
        'width' : $(window).width(),
        'height': $(window).height()
    };

    $getBlockWidth = $('.inlayLeft').width();

    $maxClientWidth = _defaults['maxContentWidth']+(_defaults['maxBlockWidth']*2);
    if($maxClientWidth <= $client['width'])
    {
        $('.inlayLeft,.inlayRight').width(_defaults['maxBlockWidth'])
        $('.inlayCenter').width( $client['width'] - ($getBlockWidth*2) );
    }
    else
    {
        $newWidth = ($client['width'] - $('.inlayCenter').width()) / 2;
        $('.bgRed').width( $newWidth );
        $('.inlayCenter').width( _defaults['maxContentWidth'] );
    }
    
    //UPDATE: 2011-07-28
    if($client['width'] <= _defaults['maxContentWidth']){
        $('.inlayLeft,.inlayRight').width(0);    
    }

}


setInterval('getColHeight()',50);
//UPDATE: 2011-07-28
setInterval('setWindow()',50);

