// Calcule les coordonnées de l'image zoom
function position_img(id) {
	document.getElementById(id).style.left='1';
	document.getElementById(id).style.top = document.body.scrollTop +1;
	if (document.getElementById(id).height > document.body.clientHeight) {
		var coef_img = document.body.clientHeight/document.getElementById(id).height;
		document.getElementById(id).height = document.body.clientHeight -4;
	}
}

// FONCTION POPUP CENTRER
function popup(page,nom,largeur,hauteur,options) {
  var top=(screen.height-hauteur)/2;
  var left=(screen.width-largeur)/2;
  window.open(page,nom,"top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}
// Affiche le calque
function montre(id) {	
	if (document.getElementById) {
		document.getElementById(id).style.visibility="visible";
	} else if (document.all) {
		document.all[id].style.visibility="visible";  
	} else if (document.layers) {
		document.layers[id].visibility="visible";
	} 
} 

// Cache le calque
function cache(id) {
	if (document.getElementById) {
		document.getElementById(id).style.visibility="hidden";
	} else if (document.all) {
		document.all[id].style.visibility="hidden";
	} else if (document.layers) {
		document.layers[id].visibility="hidden";
	}
} 

//Recupere couleur
var defaultBodyBAckground='#000000';

function getVisibleBackgroundColor(obj){

  if(obj==null) { return defaultBodyBAckground; }
  if(obj.style && obj.style.backgroundColor!='' && obj.style.backgroundColor!='none')
  { return obj.style.backgroundColor; }
  var bgColorByStylesheet=getBackgroundColorFromStyleSheetFor(obj);
  if(bgColorByStylesheet!=null) { return bgColorByStylesheet; }
  if(obj.bgColor && obj.bgColor!='') { return obj.bgColor; }
  return getVisibleBackgroundColor(obj.parentNode);
}
  
function getBackgroundColorFromStyleSheetFor(obj){
  var returnColor=null;
  for(i=0 ; i<document.styleSheets.length ; i++)
  {
	var ss=document.styleSheets[i];
	var length=0;
	if(ss.cssRules) { length=ss.cssRules.length; }
	else { length=ss.rules.length; }

	for(j=0 ; j<length ; j++)
	{
	  var cssr=null;
	  if(ss.cssRules) { cssr=ss.cssRules[j]; }
	  else { cssr=ss.rules[j]; }
	  var selector=cssr.selectorText;
	  switch(selector.charAt(0))
	  {
		case '#' :
		 if(obj.id!=null
			&& obj.id!=''
			&& obj.id.toUpperCase()==selector.substr(1).toUpperCase())
		 {
		   if(cssr.style.backgroundColor!=null
			  && cssr.style.backgroundColor!='none'
			  && cssr.style.backgroundColor!='')
		   { returnColor=cssr.style.backgroundColor; }
		  }
		  break;
		case '.' :
		  if(obj.className!=null
			&& obj.className!=''
			&& obj.className.toUpperCase()==selector.substr(1).toUpperCase())
		  {
		    if(cssr.style.backgroundColor!=null
			  && cssr.style.backgroundColor!='none'
			  && cssr.style.backgroundColor!='')
			{ returnColor=cssr.style.backgroundColor; }
		  }
		  break;
		default :
		  if(obj.tagName.toUpperCase()==selector.toUpperCase())
		  {
		    if(cssr.style.backgroundColor!=null
			   && cssr.style.backgroundColor!='none'
			   && cssr.style.backgroundColor!='')
			{ returnColor=cssr.style.backgroundColor; }
		   }
		   break;
	  }
    }
  } 
  return returnColor;
}