//Identification Navigateurs
var mac = (navigator.userAgent.indexOf("Mac") != -1);
var browserName = navigator.appName;
var browserVer = parseInt(navigator.appVersion);
var ie4 = (browserName == "Microsoft Internet Explorer") && navigator.appVersion.indexOf('MSIE 4')>0;
var ie5 = (browserName == "Microsoft Internet Explorer") && navigator.appVersion.indexOf('MSIE 5')>0;
var ie6 = (browserName == "Microsoft Internet Explorer") && navigator.appVersion.indexOf('MSIE 6')>0;
var ie = (browserName == "Microsoft Internet Explorer");
var ns = (browserName == "Netscape" && browserVer <6 && navigator.vendor != "Netscape6");
var ns6 = (navigator.vendor == "Netscape6");

function preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

home = new Array('organ','clar','mater','conti','fotog','vera');

function affect(witch){
	for(i = 0; i < home.length; i++){
		if(witch == home[i]){
			show(witch);
			rollOn("indik"+i);
		}
		else{
			hide(home[i]);
			rollOff("indik"+i);
		}
	}
}

function rollOff(ou){
	obj = eval("document." + ou);
	if(obj){
		obj.src = "/common/images/common/spacer.gif";
	}
}

function rollOn(ou){
	obj = eval("document." + ou);
	if(obj){
		obj.src = "/common/images/home/arrow.gif";
	}
}

//Affiche un layer||div
function show(cible){
	if(ns && document.layers[cible]){
		document.layers[cible].visibility = 'show';
	}
	else if(ie || ns6){
		document.getElementById(cible).style.visibility = 'visible';
	}
}

//Masque un layer||div
function hide(cible){
	if(ns && document.layers[cible]){
		document.layers[cible].visibility = 'hide';
	}
	else if(ie || ns6){
		document.getElementById(cible).style.visibility = 'hidden';
	}
}

//Position layers||div
function posDyn(page,cible,horiz,vert){

	//Constante largeur du site
	var cartouche = 775;

	//Recupere Espace affichage
	if(ns){
		client_width = window.innerWidth;
	}
	if(ie || ns6){
		client_width = document.body.offsetWidth;
	}

	if(client_width >= cartouche){
		//Correction positionnement
		if(mac){ // MACOS
			if(ns){
				if(page == "home"){var vertplus = 0;var horizplus = 0;}
			}
			if(ie){
				if(page == "home"){var vertplus = 0;var horizplus = 8;}
			}
			if(ns6){
				if(page == "home"){var vertplus = 0;var horizplus = 8;}
			}
		}
		else{ // WINDOWS
			if(ns){
				if(page == "home"){var vertplus = 0;var horizplus = 0;}
			}
			if(ie){ //talon
				if(page == "home"){var vertplus = 0;var horizplus = 0;}
			}
			if(ns6){
				if(page == "home"){var vertplus = 0;var horizplus = 8;}
			}
		}	
		
		if(ns){
			document.layers[cible].left = ((client_width/2)-(cartouche/2)) + horiz + horizplus;
			document.layers[cible].top = vert + vertplus;
		}
		else if(ie){
			document.getElementById(cible).style.left = ((client_width/2)-(cartouche/2)) + horiz + horizplus;
			document.getElementById(cible).style.top = vert  + vertplus;
		}
		else if(ns6){
			document.getElementById(cible).style.left = ((client_width/2)-(cartouche/2)) + horiz  + horizplus;
			document.getElementById(cible).style.top = vert  + vertplus;
		}
	}
	
	else if(client_width < cartouche){
		//Correction positionnement
		if(mac){ // MACOS
			if(ns){
				if(page == "home"){var vertplus = 0;var horizplus = 0;}
			}
			if(ie){
				if(page == "home"){var vertplus = 0;var horizplus = 8;}
			}
			if(ns6){
				if(page == "home"){var vertplus = 0;var horizplus = 8;}
			}
		}
		else{ // WINDOWS
			if(ns){
				if(page == "home"){var vertplus = 0;var horizplus = 0;}
			}
			if(ie){
				if(page == "home"){var vertplus = 0;var horizplus = 8;}
			}
			if(ns6){
				if(page == "home"){var vertplus = 0;var horizplus = 8;}
			}
		}	
		
		if(ns){
			document.layers[cible].left = horiz + horizplus;
			document.layers[cible].top = vert + vertplus;
		}
		else if(ie){
			document.getElementById(cible).style.left = horiz + horizplus;
			document.getElementById(cible).style.top = vert + vertplus;
		}
		else if(ns6){
			document.getElementById(cible).style.left = horiz + horizplus;
			document.getElementById(cible).style.top = vert + vertplus;
		}
	}
}
