// JavaScript Document
var menuActive = '';
var subMenuActive = 0;
$( function () {



// Ajout 4D

	/* Personnalisation */
	$('.ItemSortable').each ( function () {
		$(this).find('.personnalisation').find('a').eq(0).lightBox({
			fixedNavigation:false,
			overlayOpacity:0.5,
			caption:'rel',
			imageLoading: 'images/design/lightbox-image-loader.gif',
			imageBtnClose: 'images/design/lightbox-btn-close.gif',
			navigation:false,
			imagePos:false,
			nonImageContent:true,
			maxHeight: $(window).height(),
			maxWidth: $(window).width()
		});

		/* identification */
  	$('.Classement_Entreprises').lightBox({
		   fixedNavigation: false,
		   overlayOpacity: 0.5,
		   caption: 'rel',
		   imageLoading: 'images/design/lightbox-image-loader.gif',
		   imageBtnClose: 'images/design/lightbox-btn-close.gif',
		   navigation: false,
		   imagePos: false,
		   nonImageContent: true,
		   // definir le skin � appliquer : le id par defaut du lightbox est "#jquery-lightbox".Donc, pour ce lightbox, on lui assignera un id "#jquery-lightbox-custom"
		   // si on utilise le skin par defaut, alors il n'est pas necessaire de specifier ce parametre
		   skin: '-custom',
		   maxHeight: $(window).height(),
		   maxWidth: $(window).width()

 		});

   	$('.Classement_Entreprises2').lightBox({
		   fixedNavigation: false,
		   overlayOpacity: 0.5,
		   caption: 'rel',
		   imageLoading: 'images/design/lightbox-image-loader.gif',
		   imageBtnClose: 'images/design/lightbox-btn-close.gif',
		   navigation: false,
		   imagePos: false,
		   nonImageContent: true,
		   // definir le skin � appliquer : le id par defaut du lightbox est "#jquery-lightbox".Donc, pour ce lightbox, on lui assignera un id "#jquery-lightbox-custom"
		   // si on utilise le skin par defaut, alors il n'est pas necessaire de specifier ce parametre
		   skin: '-custom',
		   maxHeight: $(window).height(),
		   maxWidth: $(window).width()

 		});

    $('.Classement_Entreprises3').lightBox({
		   fixedNavigation: false,
		   overlayOpacity: 0.5,
		   caption: 'rel',
		   imageLoading: 'images/design/lightbox-image-loader.gif',
		   imageBtnClose: 'images/design/lightbox-btn-close.gif',
		   navigation: false,
		   imagePos: false,
		   nonImageContent: true,
		   // definir le skin � appliquer : le id par defaut du lightbox est "#jquery-lightbox".Donc, pour ce lightbox, on lui assignera un id "#jquery-lightbox-custom"
		   // si on utilise le skin par defaut, alors il n'est pas necessaire de specifier ce parametre
		   skin: '-custom',
		   maxHeight: $(window).height(),
		   maxWidth: $(window).width()

 		});


		$(this).find('.personnalisation').find('a').eq(1).toggle ( function () {
			var __$scrollContent = $(this).parents('.ItemSortable').find('.G_content');
			var __$scrollContentHeight = parseInt ( __$scrollContent.parent().css('height') );

			var __$container =  $(this).parents('.ItemSortable').find('.G_content').parent().parent();
			__$container.empty();
			__$container.append( __$scrollContent.css({ position:'static', height:(__$scrollContentHeight * 2) + 'px', overflow:'auto' }) );
			//console.log($scrollContent);

			/*console.log ($(this).parents('.ItemSortable').find('.G_content').css('height'));*/
			__$scrollContent.jScrollPane({
				showArrows:true,
				scrollbarWidth: 19,
				arrowSize: 11,
				scrollbarMargin: 0
			});
			$(this).children('img').get(0).src = 'images/buttons/maillage.moins.gif';
			$(this).children('img').attr('alt', 'Afficher moins de r�sultats');
			$(this).attr('title', 'Afficher moins de r�sultats');
			return false;
		}, function () {
			var __$scrollContent = $(this).parents('.ItemSortable').find('.G_content');
			var __$scrollContentHeight = parseInt ( __$scrollContent.parent().css('height') );

			var __$container =  $(this).parents('.ItemSortable').find('.G_content').parent().parent();
			__$container.empty();
			__$container.append( __$scrollContent.css({ position:'static', height:(__$scrollContentHeight/2) + 'px', overflow:'auto' }) );

			__$scrollContent.jScrollPane({
				showArrows:true,
				scrollbarWidth: 19,
				arrowSize: 11,
				scrollbarMargin: 0
			});

			$(this).children('img').get(0).src = 'images/buttons/maillage.plus.gif';
			$(this).children('img').attr('alt', 'Afficher plus de r�sultats');
			$(this).attr('title', 'Afficher plus de r�sultats');

			return false;
		});

	});

// Fin Ajout 4D







	$('.B_menuNavigation_main').DropdownMenu ({ itemActive: menuActive, subItemActive:subMenuActive });

	/* Bloc identification */

	$(".connect").hover ( function () {
		$(".B_header_access_home").hide();
		$(".B_header_access_login").show();
		return false;
	}, function () {});

	$(".B_header_access_login").find(".G_closepanel").eq(0).click ( function () {
		$(".B_header_access_login").hide();
		$(".B_header_access_error").hide();
		$(".B_header_access_forget").hide();
		$(".B_header_access_home").show();
	});
/* SUPPR
	$('.B_header_access_login').find('.G_button').eq(0).click( function () {
		$(".B_header_access_login").hide();
		$(".B_header_access_connected").show();
		return false;
	});

	$('.disconnect a').click( function () {
		$(".B_header_access_connected").hide();
		$(".B_header_access_login").show();
		return false;
	});
//*/
// ADD
	$(".B_header_access_connected").show();
//

	$(".oubli").click ( function () {
		$(".B_header_access_forget").show();
	});

	$(".B_header_access_forget").find(".G_closepanel").eq(0).click ( function () {
		$(".B_header_access_forget").hide();
		$(".B_header_access_forget_form").show();
		$(".B_header_access_forget_message").hide();
	});

	$('.B_header_access_forget').find('.G_button').eq(0).click( function () {
		$(".B_header_access_forget_form").hide();
		$(".B_header_access_forget_message").show();
		return false;
	});


	$(".B_header_access_error").find(".G_closepanel").eq(0).click ( function () {
		$(".B_header_access_error").hide();
	});


	/* Flash header
	$('#B_headerLibrairie_vitrine').flash(
	{
	  src: 'swf/moniteur.swf',
	  width: 236,
	  height: 99,
	  flashvars: { xmlPath: 'xml/vitrine.xml'}
	},
	{ version: 8 } ,
	function (htmlOptions) {
		$this = $(this);
		this.innerHTML = '<div class="alt">'+this.innerHTML+'</div>';
    	$this.addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions));
	});*/

	// Favoris et acceuil

	var moniteurUrl = "http://www.lemoniteur.fr"
	var moniteurTitle = "Le Moniteur.fr"

	$('.addFavorite').click( function () {
		if ($.browser.msie)
			window.external.AddFavorite(moniteurUrl, moniteurTitle);
		else if ($.browser.mozilla) {
			window.sidebar.addPanel(moniteurTitle, moniteurUrl, "");
		}
		return false;
	});


	$('.addHome').click( function () {
		if ($.browser.msie) {
			this.style.behavior='url(#default#homepage)'
			this.setHomePage(moniteurUrl);
		}
		else if ($.browser.mozilla) {
			// window.sidebar.addPanel(moniteurTitle, moniteurUrl, "");
		}
		return false;
	});


});


