$(document).ready(function(){
  $('#drafts #footer').each(function(){
   $(this).find('.mojj_copy').addClass('bg_black');
   $(this).find('.podhod_copy').addClass('bg_black');
  });

  $.preloadImages(
    '/img/illustrations/liners5.jpg'
  );
/*
  $.preloadImages(
    '/img/illustrations/ice/ice.jpg',
    '/img/illustrations/ice/vanya.jpg',
    '/img/illustrations/ice/borya.jpg',
    '/img/illustrations/ice/slava.jpg',
    '/img/illustrations/ice/liza.jpg',
    '/img/illustrations/ice/tolya.jpg',
    '/img/illustrations/ice/nikita.jpg',
    '/img/illustrations/ice/guitar.jpg'
  );
  $('a.switch').click(function(){
    if ($(this).hasClass('selected')) return false;
    var obj = $(this);
    $('#ice div div').fadeOut(200, function(){
      $(this).attr('class', obj.attr('mode'));
      $('a.switch.selected').parents('div').eq(0).removeClass('bg_red');
      $('a.switch').removeClass('selected');
      obj.addClass('selected');
      obj.parents('div').eq(0).addClass('bg_red');
      $(this).fadeIn(200);
    })
    return false;
  });
*/

/*
 $('.channels span b').click(function(){
  switch_channel($(this));
 });
*/
});

$(window).bind('load', function(){
 $('#layout').show();
 $('a.switch').eq(_random($('a.switch').length)).click();

/*
  switch_channel($('.channels span b:nth(2)'));
  if (!$.browser.msie||$.browser.version.number>=7)
    $('#layout').fadeIn('500');
  else
    $('#layout').show();
  $('body').css('background-image', 'none');
*/
});
/*
function switch_channel(obj) {
  if (obj.hasClass('selected')) return;
  $('.channels span b').removeClass('selected');
  var stream = obj.attr('stream');

  $('.translation').html('<object id="flowplayer" width="352" height="288" data="/swf/flowplayer-3.1.5.swf"'+
   'type="application/x-shockwave-flash">'+

   '<param name="movie" value="/swf/flowplayer-3.1.5.swf" />'+
   '<param name="allowfullscreen" value="false" />'+

   '<param name="flashvars" value=\'config={"clip":"http://vserver.artx.ru:8090/'+stream+'"}\' />'+
    '</object>');
  obj.addClass('selected');
}
*/

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.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)

_random = function(b) {
  return Math.floor(b*Math.random());
}
