/*
   layout.js
*/

var flag = false;
var containerHeight;

$(document).ready(function(){
   
   var sideHeight = $("#sidemenu").height();
   sizeADJ();
   
   containerHeight = $("#container").height();
   
   /*
   if($("#contents").height() < $(window).height()){
      $("sidemenu").css("height",$(window).height()-$("#foot").height())
      $("#contents").css("height",$(window).height()-$("#foot").height());
   }
   */
   
   $(window).resize(function(){
      sizeADJ();
   });
   
   function sizeADJ(){
      if($(window).height() <= sideHeight){
         $("#sidemenu").css("height",sideHeight);
         //$("#container").css("height",$(window).height()-$("#foot").height());
      }else{
         $("#sidemenu").css("height",$(window).height());
         //$("#container").css("height",$(window).height()-$("#foot").height());
         $("#sidemenu").css("top","0");
      }
      /*
      if($("#container").height() < $(window).height()){
         $("#container").css("height",$(window).height()-$("#foot").height());
      }else{
         $("#container").css("height","auto");
      }
      */
   }
   
   $(window).scroll(function(){
      if($(window).height() <= sideHeight){
         //$("#testtext").text("true");
         if($(this).scrollTop()+$(window).height() > sideHeight){
            $("#sidemenu").css("bottom","0");
            $("#sidemenu").css("top",$(window).height()-sideHeight);
         }else{
            $("#sidemenu").css("bottom","0");
            $("#sidemenu").css("top",-$(this).scrollTop());
         }
      }else{
         //$("#sidemenu").css("top",$(this).scrollTop());
         //$("#testtext").text("true");
      }
   });
   
});



