/* Author: VZ

*/

function popitup(url) {
	newwindow = window.open(url,'name','height=320,width=420');
	if (window.focus) {newwindow.focus()}
	return false;
}


$(document).ready(function() { 
	
	
// écoute en direct
	$("#playDirect").click(function(){
		href = $(this).attr('href');
		popitup(href);
		return false;
	});

// masquer le champ anti-spam
	
	$("fieldset.prenom").hide();
	
// accordéon sur la navigation des émissions
	
	//catégories
		// initialisation
	$(".navSec").not(".admin").find("nav.emissions").find("li").not(".opened").find(".arrow").toggleClass("closed");
	$(".navSec").not(".admin").find("nav.emissions").find("li").not(".opened").find("ul").hide();

		// function au click
	$(".navSec").not(".admin").find(".groupName").click(function(){
		$(this).find(".arrow").toggleClass("closed");
		$(this).next("ul").slideToggle('fast');
	});
	
	// sous-catégories
		// initialisation
	$(".navSec").find("nav.emissions").find("li").not(".opened").next("ul").hide();
	
		// function au click
	$(".navSec").not(".admin").find("a.subCat").click(function(){
		$(this).parent().toggleClass("opened");
		$(this).next("ul").slideToggle(30);
	});

// help pour le podcast
	
	$(".help .content").hide();
	$(".help .helpLink").click(function(){
		$(this).next(".content").slideToggle('fast');
	});
	
// commentaires des podcasts
	$("section.comments .body").not('.opened').hide();
	$("section.comments header a").click(function(){
		$(this).find('.arrow').toggleClass("opened");
		$(this).parent().parent().parent().find(".body").toggleClass('opened').slideToggle('fast');
		return false;
	});
	
	// ledirect
	num = $('div.cont ul').find("li.selected").index();
	pixels = -((num*40)-80)+'px';
	$('div.cont ul').css({top : pixels});
	
	// annonces
	
	
	
	// $(".annonce:first").addClass('current');
	$(".annonce:first").find(".image img").load(function(){
		if($(this).height() > 250 || $(".annonce:first").find(".content").height() > 250){
			$("div.suite").show();
		} else {
			$("div.suite").hide();
		}
	});
	
	$(".suite").hover(function(){
		$(".annonces").cycle('pause');
	}, function(){
		$(".annonces").cycle('resume');
	});
	$(".suite a").click(function(){
		h = $(".annonce.current").find(".content").height();
		hi = $(".annonce.current").find(".image img").height();
		if(hi > h) {
			h = hi+15;
		} else {
			h = h+15;
		}
		speed = 0.5*h;
		h = h + 'px';
		$("div.annonces").animate({
		    height: h
		}, speed);
		$("div.suite").hide();
	});
	
	$(".annonces").cycle({
		fx: 'scrollHorz',
		pager: '#navAnnonces',
		activePagerClass: 'current',
		timeout: 6000,
		speed: 400,
		pause: 1,
		height: 250,
		slideResize: 1,
		containerResize: 0,
	    pagerAnchorBuilder: function(idx, slide) {
	    	num = idx+1;
	        return '<li><a>' + num + '<span class="tri"></span></a></li>'; 
	    },
        before: function(){
        	$(".annonces").height(250);
        	$(".annonce.current").removeClass('current');
		},
		after: function(){
			$(this).addClass('current');
			if($(this).find(".image img").height() > 250 || $(this).find(".content").height() > 250){
				$("div.suite").show();
			} else {
				$("div.suite").hide();
			}
		}
    });
	
	// CKEditor
	$('textarea.editeur').ckeditor(function(){
		$('.cke_skin_kama').css({width : '435px', marginBottom : '20px'});
	});
	
	// DatePicker
	$.datepicker.regional['fr'] = {
		closeText: 'Fermer',
		prevText: '&#x3c;Préc',
		nextText: 'Suiv&#x3e;',
		currentText: 'Courant',
		monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin',
		'Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
		monthNamesShort: ['Jan','Fév','Mar','Avr','Mai','Jun',
		'Jul','Aoû','Sep','Oct','Nov','Déc'],
		dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
		dayNamesShort: ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'],
		dayNamesMin: ['Di','Lu','Ma','Me','Je','Ve','Sa'],
		weekHeader: 'Sm',
		dateFormat: 'dd/mm/yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['fr']);
	$("#PodcastDatediff").datepicker();
	$("#EventDateDeb").datepicker();
	$("#EventDateFin").datepicker();
	
	
});


















