$(document).ready(function(){
    $("#featured").kricordion({
        slides: '.featured',		// wich element inside the container should serve as slide
        animationSpeed: 900,		// animation duration in milliseconds
        autorotation: true,			// autorotation true or false?
        autorotationSpeed:3,		// duration between autorotation switch in Seconds
        event: 'mouseover',			// event to focus a slide: mouseover or click
        imageShadow:true,			// should the image get a drop shadow to the left
        easing: 'easeOutQuart',		// easing method
        imageShadowStrength:0.5		// how dark should that shadow be, recommended values: between 0.3 and 0.8, allowed between 0 and 1
    });
    /*
    $('.kwicks').kwicks({
        max : 200,
        duration: 800,
        sticky: true,
        defaultKwick: 0,
        easing: 'easeOutQuint'
    });*/

    $('input[name=_user],#loginUsername').focusin(function() {
        if ($(this).val() == 'Username')
            $(this).val('');
    });

    $('input[name=_user],#loginUsername').focusout(function() {
        if ($(this).val() == '')
            $(this).val('Username');
    });

    $('input[name=_pass],#loginPassword').focusin(function() {
        if ($(this).val() == 'Password')
            $(this).val('');
    });

    $('input[name=_pass],#loginPassword').focusout(function() {
        if ($(this).val() == '')
            $(this).val('Password');
    });

    $('.emailBtn').toggle(function() {
        $('#email').fadeIn();
    }, function() {
        $('#email').fadeOut();
    });

    $('.officeBtn').toggle(function() {
        $('#office').fadeIn();
    }, function() {
        $('#office').fadeOut();
    });

    slideShow();

    $('.fancybox').fancybox({
        'overlayOpacity' : 0.7,
        'overlayColor' : '#000'
    });

    $('#readmore').click(function() {
        $(this).parent().remove();
        $('#readmore-content').show();
        return false;
    });

    jQuery('#menu ul').superfish({
        delay:       0,                            // one second delay on mouseout
        animation:   {
            opacity:'show',
            height:'show'
        },  // fade-in and slide-down animation
        speed:       'fast',                          // faster animation speed
        autoArrows:  false,                           // disable generation of arrow mark-up
        dropShadows: false                            // disable drop shadows
    });


});

function slideShow() {

    $('#breaking li').hide();
    $('#caption').html($('#breaking li:first').html());
    setInterval('gallery()',5000);

}

function gallery() {    
    var current = ($('#breaking li.show')?  $('#breaking li.show') : $('#breaking li:first'));    
    var next;
    if (current.next().length)
        next = current.next();
    else
        next = $('#breaking li:first')    
    var caption = next.html();

    next.css({
        opacity: 0.0
    })    
    .addClass('show')
    .animate({
        opacity: 1.0
    }, 1000);    
    
    current.removeClass('show');

    $('#caption').fadeOut('slow').fadeIn('slow');
    $('#caption').html(caption);
}

