$(document).ready(function() {
  init();
});

function init(){
    $('#sideRotator').cycle({
        fx:     'fade',
        timeout: 4000,
        delay:  -2000
    });

    var max_size = 220;
    $("#catalog img").each(function(i) {
      if ($(this).height() > $(this).width()) {
	var h = max_size;
	var w = Math.ceil($(this).width() / $(this).height() * max_size);
      } else {
	var w = max_size;
	var h = Math.ceil($(this).height() / $(this).width() * max_size);
      }
      $(this).css({ height: h, width: w });
    });
  
};
