/** 
 * @projectDescription Dessange main script file
 *
 * @author 	DEILLER Emmanuel emmanuel.deiller@mediagong.tv
 * @version 	0.1 
 */
function trace(obj){
	if (!jQuery.browser.msie) {
		console.log(obj);
	}else{
		//alert(obj);
	}
}

var navStatus 			= '';
var cuePointArrayTxt 	= new Array();
var titleVideo 			= '';		
var domain_name			= 'www.secrets-dessange.fr';
var defaultVideo 		= 'le-coiffe-decoiffe';
var defaultConseil 		= 'notre-programme-anti-secheresse';
/**
 * updateCuePoint
 * idCuePoint int return id node to parse xml
 */
function updateCuePoint(idCuePoint,url_xml){
	Dessange.buildCuePointText(idCuePoint,url_xml);
}

/**
 * @classDescription Dessange main Javascript Class
 */
var Dessange = {	
	/**
	 * Gets user's viewport width and height
	 * @method
	 */
	getViewportDim: function(){		
		// dimension array : width/height
		var dimensions = [];
		dimensions.push(jQuery("html").outerWidth());
		dimensions.push(jQuery("html").outerHeight());		
		return dimensions;
	},	
	/**
	 *  settlement
	 * @method
	 */
	intro: function(){
		if (!jQuery.browser.msie) {
		}
	},
	/**
	 * toggleNav settlement
	 * @method
	 */
	toggleNav: function(){
		
		/**
		 * @classDescription Navigation management between pages
		 */
		var Navigation = {
			manageNav: function(obj){
				jQuery("#navigation #level0 ul li h2 a").each(function(){
					Navigation.hoverNav(jQuery(this));
				});									
			},
			buildNav: function(obj){	
				Navigation.setCurrentItem(jQuery(obj));	
			},
			buildSubNav: function(obj){		
				Navigation.setCurrentItem(jQuery(obj).parents("li.subnav").attr("id").replace('sub_','')+" h2 a");
				Navigation.setCurrentItem(jQuery(obj).parents("li.subnav"));
				jQuery(obj).addClass("active");
			},	
			/**
			 * Bind hover nav default behaviours
			 * @method
			 */
			hoverNav:function(obj){
				jQuery(obj).bind("mouseenter", function(event){
					Navigation.setDefault();
					if (navStatus != "open"){
						Navigation.setHoverItem(jQuery(this));
						Navigation.removeHoverAllSubItem();
						Navigation.setHoverSubItem(jQuery(this));
						navStatus = "open";	
						return false;
					}
				});
				jQuery(obj).bind("mouseleave", function(event){					
					navStatus = "";						
					return false;					
				});
			},
			/**
			 * Bind hover nav default behaviours
			 * @method
			 */
			hoverSubNav:function(obj){
				/*
				jQuery(obj).bind("mouseenter", function(event){
					jQuery("#navigation #level0 ul li h2 a.current").removeClass("hover");		
					jQuery("#navigation #level0 ul li#"+jQuery(this).attr("id").replace('sub_','')+" h2 a").addClass("hover");
					jQuery(this).addClass("hover");
				});
				*/
				/*
				jQuery(obj).bind("mouseleave", function(event){
					Navigation.removeHoverItem(jQuery(this));
					Navigation.removeHoverItem(jQuery("#navigation #level0 ul li#"+jQuery(this).attr("id").replace('sub_','')+" h2 a"));
					jQuery("#navigation #level0 ul li h2 a.current").addClass("hover");		
				});
				*/
			},
			/**
			 * Generic nav Current Item menu
			 * @method
			 * @param	obj		jQuery collection : current nav list item
			 */
			setCurrentItem: function(obj){				
				jQuery(obj).addClass("hover").addClass("current");				
			},
			/**
			 * Generic nav hover Item menu
			 * @method
			 * @param	obj		jQuery collection : current nav list item
			 */
			setHoverItem: function(obj){
				jQuery(obj).addClass("hover");
			},
			/**
			 * Generic nav hover sub Item menu
			 * @method
			 * @param	obj		jQuery collection : current nav list item
			 */
			setHoverSubItem: function(obj){
				jQuery("#navigation #level1 ul li#sub_"+jQuery(obj).parents("li").attr("id")).addClass("subhover");
				Navigation.setHoverItem(jQuery("#navigation #level1 ul li#sub_"+jQuery(obj).parents("li").attr("id")));		
				Navigation.hoverSubNav(jQuery("#navigation #level1 ul li#sub_"+jQuery(obj).parents("li").attr("id")));	
			},
			/**
			 * Generic remove nav hover Item menu
			 * @method
			 * @param	obj		jQuery collection : current nav list item
			 */
			removeHoverItem: function(obj){
				jQuery(obj).removeClass("hover");
			},
			/**
			 * Generic remove nav hover sub Item menu
			 * @method
			 * @param	obj		jQuery collection : current nav list item
			 */
			removeHoverSubItem: function(obj){
				jQuery(obj).removeClass("hover");						
			},
			/**
			 * Generic remove nav hover all Item menu
			 * @method
			 * @param	obj		jQuery collection : current nav list item
			 */
			removeHoverAllItem: function(){
				jQuery("#navigation #level0 ul li h2 a.hover").removeClass("hover");
			},
			/**
			 * Generic remove nav hover all sub Item menu
			 * @method
			 * @param	obj		jQuery collection : current nav list item
			 */
			removeHoverAllSubItem: function(){
				jQuery("#navigation #level1 ul li.hover").removeClass("current").removeClass("hover");						
			},
			/**
			 * Bind nav default behaviours
			 * @method
			 */
			setDefault: function(){
				// restores default behaviours
				Navigation.removeHoverAllItem();
				Navigation.removeHoverAllSubItem();				
			}
		}
		// variables
		var myUrl = document.location.href;		
		var temp = myUrl.lastIndexOf("/");
		myUrl = myUrl.substr(temp+1);
					
		myUrlId = myUrl.split(".")[0];
		var reg=new RegExp("-", "g");
		myUrlId = myUrlId.replace(reg,'_');
		
		var stringToFind = "la_gamme";
		var text = myUrlId.toString();
		
		var regExp = new RegExp( stringToFind, "gi") ;
		if (text.search(regExp) == -1){
			myUrlIdCase = myUrlId;
		}else{
			myUrlIdCase = stringToFind;
		}
		/* 	from : "la-gamme-anti-age.html"  to : "la-gamme/anti-age/index.html"*/
		var regExp 	= new RegExp("^([A-Za-z]+-[A-Za-z]+)-([A-Za-z\-]*)\.html$" );
		myUrl 		= myUrl.replace(regExp,"$1/$2/index.html");
		
		/* patch for gamme html product acces direct to load autocompletion searchbot */
		if(jQuery('body').hasClass('la_gamme') || jQuery('body').hasClass('gamme_hp')){
			Dessange.autoComplete("#searchword");
			jQuery("#searchBox").bind("submit", function(e){
				jQuery("#searchword").val('');
				return false;
			});			
		}	
		if (myUrlIdCase.length) {
			// defines differents action for different page
			switch (myUrlIdCase) {
				default:
					// show current item
					Navigation.setCurrentItem(jQuery("#"+myUrlId));					

					// restores default nav
					break;
					
				case "index":
					break;
					
				case "votre_diagnostic_cheveu" :					
					// show current item
					Navigation.setCurrentItem(jQuery("#les_conseils_sur_mesure"));
					
					// initSlide
					Dessange.initSlide("slow",false,true);
					
					// manage form
					Dessange.FormDiag();
										
					// manage Rollover
					Dessange.Rollover('#slider label img','formdiag');					
					break;	
					
				case "votre_diagnostic_cheveu_resultat" :
					// show current item
					Navigation.setCurrentItem(jQuery("#les_conseils_sur_mesure"));

					/* gestion png transparents pour ie6 */
					if (jQuery.browser.msie) {
						if(parseInt(jQuery.browser.version)==6){
							$('#result_products img').each(function(){
								t = $(this);
								t.wrap('<span class="png"></span>');
							});
						}
					}
							
					if (jQuery.browser.msie) {
						if(parseInt(jQuery.browser.version)==6){
							$('.png').each(function(){
								t = $(this);
								t.css({display:'block'});
								t.attr("id",t.children('img').attr('id'));
								t.css({width:t.children('img').attr('width')});
								t.css({height:t.children('img').attr('height')});
								t.css({filter:'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+t.children('img').attr('src')+'", sizingMethod="image")'});
								t.children('img').hide();
							});
						}
					}
					/*/gestion png transparents pour ie6 */
					
					/* Print Button */
					jQuery("#print_solution").bind("click", function(event){
						//prevents default behaviour
						event.preventDefault();			
						var url 		= jQuery(this).attr('href');
						var title		= jQuery(this).attr('title');
						Dessange.socialFunctions('print', url, title);
						return false;	
					});	 
					
					// scroll skinned
					Dessange.toggleScroll(0);
					break;
					
				case "jeu_concours" :
					
					// manage popin			
					jQuery(".jeu_concours2 #contentVideo").hide();
					jQuery(".jeu_concours2 #contentVideo").addClass('popin_content');
					Dessange.popin(".jeu_concours2 #contentVideo");
					
					// load video
					Dessange.buildContentVideo('something');
					Dessange.Rollover('#indice img');					
					break;	
					
				case "jeu_concours_inscription" :					
					// apply FormSkin
					Dessange.FormSkin('.jc_form');
					
					/* Legacy button to popin */					
					Dessange.popin("#popup_content_legacy");
					break;	
					
				case "la_marque":
				case "son_histoire":
					// show current item
					Navigation.setCurrentItem(jQuery("#la_marque"));

					// show current subitem
					Navigation.buildSubNav(jQuery("#son_histoire"));
					
					/* gestion png transparents pour ie6 */
					if (jQuery.browser.msie) {
						if(parseInt(jQuery.browser.version)==6){
							$('#history_content img.pnggif').each(function(){
								t = $(this);
								t.wrap('<span class="png"></span>');
							});
						}
					}
							
					if (jQuery.browser.msie) {
						if(parseInt(jQuery.browser.version)==6){
							$('.png').each(function(){
								t = $(this);
								t.css({display:'block'});
								t.attr("id",t.children('img').attr('id'));
								t.css({width:t.children('img').attr('width')});
								t.css({height:t.children('img').attr('height')});
								t.css({filter:'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+t.children('img').attr('src')+'", sizingMethod="image")'});
								t.children('img').hide();
							});
						}
					}
					/*/gestion png transparents pour ie6 */
					
					// scroll skinned
					if (jQuery.browser.msie) {
						if(parseInt(jQuery.browser.version)==6){
							//do nothing
						}else{
							Dessange.toggleScroll(1);
						}
					}else{
						Dessange.toggleScroll(1);
					}
					break;	
				
				case "son_expertise_professionnelle":				
					// show current item
					Navigation.setCurrentItem(jQuery("#la_marque"));
					
					// show current subitem
					Navigation.buildSubNav(jQuery("#"+myUrlId));					
					break;	
									
				case "les_publicites":			
					// show current item
					Navigation.setCurrentItem(jQuery("#la_marque"));
					
					// show current subitem
					Navigation.buildSubNav(jQuery("#"+myUrlId));
					
					// scroll skinned
					Dessange.toggleScroll(1);	
					
					// manage popin			
					jQuery(".les_publicites #contentVideo").hide();
					jQuery(".les_publicites #contentVideo").addClass('popin_content');
					Dessange.popin(".les_publicites #contentVideo");
					
					// load video
					Dessange.buildContentVideo('something');
					break;	
												
				case "programmes_de_soins":
				case "produits_coiffants":
					// show current item
					Navigation.setCurrentItem(jQuery("#la_gamme"));

					// show current subitem
					Navigation.buildSubNav(jQuery("#"+myUrlId));
						
					break;	
				
				case "les_conseils_sur_mesure":
				case "les_secrets_de_coiffeurs":			
				case "secrets_de_coiffure_en_video":
					// show current item
					Navigation.setCurrentItem(jQuery("#les_conseils_sur_mesure"));

					// show current subitem
					Navigation.buildSubNav(jQuery("#les_secrets_de_coiffeurs"));
					
					// scroll skinned
					Dessange.toggleScroll(0);
					
					// load video
					Dessange.buildContentVideo();
					
					/* Print Button */
					jQuery("#btn_print").bind("click", function(event){
						//prevents default behaviour
						event.preventDefault();			
						var url 		= jQuery(this).attr('href');
						var title		= jQuery(this).attr('title');
						Dessange.socialFunctions('print', url, title);
						return false;	
					});	 
					
					/* Download Button */
					jQuery("#btn_dl").bind("click", function(event){
						//prevents default behaviour
						event.preventDefault();			
						var url 		= jQuery(this).attr('href');
						var title		= jQuery(this).attr('title');
						title 			= title.replace('Télécharger le secret vidéo : ','');
						Dessange.socialFunctions('download', url, title);
						return false;						
					});	
					
					/* Blogger button to popin */
					jQuery("#btn_blogger").bind("click", function(event){
						//prevents default behaviour
						event.preventDefault();			
						var url 		= jQuery(this).attr('href');
						var title		= jQuery(this).attr('title');
						title 			= title.replace('Blogger le secret vidéo : ','');
						Dessange.socialFunctions('blogger', url, title);
						return false;
					});	
					Dessange.popin("#popup_content_blogger");
					
					/* Send to Friend Button */
					jQuery("#btn_mail").bind("click", function(event){
						//prevents default behaviour
						event.preventDefault();			
						var url 		= jQuery(this).attr('href');
						var title		= jQuery(this).attr('title');
						title 			= title.replace('Envoyer à un(e) ami(e) le secret vidéo ','');
						Dessange.socialFunctions('mail', url, title);
					});	
					
					/* Facebook share Button */
					jQuery("#btn_fb").bind("click", function(event){
						//prevents default behaviour
						event.preventDefault();			
						var url 		= jQuery(this).attr('href');						
						var title		= jQuery(this).attr('title');
						Dessange.socialFunctions('FB_share', url, title);
						//return false;
					});	 
					break;	
					
				case "secrets_pour_une_chevelure_magnifique":
					// show current item
					Navigation.setCurrentItem(jQuery("#les_conseils_sur_mesure"));

					// show current subitem
					Navigation.buildSubNav(jQuery("#les_secrets_de_coiffeurs"));

					Dessange.secretsConseil();
					
					// scroll skinned
					//Dessange.toggleScroll(0);
					break;	
					
				case "la_gamme" :
					// show current item
					Navigation.setCurrentItem(jQuery("#"+myUrlId));
					
					// manage autoComplete
					Dessange.autoComplete("#searchword");

					// Manage content html or flash
					var stringToFind = "la-gamme.html";
					var text = myUrl.toString() ;
					var regExp = new RegExp( stringToFind, "gi") ;
					if (text.search(regExp) == -1){
						Dessange.buildContentArea("#contentArea", myUrl, 1);
					}
					break;
			}
		}
		// inits navigation
		Navigation.manageNav();
	},
	/**
	 * Initialization of Dessange class
	 * All calls of other methods go in there
	 * @method
	 */
	init: function(){
		// inits navigation
		Dessange.toggleNav();
	},
	/**
	 * Building FlashContent sets
	 * @method
	 * @param {Object}	DEST			jQuery object 
	 * @param {String}	SRC				flash source
	 * @param {Number}	W				width
	 * @param {Number}	H				height
	 * @param {String}	FLASHVARS		vars
	 * @param {String}	FLASHPARAMS		params
	 */
	loadSWF : function(DEST,SRC,objId,W,H,VERSION,FLASHVARS,FLASHPARAMS){
		jQuery('#'+DEST).remove(jQuery('#'+objId));
		//jQuery(DEST).append('<object id="flashcontent" type="application/x-shockwave-flash" data="'+SRC+'" width="'+W+'" height="'+H+'"><param name="movie" value="'+SRC+'" /><param name="wmode" value="transparent" /><param name="flashvars" value="'+FLASHVARS+'" /></object>');
		jQuery('#'+DEST).append('<div id="'+objId+'"></div>');
		// loading an SWF to the flashcontent
		swfobject.embedSWF(SRC, "'+objId+'", W, H, VERSION, "/swf/expressInstall.swf", FLASHVARS, FLASHPARAMS);
	},
	/**
	 * Building ContentVideo sets
	 * @method
	 * @param {Object}	oElm		jQuery object 
	 * @param {String}	link		link = video url or xml url 
	 */
	buildContentVideo : function(oElm, url_xml){
		/**
		 * @classDescription Content set manipulation class
		 */
		var ContentVideo = {
			/**
			 * manage Content set
			 * @method
			 */
			manageContent: function(){
				jQuery("#linkers li a, #videos_links li a, a.popup_content_video").bind("click", function(event){		
					//prevents default behaviour
					event.preventDefault();					
					var link 	= jQuery(this).attr("href");
					var regex 	= /\/[a-zA-Z0-9\-]+\.html#?/;
					var url_xml = link.replace(regex,'/videos/')+'.xml';
					ContentVideo.buildContent("contentVideo", url_xml);
				});	
			},
			/**
			 * build Content set
			 * @method
			 */
			buildContent: function(oElm,url_xml){
				ContentVideo.setDefault("#contentVideo", url_xml);
				
				// empty cuePointArrayTxt
				cuePointArrayTxt=[];
				ContentVideo.clean('#cuePointText p');
					
				jQuery('#'+oElm).fadeTo(150, 0, function(){
					var FLASHVARS 	= {url_xml:url_xml};
					var FLASHPARAMS = {allowfullscreen:"true",allowscriptaccess:"always",menu:"false",wmode:"transparent"};
					var SRC 		= "/swf/videoplayer.swf";
					var W 			= 650;
					var H			= 432;
					var VERSION		= "9.0.0";
					swfobject.embedSWF(SRC, oElm, W, H, VERSION, "/swf/expressInstall.swf", FLASHVARS, FLASHPARAMS);
				}).fadeTo(1000, 1).fadeTo("slow", 1);	
			},	
			/**
			 * Cleans obj set
			 * @method
			 */
			clean: function(obj){	
				jQuery(obj).empty();
			},	
			/**
			 * default obj
			 * @method
			 */
			setDefault: function(oElm, url_xml){	
				var reg 		= new RegExp("/videos/", "g");
				var url  		= url_xml.replace(reg,'');
				
				var myUrl 		= document.location.href;
				var temp 		= myUrl.lastIndexOf("/");
				myUrl 			= myUrl.substr(temp+1);
				reg 			= new RegExp("#", "g");
				myUrl  			= myUrl.replace(reg,'');
				
				/* assign location href to Facebook Share button */				
				var newtitle 	= url_xml;
				reg 			= new RegExp(".xml", "g");
				url  			= url.replace(reg,'');
				
				var reg 		= new RegExp("/videos/", "g");
				newtitle 		= newtitle.replace(reg,'');
				
				reg 			= new RegExp("-", "g");
				newtitle 		= newtitle.replace(reg,' ');
				
				reg 			= new RegExp(".xml", "g");
				newtitle 		= newtitle.replace(reg,'');
				
				newtitle 		= jQuery('meta[name=title]').attr('content')+' : '+newtitle;
				window.name		= newtitle;
				jQuery('meta[name=title]').attr('content',newtitle);
				jQuery('#btn_fb').attr('title',newtitle);
				//jQuery('#btn_fb').attr('href',document.location.href);
				var fb_url = 'http://'+domain_name+'/secrets-de-coiffure-en-video.html#'+url;
				jQuery('#btn_fb').attr('href',fb_url);
				
				/* assign location href to print button */				
				var print_url 	= '/pdf/secrets/'+url+'.pdf';
				jQuery('#btn_print').attr('title','Imprimer le secret vidéo : '+newtitle);
				jQuery('#btn_print').attr('href',print_url);

				/* assign location href to download button */
				var dl_url 		= '/videos/'+url+'.wmv';
				jQuery('#btn_dl').attr('title','Télécharger la vidéo : '+newtitle);
				jQuery('#btn_dl').attr('href',dl_url);

				/* assign location href to blogger button */
				var blogger_url = '/secrets-de-coiffure-en-video.html#'+url;
				jQuery('#btn_blogger').attr('title','Blogger le secret vidéo : '+newtitle);
				jQuery('#btn_blogger').attr('href',blogger_url);
				jQuery('#btn_blogger').addClass('popin').addClass('popup_content_blogger');
				
				/* assign location href to mail button */
				var mail_url 	= '/envoyer-a-un-ami.aspx?video_url='+myUrl+'#'+url+'&title='+newtitle;
				jQuery('#btn_mail').attr('title','Envoyer à un(e) ami(e) le secret vidéo : '+newtitle);
				jQuery('#btn_mail').attr('href',mail_url);
				
				var SRC 		= '/swf/videoplayer.swf';
				var W 			= 650;
				var H			= 432;
				var flash_vars 	= 'lang=fr&country=fr&domain_name=http://'+domain_name+'/&url_xml='+url_xml;
				jQuery("head").append('<meta name="medium" content="video" />');
				//jQuery("head").append('<link rel="image_src" href="http://'+domain_name+'/videos/vignette_'+url+'.jpg" />');
				jQuery("head").append('<link rel="image_src" href="http://'+domain_name+'/img/content/conseils/btn_'+url+'_OFF.jpg" />');
				jQuery("head").append('<link rel="video_src" href="http://'+domain_name+''+SRC+'?'+flash_vars+'" />');
				jQuery("head").append('<meta name="video_height" content="'+H+'" />');
				jQuery("head").append('<meta name="video_width" content="'+W+'" />');
				jQuery("head").append('<meta name="video_type" content="application/x-shockwave-flash" />');
			}				
		}
		
		// set manageContent
		ContentVideo.manageContent();
		
		if (oElm) {
			// cleaning previous set
			//ContentVideo.buildContent(oElm,url_xml);
		} else {
			// start by default to load the first video
			var myUrl 		= document.location.href;
			var temp 		= myUrl.lastIndexOf("/");
			myUrl 			= myUrl.substr(temp+1);
			reg 			= new RegExp("#", "g");

			if (myUrl.search(reg) == -1){
				ContentVideo.buildContent("contentVideo",'/videos/'+defaultVideo+'.xml');
			}else{
				temp 			= myUrl.lastIndexOf("#");
				myUrl 			= myUrl.substr(temp+1);
				ContentVideo.buildContent("contentVideo",'/videos/'+myUrl+'.xml');	
			}
		}
	},
	/**
	 * Building cue point text sets
	 * @method
	 * @param {int}	idCuePoint		
	 * @param {String}	url		url = video url or xml url 
	 */
	buildCuePointText : function(idCuePoint,url_xml){
		/**
		 * @classDescription Content set manipulation class
		 */
		var textVideo 			= '';
										
		var ContentTxt = {
			/**
			 * manage Content set
			 * @method
			 */
			manageContent: function(idCuePoint,url_xml){	
				jQuery.ajax({ // Requete ajax
					type: "GET",
					url: url_xml,
					dataType: "xml",// donn&eacute;es envoy&eacute;es
					success: function(xml){ // Lorsque le PHP a renvoy&eacute; une r&eacute;ponse
						jQuery(xml).find('video').each(function(){ // pour chaque "element"
							titleVideo 		= "<b>"+jQuery(this).find('title').text()+"</b><br /><br />";
						});
						jQuery(xml).find('cuePoint').each(function(){ // pour chaque "element"
							textVideo 		= jQuery(this).find('texte').text();
							cuePointArrayTxt.push(titleVideo+textVideo); // ajout dans le tableau
						});
						textVideo = cuePointArrayTxt[idCuePoint];
						ContentTxt.buildContent(textVideo);
					}
				});
			},
			/**
			 * build Content set
			 * @method
			 */
			buildContent: function(cuePointTxt){
				jQuery('#cuePointText p').fadeTo("fast", 0, function(){					
					ContentTxt.clean('#cuePointText p');
					ContentTxt.updateText('#cuePointText p',cuePointTxt);	
				}).fadeTo(1000, 1).fadeTo("fast", 1);	
			},
			/**
			 * update cue point text set
			 * @method
			 */
			updateText: function(obj,msg){
				jQuery(obj).html(msg);			
			},					
			/**
			 * Cleans obj set
			 * @method
			 */
			clean: function(obj){	
				jQuery(obj).empty();
			},	
			/**
			 * default obj
			 * @method
			 */
			setDefault: function(cuePointTxt){	
				if (jQuery(cuePointTxt).length) {
					// cleaning previous set
					ContentTxt.clean('#cuePointText p');
					// appending new content set from ajax request
					ContentTxt.buildContent(cuePointTxt);
				}
			}		
		}	
		// set manageContent
		if (cuePointArrayTxt.length) {
			textVideo = cuePointArrayTxt[idCuePoint];
			ContentTxt.buildContent(textVideo);
		} else {
			ContentTxt.manageContent(idCuePoint,url_xml);
		}
	},
	/**
	 * Building socialFunctions sets
	 * @method
	 * @param {int}	idCuePoint		
	 * @param {String}	url		url = video url or xml url 
	 */
	socialFunctions : function(actionName, url, title){
		/**
		 * @classDescription Content set manipulation class
		 */
		var textVideo 			= '';
										
		var socialActions = {
			/**
			 * manage Actions set
			 * @method
			 */
			manageActions: function(){	
				
			},
			/**
			 * build print set
			 * @method
			 */
			print: function(title,url){
				title = 'popImprimer';
				window.open(url,title,"top=0,left=0,width="+screen.width+", height="+screen.height+",scrollbars=yes,status=yes,toolbar=yes,resizable=yes,menubar=yes,location=yes");
				return false;
			},
			/**
			 * build download set
			 * @method
			 */
			download: function(title,url){
				title = 'popTelecharger';
				window.open(url,title);
				return false;
			},
			/**
			 * build embedContent set
			 * @method
			 */
			embedContent: function(title,url){
				var regex 		= /\/[a-zA-Z0-9\-]+\.html#?/;
				var url_xml 	= url.replace(regex,'/videos/')+'.xml';
				var FLASHVARS 	= {url_xml:url_xml};
				var SRC 		= "/swf/videoplayer.swf";
				var W 			= 650;
				var H			= 432;
				var embedCode 	='';
				embedCode 		+='<object '+"\n";
				embedCode 		+="\t"+'data="http://'+domain_name+''+SRC+'" '+"\n";
				embedCode 		+="\t"+'id="contentVideo" ';
				embedCode 		+='type="application/x-shockwave-flash" '+"\n";
				embedCode 		+="\t"+'height="'+H+'" ';
				embedCode 		+='width="'+W+'">'+"\n";
				embedCode 		+="\t"+'<param name="allowfullscreen" value="true" />'+"\n";
				embedCode 		+="\t"+'<param name="allowscriptaccess" value="always" />'+"\n";
				//embedCode 		+="\t"+'<param name="menu" value="false" />'+"\n";
				//embedCode 		+="\t"+'<param name="wmode" value="transparent" />'+"\n";
				embedCode 		+="\t"+'<param name="movie" value="http://'+domain_name+''+SRC+'" />'+"\n";
				//embedCode 		+="\t"+'<param name="flashvars" value="url_xml='+url_xml+'" />'+"\n";
				embedCode 		+="\t"+'<param name="flashvars" value="url_xml=http://'+domain_name+''+url_xml+'&is_cue_point=false" />'+"\n";
				embedCode 		+="\t"+'<embed '+"\n";
				embedCode 		+="\t\t"+'src="http://'+domain_name+''+SRC+'" '+"\n";
				//embedCode 		+="\t\t"+'flashvars="url_xml='+url_xml+'" '+"\n";
				embedCode 		+="\t\t"+'flashvars="url_xml=http://'+domain_name+''+url_xml+'&is_cue_point=false" '+"\n";
				embedCode 		+="\t\t"+'id="contentVideo"';
				embedCode 		+='type="application/x-shockwave-flash" '+"\n";
				embedCode 		+="\t\t"+'allowfullscreen="true" ';
				embedCode 		+='allowscriptaccess="always" '+"\n";
				//embedCode 		+="\t\t"+'menu="false" ';
				//embedCode 		+='wmode="transparent" '+"\n";
				embedCode 		+="\t\t"+'height="'+H+'" ';
				embedCode 		+='width="'+W+'">'+"\n";
				embedCode 		+="\t"+'</embed>'+"\n";
				embedCode 		+='</object>'+"\n";
				embedCode 		+='<p>'+"\n";
				embedCode 		+="\t"+'<a href="http://'+domain_name+''+url+'">'+"\n";
				embedCode 		+="\t\t"+title+"\n";
				embedCode 		+="\t"+'</a>'+"\n";
				embedCode 		+="\t"+'<br />'+"\n";
				embedCode 		+="\t"+'<a href="http://'+domain_name+'/secrets-de-coiffure-en-video.html">'+"\n";
				embedCode 		+="\t\t"+'Cliquez pour voir plus de Secrets de coiffures en vidéo sur '+domain_name+''+"\n";
				embedCode 		+="\t"+'</a>'+"\n";
				embedCode 		+='</p>'+"\n";
				embedCode		= '<form id="embedCodeForm" name="embedCodeForm" action="#"><textarea readonly="readonly">'+embedCode+'</textarea></form>';
				jQuery('#content #popup_content_blogger').empty();
				jQuery('#content #popup_content_blogger').append(embedCode);
			},
			/**
			 * build blogger set
			 * @method
			 */
			blogger: function(title,url){
				socialActions.embedContent(title,url);
				jQuery('#popin_content').bind("click", function(event){
					var copytext = jQuery('#popin_content textarea').text();
					jQuery('#popin_content textarea').select();
					//window.clipboardData.setData('Text', copytext); 
				});
			},
			/**
			 * build mail set
			 * @method
			 */
			mail: function(title,url){
				title = 'popEnvoyer';
				window.open(url,title,"top=0,left=0,width="+screen.width+", height="+screen.height+",scrollbars=yes,status=yes,toolbar=yes,resizable=yes,menubar=yes,location=yes");
				return false;
			},
			/**
			 * build fbShare set
			 * @method
			 */
			fbShare: function(title,url){
				window.open('http://www.facebook.com/sharer.php?u=' +encodeURIComponent(url)+'&t='+ encodeURIComponent(title),'sharer','toolbar=0,status=0,width=626,height=436'); 
				return false;
			},	
			/**
			 * default obj
			 * @method
			 */
			setDefault: function(){	
			}		
		}	
		// set manageContent
		switch (actionName) {
				case 'print':
					socialActions.print(title,url);
					break;
				case 'download':
					socialActions.download(title,url);
				break;
				case 'blogger':
					socialActions.blogger(title,url);
				break;
				case 'mail':
					socialActions.mail(title,url);
				break;
				case 'FB_share':
					socialActions.fbShare(title,url);
				break;
				 
				default:
				break;				
		}
	},
	
	/**
	 * Building ContentArea sets
	 * @method
	 * @param {Object}	oElm		jQuery object 
	 * @param {String}	link		link = html page content to load 
	 */
	buildContentArea: function(oElm, link){
		/**
		 * @classDescription Content set manipulation class
		 */
		var ContentArea = {
			/**
			 * manage Content set
			 * @method
			 */
			manageContent: function(){
				jQuery("#linkers li a").bind("click", function(event){
					//prevents default behaviour
					event.preventDefault();					
					var link = jQuery(this).attr("href");
					ContentArea.buildContent("#contentArea", link, 0);
				});	
			},
			/**
			 * build Content set
			 * @method
			 */
			buildContent: function(oElm, link, state){
				if (state==1) {
					jQuery('#datas').fadeTo(150, 0, function(){
						jQuery(this).load(link + " " + oElm, function(){
							ContentArea.manageContent();
							var currentClass = jQuery(oElm).attr("class");
							jQuery("#global_content").addClass(currentClass);							
							jQuery(oElm).removeClass(currentClass);
						})
					}).fadeTo(1000, 1).fadeTo("slow", 1);	
				} else {
					jQuery('#datas_tmp').load(link + " " + "#description > div", function(){});						
					jQuery('#description').fadeTo(150, 0, function(){
						jQuery('#contentArea #description').html(jQuery('#datas_tmp').html());
					}).fadeTo(1000, 1).fadeTo("slow", 1);		
					jQuery('#datas_tmp').empty();
				}		
				jQuery('#datas_tmp').empty();
				jQuery().ajaxSend(function(r,s){
					jQuery("#contentLoading").show();
				});
				jQuery().ajaxStop(function(r,s){
					jQuery("#contentLoading").fadeOut("fast");
				});
				ContentArea.updateTitle(link);				
			},
			/**
			 * update title set
			 * @method
			 */
			updateTitle: function(link){
				/* create a temporary div#title */
				jQuery('body').append('<div id="title"></div>');
				
				/* load TITLE content html value from new content page */
				jQuery('#title').load(link + ' ' + 'title', function(){
					/* update current TITLE content html value from new content page */
					var newtitle 	= jQuery('#title title').html();
					window.name	= newtitle;
					jQuery('meta[name=title]').attr('content',newtitle);				
					/* remove new temporary div#title */
					ContentArea.clean('#title');		
				});				
			},	
			/**
			 * Cleans obj set
			 * @method
			 */
			clean: function(obj){
				jQuery(obj).remove();
			},	
			/**
			 * default obj
			 * @method
			 */
			setDefault: function(oElm, link){	
				if (jQuery(oElm).length) {
					// cleaning previous set
					ContentArea.clean("#contentArea");
					// appending new content set from ajax request
					ContentArea.buildContent(oElm, link, 1);
				}
			}		
		}
		// set manageContent
		ContentArea.manageContent();
		if (jQuery(oElm).length) {
			// cleaning previous set
			ContentArea.clean(obj);
			// appending new content set from ajax request
			ContentArea.buildContent(oElm, link, 1);
		} else {
			// appending new images set from ajax request
			ContentArea.buildContent(oElm, link, 1);
		}		
	},
	/**
	 * Method for setting Slide for form
	 * @method
	 * @param {Number}	speed		Speed value (a milliseconds value)
	 * @param {bool}	rotate		true or false
	 */
	initSlide: function(speed, rotate,opacite){
		// get each item width
		var item_width = jQuery('#slider .slide').outerWidth(); 
		
		// set left_value
		var left_value = item_width * (-1);
		
		// set slider_content width = item_width * number of item
		var slider_content_width = jQuery('#slider .slide').size()*item_width;
		jQuery('#slider ul#slider_content').css({'width': slider_content_width});		
			
		var Manage = {
			buildSlider: function(){
				//grab the width and calculate left value
				//move the last item before first item, just in case user click prev button
				jQuery('#slider .slide:first').before(jQuery('#slider .slide:last'));
				//set the default item to the correct position 
				jQuery('#slider ul#slider_content').css({'left' : left_value});
				Manage.actionBtn();
			},			
			actionBtn: function(){
				//if user clicked on prev button
				jQuery('.prev').click(function() {			
					//get the right position            
					var left_indent = parseInt(jQuery('#slider ul').css('left')) + item_width;			
					//slide the item       
					if (opacite == true) {
						jQuery('#slider ul#slider_content:not(:animated)').animate({
							'left': left_indent,
							"opacity": 0.3
						}, speed, function(){
							//move the last item and put it as first item            	
							jQuery('#slider .slide:first').before(jQuery('#slider .slide:last'));
							//set the default item to correct position
							jQuery('#slider ul#slider_content').css({
								'left': left_value
							});
							jQuery(this).animate({
								"opacity": 1
							}, speed);
						});
					}else{
						jQuery('#slider ul#slider_content:not(:animated)').animate({
							'left': left_indent
						}, speed,function(){
							//move the last item and put it as first item            	
							jQuery('#slider .slide:first').before(jQuery('#slider .slide:last'));
							//set the default item to correct position
							jQuery('#slider ul#slider_content').css({
								'left': left_value
							});
						});						
					}
					//cancel the link behavior            
					return false;			            
				});			
			 
			    //if user clicked on next button
				jQuery('.next').click(function() {					
					//get the right position
					var left_indent = parseInt(jQuery('#slider ul#slider_content').css('left')) - item_width;					
					//slide the item
					if (opacite == true) {
						jQuery('#slider ul#slider_content:not(:animated)').animate({
							'left': left_indent,
							"opacity": 0.3
						}, speed, function(){
							//move the first item and put it as last item
							jQuery('#slider .slide:last').after(jQuery('#slider .slide:first'));
							//set the default item to correct position
							jQuery('#slider ul#slider_content').css({
								'left': left_value
							});
							jQuery(this).animate({
								"opacity": 1
							}, speed);
						});
					}
					else {
						jQuery('#slider ul#slider_content:not(:animated)').animate({
							'left': left_indent
						}, speed, function(){
							//move the first item and put it as last item
							jQuery('#slider .slide:last').after(jQuery('#slider .slide:first'));
							//set the default item to correct position
							jQuery('#slider ul#slider_content').css({
								'left': left_value
							});
						});
					}
					//cancel the link behavior
					return false;					
				}); 
			},
			rotateSlides: function(obj){
				//a simple function to click next link
				//a timer will call this function, and the rotation will begin :)  		
				jQuery(obj).click();//'.next'	
				//if mouse hover, pause the auto rotation, otherwise rotate it
				jQuery('#slider').hover(			
					function() {clearInterval(run);}, 
					function() {run = setInterval(function(){Manage.rotateSlides(obj);}, speed);}
				);
			}
		}
		Manage.buildSlider();
		if(rotate == true){
			//rotation speed and timer
			var run = setInterval(function(){Manage.rotateSlides('.next');}, speed);
		}           
	},
	/**
	 * Method for setting FormDiag
	 * @method
	 * @param {Object}	obj			jQuery collection of DOM elements
	 */
	FormDiag: function(){
		var Manage = {
			Init: function(){
				var t = jQuery('.form .question');
				
				// fade Out content on result form submit
				jQuery('.form .question .result').bind('click', function(){jQuery('#slider').fadeOut('fast');});
				
				/* on force le click pour que le input radio se coche */
				t.each(function(){
					var v = jQuery(this);
					v.find('.next').hide(); /* on cache temporairement les boutons pr&eacute;c&eacute;dents le temsp de trouver */
					v.find('.prev').hide();
					
					v.find('.next').bind("click", function(event){
						t.find('.active').each(function(){
							jQuery(this).addClass('selected');
						});
					});
					v.find('.prev').bind("click", function(event){
						t.find('.selected').each(function(){
							Dessange.Rollover(jQuery(this));
						});
					});
				});
				t.each(function(){
					var v = jQuery(this);
					v.find('input.radio,label').bind("click", function(event){
						v.find('.next, .result').show();
					});
				});
				t.each(function(){
					var v = jQuery(this);
					v.find('label img').bind("click", function(event){
						jQuery(this).parent('label').next('input.radio').click();
						jQuery(this).parent('label').next('input.radio').attr('checked', 'checked');
						jQuery(this).parent('label').next('input.radio').addClass('radio_checked');
						jQuery(this).parent('label').next('input.radio').addClass('radio_checked');
					});
				});
				jQuery('.form .answers').each(function(){
					var v = jQuery(this);
					v.find('label').bind("click", function(event){
						v.find("input[type=radio],input.radio").removeClass("radio_checked");
						jQuery(this).next("input[type=radio],input.radio").addClass("radio_checked");
					});
				});
				jQuery("form").bind("submit", function(){
					var ok = {};
					jQuery("form input.radio_checked").each(function(){ // pour chaque "element"
						ok[$(this).attr('name')] = $(this).val();
					});
					jQuery("form input").remove();
					var url = "/votre-diagnostic-cheveu-resultat.aspx?";
					$.each(ok, function(i, val){
						url += ("&" + i + "=" + val);
					});
					document.location = url;
					return false;
				});
				var t = jQuery('#diag_form');
				t.find('#label_step_02_answer_01,#label_step_02_answer_03').bind("click", function(event){
					t.find('#step_03_answer_05,#label_step_03_answer_05').css({
						'visibility': 'hidden'
					});
				});
				t.find('#label_step_02_answer_02').bind("click", function(event){
					t.find('#step_03_answer_05,#label_step_03_answer_05').css({
						'visibility': 'visible'
					});
				});
			}
		}
		Manage.Init();
	},	
	FormSkin: function(obj){
		var Manage = {
			Init: function(){
				var t = jQuery(obj);
				
				/* FORM COMPONENT SKIN JQUERY */
				t.addClass("skinned");
				
				jQuery("form.skinned input[type=checkbox],form.skinned input.checkbox").each(function(i){
					jQuery(this).before('<span class="checkbox" id="checkbox_'+jQuery(this).attr('id')+'"></span>');
				});	
				/* gestion cochage/decochage checkbox formulaire inscription */
				jQuery("form.skinned input[type=checkbox],form.skinned .checkbox,form.skinned .label_checkbox").each(function(i){
					if(jQuery(this).is(':checked')){
						/* input[type=checkbox:checked] */
						jQuery(this).addClass("checkbox_checked");
						jQuery(this).parent().children("span.checkbox").addClass("checkbox_checked");
					}
					jQuery(this).bind("click", function(e){						
						if(!jQuery(this).is(':checked')){
							/* span.checkbox */
							jQuery(this).removeClass("checkbox_checked");
							jQuery(this).parent().children("span.checkbox").removeClass("checkbox_checked");
						}else{
							/* input[type=checkbox] */
							jQuery(this).addClass("checkbox_checked");
							jQuery(this).parent().children("span.checkbox").addClass("checkbox_checked");
						}
						if(!jQuery(this).next("input[type=checkbox],input.checkbox").is(':checked')){
							/* span.checkbox */							
							jQuery(this).addClass("checkbox_checked");
							jQuery(this).next("input[type=checkbox],input.checkbox").attr("checked","checked");
						}else{
							/* input[type=checkbox] */
							jQuery(this).removeClass("checkbox_checked");
							jQuery(this).next("input[type=checkbox],input.checkbox").removeAttr("checked","checked");
						}
						/* label.label_checkbox */
						if(jQuery(this).hasClass('label_checkbox') && !jQuery(this).parent().children("input[type=checkbox],input.checkbox").is(':checked')){
							jQuery(this).addClass("checkbox_checked");
							jQuery(this).parent().children("span.checkbox").addClass("checkbox_checked");							
							jQuery(this).parent().children("input[type=checkbox],input.checkbox").addClass("checkbox_checked").attr("checked","checked");
						}else if(jQuery(this).hasClass('label_checkbox')){
							jQuery(this).removeClass("checkbox_checked");
							jQuery(this).parent().children("span.checkbox").removeClass("checkbox_checked");	
							jQuery(this).parent().children("input[type=checkbox],input.checkbox").removeClass("checkbox_checked").removeAttr("checked","checked");
						}	
						/* /label.label_checkbox */			
					});	
					jQuery(this).hover(function(){
						jQuery(this).addClass("checkbox_hover");
						jQuery(this).parent().children("span.checkbox").addClass("checkbox_hover");						
						jQuery(this).parent().children("input[type=checkbox],input.checkbox").addClass("checkbox_hover");						
					},function(){
						jQuery(this).removeClass("checkbox_hover");
						jQuery(this).parent().children("span.checkbox").removeClass("checkbox_hover");
						jQuery(this).parent().children("input[type=checkbox],input.checkbox").removeClass("checkbox_hover");
					});						
				});	
				/*/gestion cochage/decochage checkbox formulaire inscription */
				
				/* gestion cochage/decochage boutons radios formulaire inscription */
				jQuery("form.skinned input[type=radio],form.skinned input.radio").each(function(i){
					jQuery(this).before('<span class="radio" id="radio_'+jQuery(this).attr('id')+'"></span>');
				});	
				
				jQuery("form.skinned input[type=radio],form.skinned .radio").each(function(i){
					if(jQuery(this).is(':checked')){
						/* input[type=radio:checked] */
						jQuery(this).addClass("radio_checked");
						jQuery(this).prev("span.radio").addClass("radio_checked");
					}
					jQuery(this).bind("click", function(e){
						jQuery("form.skinned input[type=radio],form.skinned .radio").removeClass("radio_checked");
						if(!jQuery(this).is(':checked')){
							jQuery(this).removeClass("radio_checked");
							jQuery(this).prev("span.radio").removeClass("radio_checked");
						}else{
							jQuery(this).addClass("radio_checked");
							jQuery(this).prev("span.radio").addClass("radio_checked");
						}
						if(!jQuery(this).next("input[type=radio],input.radio").is(':checked')){
							jQuery(this).addClass("radio_checked");
							jQuery(this).next("input[type=radio],input.radio").attr("checked","checked");
						}else{
							jQuery(this).removeClass("radio_checked");
							jQuery(this).next("input[type=radio],input.radio").removeAttr("checked","checked");
						}					
					});	
					jQuery(this).hover(function(){
						jQuery(this).addClass("radio_hover");
						jQuery(this).prev("span.radio").addClass("radio_hover");
						jQuery(this).next("input[type=radio],input.radio").addClass("radio_hover");
					},function(){
						jQuery(this).removeClass("radio_hover");
						jQuery(this).prev("span.radio").removeClass("radio_hover");
						jQuery(this).next("input[type=radio],input.radio").removeClass("radio_hover");
					});						
				});	
				/*/gestion cochage/decochage boutons radios formulaire inscription */
			}
		}
		Manage.Init();
	},
	autoComplete: function(obj){
		var Manage = {
			Init: function(){
				jQuery.ajax({ // Requete ajax
					type: "GET",
					url: "/xml/search_url.xml",
					dataType: "xml",// donn&eacute;es envoy&eacute;es
					success: function(xml){ // Lorsque le PHP a renvoy&eacute; une r&eacute;ponse
						var elementsArray = new Array();
						var title = '';
						var link = '';
						jQuery(xml).find('entry').each(function(){ // pour chaque "element"
							title 		= jQuery(this).find('title').text();
							subtitle 	= jQuery(this).find('subtitle').text();
							link 		= jQuery(this).find('url').text();
							elementsArray.push({text:title, url:link}); // ajout dans le tableau
							elementsArray.push({text:subtitle, url:link}); // ajout dans le tableau
						});
						
						jQuery(obj).autocomplete(
							elementsArray,
							{
								max:100,
								delay:10,
								minChars:3,
								matchSubset:1,
								scrollHeight:260,
								matchContains:true,
								formatItem: function(item) {
									return item.text;
								}
							}
						)
						.result(function(event, item) {
							jQuery("#searchBox #btn_ok").bind("click", function(event){
								event.preventDefault();										
								location.href = item.url;					
							});	
						}); 
						// activation de l'autocompletion
					}
				});
				jQuery(obj).val('Saisir un nom');
				jQuery(obj).bind("click", function(event){
					jQuery(this).val('');
				});
				jQuery(obj).blur(function() {
					if(jQuery(this).val() == '')
						jQuery(this).val('Saisir un nom');
				});				
			}		
		}
		Manage.Init();		
	},
	/**
	 * Inits scroll bar theming
	 * @method
	 */
	toggleScroll: function(scrollCase,obj){
		var oElm = ".jscrollpane";
		var oElmH = ".scrollpaneH";
		if(obj){
			oElm = obj;
			oElmH = obj;
		}			
		switch (scrollCase) {
				case 0:
				case "vertical":
				default:
				jQuery(oElm).jScrollPane({
					showArrows:true, 
					arrowSize:14,
				  	scrollbarOnLeft:true,
				  	dragMinHeight:40,
					dragMaxHeight:40,
					scrollbarWidth:14
				});
				break;
				case 1:
				case "horizontal":
				jQuery(oElmH).jScrollHorizontalPane({
					showArrows:true, 
					arrowSize:14,
				  	scrollbarHeight:9, 
					scrollbarMargin:0
				});
				break;
		}
	}, 
	/**
	 * Method for setting Rollover/setHover/setActive State for img
	 * @method
	 * @param {Object}	obj			jQuery collection of DOM elements
	 */
	Rollover: function(obj,active){
		var Manage = {
			Init: function(obj){
				if(!obj){
					obj = 'img';
				}
				Manage.Hover(obj);
			},
			Hover: function(obj){
				if(!obj){
					obj = 'img';
				}
				jQuery(obj+".rollover:not(.active)").hover(// img.rollover
					function(){
						Manage.setHover(this);						
			        },
			        function(){ 
						Manage.setUnHover(this);
			        }
				);
				jQuery(obj+".active, "+ obj+".selected").hover(// img.rollover
					function(){
						Manage.setHover(this);						
			        },
			        function(){ 
						Manage.setHover(this);
			        }
				);
			},
			Activeformdiag: function(obj){
				jQuery(obj).each(function(){
					t = jQuery(this);
					t.bind("click", function(event){
						var classe = jQuery(t.parent('label')).parent('li').attr('class');
						jQuery('.'+classe).find('img').each(function(){
							if(jQuery(this).hasClass('active')){
								jQuery(this).removeClass("active");
								if(!jQuery(this).hasClass('selected')){
									Manage.setUnHover(jQuery(this));
								}
							}
						});
						jQuery(this).addClass("active");
						Manage.Hover();
					});
				});
			},
			Activeformjc: function(obj){
				jQuery(obj).each(function(){
					t = jQuery(this);
					t.bind("click", function(event){
						T=jQuery(t.parent().attr('class')+ obj);
						t.removeClass("active");
						jQuery(obj).removeClass("active");
						T.each(function(){
							if(!jQuery(this).hasClass('selected'))
								Manage.setUnHover(jQuery(this));
						});
						jQuery(this).addClass("active");
						Manage.Hover();
					});
				});
			},
			setHover: function(obj){
				t = jQuery(obj);
				var speed = 100;
				t.attr('src',t.attr('src').replace('_OFF','_ON'));
				t.addClass('hover'); // for ie6
			},
			setUnHover: function(obj){
				t = jQuery(obj);
				t.attr('src',t.attr('src').replace('_ON','_OFF'));		
				t.removeClass('hover');	 // for ie6			
			}
		}
		Manage.Init(obj);
		if (active == 'formjc') {
			Manage.Activeformjc(obj);
		}
		if (active == 'formdiag') {
			Manage.Activeformdiag(obj);
		}			
	}, 
	/**
	 * Method for popi,
	 * @method
	 * @param {Object}	obj			jQuery collection of DOM elements
	 */
	popin: function(obj){
		var Manage = {
			Init: function(){
				jQuery('body').prepend('<div id="popin"><div id="popin_content"></div><div id="close_popin"><a href="#" class="popin" title="Fermer"><img src="/img/content/close_popin.png" width="30" height="30" border="0" alt="Fermer" /></a></div></div>');
				jQuery('body').prepend('<div id="overlay"></div>');
				jQuery('#overlay').css('opacity','0.5');
			},
			setMarginToCenter: function (obj){
				var marginTop = (jQuery(obj).height() / 2 );
				var marginLeft = (jQuery(obj).width() / 2 );
				jQuery(obj).css("margin", "-"+marginTop+"px 0 0 -"+marginLeft+"px");
			},
			toPopin: function (obj){
				jQuery('#popin #popin_content').empty();
				jQuery('#popin #popin_content').prepend(jQuery(obj).html());				
				jQuery('#popin').width(jQuery(obj).width());
				jQuery('#popin').height(jQuery(obj).height());	
				Manage.setMarginToCenter('#popin');
			},
			Action: function(obj){
				jQuery('a.popin').bind("click", function(event){
					var popin = jQuery(this).attr('class').replace("popin ", "");
					event.preventDefault();					
					Manage.toPopin('#'+popin);
					if (jQuery("#popin").is(":hidden")) {
						jQuery('#overlay').show("fast",function(){jQuery("#popin").show("slow");}); 
					} else {
						jQuery("#popin").hide("fast",function(){jQuery('#overlay').hide("slow");jQuery('#popin #popin_content').empty();});						
					}				
				});
				jQuery('#overlay').bind("click", function(event){
					jQuery("#popin").hide("fast",function(){jQuery('#overlay').hide("slow");jQuery('#popin #popin_content').empty();});					 
				});
				jQuery(document).keydown( function( e ) {
					if( e.which == 27) {  // escape, close box				
						jQuery("#popin").hide("fast",function(){jQuery('#overlay').hide("slow");jQuery('#popin #popin_content').empty();});						 		
					}
				}); 
			}
		}
		Manage.Init();
		Manage.Action(obj);
	},
	/**
	 * Method to show content conseil secret,
	 * @method
	 * @param {Object}	obj			jQuery collection of DOM elements
	  * @param {myUrl}	char		url of element ID to show	 
	 */
	secretsConseil: function(){
		var contentConseil = {
			/**
			 * manage Content set
			 * @method
			 */
			manageContent: function(){
				jQuery('.secret').hide();
					
					jQuery('#secrets_list a, li.current ul.sub_nav li a').bind("click", function(event){
						//prevents default behaviour
						event.preventDefault();					
						
						var myUrl 	= jQuery(this).attr('href');
						
						// toogle content and current button
						/*
						 jQuery('#secrets_list a, li.current ul.sub_nav li a').each(function(){
							if (jQuery(this).hasClass('current')){
								jQuery(this).removeClass('current');
							}
							if (jQuery(this).attr('href') == myUrl) {
								jQuery(this).addClass('current');
							}							
						});		
						*/										
						var temp 	= myUrl.lastIndexOf("#");
						myUrl 		= myUrl.substr(temp+1);
						reg 		= new RegExp(".html", "g");
						myUrl  		= myUrl.replace(reg,'');						
						
						contentConseil.Action(jQuery(this),myUrl);
					});
			},
			Action: function(obj,myUrl){
				
				// toogle content and current button
				jQuery('#secrets_list a, li.current ul.sub_nav li a').each(function(){
					if (jQuery(this).hasClass('current')){
						jQuery(this).removeClass('current');
					}
					reg 		= new RegExp(myUrl, "g");
					if (jQuery(this).attr('href').search(reg) == -1){
					}
					//if (jQuery(this).attr('href') == myUrl) {
					else{
						jQuery(this).addClass('current');
					}							
				});
				
				// action for print button pdf files
				var urlPDF 		= '';
				var titlePDF 	= '';
				jQuery('.actionBtn .btn_print').bind("click", function(event){
					//prevents default behaviour
					event.preventDefault();			
					urlPDF 		= jQuery(this).attr('href');
					titlePDF 	= jQuery(this).attr('title');
					// assign social function to btn print
					reg 			= new RegExp("-", "g");
					titlePDF  	= myUrl.replace(reg,'_');
					Dessange.socialFunctions('print', urlPDF, titlePDF);
					return false;	
				});	 
				
				// action for send to friend
				var urlMail 		= '';
				var titleMail 	= '';
				jQuery('.actionBtn .btn_mail').bind("click", function(event){
					//prevents default behaviour
					event.preventDefault();			
					urlMail 		= jQuery(this).attr('href');
					titleMail 	= jQuery(this).attr('title');
					Dessange.socialFunctions('mail', urlMail, titleMail);
					return false;	
				});	 
				
				// toogle content and current button
				jQuery('#secret_content div.current').each(function(){ // pour chaque "element"
					jQuery(this).removeClass('current');
				});
				jQuery('.secret').fadeOut('fast');
				jQuery('#'+myUrl).slideUp('fast',function(){
					jQuery(this).fadeIn('fast');
					jQuery(this).addClass('current');
				});
			}
		}
		contentConseil.manageContent();
		// start by default to load the first conseil
		var myUrl 		= document.location.href;
		var temp 		= myUrl.lastIndexOf("/");
		myUrl 			= myUrl.substr(temp+1);
		reg 			= new RegExp(".html", "g");
		myUrl  			= myUrl.replace(reg,'');
		reg 			= new RegExp("#", "g");
		
		if (myUrl.search(reg) == -1){
			contentConseil.Action(jQuery('#'+defaultConseil),defaultConseil);
		}else{
			temp 			= myUrl.lastIndexOf("#");
			myUrl 			= myUrl.substr(temp+1);
			contentConseil.Action(jQuery(this),myUrl);
		}
	}						
}

/* launching scripts */
jQuery(document).ready(function(){
	Dessange.init();
	Dessange.Rollover();
});

