$(document).ready(function() {
   if ($("body").hasClass("home")) resize_homeGrid_columns();
   
   if ($(".page_index #hdrImg .item").length > 1)
   {
      $.fn.cycle.defaults.speed   = 500;
      $.fn.cycle.defaults.timeout = 10000;

      $('#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);'><span>Pause</span></a>");
      $("#cycle_toggle").bind("click",function(){
         var target = $(this).children("span");
         var button_txt = target.text();
         switch(button_txt.toLowerCase())
         {
            case "pause":
               target.text("Resume");
               $(this).addClass("resume").removeClass("pause");
               $('#container .items').cycle('pause');
            break;
            case "resume":
               target.text("Pause");
               $(this).addClass("pause").removeClass("resume");
               $('#container .items').cycle('resume');
            break;
         }
      });
   }
});
//---------------------------------------
$(window).load(function() {
   if ($("body").hasClass("home")) resize_homeGrid_columns();
});
//---------------------------------------
function resize_homeGrid_columns()
{
   if($("#homeGrid").length > 0)
   {
      var col_height = 136;
      $.each($("#homeGrid").find(".homeContent"),function(i,el){
         $(el).attr("style","");

         if (i < 4) {
            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");
   }
}
