// Load scripts/ 



















$(function(){





if(document.location.toString().indexOf('formulaires/') != -1){
	//votre-caisse/
	//console.log($('a', '#leftside .block'));
		//$('a','#leftside .block').eq(5).addClass('active');
		$('a','#leftside .block').eq(11).addClass('active');
		$('#sublinks').show();
}






$('a').each(function(i, e){



	if($(e).attr('href') && $(e).attr('href').indexOf('desjardins.com') != -1){



		$(e).css({'color':'#00A665'});



	}



});







if( document.location.toString().indexOf('general') != -1 ||  document.location.toString().indexOf('pompiers') != -1 ||  document.location.toString().indexOf('cols-bleus') != -1){



	$('a:first','#leftside').not('.avantages').addClass('active');



}











if( document.location.toString().indexOf('pompiers') != -1){



	$('.fdc').addClass('colred');



}











if( document.location.toString().indexOf('votre-caisse') != -1 || document.location.toString().indexOf('votre-caisse-new') != -1){



	$('#sublinks').show();



}







if( document.location.toString().indexOf('nous-joindre') != -1 ||  document.location.toString().indexOf('nous-joindre-new') != -1){



	$('#sublinks2').show();



}


if( document.location.toString().indexOf('etudiants') != -1){



	$('#sublinks10').show();



}










if( document.location.toString().indexOf('produits-services') != -1 ||  document.location.toString().indexOf('produits-services-2') != -1){



	$('#sublinks3').show();



}











if(document.location.toString().indexOf('mission-de-la-caisse')){



if($('html').attr('id')=='b'){$('.jqsectionname').html('COLS-BLEUS');}else



if($('html').attr('id')=='g'){$('.jqsectionname').html('');}







}



/*******/



if($('.votre-caisse-nos-groupes').length){



	if($('html').attr('id')=='b'){



		var ul = $('ul', '.ovr_right_group');



		var li = $(ul).find('li').eq(8);



		console.log(li);



		$(ul).prepend(li);



		//$(li).remove();



	}



}



/*******/



if($('.votre-caisse-gratuite-des-transactions').length){



	if($('html').attr('id')=='b'){



		$('h3', '#mcmiddle').html('unique au Centre de services financiers des cols bleus');



	}else if($('html').attr('id')=='g'){



		$('h3', '#mcmiddle').html('unique à la Caisse Desjardins du Réseau municipal');



	}else{



		$('h3', '#mcmiddle').html('unique au Centre de services financiers des pompiers');



	}



}



/*******/



if($('.votre-caisse-mission-de-la-caisse').length){



	if($('html').attr('id')=='b'){



		$('h1', '#mcmiddle').html('Mission du Centre de services financiers des cols bleus').css({'padding-left':'7px'});



		$('h2', '#mcmiddle').html('Au service cols-bleus pour enrichir les cols-bleus, individuellement et collectivement!');



	}else if($('html').attr('id')=='g'){



		$('h1', '#mcmiddle').html('Mission de la Caisse Desjardins du Réseau municipal');



		$('h2', '#mcmiddle').html('Au service des employés municipaux pour enrichir les employés municipaux, individuellement et collectivement!');



	}else{



		$('h1', '#mcmiddle').html('Mission du Centre de services financiers des pompiers').css({'padding-left':'11px'});



		$('h2', '#mcmiddle').html('Au service des pompiers pour enrichir les pompiers, individuellement et collectivement!');



	}



}



/*******/



if(document.location.toString().indexOf('page-employes') == -1 && document.location.toString().indexOf('conseil-administration') == -1){

$('.block a','#leftside').not('.avantages').each(function(){



	var url = document.location.toString().replace('http://www.desjardinsmunicipal.com/','').replace(/^\/(.*)/ig, "$1").replace(/(.*?)\/$/ig, "$1").split('/');



	

	if($($(this).parents()[0]).attr('id').indexOf('sublinks') == -1){



		if($(this).attr('href').indexOf(url[0]) != -1){



			//console.log( url[0] );



			$(this).addClass('active');



		}



	}else{

		



		if(



		   document.location.toString().replace('http://www.desjardinsmunicipal.com/','').replace(/^\/(.*)/ig, "$1").replace(/(.*?)\/$/ig, "$1") ==



			$(this).attr('href').replace(/^\/(.*)/ig, "$1").replace(/(.*?)\/$/ig, "$1")){



				$(this).addClass('active');



			}



	}







});



}










$('a', '#header').click(function(e){







	if($(e.target).index() == 0){



		//$('#dyncss').attr({'href':'/css/rouge.css'});



		$.cookie("p", "r", { domain:'.desjardinsmunicipal.com', path: '/', expires: 365 }); 



	}



	if($(e.target).index() == 1){



		//$('#dyncss').attr({'href':'/css/bleu.css'});



		$.cookie("p", "b", { domain:'.desjardinsmunicipal.com', path: '/', expires: 365 }); 



	}



	if($(e.target).index() == 2 || $(e.target).index() == 3){



		//$('#dyncss').attr({'href':'/css/blanc.css'});



		$.cookie("p", "g", { domain:'.desjardinsmunicipal.com', path: '/', expires: 365 }); //=>g == generique / blanc



	}



});











//font work



$.getScript('/js/font.js', function() {		



	Cufon.replace('.font', { fontFamily: 'OptimBold'});		



});	







//png fix



if($.browser.msie && parseInt($.browser.version,10)>=6){



	$.getScript('/js/jquery.pngFix.js', function() {



		$(document).pngFix();



	});







}







//-- ________________________________________________________________________________________











	//mcleft = $('#maincontainer').aPosition().left; 



	$('#loader').fadeOut(1500, function(){});



	



	if(!$.browser.msie){



		$('#maincontainer').fadeIn(250,function(){



			mcleft = $('#maincontainer').aPosition().left; 



			resizefooter();



			$('#footer').fadeIn();



			$('#shadowmid').fadeIn();



		});



	}else{



		$('#maincontainer').show();



			resizefooter();



			$('#footer').show();



			$('#shadowmid').show();



	}



	







//LOAD ROTATION SCRIPT/



$.getScript('/js/jquery.cycle.all.min.js', function() {



	$('#rotation').after('<'+'div id="nav">').cycle({ 



		fx:     'fade', 



		speed:  'fast', 



		timeout: 3000, 



		pager:  '#nav' 



	});



});



















$('#minusfooter').equalHeights();



















//$('#ca_leftside_block01 > a').css({'background':'none','background-image':'none', 'background-position':'-5000px -5000px'});























});







//RESIZE footer/



//-- ____________________________________________________________________________________-- //



var mcleft = 140;



var isResizing = false;



$(window).resize(function(){ 



	if($.browser.msie && parseInt($.browser.version,10)>=6){return;}



	if(!isResizing){



		



		mcleft = $('#maincontainer').aPosition().left;



		$('#loader').fadeIn(100, function(){});



		$('#maincontainer').hide();



		$('#footer').hide();



		$('#shadowmid').hide();



		resizefooter();



		$('#loader').fadeOut(1500, function(){});



		



		



		if($.browser.msie){



			$('#maincontainer').show();



			mcleft = $('#maincontainer').aPosition().left;			



			$('#footer').show();



			$('#shadowmid').show();



		}else{



			$('#maincontainer').fadeIn('fast',function(){



				mcleft = $('#maincontainer').aPosition().left;			



				$('#footer').fadeIn();



				$('#shadowmid').fadeIn();



			});



		}



	}



});







function resizefooter(){



	if(!isResizing){



		isResizing=true;



		$('#left', '#footer').css({'width':mcleft+220});



		$('#right', '#footer').css({'width':$(window).width()-220, 'left':mcleft+240});



		isResizing = false;



		



	}



}



// END RESIZE footer/



//-- ________________________________________________________________________________________























jQuery.fn.aPosition = function() {



	try{



		thisLeft = this.offset().left;



		thisTop = this.offset().top;



		thisParent = this.parent();



		parentLeft = thisParent.offset().left;



		parentTop = thisParent.offset().top;



		return {



			left: thisLeft-parentLeft,



			top: thisTop-parentTop



		}



	}catch(er){



		return $('#maincontainer').position().left; 



	}



}







//-- ________________________________________________________________________________________



$.fn.equalHeights = function(px) {



	$(this).each(function(){



		//



		var currentTallest = 0;



		if(document.location.toString().indexOf('/home') != -1 ||



			document.location.toString().indexOf('/general-new') != -1 ||



			document.location.toString().indexOf('/pompiers-new') != -1 ||



			document.location.toString().indexOf('/cols-bleus-new') != -1



			



		){currentTallest = 0;}



		$(this).children().each(function(i){



			if($(this).attr('id') != 'mcmiddle' && $(this).attr('id') != 'leftside'){return;}



			if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }



		});



		//if (!px || !Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm(); //use ems unless px is specified



		// for ie6, set height since min-height isn't supported



		if ($.browser.msie && $.browser.version == 6.0) { $(this).children('#mcmiddle, #leftside').css({'height': currentTallest}); }



		$(this).children('#mcmiddle, #leftside').css({'min-height': currentTallest}); 



		



	});



	return this;



};



//-- ________________________________________________________________________________________




