$(function() {
  // jQuery Cycle
	$("#work-list").cycle({
	  fx:     'scrollHorz', 
    speed:  800, 
    timeout: 0,
    delay:  -1000,
		sync: true,
	  prev: $(".bt-left"), 
	  next: $(".bt-right")
	});
	
	$(window).resize(function() {
    var contents = $('#main, #internal');
    var top = ($(this).height() / 2) - (contents.height() / 2);
    var left = ($(this).width() / 2) - (contents.width() / 2);
    
    if ( top < 0 ) {
      top = 0
    };
    
    contents.stop(true, true).animate({'paddingTop': top, }, 500);
    
  }).trigger('resize');
	
	// var defineContentSize = function(aContent) {
	//     console.log($(window).width(), $(aContent).width())
	//     if ($(window).width() > $(aContent).width()) {
	//       $(aContent).width($(window).width());
	//     }
	//     if ($(window).height() > $(aContent).height()) {
	//       $(aContent).height($(window).height());
	//     }
	//   };
	//   
	//   var scrollToElement = function(aEl) {
	//     var offset = $(aEl).offset();
	//     $('html, body').animate({scrollTop:offset.top}, 'slow');
	//   };
	//   
	//   var addNewPage = function(index, html) {
	//     viewport = $(window);
	//     wrapper = $('<div class="content-wrapper">').attr('id', 'content-' + index);
	//     wrapper.append(html);
	//     
	//     defineContentSize(wrapper);
	//     
	//     $('body').append(wrapper);
	//     
	//     scrollToElement($('content-' + index));
	//   };
	//   
	//   $(window).resize(function() {
	//     contents = $('div.content-wrapper');
	//     
	//     if (contents.length) {
	//       contents.each(function() {
	//         defineContentSize($(this));
	//       });
	//     };
	//   }).trigger('resize');
	//   
	//   for (i=0; i < $("a").length; i++) {
	//     $($("a")[i]).attr('rel', i);
	//   }
	//   
	//   $('a[href!="#"]').click(function() {
	//     index = $(this).attr('rel');
	//     wrapper = $('content-' + index);
	//     href = $(this).attr('href');
	//     
	//     
	//     
	//     if (wrapper) {
	//       scrollToElement(wrapper);
	//       return false;
	//     };
	//     
	//     $.get(href, function(data) {
	//       addNewPage(index, data);
	//     });
	//     
	//     return false;
	//   });
});

