// JavaScript Document
function PopupCentrerNl(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);
}

function goImprimer(){
	PopupCentrerNl('','popup',680,700,'menubar=no,scrollbars=yes,statusbar=no');
	document.forms['versionImprimable'].submit();
}


function goImprimer2(){
	PopupCentrerNl('','popup',680,700,'menubar=no,scrollbars=yes,statusbar=no');
	document.forms['versionImprimableFiches'].submit();
}

/********************************************************
*  EXTERNAL LINK
********************************************************/
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 } 
}

function correctPNG() 
{
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
	 }
  }
}


function masqueSaisieChaineNum(obj, masque) {
  var ch = obj.value;
  var tmp = "";
  ch.toString();
  
  if (window.event.keyCode != 37 && window.event.keyCode != 39 && window.event.type != "keydown" && window.event.keyCode != 8 && window.event.keyCode != 46) {
    
		if (window.event.type == "keyup") {
		  
		      // reconstitution de la chaine ss espace ni lettre
			  for (i=0; i<ch.length; i++) {
					if (!isNaN(ch.charAt(i)) && ch.charAt(i) != " "){
						tmp += ch.charAt(i);
					}
			  }		  
		      // vidage de la chaine
			  ch = ""
		  	  var j = 0;
		  	  // parsage pour reconstituer la chaine avec le masque
			  for (i=0; i<masque.length; i++) {
					if (masque.charAt(i)  == "0") {
						  if (tmp.charAt(j) != "" ) {
							ch += tmp.charAt(j);
							j++;
						  }else{
							ch += ""
						  }
					}else if(tmp.charAt(j) != ""){ 
						ch += masque.charAt(i);
					}
			  }
			  
		}
	  
		obj.value = ch;
  }
  
}


Event.observe(window, 'load', externalLinks, false);

