// JavaScript Document
var thumbZoneWidth = 0;
var thumbArray = new Array();
var maxWidth = 820;
var browser = navigator.appName;
var browserVersion = navigator.appVersion;


function calcThumbWidth()
{
	var $i = $j = 0;	
	
	if(document.getElementById('thumbZone').childNodes.length > 0)
	{
		for($i in document.getElementById('thumbZone').childNodes)
		{
			if(document.getElementById('thumbZone').childNodes[$i].tagName == 'IMG')
			{
				thumbArray[$j] = document.getElementById('thumbZone').childNodes[$i].id;
				
				thumbZoneWidth = thumbZoneWidth + document.getElementById('thumbZone').childNodes[$i].clientWidth + 14;
				//document.getElementById('thumbZone').style.width = Number(thumbZoneWidth);
				$j = $j + 1;
			}
		}
	}
	
	document.getElementById('thumbZoneContainer').style.overflowX = 'scroll'; 
	document.getElementById('thumbZoneContainer').style.height = '96px'; 
	
	if(thumbZoneWidth > maxWidth)
	{
		document.getElementById('thumbZone').style.width = maxWidth + 'px';
		document.getElementById('thumbZoneContainer').style.width = maxWidth + 'px';
		document.getElementById('thumbZoneContainer').style.height = '96px'; 
	}
}

function openPopUp(fichier, nom, hauteur, largeur)
{
	window.open(fichier, nom, config='height='+hauteur+', width='+largeur+',toolbar=no,menubar=no,scrollbars=yes,resizable=no, location=no,directories=no,status=no')
}

function positionCentralElem()
{
	var bodyWidth = document.body.clientWidth;
	var photoWidth = document.getElementById('photo').clientWidth;
	var textAreaWidth = document.getElementById('mainTextarea').clientWidth;	
	
	leftMargin = (bodyWidth-(photoWidth+textAreaWidth))/2;
	leftMargin = leftMargin - 54;
		
	//document.getElementById('boxContainer').style.width = photoWidth+textAreaWidth+80;
	
	if(browser == 'Microsoft Internet Explorer'){
		var mainStr = new String(browserVersion);
	
		//document.getElementById('squares').style.width = photoWidth+textAreaWidth + 70 + 'px';
		
		
		if(mainStr.indexOf('MSIE 6.0') > -1)
		{		
			if(document.body.clientWidth < 925)
			{
				document.body.style.width = 925 + 'px';
				
				document.getElementById('central').style.width = 915 + 'px';
				document.getElementById('header').style.width = 915 + 'px';
				document.getElementById('header').style.padding = '0px 10px 0px 10px'; 
				document.getElementById('menu').style.width = 915 + 'px';
				document.getElementById('menu').style.padding = '0px 10px 0px 10px'; 
				
			}
		}
	}
	else if(browser == 'Netscape')
	{
		document.body.padding = '10px';
	}
	
	if(leftMargin > 0)
	{
		document.getElementById('squares').style.padding = '0 0 0 ' + Number(leftMargin) + 'px';
	}
	
}

function switchCube(element)
{
	//alert(element.id);
	//alert(element.src);
	mainStr = new String(element.src);
	
	if(mainStr.indexOf('blank') > -1)
	{
		element.src = "images/orangeCube.gif";	
	}
	else
	{
		element.src = "images/blankCube.gif";	
	}
}

function switchMainImg(imgName)
{
	document.getElementById('photo').src = "./images/gallery/" + imgName;
	setTimeout('positionCentralElem()',25);
}

function tweakmainTextare(){
	if(browser == "Microsoft Internet Explorer"){
		document.getElementById('mainTextarea').style.height = '370px';
	}	
}
