LIGHTCOLOR="#D7D7D7";
DARKCOLOR="#c0c0c0";


allowFocus = true;
if (document.all) {
  ver = navigator.appVersion;
  if (ver.search("MSIE")!=-1) {
    x=parseFloat(ver.slice(ver.search("MSIE")).split(";")[0].slice (4));
    if (x<5.5) {
      allowFocus = false;
    }
  }
}

function checkNumber (i,n) {
  err=0;
  if (i.value!="") {
    if (!parseInt(i.value)) {
      alert ("Ihre Mengenangabe kann nicht stimmen!");
      err=1;
    } else {
      if (i.value<0) {
        alert ("Die Mengenangabe muß positiv sein!");
        err=1;
      }
    }
  }
  if (err==1) {
    if (n) {
      eval(n+".focus()");
    }
  }
  return err;
}

function checkNumberEL (i,n) {
  err=0;
  if (i.value!="") {
    if (!parseInt(i.value)) {
      if (i.value != 0) {
        alert ("Ihre Mengenangabe kann nicht stimmen!");
        err=1;
      }
    } else {
      if (i.value<0) {
        alert ("Die Mengenangabe muß positiv sein!");
        err=1;
      }
    }
  }
  if (err==1) {
    if (n) {
      eval(n+".focus()");
    }
  }
}

function change_color (line,col) {
  if (document.all) {
    if (document.all("trCell"+line)) {
      document.all("trCell"+line).bgColor = col;
    }
  } else if (document.layers) {
    if (document["trCell"+line]) {
      document["trCell"+line].gbColor = col;
    }
  } else {
    if (document.getElementById("trCell"+line)) {
      document.getElementById("trCell"+line).bgColor = col;
    }
  }
}

function sign_line (line) {
  change_color(line,DARKCOLOR);
}

function unsign_line (line) {
  change_color(line,LIGHTCOLOR);
}


clicked_i=-1;
function set_clicked (i) {
  clicked_i=i;
}
function clicked_tr_donoting (i) {
  if (clicked_i!=i) {
    return true;
  } else {
    clicked_i=-1;
  }
  return false;
}

function clicked_tr (a,i) {
  if (clicked_tr_donoting(i)) {
    document.location=a;
  }
}

function clicked_input (i) {
  clicked_i=i;
}


function openwin (url, name, x, y, sb) {
  if (!sb) {
    sb="auto";
  }
  if (!x) {
    x=640;
  }
  if (!y) {
    y=480;
  }
  if (name) {
    if (url) {
      x=window.open ("load.html", name, "width="+x+", height="+y+", scrollbars="+sb);
      x.document.writeln ("<HTML>");
      x.document.writeln ("<HEAD>");
      x.document.writeln ("<TITLE>Quester - lade Seite ...</TITLE>");
      x.document.writeln ("</HEAD>");
      x.document.writeln ("<BODY topmargin=\"0\" leftmargin=\"0\" bgcolor=\"#E4E4E4\">");
      x.document.writeln ("<TABLE width=\"100%\" height=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">");
      x.document.writeln ("<TR>");
      x.document.writeln ("<TD class=\"background\" width=\"100%\" height=\"100%\" align=\"center\" valign=\"middle\">");
      x.document.writeln ("<FONTface=\"Arial\"><FONT color=\"red\"><B>Lade Seite ...</B></FONT>");
      x.document.writeln ("<BR><BR><FONT size=\"-1\">(Bitte warten)<FONT></FONT>");
      x.document.writeln ("</TD>");
      x.document.writeln ("</TR>");
      x.document.writeln ("</TABLE>");
      x.document.writeln ("</BODY>");
      x.document.writeln ("</HTML>");
      if (allowFocus) {
        x.focus();
      }
      x=window.open (url ,name ,"width="+x+", height="+y+", scrollbars="+sb);
    }
  }
}


function openHelp (i) {
  if (i) {
    openwin ("help.do?event=show&id="+i,"helpwindow",400,300);
  } else {
    openwin ("help.do?event=select","helpwindow",400,300);
  }
}

function openInfo (index) {
  openwin ("basket.do?event=showInfo&basketIndex="+index,"infowindow",400, 400);
}

function openPriceQuery (article, quantity, unit) {
  if (!unit) {
    unit="ST";
  }
  if (!quantity) {
    quantity=1;
  }
  openwin ("article.do?event=priceQuery&article="+article+"&quantity="+quantity+"&unit="+unit,"pricequery", 600, 310);
}




function onEnter(el, ek) {
  if (window.event.keyCode == 13) {
    nextField (el, ek);
  }
}



function nextField (el, ek) {
  x=standardfield;
  if (ek) {
    x=ek;
  }
  f=el;
  g=0;
  for (;;) {
    e=eval("document."+formname+"."+x+f);
    if (e) {
      if (e.type=="hidden") {
        x="a";
      } else {
        if (e != null) {
          e.focus();
        }
        break;
      }
    } else {
      x=standardfield;
    }
    f++;
    if (f>=eval("document."+formname+".maxindex.value")) {
      if (g==1) {
        break;
      }
      f=0;
      g=1;
    }
  }
  window.event.cancelBubble = true;
  return false;
}
