/**
 * jQuery.fullBg
 * Version 1.0
 * Copyright (c) 2010 c.bavota - http://bavotasan.com
 * Dual licensed under MIT and GPL.
 * Date: 02/23/2010
**/

(function ($) {

Drupal.behaviors.fullBgScript = {
attach: function (context) {
	
	$.fn.fullBg = function(){
		var bgImg = $(this);
		
		bgImg.addClass('fullBg');
		
		function resizeImg() {
			var imgwidth = bgImg.width();
			var imgheight = bgImg.height();
			
			var winwidth = $(window).width();
			var winheight = $(window).height();
				
			var widthratio = winwidth/imgwidth;
			var heightratio = winheight/imgheight;
			
			var widthdiff = heightratio*imgwidth;
			var heightdiff = widthratio*imgheight;
			
			if(heightdiff>winheight) {
				bgImg.css({
					width: winwidth+'px',
					height: heightdiff+'px'
				});
			} else {
				bgImg.css({
					width: widthdiff+'px',
					height: winheight+'px'
				});		
			}
		}
		
		resizeImg();
		
		$(window).load(function() {
			resizeImg();
		});
		
		$(window).resize(function() {
			resizeImg();
		}); 
	};
	
	
}
};
})(jQuery);


;
/**
 * jQuery.canophile
 * Pixicode
 * 
 * 
 * Date: 08/04/2011
**/

(function ($) {

Drupal.behaviors.canophileScript = {
attach: function (context) {
	
	
	// Appel fonction image bg plein ecran : jQuery.fullBg
	/*$(window).load(function() {*/
		$('#wrapper-scrollable img#background').fullBg();
	/*});*/

		
	// Affichage Carte parcours
	// Cette variante ne marche pas avec ie7 -> opacitu
	/*$('#wrapper-carte .switcher-carte a').text('Carte');
	
	$('#wrapper-carte .switcher-carte').toggle(function () {
		$('#page-wrapper').animate({
			opacity: 0,
		}, 1000, function() {
			$('#page-wrapper').css({'top': '-5000px'});
			$('#wrapper-carte .bg-carte').show().animate({
				opacity: 1,
			}, 1000, function() {
				$('#wrapper-carte .switcher-carte a').text('Fermer');
			});
		});

	}, function () {
		$('#wrapper-carte .bg-carte').animate({
			opacity: 0,
		}, 1000, function() {
			$('#page-wrapper').css({'top': '0px'});
			$('#page-wrapper').show().animate({
				opacity: 1,
			}, 1000, function() {
				$('#wrapper-carte .switcher-carte a').text('Carte');
			});
		});
	});*/
	
	$('#wrapper-carte .switcher-carte a').text('Carte');

	$('#wrapper-carte .switcher-carte').toggle(function () {
		$('#page-wrapper').fadeTo('slow', 0, function() {
			$('#page-wrapper').css({'top': '-5000px'});
			$('#wrapper-carte .bg-carte').fadeTo('slow', 1, function() {
				$('#wrapper-carte .switcher-carte a').text('Fermer');
			});
		});

	}, function () {
		$('#wrapper-carte .bg-carte').fadeTo('slow', 0, function() {
			$('#page-wrapper').css({'top': '0px'});
			$('#page-wrapper').fadeTo('slow', 1, function() {
				$('#wrapper-carte .switcher-carte a').text('Carte');
			});
		});
	});
	

	
	// Make border radius work on images in Firefox. ! provoque un bug d'affichage avec firefox 4 sous windows
	/*if ($.browser.mozilla) {
		$('.views-slideshow-cycle-main-frame-row-item img', context).filter(':not(.initFirefoxBackgroundImage-processed)').addClass('initFirefoxBackgroundImage-processed').each(function () {
		  var imageUrl = $(this).attr('src');
		  var imageWidth = $(this).attr('width');
		  var imageHeight = $(this).attr('height');
		  $(this).parent().addClass('firefox-radius').css({'background-image' : 'url(' + imageUrl + ')', 'width' : imageWidth, 'height' : imageHeight});
		  $(this).hide();
		});	
	}*/
	
	
	// Boutons controle slider
	var $control = $('.views-slideshow-controls-text-pause');
	
	$('.views_slideshow_slide').hover(function () {
		$control.addClass('active');
	}, function () {
		$control.removeClass('active');
	});
	
	$('.views-slideshow-pager-field-item').hover(function () {
		$control.addClass('active');
		$(this).addClass('active');
	}, function () {
		$control.removeClass('active');
		$(this).removeClass('active');
	});
	
	$control.click(function () {
		$(this).toggleClass('active');
	});

		
}
};
})(jQuery);;

