/**
 * jQuery.fullBg
 * Version 1.0
 * Copyright (c) 2010 c.bavota - http://bavotasan.com
 * Dual licensed under MIT and GPL.
 * Date: 02/23/2010
**/
(function($) {
  $.fn.amEm = function(){
    var bgImg = $(this);        
    var content = $('.content-container .content .content-text');
    var maxHeight=content.height();
    var menuHeight=$('.content-container').height()-maxHeight;
    
    function resizeImg() {
      var imgwidth = bgImg.width();
      var imgheight = bgImg.height();
 
      var winwidth = $(window).width();
      var winheight = $(window).height();//-670;
 
      var widthratio = winwidth / imgwidth;
      var heightratio = winheight / imgheight;
 
      var widthdiff = heightratio * imgwidth;
      var heightdiff = widthratio * imgheight;
 
      if(heightdiff>winheight) {
        bgImg.css({
          width: winwidth+'px',
          height: heightdiff+'px'
        });
      } else {
        bgImg.css({
          width: widthdiff+'px',
          height: winheight+'px'
        });     
      }
    }
    
    function resizeContent(){
       /* $('#right_transbox').css('minHeight',$(window).height()-30);*/
    }
    resizeImg();
    resizeContent();
    $(window).resize(function() {
      resizeImg();
      resizeContent();
    }); 
  };
})(jQuery);

amem = {
    stickerCount:0,
    sticker:null,
    stickerImgs:null,
    activeImgIdx:0,
    interval:5000,
    fadeSpeed:500,
    init:function(){
        amem.sticker=$('a.sticker');
        amem.stickerImgs=amem.sticker.find('img');
        amem.stickerCount=amem.stickerImgs.length;
        amem.activeImgIdx=0;
    },
    fade:function(){
        amem.stickerImgs.eq(amem.activeImgIdx).fadeOut(amem.fadeSpeed);
        amem.activeImgIdx=(amem.activeImgIdx+1)%amem.stickerCount;
        amem.stickerImgs.eq(amem.activeImgIdx).fadeIn(amem.fadeSpeed);
        setTimeout('amem.fade()',amem.interval);
    }
};

$(window).load(
    function() {

    //$('#bgImg').amEm();
    $('#supersize').amEm();
    amem.init();
    setTimeout('amem.fade()',amem.interval);
   }
);

