﻿
	    $(function () {
	        if ($('#rotator').length) {
	            $('#rotator').addClass('loader');
	            var li_length = $('#rotator .container li').length;
	            var initial_pos = 0;
	            for (i = 0; i < li_length * 2; i++) {
	                $('#rotator .container ul').append($('#rotator .container li').eq(i).clone());
	            }
	            $(window).load(function () {
	                $('#rotator .container').jcarousel({
	                    visible: 1,
	                    scroll: 1,
	                    animation: 1000,
	                    start: (li_length + 1),
	                    easing: 'easeInOutBack',
	                    auto: 7,
	                    wrap: 'both',
	                    buttonPrevHTML: null,
	                    initCallback: function (carousel) {
	                        $('#rotator').removeClass('loader');
	                        $('#rotator .container').animate({
	                            opacity: 1
	                        }, {
	                            queue: false,
	                            duration: 700,
	                            complete: function () {
	                                $('#rotator .overlay').animate({
	                                    top: '-10px'
	                                }, {
	                                    queue: false,
	                                    duration: 400
	                                });
	                                $('#rotator .btn-intro').animate({
	                                    bottom: 0
	                                }, 400);
	                            }
	                        });
	                    },
	                    buttonNextHTML: null,
	                    itemFirstInCallback: {
	                        onBeforeAnimation: function (carousel, item, idx, state) {
	                            $('#rotator .container li .text.current').animate({
	                                bottom: '-400px'
	                            }, {
	                                duration: 500,
	                                easing: 'easeInOutQuart',
	                                complete: function () {
	                                    $(this).removeClass('current');
	                                }
	                            });
	                        },
	                        onAfterAnimation: function (carousel, item, idx, state) {
	                            $('#rotator .container li').eq(idx - 1).find('.text').animate({
	                                bottom: 0
	                            }, {
	                                duration: 700,
	                                easing: 'easeInOutQuart',
	                                complete: function () {
	                                    $(this).addClass('current');
	                                }
	                            });
	                            initial_pos == 0 ? initial_pos = $('#rotator .jcarousel-list').css('left') : initial_pos = initial_pos;
	                            if (idx == (li_length * 2) + 1) {
	                                carousel.scroll($.jcarousel.intval(li_length + 1));
	                                $('#rotator .jcarousel-list').css('left', initial_pos);

	                            }
	                        }
	                    }
	                });
	            });
	        }

	        // Get the querystring parameters
	        var urlParams = {};
	        (function () {
	            var e,
                    a = /\+/g,  // Regex for replacing addition symbol with a space 
                    r = /([^&=]+)=?([^&]*)/g,
                    d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
                    q = window.location.search.substring(1);

	            while (e = r.exec(q))
	                urlParams[d(e[1])] = d(e[2]);
	        })();

	    });
		
