$(function() { $.preload([ $('#background img:first').attr('src') ], { loaded_all: function(loaded, total) { $('#background img:first').show(); $('#background img').fullBg(); } }); /* $('#background').cycle({ fx: 'fade', pause: 1, random: 1, timeout: 0, prev: '#prev', next: '#next' }); */ $('div#toggle > a').live('click',function(e){ var toggle = $(this); if(toggle.hasClass('up')){ $('#content').css('min-height','inherit'); $('div#content').slideUp(500, function(){ toggle.removeClass('up').addClass('down'); }); }else{ $('#content').css('min-height','450px'); toggle.removeClass('down').addClass('up'); $('div#content').slideDown(500, function(){}); } e.preventDefault(); }); $('div#portfolio').cycle({ fx: 'scrollHorz', pause: 1, timeout: 0, speed: 500, prev: '#prev-port', next: '#next-port' }); }); (function($) { $.fn.fullBg = function(){ var bgImg = $(this); function resizeImg() { var imgwidth = bgImg.width(); var imgheight = bgImg.height(); var winwidth = $(window).width(); var winheight = $(window).height(); 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' }); } } resizeImg(); $(window).resize(function() { resizeImg(); }); }; })(jQuery); (function($) { var imgList = []; $.extend({ preload: function(imgArr, option) { var setting = $.extend({ init: function(loaded, total) {}, loaded: function(img, loaded, total) {}, loaded_all: function(loaded, total) {} }, option); var total = imgArr.length; var loaded = 0; setting.init(0, total); for(var i in imgArr) { imgList.push($("") .attr("src", imgArr[i]) .load(function() { loaded++; setting.loaded(this, loaded, total); if(loaded == total) { setting.loaded_all(loaded, total); } }) ); } } }); })(jQuery);