window.popin.skins.changeCloseBtn = function() {
		return this.container()
			.children('.'+this.masque().options('closeCls'))
				.css({
					top : '-30px',
					right : '-22px',
					color: 'white',
					'font-size': '10px'
				})
				.prepend('Fermer')
				.children('img')
					.css('vertical-align', 'middle')
				.end()
			.end();
	};

window.popin.skins.closeBtnPerso = ['closeBtn', 'changeCloseBtn'];

(function ($) {
	$(function() {
		$('.onglets').listOnglets();

		if ($('.scroller').length > 0) {
			$('.scroller').cycle({
				fx:     'scrollHorz', 
				prev:   '.prev', 
				next:   '.next', 
				timeout: 0 
			});
		}

		$('.prev').click(function() {
			return false;
		});

		$('.next').click(function() {
			return false;
		});

		$('.getPopin').each(handleMediaVideoLink);
	});

	function handleMediaVideoLink() {
		$(this)
			.popinTrigger($(this).clone(), {
				skin: 'closeBtnPerso',
				preShow	: [function() {
								this.size({width: 500, height: 364});
							}, 1],
				postShow	: [[function() {
								this.content().mediaCatchup({
												width: 500,
												height: 364
											});
								 return false;
							}, 1],
							function() {
								return false;
							}],
				preHide	: function() {
								this.content()
									.find('object')
									.each(function() {
										if(this.controls) {
											this.controls.stop();
										}
									});
							}
			});
	}
}(this.jQuery));
