function popupImage( img )
{
  var largeur = 0;
  var hauteur = 0;
  
  var top  = 10;
  var left = 10;
  
	var titre = "Aperçu de l'image";
	
	w = open( "", 'image', 'left='+left+',top='+top+',width=' + largeur + ',height=' + hauteur + ',status=yes,toolbar=no,scrollbars=yes,resizable=yes,menubar=no,directories=no' );
	
	w.document.write( "<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>" );
	w.document.write( "<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+60,document.images[0].height+110); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>" );
	w.document.write( "<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>" );
	w.document.write( "<table width=100% height=100%><tr><td><center><table align=center><tr><td align=center><a href='#' onclick='self.close();'><IMG src='"+img+"' border=0 style='border: 5px solid black;'><a></td></tr></table></center></td></tr></table>" );
	w.document.write( "</BODY></HTML>" );
	
	w.document.close();
}

function popupc( page, id, largeur, hauteur, options )
{
  var top  = (screen.height - hauteur) / 2;
  var left = (screen.width - largeur) / 2;
  if( largeur == -1 ) largeur = screen.width;
  if( hauteur == -1 ) hauteur = screen.height;

  window.open( page, id, "top="+top+", left="+left+", width="+largeur+", height="+hauteur+","+options );
}

function popup( page, idpage, largeur, hauteur, options ) {
  var top  = 20; var left = 20;
  window.open( page, idpage, "top="+top+", left="+left+", width="+largeur+", height="+hauteur+", "+options );
}

function detectPopupBlocker()
{
  var myTest = window.open("about:blank","","directories=no,height=20,width=20, menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,top=0,location=no");
  if (!myTest) {
	  alert("Anti-popup détecté.");
  } else {
    myTest.close();
    alert("Aucun anti-popup détecté.");
  }
}

function ajouterAuxFavoris()
{
  browserName = navigator.appName;
  browserVer  = parseInt(navigator.appVersion);
  if( browserName == "Microsoft Internet Explorer" & browserVer >= 4 ) {
    window.external.AddFavorite( 'http://www.generation-implant.com/', 'Génération-Implant' );
  }
}

function getElement( elem )
{
  if( document.getElementById ) {
    if( document.getElementById(elem) ) return document.getElementById(elem);
  } else if( document.all ) {
    if( document.all[elem] ) return document.all[elem];
  }
  return null;
}

function getValueElement( elem )
{
  if( document.getElementById ) {
    if( document.getElementById(elem) ) return document.getElementById(elem).value;
  } else if( document.all ) {
    if( document.all[elem] ) return document.all[elem].value;
  }
  return null;
}

function setValueElement( elem, val )
{
  if( document.getElementById ) {
    document.getElementById(elem).value = val;
  } else if( document.all ) {
    document.all[elem].value = val;
  }
}

function setFocus( elem )
{
  if( document.getElementById ) {
    document.getElementById(elem).focus();
  } else if( document.all ) {
    document.all[elem].focus();
  }
}

function disableElement( elem )
{
  if( document.getElementById ) {
    if( document.getElementById(elem) != null ) document.getElementById(elem).disabled = true;
  } else if( document.all ) {
    if( document.all[elem] != null ) document.all[elem].disabled = true;
  }
}

function changeStyle( elem, style ) {
	if (document.all) {
		// pour ie
		document.getElementById(elem).style.setAttribute('cssText', style);
	} else {
		document.getElementById(elem).setAttribute('style', style);
	}
}

function checkAll( check, label, nb )
{
	var oDiv = null;
	
	for ( var i=0; i < nb; i++ )
	{
    if( document.getElementById ) {
  		oDiv = document.getElementById(label+i);
    } else if( document.all ) {
      oDiv = document.all[label+i];
    }
		if ( check == 0 )
			oDiv.checked = false;
		else
			oDiv.checked = true;
	}
}

function hideSelects( action )
{
  //possible values for action are 'hidden' and 'visible'
  if( action != 'visible' ) action = 'hidden';

  if( !navigator.appName.indexOf("MSIE 7") )
  {
    for( var S = 0; S < document.forms.length; S++ )
    {
      for( var R = 0; R < document.forms[S].length; R++ ) {
        if( document.forms[S].elements[R].options ) {
          document.forms[S].elements[R].style.visibility = action;
        }
      }
    } 
  }
}
