jQuery(document).ready(function () {

    /* Login Form */

//    var loginPanelWrap = jQuery('#loginPanelWrap');
//    var loginPanel = jQuery('#loginPanel');

//    jQuery('#loginBtn').click(function () {
//        loginPanelWrap.slideToggle(200);
//        return false;
//    });

//    jQuery('#loginCross').click(function () {
//        loginPanelWrap.slideUp(200);
//    });

    /* Text Rotator */

	  	var textNum = 0;
	  	var currentText = jQuery('#textRotator p:eq(0)');
	  	currentText.addClass('current');

	  	var scrollSpeed = 10; //pixels per second

	  	var scrollText = function (obj) {
	  	    var scrollWidth = -1 * ((obj.outerWidth(true) - jQuery('#textRotator .text').outerWidth(true)) + 25);
	  	    var time = (obj.outerWidth(true) / scrollSpeed) * 100;
	  	    obj.animate({ left: scrollWidth }, time, 'linear', function () {
	  	        jQuery('#textRotator').oneTime(1000, "pause", function () {
	  	            jQuery('#textRotator').oneTime(4000, "rotate", function () {
	  	                rotateText();
	  	            });
	  	        });
	  	    });
	  	}

	  	var rotateText = function () {

	  	    textNum += 1;
	  	    if (textNum >= jQuery('#textRotator p').size()) textNum = 0;
	  	    var nextText = jQuery('#textRotator p:eq(' + textNum + ')');
	  	    currentText.animate({ top: 50 }, 900, function () {
	  	        currentText.css({ 'top': '-25px', 'left': '3px' });
	  	    });
	  	    nextText.animate({ top: 0 }, 1000, function () {
	  	        currentText.removeClass('current');
	  	        currentText = nextText;
	  	        currentText.addClass('current');

	  	        if (currentText.outerWidth(true) > jQuery('#textRotator').outerWidth()) {
	  	            jQuery('#textRotator').oneTime(1000, "scroll", function () {
	  	                scrollText(currentText);
	  	            });
	  	        } else {
	  	            jQuery('#textRotator').oneTime(4000, "rotateText", function () {
	  	                rotateText();
	  	            });
	  	        }
	  	    });
	  	}

	  	jQuery('#textRotator').oneTime(2000, "rotateText", function () {
	  	    if (currentText.outerWidth(true) > jQuery('#textRotator').outerWidth()) {
	  	        jQuery('#textRotator').oneTime(1000, "scroll", function () {
	  	            scrollText(currentText);
	  	        });
	  	    } else {
	  	        jQuery('#textRotator').oneTime(4000, "rotateText", function () {
	  	            rotateText();
	  	        });
	  	    }
	  	});


});
