if (document.getElementById("header"))
	document.getElementById("header").firstChild.nodeValue = "";
if (document.getElementById("slogan"))
	document.getElementById("slogan").firstChild.nodeValue = "";
if (document.getElementById("documentation"))
	document.getElementById("documentation").firstChild.firstChild.nodeValue = "";
if (document.getElementById("contacts"))
	document.getElementById("contacts").firstChild.firstChild.nodeValue = "";

function show_it(theImg, persist) {
	var imgsCadrePhoto = document.getElementById("cadrePhoto").getElementsByTagName("IMG");
	if (persist) {
		document.getElementsByTagName('body')[0].theImg = theImg;
	}
	else if (typeof theImg == "undefined") {
		theImg = document.getElementsByTagName('body')[0].theImg;
	}
	for (i=0;i<imgsCadrePhoto.length;i++) {
		imgsCadrePhoto[i].style.border='1px solid #22339a';
		imgsCadrePhoto[i].style.margin='0 12px 12px 0';
	}
	imgsCadrePhoto[theImg].style.border='3px solid #accd37';
	imgsCadrePhoto[theImg].style.margin='0 8px 8px 0';
	j = 0;
	var divs = document.getElementsByTagName("div");
	for (i=0;i<divs.length;i++) {
		if ((divs[i].className) == "cadreProduit" ) {
			divs[i].style.display = "none";
			if (j == theImg) {
				divs[i].style.display = "block";
			}
			j++;
		}
		//divs[theOne].style.display = "block";
	}
}

window.onload = function () {
	showTime();
	if (document.getElementById("cadrePhoto")) {
		var imgsCadrePhoto = document.getElementById("cadrePhoto").getElementsByTagName("IMG");
		for (i=0;i<imgsCadrePhoto.length;i++) {
			var a_function = new Function('', 'show_it('+i+', true);');
			var a_function2 = new Function('', 'show_it('+i+');');
			var a_function3 = new Function('', 'show_it();');
			if (window.addEventListener) {
				imgsCadrePhoto[i].addEventListener('click', a_function, false);
				imgsCadrePhoto[i].addEventListener('mouseover', a_function2, false);
				imgsCadrePhoto[i].addEventListener('mouseout', a_function3, false);
			}
			else if (window.attachEvent) {
				imgsCadrePhoto[i].attachEvent('onclick', a_function);
				imgsCadrePhoto[i].attachEvent('onmouseover', a_function2);
				imgsCadrePhoto[i].attachEvent('onmouseout', a_function3);
			}
		}
		show_it(i-1, true);
	}
}

function showTime() {
	var anchors = document.getElementsByTagName('a');
	for (var k=0;k<anchors.length;k++) {
		if ( ((anchors[k].href.substr(anchors[k].href.length-3)) == "JPG") || ((anchors[k].href.substr(anchors[k].href.length-3)) == "jpg") || ((anchors[k].href.substr(anchors[k].href.length-3)) == "png")) {
			anchors[k].href = 'javascript:showIt(\''+anchors[k].href+'\')';
		}
	}
}
function showIt(thisOne) {
	sp = document.createElement('div');
	sp.id = "displayer";
	document.getElementsByTagName('body')[0].appendChild(sp);
	var parag = document.createElement("img");
	if (document.all) {
		parag.src = thisOne;
		parag.style.visibility = "hidden";
	}
	else {
		parag.setAttribute("src", thisOne);
		parag.setAttribute("style", "visibility:hidden;");
	}
	parag.id = 'overview';
	document.getElementsByTagName("body")[0].insertBefore(parag, document.getElementsByTagName("body")[0].childNodes[0]);
	isLoaded = setInterval ("loadIt()", 50);
}
function loadIt() {
	if (document.getElementById('overview').complete == true) {
		document.getElementById('overview').style.margin = " 0 0 0 -"+ (document.getElementById('overview').offsetWidth/2) + "px";
		document.getElementById('overview').style.visibility = "visible";
		document.onclick = function () {
			document.onclick = "";
			the_div = document.getElementById('displayer');
			the_div.parentNode.removeChild(the_div);
			the_div = document.getElementById('overview');
			the_div.parentNode.removeChild(the_div);
		}
		clearInterval(isLoaded);
	}
}
