// Change style of navigation link to own page
function marklink()
{ var i,f;
  if (parent.frames.length<2) f=location.href; else f=parent.location.href;
  if (f.indexOf('#')<0) // Not with anchors
  {  if (f.substring(f.length-1)=='/') f+="index.htm";
    for (i=0; i<document.links.length; i++)
    { lk=document.links[i];
      if (f==lk.href && document.links[i].name=='')
      { lk.style.color="#CC0000";
        lk.style.textDecoration="none";
        lk.style.cursor="default"
} } } }

// Return true for illegal mail address
function MailErr(s)
{ var j=true, k, w='.-_%#!+~';
  if (s.indexOf('@')>0 && s.lastIndexOf('.')>2 && s.length>5)
  { j=false;
    for (i=0; i<s.length; i++)
    { k=s.charAt(i);
      if ((k<"@"||k>"Z")&&(k<"a"||k>"z")&&(k<"0"||k>"9")&& w.indexOf(k)<0)
      { j=true; break
    } }
  } return j;
}

// Check mail form
function checkform()
{ m=document.f.Text.value;
  if (m.length<60 || m.lastIndexOf(" ")<40)
  { alert ('Sorry, senseless text.'); return false; }
  if (document.f.Fa.value=="")
  { alert ('Please enter your name.'); document.f.Fa.focus(); return false; }
  m=document.f.Mail.value;
  if (MailErr(m))
  { alert ('Sorry, missing or wrong mail address.'); document.f.Mail.focus(); return false; }
  return true;
}

// Compute Erlang formula
function erl()
{ a=(document.e.anrufe.value*document.e.dauer.value)/60;
  n=document.e.ltg.value; u=1;
  for (i=1; i<=n; i++) u+=pow(a,i)/fak(i);
  document.e.besetzt.value=parseInt(((pow(a,n)/fak(n))/u + 0.005)*100)+" %";
}
function fak(i) // Faculty
{ k=1;
  for (j=1; j<=i; j++) k*=j;
  return k;
}
function pow(k,i) // Power
{ w=1;
  for (j=1; j<=i; j++) w*=k;
  return w;
}

// Satellite airtime
function calc()
{ ol=document.f.len[document.f.len.selectedIndex].value; // Net length
  ol=ol/document.f.dienst[document.f.dienst.selectedIndex].value // Bytes/s
  sf=ol*document.f.typ[document.f.typ.selectedIndex].value+3; // SkyFile compr.+login
  if (document.f.dienst.selectedIndex!=3) { sf+=15; ol+=15; } // Modem negotiating
  ol=ol*8/6+32 // MIME encoding of Outlook and PPP/POP3/SMTP steps
  document.f.skyfile.value=minsec(sf);
  document.f.outlook.value=minsec(ol);
}
function minsec(i)
{ var m,s,r="";
  if (i>59) m=parseInt(i/60); else m=0; // Netscape workaround
  s=parseInt(i%60);
  if (m<10) r="0"+m; else r=m;
  r+=":";
  if (s<10) r+="0"+s; else r+=s;
  return r;
}
