function MM_menuStartTimeout(hideTimeout) {
	mmHideMenuTimer = setTimeout("hide_menu('1')", hideTimeout);	
}

function MM_menuResetTimeout() {
	if (mmHideMenuTimer) clearTimeout(mmHideMenuTimer);
	mmHideMenuTimer = null;
}

function show_hide(i,j,k,l)
{
	if(l==1)
	{
		document.getElementById(i).style.display='none';
		document.getElementById(j).style.display='none';
		document.getElementById(k).style.display='block';
		$('#'+i).siblings('.applyNow').hide();
	}
	if(l==0)
	{
		document.getElementById(i).style.display='block';
		document.getElementById(j).style.display='block';
		document.getElementById(k).style.display='none';
		$('#'+i).siblings('.applyNow').show();
	}
	return false;
}
function show(i,j) {
	if(j==0) document.getElementById(i).style.visibility='hidden';
	if(j==1) document.getElementById(i).style.visibility='visible';
}

function combo_change()
{
	var sel = document.getElementById('secteur').value;
	var i=1;
	while(document.getElementById('a'+i))
	{
		document.getElementById('a'+i).style.display = 'none';
		i++;
	}
	document.getElementById('a'+sel).style.display = 'block';
	return false;
}

$(function(){
	$('img[@src$=.png]').ifixpng();
	
	// HOME
	$('.subMenu').hide();
	$('#global > div > div').hover(function(){
		$('.subMenu',$(this)).show();
	}, function(){
		$('.subMenu',$(this)).hide();
	});
	
	$('#global .slides1 > div[@id]').prepend('<div class="whiteLine"></div>').find('.whiteLine').each(function(){
		var plusElmtOffsetTop = $(this).siblings('.plusItem').offset()['top'];
		if ($(this).parent().is('#contact')) {
			$(this).css('bottom','30px');
			var parentHeight = $(this).parent().height()+$(this).parent().offset()['top']-52;
		} else {
			var parentHeight = $(this).parent().height()+$(this).parent().offset()['top']-22;
		}
		if (parentHeight<=0 || parentHeight > plusElmtOffsetTop) $(this).height(parentHeight-plusElmtOffsetTop);
	});
	
	//SUBMENU PAGE
	$('.submenu').hide();
	$('.subMenu_block').hover(function(){
		$('.submenu',$(this)).show();
	}, function(){
		$('.submenu',$(this)).hide();
	});
	
	var ltie7 = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent);
	if (ltie7) {

		$('img[@usemap]').css('border','none');
		
		$('#global .subMenu ul').each(function(){
			$(this).find('li:first').css('filter','none');
		});
		
		$('.orbeoID .box table tr:first-child td').css('border-top','none');
		
		$('#identity .box p:first-child').css('margin-top','0');
		$('.cadre > *:first-child, .cadre .arrondiHaut + *').css('margin-top','0');
		$('.intro_cadre + h2').css('margin-top', '2em');
		$('.cadreMeet h4').css('margin-top','0.6em');
		$('.rub_bleu .ourActivitiesCadreTop > *:first').css({marginTop: '1.2em'});
		$('.ourActivitiesCadreTop ul li:first').css({paddingTop: '0'});
	}

	// Quand une page contient des cadres, ils sont tous masques sauf le premier
	$('.moin_2:gt(0)').parent('.cadreSwitcher').prev('.cadre').hide();
	$('.moin_2:first').parent('.cadreSwitcher').find('.moin_2').show().end().find('.plus_2').hide();
	$('.moin_2').click(function(){
		$(this).hide().siblings('.plus_2').show().parent('a').prev('.cadre').hide();
	});
	$('.plus_2').click(function(){
		$(this).hide().siblings('.moin_2').show().parent('a').prev('.cadre').show();
	});
	
	if ($('.cadreMeet').size() != 0) { 
		$('.descriptif').css({height: '88px',overflow: 'hidden'}).append('<div class="toBeContinued">(&hellip;)</div>');
		$(' .logo > p').hide();
	}
	$('.moin_5').click(function(){
		$(this).hide().siblings('.plus_5').show().parent('a').prev('.cadre').find('.descriptif').css({height: '88px',overflow: 'hidden'}).parent('.cadre').find('.logo p').hide().end().find('.toBeContinued').show();
	});
	$('.plus_5').click(function(){
		$(this).hide().siblings('.moin_5').show().parent('a').prev('.cadre').find('.descriptif').css({height: 'auto',overflow: 'visible'}).parent('.cadre').find('.logo p').show().end().find('.toBeContinued').hide();
	});
	$('.moin_6').parent('.cadreSwitcher').prev('.cadre').find('.detail, .applyNow').hide();
	$('.moin_6').click(function(){
		$(this).hide().siblings('.plus_6').show().parent('a').prev('.cadre').find('.detail, .applyNow').hide();
	});
	$('.plus_6').click(function(){
		$(this).hide().siblings('.moin_6').show().parent('a').prev('.cadre').find('.detail, .applyNow').show();
	});

	$('#content .smallbox li:first').css('border','none');

	// ajustement des premier h3 des "cadre" dans From projectt to market 
	$('.cadreP2M').find("h3:first").css('margin-top',0);
	$('.cadreP2M ').find('h3').each(function () {
		if ($(this).next().is('ul')) {
			$(this).css('margin-bottom',0);
		}
	});
	
	// Market Dedicated Solutions
	$('#content .interest:gt(0)').hide();
	
	if (ltie7) {
		$('.ourActivitiesCadreMiddle, .ourActivitiesCadreBottom').height($('.ourActivities td').height()+'px');
		$('.ourActivitiesCadreTop').height(($('.ourActivities td').height()-20)+'px');
	} else {
		$('.ourActivitiesCadreMiddle, .ourActivitiesCadreBottom').css('minHeight',($('.ourActivities td').height()+'px'));
		$('.ourActivitiesCadreTop').css('minHeight',($('.ourActivities td').height()-20)+'px');
	}
	
});

function homeMenuOver (jQElmt) {
	next=jQElmt.parent('div').next('div');
	if (next.size() == 0) next = jQElmt.parent('div').parent('div').next('div');
	next.css('visibility','visible');
}

function homeMenuOut (jQElmt) {
	jQElmt.css('visibility','hidden');
}

// Target est un selecteur jQuery qui permet d'indiquer quel est l'element (image ou input) qui doit changer.
// Sa valeur par defaut est '$myself', ce qui indique que l'objet est sa propre cible.
// Ex : $('#menu > li').each(function(){$(this).switchImage("","> a > img");});

$.fn.extend({
	switchImage: function(eventTargetSelector, changeTargetSelector, options) {
		var eventTargetSelector, changeTargetSelector, eventTarget, changeTarget;
		if (!eventTargetSelector) eventTargetSelector = '?myself';
		if (!changeTargetSelector) changeTargetSelector = '?myself';
		var settings = {
			stringDefault: '_off',
			stringHover: '_on'
		};
		if (options) {
			jQuery.extend(settings, options);
		}
		if (eventTargetSelector == '?myself') eventTarget=$(this);
		else eventTarget = $(this).find(eventTargetSelector);
		if (changeTargetSelector == '?myself') changeTarget=$(this);
		else changeTarget = $(this).find(changeTargetSelector);
		eventTarget.filter(function(index){
			return (changeTarget.is("input[@type=image][@src]") || changeTarget.is("img[@src]"));
		}).mouseover(function(){switchToHover(changeTarget)}).focus(function(){switchToHover(changeTarget)}).mouseout(function(){switchToDefault(changeTarget)}).blur(function(){switchToDefault(changeTarget)});
		function switchToHover(e) {
			var src = e.attr('src');
			var srcPathSplit = src.split('/');
			var fileName=srcPathSplit.pop();
			var filePath=srcPathSplit.join('/');
			if (fileName.indexOf(settings.stringDefault) != -1) {
				e.attr('src', filePath+'/'+fileName.replace(settings.stringDefault, settings.stringHover));
			}
		}
		function switchToDefault(e) {
			var src = e.attr('src');
			var srcPathSplit = src.split('/');
			var fileName=srcPathSplit.pop();
			var filePath=srcPathSplit.join('/');
			if (fileName.indexOf(settings.stringHover) != -1) {
				e.attr('src', filePath+'/'+fileName.replace(settings.stringHover, settings.stringDefault));
			}
		}
		
		return this;
	},
	adjustSize: function(options) {
		var settings = {
			periode: 3,
			mode: 'height',
			minHeight: 0,
			minWidth: 0
		};
		var ltie7 = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent);
		if (options) jQuery.extend(settings, options);
		var totalSize = $(this).size();
		var nbPeriodes = Math.ceil(totalSize/settings.periode);
		var index = 0;
		if (settings.mode == 'height' || settings.mode == 'both') {
			var maxTotalHeightArray = new Array();
			$(this).each(function(){
				var blockId = Math.floor(index/settings.periode);
				if (!maxTotalHeightArray[blockId]) maxTotalHeightArray[blockId]=0;
				var blockTotalHeight = $(this).height();
				if (blockTotalHeight > maxTotalHeightArray[blockId]) {
					if (settings.minHeight && settings.minHeight > blockTotalHeight) blockTotalHeight = settings.minHeight;
					maxTotalHeightArray[blockId] = blockTotalHeight;
				}
				index++;
			});
			var index = 0;
			$(this).each(function(){
				var blockId = Math.floor(index/settings.periode);
				var blockComputedHeight = maxTotalHeightArray[blockId];
				if (ltie7) $(this).height(blockComputedHeight+'px');
				else $(this).css('minHeight',blockComputedHeight+'px');
				index++;
			});
		}
		if (settings.mode == 'width' || settings.mode == 'both') {
			var maxTotalWidthArray = new Array();
			$(this).each(function(){
				var blockId = Math.floor(index/settings.periode);
				if (!maxTotalWidthArray[blockId]) maxTotalWidthArray[blockId]=0;
				var blockTotalWidth = $(this).width() ? $(this).width() : $(this).attr('offsetWidth') ;
				if (blockTotalWidth > maxTotalWidthArray[blockId]) {
					if (settings.minWidth && settings.minWidth > blockTotalHeight) blockTotalWidth = settings.minWidth;
					maxTotalWidthArray[blockId] = blockTotalWidth;
				}
				index++;
			});
			var index = 0;
			$(this).each(function(){
				var blockId = Math.floor(index/settings.periode);
				var blockComputedWidth = maxTotalWidthArray[blockId];
				if (ltie7) $(this).width(blockComputedWidth+'px');
				else $(this).css('minWidth',blockComputedWidth+'px');
				index++;
			});
		}
		
		return this;
	}
});

/*
 * jQuery ifixpng plugin
 * (previously known as pngfix)
 * with another plugin
 * Version 1.9  (27/09/2007)
 * @requires jQuery v1.1.3 or above
 *
 * Examples at: http://jquery.khurshid.com
 * Copyright (c) 2007 Kush M.
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
 
 /**
  *
  * @example
  *
  * optional if location of pixel.gif if different to default which is images/pixel.gif
  * $.ifixpng('media/pixel.gif');
  *
  * $('img[@src$=.png], #panel').ifixpng();
  *
  * @apply hack to all png images and #panel which icluded png img in its css
  *
  * @name ifixpng
  * @type jQuery
  * @cat Plugins/Image
  * @return jQuery
  * @author jQuery Community
  */
 
(function($) {
	
	/**
	 * helper variables and function
	 */
	$.ifixpng = function(customPixel) {
		$.ifixpng.pixel = customPixel;
	};
	
	$.ifixpng.getPixel = function() {
		return $.ifixpng.pixel || 'images/pixel.gif';
	};
	
	var hack = {
		ltie7  : $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent),
		filter : function(src) {
			return "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='"+src+"')";
		}
	};
	
	/**
	 * Applies ie png hack to selected dom elements
	 *
	 * $('img[@src$=.png]').ifixpng();
	 * @desc apply hack to all images with png extensions
	 *
	 * $('#panel, img[@src$=.png]').ifixpng();
	 * @desc apply hack to element #panel and all images with png extensions
	 *
	 * @name ifixpng
	 */
	 
	$.fn.ifixpng = hack.ltie7 ? function() {
    	return this.each(function() {
			var $$ = $(this);
			var base = $('base').attr('href'); // need to use this in case you are using rewriting urls
			if ($$.is('img') || $$.is('input')) { // hack image tags present in dom
				if ($$.attr('src')) {
					if ($$.attr('src').match(/.*\.png([?].*)?$/i)) { // make sure it is png image
						// use source tag value if set 
						var source = (base && $$.attr('src').substring(0,1)!='/') ? base + $$.attr('src') : $$.attr('src');
						// apply filter
						$$.css({filter:hack.filter(source), width:$$.width(), height:$$.height()})
						  .attr({src:$.ifixpng.getPixel()})
						  .positionFix();
					}
				}
			} else { // hack png css properties present inside css
				var image = $$.css('backgroundImage');
				if (image.match(/^url\(["']?(.*\.png([?].*)?)["']?\)$/i)) {
					image = RegExp.$1;
					$$.css({backgroundImage:'none', filter:hack.filter(image)})
					  .children().positionFix();
				}
			}
		});
	} : function() { return this; };
	
	/**
	 * Removes any png hack that may have been applied previously
	 *
	 * $('img[@src$=.png]').iunfixpng();
	 * @desc revert hack on all images with png extensions
	 *
	 * $('#panel, img[@src$=.png]').iunfixpng();
	 * @desc revert hack on element #panel and all images with png extensions
	 *
	 * @name iunfixpng
	 */
	 
	$.fn.iunfixpng = hack.ltie7 ? function() {
    	return this.each(function() {
			var $$ = $(this);
			var src = $$.css('filter');
			if (src.match(/src=["']?(.*\.png([?].*)?)["']?/i)) { // get img source from filter
				src = RegExp.$1;
				if ($$.is('img') || $$.is('input')) {
					$$.attr({src:src}).css({filter:''});
				} else {
					$$.css({filter:'', background:'url('+src+')'});
				}
			}
		});
	} : function() { return this; };
	
	/**
	 * positions selected item relatively
	 */
	 
	$.fn.positionFix = function() {
		return this.each(function() {
			var $$ = $(this);
			var position = $$.css('position');
			if (position != 'absolute' && position != 'relative') {
				$$.css({position:'relative'});
			}
		});
	};

})(jQuery);
