$(document).ready(function() {


/* SLIDER */
$("#slider").css({"overflow" : "visible"});
$("#slider").advancedSlider({
    width:620,
    height:310,
    hideTimer:false,
    slideshowControls : false,
    timerStrokeColor1 : "#041a22",
    timerStrokeColor2 : "#68b84b",
    navigationArrows : false,
    showThumbnails : true,
    captionPosition : "custom",
    captionLeft : 20 ,
    captionTop: 250,
    captionWidth : 620,
    captionHeight : "auto",
    captionShowEffect : "fade"
});

// Sepias images
$('img.original').each(function() {

    /*var src = $(this).attr('src');
     var sepia = $(this).data('sepia');
     var sepia = '<img class="sepia" src="' + sepia + '" >';
     $('.sepia').css({'opacity' : 0.8});
     $(this).parent().append(sepia);*/
});



/* DATE PICKER */
//$('#title-search-date').datepicker({ dateFormat: 'dd-mm-yy', maxDate: '+0d' }, $.datepicker.regional[ "fr" ]);
$("#title-search-date").datepicker({ dateFormat: "dd-mm-yy", maxDate: "+0d" });



/* IMAGE LOADER */

// Is this a version of IE?
if( ! $.browser.msie){
    $("img").not($("#slider img"), 'img.test').lazyload({
        effect : "fadeIn",
        placeholder : "assets/img/placeholder.gif"
    });
}

/* NOTIFICATIONS */
$('.notification span').click(function() {
    $(this).parents('.notification').fadeOut(800);
});


$('.notification').click(function() {
    $(this).fadeOut(800);
});

$('.notification').hover(function() {
    $(this).css('cursor', 'pointer');
}, function() {
    $(this).css('cursor', 'auto');
})


/* MODEERNIZR */

/* placeholder */
$('label').css({'display' : 'none'});
var initPlaceholder = function() {
    $("input, textarea").placehold("something-temporary");
};

if (!Modernizr.input.placeholder) {
    initPlaceholder();
}


/* TITLE UPDATE */
function lpStart() {
        $.getJSON( "http://www.rcn-radio.org/onair/live", function(data){

                var output = data.title + '<span>' +  data.artist +'</span>'
                $('#on-air').html(output);
                setTimeout(function() {
                    lpStart();
                }, 7000);

        });
    }
lpStart();

/* Validation */

$.validity.setup({ outputMode:"modal" });
$.validity.messages.require = "Ce champ est requis.";
$.validity.cssClass = 'validity-error';

$("#title-search-form").validity(function() {

    $("#title-search-date")
            .require();

});


$('#message').focusin(function() {
    $(this).html('');
});

$("#contact-us").validity(function() {

    $("#firstname").require();
    $("#message").require();
    $("#email").match('email', 'L\'email renseigné n\'est pas au format email');

});

});
