        var ProductRotator = function(){
            var self = this;
            self.v = {ani:{duration:600}};
            self.el = {};
            self.products = [];
            //
            // Product
            self.Product = function(name, url, img, thumb, img_alt, thumb_alt){
                var product = this;
                //
                // Init
                product.init = function(name, url, img, thumb, img_alt, thumb_alt){
                    product.name = name;
                    product.url = url;
                    product.img = img;
                    product.thumb = thumb;
                    product.img_alt = img_alt;
                    product.thumb_alt = thumb_alt;
                    return product;
                };
                return product.init(name, url, img, thumb, img_alt, thumb_alt);
            };
            self.addProduct = function(name, url, img, thumb, img_alt, thumb_alt) {
                var product = new self.Product(name, url, img, thumb, img_alt, thumb_alt);
                self.products.push(product);
                return self;
            };
            self.getNext = function(i) {
                if (++i >= self.products.length) {
                    return 0;
                } else {
                    return i
                };
            };
            self.getPrev = function(i) {
                if (--i < 0) {
                    return self.products.length - 1;
                } else {
                    return i
                };
            };
            self.setHero = function(i) {
                var product = self.products[i];
                var link = $('<a/>')
                    .attr('href', product.url)
                    .appendTo(self.el.heroContainer);
                var productEl = $('<img/>')
                    .attr('src', product.img)
                    .attr('alt', product.img_alt)
                    .appendTo(link);
                return productEl;
            };
            self.setLeft = function(i) {
                var product = self.products[i];
                var productEl = $('<img/>')
                    .attr('src', product.thumb)
                    .appendTo(self.el.leftContainer)
                    .click(function(){ self.goTo(i, -1) });
                return productEl;
            };
            self.setRight = function(i) {
                var product = self.products[i];
                var productEl = $('<img/>')
                    .attr('src', product.thumb)
                    .appendTo(self.el.rightContainer)
                    .click(function(){ self.goTo(i, 1) });
                return productEl;
            };
            self.goTo = function(i, dir) {
                // hero
                self.el.heroContainer.find('img')
                    .animate({
                        'opacity': 0
                    }, {
                        complete: function(){
                            $(this).remove();
                            self.setHero(i).hide().fadeIn('slow');
                        }
                    });
                // left
                self.el.leftContainer.find('img')
                    .animate({
                        'left': -150*dir,
                        'opacity': 0
                    }, {
                        duration: self.v.ani.duration,
                        complete: function(){ $(this).remove(); }
                    });
                self.setLeft(self.getPrev(i))
                    .css({
                        'left': 150*dir,
                        'opacity': 0
                    })
                    .animate({
                        'left': 0,
                        'opacity': 1
                    }, {
                        duration: self.v.ani.duration
                    });
                // right
                self.el.rightContainer.find('img')
                    .animate({
                        'right': 150*dir,
                        'opacity': 0
                    }, {
                        duration: self.v.ani.duration,
                        complete: function(){ $(this).remove(); }
                    });
                self.setRight(self.getNext(i))
                    .css({
                        'right': -150*dir,
                        'opacity': 0
                    })
                    .animate({
                        'right': 0,
                        'opacity': 1
                    }, {
                        duration: self.v.ani.duration
                    });
            };
            //
            // Start
            self.start = function(){
                self.setHero(0).hide().fadeIn('slow');
                self.setLeft(self.getPrev(0)).hide().fadeIn('slow');
                self.setRight(self.getNext(0)).hide().fadeIn('slow');
                return self;
            };
            //
            // Init
            self.init = function(){
                self.el.leftContainer = $('#leftContainer');
                self.el.rightContainer = $('#rightContainer');
                self.el.heroContainer = $('#heroContainer');
                return self;
            };
            return self.init();
        };
        $(document).ready(function(){
            pr = new ProductRotator();
            
                pr.addProduct(
                    'Smartseal',
                    '/products/smart-seal/',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-01.jpg',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-01-thumb.jpg',
                    '',
                    ''
                );
            
                pr.addProduct(
                    'Smartpoint',
                    '/products/smart-point/',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-02.jpg',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-02-thumb.jpg',
                    '',
                    ''
                );
            
                pr.addProduct(
                    'SmartpointPT',
                    '/products/smart-point-pt/',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-03.jpg',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-03-thumb.jpg',
                    '',
                    ''
                );
            
                pr.addProduct(
                    'SmartpointS',
                    '/products/smart-point-s/',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-04.jpg',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-04-thumb.jpg',
                    '',
                    ''
                );
            
                pr.addProduct(
                    'smartpaste',
                    '/products/smart-paste/',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-05.jpg',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-05-thumb.jpg',
                    '',
                    ''
                );
				
                pr.addProduct(
                    'SmartpasteBio',
                    '/products/smart-paste-bio/',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-06.jpg',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-06-thumb.jpg',
                    '',
                    ''
                );
				
                pr.addProduct(
                    'Smarttrim',
                    '/products/smart-trim/',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-07.jpg',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-07-thumb.jpg',
                    '',
                    ''
                );
				
                pr.addProduct(
                    'Smartgauge',
                    '/products/smart-gauge/',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-08.jpg',
                    'http://www.smart-seal.co.uk/wp-content/themes/smart-seal/images/layout/product-rotator/product-08-thumb.jpg',
                    '',
                    ''
                );
            
            pr.start();
        });

