
/*MENU*/
$.tabs = function(containerID) {
    var ON_CLASS = 'active';
    var id = '#' + containerID;
    var i = (typeof start == "number") ? start - 1 : 0;
    $(id + '>div:lt(' + i + ')').add(id + '>div:gt(' + i + ')').hide();
    $(id + '>ul>li:nth-child(' + i + ')').addClass(ON_CLASS);
	$(id + '>ul>li>a.ssm').click(function() {return false;});
    $(id + '>ul>li>a.ssm').click(function() {
        if (!$(this.parentNode).is('.' + ON_CLASS)) {
            var re = /([_\-\w]+$)/i;
            var target = $('#' + re.exec(this.href)[1]);
            if (target.size() > 0) {
                $(id + '>div:visible').hide();
                target.fadeIn('normal');
                $(id + '>ul>li').removeClass(ON_CLASS);
                $(this.parentNode).addClass(ON_CLASS);
				
				/*bouge les pointes rouges ss chaque element du menu*/
				if($("#mCategories").css("display") != "none") {
					$("span.select").css({
						marginLeft:"192px"
					})
				}
				if($("#mRubriques").css("display") != "none") {
					$("span.select").css({
						marginLeft:"65px"
					})
				}
				if($("#mTags").css("display") != "none") {
					$("span.select").css({
						marginLeft:"284px"
					})
				}
				
            } else {
                //alert('Attention : aucun conteneur ! ');
				return;
            }
        }
        return false;
    });
};

$(document).ready(function()	
{
	
	/*click ouverture lien externe sur http:// */
	/*$("a[@href^=\"http\"]").each(function(i){var temp = $(this).attr("href"); $(this).not("[@href*=\""+document.domain+"\"]").not(":has(img)").after("&nbsp;<a href=\""+$(this).attr("href")+"\" onclick=\"javascript:window.open(this.href); return false;\"></a>");});*/
	
	
	/*FADE LOGO partenaires sur la homepage*/
	$(".thumbs img").fadeTo("slow", 0.4);
	$(".thumbs img").hover(function(){
		$(this).fadeTo("nomal", 1.0);
	},function(){
		$(this).fadeTo("normal", 0.4); 
	});
	/* /FADE LOGO */
	
	/* ACCORDEON (plugin jquery.accordion) : Bloc deroulant commentaires + articles les plus lus */
	$('#accordeon').accordion();
	/* /ACCORDEON */
	
	
	/* TRAITEMENT IMAGES BILLETS : placement des images dans les paragraphes des articles*/
	$("img[align='right']").addClass("imageRight");
	$("img[align='left']").addClass("imageLeft");
	/* /TRAITEMENT IMAGES BILLETS*/
	
	/*INPUTS : ajout couleur de fond sur le focus*/
	$('input:text, textarea, select')
	.focus(function(){
         $(this).css('background','#D4EEFD');
		 $(this).css('border','1px solid #4C96C1');
	})
	.blur(function(){
         $(this).css('background','#F6F6F6');
		 $(this).css('border','1px solid #999999');
	});
	/* /INPUTS */

	/*MENU*/
 	$.tabs("menu");
	/* /MENU*/
	
	/*form newsletter*/
  $("#nl, #nl2").submit(function() {
		return valider(this);
    });
  
  	/*PLAYER youtube*/
	/*$('#player a[@href^="http://www.youtube.com/cp/"]').flash(
		{ width: 297, height: 256 },
		{ version: 8 },
		function(htmlOptions) {
			$this = $(this);
			htmlOptions.src = $this.attr('href');
			$this.before($.fn.flash.transform(htmlOptions));						
		}
	);*/
	/*PLAYER youtube*/
		
		/*tooltip col centrale*/
		$('a[rel=intronews]')
		.live('mouseover', function(){
			$(this).parents('.actu').find('.introduction').show();
		})
		.live('mouseout', function() {
			$(this).parents('.actu').find('.introduction').hide();
		});
		

});

/*rapide fonction de validation email a l'ancienne */
function IsMail(email){
    return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email));
};
function valider(frm)
{

  if(frm.elements['email'].value != "") {
 	 if(IsMail(frm.elements['email'].value)) {
    	return true;
  	} else {
   $(".erreur").text("Attention veuillez saisir un email valide ! ").show().fadeOut(5000);
    return false;
  	}
  } else {
     $(".erreur").text("Attention veuillez saisir un email").show().fadeOut(5000);
    return false;
  }
}


