$(document).ready(function() {
   //home header rotation script
   if ($(".home #hdrImg #container").length > 0)
   {
      $.fn.cycle.defaults.speed   = 500;
      $.fn.cycle.defaults.timeout = 7500;

      $('#container .items').cycle({
          fx: 'fade'
         ,pager: "#container .navi"
         ,sync: 1
         //,cleartype: true
         //,cleartypeNoBg: true
         //,pause: 1
         //,pauseOnPagerHover: 1
      });
      //append a pause/resume function to the navigation
      $("#container .navi").append("<a id='cycle_toggle' class='pause' href='javascript:void(0);'>Pause</a>");
      $("#cycle_toggle").bind("click",function(){
         var button_txt = $(this).text();
         switch(button_txt.toLowerCase())
         {
            case "pause":
               $(this).text("Resume");
               $(this).addClass("resume").removeClass("pause");
               $('#container .items').cycle('pause');
            break;
            case "resume":
               $(this).text("Pause");
               $(this).addClass("pause").removeClass("resume");
               $('#container .items').cycle('resume');
            break;
         }
      });
   }//end home pg img rotation
   
   if($(".default #homeGrid").length > 0)
   {
      $(".default #homeGrid .column").each(function(){
         $(this).prepend('<iframe class="iframe" frameborder="0" style="position: absolute; z-index: 1; opacity: 0; filter:alpha(opacity=0); width: '+($(this).width())+'px; display: none;"></iframe>');
      });
      $(".default #homeGrid .column").hover(function(){
         //over
         $(this).children().show();
         $(this).children("iframe").css("height",($(this).height()-34)+"px");
         $(this).children(".homeTitle").addClass("active");
      },function(){
         //out
         $(this).children(":not('.homeTitle')").hide();
         $(this).children(".homeTitle").removeClass("active");
      });
   }//end interior home box navi
   
   //resize home grid
   if ($("body").hasClass("home")) resize_homeGrid_columns();
});
//---------------------------------------
$(window).load(function() {
   if ($("body").hasClass("home")) resize_homeGrid_columns();
});
//---------------------------------------
function resize_homeGrid_columns()
{
   if($("#homeGrid").length > 0)
   {
      var col_height = 140;
      $.each($("#homeGrid").find(".homeContent"),function(i,el){
         $(el).attr("style","");

         if (i > 0) {
            var el_height = $(el).height();

            if (el_height > col_height) {
               col_height = el_height;
               //return false;
            }//end if
         }
      });

      $("#homeGrid div.homeContent").attr("style","height: " + col_height + "px");//:not('#homeGrid #column1 .homeContent')
   }
}


