function openit(page){
	var H = screen.height/ 4;
	var L = screen.width/ 4;
	var hauteur_popup=screen.height/2;
	var largeur_popup=screen.width/2;
	pop_up = window.open(page,"Popup"+Math.floor(Math.random() * 34)+"p","scrollbars=yes,resizable=yes,height="+hauteur_popup+",width="+largeur_popup+",top="+H+",left="+L);
}
function NewWindow(mypage,myname,w,h,scrolll)
    {
        var win = null;
        LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
        TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
        LeftPosition = 20//LeftPosition - 7
        TopPosition = 20//TopPosition ;
        settings ='height='+(h>0?h:7*(screen.height/8))+',width='+(w>0?w:7*(screen.width/8))+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable=0,menubar=0,toolbar=0'
        win = window.open(mypage,"bob",settings)
        if(win.window.focus){win.window.focus();}
    }

function verifTxtBoxInteger(control)
{
	if(/[^0-9]/.test(control.value))
		control.value = control.value.toLowerCase().replace(/([^0-9])/g,"");
	
	if(/^0[0-9]/.test(control.value))
		control.value = control.value.toLowerCase().replace(/(^0[0-9])/,"0");
}

function open_window(page, hauteur, largeur){
	var hauteur_popup=7*(screen.height/8)//screen.height-200;
	var H = (screen.height) / 8;
	var largeur_popup=7*(screen.width/8);
	var L = ((screen.width) / 8)/2;
	pop_up = window.open(page,"Popup"+Math.floor(Math.random() * 34)+"p","scrollbars=yes,resizable=yes,scrollbars=yes,height="+hauteur_popup+",width="+largeur_popup+",top="+H+",left="+L);
}	

function verifTxtBoxDecimal(control)
{
	if(/[^0-9.]/.test(control.value))
		control.value = control.value.toLowerCase().replace(/([^0-9.])/g,"");
		
	if(/^\.|^0[0-9]/.test(control.value))
		control.value = control.value.toLowerCase().replace(/(^\.|^0[0-9])/,""); //control.value = "0.";
	
	if(control.name.substr(0,6) == "rabais")
		verifTxtBoxDecimalRabais(control);
	
	if(/\.$/.test(control.value))
	{
		avant_le_point = control.value.substr(0, control.value.length-1);
		if(avant_le_point.indexOf(".") > 0)
			control.value = avant_le_point;
	}		
	
	if(/[\d+(\.\d\d)?$]/.test(control.value))
	{
		concat_value = control.value;
		pos = control.value.indexOf(".");
		if(pos > 0)
		{
			avant_le_point = control.value.substr(0,pos+1);
			apres_le_point = control.value.substr(pos+1);
			if(apres_le_point.indexOf(".") >= 0)
			{
				apres_le_point = apres_le_point.replace(".","");
				concat_value = avant_le_point + apres_le_point;
				//concat_value = Math.round(concat_value*100)/100;
				control.value = concat_value;
			}
			
			longueur = control.value.substr(pos)
			if(longueur.length > 3)
				control.value = control.value.substr(0,pos+3);
		}
	}
}

function do_imc(lng){
	if(valideimc(lng)){
	taille=document.getElementById("taille_metrique").value*1>0?document.getElementById("taille_metrique").value/100:mk_cm(document.getElementById("taille_im_pi").value,document.getElementById("taille_im_po").value)
	poids=document.getElementById("poids_metrique").value*1>0?document.getElementById("poids_metrique").value:mk_kg(document.getElementById("poids_im").value)
	indice=calc_imc(taille,poids)
	affiche_imc(indice,lng)
	}
}
function affiche_imc(indice,lng){
	sp=document.getElementById("msg")
	sp.style.display="block"
	if(lng=="fr")
		sp.innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>VOTRE IMC: </b><span style='color:darkblue'><b>"+indice+"</b></span><br><br>"
	else
		sp.innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>YOUR BMI: </b><span style='color:darkblue'><b>"+indice+"</b></span><br><br>"
	if(indice>18.5&& indice<=25)
		sp.innerHTML=sp.innerHTML+arr_msg[1]
	else if(indice>25&& indice<=30)
		sp.innerHTML=sp.innerHTML+arr_msg[2]
	else if(indice>30 && indice<=35)
		sp.innerHTML=sp.innerHTML+arr_msg[3]
	else if(indice>35 && indice<=40)
		sp.innerHTML=sp.innerHTML+arr_msg[4]
	else if(indice>40 )
		sp.innerHTML=sp.innerHTML+arr_msg[5]
	else
		sp.innerHTML=sp.innerHTML+arr_msg[0]
}
function calc_imc(taille,poids){
	return Math.round((poids/(taille*taille)*10))/10
}
function mk_kg(lbs){
	return lbs*0.45359237
}
function mk_cm(pieds,po){
	pos=((pieds*12)*1)+po*1
	return (pos*2.54)/100
}
function clearall(controle){
	if(controle.id=="taille_metrique"){
		document.getElementById("taille_im_pi").value=""
		document.getElementById("taille_im_po").value=""
	}
	else if(controle.id=="taille_im_pi" || controle.id=="taille_im_po"){
		document.getElementById("taille_metrique").value=""
	}
	else if(controle.id=="poids_metrique" ){
		document.getElementById("poids_im").value=""
	}
	else if(controle.id=="poids_im" ){
		document.getElementById("poids_metrique").value=""
	}
}
function valideimc(lng){
	fl_taille=0
	fl_poids=0
	if(document.getElementById("poids_metrique").value*1>0 || document.getElementById("poids_im").value*1>0)
	fl_poids=1
	if(document.getElementById("taille_metrique").value*1>0 || document.getElementById("taille_im_pi").value*1>0)
	fl_taille=1
	if(fl_taille==1 && fl_poids==1){
		return true
	}
	else{
		if(lng=="fr"){
			ermsg="Vous devez remplir les champs suivants :\n"
			if(fl_taille==0)
			ermsg=ermsg+"\n-\t Une taille valide"
			if(fl_poids==0)
			ermsg=ermsg+"\n-\t Un poids valide"
		}
		else{
			ermsg="Please fill all following fields :\n"
			if(fl_taille==0)
			ermsg=ermsg+"\n-\t A valid height"
			if(fl_poids==0)
			ermsg=ermsg+"\n-\t A valid weight"
		}
		alert(ermsg)
		return false
	}
}
function VersionNavigateur(Netscape, Explorer) {
	if ((navigator.appVersion.substring(0,3) >= Netscape && navigator.appName == 'Netscape') ||
	(navigator.appVersion.substring(0,3) >= Explorer && navigator.appName.substring(0,9) == 'Microsoft'))
	return true;
	else return false;
}
function printer(suff){
	document.getElementById('contenu').value=suff;
	win=window.open("print.html","mywin");
}

