function masqueSaisieChaineNum2(obj, masque)
{
	var ch = obj.value
	var tmp = ""
	var j = 0
	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")
		{
			for (i=0; i<ch.length; i++)
			{
				if (!isNaN(ch.charAt(i)) && ch.charAt(i) != " ")
				{
					tmp += ch.charAt(i)
				}
			}
			ch = ""
			for (i=0; i<masque.length; i++)
			{
				if (masque.charAt(i) == "0") 
				{
					if (tmp.charAt(j) != "" )
					{
						ch += tmp.charAt(j)
						j++
					}
					else
					{
						ch += " "
					}
				}
				else
				{ 
					ch += masque.charAt(i) 
				}
			}
		}
		obj.value = ch
	}
}

function affiche()
{
	document.formSAP.submit();
}


function calculeLongueur(longueur,nomchamp,nomindic)
{
	var iLongueur, iLongueurRestante,type;
	
	iLongueur = document.getElementById(nomchamp).value.length;
	if (iLongueur>longueur)
	{
		document.getElementById(nomchamp).value = document.getElementById(nomchamp).value.substring(0,longueur);
		iLongueurRestante = 0;
	}
	else
	{
		iLongueurRestante = longueur - iLongueur;
	}
	if (iLongueurRestante <= 1)
	{
		document.getElementById(nomindic).innerHTML = iLongueurRestante + "/"+longueur;
	}
	else
	{
		document.getElementById(nomindic).innerHTML = iLongueurRestante + "/"+longueur;
	}
}

// Correctly handle PNG transparency in Win IE 5.5 or higher.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004

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='scale');\"></span>"
				img.outerHTML = strNewHTML
				i = i-1
		}
	}
}
window.attachEvent("onload", correctPNG);



function calculeLongueur(longueur,nomchamp,nomindic,typeentre)
{
	var iLongueur, iLongueurRestante,type;
	if(typeentre=="int")
	{
			type=parseInt(document.getElementById(nomchamp).value);
		if(!isNaN(type))
		{
			iLongueur = document.getElementById(nomchamp).value.length;
		   if (iLongueur>longueur) {
			  document.getElementById(nomchamp).value = document.getElementById(nomchamp).value.substring(0,longueur);
			  iLongueurRestante = 0;
		   }
		   else {
			  iLongueurRestante = longueur - iLongueur;
		   }
		   if (iLongueurRestante <= 1)
			  document.getElementById(nomindic).innerHTML = iLongueurRestante + "/"+longueur;
		   else
			  document.getElementById(nomindic).innerHTML = iLongueurRestante + "/"+longueur;
		}
		else
		{
			document.getElementById(nomchamp).value="";
			document.getElementById(nomindic).innerHTML = "Ce n'est pas un entier";
		}
	}
	else
	{
		iLongueur = document.getElementById(nomchamp).value.length;
		if (iLongueur>longueur)
		{
			document.getElementById(nomchamp).value = document.getElementById(nomchamp).value.substring(0,longueur);
			iLongueurRestante = 0;
		}
		else
		{
		  iLongueurRestante = longueur - iLongueur;
		}
		if (iLongueurRestante <= 1)
		{
			document.getElementById(nomindic).innerHTML = iLongueurRestante + "/"+longueur;
		}
		else
		{
			document.getElementById(nomindic).innerHTML = iLongueurRestante + "/"+longueur;
		}
	}

}


function MyGetDate(champs)
{
	IE = !(document.all?0:1);
	NS = !IE;
 dest = champs;
 if (IE) {
 // Taille du calendrier
 larg = 250;
 Long = 188;
 posX = event.screenX; posY = event.screenY;
 if (posX+larg > screen.width) posX = screen.width - larg;
 if (posY+Long > screen.height) posY = screen.height - Long;
 eval("maFen = window.open('','','top='+posY+',left='+posX+',width="+larg+",height="+Long+"');");
 maFen.focus();
 dessine();
 }
 }

 function dessine() {
 txt = '\n\n\n<!--\n\nAuteur : DarkSide <sergebertet@voila.fr> - http://www.merrouge.com/serge.htm \n\n';
txt += 'Ce script est disponible à l\'adresse : http://www.merrouge.com/calendar.zip \n\n-->\n\n\n';
 txt += '<html><head><title>Choisissez une date.</title>\n';
 txt += '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\n';
 txt += '<script>\n';
 txt += 'var now = new Date();\nIE = !(document.all?0:1);\nNS = !IE;\n';
 txt += 'months = new Array(\'Janvier\',\'Février\',\'Mars\',\'Avril\',\'Mai\',\'Juin\',\'Juillet\',\'Août\',\'Septembre\',\'Octobre\',\'Novembre\',\'Décembre\');\n';
 txt += 'mois = now.getMonth();\nan = now.getFullYear();\njour = now.getDate();\nvide = "...";\n \n';

 // Affectation des dates aux bouttons
 txt += 'function init() {\n';
 txt += 'document.calendar.curMonth.value = months[mois] + " " + an;\n';
 txt += 'document.calendar.curMonth.readOnly = true;\n';
 txt += 'now.setMonth(mois);\n';
 txt += 'now.setYear(an);\n';
 txt += 'now.setDate(1);\n';
 txt += 'for (i=0;i<now.getDay();i++) { eval("document.calendar.b"+0+i+".value = \' " + vide + " \' ;"); }\n';
 txt += 'for (i=now.getDay();i<7;i++) {\n';
 txt += ' jour = "0"+now.getDate();\n';
 txt += ' eval("document.calendar.b"+0+i+".value = \' "+jour+" \';");\n';
 txt += ' now.setDate(now.getDate()+1);\n';
 txt += ' }\n';
 txt += 'for (j=1;j<6;j++) {\n';
txt += ' for (i=0;i<7;i++) {\n';
 txt += ' if (jour==vide || now.getDate() < jour) { jour = vide; } else { jour = now.getDate(); }\n';
 txt += ' if (jour < 10) { jour = "0"+jour; }\n';
 txt += ' eval("document.calendar.b"+j+i+".value = \' "+jour+" \' ;");\n';
 txt += ' now.setDate(now.getDate()+1);\n';
 txt += ' }\n';
 txt += ' }\n';
 txt += '}\n\n';

 // Mois suivant
 txt += 'function next() {\n';
 txt += 'if (mois == 11) { mois = 0; an = an + 1; } else { mois += 1; }\n';
 txt += 'init();\n';
 txt += '}\n\n';

 // Mois précédent
 txt += 'function prev() {\n';
 txt += 'if (mois == 0) { mois = 11; an -= 1; } else { mois -= 1; }\n';
 txt += 'init();\n';
 txt += '}\n\n';

 //
 txt += 'function lz(valeur) { if (valeur < 10) return("0"+valeur); else return(valeur); }\n\n';

 // retour et fermeture du calendrier
 txt += 'function done(but) {\n';
 txt += 'txt = but.value.substr(1,2);\n';
 txt += 'if (txt == vide.substr(1,2)) return;\n';

 /*
 Si on veut l'année sur 2 digits, ajouter ligne suivante :
 txt += 'an = an+""; an = an.substr(2,2);'; // Y2K compliant :o) comme ils disent là-bas.
 */

 txt += 'txt = txt+"/"+lz(mois+1)+"/"+an;\n';
 txt += 'opener.document.' + dest.form.name + '.' + dest.name + '.value = txt;\n';
 txt += 'window.close();\n';
 txt += '}\n';

 txt += '</script>\n</head>\n<style>\n';
 txt += 'td { color: white; font-weight: bold; text-align: center; }\n';

 // Couleur des boutons
 txt += 'input { cursor: hand; font-weight: bold; text-align: center; color: #4d89c7; background-color: silver; }\n';

 // Texte
 txt += 'td { font-size: 14px; }\n';

 // Couleurs de fond de table et de document
 txt += 'body { background: white; }\n';
 txt += 'table { background: white; }\n</style>\n';
 txt += '<body leftmargin="0" topmargin="0"; onLoad="init();">\n';
 txt += '<form name="calendar">\n';
 txt += '<table border="0" cellspacing="0" cellpadding="0" bgcolor="#00CCFF" align=center>\n';
 txt += '<tr><td>Dim</td><td>Lun</td><td>Mar</td><td>Mer</td><td>Jeu</td><td>Ven</td><td>Sam</td></tr>\n';

 // Création des bouttons
 for (i=0;i<6;i++) {
 txt += '<tr>\n';
 for (j=0;j<7;j++) {
 txt += '<td><input type="button" name="b'+i+j+'" onclick="done(this)"></td>\n';
 }
 txt += '</tr>\n';
 }
 txt += '<tr><td>\n';
 txt += '<input type="button" name="bk" value="<< " onclick="prev()"></td><td colspan=5>\n';
 txt += '<input type="text" name="curMonth" size="20">\n';
 txt += '</td><td><input type="button" name="bk" value=" >>" onclick="next()">\n';
 txt += '</td></tr></table></form></body>\n';

 // Création de la page
 txt += '<script>\n';
 txt += 'init();\n';
 txt += '</script></html>\n';
 maFen.document.write(txt);
}

function copy2Clipboard(obj)
	{
		var textRange = document.body.createTextRange();
		textRange.moveToElementText(obj);
		textRange.execCommand("Copy");
	}