$.easing.custom = function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	}

/*
$.easing.custom = function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	}
*/

function initHeight () {
	wHeight = $(window).height();
	hHeight = $('#scrollable').height();
	var pTop = Math.ceil((wHeight - 400)/4);
	$('#core').height(wHeight - 100 - Math.ceil((wHeight - 400)/4));
	$('#coreInner').height(wHeight - 100 - Math.ceil((wHeight - 400)/4));
	$('.scrollable').css('marginTop', pTop);
	}


/**
 * Function qui adapte la taille du titre dans le widget "chauffage"
 */
function fontResize() {
    var length = $('.BlocMoreLink').find('h1').text().length;

    switch(length){
        case (length>12):
            $('.BlocMoreLink').find('h1').css("font-size", "30px");
            break;
        case (length > 13):
            $('.BlocMoreLink').find('h1').css("font-size", "28px");
            break;
        case (length > 14):
            $('.BlocMoreLink').find('h1').css("font-size", "26px");
            break;
        case (length > 15):
            $('.BlocMoreLink').find('h1').css({"font-size": "24px", "padding-bottom" : "6px"});
            break;
        case (length > 16):
            $('.BlocMoreLink').find('h1').css({"font-size": "22px", "padding-bottom" : "8px"});
            break;
        case (length > 21):
            $('.BlocMoreLink').find('h1').css({"font-size": "17px", "padding-bottom" : "13px"});
            break;
        default:
            break;
    }
}


function initWidgets() {
	var i = 0;
	
	$('.items .widget').each( function(){

		if (i == 0) $(this).parent().append('<div class="item"></div>');
		if (i < 3) {
			$(this).appendTo(".item:last");
		}
		i++;
		if (i == 3) i = 0;
	});
	
	//$('.items').fadeIn(2000);
	
	// launch scrollable 
	$(".scrollable").scrollable({easing: 'custom', speed: 700}).navigator();

        //Function qui adapte la taille du titre dans le widget "chauffage"
        fontResize();
}
	
$(function() {

	$(".openProfil").fancybox({
		'height'			: 540,
		'width' 			: 859,
		'autoScale'		    : 'false',
		'transitionIn'      : 'none',
		'transitionOut'	    : 'none',
		'type'				: 'iframe',
		'margin'			: 0,
		'padding'			: 0,
		'scrolling'		    : 'no'
	});
	
	
	$("#favoriteStation").fancybox({
		'height'			: 328,
		'width' 			: 563,
		'autoScale'		    : 'false',
		'transitionIn'      : 'none',
		'transitionOut'	    : 'none',
		'type'				: 'iframe',
		'margin'			: 0,
		'padding'			: 0,
		'scrolling'		    : 'no',
		'overlayColor' : '#000',
		'overlayOpacity' : '0.8'
	});

});
