function imageResize(nbItems, newImg1, newImg2, border1, border2)
{
	/**
	 * Determination de la taille de la fenetre
	 */
	var MAX_WINDOW_WIDTH = $(window).width() - 140 ;
	var MAX_WINDOW_HEIGHT = $(window).height() - 100 ;
	$("#mainPicture").height(MAX_WINDOW_HEIGHT);
	/**
	 * Taille d'origine de l'image
	 */
	var imageHeight1 = newImg1.height;
	var imageWidth1 = newImg1.width;
	/**
	 * Total image width
	 */
	var totalWidth = imageWidth1 ;
	if (nbItems == 2)
	{
		var imageHeight2 = newImg2.height;
		var imageWidth2 = newImg2.width;
		totalWidth += imageWidth2;
	}

	var ratioWidth1 = MAX_WINDOW_WIDTH / (totalWidth) ;
	var ratioHeight1 = MAX_WINDOW_HEIGHT / imageHeight1 ;
	var ratio1 = Math.min(Math.min(ratioWidth1, ratioHeight1), 1) ;
	var resizedWidth1 = Math.ceil(imageWidth1 * ratio1) ;
	if (border1 == 1)
	{
		resizedWidth1 +=1 ;
	}
	$("#picture1").width(resizedWidth1);
	
	var navigationPictureMarginLeft = resizedWidth1 ;
	if (nbItems == 2)
	{

		var ratioWidth2 = (MAX_WINDOW_WIDTH) / (totalWidth) ;
		var ratioHeight2 = MAX_WINDOW_HEIGHT / imageHeight2 ;
		var ratio2 = Math.min(Math.min(ratioWidth2, ratioHeight2), 1) ;
		var resizedWidth2 = Math.ceil(imageWidth2 * ratio2) ;
		if (border2 == 1)
		{
				resizedWidth2 += 1;
		}
		$("#picture2").width(resizedWidth2);
		navigationPictureMarginLeft += resizedWidth2 ;
	}
	$('#picture').width(navigationPictureMarginLeft) ;
	$('#navigationPicture').css('display','inline');
	/**
	 * Calcul du positionnement du tooltip du contact
	 */
	var tooltipMarginLeft = MAX_WINDOW_WIDTH - 40 ;
	//$('div.tooltip').css('margin-left', tooltipMarginLeft + 'px');
	//$('div.tooltip').css('margin-top', '260px');
}

function thumbnailDivResize()
{
	$('#panel').jScrollPaneRemove() ;	
	/**
	 * Determination de la taille de la fenetre
	 */
	var thumbnailsHeight = 142 ;
	var thumbnailsWidth = 142 ;

	var MAX_WINDOW_WIDTH = $(window).width();
	var MAX_WINDOW_HEIGHT = $(window).height() - 50 ;
	var nbItemsWidth = Math.floor(MAX_WINDOW_WIDTH / thumbnailsWidth) ;

	var panelWidth = (nbItemsWidth)*thumbnailsWidth ;
	var panelHeight = MAX_WINDOW_HEIGHT - 130 ;

	$('#panel').width(panelWidth) ;
	$("#panel").height(panelHeight);
	$('#panel').css('margin-left', '30px');
	$('#panel').jScrollPane({scrollbarWidth:40, scrollbarMargin:0, animateTo:false, showArrows:true, scrollbarOnLeft:false, topCapHeight: 0, bottomCapHeight: 0, dragMaxHeight:0});
	/**
	 * Positionement des fleches de navigations
	 */
	var arrowTopMargin = panelHeight - 72 ;
	//var arrowBottomMargin = panelHeight - 72 ;
	/*alert( " -- MAX_WINDOW_WIDTH = " + MAX_WINDOW_WIDTH + " -- nbItemsWidth*thumbnailsWidth = " + nbItemsWidth*thumbnailsWidth + " -- arrowRightMargin = " + arrowRightMargin) ;*/
	$('a.jScrollArrowUp').css('margin-top', arrowTopMargin + 'px');
	//$('a.jScrollArrowDown').css('margin-bottom', arrowBottomMargin + 'px');
}

function homePageDivResize(marginLeftRight, marginTopBottom, nbColumn, nbLine, thumbnailsWidthMargin)
{
	/**
	 * Determination de la taille de la fenetre
	 */
	var thumbnailsHeight = 501 ;
	var thumbnailsWidth = 395 ;
	//var marginTopBottom = 20 ;
	//var marginLeftRight = 40 ;

	var fontSize = 36 ;
	var titleWidthSize = 12*24 ;

	var MAX_WINDOW_WIDTH = $(window).width() - 3 * marginLeftRight ;
	var MAX_WINDOW_HEIGHT = $(window).height() - 3 * marginLeftRight - 2 * marginTopBottom ;

	var ratioWidth = MAX_WINDOW_WIDTH / (nbColumn * (thumbnailsWidth + thumbnailsWidthMargin)) ;
	var ratioHeight = MAX_WINDOW_HEIGHT / (nbLine * thumbnailsHeight + marginTopBottom) ;
	var ratio = Math.min(Math.min(ratioWidth, ratioHeight), 1) ;

	var resizedWidth = Math.ceil(thumbnailsWidth * ratio) ;
	var resizeHeight = Math.ceil(thumbnailsHeight * ratio) ;
	var resizeMarginTopBottom = Math.ceil(marginTopBottom * ratio) ;
	var resizeMarginLeftRight = Math.ceil(marginLeftRight * ratio) ;

	var resizeFontSize = Math.ceil(fontSize * ratio) ;
	var resizeTitleWidthSize = Math.ceil(titleWidthSize * ratio) ;
	var resizeTopTitle = resizeHeight/nbLine + 20 ;
	var resizeLeftTitle = marginLeftRight + (resizedWidth - resizeTitleWidthSize)/nbLine ;

	//alert("thumbnailsWidth = " + thumbnailsWidth + " -- ratio = " + ratio) ;
	$("img.homePage").width(resizedWidth);

	$('img.homePage').css('margin-top','10px');
	$('img.homePage').css('margin-bottom','0px');
	$('img.homePage').css('margin-right',resizeMarginLeftRight + 'px');
	$('img.homePage').css('margin-left', marginLeftRight + 'px');

	$('div.homePageTitle').css('font-size', resizeFontSize + 'px') ;
	$('div.homePageTitle').css('line-height', resizeFontSize + 'px') ;
	$('div.homePageTitle').css('top',  resizeTopTitle + 'px') ;
	$('div.homePageTitle').css('left',  resizeLeftTitle + 'px') ;
	$('div.homePageTitle').css('width', resizeTitleWidthSize + 'px') ;
}

function homePageDivResizeNew(marginLeftRight, marginTopBottom, nbColumn, nbLine, thumbnailsWidthMargin)
{
	/**
	 * Determination de la taille de la fenetre
	 */
	var thumbnailsHeight = 501 ;
	var thumbnailsWidth = 395 ;
	//var marginTopBottom = 20 ;
	//var marginLeftRight = 40 ;

	var fontSize = 36 ;
	var titleWidthSize = 12*24 ;

	var MAX_WINDOW_WIDTH = $(window).width() - 3 * marginLeftRight ;
	var MAX_WINDOW_HEIGHT = $(window).height() - 80 - 65 - 20 - 10 ; // on enlˇve 80 px bandeau du haut, 65px bandeau du bas , 

	var ratioWidth = MAX_WINDOW_WIDTH / (nbColumn * (thumbnailsWidth + thumbnailsWidthMargin)) ;
	var ratioHeight = MAX_WINDOW_HEIGHT / (nbLine * thumbnailsHeight + marginTopBottom) ;
	var ratio = Math.min(Math.min(ratioWidth, ratioHeight), 1) ;

	var resizedWidth = Math.ceil(thumbnailsWidth * ratio) ;
	var resizeHeight = Math.ceil(thumbnailsHeight * ratio) ;
	var resizeMarginTopBottom = Math.ceil(marginTopBottom * ratio) ;
	var resizeMarginLeftRight = Math.ceil(marginLeftRight * ratio) ;

	var resizeFontSize = Math.ceil(fontSize * ratio) ;
	var resizeTitleWidthSize = Math.ceil(titleWidthSize * ratio) ;
	var resizeTopTitle = resizeHeight/nbLine + 20 ;
	var resizeLeftTitle = (resizedWidth - resizeTitleWidthSize)/nbLine ;

	//alert("thumbnailsWidth = " + thumbnailsWidth + " -- ratio = " + ratio) ;
	$("img.homePage").width(resizedWidth);

	$('img.homePage').css('margin-top','10px');
	$('img.homePage').css('margin-bottom','0px');
	$('img.homePage').css('margin-right',resizeMarginLeftRight + 'px');
	$('img.homePage').css('margin-left', '0px');

	$('div.homePageTitle').css('font-size', resizeFontSize + 'px') ;
	$('div.homePageTitle').css('line-height', resizeFontSize + 'px') ;
	$('div.homePageTitle').css('top',  resizeTopTitle + 'px') ;
	$('div.homePageTitle').css('left',  resizeLeftTitle + 'px') ;
	$('div.homePageTitle').css('width', resizeTitleWidthSize + 'px') ;
}

function imageNavigation(obj, previousLink, nextLink, xMouse, yMouse)
{
	var leftPosition = $(obj).width() / 2;
	//alert(" width = " + $(obj).width() + " -- $('#picture').width() = " + $('#picture').width() + " -- id = " + $(obj).attr('id')) ;
	//alert(" previousLink = " + previousLink + " -- nextLink = " + nextLink) ;
	//alert("xMouse = " + xMouse + " -- yMouse = " + yMouse);

	var imageId = $(obj).attr('id');
	if ($('#picture2').width() != null)
	{
		if (imageId == 'picture1')
		{
			if (previousLink != '')
			{
				window.location.href = previousLink;
			}
		}
		else
		{
			if (nextLink != '')
			{
				window.location.href = nextLink;
			}
		}
	}
	else
	{
		if (xMouse <= leftPosition)
		{
			if (previousLink != '')
			{
				window.location.href = previousLink;
			}
		}
		else
		{
			if (nextLink != '')
			{
				window.location.href = nextLink;
			}
		}
	}
}
