//Hide the cart on the main page
// $(document).ready(function(){
//     $('#addedcart').slideUp();
// });
// Or alternatively, hide the sidebar if the cart has items.
// $(document).ready(function(){
//     $('#right-conbox').css({position:"relative",top:"-" + $('#addedcart').height() + "px",zIndex:"-1"});
//     
// });

function positionFooter(){
    var imgHeight = $('.bg').height();
    var leftPanelHeight = $('#leftpanel').height();
    var rightPanelHeight = $('#rightpanel').height();
    var panelHeight = (leftPanelHeight > rightPanelHeight) ? leftPanelHeight : rightPanelHeight;
    
    var calcHeight = imgHeight;
    panelHeight += 108; //to compensate for the blackbar header of 108px
    
    if (panelHeight > calcHeight){
        calcHeight = panelHeight;
    }

    // Minus the image smallest size of 1000, plus 90px
    calcHeight = calcHeight - 1090; 
    
    // If we reach a certain width, just have the footer show up a little bit on the bottom of the screen.
    if (calcHeight > -50) {
        calcHeight = -50;
    }
    // If the image is too small, make sure the footer doesn't ride up higher than it should.
    if (calcHeight < -345) {
        calcHeight = -345;
    }
    
    //finally set the calculated footer position
    $("#footer").css("margin-top", calcHeight+"px");
}

$(window).load(function(){
 $(function(){
     positionFooter(); 
     
     $(window).resize(positionFooter);
 });
});
