var g_objImagePhotos = new Array();
var g_intNumPhotos = 6;
var g_intPhotoShownId = 0;
var g_intOldParaId = -1;
function init() {
	// chargement des images
	for ( l_intCount = 1; l_intCount <= g_intNumPhotos; ++l_intCount ) {
		g_objImagePhotos[l_intCount] = new Image();
		g_objImagePhotos[l_intCount].src = "photos/" + l_intCount  + ".jpg";
	}
	g_intPhotoShownId = Math.round(Math.random()*(g_intNumPhotos));
	changePhoto();
}
function changePhoto() {
	if ( g_intPhotoShownId==g_intNumPhotos ) {
		g_intPhotoShownId = 1;
	} else {
		++g_intPhotoShownId;
	}
	document.getElementById('mainPhoto').style.background = "url('"+g_objImagePhotos[g_intPhotoShownId].src+"') no-repeat right";
	setTimeout("changePhoto();",10000);
}
function showPara( p_intParaId ) {
	if ( g_intOldParaId != -1 ) { 
		document.getElementById( g_intOldParaId ).style.display = "none"; 
		document.getElementById( 'title'+g_intOldParaId ).style.textTransform = "none";
		document.getElementById( 'title'+g_intOldParaId ).style.color = "#202020";
	}
	if ( g_intOldParaId != p_intParaId ) { 
		document.getElementById( p_intParaId ).style.display = "block";
		document.getElementById( 'title'+p_intParaId ).style.textTransform = "uppercase";
		document.getElementById( 'title'+p_intParaId ).style.color = "#606060";
	} 
	g_intOldParaId = ( g_intOldParaId == p_intParaId ? -1 : p_intParaId );
}
function openUL( l_intId ) {
	var l_objUL = document.getElementById('rep').getElementsByTagName('ul');
	for ( var l_intCount = 0; l_intCount < l_objUL.length; ++l_intCount ) {
		if ( l_intCount == l_intId ) {
			l_objUL[l_intCount].style.display = "block";
		} else {
			l_objUL[l_intCount].style.display = "none";
		}
	}
}
function playWithFlashPlayer (p_strFileMp3) {
	
	parent.document.getElementById('flashPlayer').innerHTML =
		'<embed src="player.swf" width="385" height="19" border="0" type="application/x-shockwave-flash" '+
				'pluginspage="http://www.macromedia.com/go/getflashplayer" '+
				'flashvars="file='+p_strFileMp3+'&showdigits=true&autostart=true&shuffle=false" /> ';
	
}
function rollOverImg( p_objElement, p_boolMakeOn ) { // faire changer des images JPG quand on passe sur un <div> qui en contient
	var l_objAllImgInElement = p_objElement.getElementsByTagName('img');
	var l_strImgSrc = ''
	for ( var l_intCount = 0; l_intCount < l_objAllImgInElement.length; ++l_intCount ) {
		l_strImgSrc = l_objAllImgInElement[l_intCount].src;
		if ( p_boolMakeOn ) {
			l_strImgSrc = replace(l_strImgSrc,'.jpg','ON.jpg');
		} else {
			l_strImgSrc = replace(l_strImgSrc,'ON.jpg','.jpg');
		}
		l_objAllImgInElement[l_intCount].src = l_strImgSrc;
	}
}
function rollImg ( p_objElementImg, p_boolMakeOn ) { // faire changer une image GIF quand on passe dessus
	l_strImgSrc = p_objElementImg.src;
	if ( p_boolMakeOn ) {
		p_objElementImg.src = replace(l_strImgSrc,'.gif','ON.gif');
	} else {
		p_objElementImg.src = replace(l_strImgSrc,'ON.gif','.gif');
	}
}
function goLink( p_objElement ) {
	var l_objAllHrefInElement = p_objElement.getElementsByTagName('a');
	window.location.href = l_objAllHrefInElement[0].href;
}
function showImg( p_objElement ) {
	var l_strImgSrc = replace(p_objElement.src,'mini.jpg','.jpg');
	window.open(l_strImgSrc,'photos','directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,width=640,height=830');
}
function lightImg( p_objElement, p_boolMakeOn ) {
	p_objElement.style.filter = (p_boolMakeOn ? 'alpha(opacity=60)' : 'none');
}
function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}
