/*  Rör
-----------------*/

function ClearForm(form)
{
}

function ResetForm(form)
{
form.hast.value="";
form.typ.value="";
form.tfall.value="";
}

function compute(form)
{
if (check(form)==false)
{
ResetForm(form);
}
else
{
ResetForm(form)
form.hast.value=Math.round(100*((form.flode.value*21.23)/(form.rord.value*form.rord.value)))/100;
re=form.hast.value*form.rord.value*1000/form.visk.value;
if(re <= 2300)
{
form.typ.value="laminär";
form.tfall.value=Math.round(100*((0.285*form.visk.value*form.langd.value*form.hast.value)/(form.rord.value*form.rord.value)))/100;
}
else
{
form.typ.value="turbulent";
form.tfall.value=Math.round(100*((1.41*form.langd.value*form.hast.value*form.hast.value)/(Math.sqrt(Math.sqrt(re))*form.rord.value)))/100;
}
}
}


function check(form)
{
if (form.flode.value.length==0||form.rord.value.length==0||form.visk.value.length==0||form.langd.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äkningrör</TITLE></HEAD>");
text=(text+"<BODY><FONT SIZE=4><B>Beräkning rör</B></FONT>");
text=(text+"<P>");
text=(text+MonthDayYear);
text=(text+"<P>");
text=(text+"<B>Indata</B><P>");
text=(text+"<TABLE WIDTH=250><tr><td WIDTH=120>Flöde =<td WIDTH=60><B>"+form.flode.value+"</B><td WIDTH=40>l/m<tr><td>Inv. rördiameter =<td><B>"+form.rord.value+"</B><td>mm<tr><td>Viskositet =<td><B>"+form.visk.value+"</B><td>cst<tr><td>Rörlängd =<td><B>"+form.langd.value+"</B><td>m</table><P>");
text=(text+"<P><BR>");

text=(text+"<B>Resultat</B><P>");

text=(text+"<TABLE  WIDTH=250><tr><td WIDTH=120>Strömningshast. =<td WIDTH=60><B>"+form.hast.value+"</B><td WIDTH=40>m/s<tr><td>Strömningstyp =<td><B>"+form.typ.value+"</B><td><tr><td>Tryckfall =<td><B>"+form.tfall.value+"</B><td>bar</table><P>");
text=(text+"<P><BR>");
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()
}

