function changeActiveStyleSheet(previous_css, new_css){
    if (document.styleSheets) {
        for (var StyleSheetIterator = 0; StyleSheetIterator < document.styleSheets.length; StyleSheetIterator++) {
            if (document.styleSheets[StyleSheetIterator].title == previous_css) {
                document.styleSheets[StyleSheetIterator].disabled = true;
            }
            if (document.styleSheets[StyleSheetIterator].title == new_css) {
                document.styleSheets[StyleSheetIterator].disabled = false;
            }
        }
    }
}

$(document).ready(function(){
    $('#Next').click(function(){
	var id = parseInt( $('#Exact').html() );
	var new_id = id + 1;
	var max = parseInt( $('#AllBigCount').html() );
	if (new_id == max) $('#Next').hide();
	$('#Previos').show();
	$('#Exact').html(new_id);
	$.post( "/big_obj.php", {
		id: new_id
	}, function( data ) {
		$('#big_name').attr('href', data.url);
		$('#big_name').html( data.name);
		$('#ImageBox img').attr('src', data.image);
	}, "json" );
    });

    $('#Previos').click(function(){
	var id = parseInt( $('#Exact').html() );
	var new_id = id - 1;
	if (new_id == 1) $('#Previos').hide();
	$('#Next').show();
	$('#Exact').html(new_id);
	$.post( "/big_obj.php", {
		id: new_id
	}, function( data ) {
		$('#big_name').attr('href', data.url);
		$('#big_name').html( data.name);
		$('#ImageBox img').attr('src', data.image);
	}, "json" );
    });

    $('.FastLogin > .FastLoginWelcome a').click(function(){											 
        $('#FastLoginForm').show();
        $('#FastLoginForm').animate({
            opacity: 1
        }, 750);
        return false;
    });
	function HideLoginForm(){
        $('#FastLoginForm').animate({
            opacity: 0
        }, 750, function(){
            $('#FastLoginForm').hide();
        });
        return false;
    }
    $('#FastLoginForm  .FastLoginWelcome a').click(function(){HideLoginForm();});

    $('#ViewModeChooser ul li a').click(function(){
        $(this).parent().siblings().removeClass('Current');
		$(this).parent().siblings().addClass('Clikcable');
        $(this).parent().addClass('Current');
		$(this).parent().removeClass('Clikcable');
        return false;
    });

    $('#a1').click(function(){
		if (!($('#Article_1').hasClass('elemVisible')))
		{
			$('#Article_2').hide();
			$('#Article_2').removeClass('elemVisible');
			$('#Article_1').addClass('elemVisible').fadeIn('slow');
		}

        return false;
    });

    $('#a2').click(function(){
		if (!($('#Article_2').hasClass('elemVisible')))
		{
			$('#Article_1').hide();
			$('#Article_2').hide();
			if ($('#Article_2').hasClass('hideOnLoad')) {
				$('#Article_2').removeClass('hideOnLoad');
			}
			$('#Article_1').removeClass('elemVisible');
			$('#Article_2').addClass('elemVisible').fadeIn('slow');
		}
        return false;
    });

    $('.ThemeChooser').click(function(){
	EventProtectorActivator();
        if ($('#Container').hasClass('xNight')) {
            $('.Extras .n').animate({
                opacity: 0
            }, 1500);
            $('.FastNav').animate({
                opacity: 0
            }, 500);
            $('.Extras .nn').animate({
                opacity: 0
            }, 500);
	$('.Extras .ExtraControler-Night').animate({
                opacity: 0
            }, 500, function(){ $('.Extras .ExtraControler-Night').css({'display':'none'}); });
            $('.Extras .d').animate({
                opacity: 1
            }, 1500, function(){
                setDay();
            });
        }
        else 
            if ($('#Container').hasClass('xDay')) {
                $('.Extras .n').animate({
                    opacity: 0
                }, 500);
                $('.FastNav').animate({
                    opacity: 0
                }, 500);
                $('.Extras .dd').animate({
                    opacity: 0
                }, 500);
		$('.Extras .ExtraControler-Day').animate({
                    opacity: 0
                }, 500, function(){ $('.Extras .ExtraControler-Day').css({'display':'none'}); });
                $('.Extras .n').animate({
                    opacity: 1
                }, 1500, function(){
                    setNight();
                });
            }
        return false;
    });

    function setDay(){
        $('.FastNav').animate({
            opacity: 1
        }, 750);
        $('.Extras .nn').animate({
            opacity: 0
        }, 500);
		$('.Extras .ExtraControler-Day').css({'display':'block'});
	$('.Extras .ExtraControler-Day').animate({
            opacity: 1
        }, 500);
        $('.Extras .dd').animate({
            opacity: 1
        }, 750, function(){
                    EventProtectorDeactivator();
                });
        $('#Container').removeClass('xNight');
        $('#Container').addClass('xDay');
        for (i=0; i<3; i++){
			$('.ExtraControler-Day-Bg').animate({
				opacity: 0.6
			}, 500);
			$('.ExtraControler-Day-Bg').animate({
				opacity: 0
			}, 500);
		}
    }

    function setNight(){
        $('.FastNav').animate({
            opacity: 1
        }, 750);
        $('.Extras .dd').animate({
            opacity: 0
        }, 500);
		$('.Extras .ExtraControler-Night').css({'display':'block'});
		$('.Extras .ExtraControler-Night').animate({
                opacity: 1
            }, 500);
        $('.Extras .nn').animate({
            opacity: 1
        }, 750, function(){
                    EventProtectorDeactivator();
                });
        $('#Container').removeClass('xDay');
        $('#Container').addClass('xNight');
		for (i=0; i<3; i++){
			$('.ExtraControler-Night-Bg').animate({
				opacity: 0.6
			}, 500);
			$('.ExtraControler-Night-Bg').animate({
				opacity: 0
			}, 500);
		}
    }  

    function EventProtectorActivator (){
            $('.EventProtector').addClass('EventProtectorActivated');
    }

    function EventProtectorDeactivator (){
            setTimeout(function() {$('.EventProtector').removeClass('EventProtectorActivated')},9000);
    }
	
	setDay();
});


