function next_news()
{
  jQuery('.news .nav > .next').click();
  setTimeout("next_news()",6500);
}
function empty() {}

var croto=0;
var hpmousemove=false;
function rotate_home(frame)
{
  if(!hpmousemove||frame!=null)
  {
    var data=jQuery('.home.promo').attr('bgclass');
    data=data.split(',');
    croto++;
    if(croto>=data.length)
      croto=0;
    if(frame!=null)
    {
       var tmp;
       //FIND FRAME
       for(var i=0;i<data.length;i++)
       {
          tmp=data[i].split(':');
          if(tmp[0]==frame)
            croto=i;
       }
    }
    data=data[croto].split(':');
    var bgclass=data[0];
    var btnhref=data[1];
      jQuery('.home.promo .layer1').fadeOut(250,function() {
      jQuery('.home.promo .layer1').attr('class','layer1 '+bgclass);
      jQuery('.home.promo .layer1').fadeIn(500);
    });
    jQuery('.home.promo .more_btn').find('a').attr('href',btnhref);
  } 
  if(frame==null)
    setTimeout("rotate_home(null);",5000);
}

(function(jQuery) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  jQuery.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src= arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)
var curAccord=null;
jQuery(function() {

  jQuery(".stripe:odd").addClass("odd");
  jQuery(".rollodiv")
   .bind("click", function () { location.href=jQuery(this).find("a").attr("href"); })
   .bind("mouseover",function() { 
     jQuery(this).css("background-image",jQuery(this).css("background-image").replace("_up","_over")); })
   .bind("mouseout",function() { 
     jQuery(this).css("background-image",jQuery(this).css("background-image").replace("_over","_up")); });

  jQuery(".hoverdiv")
   .bind("click", function () { location.href=jQuery(this).find("a").attr("href"); })
   .bind("mouseover",function() { jQuery(this).addClass("hover"); })
   .bind("mouseout",function() { jQuery(this).removeClass("hover"); });



  jQuery('.news .nav > .prev')
    .bind("mouseover",function() { jQuery(this).addClass('hover');})
    .bind("mouseout",function()  { jQuery(this).removeClass('hover');})
    .bind("click",function() 
    { story=jQuery('.news .story:visible'); 
      story.hide();
      prev=story.prev('.story');
      if(prev.length!=0)
        prev.show();
      else
        jQuery('.news .story').last().show(); 
    });

  jQuery('.news .nav > .next')
    .bind("mouseover",function() { jQuery(this).addClass('hover');})
    .bind("mouseout",function()  { jQuery(this).removeClass('hover');})
    .bind("click",function() 
    { story=jQuery('.news .story:visible'); 
      story.hide();
      next=story.next('.story');
      if(next.length!=0)
        next.show();
      else
        jQuery('.news .story').first().show(); 
    });
  if(jQuery('.screen_nav_wrapper').length>0)
  {
    jQuery('.screen_nav_wrapper .item')
      .bind("click",function() { 
        jQuery('.screen_nav_wrapper .item').removeClass('on'); 
        jQuery(this).addClass('on');
        jQuery('.display_screen img').attr('src',jQuery(this).attr('bgclass'));
      })
      .bind("mouseover",function() { jQuery(this).addClass('hover');})
      .bind("mouseout",function() { jQuery(this).removeClass('hover');});
  }

  if(jQuery('.accordion').length>0)
  {
    jQuery('.accordion .title')
      .bind('click',function() {
        if(curAccord==null)
          curAccord=this;
        else
        {
          jQuery(curAccord).next().animate({'height':'0px'});
          curAccord=this;
        }
        jQuery(this).next().animate({'height':jQuery(this).next().find('.desc').height()+50});
      });
  }
  if(jQuery('.home.promo').length>0)
  {
    jQuery('.home.promo')
      .bind('mousemove',function() {
        if(!hpmousemove)
          setTimeout("hpmousemove=false;",5000);
        hpmousemove=true;
      });

    jQuery('.home.promo .layer3 img')
      .bind("click",function(){ rotate_home(jQuery(this).parent().attr('class')); })
      .bind("mouseover",function() { jQuery(this).attr('src',jQuery(this).attr('src').replace('_off','_over'));})
      .bind("mouseout",function()  { jQuery(this).attr('src',jQuery(this).attr('src').replace('_over','_off'));});

    jQuery('.news .story').last().show();
    setTimeout("rotate_home(null);",5000);
    setTimeout("next_news()",5000);
    jQuery.preLoadImages('../home/hmbanner1.png','../home/hmbanner2.png','../home/hmbanner3.png','../home/hmbanner4.png');

  }
});
