var dev_version = new Array('192.168.1.42','cosmic2.typhon.net'); // versions dev du site

// cryptage md5
function array(n){for(i=0;i<n;i++)this[i]=0;this.length=n}function integer(n){return n%(0xffffffff+1)}function shr(a,b){a=integer(a);b=integer(b);if(a-0x80000000>=0){a=a%0x80000000;a>>=b;a+=0x40000000>>(b-1)}else a>>=b;return a}function shl1(a){a=a%0x80000000;if(a&0x40000000==0x40000000){a-=0x40000000;a*=2;a+=0x80000000}else a*=2;return a}function shl(a,b){a=integer(a);b=integer(b);for(var i=0;i<b;i++)a=shl1(a);return a}function and(a,b){a=integer(a);b=integer(b);var c=(a-0x80000000);var d=(b-0x80000000);if(c>=0)if(d>=0)return((c&d)+0x80000000);else return(c&b);else if(d>=0)return(a&d);else return(a&b)}function or(a,b){a=integer(a);b=integer(b);var c=(a-0x80000000);var d=(b-0x80000000);if(c>=0)if(d>=0)return((c|d)+0x80000000);else return((c|b)+0x80000000);else if(d>=0)return((a|d)+0x80000000);else return(a|b)}function xor(a,b){a=integer(a);b=integer(b);var c=(a-0x80000000);var d=(b-0x80000000);if(c>=0)if(d>=0)return(c^d);else return((c^b)+0x80000000);else if(d>=0)return((a^d)+0x80000000);else return(a^b)}function not(a){a=integer(a);return(0xffffffff-a)}var state=new array(4);var count=new array(2);count[0]=0;count[1]=0;var buffer=new array(64);var transformBuffer=new array(16);var digestBits=new array(16);var S11=7;var S12=12;var S13=17;var S14=22;var S21=5;var S22=9;var S23=14;var S24=20;var S31=4;var S32=11;var S33=16;var S34=23;var S41=6;var S42=10;var S43=15;var S44=21;function F(x,y,z){return or(and(x,y),and(not(x),z))}function G(x,y,z){return or(and(x,z),and(y,not(z)))}function H(x,y,z){return xor(xor(x,y),z)}function I(x,y,z){return xor(y,or(x,not(z)))}function rotateLeft(a,n){return or(shl(a,n),(shr(a,(32-n))))}function FF(a,b,c,d,x,s,e){a=a+F(b,c,d)+x+e;a=rotateLeft(a,s);a=a+b;return a}function GG(a,b,c,d,x,s,e){a=a+G(b,c,d)+x+e;a=rotateLeft(a,s);a=a+b;return a}function HH(a,b,c,d,x,s,e){a=a+H(b,c,d)+x+e;a=rotateLeft(a,s);a=a+b;return a}function II(a,b,c,d,x,s,e){a=a+I(b,c,d)+x+e;a=rotateLeft(a,s);a=a+b;return a}function transform(e,f){var a=0,b=0,c=0,d=0;var x=transformBuffer;a=state[0];b=state[1];c=state[2];d=state[3];for(i=0;i<16;i++){x[i]=and(e[i*4+f],0xff);for(j=1;j<4;j++){x[i]+=shl(and(e[i*4+j+f],0xff),j*8)}}a=FF(a,b,c,d,x[0],S11,0xd76aa478);d=FF(d,a,b,c,x[1],S12,0xe8c7b756);c=FF(c,d,a,b,x[2],S13,0x242070db);b=FF(b,c,d,a,x[3],S14,0xc1bdceee);a=FF(a,b,c,d,x[4],S11,0xf57c0faf);d=FF(d,a,b,c,x[5],S12,0x4787c62a);c=FF(c,d,a,b,x[6],S13,0xa8304613);b=FF(b,c,d,a,x[7],S14,0xfd469501);a=FF(a,b,c,d,x[8],S11,0x698098d8);d=FF(d,a,b,c,x[9],S12,0x8b44f7af);c=FF(c,d,a,b,x[10],S13,0xffff5bb1);b=FF(b,c,d,a,x[11],S14,0x895cd7be);a=FF(a,b,c,d,x[12],S11,0x6b901122);d=FF(d,a,b,c,x[13],S12,0xfd987193);c=FF(c,d,a,b,x[14],S13,0xa679438e);b=FF(b,c,d,a,x[15],S14,0x49b40821);a=GG(a,b,c,d,x[1],S21,0xf61e2562);d=GG(d,a,b,c,x[6],S22,0xc040b340);c=GG(c,d,a,b,x[11],S23,0x265e5a51);b=GG(b,c,d,a,x[0],S24,0xe9b6c7aa);a=GG(a,b,c,d,x[5],S21,0xd62f105d);d=GG(d,a,b,c,x[10],S22,0x2441453);c=GG(c,d,a,b,x[15],S23,0xd8a1e681);b=GG(b,c,d,a,x[4],S24,0xe7d3fbc8);a=GG(a,b,c,d,x[9],S21,0x21e1cde6);d=GG(d,a,b,c,x[14],S22,0xc33707d6);c=GG(c,d,a,b,x[3],S23,0xf4d50d87);b=GG(b,c,d,a,x[8],S24,0x455a14ed);a=GG(a,b,c,d,x[13],S21,0xa9e3e905);d=GG(d,a,b,c,x[2],S22,0xfcefa3f8);c=GG(c,d,a,b,x[7],S23,0x676f02d9);b=GG(b,c,d,a,x[12],S24,0x8d2a4c8a);a=HH(a,b,c,d,x[5],S31,0xfffa3942);d=HH(d,a,b,c,x[8],S32,0x8771f681);c=HH(c,d,a,b,x[11],S33,0x6d9d6122);b=HH(b,c,d,a,x[14],S34,0xfde5380c);a=HH(a,b,c,d,x[1],S31,0xa4beea44);d=HH(d,a,b,c,x[4],S32,0x4bdecfa9);c=HH(c,d,a,b,x[7],S33,0xf6bb4b60);b=HH(b,c,d,a,x[10],S34,0xbebfbc70);a=HH(a,b,c,d,x[13],S31,0x289b7ec6);d=HH(d,a,b,c,x[0],S32,0xeaa127fa);c=HH(c,d,a,b,x[3],S33,0xd4ef3085);b=HH(b,c,d,a,x[6],S34,0x4881d05);a=HH(a,b,c,d,x[9],S31,0xd9d4d039);d=HH(d,a,b,c,x[12],S32,0xe6db99e5);c=HH(c,d,a,b,x[15],S33,0x1fa27cf8);b=HH(b,c,d,a,x[2],S34,0xc4ac5665);a=II(a,b,c,d,x[0],S41,0xf4292244);d=II(d,a,b,c,x[7],S42,0x432aff97);c=II(c,d,a,b,x[14],S43,0xab9423a7);b=II(b,c,d,a,x[5],S44,0xfc93a039);a=II(a,b,c,d,x[12],S41,0x655b59c3);d=II(d,a,b,c,x[3],S42,0x8f0ccc92);c=II(c,d,a,b,x[10],S43,0xffeff47d);b=II(b,c,d,a,x[1],S44,0x85845dd1);a=II(a,b,c,d,x[8],S41,0x6fa87e4f);d=II(d,a,b,c,x[15],S42,0xfe2ce6e0);c=II(c,d,a,b,x[6],S43,0xa3014314);b=II(b,c,d,a,x[13],S44,0x4e0811a1);a=II(a,b,c,d,x[4],S41,0xf7537e82);d=II(d,a,b,c,x[11],S42,0xbd3af235);c=II(c,d,a,b,x[2],S43,0x2ad7d2bb);b=II(b,c,d,a,x[9],S44,0xeb86d391);state[0]+=a;state[1]+=b;state[2]+=c;state[3]+=d}function init(){count[0]=count[1]=0;state[0]=0x67452301;state[1]=0xefcdab89;state[2]=0x98badcfe;state[3]=0x10325476;for(i=0;i<digestBits.length;i++)digestBits[i]=0}function update(b){var a,i;a=and(shr(count[0],3),0x3f);if(count[0]<0xffffffff-7)count[0]+=8;else{count[1]++;count[0]-=0xffffffff+1;count[0]+=8}buffer[a]=and(b,0xff);if(a>=63){transform(buffer,0)}}function finish(){var a=new array(8);var b;var i=0,index=0,padLen=0;for(i=0;i<4;i++){a[i]=and(shr(count[0],(i*8)),0xff)}for(i=0;i<4;i++){a[i+4]=and(shr(count[1],(i*8)),0xff)}index=and(shr(count[0],3),0x3f);padLen=(index<56)?(56-index):(120-index);b=new array(64);b[0]=0x80;for(i=0;i<padLen;i++)update(b[i]);for(i=0;i<8;i++)update(a[i]);for(i=0;i<4;i++){for(j=0;j<4;j++){digestBits[i*4+j]=and(shr(state[i],(j*8)),0xff)}}}function hexa(n){var a="0123456789abcdef";var b="";var c=n;for(hexa_i=0;hexa_i<8;hexa_i++){b=a.charAt(Math.abs(c)%16)+b;c=Math.floor(c/16)}return b}var ascii="01234567890123456789012345678901"+" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";function md5(a){var l,s,k,ka,kb,kc,kd;init();for(k=0;k<a.length;k++){l=a.charAt(k);update(ascii.lastIndexOf(l))}finish();ka=kb=kc=kd=0;for(i=0;i<4;i++)ka+=shl(digestBits[15-i],(i*8));for(i=4;i<8;i++)kb+=shl(digestBits[15-i],((i-4)*8));for(i=8;i<12;i++)kc+=shl(digestBits[15-i],((i-8)*8));for(i=12;i<16;i++)kd+=shl(digestBits[15-i],((i-12)*8));s=hexa(kd)+hexa(kc)+hexa(kb)+hexa(ka);return s}

(function($) {
	$.fn.clickTags = function(options,callback) {
		var settings = {
			idWeborama: null,
			taggedPage:null,
			defaultHomeTag:'home',
			extendedTag:null,
			urlWeborama:'http://cetelem.solution.weborama.fr/fcgi-bin/performance.fcgi'
		};
		if(options) $.extend(settings, options);
		
		if (settings.idWeborama == null || settings.taggedPage == null) {
			alert('Veuillez renseigner votre id weborama ainsi que les liens que vous souhaitez tagguer')
		}

		var $this = $(this);
		
		$this.each(function(){
			var url = $(this).attr('href');
			var posSlash = url.lastIndexOf('/');
			var posWWW = url.lastIndexOf('www');
												
			// if ((posSlash > -1) && (posWWW == -1)) { var clickTagUrl = url.substr(posSlash+1,url.length); }
			if ((posSlash > -1) && (posWWW == -1)) { var clickTagUrl = url.substr(posSlash+1,url.length); }
			else { clickTagUrl = url; }

			while (clickTagUrl.search("\r\n") != -1) { clickTagUrl = clickTagUrl.replace('/',""); }

			if (clickTagUrl == '') { clickTagUrl = url; }
			
			var tagInfo = null;
			if (
				settings.extendedTag != null && 
				typeof settings.taggedPage[clickTagUrl] != 'undefined' && 
				typeof settings.taggedPage[clickTagUrl][settings.extendedTag] != 'undefined'
			) {
				tagInfo = settings.taggedPage[clickTagUrl][settings.extendedTag];
			}
			else if (typeof settings.taggedPage[clickTagUrl] != 'undefined') {
				tagInfo = settings.taggedPage[clickTagUrl];
			}			

			if (tagInfo != null) {
				urlRedirect = settings.urlWeborama+'?ID='+settings.idWeborama+'&A='+tagInfo.A+'&L='+tagInfo.L+'&C='+tagInfo.C+'&P='+tagInfo.P+'&T='+tagInfo.T+'&URL='+tagInfo.URL;
				$(this).attr('href',urlRedirect);
			}
		});
		
		
	}
})(jQuery);

/*******************************************************
	
					Données Click Tags Weborama

*******************************************************/

var tag_infos = new Array();

/************************* Que faire en cas de difficulté *************************/
// Que faire en cas de difficulté > Home
tag_infos['difficultes'] = { A:'1', L:'183259', C:'8679', P:'17045', T:'I', URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fdifficultes' };
tag_infos['difficultes']['home'] = {A:'1',L:'183245',C:'8679',P:'17042',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fdifficultes' };

// Que faire en cas de difficulté > Que faire situation de surendettement?
tag_infos['en-situation-de-surendettement'] = {A:'1',L:'183262',C:'8679',P:'17045',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fdifficultes%2Fen-situation-de-surendettement' };

// Que faire en cas de difficulté > Vous avez plusieurs crédits et vous n’arrivez plus à faire face ?
tag_infos['plus-a-faire-face'] = {A:'1',L:'183261',C:'8679',P:'17045',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fdifficultes%2Fplus-a-faire-face' };

// Que faire en cas de difficulté > Vous avez plusieurs mensualités de retard
tag_infos['mensualites-retard'] = {A:'1',L:'183260',C:'8679',P:'17045',T:'I',URL:'http%3A%2F%2Fmoncreditresponsable.com%2Fdifficultes%2Fmensualites-retard' };


/************************* Tout savoir sur le crédit *************************/
// Tout savoir sur le crédit > Home
tag_infos['tout-savoir'] = {A:'1',L:'183243',C:'8679',P:'17042',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Ftout-savoir' };
tag_infos['tout-savoir']['home'] = {A:'1',L:'183246',C:'8679',P:'17043',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Ftout-savoir' };

// Tout savoir sur le crédit > Tchat du crédit responsable
tag_infos['tchat-credit-responsable'] = {A:'1',L:'183264',C:'8679',P:'17046',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Ftchat-credit-responsable' };
tag_infos['tchat-credit-responsable']['home'] = {A:'1',L:'183263',C:'8679',P:'17046',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Ftchat-credit-responsable' };

// Tout savoir sur le crédit > Conseils d'experts
tag_infos['conseils-experts'] = {A:'1',L:'183247',C:'8679',P:'17043',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Ftout-savoir%2Fconseils-experts' };

// Tout savoir sur le crédit > Les dossiers
tag_infos['les-dossiers'] = {A:'1',L:'183248',C:'8679',P:'17043',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Ftout-savoir%2Fles-dossiers' };

// Tout savoir sur le crédit > Lexique
tag_infos['lexique'] = {A:'1',L:'183270',C:'8679',P:'17050',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Ftout-savoir%2Flexique' };
tag_infos['lexique']['tout-savoir'] = {A:'1',L:'183249',C:'8679',P:'17043',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Ftout-savoir%2Flexique' };

// Tout savoir sur le crédit > Question des internautes
tag_infos['questions-internautes'] = {A:'1',L:'183266',C:'8679',P:'17047',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Ftout-savoir%2Fconseils-experts%2Fquestions-internautes' };

// Tout savoir sur le crédit > Le crédit responsable® vu par Cetelem
tag_infos['credit-responsable-cetelem'] = {A:'1',L:'183250',C:'8679',P:'17043',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Ftout-savoir%2Fcredit-responsable-cetelem' };

// Tout savoir sur le crédit > Outils pratiques
tag_infos['outils-pratiques'] = {A:'1',L:'183252',C:'8679',P:'17044',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fgerer-votre-budget%2Foutils-pratiques' };

// Tout savoir sur le crédit > Outils pratiques > Calcul de frais notariés
tag_infos['calculer-frais-notaries'] = {A:'1',L:'183257',C:'8679',P:'17044',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fgerer-votre-budget%2Foutils-pratiques%2Fimmobilier%2Fcalculer-frais-notaries' };

// Tout savoir sur le crédit > Outils pratiques > Simuler Crédit Immobilier
tag_infos['simuler-credit-immobilier'] = {A:'1',L:'183256',C:'8679',P:'17044',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fgerer-votre-budget%2Foutils-pratiques%2Fimmobilier%2Fsimuler-credit-immobilier' };

// Tout savoir sur le crédit > Outils pratiques > Estimer votre capacité d'emprunt (Immobilier)
tag_infos['estimer-capacite-emprunt'] = {A:'1',L:'183255',C:'8679',P:'17044',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fgerer-votre-budget%2Foutils-pratiques%2Fimmobilier%2Festimer-capacite-emprunt' };

// Tout savoir sur le crédit > Outils pratiques > Estimer votre capacité d'emprunt (Consommation)
tag_infos['estimer-capacite-emprunt-conso'] = {A:'1',L:'183253',C:'8679',P:'17044',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fgerer-votre-budget%2Foutils-pratiques%2Fconsommation%2Festimer-capacite-emprunt-conso' };

// Tout savoir sur le crédit > Outils pratiques > Simuler un crédit conso
tag_infos['simuler-credit-consommation'] = {A:'1',L:'183254',C:'8679',P:'17044',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fgerer-votre-budget%2Foutils-pratiques%2Fconsommation%2Fsimuler-credit-consommation' };


/************************* Bien gérer votre budget *************************/
// Bien gérer votre budget > Accueil
tag_infos['gerer-votre-budget'] = {A:'1',L:'183244',C:'8679',P:'17042',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fgerer-votre-budget' };
tag_infos['gerer-votre-budget']['home'] = {A:'1',L:'183251',C:'8679',P:'17044',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fgerer-votre-budget' };

// Bien gérer votre budget > les 5 règles d'or
tag_infos['regles-d-or'] = {A:'1',L:'183258',C:'8679',P:'17044',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fgerer-votre-budget%2Fregles-d-or' };

// Bien gérer votre budget  > Logiciel de gestion de budget
tag_infos['logiciel'] = {A:'1',L:'183268',C:'8679',P:'17048',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fgerer-votre-budget%2Flogiciel' };
tag_infos['logiciel']['home'] = {A:'1',L:'183267',C:'8679',P:'17048',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fgerer-votre-budget%2Flogiciel' };

// Bien gérer votre budget  > Posez votre question
tag_infos['poser-votre-question'] = {A:'1',L:'183269',C:'8679',P:'17049',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Ftout-savoir%2Fconseils-experts%2Fposer-votre-question' };


/************************* Autres rubriques *************************/
// Autres rubriques > Mentions légales
tag_infos['mentions-legales'] = {A:'1',L:'183274',C:'8679',P:'17050',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fmentions-legales' };

// Autres rubriques > Contact
tag_infos['contact'] = {A:'1',L:'183275',C:'8679',P:'17050',T:'I',URL:'http%3A%2F%2Fmoncreditresponsable.com%2Fcontact' };

// Autres rubriques > Contacts presse
tag_infos['contacts-presse'] = {A:'1',L:'183276',C:'8679',P:'17050',T:'I',URL:'http%3A%2F%2Fmoncreditresponsable.com%2Fcontacts-presse' };

// Autres rubriques > Plan du site
tag_infos['plan-du-site'] = {A:'1',L:'183273',C:'8679',P:'17050',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fplan-du-site' };

// Autres rubriques > Liens
tag_infos['liens'] = {A:'1',L:'183272',C:'8679',P:'17050',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Fliens' };

// Autres rubriques > Archives du chat
tag_infos['archives'] = {A:'1',L:'183271',C:'8679',P:'17050',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2Ftchat-credit-responsable%2Farchives%2F' };

// Autres rubriques > Accueil du site
tag_infos['home'] = {A:'1',L:'183277',C:'8679',P:'17050',T:'I',URL:'http%3A%2F%2Fwww.moncreditresponsable.com%2F' };

/* Typewriter */
(function($) {
	$.fn.typewriter = function(opt,callback) {
	        var i=0;
	        var typeone = function(self, text, content) {
	                if (text.length > 0) {
	                        i=i+1;
	                        var next = text.match(/(\s*(<[^>]*>)?)*(&.*?;|.?)/)[0];
	                        text = text.substr(next.length);
	                        $(self).html(content+next);
	                        setTimeout(function(){
	                                typeone(self, text, content+next);
	                        }, opt['delay']);
	                        if(text.length==0) if (callback!=null) callback();
	                }
	        }
	        this.each(function() {
	                opt = opt || { 'delay': 5000 };
	                typeone(this, $(this).html(), '');
	        });
	        return this;
	}
})(jQuery);
/*
	tabGenerator plugin for jQuery
	created by Cosmic Communication
	parameters: @separator : element which define the différent panels of content
					             a header tag (h2,h3,hr) can be choosen as delimiter > a div wraps each section beginning by this tag
	            @navigation : element which contains the tabs
*/

(function($) {
	$.fn.tabGenerator = function(options) {
		// Default options
		var settings = {
			separator : 'h4', // separator
			navigation: '.nav', // tab links class or id
			tabClassName: '.tabApplied'
		};
		if(options) $.extend(settings, options);
		function c(classSelector) { return classSelector.substr(1, classSelector.length); }  // remove the "." form the class selector
		// Element to exclude from the creation of wrapper div
		var arr = [ 'div' , 'dl' , 'ul' , 'li' ];
		
		$(this).addClass(c(settings.tabClassName));
		return $(this).each(function(i, elem) {
			// if object exists
			if ($(elem).length) {
				// initialize variables
				var div = false;
				var linkNavigTab = new Array();
				var idConteneur = null;
				var createWrappers = null;
				if (jQuery.inArray(options.separator, arr) < 0) {
					createWrappers = true
				}

				var wrapperElement = options.separator;
				/* Each elements delimited by the 
				 separator is wrapped by a div */
				
				// if element is not in the exclusion list to wrap with a div
				if (createWrappers) {
					$(elem).children().each(function(){
						if( $(this).is(options.separator) ){
							div = document.createElement("div");
							$(div).insertBefore(this);
							$(div).append(this);
							return;
						}
						if( div != false ){
							$(div).append(this);
						}
					});
					wrapperElement = 'div';
				}
				
				/* Id attribute of each created div */
				var parentElement = $(elem).find(wrapperElement).not(options.navigation);
				if (wrapperElement == 'li' && $(elem).find('ul').length == 2) {
					parentElement = $(elem).find('ul:eq(1)').find(wrapperElement).not(options.navigation);
				}

				parentElement.each(function(i,item) {
					var idConteneur;
					if (createWrappers) {
						idConteneur = $(this).find(options.separator).attr('id');
						$(this).attr('id',idConteneur+'_wrapper').addClass('panel').hide();	
						idConteneur = $(this).find(options.separator).attr('id',idConteneur+'_title');
					} else {
						idConteneur = $(this).attr('id');
						$(this).attr('id',idConteneur+'_wrapper').addClass('panel').hide();	
					}
				})

				/* If a url hash is present in the URL */

				if (window.location.hash) {
					var offsetElem = $(settings.tabClassName).offset().top
					$('html,body').animate({ scrollTop: offsetElem }, 0)
					var navigTabHash = window.location.hash; // hash variable
					if ($(elem).find(navigTabHash+'_wrapper').length) {
						$(elem).find(navigTabHash+'_wrapper').show(); // show !!!
						$(elem).find("a[href$='"+navigTabHash+"']").parent('li').addClass('active'); // give the 'active' class to the active tab
					}
					// else we show the first element
					else {
						$(elem).find('.panel:first').show(); // show !!!
						$(options.navigation).find('li:first').addClass('active'); // give the 'active' class to the first tab
					}
				} else {
					$(elem).find('.panel:first').show();
					$(settings.navigation).find('li:first').addClass('active');
				}
				
				// when the user click on a tab
				$(options.navigation).bind('click', function (e){	
					var $target = $(e.target);			
					if ($target.is("a[href*='#']")) {
						if ($target.parent('li').hasClass('active')) { return; }
						$(options.navigation).find("a").parent('li.active').removeClass('active'); // remove the 'active' class
						$target.parent('li').addClass('active'); // give the 'active' class to the active tab
						var hashValue = $target.attr("href"); // 'href' attribute of the clicked tab
						var lengthHref = $target.attr("href").length; // size of the url
						var checkhashValue = hashValue.lastIndexOf('#'); // search for the last # in the url
						if (checkhashValue > 1) {
							var targetHash = hashValue.substr(checkhashValue,lengthHref); // give the real hash value
							if ($(elem).find(targetHash)) {
								$(elem).find('.panel:visible').hide(); // hide the previous panel
								$(elem).find(targetHash+'_wrapper').fadeIn(); // show the called panel by the tab link
							}
						}
					}
				});
			}
		});
	}
})(jQuery);

(function($) {

    $.fn.innerfade = function(options) {
        return this.each(function() {   
            $.innerfade(this, options);
        });
    };

    $.innerfade = function(container, options) {
        var settings = {
        	'animationtype':    'fade',
            'speed':            'normal',
            'type':             'sequence',
            'timeout':          2000,
            'containerheight':  'auto',
            'runningclass':     'innerfade',
            'children':         null
        };
        if (options)
            $.extend(settings, options);
        if (settings.children === null)
            var elements = $(container).children();
        else
            var elements = $(container).children(settings.children);
        if (elements.length > 1) {
            $(container).css('position', 'relative').addClass(settings.runningclass);
            for (var i = 0; i < elements.length; i++) {
                $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide();
            };
            if (settings.type == "sequence") {
                setTimeout(function() {
                    $.innerfade.next(elements, settings, 1, 0);
                }, settings.timeout);
                $(elements[0]).show();
            } else if (settings.type == "random") {
            		var last = Math.floor ( Math.random () * ( elements.length ) );
                setTimeout(function() {
                    do { 
												current = Math.floor ( Math.random ( ) * ( elements.length ) );
										} while (last == current );             
										$.innerfade.next(elements, settings, current, last);
                }, settings.timeout);
                $(elements[last]).show();
						} else if ( settings.type == 'random_start' ) {
								settings.type = 'sequence';
								var current = Math.floor ( Math.random () * ( elements.length ) );
								setTimeout(function(){
									$.innerfade.next(elements, settings, (current + 1) %  elements.length, current);
								}, settings.timeout);
								$(elements[current]).show();
						}	else {
							alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
						}
				}
    };

    $.innerfade.next = function(elements, settings, current, last) {
        if (settings.animationtype == 'slide') {
            $(elements[last]).slideUp(settings.speed);
            $(elements[current]).slideDown(settings.speed);
        } else if (settings.animationtype == 'fade') {
            $(elements[last]).fadeOut(settings.speed);
            $(elements[current]).fadeIn(settings.speed, function() {
							removeFilter($(this)[0]);
						});
        } else
            alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');
        if (settings.type == "sequence") {
            if ((current + 1) < elements.length) {
                current = current + 1;
                last = current - 1;
            } else {
                current = 0;
                last = elements.length - 1;
            }
        } else if (settings.type == "random") {
            last = current;
            while (current == last)
                current = Math.floor(Math.random() * elements.length);
        } else
            alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
        setTimeout((function() {
            $.innerfade.next(elements, settings, current, last);
        }), settings.timeout);
    };

})($);

// **** remove Opacity-Filter in ie ****
function removeFilter(element) {
	if(element.style.removeAttribute){
		element.style.removeAttribute('filter');
	}
}


/* fonction qui réalise des effets de fading sur différentes éléments */
function fadingHome() {
	/* agit sur le texte défilant de la page d'accueil */
	if ($('.fade').length)
		$('.fade').innerfade({ 
			speed: 'slow', /* On fixe la vitesse d'animation */
			timeout: 5000, /* On détermine le temps ou le texte sera visible */
			type: 'sequence', /* On selection un type d'animation (il y a également slide) */
			containerheight: '6.2em' /* On fixe une taille pour la div concernée */
		});
		
	/* agit sur la pseudo-bannière de la page d'accueil */
	if ($('.banniere').length)	{
	  	// on revele les blocs caches pour le cas : pas de js
	  $('.sequence2').show();
	  $('.sequence3').show();	  
	  $('.banniere').innerfade({ 
			speed: 'slow', 
			timeout: 4000, 
			type: 'sequence', 
			containerheight: '61px'
		});
	}	
}

/* Permet d'afficher le formulaire */	
function afficheForm() {
	if($(".error").text().length) {
		$('.pas-de-reponse').hide();
	}
	
	$('#affiche-form').click(function () {
		$('#contacter-un-expert').fadeIn("slow");
	});
}

/* Cache le formulaire s'il n'y a pas de message d'erreur 
ou si la page est chargée pour la première fois sinon on affiche */

function cacheForm() {
	if(($(".error").text().length) || ($(".info-form-contact").text().length)) {
		$('#contacter-un-expert').show();
		// on scrolle vers le bas pour montrer l'erreur dans le formulaire
		var $targetId = $("#contacter-un-expert"), $targetAnchor = $('[name=#contacter-un-expert]');
	    var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
	       if ($target) {
	         var targetOffset = $target.offset().top;
	           $('html, body').animate({scrollTop: targetOffset}, 400);
	           return false;
	    }
	}
	else if ($('#poser-votre-question').length || $('#vos-commentaires').length || $('#envoyer-commentaire').length){
		$('#contacter-un-expert').show();
	}
	else {
		$('#contacter-un-expert').hide();
	}
}

// permet de scroller sur les éléments de la page
function scrollerAncre(){
  function filterPath(string) {
    return string
      .replace(/^\//,'')  
      .replace(/(index|default).[a-zA-Z]{3,4}$/,'')  
      .replace(/\/$/,'');
  }
  $('a[href*=#]').each(function() {
    if ( filterPath(location.pathname) == filterPath(this.pathname)
    && location.hostname == this.hostname
    && this.hash.replace(/#/,'') ) {
      var $targetId = $(this.hash), $targetAnchor = $('[name=' + this.hash.slice(1) +']');
      var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
       if ($target) {
         var targetOffset = $target.offset().top;
			if (!$(this).parents('#transcriptContainer')) {
				$(this).click(function() {
	           $('html, body').animate({scrollTop: targetOffset}, 400);
	           return false;
	         });
			}
      }
    }
  });
}

/*Gestion des popups*/
jQuery.fn.popupwindow = function(p)
{

	var profiles = p || {};

	return this.each(function(index){
		var settings, parameters, mysettings, b, a;
		
		// for overrideing the default settings
		mysettings = (jQuery(this).attr("rel") || "").split(",");

		
		settings = {
			height:600, // sets the height in pixels of the window.
			width:600, // sets the width in pixels of the window.
			toolbar:0, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
			scrollbars:0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
			status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
			resizable:1, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
			left:0, // left position when the window appears.
			top:0, // top position when the window appears.
			center:0, // should we center the window? {1 (YES) or 0 (NO)}. overrides top and left
			createnew:1, // should we create a new window for each occurance {1 (YES) or 0 (NO)}.
			location:0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
			menubar:0 // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}.
		};

		// if mysettings length is 1 and not a value pair then assume it is a profile declaration
		// and see if the profile settings exists

		if(mysettings.length == 1 && mysettings[0].split(":").length == 1)
		{
			a = mysettings[0];
			// see if a profile has been defined
			if(typeof profiles[a] != "undefined")
			{
				settings = jQuery.extend(settings, profiles[a]);
			}
		}
		else
		{
			// overrides the settings with parameter passed in using the rel tag.
			for(var i=0; i < mysettings.length; i++)
			{
				b = mysettings[i].split(":");
				if(typeof settings[b[0]] != "undefined" && b.length == 2)
				{
					settings[b[0]] = b[1];
				}
			}
		}

		// center the window
		if (settings.center == 1)
		{
			settings.top = (screen.height-(settings.height + 110))/2;
			settings.left = (screen.width-settings.width)/2;
		}
		
		parameters = "location=" + settings.location + ",menubar=" + settings.menubar + ",height=" + settings.height + ",width=" + settings.width + ",toolbar=" + settings.toolbar + ",scrollbars=" + settings.scrollbars  + ",status=" + settings.status + ",resizable=" + settings.resizable + ",left=" + settings.left  + ",screenX=" + settings.left + ",top=" + settings.top  + ",screenY=" + settings.top;
		
		jQuery(this).bind("click", function(){
			var name = settings.createnew ? "PopUpWindow" + index : "PopUpWindow";
			window.open(this.href, name, parameters).focus();
			return false;
		});
	});

};

function loadPopup() {
  	jQuery(".popupwindow").popupwindow();
}

function in_array(needle, haystack, argStrict) {
    var key = '', strict = !!argStrict;
    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;
            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
                return true;
            }
        }
    }
    return false;
}

// Lancement des fonctions au chargement de la page
$(document).ready(function(){
	loadPopup();
	scrollerAncre(); // fonction permettant de scroller vers le haut

	// Lancement des fonctions au chargement de la page home
	if ($('#home').length){
		fadingHome(); // texte défilant de la page d'accueil
		scrollerAncre(); // fonction permettant de scroller vers le haut
	};

	// Lancement des fonctions au chargement d'un page contenu
	if ($('#contacter-un-expert').length){
		cacheForm();
		afficheForm(); // fonction permettant d'afficher le formulaire de contact
	};
	
	$('.img-img-illustr').innerfade({ 
		speed: 'slow', 
		timeout: 6000, 
		type: 'sequence', 
		containerheight: '61px'
	});



	/* c'est ici que l'on définit la taille du flash */
	/* attention à rester en 4/3, auquel il faut ajouter la hauteur de la navigation */
	if ($('a[@href$=".flv"]:first').length) {
		var widthPlayer,heightPlayer;
		if ($('#home').length) {
			widthPlayer = 288;
			heightPlayer = 222;
		} else {
			widthPlayer = 370;
			heightPlayer = 281;
		}
	}

	$('a[@href$=".flv"]').each(function(i,item) {
		var flv = $(item).attr('href');
		var img = $(item).find('img').attr('src');
		var wrapper_id = 'flashvideo_'+i;
		var player_id = 'mediaplayer_'+i;
		$(item).attr('id',wrapper_id)
		var s = new FlashObject("scripts/player.swf", player_id, widthPlayer, heightPlayer, "9", "#FFFFFF");
		s.addParam("allowfullscreen","true");
		s.addParam("allowscriptaccess","always");
		s.addParam("flashvars","file="+flv+"&image="+img+"&stretching=uniform");
		s.write(wrapper_id);
		$('object[name='+player_id+']').attr('id',player_id);
	});


	
	$('.playvideo a[@href$=".mp4"]').click(function() {
		var playerId = document.getElementById('mediaplayer_0');
		var url = $(this).attr('href');
		var urlFlv = url.replace('.mp4','.flv');
		var obj = {type:"video",file:urlFlv};
		playerId.sendEvent('LOAD',obj);
		playerId.sendEvent('PLAY','true');
		return false;
	});
	
	$('a[id^=flashvideo]').click(function() {
		return false;
	});

	
	// Setup the tab Generator :)
	if (typeof $.fn.tabGenerator != 'undefined') {
		$('#transcriptContainer blockquote').tabGenerator({
			separator: 'h4',
			navigation: '.navigationtranscripts'
		});
	}
	
	$('a[rel=external]').attr('target','blank');
	
	if (typeof $.fn.prettyPhoto != "undefined") {
		$('a[rel*=lightbox]').prettyPhoto({
			theme: 'light_rounded' /* light_rounded / dark_rounded / light_square / dark_square */
		});
	}

	$('#home #forum h3 a').typewriter({
		delay:100
	});
	

	/* Insertion des clicks tags weborama */
	if ( !in_array(window.location.host,dev_version) ) {
		$('a').clickTags({
			idWeborama:142001,
			taggedPage:tag_infos,
			extendedTag:$('body').attr('id')
		});
	}

});
