jQuery(document).ready(function(){

/*----------------------- remove "onclick" for the poupup lighbox ------------------*/
	jQuery(".ixCTG_contact").removeAttr("onclick");
	jQuery(".viewTheme").removeAttr("onclick");	
	jQuery(".jcarousel-clip").addClass("jcarousel-clip").removeClass("Image1");
	jQuery(".ixCTG_VideoTemoignage").removeAttr("onclick");
	jQuery(".ixCTG_Videocongres").removeAttr("onclick");

/*----------------------- plan d'accès ------------------*/
	jQuery(".ixCTG_zoom_fr").removeAttr("href");
	jQuery(".ixCTG_zoom_fr").attr("href", "./iso_album/plan_acces_fr.png");
	jQuery(".ixCTG_zoom_ang").removeAttr("href");
	jQuery(".ixCTG_zoom_ang").attr("href", "./iso_album/plan_acces.png");
	//styles + scroll bar pour les form + popup
	jQuery(".formContainer").attr("id", "pane5");
	jQuery('#pane5').jScrollPane({showArrows:true});
    jQuery("input[type=radio]").attr("style", "width:50px; padding-left:0px;  padding-right:0px; height: 10px;");
	jQuery("textarea").attr("style", "background: url('./iso_icons/ixCTG_area.png') no-repeat scroll left bottom #FFFFFF; border: 0px; height: 30px; 	border: 0px; padding-left:10px; padding-bottom:10px;  padding-right:5px; padding-top:10px; width: 210px ");	
    jQuery("input[type=radio]").attr("class", function() {
			return (this.className ? ("styled " + this.className) : "styled");
	});
    jQuery("input[type=checkbox]").attr("class", "styled");
	jQuery("select").attr("class", "styled");
	//jQuery(".submit .bsButtonSpan .bsButton").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"); 
	jQuery("#brands").attr("style", "border:0px ");
	jQuery(".ixCTGNextLink").html("<img src='iso_icons/ixCTG_bouton_question_suivante.png'");
		
/*----------------------- Popup ----------------------*/	
	
	//formulaire "Nous Contacter"
	$(".ixCTG_contact").fancybox({
		'width'				: 640,
		'height'			: 420,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
	//FancyBox"
	$(".FancyBoxLink").fancybox({
		'width'				: 640,
		'height'			: 420,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});	
	
	//video temoignage"
	$(".ixCTG_VideoTemoignage").fancybox({
		'width'				: 640,
		'height'			: 420,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
		//video congre"
	$(".ixCTG_Videocongres").fancybox({
		'width'				: 640,
		'height'			: 420,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
    //Zoom france
	$(".ixCTG_zoom_fr").fancybox({
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'image'
	});
    // Zoom English
	$(".ixCTG_zoom_ang").fancybox({
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'image'
	});


   // Formulaire demo
	$(".ixCTG_demo").fancybox({
		'width'				: 650,
		'height'			: 430,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});	
	
	$(".ixCTG_condidat").fancybox({
		'width'				: 650,
		'height'			: 430,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});	
	
   // Formulaire cliente
	$(".ixCTG_cliente").fancybox({
		'width'				: 650,
		'height'			: 430,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});	
		
   // Formulaire de hotesse
	$(".ixCTG_hotesse").fancybox({
		'width'				: 650,
		'height'			: 430,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});	
	$(".ixCTG_devenirHotesse").fancybox({
		'width'				: 640,
		'height'			: 420,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});	
   // Formulaire journée démonstratrice
	$(".ixCTG_VideoJournee").fancybox({
		'width'				: 640,
		'height'			: 420,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
   // Formulaire journée démonstratrice
 
		$(".ixCTGFrend").fancybox({
			'width'				: 680,
			'height'			: 430,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe'
		});	
		
		
	//formulaire "viewTheme"
	$(".viewTheme").fancybox({
		'width'				: 791,
		'height'			: 528,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe',
		'refreshOnClose'	: true
	});	

	//shopping-list
		$(".ShoppingListLink").fancybox({
		'width'				: 770,
		'height'			: 535,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});	


/*----------------------- uniforme input ------------------*/
	Custom.init();	

/*----------------------- addFavoris ----------------------*/
	addFovoris();

/*----------------------- Timer Nos étapes clés ----------------------*/	
	$('.ixCTGCarrouselInsFullcontent').loopedSlider({
		container: ".ixCTGCarrouselInsContent", 
		slides: ".ixCTGCarrousel", 
		containerClick: false, 
		autoStart: 20000, 
		addPagination: true 
	});


/*----------------------- Timer image vidéo ----------------------*/	 
	img ="";
	jQuery("div.ixCTTimerImageContent a").each(function(i){
		 link = $(this).attr("href");
		 img +="<div><a href='"+link+"'>";
		 img += $(this).html();
		 img +="</a></div>";
		
	});	
	jQuery("div.ixCTTimerImageContent").html("");
	jQuery("div.ixCTTimerImageContent").append(img)	 
	$('div.ixCTTimerImage').loopedSlider({
		container: ".ixCTTimerImageFullContent", 
		slides: ".ixCTTimerImageContent", 
		containerClick: false, 
		autoStart: 5000, 
		addPagination: false 
	});
		
/*----------------------- fil défilant des news ----------------------*/	 		
	//fil défilant des news
	$("ul.ixCTGNewsList").liScroll();

/*----------------------- modif width des balises <p> dans les cadres (encart gauche et encart droit) ----------------------*/	 	
	//redem de contenu des cadres
 	$(".ixCTGZoom > .insFullcontent > .insContent > p ").attr("style", "width:auto");
	$(".ixCTGNosMarquesContent > p ").attr("style", "width:auto");
	$(".ixCTGNosProduits > .insFullcontent > .insContent > p ").attr("style", "width:auto");
	$(".ixCTGNosDevenezCliente > .insFullcontent > .insContent > p ").attr("style", "width:auto");
	$(".ixCTGNosDevenezHotesse > .insFullcontent > .insContent > p ").attr("style", "width:auto");
	$(".ixCTGNousContacter > .insFullcontent > .insContent > p ").attr("style", "width:auto");
	$(".ixCTGNousContacterEntContent  > .insContent > p ").attr("style", "width:auto");
	$(".ixCTGNosClienteHotesse > .insFullcontent > .insContent > p.bsImage ").attr("style", "width:auto");
	$(".ixCTGNosClienteHotesse > .insFullcontent > .insContent > p.bsImage ").attr("style", "width:auto");
	$(".ixCTGQuiz > .insFullcontent > .insContent > p ").attr("style", "width:auto");
	$(".ixCTGRecVideo > .insFullcontent > .insContent > p ").attr("style", "width:auto");
	$(".ixCTGLinkAllTem > .insFullcontent > .insContent > p ").attr("style", "width:auto");
	$(".ixCTGNewsLetter > .insFullcontent > .insContent > p ").attr("style", "width:auto");
	$(".ixCTGNewsLetter > .insFullcontent > .insContent > p ").attr("style", "width:auto");
	$(".ixCTGCollectionContent > p ").attr("style", "width:auto"); 

	
/*------------------- ID News dans la page "home" ----------------------*/
	jQuery(".ixCTGGreyButton li").each(function(i){
 		$(this).attr("id", 'news_'+ i);
	});
	 
/*----------------------- Nuage mots clés ----------------------*/	 
	$('.ixCTGkeyWordsContent > div').removeAttr("class");
	$('.ixCTGkeyWordsContent > div').attr("id", "cloud");
	$('div.cloud > ul').attr("class", "nav");
	var nbr= 0;
		jQuery("#cloud > .nav > li > span > a").each(function(i){
			$(this).attr("class","size"+i);
			$(this).attr("href","#");
		});	
	window.setTimeout(hovertipInit, 1);
 

  
/*----------------------- Ombre Thème ----------------------*/	
	var nbrListeLink ="";
	jQuery("div.theme").each(function(i){
	   nbrListeLink ++;
	});

	 if(nbrListeLink == 3 ) {
		jQuery("div.theme").attr("style", " background: url('./iso_icons/ixCTG_theme_3.png') no-repeat scroll left top transparent; margin-right: 3px;  width: 145px;");
		jQuery("span.newTheme").attr("style", "width: 104px; left: 11px;");
		jQuery("td.themeLabelTabs").attr("style", "width: 150px;");
	 }else if(nbrListeLink == 2 ) {
		jQuery("div.theme").attr("style", " background: url('./iso_icons/ixCTG_theme_2.png') no-repeat scroll left top transparent; width: 218px;");
		jQuery("span.newTheme").attr("style", "width: 180px;");
		jQuery("td.themeLabelTabs").attr("style", "width: 230px;");		
	 }	
 
 
/*----------------------------- QUIZ -------------------------*/
	jQuery(".checkbox").each(function(i){

		$(this).attr("id", 'choice_'+ i);
		$('#choice_'+ i).click(function() {
		
			if( $('#c'+i).attr("checked")) {
				$('#r'+i).attr("style", "display:block;");
			}else {
				$('#r'+i).attr("style", "display:none;")
			}
			jQuery('#pane2').jScrollPane({showArrows:true});		
		});
	});	


/*----------------------- scrollbar ------------------*/
	if(typeof(slidePosition) == "undefined") {
		  jQuery('#pane2').jScrollPane({showArrows:true});
	}
 
	jQuery("div.jScrollPaneDrag").attr("style", "top: 0px; width: 20px; height: 20px;");
	jQuery('#pane4').jScrollPane({showArrows:true});
 
	//spec pour les ongelets	
	if(	jQuery("div.jScrollPaneContainer ").width() == 600 ) {
		jQuery("div.jScrollPaneContainer ").width("630");
	}
		
/*-------------------- Onglet--------------------*/
	jQuery('.ixCTGDownload .bsDownloadableDL').css("padding-left", "");
	jQuery('.ixCTGTxtTabs .tabsTabContent').css("height", "auto");	
	jQuery('div.itlTabs').attr('id', 'itlTabsId');

if($("#itlTabsId").length) {
	jQuery('div.jScrollPaneContainer').width(635);
	jQuery('#pane2').jScrollPane({showArrows:true});
	$('.ixCTGTxtTabs li a').click(function() { 
		jQuery('#pane2').jScrollPane({showArrows:true});
	});
	$('.ixCTGTxtTabs li a').each(function() {	 
		jQuery('#pane2').jScrollPane({showArrows:true});
		$(this).click(function() {
			 return false;
		});			
	});
}	
/*----------------------------- FIdelite -------------------------*/

	$('.ixCTGFidelRecomp .ixCTGFidelParagraphe').each(function() {	 
		$(this).append("<img  src='./iso_icons/ixCTG_etoile.jpg' border='0' alt='CTG' style='' class='starImage'/>");		
	});
 
/*----------------------------- FAQ -------------------------*/
	jQuery(".ocsHelpDeskFaqQuestion img").each(function(){
		$(this).attr("style","display: none;");
	});
	jQuery(".question").each(function(k){
	var index = k +1;
		jQuery('#question'+index).click(function() {
			if(jQuery('#answer'+index).css("display") == "block") {
				jQuery('#question'+index).css("font-weight","bold");
				jQuery('#question'+index).css("color","#3e3537");
				jQuery('#answer'+index+' p').css("color","#3e3537");
			} else {
				jQuery('#question'+index).css("font-weight","normal");
				jQuery('#question'+index).css("color","#707172");
				jQuery('#answer'+index+' p').css("color","#707172");
			}
			if(window.location.href.indexOf("#") != -1)
				jQuery('#pane2').jScrollPane({showArrows:true, observeHash: false});
			else
				jQuery('#pane2').jScrollPane({showArrows:true});
		});
	});

 	
/*-------------------- wrap all des input--------------------*/
	/*$("div.yui-skin-sam").attr("class", '');
	$("div.localityField").attr("class", '');	
	$("div.yui-ac").attr("class", '');	*/
	jQuery("input[type=text]").each(function(i){
			var w = $(this).width()+10;
			if($(this).attr("id")=="birthDate") {
				w = 238;
		 }
		$(this).wrapAll('<div style="overflow:hidden;float:left;"><div class="inputTextWarpper"  style="width:'+w+'px"></div></div>');
		$(this).attr("class", '');
	});

 	jQuery("label").each(function(i){
		$(this).wrapAll('<div class="labelContainer" style="float: left;"></div>');
		$(this).attr("class", '');
	});
	
 
	jQuery("input[type=password]").each(function(i){
		var w = $(this).width()+10;
		$(this).wrapAll('<div style="overflow:hidden;float:left;"><div class="inputTextWarpper"  style="width:'+w+'px"></div>');
		$(this).attr("class", '');
	});
	
	

	jQuery("select").each(function(i){
		var h = $(this).width() - 35;
	   
		$(this).wrapAll('<div style="overflow:hidden;"><span class="selectFormWrapper" style="width:'+h+'px"><span class="selectForm" style="width:'+h+'px"></span></span></div>');
		
	});


	var middle  = 0;
	jQuery(".MiskPages > ul > li > a ").each(function(i){
		if((jQuery(".MiskPages > ul > li").height() - jQuery(this).height())  >=14) {
			middle = ((jQuery(".MiskPages > ul > li").height() - jQuery(this).height()) - 8 );
		$(this).attr("style", 'margin-top:'+middle+'px');
		}
	});
 
 
 
 
	//showing forms (CSS set on visibility:hidden to avoid having standard style then new style)
 	jQuery(".ixCTGContentFormContact").attr("style", "visibility:visible;");
 	jQuery(".ixCTGContentFormDemo").attr("style", "visibility:visible;");
	
/*-------------------- carousel--------------------*/
	jQuery('#viewport').carousel('#simplePrevious', '#simpleNext');
	jQuery('#viewportPopup').carousel('#simplePrevious', '#simpleNext'); 
 

});


var waitYUIButton = function() {
	var elem = YAHOO.util.Dom.getElementsByClassName("first-child", "span");
	if (elem == null)
	{
		YAHOO.lang.later(50,null,waitYUIButton);
	}
	else
	{
		if (typeof(elem[0]) == "undefined" || elem[0] == null)
		{
			YAHOO.lang.later(50,null,waitYUIButton);
		}
		else
		{
			jQuery('#pane2').jScrollPane({showArrows:true});
		}
	}
};

isoYUILoader.onReady( function() {
	YAHOO.util.Event.onContentReady("pane2", function() {
		if(YAHOO.util.Dom.getElementsByClassName("sdsButtonBar", "div") != "") waitYUIButton();
	});
});

jQuery('#pane2').jScrollPane({showArrows:true});

/*-------------------- function--------------------*/

//vider un champs
	function inputFocus(id) {
		var valIni = (jQuery("#"+id).attr("value"));
		jQuery("#"+id).click(function(){
		if(jQuery("#"+id).attr("value") == valIni)	{			
			jQuery("#"+id).attr("value", "") ;
		}
		});
		jQuery("#"+id).blur(function(){
		if(jQuery("#"+id).attr("value") == "")	{
			jQuery("#"+id).attr("value", valIni) ;			
		}
		});	
	}


	function displayReponseQuiz (rep) {
		$('#'+rep).attr("style", "display:none;")
	}
  
//add favoris
	function addFovoris() {
	  $("a.ixCTGFavoris").attr("href","javascript:void(0);");
	  $("a.ixCTGFavoris").attr("title","Ajouter aux favoris");
		// add a "rel" attrib if Opera 7+
		if(window.opera) {
			if ($("a.ixCTGFavoris").attr("rel") != ""){ // don't overwrite the rel attrib if already set
				$("a.ixCTGFavoris").attr("rel","sidebar");
			}
		} 
		
		$("a.ixCTGFavoris").click(function(event){
			event.preventDefault(); // prevent the anchor tag from sending the user off to the link

			var title = "Captain Tortue Group - " + document.title;
			var url = window.location.href 
		 if (window.sidebar)
	   { 
	   window.sidebar.addPanel(title, url,""); 
	   }
	   else if( document.all )
	   {
	   window.external.AddFavorite(url, title);
	   }
	   else
			{
	   return true;
	   }
		 
		});
	}


var checkboxHeight = "25";
var radioHeight = "25";
var selectWidth = "250";
document.write('<style type="text/css">input.styled { display: none; } select.styled { position: relative; width: ' + selectWidth + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5; } .disabled { opacity: 0.5; filter: alpha(opacity=50); }</style>');
