// Delay Plugin for jQuery
// - http://www.evanbot.com
// - copyright 2008 Evan Byrne
/*
 * Jonathan Howard
 * jQuery Pause
 * version 0.2
 * Requires: jQuery 1.0 (tested with svn as of 7/20/2006)
 * Feel free to do whatever you'd like with this, just please give credit where
 * credit is do.
 * pause() will hold everything in the queue for a given number of milliseconds,
 * or 1000 milliseconds if none is given.
 */
// Wait Plugin for jQuery
// http://www.inet411.com
// based on the Delay and Pause Plugin
 (function($) {
    $.fn.wait = function(option, options) {
        milli = 1000; 
        if (option && (typeof option == 'function' || isNaN(option)) ) { 
            options = option;
        } else if (option) { 
            milli = option;
        }
        // set defaults
        var defaults = {
            msec: milli,
            onEnd: options
        },
        settings = $.extend({},defaults, options);

        if(typeof settings.onEnd == 'function') {
            this.each(function() {
                setTimeout(settings.onEnd, settings.msec);
            });
            return this;
        } else {
            return this.queue('fx',
            function() {
                var self = this;
                setTimeout(function() { $.dequeue(self); },settings.msec);
            });
        }

    }
})(jQuery);


$(document).ready(function(){
	function animateHeader(position) {
		$("#history .text").eq(position).fadeIn(900, function() {
			var nextPosition = position + 1;
			if (nextPosition == $("#history .text").length) {
				var nextPosition = 0;
			}
			$("#history .text").wait(5000).eq(position).fadeOut(900,animateHeader(nextPosition));
			});
	}
	animateHeader(0);

	$("#activirungForm").bind("submit", function(e){
		$.getJSON("/cms/front_content.php?idart=38&a=activateUser&verNr="+$("#activirungForm #verNr").val(),
			function(result){
				if (result.bSuccess) {
					$("#activirungForm .errortext").html(result.sText);
					$("#activirungForm .errortext").show(200);
					$("#activirungForm .errortext").css({'color':'green'});
					window.location =result.sUrl;
				} else {
					$("#activirungForm .errortext").html(result.sText);
					$("#activirungForm .errortext").show(200);
					$("#activirungForm .errortext").css({'color':'red'});
				}
		});
		return false;
	});	
	

	$(".loginDiv .doLogin, .loginDiv .doReg").bind("click", function(e){
                $("#login .inp_text").css("background-color","#ef7222");
                $("#left_content .row_0, #right_content .row_0").css("border-color","#ef7222");
		$("html,body").animate({scrollTop: 0}, 1000);

        });

	$(".loginDiv .textGrey").bind("click", function(e){

                $("#left_content .row_0, #right_content .row_0").css("border-color","#ef7222");
                $("#login .inp_text").css("background-color","#ef7222");

		$("html,body").animate({scrollTop: 0}, 1000);
	});	
	$(".loginDiv .textGrey,.loginDiv .doLogin, .loginDiv .doReg").css('cursor','pointer');
	
//	var bLoginSubmit = false;
//	$("#login #loginform").bind("submit", function(e){
//		if (bLoginSubmit == false) {
//			$.getJSON("/cms/front_content.php?idart=38&a=checkActive&sUserName="+$("#login #loginform #username").val(),
//				function(result){
//				if (result.bSuccess) {
//					if (result.sStatus == 'notactive') {
//						$("#login #loginform").hide();
//						$("#login").append(result.sForm);
//						$("#login #activirungForm").bind("submit", function(e){
//							$.getJSON("/cms/front_content.php?idart=38&a=activateUser&sUserName="+$("#login #loginform #username").val()+"&verNr="+$("#login #activirungForm #verNr").val(),
//								function(result){
//									if (result.bSuccess) {
//										$("#login #activirungForm .errortext").html(result.sText);
//										$("#login #activirungForm .errortext").css({'color':'green'});
//										bLoginSubmit = true;	
//										$("#login #loginform").submit();
//									} else {
//										$("#login #activirungForm .errortext").html(result.sText);
//										$("#login #activirungForm .errortext").css({'color':'red'});
//									}
//							});
//							return false;
//						});	
//					} else {
//						bLoginSubmit = true;	
//						$("#login #loginform").submit();
//					} 
//				} else {
//					bLoginSubmit = true;	
//					$("#login #loginform").submit();
//				}
//				
//			}); 
//			return false;
//		} else {
//			return true;
//		}
//	});
	biblioExample.animate();	
	
 });

var biblioExample={
	animate:function(){
		var myEx=$('#biblioExample .scrollContainer .group:first');
		myEx.hide(1000,function(){
			var myNode=$(this);
			myNode.remove();
			$('#biblioExample .scrollContainer').append(myNode);
			myNode.show();
			setTimeout('biblioExample.animate()',5000);
		});
	}
}









