if(typeof($) == 'function') {    /*     *  Like constructor for jQuery plugin.     */    jQuery.makePresentation = function(settings) {                settings = jQuery.extend({            aSlidesLength   : 0,            onShowSlide     : null,            onSwitchMode    : null,            canGo           : null        }, settings);                /*         *  Presentation plugin         */        jQuery.presentation = {                        settings: settings,                        isSlides: false,            aCounter: 0,                            /*             *  Base             */            switchMode: function () {                this.isSlides = !this.isSlides;                                if(typeof(this.settings.onSwitchMode) == 'function') {                    this.settings.onSwitchMode(this.isSlides);                }            },                        /*             *  Navigation             */             canGo: function() {                return this.settings.aSlidesLength > 0;            },                        canGoNext: function() {                return this.canGo && (this.aCounter + 1) < this.settings.aSlidesLength;            },                        canGoPrev: function() {                return this.canGo && this.aCounter > 0;            },                        goNext: function() {                if(this.aCounter < 0) this.aCounter = 0;                if(this.canGoNext() && (typeof(this.settings.canGo) != 'function' || this.settings.canGo(true))) this.goTo(++this.aCounter);            },                        goPrev: function() {                if(this.aCounter >= this.settings.aSlidesLenght) this.aCounter = this.settings.aSlidesLenght - 1;                if(this.canGoPrev() && (typeof(this.settings.canGo) != 'function' || this.settings.canGo(false))) this.goTo(--this.aCounter);            },                        goTo: function(aSlide) {                if(aSlide >= 0 && aSlide < this.settings.aSlidesLength) {                    if(typeof(this.settings.onShowSlide) == 'function') this.settings.onShowSlide(aSlide);                } else {                    console.error('Out of bounds');                // REMOVE THIS LINE! MAYBE LATER...                }            },                        goToFirst: function () {                this.aCounter = 0;                this.goTo(this.aCounter);            },                        goToLast: function() {                this.aCounter = this.settings.aSlidesLength - 1;                this.goTo(this.aCounter);            },                        isFirstSlide: function() {                return this.aCounter == 0;            },                        isLastSlide: function() {                return this.aCounter == this.settings.aSlidesLength - 1;            }                    }                /*         *  Events         */        $(document).keyup(function(e) {            if(typeof($.presentation) == 'object' && $.presentation.isSlides) {                                switch(e.keyCode) {                    case 13: case 32: case 34: case 39: case 40:                        if($.presentation.canGoNext()) $.presentation.goNext();                        break;                    case 33: case 37: case 38:                        if($.presentation.canGoPrev()) $.presentation.goPrev();                        break;                    case 36:                        if($.presentation.canGo()) $.presentation.goToFirst();                        break;                    case 35:                        if($.presentation.canGo()) $.presentation.goToLast();                        break;                    case 27:                        $.presentation.switchMode();                        break;                }                                return false;                                    }                        if(typeof($.presentation) == 'object' && !$.presentation.isSlides) {                                if(e.keyCode == 13) {                    $.presentation.switchMode();                    return false;                }            }        });                $(document).mouseup(function(e) {            if (typeof($.presentation) == 'object' && $.presentation.isSlides) {                switch(e.keyCode) {                    case 13: case 32: case 34: case 39: case 40:                        if($.presentation.canGoNext()) $.presentation.goNext();                        break;                    case 33: case 37: case 38:                        if($.presentation.canGoPrev()) $.presentation.goPrev();                        break;                    case 36:                        if($.presentation.canGo()) $.presentation.goToFirst();                        break;                    case 35:                        if($.presentation.canGo()) $.presentation.goToLast();                        break;                    case 27:                        $.presentation.switchMode();                        break;                }                return false;            }        });        return true;            }    }
