$(document).ready(function(){
	$('.preload').preloadImages();
});



// IMAGES PRELOAD PLUGIN

(function($){
    $.fn.preloadImages = function(options){

        var defaults = {
            showSpeed: 500,
        };

        var options = $.extend(defaults, options);

        return this.each(function(){
            var container = $(this);
            var image = container.find('img');

            $(image).css({ "visibility": "hidden", "opacity": "0" });
            $(image).bind('load error', function(){
                $(this).css({ "visibility": "visible" }).animate({ opacity:"1" }, {duration:options.showSpeed, easing:options.easing}).parent(container).removeClass('preload');
            }).each(function(){
                if(this.complete || ($.browser.msie && parseInt($.browser.version) == 6)) { $(this).trigger('load'); }
            });
        });
    }
})(jQuery);


//IMAGE CYCLE ARROWS PLUGIN

/*
cycleArrows Image Cycle Navigator Plugin
Author: Arthur Lee
E-mail: arthur@arthurlee.me
Copyright (c) 2011.
*/

(function($){

    $.fn.cycleArrows = function(options) {

        var defaults = {
        	cycle: $('#cycleArrows'),
            navPrev: $('a#nav-prev'),
            navNext: $('a#nav-next'),
            statusCurr: $('#nav-status-curr'),
            statusTotal: $('#nav-status-total'),
            numPics: 5,
        };
       
		
        var options = $.extend(defaults, options);
        var currId = 1;
        
        options.statusTotal.html(options.numPics);

		options.navPrev.bind('click', movePrev);
		options.navNext.bind('click', moveNext);

		$(document).keydown(function (key){
			if (key.which==37)
				movePrev();
			else if (key.which==39)
				moveNext();
			
		});
		
		function moveNext() {
			currId += 1;
			if (currId > options.numPics) { currId = 1 }
			
			changePhoto();
		};
		
		function movePrev() {
			currId -= 1;
			if (currId < 1) { currId = options.numPics }
			
			changePhoto();
		};
		
		function changePhoto() {
			$('#cycleArrows').fadeOut( 100, function() {
				$('#cycleArrows img').attr('src', options.pathPrefix + currId + options.pathSuffix);
				$('#cycleArrows').addClass('preload').show().preloadImages();
				updateStatus();
			});
		}
		
		function updateStatus() {
			options.statusCurr.html(currId);
		}
    };
    
    
})(jQuery);









