jQuery.fn.equalCols = function(){
    //Array Sorter
    var sortNumber = function(a,b){
        return b - a;
    };
    var heights = [];
    //Push each height into an array
    $(this).each(function(){
        heights.push($(this).height());
    });
    heights.sort(sortNumber);
    var maxHeight = heights[0];
    return this.each(function(){
        //Set each column to the max height
        if (($(this).attr("id") == 'left_textarea_box' || $(this).attr("id") == 'grey_text_subarea') && $(this).height() != maxHeight)
        {
            var h = maxHeight - 47;
            $(this).css({
                'height': h
            });
        }
        else
        {
            $(this).css({
                'height': maxHeight
            });
        }
    });
};

var timer;
jQuery(document).ready(function(){

    //$('#left_textarea_box,#right_content,#grey_text_subarea').equalCols();

    jQuery('#shortmenu1_content').bind("mouseenter",function(){
        try{
            clearTimeout(timer);
        }catch(e){}
        jQuery('#dayinfo').load('/ajax', {
            secid: '1'
        });
    });
    jQuery('#shortmenu2_content').bind("mouseenter",function(){
        try{
            clearTimeout(timer);
        }catch(e){}
        jQuery('#dayinfo').load('/ajax', {
            secid: '2'
        });
    });
    jQuery('#shortmenu3_content').bind("mouseenter",function(){
        try{
            clearTimeout(timer);
        }catch(e){}
        jQuery('#dayinfo').load('/ajax', {
            secid: '3'
        });
    });
    jQuery('#shortmenu_box').bind("mouseleave",function(){
        timer = setTimeout("jQuery('#dayinfo').load('/ajax')", 2000);

    });

    $('#dayinfo_box').live("mousemove",function(){
        //$('#shortmenu_right_content').addClass('red');
        try{
            clearTimeout(timer);
        }catch(e){}
    });
    $('#dayinfo_box').live("mouseout",function(){
        //$('#shortmenu_right_content').removeClass('red');
        timer = setTimeout("jQuery('#dayinfo').load('/ajax')", 2000);
    });

    $('#shortmenu_right_content').live('click', function(){
        window.location.href= $('#shortmenu_right_content_link').attr('href');
    })

//         $('#menu a').attr('href', function(){
//             return $(this).hasClass('main_page') || !$(this).attr('href') || $(this).attr('href').indexOf('javascript')!=-1 || $(this).hasClass('up_arrow') ? $(this).attr('href') : $(this).attr('href')+'#tresc'}
//         );
//
//         $('#left_grey_textarea_box a').attr('href', function(){
//             return $(this).hasClass('main_page') || !$(this).attr('href') || $(this).attr('href').indexOf('javascript')!=-1 || $(this).hasClass('up_arrow') ? $(this).attr('href') : $(this).attr('href')+'#tresc'}
//         );
//         $('#left_textarea_box a').attr('href', function(){
//             return $(this).hasClass('main_page') || !$(this).attr('href') || $(this).attr('href').indexOf('javascript')!=-1 || $(this).hasClass('up_arrow') ? $(this).attr('href') : $(this).attr('href')+'#tresc'}
//         );
//         $('#right_content a').attr('href', function(){
//             return $(this).hasClass('main_page') || !$(this).attr('href') || $(this).attr('href').indexOf('javascript')!=-1 || $(this).hasClass('up_arrow') ? $(this).attr('href') : $(this).attr('href')+'#tresc'}
//         );


});

function validateSearch() {
    if($.trim($('#search_keywords').attr('value'))=='' || $.trim($('#search_keywords').attr('value'))=='Szukaj...') return false
    else {
        location.href = "/szukaj/"+$.trim($('#search_keywords').attr('value'));
    //return false;
    }
}
