var e_header = "Lütfen aşağıdaki bilgileri\n"
       +"kontrol ediniz:\n\n";

var e_asn_invalid = "Ara Sınav Notu bilgisi.\n";


function GBNHesapla()
{
  e = "";
  var asn = getAraSinavNotuValue();
  if ( isEmpty(asn) ) e += e_asn_invalid;
  if (checkError(e, true)) return false;
  return setSonuc( sonucHesapla(asn) );
}
function getAraSinavNotuValue()
{
  asnx = MM_findObj("AraSinavNotu").value;
  return (isEmpty(asnx)?null :
    (parseInt(asnx)>100||parseInt(asnx)<0)?null:asnx);
}
function sonucHesapla(asn)
{
  if (isEmpty(parseInt(asn))) return 0;
  maxnot = 71;
  MaxNmr = (MinNmr = 
    (grup = parseInt(asn / 7)) * 7) + 6;
  MinNmr = (MinNmr <   0) ? 0   : MinNmr;
  MinNmr = (MinNmr >  98) ? 98  : MinNmr;
  MaxNmr = (MaxNmr > 100) ? 100 : MaxNmr;
  MaxNmr = (MaxNmr <   6) ? 6   : MaxNmr;

  if (asn == MinNmr 
  || asn == MinNmr + 1) 
      icGrup = 0;
  else if (asn == MinNmr + 2 
  || asn == MinNmr + 3)
      icGrup = 1;
  else if (asn >= MaxNmr - 2
  && asn <= MaxNmr)
      icGrup = 2;
  if (icGrup == "undefined") return 0;
  return parseInt((maxnot - 
    (grup * 3)) - icGrup);
}
function setSonuc(sonucnotu)
{
  o = MM_findObj("GBNSonuc");
  o.value = parseInt(sonucnotu);
}

function verifyCompatibleBrowser(){ 
    this.ver=navigator.appVersion 
    this.dom=document.getElementById?1:0 
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
    this.ie4=(document.all && !this.dom)?1:0; 
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
 
    this.ns4=(document.layers && !this.dom)?1:0; 
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
    return this 
} 
bw=new verifyCompatibleBrowser();

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function checkError(e, dispwarn)
{
  if ( isEmpty(e) )
    return false;
  if (dispwarn)
    alert(e_header + e);
  return true;
}
function isEmpty(ieo)
{
  return (
      ieo == "undefined" || 
      ieo == null || 
      ieo.toString().length <= 0
  );
}
function cutFloatties()
{
  arg = cutFloatties.arguments;
  argl = arg.length;

  if (argl <= 0) return;

  for (i = 0; i < argl; i++)
    if (arg[i].toString().length > FLOATDEEP)
      arg[i] = arg[i].toString().substr(0, FLOATDEEP);

  return arg;
}
function openWin(href, target, width, height)
{
	window.open(href, target, 'width=' + width +', height=' + height + ', top=0, toolbar=0, location=0, directories=0, status=0, menuBar=0, scrollBars=0, resizable=0');
	return false;
}
