﻿var project_cnt = "";

$(function(){
    DetectMobile();
    InitOpacityHeight();
    $(window).bind('resize',SetOpacityHeight);
    
})


function InitOpacityHeight()
{
        
    $.ajax({
        url: "ajax/farm_ajax.aspx?task=count_projects&page_type=feature",
        context: document.body,
        success: function(msg){
            if(msg != "")
            {
                project_cnt = msg;
                SetOpacityHeight();
            }
        }
    });
}

function SetOpacityHeight()
{
    var scroll_offset = 0;
    var lines = Math.ceil(eval(project_cnt)/3);
    var bg_height = lines * 245 + 350;
    var win_height = $(window).height();
    var footer_height = 20;
    var min_height = win_height - footer_height;
    if(bg_height < min_height)
    {
        bg_height = min_height;
        scroll_offset = 0;
    }
    else
    {
        scroll_offset = 17;
    }
    $('.content_bg').css('height',bg_height+'px');
    $('.content_bg_mobile').css('height', bg_height + 'px');
    CenterContent('center_content','1030',scroll_offset);

}

