// Пересчёт молярного количества в молярную концентрацию

var n_mol1;
var n_mol2;
var c_mol=0;
var q_mol=0;
var chk_mol1=true;
var chk_mol2=true;
function resmol()
{
n_mol1=0;
n_mol2=0;
c_mol=0;
q_mol=0;
chk_mol1=true;
chk_mol2=true;
}
function helpmol()
{
	var hlp;
switch (lng) {
	case "eng":
	hlp="/eng/scripts/h01_05.html";
	break;
	case "rus":
	hlp="/scripts/h01_05.html";
	break;
	default:
	break;
	}
window.open(hlp,'help', config='height=500,width=500,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,location=yes,status=yes');
self.name="main window"
}
function conv_mol1()
{
q1=parseFloat(document.mol.q1.value.replace(/,/g,".")); 
if(isNaN(q1)){alert(alt05_01); document.mol.q1.focus(); return true;};
q1 =  Math.abs(q1)
v1=parseFloat(document.mol.v1.value.replace(/,/g,".")); 
if(isNaN(v1)){alert(alt05_02); document.mol.v1.focus(); return true;};
v1 =  Math.abs(v1)
c1_mol=q1/Math.pow(10,3*document.mol.Dq1.selectedIndex)/v1*Math.pow(10,3*document.mol.Dv1.selectedIndex)
n=0;
	while(n<6&&c1_mol<1) {n++; c1_mol = c1_mol*1000};
	n_mol1=n;
	r=Math.round(c1_mol*100)/100;
	if(r>0){c1_mol=r};
	document.mol.q1.value=q1;
	document.mol.v1.value=v1;
	document.mol.c1.value=c1_mol;
	document.mol.Dc1.selectedIndex=n;
	chk_mol1=false;
}
function rclc_mol1()
{
if(chk_mol1){alert(alt05_03); return true};
document.mol.c1.value = c1_mol*Math.pow(10,3*document.mol.Dc1.selectedIndex)/Math.pow(10,3*n_mol1);
}
function conv_mol2()
{
c2=parseFloat(document.mol.c2.value.replace(/,/g,".")); 
if(isNaN(c2)){alert(alt05_04); document.mol.c2.focus(); return true;};
c2 =  Math.abs(c2)
v2=parseFloat(document.mol.v2.value.replace(/,/g,".")); 
if(isNaN(v2)){alert(alt05_02); document.mol.v2.focus(); return true;};
v2 =  Math.abs(v2)
q2_mol=c2/Math.pow(10,3*document.mol.Dc2.selectedIndex)*v2/Math.pow(10,3*document.mol.Dv2.selectedIndex)
n=0;
	while(n<6&&q2_mol<1) {n++; q2_mol = q2_mol*1000};
	n_mol2=n;
	r=Math.round(q2_mol*100)/100;
	if(r>0){q2_mol=r};
	document.mol.c2.value=c2;
	document.mol.v2.value=v2;
	document.mol.q2.value=q2_mol;
	document.mol.Dq2.selectedIndex=n;
	chk_mol2=false;
}
function rclc_mol2()
{
if(chk_mol2){alert(alt05_03); return true};
document.mol.q2.value = q2_mol*Math.pow(10,3*document.mol.Dq2.selectedIndex)/Math.pow(10,3*n_mol2);
}