$(document).ready(function(){
  //$(window).bind("resize", resizeWindow);
 
  /*function resizeWindow(e){
    var newWindowWidth = $(window).width(),
		halfWindowWidth = newWindowWidth / 2,
		halfBillboardWidth = $("#billboard").width() / 2,
		halfContainerWidth = 470,
		halfBtnsWidth = ($("#btns").width() + 60) / 2;
		
    //$("#billboard").css({"left": halfWindowWidth - halfBillboardWidth});
    //$("#rotator").find("div").css({"width":$(window).width(),"height":$(window).height()}); 
	
    //$("#btns").css({"left": halfContainerWidth - halfBtnsWidth});
  }*/


  /*var timr = setInterval(function(){
	   $("#rotator").css({"width":$(window).width()-1,"height":$(window).height()-1});
	   $("#rotator").find("div").css({"width":$("#rotator").innerWidth(),"height":$("#rotator").innerHeight()});
    },300);*/
    var timr = setInterval(function(){
    	   $("#rotator").css({"width":$(window).width()-1});
    	   $("#rotator").find("div").css({"width":$("#rotator").innerWidth()});
      },300);
   
  $("#btns").hover(function(){
	   $("#rotator").css({"width":$(window).width()-1,"height":$(window).height()-1}); 
	   $("#rotator").find("div").css({"width":$("#rotator").innerWidth(),"height":$("#rotator").innerHeight()});
  });
  
  $("#rotator").find("div").click(function(e){
		window.location = $(this).find("a").attr("href");
		e.preventDefault();
	}).each(function(){
		$(this).css({"background-color": $(this).attr("data-color")});
	});

  $('#rotator').cycle({ 
      fx:     'fade', 
      speed:  '800', 
      timeout: 9000,
      pager:'#btns',
	  sync:true,
	  height:960,
	  containerResize:1,
	  fit:0,
	  after:function(){
	    $("body").css({"background-color":$("#rotator").find(">div:visible").attr("data-color")}); 
	}
  });
  
  $("#rotator").find("div").each(function(i){
      var title = $(this).attr("data-title");
      $("#btns").find("a").eq(i).html(title)
  });
   $("#btns").find("a").not(":last").append("<span class='sep'> / </span>");
 //resizeWindow();
});

