/*  Ackumulator
-----------------*/

function ResetForm1(form)
{
form.ackvol.value="";
}

function ResetForm2(form)
{
form.arbvol.value="";
}

function ResetForm3(form)
{
form.forl.value="";
}

function berakna(form)
{
minne=1-(Math.pow((form.larb.value)/(form.harb.value),(1/1.5)));
return minne;
}

function ClearForm(form)
{
}

function compute1(form)
{
if (check1(form)==false)
{
ResetForm1(form);
}
else
{
check1(form);
berakna(form);
form.ackvol.value=Math.round(100*(((form.arbvol.value)*(form.larb.value/form.forl.value))/minne))/100;
}
}

function compute2(form)
{
if (check2(form)==false)
{
ResetForm2(form);
}
else
{
check2(form);
berakna(form);
form.arbvol.value=Math.round(100*((form.ackvol.value*minne)/(form.larb.value/form.forl.value)))/100;
}
}

function compute3(form)
{
if (check3(form)==false)
{
ResetForm3(form);
}
else
{
check3(form);
berakna(form);
form.forl.value=Math.round(100*((form.arbvol.value*form.larb.value)/(form.ackvol.value*minne)))/100;
}
}

function check1(form)
{
if (form.arbvol.value.length==0||form.larb.value.length==0||form.harb.value.length==0||form.forl.value.length==0)
{
alert("Erforderliga indata saknas!");
return false;
}
else
return true;
}

function check2(form)
{
if (form.ackvol.value.length==0||form.larb.value.length==0||form.harb.value.length==0||form.forl.value.length==0){
alert("Erforderliga indata saknas!");
return false;
}
else
return true;
}

function check3(form)
{
if (form.ackvol.value.length==0||form.arbvol.value.length==0||form.larb.value.length==0||form.harb.value.length==0){
alert("Erforderliga indata saknas!");
return false;
}
else
return true;
}

var now = new Date();
var year = now.getYear();
var month = (((now.getMonth()+1) < 10) ? "0" : "") + (now.getMonth()+1);
var day = ((now.getDate() < 10) ? "0" : "") + now.getDate();
var MonthDayYear =(" "+year+month+day+" ");


function print(form)
{
text=("<HEAD><TITLE>Utskrift beräkning ackumulator</TITLE></HEAD>");
text=(text+"<BODY><FONT SIZE=4><B>Beräkning ackumulator</B></FONT>");
text=(text+"<P>");
text=(text+MonthDayYear);
text=(text+"<P>");
text=(text+"<B>Indata & resultat</B><P>");
text=(text+"<TABLE WIDTH=250><tr><td WIDTH=120>Ackumulatorvolym =<td WIDTH=60><B>"+form.ackvol.value+"</B><td WIDTH=40>l<tr><td>Arbetande volym =<td><B>"+form.arbvol.value+"</B><td>l<tr><td>Förladdningstryck =<td><B>"+form.forl.value+"</B><td>bar<tr><td>Högsta arbetstryck =<td><B>"+form.harb.value+"</B><td>bar<tr><td>Lägsta arbetstryck =<td><B>"+form.larb.value+"</B><td>bar</table><P>");
text=(text+"</body></html>");
msgWindow=window.open("","displayWindow","toolbar=yes,width=400,height=400,directories=no,status=no,scrollbars=yes,resize=yes,menubar=yes")
msgWindow.document.write(text)
msgWindow.document.close()
}

