  String.prototype.leftTrim = function () {
    return (this.replace(/^\s+/,""));
  };
  String.prototype.rightTrim = function () {
    return (this.replace(/\s+$/,""));
  };
//kombiniert "leftTrim" und "rightTrim";
  String.prototype.basicTrim = function () {
    return (this.replace(/\s+$/,"").replace(/^\s+/,""));
  };
//dampft leerzeichen(-sequenzen) innerhalb einer zeichenkette auf ein einzelnes "space" ein;
  String.prototype.superTrim = function () {
    return(this.replace(/\s+/g," ").replace(/\s+$/,"").replace(/^\s+/,""));
  };
//zugabe: entfernt alle leerzeichen aus einer zeichenkette;
  String.prototype.removeWhiteSpaces = function () {
    return (this.replace(/\s+/g,""));
  };

  var picwindow;
  var change=false;

  function openPic(url) {
    var b= new Image();
    b.src=url;
    if(picwindow && !picwindow.closed) {
      picwindow.close();
    }
    picwindow=window.open('','pic','toolbar=no,scrollbars=no,width='+b.width+',height='+b.height+',resizable=yes');
    picwindow.document.open('text/html');
    picwindow.document.writeln('<html>');
    picwindow.document.writeln('<body topmargin="0" marginheight="0" marginwidth="0" leftmargin="0">');
    picwindow.document.writeln('<img src="'+b.src+'" />');
    picwindow.document.writeln('</body>');
    picwindow.document.writeln('</html>');
    picwindow.document.close();
    picwindow.focus();
  }

var bestellfenster;
var sessionid;

function newWindow(session_id)
{
//  var url="http://bestellung.handwerk.schluetersche.de/indexa.htm?session_id="+session_id;
  var url="https://bestellung.schluetersche.de/indexa.htm?session_id="+session_id;
  var h = screen.height - 80;
  bestellfenster=window.open(url,"bestellfenster","status=yes,scrollbars,height="+h+",width=556");
  bestellfenster.focus();
}

function drucken(id,bg,dienst)
{
  var url="/drucken.htm?id="+id+"&bg="+bg+"&dienst="+dienst;
  var h = screen.height - 170;
  druckfenster=window.open(url,"druckfenster","left=210,top=0,screenX=210,screenY=0,height="+h+",width=720,resizable=yes,status=yes,scrollbars=yes,menubar=yes,toolbar=yes");
  druckfenster.focus();
}

function OCFunction(id)
{
  if (document.getElementById(id).style.display == "none")
  {
    document.getElementById(id).style.display = "block";
  }
  else
  {
    document.getElementById(id).style.display = "none";
  }
}

function EMail(s)
{
 var a = false;
 var res = false;
 if(typeof(RegExp) == 'function')
 {
  var b = new RegExp('abc');
  if(b.test('abc') == true){a = true;}
  }

 if(a == true)
 {
  reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+
                   '(\\@)([a-zA-Z0-9\\-\\.]+)'+
                   '(\\.)([a-zA-Z]{2,4})$');
  res = (reg.test(s));
 }
 else
 {
  res = (s.search('@') >= 1 &&
         s.lastIndexOf('.') > s.search('@') &&
         s.lastIndexOf('.') >= s.length-5)
 }
 return(res);
}

var xmlHttp = null;
var wert_global = "";
var until_new = false;

function getList(list,neu_bis) {
  wert_global = list;
  until_new = neu_bis;
  if (list.length) {
    if (window.ActiveXObject) {
      try {
        xmlHttp= new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
        }
      }
    } else if (window.XMLHttpRequest) {
      try {
        xmlHttp= new XMLHttpRequest();
      } catch (e) {
      }
    }
    if (xmlHttp) {
      xmlHttp.open('GET', 'list.htm?mdliste=' + list, true);
      xmlHttp.onreadystatechange = daten;
      xmlHttp.send(null);
    }
  }
}

var text = '';
var text_temp = '';
var textteile = new Array();

function daten() {
  var opt = document.email.adresse.options;
  if (xmlHttp.readyState == 4) {
    text = xmlHttp.responseText;
    if (text != "") {
      textteile = text.split(";");
      opt.length=0;
      for (var teil in textteile) {
        opt[teil] = new Option(textteile[teil]);
      }
      if (until_new && (text==text_temp || text_temp=="")) {
        document.getElementById('update').style.visibility = "visible";
        if (text_temp=="")
        {
          text_temp = text;
        }
        window.setTimeout("getList(wert_global,until_new)", 5000);
      }
      else {
        document.getElementById('update').style.visibility = "hidden";        
        text_temp = text;
      }
    }
  }
}

var ms = new Array();
function openOrCloseElements (id) {
  for (var i = 0; i < ms.length; ++i)
  {
    document.getElementById(ms[i]).style.visibility = 'hidden';
  }
  document.getElementById(id).style.visibility = 'visible';
}
