// JavaScript Document
var $j = jQuery.noConflict();


// Slide Panel Jquery
$j(document).ready(function() {

	$j(".btn_slide").click(function() {
		$j("#panel").slideToggle("slow");
		$j(this).toggleClass("active_panel"); return false;
	});
	 
});
/* //Slide Panel Jquery */


// Fancybox 
$j(document).ready(function() {
	$j("a#fancybox_simple").fancybox();
});
/* // Fancybox */


/* FadeOut message erreurs */
/*
$j(document).ready(function() {
	$j("p.error_msg").fadeOut(10000);	
	$j("p.info_msg").fadeOut(10000);	
	$j("p.warning_msg").fadeOut(10000);		
	$j("p.success_msg").fadeOut(10000);	
});
*/
/* //FadeOut message erreur */

/* jQuery Autocomplete */
$j(document).ready(function() {
	$j("#search").autocomplete("scripts/autocomplete.php", {
		width: 260,
		matchContains: true,
		//mustMatch: true,
		//minChars: 0,
		//multiple: true,
		//highlight: false,
		//multipleSeparator: ",",
		selectFirst: false
	});
});
/* //jQuery Autocomplete */


/* ANNUAIRE */
$j(document).ready(function(){
	
	//$j(".accordion h3:first").addClass("active");
	//$j(".accordion p:not(:first)").hide();
	$j(".accordion ul").hide();

	$j(".accordion h3").click(function(){
		$j(this).next("ul").slideToggle("slow").siblings("ul:visible").slideUp("slow");
		$j(this).toggleClass("active");
		$j(this).siblings("h3").removeClass("active");
	});

});
/* // ANNUAIRE  */


/*  SWF CLOCK */
var flashvars = {};
var params = {wmode:"transparent"};
var attributes = {};
swfobject.embedSWF("swf/clock.swf", "swf_clock", "200", "110", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
/*  //SWF CLOCK */


/* Download Now Tooltips //Page téléchargement */
$j(document).ready(function() {
	$j(".download_button").tooltip({ effect: 'slide'});
});
/* //Download Now Tooltips */

/* Infinite Carousel */
$j(document).ready(function() {
  $j('.infiniteCarousel').infiniteCarousel();
});


$j.fn.infiniteCarousel = function () {

    function repeat(str, num) {
        return new Array( num + 1 ).join( str );
    }
  
    return this.each(function () {
        var $wrapper = $j('> div', this).css('overflow', 'hidden'),
            $slider = $wrapper.find('> ul'),
            $items = $slider.find('> li'),
            $single = $items.filter(':first'),
            
            singleWidth = $single.outerWidth(), 
            visible = Math.ceil($wrapper.innerWidth() / singleWidth), 
            currentPage = 1,
            pages = Math.ceil($items.length / visible);            


        // 1. Pad so that 'visible' number will always be seen, otherwise create empty items
        if (($items.length % visible) != 0) {
            $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
            $items = $slider.find('> li');
        }

        // 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
        $items.filter(':first').before($items.slice(- visible).clone().addClass('cloned'));
        $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
        $items = $slider.find('> li'); // reselect
        
        // 3. Set the left position to the first 'real' item
        $wrapper.scrollLeft(singleWidth * visible);
        
        // 4. paging function
        function gotoPage(page) {
            var dir = page < currentPage ? -1 : 1,
                n = Math.abs(currentPage - page),
                left = singleWidth * dir * visible * n;
            
            $wrapper.filter(':not(:animated)').animate({
                scrollLeft : '+=' + left
            }, 500, function () {
                if (page == 0) {
                    $wrapper.scrollLeft(singleWidth * visible * pages);
                    page = pages;
                } else if (page > pages) {
                    $wrapper.scrollLeft(singleWidth * visible);
                    // reset back to start position
                    page = 1;
                } 

                currentPage = page;
            });                
            
            return false;
        }
        
        $wrapper.after('<a class="arrow back"></a><a class="arrow forward"></a>');
        
        // 5. Bind to the forward and back buttons
        $j('a.back', this).click(function () {
            return gotoPage(currentPage - 1);                
        });
        
        $j('a.forward', this).click(function () {
            return gotoPage(currentPage + 1);
        });
        
        // create a public interface to move to a specific page
        $j(this).bind('goto', function (event, page) {
            gotoPage(page);
        });
    });  
};

/* /Infinite Carousel */

/* jQuery UI Tabs */
$j(document).ready(function() {
	$j("#tabs").tabs();
});
/* /jQuery UI Tabs */


/* PASSWORD STRENGH METER */
function passwordStrength(password) {
	var desc = new Array();
	desc[0] = "Faible";
	desc[1] = "Moyen";
	desc[2] = "Bon";
	desc[3] = "Fort";
	desc[4] = "Tr&egrave;s fort";
	desc[5] = "Parfait";

	var score   = 0;

	//if password bigger than 4 give 1 point
	if (password.length > 4) score++;

	//if password has both lower and uppercase characters give 1 point	
	if ((password.match(/[a-z]/)) && (password.match(/[A-Z]/))) score++;

	//if password has at least one number give 1 point
	if (password.match(/\d+/)) score++;

	//if password has at least one special caracther give 1 point
	if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)) score++;

	//if password bigger than 12 give another 1 point
	if (password.length > 12) score++;

	 document.getElementById("passwordDescription").innerHTML = desc[score];
	 document.getElementById("passwordStrength").className = "strength" + score;
}

function passwordStrength1(password) {
	var desc = new Array();
	desc[0] = "Faible";
	desc[1] = "Moyen";
	desc[2] = "Bon";
	desc[3] = "Fort";
	desc[4] = "Tr&egrave;s fort";
	desc[5] = "Parfait";

	var score   = 0;

	//if password bigger than 4 give 1 point
	if (password.length > 4) score++;

	//if password has both lower and uppercase characters give 1 point	
	if ((password.match(/[a-z]/)) && (password.match(/[A-Z]/))) score++;

	//if password has at least one number give 1 point
	if (password.match(/\d+/)) score++;

	//if password has at least one special caracther give 1 point
	if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)) score++;

	//if password bigger than 12 give another 1 point
	if (password.length > 12) score++;

	 document.getElementById("passwordDescription").innerHTML = desc[score];
	 document.getElementById("passwordStrength").className = "strength" + score;
}


/* //PASSWORD STRENGH METER */



/* TinyAccordion Javascript */
var TINY={};

function T$(i){return document.getElementById(i)}
function T$$(e,p){return p.getElementsByTagName(e)}

TINY.accordion=function(){
	function slider(n){this.n=n; this.a=[]}
	slider.prototype.init=function(t,e,m,o,k){
		var a=T$(t), i=s=0, n=a.childNodes, l=n.length; this.s=k||0; this.m=m||0;
		for(i;i<l;i++){
			var v=n[i];
			if(v.nodeType!=3){
				this.a[s]={}; this.a[s].h=h=T$$(e,v)[0]; this.a[s].c=c=T$$('div',v)[0]; h.onclick=new Function(this.n+'.pr(0,'+s+')');
				if(o==s){h.className=this.s; c.style.height='auto'; c.d=1}else{c.style.height=0; c.d=-1} s++
			}
		}
		this.l=s
	};
	slider.prototype.pr=function(f,d){
		for(var i=0;i<this.l;i++){
			var h=this.a[i].h, c=this.a[i].c, k=c.style.height; k=k=='auto'?1:parseInt(k); clearInterval(c.t);
			if((k!=1&&c.d==-1)&&(f==1||i==d)){
				c.style.height=''; c.m=c.offsetHeight; c.style.height=k+'px'; c.d=1; h.className=this.s; su(c,1)
			}else if(k>0&&(f==-1||this.m||i==d)){
				c.d=-1; h.className=''; su(c,-1)
			}
		}
	};
	function su(c){c.t=setInterval(function(){sl(c)},20)};
	function sl(c){
		var h=c.offsetHeight, d=c.d==1?c.m-h:h; c.style.height=h+(Math.ceil(d/5)*c.d)+'px';
		c.style.opacity=h/c.m; c.style.filter='alpha(opacity='+h*100/c.m+')';
		if((c.d==1&&h>=c.m)||(c.d!=1&&h==1)){if(c.d==1){c.style.height='auto'} clearInterval(c.t)}
	};
	return{slider:slider}
}();
/* //TinyAccordion Javascript */


