// JavaScript Document

jQuery(document).ready(function(){

	
//************* attribution d'un class="last" au dernier élément du breadcrumb ****************************/

	jQuery("#dnn_dnnBREADCRUMB_lblBreadCrumb a:last").addClass("last");

//*************Simple Accordion w/ CSS and jQuery*******************/

	jQuery('.acc_container').hide(); //Hide/close all containers
	//jQuery('.acc_trigger:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container
	
	//On Click
	jQuery('.acc_trigger').click(function(){
		if( jQuery(this).next().is(':hidden') ) { //If immediate next container is closed...
			jQuery('.acc_trigger').removeClass('active').next().slideUp(); //Remove all "active" state and slide up the immediate next container
			jQuery(this).toggleClass('active').next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
		}
		else {
			jQuery(this).removeClass('active').next().slideUp()
		}
		return false; //Prevent the browser jump to the link anchor
	});
	

//*************Simple Tabs w/ CSS & jQuery*******************/

	//When page loads...
	jQuery(".tab_content").hide(); //Hide all content
	jQuery("ul.tabs li:first").addClass("active").show(); //Activate first tab
	jQuery(".tab_content:first").show(); //Show first tab content

	//On Click Event
	jQuery("ul.tabs li").click(function() {

		jQuery("ul.tabs li").removeClass("active"); //Remove any "active" class
		jQuery(this).addClass("active"); //Add "active" class to selected tab
		jQuery(".tab_content").hide(); //Hide all tab content

		var activeTab = jQuery(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		jQuery(activeTab).show(); //show the active ID content
		return false;
	});

/************* Fancybox *******************/

	jQuery("a.ecran").fancybox({
		'autoScale'	: true,
		'type'		: 'image'	
	});	
	
	jQuery("a.popup").fancybox({
		'autoScale'		: false,
		'autoDimensions': false,
		'scrolling'		: 'no',	
		'type'			: 'iframe',
		'width'			: 635,	
		'height'		: 530
	});	
	
	jQuery("a.popupDemandeInfo").fancybox({
		'autoScale'		: false,
		'autoDimensions': false,
		'scrolling'		: 'no',	
		'type'			: 'iframe',
		'width'			: 500,	
		'height'		: 570
	});	
	
	jQuery("a.popupDemandeInfoEN").fancybox({
		'autoScale'		: false,
		'autoDimensions': false,
		'scrolling'		: 'no',	
		'type'			: 'iframe',
		'width'			: 500,	
		'height'		: 640
	});	
	
	
	jQuery("a.popupPetit").fancybox({
		'height':340,
		'width':600,			
		'autoScale'	: false,
		'autoDimensions': false,
		'scrolling'	: 'no',	
		'type'		: 'iframe'	
	});	
	
	jQuery("a.popupMoyen").fancybox({
		'height':450,
		'width':600,	
		'autoScale'	: false,		
		'autoDimensions': false,
		'scrolling'	: 'no',	
		'type'		: 'iframe'	
	});	
	
	jQuery("a.popupGrand").fancybox({
		'height':535,
		'width':600,	
		'autoScale'	: false,
		'autoDimensions': false,		
		'scrolling'	: 'no',	
		'type'		: 'iframe'	
	});	
	
	jQuery("a.partenariat").fancybox({
		'height':730,
		'width':600,			
		'autoScale'	: false,
		'autoDimensions'	: false,
		'scrolling'	: 'no',
		'type'		: 'iframe'
	});
	
	jQuery("a.popupTrousse").fancybox({
		'autoScale'		: false,
		'autoDimensions': false,
		'scrolling'		: 'no',	
		'type'			: 'iframe',
		'width'			: 665,	
		'height'		: 570
	});	

/* script pour event tracker pour Google Analytics */

	jQuery('a').click(function(){
		var eventCategory = document.title;
		var trackURL = jQuery(this).attr('href');
		var text = jQuery(this).text();
		trackClick(text,trackURL,eventCategory);
	});

});

function trackClick(text,link,title) {
	_gaq.push(['_trackEvent',text,link,title]);
};

/* script pour event tracker pour Google Analytics */

var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-26716319-1']);
  _gaq.push(['_setDomainName', 'legestionnaire.ca']);
  _gaq.push(['_trackPageview']);

(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
