// JavaScript Document
function PopupCentrer(page,name,largeur,hauteur,options) 
{
var top=(screen.height-hauteur)/2;
var left=(screen.width-largeur)/2;
window.open(page,name,"top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}




// Gestion des PNG //

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])


if ((version >= 5.5) && (version < 7) )//&& (document.body.filters)) 
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='image');\"></span>" 
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}

// PNG //


function setLyr(obj,lyr)
{
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	var x = new getObj(lyr);
	x.style.top = newY + 'px';
	x.style.left = newX + 'px';
	//alert('X='+newX+'Y='+newY)
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	var printstring = '';
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	window.status = printstring;
	return curtop;
}


function getObj(name)
{
 if (document.getElementById)
 {
	   this.obj = document.getElementById(name);
	   this.style = document.getElementById(name).style;
 }
 else if (document.all)
 {
	   this.obj = document.all[name];
	   this.style = document.all[name].style;
 }
 else if (document.layers)
 {
	   if (document.layers[name])
	   {
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	   }
	   else
	   {
	    this.obj = document.layers.testP.layers[name];
	    this.style = document.layers.testP.layers[name];
	   }
 }
}

// Gestion des Position Layer //

//GESTION DES ERREURS ET TOOLTIP//
var inc_id = 0;
function od_tooltip(element_target_name,ttl,titre,message,mode,format)
{
	var image_tooltip = '<img src="images/interface/icones/warn.gif" width="16" height="14" align="left" />';
	switch (mode)
	{
	  case 'warn':
		image_tooltip = '<img src="images/interface/icones/warn.gif" width="16" height="14" align="left" />';
	   break;
	  case 'wrong':
		image_tooltip = '<img src="images/interface/icones/wrong.gif" width="16" height="16" align="left" />';
		break;
		case 'idea':
		image_tooltip = '<img src="images/interface/icones/idea.gif" width="11" height="16" align="left" />';
		break;
	  default:
		image_tooltip = '<img src="images/interface/icones/warn.gif" width="16" height="14" align="left" />';
	   break;
	}
	inc_id++;
	var div_container = document.createElement('div');
	div_container.setAttribute('id','div_container_'+inc_id);
	div_container.className = 'class_tooltip';

	switch (format)
	{
	  case 'bottom':
		 var tooltip_content = '<table width="200" border="0" cellspacing="0" cellpadding="0"><tr><td><img src="images/interface/icones/tooltip-top.gif" width="200" height="6" /></td></tr><tr><td><table width="200" border="0" cellpadding="4" cellspacing="0" class="tooltip_inner"><tr><td width="17" align="left" valign="top" >'+image_tooltip+'</td><td width="165" align="left" valign="middle" style="padding:0px"><strong>'+titre+' :</strong></td></tr><tr><td align="left" valign="top" colspan="2">'+message+'</td></tr></table></td></tr></table>';
	   break;
	  case 'right':
		 var tooltip_content = '<table width="200" border="0" cellspacing="0" cellpadding="0"><tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td align="left" valign="top" background="images/interface/icones/tooltip-left-border.gif"><img src="images/interface/icones/tooltip-left.gif"   /></td><td align="left" valign="top"><table width="200" border="0" cellpadding="4" cellspacing="0" class="tooltip_inner_left"><tr><td width="17" align="left" valign="top" >'+image_tooltip+'</td><td width="165" align="left" valign="middle" style="padding:0px"><strong>'+titre+' :</strong></td></tr><tr><td align="left" valign="top" colspan="2">'+message+'</td></tr></table></td></tr></table></td></tr></table>';
	  break;
	  default:
		 var tooltip_content = '<table width="200" border="0" cellspacing="0" cellpadding="0"><tr><td><img src="images/interface/icones/tooltip-top.gif" width="200" height="6" /></td></tr><tr><td><table width="200" border="0" cellpadding="4" cellspacing="0" class="tooltip_inner"><tr><td width="17" align="left" valign="top" >'+image_tooltip+'</td><td width="165" align="left" valign="middle" style="padding:0px"><strong>'+titre+' :</strong></td></tr><tr><td align="left" valign="top" colspan="2">'+message+'</td></tr></table></td></tr></table>';
	   break;
	}
	div_container.innerHTML = tooltip_content;	
	var ttarget = document.getElementById(element_target_name);
	var tparent = ttarget.parentNode;
	tparent.insertBefore(div_container,ttarget);
	div_container.className = 'class_tooltip';
	div_container.style.position = 'absolute';
	setLyr(ttarget,'div_container_'+inc_id);
	if (format == "right" && ttarget.style.width != "" )
	{
		var act_pos = parseInt(ttarget.style.width)+parseInt(document.getElementById('div_container_'+inc_id).style.left)+6;
		document.getElementById('div_container_'+inc_id).style.left = act_pos+'px';
	}
	else if(format == "bottom" && ttarget.style.height != ""  )
	{
	
		
		var act_pos = parseInt(ttarget.style.height)+parseInt(document.getElementById('div_container_'+inc_id).style.top)+6;
		document.getElementById('div_container_'+inc_id).style.top = act_pos+'px';
	}
	
	
	if (window.ActiveXObject) div_container.style.filter = "alpha(opacity=0)";
	div_container.style.visibility='visible';	
	var anim_appear = new YAHOO.util.Anim('div_container_'+inc_id, { opacity: { from: 0, to: 1} }, 1, YAHOO.util.Easing.easeOut);
	anim_appear.animate();
	var tempo = ttl*1000;
	window.setTimeout("erase_tooltip('div_container_"+inc_id+"')",tempo );
}
function erase_tooltip(id_tooltip)
{
	setTimeout("delete_node('"+id_tooltip+"')",1000);
	var anim_disappear = new YAHOO.util.Anim(id_tooltip, { opacity: { to: 0} }, 1, YAHOO.util.Easing.easeOut);
	anim_disappear.animate();
}
function delete_node(id_tooltip)
{
	var my_obj = document.getElementById(id_tooltip);
	var tparent = my_obj.parentNode;
	tparent.removeChild(my_obj);
}

function confirmerDelete(message, url){
	if(confirm(message)){
		document.location=url;
	}
}

