//var blick = false;

function  timeExam(){
    $.ajax({
        url: base_web_dir + 'templates/ajax/clock.php',
        success: function(data){
            $("#clock span").html(data);},
        error: function(){
            alert(fail);
        }
    });
    setTimeout("timeExam()", 1000);
}

timeExam();

$(document).ready(function() {

    $('#menu li:not(#selected) a')
        .css("background-position", "-146px 0px")
        .mouseover(function(){
            $(this).stop().animate({
                    backgroundPosition: '0px 0px'
                },200)
            })
        .mouseout(function(){
            $(this).stop().animate({
                    backgroundPosition: '-146px 0px'
                },200)
            })

    $('#menu #selected a').css("background-position", "0 0");

    // GALLERY
    /*
    $('#thumbs a').click(function(){
        var photo = $(this).attr("href");        
        $('img#big-photo').show().attr("src", photo);
        $('#big-photo-holder').show();
        $.scrollTo("#thumbs", 500);


        return false;
    });
    */

    // GALLERY
    $('#photo-section #thumbs a, #print-section #thumbs a').click(function(){
        var photo = $(this).attr("href");

        $('#gallery').append('<img class="pre-active" src="#" />');
		$('#gallery img.active').css("opacity", "0.3");
        $('#gallery img.pre-active').attr('src', photo).load(function() {
            // $('#gallery').css('margin-bottom', '-6px');
            $('#gallery img.active').animate({opacity: 0}, 500, function(){
				$(this).remove();
				$('#gallery img.pre-active').fadeIn().removeClass("pre-active").css("opacity", "1").addClass("active").css("display", "block");
			});
        });

        return false;
    });

    $('#video-section #thumbs a').click(function(){
        var photo = $(this).attr("href");

        $('#big-photo-holder').append('<img class="pre-active" src="#" />');
        $('#big-photo-holder img.pre-active').attr('src', photo).load(function() {
            $('#big-photo-holder').show();
            $('#gallery img.active').fadeOut().remove();
            $('#gallery img.pre-active').fadeIn().removeClass("pre-active").addClass("active");
            //.removeClass("pre-active").addClass("active");

            //$.scrollTo("#thumbs", 500);
        });

        return false;
    });


});
