/**
 * permet de charger la photo d'en-tête de la page
 */
load_bannerPicture = function(url_picture, call_back) {
	
	var img = new Image();
				
	// wrap our new image in jQuery, then:
	$(img)
	
		// once the image has loaded, execute this code
	    .load(function () {
		    
			// on cache l'image
	      	$(this).hide();
	      	// on ajoute l'image à la page
	      	$('#headerBannerBg').append(this);				        
			// on rend l'image visible avec un petit effet de fadein
	      	$(this).fadeIn();
	      	
	      	// call back function if specified
	      	if ( call_back != undefined ) setTimeout(call_back, 0);
	    })
	    
	    // if there was an error loading the image, react accordingly
	    .error(function () {
	      // notify the user that the image could not be loaded
	    })
	    
	    // *finally*, set the src attribute of the new image to our image
	    .attr('src', url_picture);
}

/**
 * fonction générique pour précharger des images
 */ 
jQuery.preloadImages = function() {
	var a = (typeof arguments[0] == 'object') ? arguments[0] : arguments;
	for ( var i = 0; i < a.length; i++ ) {
		jQuery('<img>').attr('src', a[i]);
	}
};

/**
 * permet de précharger les images d'une page et de les garder en cache
 */
preloadImages_pagePhotos = function(path) {
	var preload = [path + 'photos-noel-2010.jpg', path + 'photos-nouvel-an-2011.jpg', path + 'photos-crampoisic-2010.jpg', path + 'photos-pessah.jpg', path + 'photos-paques-en-famille-2010.jpg', path + 'photos-noel-2009.jpg'];	
	$.preloadImages(preload);
};

/**
 * permet de précharger les images d'une page et de les garder en cache
 */
preloadImages_selectIcons = function(path) {
	var preload = [path + 'select_white.gif', path + 'select_white_active.gif'];	
	$.preloadImages(preload);
};

/* ************************************************ */
/* Main.
/* ************************************************ */

/**
 * permet d'ajouter un trigger sur le chargement de la page
 */
$(document).ready(function() {	
	$("#site").append('<div id="google_translate_element"></div>');	
});

function googleTranslateElementInit() {
	new google.translate.TranslateElement({
		pageLanguage: 'fr',
		layout: google.translate.TranslateElement.InlineLayout.SIMPLE
	}, 'google_translate_element');
}

