var wIe  = (document.all) ? 1 : 0;
var wIeVers       = navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE") + 4,navigator.appVersion.indexOf("MSIE") + 8);













function wOpenWindowX(url, name, options){
  
  url = url.replace(/&amp;/g, '&');
  name = name.replace(/\W/g, '');


  var width = screen.availWidth - 0;
  var regWidth = /width=(\d+)/;
  if(regWidth.exec(options)){
    width = RegExp.$1;
  }

  var height = screen.availHeight - 0;
  var regHeight = /height=(\d+)/;
  if(regHeight.exec(options)){
    height = RegExp.$1;
  }

  if(!name && !width && !height && !options){
    return window.open(url, name);
    return;
  }

  if(!options){
    options = ',resizable=no,scrollbars=no,status=no';
  }


  var posLeft = (screen.width / 2)  - (width  / 2);
  var posTop  = (screen.height / 2) - (height / 2);

  window.open(url, name, 'top='+posTop+',left='+posLeft+',width='+width+',height='+height+',' + options);
}



function wOpenDirOptionsX(url, name, width, height, options){
  
  if(!width || width == ''){
    width = "width=780";
    if(!height || height == ''){
      width = width + ",";
    }
  }
  if(!height || height == ''){
    height = "height=550";
    if(options != ''){
      height = height + ",";
    }
  }
  
  if(!name || name == ''){
    name = 'wDir';
  }
  
  if(!options){
    options = '';
  }
  
  return wOpenWindowX(url, name, width + height + options);
}







function wCloseDialog(){

  if(opener){
    self.close();
  }
  else if(wGlobalDialogOpenedId){
    var iFrameId = wGlobalDialogOpenedId;
    document.getElementById(iFrameId).src = 'about:blank';
    document.getElementById(iFrameId).style.display = 'none';
  }
  else{
    var iFrameId = parent.wGlobalDialogOpenedId;
    parent.document.getElementById(iFrameId).src = 'about:blank';
    parent.document.getElementById(iFrameId).style.display = 'none';
  }
}







function wOpenDialog(url, iFrameId, width, height){

  wGlobalDialogOpenedId = iFrameId;
  var iFrameElement  = document.getElementById(iFrameId);
  var className = iFrameElement.parentNode.parentNode.className;
  var clientWidth    = 0;
  var clientHeight   = 0;
  var search = / *right */i;
  if(search.test(className)){
    if(wIe){
      clientHeight  = iFrameElement.parentNode.offsetHeight;
      clientWidth   = 0;
    }
    else {
      clientWidth   = iFrameElement.parentNode.offsetWidth;
    }
    iFrameElement.style.marginLeft  = '-' + (width - clientWidth) + 'px' ;
  }
  else{
    if(wIe){
      clientHeight  = iFrameElement.parentNode.offsetHeight;
      clientWidth   = iFrameElement.parentNode.offsetWidth;
    }
    else {
      clientWidth   = 0;
    }
    iFrameElement.style.marginLeft  = '-' + (clientWidth) + 'px' ;
  }
  iFrameElement.style.marginTop   = '-' + (height - clientHeight) + 'px';
  iFrameElement.style.height      = height + 'px';
  iFrameElement.style.width       = width  + 'px';
  iFrameElement.src               = url;
  iFrameElement.style.display     = 'block';
}









function wShowUploadMask(repositoryId, currPath){

  wOpenWindowX('/weblication/grid/scripts/wUploader.php?action=showmaskuploadfile&uploaddir='+ currPath +'&path=' + currPath + '&repository=' + repositoryId, 'wUploader', 'width=640,height=290');
}









function wToggleCheckbox(checkbox){

  if(checkbox.checked){
    checkbox.checked = false;
  }
  else{
    checkbox.checked = true;
  }
}









function wToggleElement(elementId){

  if(document.getElementById(elementId)){

    if(document.getElementById(elementId).style.display == 'none'){
      document.getElementById(elementId).style.display = 'block';
    }
    else{
      document.getElementById(elementId).style.display = 'none';
    }
  }
}









function wToggleConfig(portletId){

  configNode = document.getElementById("configMask_"+portletId);

  if(configNode){
    if(configNode.style.display == 'block'){
      configNode.style.display = 'none';
    }
    else{
      configNode.style.display = 'block';




    }
  }









}













function wRemoveElement(object, interval){
  wFadeOutElement(object, interval)
 
}
















var opacity_fadeIn        = 0;
var wObject_FadeInElement = null;

function wFadeInElement(object, interval){
  if(object != ''){

    wObject_FadeInElement                   = object;
    opacity_fadeIn                          = 0;
  }

  if(wIe){
  }
  else{
    wObject_FadeInElement.style.MozOpacity = opacity_fadeIn / 100;
  }

  if(opacity_fadeIn !=100){
    setTimeout('opacity_fadeIn = opacity_fadeIn + ' + interval + ';wFadeInElement("",' + interval + ');',5);
  }

}










var opacity_fadeOut        = 100;
var wObject_fadeOutElement = null;

function wFadeOutElement(object, interval){
  if(object != ''){

    wObject_fadeOutElement                   = object;
    opacity_fadeOut                          = 100;
  }
  if(wIe){
  }
  else{
    wObject_fadeOutElement.style.MozOpacity = opacity_fadeOut / 100;
  }

  if(opacity_fadeOut !=0){
    setTimeout('opacity_fadeOut = opacity_fadeOut - ' + interval + ';wFadeOutElement("",' + interval + ');',5);
  }
  else{
    var regExp = /wysiwyg_webtag_text_/;
    if(regExp.exec(wObject_fadeOutElement.innerHTML)){
      wObject_fadeOutElement.getElementsByTagName('textarea')[0].parentNode.removeChild(wObject_fadeOutElement.getElementsByTagName('textarea')[0]);
      wObject_fadeOutElement.style.display = 'none';
    }
    else{
      wObject_fadeOutElement.parentNode.removeChild(wObject_fadeOutElement);
    }
  }

}









function wEmbedString(elementId, string){
  var origString = string;
  string   = string.replace(/[\n\r]+/g, '~_wnl_~');
  string   = string.replace(/= function/g, '~_wfunc_~');
  string   = string.replace(/= 'function'/g, '~_wfuncext_~');
  string   = string.replace(/= "function"/g, '~_wfuncext_~');
  string   = string.replace(/<\/SCRIPT>/, '</script>');

  var scripts  = string.split('<' + '/' + 's' + 'cript>');

  var jsString = '';

  for(var i = 0; i < scripts.length - 1; i++){

    var scriptStr = scripts[i].replace(/.*<script[^>]*>/i, '');

    jsString += scriptStr;
  }

  jsString     = jsString.replace(/~_wnl_~/g, "\n");

  string = string.replace(/~_wnl_~/g, "\n");
  string = string.replace(/~_wfuncext_~/g, "= 'function'");

  var jsFunctions = jsString.split(/function\s*/);

  
  for(var i = 0; i < jsFunctions.length; i++){
    if(jsFunctions[i] != ''){
      if(jsFunctions[i].search(/function|~_wfunc_~|~_wfuncext_~/i) != -1){
        jsFunctions[i] = jsFunctions[i].replace(/~_wfunc_~/g, "= function");
        jsFunctions[i] = jsFunctions[i].replace(/~_wfuncext_~/g, "= 'function'");
      }

      var tempReplace = jsFunctions[i].search(/(\w+)\s?\(/);
      var regexp = eval('/function ' + RegExp.$1 + '/');
      if(origString.search(regexp) != -1){
        var jsFunction = jsFunctions[i].replace(/(\w+)\s?\(/, 'DOLLAR_1_TMP = function(');
        jsFunction = jsFunction.replace('DOLLAR_1_TMP', RegExp.$1);
      }
      else{
        var jsFunction = jsFunctions[i];
      }

      jsFunction   = jsFunction.replace(/&#160;/g, ' ');
      eval(jsFunction);

    }
  }
  document.getElementById(elementId).innerHTML = string;
}

var wGetUrlFunctionResult;

if(typeof wResultFunctions == 'undefined'){
  var wResultFunctions = new Array();
  var wRequests        = new Array();
}













function wGetUrlAjax(url, functionResult, variable){

  var requestObject = new wRequestObject(url, functionResult, variable);
}











function wSendFormAjaxPost(url, parameters, functionResult){

  var requestObjectPost = new wRequestObjectPost(url, parameters, functionResult);
}













function wGetUrlAjaxPost(url, parameters, functionResult, variable){

  var requestObjectPost = new wRequestObjectPost(url, parameters, functionResult, variable);
}












function wRequestObject(url, functionResult, variable){

  if(typeof functionResult == 'function'){
    var id              = wResultFunctions.length;


    this.request        = null;

    if(document.all){
      this.request = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
      this.request = new XMLHttpRequest();
    }

    wResultFunctions.push(functionResult);


    wRequests.push(this.request);

    this.request.open('GET', url, true);

    this.request.onreadystatechange = function(){
      var requestObject = wRequests[id];
      if(requestObject.readyState == 4){

        if(requestObject.status == '200'){
          wResultFunctions[id](requestObject.responseText, variable);
        }
      }
    }

    this.request.send('');
  }
}















function wRequestObjectPost(url, parameters, functionResult, variable){

  if(typeof functionResult == 'function'){
    var id              = wResultFunctions.length;

    this.request        = null;

    if(document.all){
      this.request = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
      this.request = new XMLHttpRequest();
      if (this.request.overrideMimeType) {
         this.request.overrideMimeType('text/html');
      }
    }

    wResultFunctions.push(functionResult);


    wRequests.push(this.request);
    this.request.open('POST', url, true);

    this.request.onreadystatechange = function(){
      var requestObject = wRequests[id];
      if(requestObject.readyState == 4){
        if(requestObject.status == '200'){
          wResultFunctions[id](requestObject.responseText, variable);
        }
      }
    }

    this.request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    this.request.setRequestHeader("Content-length", parameters.length);
    this.request.setRequestHeader("Connection", "close");
    this.request.send(parameters);
  }
}







function wGetWidthWindow(){

  var winWidth;

  if(wIe){
    if(document.documentElement.clientWidth){
      winWidth = document.documentElement.clientWidth;
    }
    else{
      winWidth = document.body.clientWidth;
    }
  }
  else{
    winWidth = window.innerWidth;
  }
  return winWidth;
}







function wGetHeightWindow(){

  var winHeight;

  if(wIe){
    if(document.documentElement.clientHeight){
      winHeight = document.documentElement.clientHeight;
    }
    else{
      winHeight = document.body.clientHeight;
    }
  }
  else{
    winHeight = window.innerHeight;
  }
  return winHeight;
}






function wGetHeightSite(){

  var siteHeight;

  if(ie){
    if(document.body){
      siteHeight = document.body.scrollHeight;
    }
    else{
      if(document.documentElement.scrollHeight){
        siteHeight = document.documentElement.scrollHeight;
      }
      else{
        siteHeight = 0;
      }
    }
  }
  else{
    siteHeight = window.outerHeight;
  }
  return siteHeight;
}









function wSetWidthWindow(winWidth){

  var winWidth;

  if(wIe){
    if(document.documentElement.clientWidth){
      document.documentElement.clientWidth = winWidth;
    }
    else{
      document.body.clientWidth = winWidth;
    }
  }
  else{
    window.innerWidth = winWidth;
  }
  return true;
}

var wMouseX      = 0;
var wMouseY      = 0;
var wMouseXAbs   = 0;
var wMouseYAbs   = 0;

function wOnMouseMove(e){
  if(wIe){
    e = event;
    wMouseX    = event.clientX;
    wMouseY    = event.clientY;
    wMouseXAbs = event.clientX;
    wMouseYAbs = event.clientY;
  }
  else{
    wMouseX    = e.pageX;
    wMouseY    = e.pageY;
    wMouseXAbs = e.pageX;
    wMouseYAbs = e.pageY;
  }
}












var messageBoxEmbed = false;
function wShowMessageboxX(id, title, text, buttons, icon, variable, buttontext){



  if(document.getElementById('blocker')){

    messageBoxEmbed = true;
    initDialogEmbed(id, title, text, buttons, icon, variable, buttontext);
  }
  else {

    initDialog(id, title, text, buttons, icon, variable, buttontext);
  }
  scrollMessageBox();
}

function scrollMessageBox(){

  if (window.pageYOffset) {

    pagey = window.pageYOffset;
    pagex = window.pageXOffset;
  }
  else if (document.documentElement && document.documentElement.scrollTop) {

    pagey = document.documentElement.scrollTop;
    pagex = document.documentElement.scrollLeft;
  }
  else if (document.body) {

    pagey = document.body.scrollTop;
    pagex = document.body.scrollLeft;
  }

  if(document.getElementById("blocker")){
    document.getElementById("blocker").style.marginTop = window.pagey+'px';
    document.getElementById("blocker").style.marginLeft = window.pagex+'px';
  }

     if(document.getElementById("dialog")){

     if(ie){

       document.getElementById("dialog").style.top = (window.pagey-75)+'px';

     }

     else{

       document.getElementById("dialog").style.marginTop = (window.pagey-75)+'px';

       document.getElementById("dialog").style.left = (parseInt(wGetWidthWindow()/2)+window.pagex)+'px';

     }

   }


  if(document.getElementById("dialogLayer")){
    document.getElementById("dialogLayer").style.marginTop = (window.pagey-200)+'px';
    document.getElementById("dialogLayer").style.left = (parseInt(wGetWidthWindow()/2)+window.pagex)+'px';
  }

  if(document.getElementById("iframe")){
    document.getElementById("iframe").style.marginTop = (window.pagey-75)+'px';
    document.getElementById("iframe").style.left = (parseInt(wGetWidthWindow()/2)+window.pagex)+'px';
  }
}

var isShownDialog = false;
if(!TEXT_MESSAGEBOX_TITLE){
  var TEXT_MESSAGEBOX_TITLE   = null;
}
if(!TEXT_MESSAGEBOX_OK){
  var TEXT_MESSAGEBOX_OK      = null;
}
if(!TEXT_MESSAGEBOX_CANCEL){
  var TEXT_MESSAGEBOX_CANCEL  = null;
}
if(!TEXT_MESSAGEBOX_YES){
  var TEXT_MESSAGEBOX_YES     = null;
}
if(!TEXT_MESSAGEBOX_ALLWAYS){
  var TEXT_MESSAGEBOX_ALLWAYS = null;
}
if(!TEXT_MESSAGEBOX_NOT){
  var TEXT_MESSAGEBOX_NOT     = null;
}
if(!TEXT_MESSAGEBOX_BACK){
  var TEXT_MESSAGEBOX_BACK    = null;
}

function initDialog(id, title, text, buttons, icon, variable) {

  isShownMessageBox = true;
  window.onscroll = scrollMessageBox;

  text = text.replace(/<br \/>/, '<br/>')
  var parts       = text.split(' ');
  var texts       = '';
  var textsLine = '';
  var j             = 1;
  var length     = 0;

  if(parts.length != 0){
    for(var i= 0; i < parts.length; i++){
      if(i+1 == parts.length){
        texts     += textsLine+parts[i];

        j++;
        var tmpLength = (textsLine+parts[i]).length;
        if(tmpLength > length){
          length = tmpLength;
        }
      }
      else if(parts[i].search(/<br\/>/) != -1){
        texts     += textsLine+' '+parts[i].replace(/<br\/>/, '<br />');
        j++;
        var tmpLength = textsLine.length+parts[i].replace(/<br\/>/, '<br />').length+1;
        if(tmpLength > length){
          length = tmpLength;
        }
        textsLine = '';
      }
      else if((textsLine + parts[i]).length > 90 && parts[i].length <= 90){
        texts     += textsLine+'<br />\n';
        j++;
        textsLine = parts[i];
        length = 100;
      }
      else if(parts[i].length > 90){
        for(var k = 0; k < Math.round(parts[i].length/80); k++){
          texts += parts[i].substr(k*80, 80)+'<br />\n';
          j++;
        }
        length = 100;
      }
      else{
        textsLine += parts[i]+' ';
      }
    }
  }
  else{
    length = text.length;
    texts = text;
  }

  if(length < 50){
    length = 50;
  }

  if(title != '') {
    var dialogTitle = title;
  }
  else {
    if(TEXT_MESSAGEBOX_TITLE && TEXT_MESSAGEBOX_TITLE != ''){
      var dialogTitle = TEXT_MESSAGEBOX_TITLE;
    }
    else{
      var dialogTitle = 'Weblication Hinweis';
    }
  }

  if(TEXT_MESSAGEBOX_OK && TEXT_MESSAGEBOX_OK != ''){
    var buttonOKTxt   = TEXT_MESSAGEBOX_OK;
  }
  else{
    var buttonOKTxt   = 'Ok';
  }
  if(TEXT_MESSAGEBOX_CANCEL && TEXT_MESSAGEBOX_CANCEL != ''){
    var buttonCATxt   = TEXT_MESSAGEBOX_CANCEL;
  }
  else{
    var buttonCATxt   = 'Abbrechen';
  }
  if(TEXT_MESSAGEBOX_YES && TEXT_MESSAGEBOX_YES != ''){
    var buttonYESTxt   = TEXT_MESSAGEBOX_YES;
  }
  else{
    var buttonYESTxt  = 'Ja';
  }
  if(TEXT_MESSAGEBOX_ALLWAYS && TEXT_MESSAGEBOX_ALLWAYS != ''){
    var buttonALLWAYSTxt   = TEXT_MESSAGEBOX_ALLWAYS;
  }
  else{
    var buttonALLWAYSTxt  = 'Ja, alle';
  }
  if(TEXT_MESSAGEBOX_NOT && TEXT_MESSAGEBOX_NOT != ''){
    var buttonNOTxt   = TEXT_MESSAGEBOX_NOT;
  }
  else{
    var buttonNOTxt   = 'Nein';
  }
  if(TEXT_MESSAGEBOX_BACK && TEXT_MESSAGEBOX_BACK != ''){
    var buttonBACKTxt   = TEXT_MESSAGEBOX_BACK;
  }
  else{
    var buttonBACKTxt = 'Schließen';
  }

  if(icon == 'install'){
    var iconpath      = 'http://download.weblication.de/weblication/grid/gui/wImages/wMessagebox/loading.gif';
  }
  else{
    var iconpath      = '/weblication/grid/gui/wImages/wMessagebox/'+icon+'.gif';
  }

  var iconOk        = '/weblication/grid/gui/wImages/icon_small/ok.gif';
  var iconCancel    = '/weblication/grid/gui/wImages/icon_small/cancel.gif';
  var iconYes       = '/weblication/grid/gui/wImages/icon_small/ok.gif';
  var iconNo        = '/weblication/grid/gui/wImages/icon_small/cancel.gif';
  var iconBACK      = '/weblication/grid/gui/wImages/icon_small/cancel.gif';

  if(parent.frames.length < 1) {
    var docBody                 = document.body;
  }
  else{
    if(parent.document.body.tagName != 'FRAMESET') {
      if(wIe){
        var docBody                 = document.body;
      }
      else{
        var docBody                 = document.body;
      }
    }
    else{
      var docBody                 = document.body;
    }
  }
      
    var blocker       = document.createElement("div");
    blocker.className = "blockerClass";
    blocker.id        = "blocker";
    docBody.appendChild(blocker);
    if(wIe && wIeVers < 7){
      docBody.firstChild.insertAdjacentHTML('afterEnd', "<iframe src='about:blank' id='blockerFrame' style='width:100%; height: 100%;z-index:999; position:absolute; filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)' />");
    }

    var dialog                 = document.createElement('div');
    dialog.id                  = 'dialog';
    dialog.style.display       = "block";

    dialog.style.marginTop      = -(j*10+80)/2+'px';
    dialog.style.marginLeft     = -((length*5+75)/2)+'px';
    dialog.style.width          = length*5+75+"px";
    dialog.style.height         = j*10+80+"px";
    docBody.appendChild(dialog);

    if(wIe && wIeVers <= 7){
      var cssLink          = document.createElement("link");
      cssLink.rel          = 'stylesheet';
      cssLink.text         = 'text/css';
      cssLink.href         = '/weblication/grid/gui/wStyles/wIe.css';
      docBody.appendChild(cssLink);
    }
    if(wIe && wIeVers < 7){
      var frame            = document.createElement("iframe");
      frame.src            = 'about:blank';
      frame.id             = 'blockerFrame';
      frame.style.width    = '100%';
      frame.style.height   = '140%';
      frame.style.zIndex   = '-1';
      frame.style.position = 'absolute';
      frame.style.display  = 'block';
      frame.style.filter   = 'mask()';

      dialog.appendChild(frame);
    }

    var d_head                   = document.createElement('div');
    d_head.id                     = 'd_head';
    d_head.style.width        = '100%';
    dialog.appendChild(d_head);

    var headline                  = document.createElement('h1');
    headline.innerHTML       = dialogTitle;
    headline.id                    = 'headline';
    headline.style.width       = dialog.offsetWidth+'px';

    d_head.appendChild(headline);

    if(icon) {
      var d_body              = document.createElement('div');
      d_body.innerHTML   = texts;
      d_body.id                = 'd_body_icon';
      dialog.appendChild(d_body);
      var d_icon              = document.createElement('div');
      d_icon.id                = 'd_icon';
      d_icon.style.top      = '40%';
      dialog.appendChild(d_icon);

      var d_icon_img          = document.createElement('img');
      d_icon_img.id            = 'd_icon_img';
      d_icon_img.src          = iconpath;
      d_icon.appendChild(d_icon_img);
    }
    else{
      var d_body              = document.createElement('div');

      d_body.innerHTML  = texts;
      d_body.id               = 'd_body';
      dialog.appendChild(d_body);
    }


    var d_shadow_right                                    = document.createElement('div');

    d_shadow_right.style.position                      = 'absolute';
    d_shadow_right.style.top                             = 0+'px';
    d_shadow_right.style.width                          = 5+'px';
    d_shadow_right.style.left                             = dialog.offsetWidth-1+'px';
    d_shadow_right.style.height                         = dialog.offsetHeight+'px';
    var d_shadow_right_top                               = document.createElement('div');
    d_shadow_right_top.id                                 = 'd_shadow_right_top';
    d_shadow_right_top.style.height                   = 3+'px';
    d_shadow_right_top.style.backgroundImage  = 'url("/weblication/grid/gui/wImages/wShadows/messagebox_right_top.png")';
    d_shadow_right_top.style.backgroundRepeat = 'no-repeat';
    d_shadow_right.appendChild(d_shadow_right_top);
    var d_shadow_right_middle      = document.createElement('div');
    d_shadow_right_middle.id                            = 'd_shadow_right_middle';
    if(wIeVers < 7){
      d_shadow_right_middle.style.marginTop     = - 11+'px';
    }
    d_shadow_right_middle.style.height                   = dialog.offsetHeight - 1+'px';
    d_shadow_right_middle.style.backgroundImage  = 'url("/weblication/grid/gui/wImages/wShadows/messagebox_right_middle.png")';
    d_shadow_right_middle.style.backgroundRepeat = 'repeat-y';
    d_shadow_right.appendChild(d_shadow_right_middle);
    dialog.appendChild(d_shadow_right);

    var d_shadow_bottom                                     = document.createElement('div');

    d_shadow_bottom.style.position                      = 'absolute';
    d_shadow_bottom.style.width                          = dialog.offsetWidth+2+'px';
    d_shadow_bottom.style.top                             = dialog.offsetHeight+'px';
    d_shadow_bottom.style.height                         = 5+'px';
    var d_shadow_bottom_left                               = document.createElement('div');
    d_shadow_bottom_left.id                                 = 'd_shadow_bottom_left';
    d_shadow_bottom_left.style.width                    = 3+'px';
    d_shadow_bottom_left.style.cssFloat               = 'left';
    d_shadow_bottom_left.style.styleFloat             = 'left';
    d_shadow_bottom_left.style.height                  = 5+'px';
    d_shadow_bottom_left.style.backgroundImage  = 'url("/weblication/grid/gui/wImages/wShadows/messagebox_bottom_left.png")';
    d_shadow_bottom_left.style.backgroundRepeat = 'no-repeat';
    d_shadow_bottom.appendChild(d_shadow_bottom_left);
    var d_shadow_bottom_middle                               = document.createElement('div');
    d_shadow_bottom_middle.id                                 = 'd_shadow_bottom_middle';
    d_shadow_bottom_middle.style.width                    = dialog.offsetWidth - 4 +'px';
    d_shadow_bottom_middle.style.cssFloat               = 'left';
    d_shadow_bottom_middle.style.styleFloat             = 'left';
    d_shadow_bottom_middle.style.height                   = 5+'px';
    d_shadow_bottom_middle.style.backgroundImage  = 'url("/weblication/grid/gui/wImages/wShadows/messagebox_bottom_middle.png")';
    d_shadow_bottom_middle.style.backgroundRepeat = 'repeat-x';
    d_shadow_bottom.appendChild(d_shadow_bottom_middle);
    var d_shadow_bottom_right                                = document.createElement('div');
    d_shadow_bottom_right.id                                  = 'd_shadow_bottom_right';
    d_shadow_bottom_right.style.width                     = 3 +'px';
    d_shadow_bottom_right.style.cssFloat                = 'left';
    d_shadow_bottom_right.style.styleFloat              = 'left';
    d_shadow_bottom_right.style.height                    = 5+'px';
    d_shadow_bottom_right.style.backgroundImage   = 'url("/weblication/grid/gui/wImages/wShadows/messagebox_bottom_right.png")';
    d_shadow_bottom_right.style.backgroundRepeat  = 'no-repeat';
    d_shadow_bottom.appendChild(d_shadow_bottom_right);
    dialog.appendChild(d_shadow_bottom);

    var d_buttons           = document.createElement('div');
    d_buttons.id            = 'd_buttons';
    dialog.appendChild(d_buttons);

    if(buttons.toLowerCase().indexOf('yes') != '-1') {
      var d_bYES               = document.createElement('div');

      newAttrOnMouseOver = "this.className='d_b_hi';";
      d_bYES.onmouseover = new Function('F',newAttrOnMouseOver);

      newAttrOnMouseOut  = "this.className='d_b';";
      d_bYES.onmouseout  = new Function('F',newAttrOnMouseOut);

      newAttrOnClick  = "button_YES_onClick('"+id+"','"+variable+"')";
      d_bYES.onclick  = new Function('F',newAttrOnClick);

      d_bYES.className         = 'd_b';
      d_bYES.id                = 'YES';
      if(wIe){
        d_bYES.innerHTML         = '<table style="display:inline; margin-top:1px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconYes+'"/></td><td style="padding-top:2px;">'+buttonYESTxt+'</td></tr></table>';
      }
      else{
        d_bYES.innerHTML         = '<table style="display:inline; margin-top:-2px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconYes+'"/></td><td style="padding-top:2px;">'+buttonYESTxt+'</td></tr></table>';
      }
      d_buttons.appendChild(d_bYES);

      var button_YES           = d_bYES;
      button_YES.name          = variable;
      button_YES.id            = id;
      if(wIe){

      }
      else{

      }
    }

    if(buttons.toLowerCase().indexOf('allways') != '-1') {
      var d_bALLWAYS               = document.createElement('div');

      newAttrOnMouseOver = "this.className='d_b_hi';";
      d_bALLWAYS.onmouseover = new Function('F',newAttrOnMouseOver);

      newAttrOnMouseOut  = "this.className='d_b';";
      d_bALLWAYS.onmouseout  = new Function('F',newAttrOnMouseOut);

      newAttrOnClick  = "button_ALLWAYS_onClick('"+id+"','"+variable+"')";
      d_bALLWAYS.onclick  = new Function('F',newAttrOnClick);

      d_bALLWAYS.className         = 'd_b';
      d_bALLWAYS.id                = 'ALLWAYS';
      if(wIe){
        d_bALLWAYS.innerHTML         = '<table style="display:inline; margin-top:1px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconYes+'"/></td><td style="padding-top:2px;">'+buttonALLWAYSTxt+'</td></tr></table>';
      }
      else{
        d_bALLWAYS.innerHTML         = '<table style="display:inline; margin-top:-2px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconYes+'"/></td><td style="padding-top:2px;">'+buttonALLWAYSTxt+'</td></tr></table>';
      }
      d_buttons.appendChild(d_bALLWAYS);

      var button_ALLWAYS           = d_bALLWAYS;
      button_ALLWAYS.name          = variable;
      button_ALLWAYS.id            = id;
      if(wIe){

      }
      else{

      }
    }

    if (buttons.toLowerCase().indexOf('no') != '-1') {
      var d_bNO               = document.createElement('div');

      newAttrOnMouseOver = "this.className='d_b_hi';";
      d_bNO.onmouseover = new Function('F',newAttrOnMouseOver);

      newAttrOnMouseOut  = "this.className='d_b';";
      d_bNO.onmouseout  = new Function('F',newAttrOnMouseOut);

      newAttrOnClick  = "button_NO_onClick('"+id+"','"+variable+"')";
      d_bNO.onclick  = new Function('F',newAttrOnClick);


      d_bNO.className         = 'd_b';
      d_bNO.id                = 'NO';
      if(wIe){
        d_bNO.innerHTML         = '<table style="display:inline; margin-top:1px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconNo+'"/></td><td style="padding-top:2px;">'+buttonNOTxt+'</td></tr></table>';
      }
      else{
        d_bNO.innerHTML         = '<table style="display:inline; margin-top:-2px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconNo+'"/></td><td style="padding-top:2px;">'+buttonNOTxt+'</td></tr></table>';
      }
      d_buttons.appendChild(d_bNO);

      var button_NO           = d_bNO;
      button_NO.name          = variable;
      button_NO.id            = id;
      if(wIe){

      }
      else{

      }
    }

    if (buttons.toLowerCase().indexOf('ok') != '-1') {
      var d_bOK               = document.createElement('div');

      newAttrOnMouseOver = "this.className='d_b_hi';";
      d_bOK.onmouseover = new Function('F',newAttrOnMouseOver);

      newAttrOnMouseOut  = "this.className='d_b';";
      d_bOK.onmouseout  = new Function('F',newAttrOnMouseOut);

      newAttrOnClick  = "button_OK_onClick('"+id+"','"+variable+"')";
      d_bOK.onclick  = new Function('F',newAttrOnClick);

      d_bOK.className         = 'd_b';
      d_bOK.id                = 'OK';
      if(wIe){
        d_bOK.innerHTML         = '<table style="display:inline; margin-top:1px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconOk+'"/></td><td style="padding-top:2px;">'+buttonOKTxt+'</td></tr></table>';
      }
      else{
        d_bOK.innerHTML         = '<table style="display:inline; margin-top:-2px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconOk+'"/></td><td style="padding-top:2px;">'+buttonOKTxt+'</td></tr></table>';
      }
      d_buttons.appendChild(d_bOK);

      var button_OK           = d_bOK;
      button_OK.name          = variable;
      button_OK.id            = id;
      if(wIe){

      }
      else{

      }
    }

    if (buttons.toLowerCase().indexOf('cancel') != '-1') {

      var d_bCANCEL           = document.createElement('div');

      newAttrOnMouseOver = "this.className='d_b_hi';";
      d_bCANCEL.onmouseover = new Function('F',newAttrOnMouseOver);

      newAttrOnMouseOut  = "this.className='d_b';";
      d_bCANCEL.onmouseout  = new Function('F',newAttrOnMouseOut);

      newAttrOnClick  = "button_CANCEL_onClick('"+id+"','"+variable+"')";
      d_bCANCEL.onclick  = new Function('F',newAttrOnClick);

      d_bCANCEL.className     = 'd_b';
      d_bCANCEL.id            = 'CANCEL';
      if(wIe){
        d_bCANCEL.innerHTML     = '<table style="display:inline; margin-top:1px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconCancel+'"/></td><td style="padding-top:2px;">'+buttonCATxt+'</td></tr></table>';
      }
      else{
        d_bCANCEL.innerHTML     = '<table style="display:inline; margin-top:-2px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconCancel+'"/></td><td style="padding-top:2px;">'+buttonCATxt+'</td></tr></table>';
      }
      d_buttons.appendChild(d_bCANCEL);

      var button_CANCEL       = d_bCANCEL;
      button_CANCEL.name      = variable;
      button_CANCEL.id        = id;
      if(wIe){

      }
      else{

      }
    }

    if (buttons.toLowerCase().indexOf('back') != '-1') {

      var d_bBACK               = document.createElement('div');

      newAttrOnMouseOver = "this.className='d_b_hi';";
      d_bBACK.onmouseover = new Function('F',newAttrOnMouseOver);

      newAttrOnMouseOut  = "this.className='d_b';";
      d_bBACK.onmouseout  = new Function('F',newAttrOnMouseOut);

      newAttrOnClick  = "button_BACK_onClick('"+id+"','"+variable+"')";
      d_bBACK.onclick  = new Function('F',newAttrOnClick);


      d_bBACK.className         = 'd_b';
      d_bBACK.id                = 'BACK';
      if(wIe){
        d_bBACK.innerHTML         = '<table style="display:inline; margin-top:1px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconBACK+'"/></td><td style="padding-top:2px;">'+buttonBACKTxt+'</td></tr></table>';
      }
      else{
        d_bBACK.innerHTML         = '<table style="display:inline; margin-top:-2px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconBACK+'"/></td><td style="padding-top:2px;">'+buttonBACKTxt+'</td></tr></table>';
      }
      d_buttons.appendChild(d_bBACK);

      var button_BACK           = d_bBACK;
      button_BACK.name          = variable;
      button_BACK.id            = id;
      if(wIe){

      }
      else{

      }
    }

    var pClear              = document.createElement('p');
    pClear.style.clear      = 'both';
    d_buttons.appendChild(pClear);

  isShownDialog = true;
}

function initDialogEmbed (id, title, text, buttons, icon, variable) {

  isShownMessageBox = true;
  window.onscroll = scrollMessageBox;
  text = text.replace(/<br \/>/, '<br/>')
  var parts       = text.split(' ');
  var texts       = '';
  var textsLine = '';
  var j             = 1;
  var length     = 0;

  if(parts.length != 0){
    for(var i= 0; i < parts.length; i++){
      if(i+1 == parts.length){
        texts     += textsLine+parts[i];

        j++;
        var tmpLength = (textsLine+parts[i]).length;
        if(tmpLength > length){
          length = tmpLength;
        }
      }
      else if(parts[i].search(/<br\/>/) != -1){
        texts     += textsLine+' '+parts[i].replace(/<br\/>/, '<br />');
        j++;
        var tmpLength = textsLine.length+parts[i].replace(/<br\/>/, '<br />').length+1;
        if(tmpLength > length){
          length = tmpLength;
        }
        textsLine = '';
      }
      else if((textsLine + parts[i]).length > 90 && parts[i].length <= 90){
        texts     += textsLine+'<br />\n';
        j++;
        textsLine = parts[i];
        length = 100;
      }
      else if(parts[i].length > 90){
        for(var k = 0; k < Math.round(parts[i].length/80); k++){
          texts += parts[i].substr(k*80, 80)+'<br />\n';
          j++;
        }
        length = 100;
      }
      else{
        textsLine += parts[i]+' ';
      }
    }
  }
  else{
    length = text.length;
    texts = text;
  }

  if(length < 50){
    length = 50;
  }

  if(title != '') {
    var dialogTitle = title;
  }
  else {
    if(TEXT_MESSAGEBOX_TITLE && TEXT_MESSAGEBOX_TITLE != ''){
      var dialogTitle = TEXT_MESSAGEBOX_TITLE;
    }
    else{
      var dialogTitle = 'Weblication Hinweis';
    }
  }

  if(TEXT_MESSAGEBOX_OK && TEXT_MESSAGEBOX_OK != ''){
    var buttonOKTxt   = TEXT_MESSAGEBOX_OK;
  }
  else{
    var buttonOKTxt   = 'Ok';
  }
  if(TEXT_MESSAGEBOX_CANCEL && TEXT_MESSAGEBOX_CANCEL != ''){
    var buttonCATxt   = TEXT_MESSAGEBOX_CANCEL;
  }
  else{
    var buttonCATxt   = 'Abbrechen';
  }
  if(TEXT_MESSAGEBOX_YES && TEXT_MESSAGEBOX_YES != ''){
    var buttonYESTxt   = TEXT_MESSAGEBOX_YES;
  }
  else{
    var buttonYESTxt  = 'Ja';
  }
  if(TEXT_MESSAGEBOX_ALLWAYS && TEXT_MESSAGEBOX_ALLWAYS != ''){
    var buttonALLWAYSTxt   = TEXT_MESSAGEBOX_ALLWAYS;
  }
  else{
    var buttonALLWAYSTxt  = 'Ja, alle';
  }
  if(TEXT_MESSAGEBOX_NOT && TEXT_MESSAGEBOX_NOT != ''){
    var buttonNOTxt   = TEXT_MESSAGEBOX_NOT;
  }
  else{
    var buttonNOTxt   = 'Nein';
  }
  if(TEXT_MESSAGEBOX_BACK && TEXT_MESSAGEBOX_BACK != ''){
    var buttonBACKTxt   = TEXT_MESSAGEBOX_BACK;
  }
  else{
    var buttonBACKTxt = 'Schließen';
  }

  if(icon == 'install'){
    var iconpath      = 'http://download.weblication.de/weblication/grid/gui/wImages/wMessagebox/loading.gif';
  }
  else{
    var iconpath      = '/weblication/grid/gui/wImages/wMessagebox/'+icon+'.gif';
  }

  var iconOk        = '/weblication/grid/gui/wImages/icon_small/ok.gif';
  var iconCancel    = '/weblication/grid/gui/wImages/icon_small/cancel.gif';
  var iconYes       = '/weblication/grid/gui/wImages/icon_small/ok.gif';
  var iconNo        = '/weblication/grid/gui/wImages/icon_small/cancel.gif';
  var iconBACK      = '/weblication/grid/gui/wImages/icon_small/cancel.gif';

  if(parent.frames.length < 1) {
    var docBody                 = document.body;
    var docuElement = document;
  }
  else{
    if(parent.document.body.tagName != 'FRAMESET') {
      if(wIe){
        var docBody                 = document.body;
      }
      else{
        var docBody                 = document.body;
      }
    }
    else{
      var docBody                 = document.body;
    }
    var docuElement = document;
  }

    var blocker       = document.getElementById("blocker");
    blocker.className = "blockerClass";
    blocker.id        = "blocker";


    if(wIe && wIeVers < 7){
      docBody.firstChild.insertAdjacentHTML('afterEnd', "<iframe src='about:blank' id='blockerFrame' style='width:100%; height: 100%;z-index:999; position:absolute; filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)' />");
    }

    var dialog                 = document.getElementById('dialog');
    dialog.id                  = 'dialog';
    dialog.style.display       = "block";

    dialog.style.marginTop      = -(j*10+80)/2+'px';
    dialog.style.marginLeft     = -((length*5+75)/2)+'px';
    dialog.style.width          = length*5+75+"px";
    dialog.style.height         = j*10+80+"px";


    if(wIe && wIeVers <= 7){
      var cssLink          = document.createElement("link");
      cssLink.rel          = 'stylesheet';
      cssLink.text         = 'text/css';
      cssLink.href         = '/weblication/grid/gui/wStyles/wIe.css';

    }
    if(wIe && wIeVers < 7){
      var frame            = document.createElement("iframe");
      frame.src            = 'about:blank';
      frame.id             = 'blockerFrame';
      frame.style.width    = '100%';
      frame.style.height   = '140%';
      frame.style.zIndex   = '-1';
      frame.style.position = 'absolute';
      frame.style.display  = 'block';
      frame.style.filter   = 'mask()';


    }
    
    var d_head                = document.getElementById('d_head');
    d_head.id                 = 'd_head';
    d_head.style.width        = '100%';

    var headline             = document.getElementById('headline');
    headline.innerHTML       = dialogTitle;
    headline.id              = 'headline';
    headline.style.width     = dialog.offsetWidth+'px';

    if(icon) {
      var d_body              = docuElement.getElementById('d_body_icon');
      d_body.innerHTML   = texts;
      d_body.id                = 'd_body_icon';
      
      var d_icon              = docuElement.getElementById('d_icon');
      d_icon.id                = 'd_icon';
      d_icon.style.top      = '40%';
  
      var d_icon_img          = docuElement.getElementById('d_icon_img');
      d_icon_img.id            = 'd_icon_img';
      d_icon_img.src          = iconpath;
    }
    else{
      var d_body              = docuElement.getElementById('d_body');
      d_body.innerHTML  = texts;
      d_body.id               = 'd_body';
    }

    var d_shadow_right                                    = docuElement.createElement('div');

    d_shadow_right.style.position                      = 'absolute';
    d_shadow_right.style.top                             = 0+'px';
    d_shadow_right.style.width                          = 5+'px';
    d_shadow_right.style.left                             = dialog.offsetWidth-1+'px';
    d_shadow_right.style.height                         = dialog.offsetHeight+'px';
    var d_shadow_right_top                               = document.createElement('div');
    d_shadow_right_top.id                                 = 'd_shadow_right_top';
    d_shadow_right_top.style.height                   = 3+'px';
    d_shadow_right_top.style.backgroundImage  = 'url("/weblication/grid/gui/wImages/wShadows/messagebox_right_top.png")';
    d_shadow_right_top.style.backgroundRepeat = 'no-repeat';
    d_shadow_right.appendChild(d_shadow_right_top);
    var d_shadow_right_middle      = document.createElement('div');
    d_shadow_right_middle.id                            = 'd_shadow_right_middle';
    if(wIeVers < 7){
      d_shadow_right_middle.style.marginTop     = - 11+'px';
    }
    d_shadow_right_middle.style.height                   = dialog.offsetHeight - 1+'px';
    d_shadow_right_middle.style.backgroundImage  = 'url("/weblication/grid/gui/wImages/wShadows/messagebox_right_middle.png")';
    d_shadow_right_middle.style.backgroundRepeat = 'repeat-y';
    d_shadow_right.appendChild(d_shadow_right_middle);
    dialog.appendChild(d_shadow_right);

    var d_shadow_bottom                                     = document.createElement('div');

    d_shadow_bottom.style.position                      = 'absolute';
    d_shadow_bottom.style.width                          = dialog.offsetWidth+2+'px';
    d_shadow_bottom.style.top                             = dialog.offsetHeight+'px';
    d_shadow_bottom.style.height                         = 5+'px';
    var d_shadow_bottom_left                               = document.createElement('div');
    d_shadow_bottom_left.id                                 = 'd_shadow_bottom_left';
    d_shadow_bottom_left.style.width                    = 3+'px';
    d_shadow_bottom_left.style.cssFloat               = 'left';
    d_shadow_bottom_left.style.styleFloat             = 'left';
    d_shadow_bottom_left.style.height                  = 5+'px';
    d_shadow_bottom_left.style.backgroundImage  = 'url("/weblication/grid/gui/wImages/wShadows/messagebox_bottom_left.png")';
    d_shadow_bottom_left.style.backgroundRepeat = 'no-repeat';
    d_shadow_bottom.appendChild(d_shadow_bottom_left);
    var d_shadow_bottom_middle                               = document.createElement('div');
    d_shadow_bottom_middle.id                                 = 'd_shadow_bottom_middle';
    d_shadow_bottom_middle.style.width                    = dialog.offsetWidth - 4 +'px';
    d_shadow_bottom_middle.style.cssFloat               = 'left';
    d_shadow_bottom_middle.style.styleFloat             = 'left';
    d_shadow_bottom_middle.style.height                   = 5+'px';
    d_shadow_bottom_middle.style.backgroundImage  = 'url("/weblication/grid/gui/wImages/wShadows/messagebox_bottom_middle.png")';
    d_shadow_bottom_middle.style.backgroundRepeat = 'repeat-x';
    d_shadow_bottom.appendChild(d_shadow_bottom_middle);
    var d_shadow_bottom_right                                = document.createElement('div');
    d_shadow_bottom_right.id                                  = 'd_shadow_bottom_right';
    d_shadow_bottom_right.style.width                     = 3 +'px';
    d_shadow_bottom_right.style.cssFloat                = 'left';
    d_shadow_bottom_right.style.styleFloat              = 'left';
    d_shadow_bottom_right.style.height                    = 5+'px';
    d_shadow_bottom_right.style.backgroundImage   = 'url("/weblication/grid/gui/wImages/wShadows/messagebox_bottom_right.png")';
    d_shadow_bottom_right.style.backgroundRepeat  = 'no-repeat';
    d_shadow_bottom.appendChild(d_shadow_bottom_right);
    dialog.appendChild(d_shadow_bottom);

    var d_buttons           = document.createElement('div');
    d_buttons.id            = 'd_buttons';
    dialog.appendChild(d_buttons);

    if(buttons.toLowerCase().indexOf('yes') != '-1') {
      var d_bYES               = document.createElement('div');

      newAttrOnMouseOver = "this.className='d_b_hi';";
      d_bYES.onmouseover = new Function('F',newAttrOnMouseOver);

      newAttrOnMouseOut  = "this.className='d_b';";
      d_bYES.onmouseout  = new Function('F',newAttrOnMouseOut);

      newAttrOnClick  = "button_YES_onClick('"+id+"','"+variable+"')";
      d_bYES.onclick  = new Function('F', newAttrOnClick);

      d_bYES.className         = 'd_b';
      d_bYES.id                = 'YES';
      if(wIe){
        d_bYES.innerHTML         = '<table style="display:inline; margin-top:1px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconYes+'"/></td><td style="padding-top:2px;">'+buttonYESTxt+'</td></tr></table>';
      }
      else{
        d_bYES.innerHTML         = '<table style="display:inline; margin-top:-2px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconYes+'"/></td><td style="padding-top:2px;">'+buttonYESTxt+'</td></tr></table>';
      }
      d_buttons.appendChild(d_bYES);

      var button_YES           = d_bYES;
      button_YES.name          = variable;
      button_YES.id            = id;
      if(wIe){

      }
      else{

      }
    }

    if(buttons.toLowerCase().indexOf('allways') != '-1') {
      var d_bALLWAYS               = document.createElement('div');

      newAttrOnMouseOver = "this.className='d_b_hi';";
      d_bALLWAYS.onmouseover = new Function('F',newAttrOnMouseOver);

      newAttrOnMouseOut  = "this.className='d_b';";
      d_bALLWAYS.onmouseout  = new Function('F',newAttrOnMouseOut);

      newAttrOnClick  = "button_ALLWAYS_onClick('"+id+"','"+variable+"')";
      d_bALLWAYS.onclick  = new Function('F',newAttrOnClick);

      d_bALLWAYS.className         = 'd_b';
      d_bALLWAYS.id                = 'ALLWAYS';
      if(wIe){
        d_bALLWAYS.innerHTML         = '<table style="display:inline; margin-top:1px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconYes+'"/></td><td style="padding-top:2px;">'+buttonALLWAYSTxt+'</td></tr></table>';
      }
      else{
        d_bALLWAYS.innerHTML         = '<table style="display:inline; margin-top:-2px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconYes+'"/></td><td style="padding-top:2px;">'+buttonALLWAYSTxt+'</td></tr></table>';
      }
      d_buttons.appendChild(d_bALLWAYS);

      var button_ALLWAYS           = d_bALLWAYS;
      button_ALLWAYS.name          = variable;
      button_ALLWAYS.id            = id;
      if(wIe){

      }
      else{

      }
    }

    if (buttons.toLowerCase().indexOf('no') != '-1') {
      var d_bNO               = document.createElement('div');

      newAttrOnMouseOver = "this.className='d_b_hi';";
      d_bNO.onmouseover = new Function('F',newAttrOnMouseOver);

      newAttrOnMouseOut  = "this.className='d_b';";
      d_bNO.onmouseout  = new Function('F',newAttrOnMouseOut);

      newAttrOnClick  = "button_NO_onClick('"+id+"','"+variable+"')";
      d_bNO.onclick  = new Function('F',newAttrOnClick);


      d_bNO.className         = 'd_b';
      d_bNO.id                = 'NO';
      if(wIe){
        d_bNO.innerHTML         = '<table style="display:inline; margin-top:1px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconNo+'"/></td><td style="padding-top:2px;">'+buttonNOTxt+'</td></tr></table>';
      }
      else{
        d_bNO.innerHTML         = '<table style="display:inline; margin-top:-2px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconNo+'"/></td><td style="padding-top:2px;">'+buttonNOTxt+'</td></tr></table>';
      }
      d_buttons.appendChild(d_bNO);

      var button_NO           = d_bNO;
      button_NO.name          = variable;
      button_NO.id            = id;
      if(wIe){

      }
      else{

      }
    }

    if (buttons.toLowerCase().indexOf('ok') != '-1') {
      var d_bOK               = document.createElement('div');

      newAttrOnMouseOver = "this.className='d_b_hi';";
      d_bOK.onmouseover = new Function('F',newAttrOnMouseOver);

      newAttrOnMouseOut  = "this.className='d_b';";
      d_bOK.onmouseout  = new Function('F',newAttrOnMouseOut);

      newAttrOnClick  = "button_OK_onClick('"+id+"','"+variable+"')";
      d_bOK.onclick  = new Function('F',newAttrOnClick);

      d_bOK.className         = 'd_b';
      d_bOK.id                = 'OK';
      if(wIe){
        d_bOK.innerHTML         = '<table style="display:inline; margin-top:1px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconOk+'"/></td><td style="padding-top:2px;">'+buttonOKTxt+'</td></tr></table>';
      }
      else{
        d_bOK.innerHTML         = '<table style="display:inline; margin-top:-2px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconOk+'"/></td><td style="padding-top:2px;">'+buttonOKTxt+'</td></tr></table>';
      }
      d_buttons.appendChild(d_bOK);

      var button_OK           = d_bOK;
      button_OK.name          = variable;
      button_OK.id            = id;
      if(wIe){

      }
      else{

      }
    }

    if (buttons.toLowerCase().indexOf('cancel') != '-1') {

      var d_bCANCEL           = document.createElement('div');

      newAttrOnMouseOver = "this.className='d_b_hi';";
      d_bCANCEL.onmouseover = new Function('F',newAttrOnMouseOver);

      newAttrOnMouseOut  = "this.className='d_b';";
      d_bCANCEL.onmouseout  = new Function('F',newAttrOnMouseOut);

      newAttrOnClick  = "button_CANCEL_onClick('"+id+"','"+variable+"')";
      d_bCANCEL.onclick  = new Function('F',newAttrOnClick);

      d_bCANCEL.className     = 'd_b';
      d_bCANCEL.id            = 'CANCEL';
      if(wIe){
        d_bCANCEL.innerHTML     = '<table style="display:inline; margin-top:1px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconCancel+'"/></td><td style="padding-top:2px;">'+buttonCATxt+'</td></tr></table>';
      }
      else{
        d_bCANCEL.innerHTML     = '<table style="display:inline; margin-top:-2px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconCancel+'"/></td><td style="padding-top:2px;">'+buttonCATxt+'</td></tr></table>';
      }
      d_buttons.appendChild(d_bCANCEL);

      var button_CANCEL       = d_bCANCEL;
      button_CANCEL.name      = variable;
      button_CANCEL.id        = id;
      if(wIe){

      }
      else{

      }
    }

    if (buttons.toLowerCase().indexOf('back') != '-1') {

      var d_bBACK               = document.createElement('div');

      newAttrOnMouseOver = "this.className='d_b_hi';";
      d_bBACK.onmouseover = new Function('F',newAttrOnMouseOver);

      newAttrOnMouseOut  = "this.className='d_b';";
      d_bBACK.onmouseout  = new Function('F',newAttrOnMouseOut);

      newAttrOnClick  = "button_BACK_onClick('"+id+"','"+variable+"')";
      d_bBACK.onclick  = new Function('F',newAttrOnClick);


      d_bBACK.className         = 'd_b';
      d_bBACK.id                = 'BACK';
      if(wIe){
        d_bBACK.innerHTML         = '<table style="display:inline; margin-top:1px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconBACK+'"/></td><td style="padding-top:2px;">'+buttonBACKTxt+'</td></tr></table>';
      }
      else{
        d_bBACK.innerHTML         = '<table style="display:inline; margin-top:-2px; border:0;" cellpadding="0" cellspacing="0"><tr><td><img style="margin-right:3px; margin-top:1px;" src="'+iconBACK+'"/></td><td style="padding-top:2px;">'+buttonBACKTxt+'</td></tr></table>';
      }
      d_buttons.appendChild(d_bBACK);

      var button_BACK           = d_bBACK;
      button_BACK.name          = variable;
      button_BACK.id            = id;
      if(wIe){

      }
      else{

      }
    }

    var pClear              = document.createElement('p');
    pClear.style.clear      = 'both';
    d_buttons.appendChild(pClear);

  isShownDialog = true;
}

function button_hideMessageBox(){
  if(wIe){


  }
  else{


  }

  if(parent.frames.length < 1){
    docBody                 = document.body;
    blocker                 = document.getElementById('blocker');
    dialog                  = document.getElementById('dialog');
    iframe                  = document.getElementById('iframe');
  }
  else{
    if(parent.document.body.tagName != 'FRAMESET'){
      if(wIe){
        var docBody                 = document.body;
        var blocker                 = document.getElementById('blocker');
        var dialog                  = document.getElementById('dialog');
        var iframe                  = document.getElementById('iframe');
      }
      else{
        docBody                 = document.body;
        blocker                 = document.getElementById('blocker');
        dialog                  = document.getElementById('dialog');
        iframe                  = document.getElementById('iframe');
      }
    }
    else{
      docBody                 = document.body;
      blocker                 = document.getElementById('blocker');
      dialog                  = document.getElementById('dialog');
      iframe                  = document.getElementById('iframe');
    }
  }

  if(window.removeEventListener){
    window.removeEventListener("scroll", scrollMessageBox, false);
  }
  else if (window.detachEvent){
    document.detachEvent("scroll", scrollMessageBox);
  }
  
  blocker.parentNode.removeChild(blocker);
  dialog.parentNode.removeChild(dialog);
  if(iframe){
    iframe.parentNode.removeChild(iframe);
  }
  if(wIe && wIeVers < 7){
    document.getElementById('blockerFrame').parentNode.removeChild(document.getElementById('blockerFrame'));
  }
}

function button_YES_onClick(id, value){
  button_hideMessageBox();
  eval ('messagebox_' + id + '_onConfirm("yes","' + value + '")');
  isShownDialog = false;
  isShownMessageBox = false;
}

function button_ALLWAYS_onClick(id, value){
  button_hideMessageBox();
  eval('messagebox_' + id + '_onConfirm("allways","' + value + '")');
  isShownDialog = false;
  isShownMessageBox = false;
}

function button_CANCEL_onClick(id, value){
  button_hideMessageBox();
  eval('messagebox_' + id + '_onConfirm("cancel","' + value + '")');
  isShownDialog = false;
  isShownMessageBox = false;
}

function button_NO_onClick(id, value){
  button_hideMessageBox();
  eval('messagebox_' + id + '_onConfirm("no","' + value + '")');
  isShownDialog = false;
  isShownMessageBox = false;
}

function button_BACK_onClick(id, value){
  button_hideMessageBox();
  eval('messagebox_' + id + '_onConfirm("back","' + value + '")');
  isShownDialog = false;
  isShownMessageBox = false;
}


function wGetParentForm(element){

  var currentElement = element;
  while(currentElement.tagName != 'FORM' && currentElement.tagName != 'BODY'){
    currentElement = currentElement.parentNode;
  }
  return currentElement;
}









function wLoadXmlX(str){

  var domObject = null;

  if(wIe){
    var domObject = new ActiveXObject("MSXML.DomDocument");
    if(!domObject.loadXML(str)){
      throw "wLoadXml Parse error";
    }
  }
  else{
    var domParser = new DOMParser()
    domObject = domParser.parseFromString(str, "text/xml");
  }
  return domObject;
}










function wDomX(){

  this.wGetElementById = function(id, domObject){

    var childs  = domObject.childNodes;
    var element = null;
    if(childs.length > 0){
      for(var i = 0; i < childs.length; i++){
        if(childs[i].nodeName != "SCRIPT" && childs[i].nodeType == 1){

          if(id == childs[i].id){
            return childs[i];
          }
          if(childs[i].hasChildNodes() ){
            element = this.wGetElementById(id, childs[i]);
          }
          if(element != null){
            return element;
          }
        }
      }
    }
    else{
      return element;
    }
  };

  this.wGetElementByName = function(name, domObject){

    var childs  = domObject.childNodes;
    var element = null;
    if(childs.length > 0){
      for(var i = 0; i < childs.length; i++){
        if(childs[i].nodeName != "SCRIPT" && childs[i].nodeType == 1){
          if(name == childs[i].name){
            return childs[i];
          }
          if(childs[i].hasChildNodes() ){
            element = this.wGetElementByName(name, childs[i]);
          }
          if(element != null){
            return element;
          }
        }
      }
    }
    else{
      return element;
    }
  };

  this.wGetFirstChild = function(object){
    if(object == null || typeof object != 'object'){
      return false;
    }
    if(object.firstChild.nodeType != 1){
      return object.firstChild.nextSibling;
    }
    return object.firstChild;
  };

  this.wGetPreviousSibling = function(object){
    if(object == null || typeof object != 'object'){
      return false;
    }
    if(object.previousSibling.nodeType != 1){
      return object.previousSibling.previousSibling;
    }
    return object.previousSibling;
  };

  this.wGetNextSibling = function(object){
    if(object == null || typeof object != 'object'){
      return false;
    }
    if(object.nextSibling != null && object.nextSibling.nodeType != 1){
      return object.nextSibling.previousSibling;
    }
    return object.nextSibling;
  };

  this.wGetParentNodeId = function(parentId, domObject){
    var parentNode = domObject.parentNode;

    while (parentNode != null && parentNode.id != null && parentNode.id != parentId) {
      parentNode = parentNode.parentNode;
    }
    if(parentNode == null){
      return false;
    }
    return parentNode;
  };

  this.wGetParentNodeTagName = function(parent, domObject){

    var parentNode = domObject.parentNode;

    while (parentNode != null && parentNode.tagName != parent) {
      parentNode = parentNode.parentNode;
    }
    if(parentNode == null){
      return false;
    }
    return parentNode;
  };

  this.wGetInputByValue = function(name, value){

    var inputs = document.getElementsByName(name);
    for(var i = 0; i < inputs.length && i < 20; i++){
      if(inputs.item(i).value == value){
        return inputs.item(i);
      }
    }
    return false;
  };

}








function showAllAttributes(obj){
  var attStr;
  var regExp = /funct/i;
  var regExp2 = /Text/i;
  var regExp3 = /^on/i;
  for (var att in obj){

      if (regExp.test(obj[att]) == false && regExp2.test(obj[att]) == false && regExp3.test(obj[att]) == false){
        if(att != 'outerText' && att != 'innerText' && att.indexOf('on' < 0)){
          attStr += att + "=" + obj[att] + "        ";
        }



        alert(att + " = " + obj[att]);
	    }

  }

}









function wGetDirFileToSelect(file){

  if(file.indexOf('http://') == 0 || file.indexOf('https://') == 0  || file.indexOf('ftp://') == 0  || file.indexOf('//') == 0){
    return '/';
  }
  var dirFile = file.replace(/(.*\/)[^\/]*/, '$1');
  return dirFile;
}



function openWin(url, name, width, height, options){


  if(width == ''){
    var regWidth = /width=(\d+)/;
    regWidth.exec(options);
    width = RegExp.$1;
    if(width == ''){
      width = 640;
    }
  }
  else if(width == 'max'){
    width = screen.width;
  }

  if(height == ''){
    var regHeight = /height=(\d+)/;
    regHeight.exec(options);
    height = RegExp.$1;
    if(height == ''){
      height = 480;
    }
  }
  else if(height == 'max'){
    height = screen.height;
  }

  if(!name && !width && !height && !options){
    return window.open(url, name);
  }

  if(!options){
    options = ',resizable=no,scrollbars=no,status=no,location=no';
  }


  var posLeft = (screen.width / 2)  - (width  / 2);
  var posTop  = (screen.height / 2) - (height / 2);
  var rtc = window.open(url, name, 'top='+posTop+',left='+posLeft+',width='+width+',height='+height+',' + options);

  if(!rtc){
    var link = document.createElement('A');
    link.href = "javascript:window.open('" + url + "', '', 'width=" + width + ",height=" + height + "');void(0);";
    link.className = 'popupLink';
    link.innerHTML = 'Fenster jetzt öffnen';
    var popupBlockerBox = document.createElement('DIV');
    popupBlockerBox.className = 'wPopupblocker';
    var popupBlockerBoxInner = document.createElement('DIV');
    popupBlockerBoxInner.className = 'popupBlockerInner'

    var textBeforeLink = document.createElement('SPAN');
    textBeforeLink.innerHTML = 'Der Browser hat das Öffnen eines neuen Fensters verhindert!&#160;';

    popupBlockerBoxInner.appendChild(textBeforeLink);

    popupBlockerBox.appendChild(popupBlockerBoxInner);

    popupBlockerBoxInner.appendChild(link);
    document.body.insertBefore(popupBlockerBox, document.body.firstChild);
  }

  return rtc;
}











function wUsersX(id){
  this.id = id;

  this.wShowSelectUsers = function(title, term, maxEntries, group, type, fieldsToSearch, embedMode, projectGroup){
    var url = '/weblication/grid/scripts/wUsermanager.php?action=showmaskselectuser&returnType=object&filterGroupType=organisation&title='+  title +  '&id=' + this.id + '&limit='+ maxEntries +'&mode=public&embedMode=' + embedMode + '&term=' + term + '&group=' + group + '&type=' + type + '&fieldsToSearch=' + fieldsToSearch + '&projectPath=' + projectGroup;
    wOpenWindowX(url, 'wUsersX', 'width=420,height=470');
  }

}











function wGroupsX(id){
  this.id = id;

  this.wShowSelectGroups = function(title, ok_button, term, maxEntries, group, type, embedMode, projectGroup){
    var url = '/weblication/grid/scripts/wUsermanager.php?action=showmaskselectgroup&returnType=object&mode=public&title=' + title + '&ok_button=' + ok_button + '&term=' + term + '&maxEntries=' + maxEntries + '&group=' + group + '&id=' + this.id + '&embedMode=' + embedMode + '&groupType=' + type + '&projectPath=' + projectGroup;
    wOpenWindowX(url, 'wGroupsX', 'width=420,height=320');
  }
  
  this.wShowSelectGroupsMulti = function(objectId, title, ok_button, term, maxEntries, group, type, embedMode, projectGroup){
    var url = '/weblication/grid/scripts/wUsermanager.php?action=showgroupselectionmultiple&objectId=' + objectId + '&pageType=dialog&mode=public&title=' + title + '&ok_button=' + ok_button + '&term=' + term + '&maxEntries=' + maxEntries + '&group=' + group + '&id=' + this.id + '&embedMode=' + embedMode + '&groupType=' + type + '&projectPath=' + projectGroup;
    wOpenWindowX(url, 'wGroupsX', 'width=420,height=470');
  }

}










function wglInputGroupAdmin(input, input_display){

  this.inputObject  = input;
  this.inputId      = input.name;
  this.inputDisplay = input_display;

  this.wGetCaption = function(group, respFuncId){
    var url = null;
    url = '/weblication/grid/scripts/wUsermanager.php?action=getgroupcaption&group=' + group;
    if(url != null){
      wGetUrlAjax(url, eval(respFuncId));
    }
  };

  this.wSetCaption = function(caption){
    if(typeof this.inputDisplay == 'object' && this.inputDisplay != null){
      this.inputDisplay.value = caption;
    }
  };

  this.wSetInputValues = function(userId, caption){
    if(typeof this.inputObject == 'object' && this.inputObject != null){
      this.inputObject.value = userId;
    }
    if(typeof this.inputDisplay == 'object' && this.inputDisplay != null){
      this.inputDisplay.value = caption;
      this.inputDisplay.title = caption;
    }
  };

  this.wGetInputDisplayValue = function(display){
    if(typeof this.inputDisplay == 'object' && this.inputDisplay != null){
      return this.inputDisplay.value;
    }
    return '';
  };

  this.wGetInputDisplay = function(){
    return this.inputDisplay;
  };

}










function wglInputUserAdmin(input, input_display, listObject, imgObject, type, userType, group){

  this.inputObject  = input;
  this.inputId         = input.name;
  this.inputDisplay = input_display;
  this.imgObject    = imgObject;
  this.imgOpen      = '/weblication/grid/gui/wImages/icon_small/open.gif';
  this.imgClose     = '/weblication/grid/gui/wImages/icon_small/close.gif';
  this.listObject     = listObject;
  this.height          = this.listObject.style.height;
  this.listId            = listObject.id;
  this.type             = type;
  this.userType     = userType;
  this.group           = group;
  this.maxEntries   = 10;

  this.wGetObjectList = function(term, maxEntries, respFuncId){
    if(maxEntries != '' && maxEntries != null){
      this.maxEntries = maxEntries;
    }
    if(typeof this.listObject == 'object' && this.listObject != null){
      var url = '/weblication/grid/scripts/wUsermanager.php?action=showmaskselectuserembed&inputId=' + this.inputId + '&limit='+ this.maxEntries +'&embedMode=public&term=' + term + '&group=' + this.group + '&type=' + this.userType + '&fieldsToSearch=firstname,surname,username';
      wGetUrlAjax(url, eval(respFuncId));
    }
  };

  this.wSetObjectList = function(responseStr){
    if(typeof this.listObject == 'object' && this.listObject != null){
      this.listObject.innerHTML = responseStr;
      var countElement = document.getElementById('countUserEntries_'+ this.inputId);
      var countUsers = countElement.innerHTML;
      if(countUsers == 0){
        this.listObject.style.height = 15 + 'px';
      }
      else if(countUsers < this.maxEntries){
        this.listObject.style.height = (15 * countUsers) + 'px';
      }
      else{
        this.listObject.style.height = this.height;
      }
    }
  };

  this.wGetCaption = function(user, respFuncId){
    var url = null;
    url = '/weblication/grid/scripts/wUsermanager.php?action=getuserdisplayname&user=' + user;
    if(url != null){
      wGetUrlAjax(url, eval(respFuncId));
    }
  };

  this.wSetCaption = function(caption){
    if(typeof this.inputDisplay == 'object' && this.inputDisplay != null){
      this.inputDisplay.value = caption;
    }
  };

  this.wSetInputValues = function(userId, caption){
    if(typeof this.inputObject == 'object' && this.inputObject != null){
      this.inputObject.value = userId;
    }
    if(typeof this.inputDisplay == 'object' && this.inputDisplay != null){
      this.inputDisplay.value = caption;
      this.inputDisplay.title = caption;
    }
  };

  this.wToggleList = function(){


  };

  this.wShowObjectList = function(){
    var dom = new wDomX()
    var prevSib = dom.wGetPreviousSibling(this.listObject);
    var childNodes = prevSib.childNodes;
    var height = -1;
    for(var i = 0; i < childNodes.length; i++){
      height = height + childNodes.item(i).clientWidth;
    }

    this.listObject.style.width = height + 'px';
    this.listObject.style.display = 'block';
  };

  this.wGetInputDisplayValue = function(display){
    if(typeof this.inputDisplay == 'object' && this.inputDisplay != null){
      return this.inputDisplay.value;
    }
    return '';
  };

  this.wGetInputDisplay = function(){
    return this.inputDisplay;
  };

  this.wGetListObject = function(){
    return this.listObject;
  };

  this.wResetInputs = function(caption){
    if(typeof this.inputDisplay == 'object' && this.inputDisplay != null){
      this.inputDisplay.value = '';
    }
    if(typeof this.inputObject == 'object' && this.inputObject != null){
      this.inputObject.value = '';
    }
  };
}








function wSelectMultipleX(id){
  this.id     = id; 
  this.object = null; 
  this.objectExt = new Array();
  this.selectAll = false;
  
  this.wSetObjectExtData = function(value, key, data){
    if(this.objectExt[0] == null){
      this.objectExt[0] = new Object();
    }
    if(this.objectExt[0][value] == null){
      this.objectExt[0][value] = new Array();
      this.objectExt[0][value][0] = new Object();
    }
    this.objectExt[0][value][0][key] = data;
  }
  
  this.wSetObjectExt = function(value, data){
    if(this.objectExt[0] == null){
      this.objectExt[0] = new Object();
    }
    if(this.objectExt[0][value] == null){
      this.objectExt[0][value] = new Array();
    }
    this.objectExt[0][value] = data;
  }
  
  this.wGetObjectExt = function(value, key){
    if(this.objectExt[0] != null){
      if(key != null){
        if(this.objectExt[0][value] != null && this.objectExt[0][value][0] != null){
          return this.objectExt[0][value][0][key];
        }
      }
      return this.objectExt[0][value];
    }
    return null; 
  }
  
  this.wSetStateByValue = function(value, state){
    this.object = document.getElementById(this.id);
    if(typeof this.object == 'object' && this.object.tagName == 'SELECT' && this.object.type == 'select-multiple'){
      if(this.object.options.length == 0){
        return false;
      }
      for(var i = 0; i < this.object.options.length; i++){
        if(this.object.options[i].value == value){
          if(ie){
            this.object.options[i].setAttribute("selected", state);
          }
          else{
            this.object.options[i].selected = state;
          }
          return true;
        }
      } 
    }
    return false;
  };
  
  this.wValueIsSet = function(value){
    this.object = document.getElementById(this.id);
    if(typeof this.object == 'object' && this.object.nodeName == 'SELECT'){
      for(var i = 0; i < this.object.options.length; i++){
        if(this.object.options[i].value == value && this.object.options[i].selected == true){
          return true;
        }
      } 
    }
    return false;
  };
  
  this.wGetIndex = function(value){
    this.object = document.getElementById(this.id);
    if(typeof this.object == 'object' && this.object.nodeName == 'SELECT'){
      for(var i = 0; i < this.object.options.length; i++){
        if(this.object.options[i].value == value){
          return i;
        }
      } 
    }
    return false;
  };  
  
  this.wAddOption = function(value, text, state){
    this.object = document.getElementById(this.id);
    if(typeof this.object == 'object' && this.object.nodeName == 'SELECT'){
      var option = document.createElement("option");
      if(state){
        if(ie){
          option.setAttribute("selected", state);
        }
        else{
          option.selected = state;
        }
      }
      this.object.appendChild(option);
      this.object.options[this.object.options.length - 1].value = value;
      this.object.options[this.object.options.length - 1].appendChild(document.createTextNode(text));
      return true;
    }
    return false;
  };
  
  this.wDeleteOption = function(value){
    this.object = document.getElementById(this.id);
    if(typeof this.object == 'object' && this.object.tagName == 'SELECT'){
      for(var i = 0; i < this.object.options.length; i++){
        if(this.object.options[i].value == value){
          this.object.options[i].parentNode.removeChild(this.object.options[i]);
          return true;
        }
      } 
    }
    return false;
  };
  
  this.wGetOptions = function(){
    this.object = document.getElementById(this.id);
    return this.object.options;
  };
  
  this.wGetOption = function(i){
    this.object = document.getElementById(this.id);
    return this.object.options[i];
  };
  
  this.wGetOptionValue = function(i){
    this.object = document.getElementById(this.id);
    return this.object.options[i].value;
  };
  
  this.wGetOptionsAsArray = function(onlySelected){
    this.object = this.object = document.getElementById(this.id);
    var selected = new Array();
    if(typeof this.object == 'object' && this.object.tagName == 'SELECT'){
      for(var i = 0; i < this.object.options.length; i++){
        if(!onlySelected || this.object.options[i].selected == 'true'){
          selected.push(this.object.options[i].value); 
        }
      } 
    }
    return selected;
  }
  
  this.wImportOptions = function(options){
    this.object = document.getElementById(this.id);
    for(var i = 0; i < options.length; i++){
      this.wImportOption(options[i]);
    }
  }
  
  this.wRemoveOptions = function(options){
    this.object = document.getElementById(this.id);
    for(var i = 0; i < options.length; i++){
      this.wDeleteOption(options[i].value);
    }
  }
  
  this.wRemoveAllOptions = function(){
    this.object = document.getElementById(this.id);
    var clonedNode = this.object.cloneNode(false);
    this.object.parentNode.replaceChild(clonedNode, this.object);
  }
  
  this.wImportOption = function(option){
    this.object = document.getElementById(this.id);  
    var val = option.value;
    eval('var Ausdruck = /="?' + val + '"\s/');
    if(Ausdruck.exec(this.object.innerHTML) == null){
      this.object.appendChild(option.cloneNode(true));
    }
  }

  this.wSetSelectAll = function(status){
    this.selectAll = true;
    if(status === false){
      this.selectAll = false;
    }
  }
  
  this.wAllSelected = function(){
    return this.selectAll;
  }
  
  this.isSthSelected = function(){
    var options = this.wGetOptions();
    for(var i = 0; i < options.length; i++){
      if(options[i].selected === true){
        return true;
      }
    }
    return false; 
  }
}










function wShowLanguageVersionX(langVersion, redirectUrl){

  var url = '/weblication/grid/scripts/wSystem.php?action=showLanguageVersion&redirectUrl=' + decodeURI(redirectUrl) + '&langVersion=' + langVersion;
  location.href = url;
}










function wSetSelectDisplayValueX(selectObject, inputObject){

  if(typeof selectObject == 'object' && typeof inputObject == 'object'){
    if(selectObject.nodeName == 'SELECT' && inputObject.nodeName == 'INPUT'){
      inputObject.value = selectObject.options[selectObject.selectedIndex].text;
    }
  }
}









function wLockContextMenueX(){

  return false;
}









function wValidateFormElementX(formObject, id, type, required){


  if(typeof formObject == 'object' && formObject.nodeName == 'FORM'){
    var result = true;
    if(required == 1){
      if(type == 'checkbox' || type == 'radio'){
        var isSet = false;
        if(formObject.elements[id].nodeName == 'INPUT' && formObject.elements[id].checked){
          isSet = true;
        }
        else{

          for(var i = 0; i < formObject.elements[id].length && !isSet; i++){
            if(formObject.elements[id][i].checked){
              isSet = true;
            }
          }
        }
        result = isSet;
      }

      else if(formObject.elements[id].length && formObject.elements[id].nodeName != 'SELECT'){
        var isSet = false;
        for(var i = 0; i < formObject.elements[id].length && !isSet; i++){
	        if(formObject.elements[id][i].value.replace(/^\s+|\s+$/, '') != ''){
	          isSet = true;
	        }
	      }
	      result = isSet;
      }
      else if(formObject.elements[id].value.replace(/^\s+|\s+$/, '') == ''){
        result = false;
      }
    }
    
    if(!wValidateFormElementTypeX(formObject, id, type) && (formObject.elements[id].value != '' || type == 'calendarSelect')){
      result = false;
    }

    var classNameObject = null;
    if(type == 'select' || type == 'calendarSelect'){
      classNameObject = 'wglSelectOk';
    }
    else if(type == 'calendar' || type == 'calendarClock'){
      classNameObject = 'wglInputCalendar';
    }
    else if(type == 'radio'){
      classNameObject = 'wglRadiobuttonOk';
    }
    else if(type == 'checkbox'){
      classNameObject = 'wglInputCheckboxOk';
    }
    else{
      classNameObject = 'wglInputOk';
    }

    if(!result){
      if(type == 'select' || type == 'calendarSelect'){
        classNameObject = 'wglSelectError';
      }
      else if(type == 'radio'){
        classNameObject = 'wglRadiobuttonError';
      }
      else{
        classNameObject = 'wglInputError';
      }
    }
		
    if(type == 'checkbox'){
   		if(formObject.elements[id].length){
	   		for(var i = 0; i < formObject.elements[id].length; i++){
	        formObject.elements[id][i].parentNode.className = formObject.elements[id][i].parentNode.className.replace(/\swglInputError|\swglSelectError|\swglInputOk|\swglInputCheckboxOk|\swglSelectOk/, "") + " " + classNameObject;
	      }
   		}
   		else{
   			formObject.elements[id].parentNode.className = formObject.elements[id].parentNode.className.replace(/\swglInputError|\swglSelectError|\swglInputOk|\swglInputCheckboxOk|\swglSelectOk/, "") + " " + classNameObject;
   		}
    }
    else if(type == 'radio'){
      if(formObject.elements[id].length){
	      for(var i = 0; i < formObject.elements[id].length; i++){
	        formObject.elements[id][i].className = formObject.elements[id][i].className.replace(/\swglRadiobuttonError|\swglInputError|\swglSelectError|\swglRadiobuttonOk|\swglInputOk|\swglSelectOk/, "") + " " + classNameObject;
	        formObject.elements[id][i].parentNode.className = formObject.elements[id][i].parentNode.className.replace(/\swglRadiobuttonError|\swglInputError|\swglSelectError|\swglRadiobuttonOk|\swglInputOk|\swglSelectOk/, "") + " " + classNameObject;
	      }
	    }
	    else{
	      formObject.elements[id].className = formObject.elements[id].className.replace(/\swglRadiobuttonError|\swglInputError|\swglSelectError|\swglRadiobuttonOk|\swglInputOk|\swglSelectOk/, "") + " " + classNameObject;
	      formObject.elements[id].parentNode.className = formObject.elements[id].parentNode.className.replace(/\swglRadiobuttonError|\swglInputError|\swglSelectError|\swglRadiobuttonOk|\swglInputOk|\swglSelectOk/, "") + " " + classNameObject;
	    }
    }
    else if(type == 'calendarSelect'){
      formObject.elements['day_' + id].className = formObject.elements['day_' + id].className.replace(/\swglInputError|\swglSelectError|\swglInputOk|\swglSelectOk/, "") + " " + classNameObject;
      formObject.elements['month_' + id].className = formObject.elements['month_' + id].className.replace(/\swglInputError|\swglSelectError|\swglInputOk|\swglSelectOk/, "") + " " + classNameObject;
      formObject.elements['year_' + id].className = formObject.elements['year_' + id].className.replace(/\swglInputError|\swglSelectError|\swglInputOk|\swglSelectOk/, "") + " " + classNameObject;
      if(formObject.elements['hour_' + id]){
	      formObject.elements['hour_' + id].className = formObject.elements['hour_' + id].className.replace(/\swglInputError|\swglSelectError|\swglInputOk|\swglSelectOk/, "") + " " + classNameObject;
	      formObject.elements['min_' + id].className = formObject.elements['min_' + id].className.replace(/\swglInputError|\swglSelectError|\swglInputOk|\swglSelectOk/, "") + " " + classNameObject;
      }
    }
    else if(formObject.elements[id + '_display'] && formObject.elements[id + '_display'].type != 'hidden'){
      if(formObject.elements[id + '_display'].length && formObject.elements[id + '_display'].nodeName != 'SELECT'){
	      for(var i = 0; i < formObject.elements[id + '_display'].length; i++){
	      	formObject.elements[id + '_display'][i].className = formObject.elements[id][i].className.replace(/\swglInputError|\swglSelectError|\swglInputOk|\swglSelectOk/, "") + " " + classNameObject;
	      }
	    }
	    else{
      	formObject.elements[id + '_display'].className = formObject.elements[id].className.replace(/\swglInputError|\swglSelectError|\swglInputOk|\swglSelectOk/, "") + " " + classNameObject;
      }
    }
    else if(formObject.elements['display_' + id] && formObject.elements['display_' + id].type != 'hidden'){
      if(formObject.elements['display_' + id].length && formObject.elements['display_' + id].nodeName != 'SELECT' ){
	      for(var i = 0; i < formObject.elements['display_' + id].length; i++){
		      formObject.elements['display_' + id][i].className = formObject.elements['display_' + id][i].className.replace(/\swglInputError|\swglSelectError|\swglInputOk|\swglSelectOk/, "") + " " + classNameObject;
	      }
	    }
	    else{
	      formObject.elements['display_' + id].className = formObject.elements['display_' + id].className.replace(/\swglInputError|\swglSelectError|\swglInputOk|\swglSelectOk/, "") + " " + classNameObject;
	    }
    }
    else{
      if(formObject.elements[id].length && formObject.elements[id].nodeName != 'SELECT' ){
	      for(var i = 0; i < formObject.elements[id].length; i++){
		      formObject.elements[id][i].className = formObject.elements[id][i].className.replace(/\swglInputError|\swglSelectError|\swglInputOk|\swglSelectOk/, "") + " " + classNameObject;
	      }
	    }
	    else{
	      formObject.elements[id].className = formObject.elements[id].className.replace(/\swglInputError|\swglSelectError|\swglInputOk|\swglSelectOk/, "") + " " + classNameObject;
	    }
    }
    return result;
  }
  return false;
}









function wValidateFormElementTypeX(formObject, id, type){
  if(type == 'email'){
    var value   = formObject.elements[id].value;
    if(value.search(/([a-zA-Z0-9\.\-_]+@[a-zA-Z0-9][a-zA-Z0-9\.-]*\.\w\w+)/) != 0){
      return false;
    }
    else if(RegExp.$1.length != value.length){
      return false;
    }
  }
  else if (type == 'calendarSelect'){
    return wValidateCalendarSelectX(id);
  }
  return true;
}










function wValidateCalendarSelectX(id){
  var day = document.getElementsByName('day_' + id)[0].value;
  var month = document.getElementsByName('month_' + id)[0].value;
  var year = document.getElementsByName('year_' + id)[0].value;
  if((day == '' || month == '' || year == '' || year < 1901) && (day != '' || month != '' || year != '')){
    return false;
  }
  return true;
}










function wAddErrorClass(object, className){
  if(typeof object == 'object' && object != null){
    object.className = object.className.replace(/\swglInputError|\swglSelectError|\swglInputOk|\swglSelectOk/, "") + " " + className;
  }
}









function wHideMessageboxX(){
  hideMessagebox();
}









function hideMessagebox(){

  if(parent.frames.length < 1){
    docBody                 = document.body;
    blocker                 = document.getElementById('blocker');
    dialog                  = document.getElementById('dialog');
  }
  else{
    if(parent.document.body.tagName != 'FRAMESET'){
      if(ie){
        var docBody                 = document.body;
        var blocker                 = document.getElementById('blocker');
        var dialog                  = document.getElementById('dialog');
      }
      else{
        docBody                 = document.body;
        blocker                 = document.getElementById('blocker');
        dialog                  = document.getElementById('dialog');
      }
    }
    else{
      docBody                 = document.body;
      blocker                 = document.getElementById('blocker');
      dialog                  = document.getElementById('dialog');
    }
  }
    
  if(blocker){
    
    if(messageBoxEmbed){
      blocker.style.display = 'none';
    }
    else{
      blocker.parentNode.removeChild(blocker);
    }
  }
  if(dialog){
    if(messageBoxEmbed){
      dialog.style.display = 'none';
    }
    else{
      dialog.parentNode.removeChild(dialog);
    }
  }
  if(ie && ieVers < 7){
    if(document.getElementById('blockerFrame')){
  	 document.getElementById('blockerFrame').parentNode.removeChild(document.getElementById('blockerFrame'));
    }
  }
  clickEvents = new Array();

  isShownDialog = false;
  isShownMessageBox = false;
}










function wglSelectGroups(name){
  
  this.name = name;
  this.selObject = new wSelectMultipleX(name);
  this.lObj   = null;
  this.tmpObj = null;
  this.standard = null;




  this.wSetList = function(object){
    this.lObj = object;
  }
  
  this.wSetTemplate = function(object){
    this.tmpObj = object;
  }
  
  this.wSetStandard = function(object){
    this.standard = object;
  }
  
  this.wInitGroupList = function(value, caption, type){
  
    this.wAddGroupSelection(this.selObject);
    return true;
        
  }
   
  this.wAddGroupSelection = function(multiSel){
    if(multiSel.isSthSelected()){
      var values = multiSel.wGetOptionsAsArray();
      for(var i = 0; i < values.length; i++){
        if(!this.selObject.wValueIsSet(values[i])){
          var caption = multiSel.wGetObjectExt(values[i], 'caption');
          var type = multiSel.wGetObjectExt(values[i], 'type');
          this.selObject.wAddOption(values[i], caption);
          var clonedRow = this.tmpObj.cloneNode(true);
          while (clonedRow.innerHTML.search(/W_CAPTION/) != -1) {
            clonedRow.innerHTML = clonedRow.innerHTML.replace('W_CAPTION', caption);
          }
          while (clonedRow.innerHTML.search(/W_ID/) != -1) {
            clonedRow.innerHTML = clonedRow.innerHTML.replace('W_ID', values[i]);
          }
          var img = clonedRow.getElementsByTagName('IMG');
          for(var j = 0; j < img.length; j++){
            var src = decodeURI(img[j].src);
            img[j].src = src.replace('W_TYPE', type);
          }
          clonedRow.id = this.idNewEntry + values[i];
          clonedRow.style.display = 'block';  
          this.lObj.appendChild(clonedRow);
          if(this.standard.value == ''){
            this.wSetStandardGroup(values[i]);
          }
        }
        this.selObject.wSetStateByValue(values[i], true);
        
      }
    }
    return true;  
  }
  
  this.wRemoveGroup = function(value, object){
    try{
      this.selObject.wDeleteOption(value);
      this.lObj.removeChild(object);
      if(this.standard.value == value){
        var dom = new wDomX();
        var firstElement = dom.wGetNextSibling(this.tmpObj);
        if(firstElement != null){
          this.wSetStandardGroup(firstElement.id.replace('GroupEntry_' + this.name + '_', ''));
        }
        else{
          this.standard.value = '';
        }
      }
    }
    catch(e){alert(e);} 
  }
  
  this.wSetStandardGroup = function(value){
    try{
      if(this.standard.value != ''){
        toggleCheckBox(document.getElementById('GroupEntry_' + this.name + '_' + this.standard.value + '_standard'));
      }
      this.standard.value = value;
      toggleCheckBox(document.getElementById('GroupEntry_' + this.name + '_' + value + '_standard'));          
    }
    catch(e){alert(e);}
  }
  
  this.wOpenGroups = function(objectId, title, term, maxEntries, option2, option3, type, public, projectPath){
    var groupObject = new wGroupsX(this.name);

    groupObject.wShowSelectGroupsMulti(objectId, title, term, maxEntries, option2, option3, type, public, projectPath);
  }
  
}










function wglInputGroupAdmin(input, input_display){

  this.inputObject  = input;
  this.inputId      = input.name;
  this.inputDisplay = input_display;

  this.wGetCaption = function(group, respFuncId){
    var url = null;
    url = '/weblication/grid/scripts/wUsermanager.php?action=getgroupcaption&group=' + group;
    if(url != null){
      wGetUrlAjax(url, eval(respFuncId));
    }
  };

  this.wSetCaption = function(caption){
    if(typeof this.inputDisplay == 'object' && this.inputDisplay != null){
      this.inputDisplay.value = caption;
    }
  };

  this.wSetInputValues = function(userId, caption){
    if(typeof this.inputObject == 'object' && this.inputObject != null){
      this.inputObject.value = userId;
    }
    if(typeof this.inputDisplay == 'object' && this.inputDisplay != null){
      this.inputDisplay.value = caption;
      this.inputDisplay.title = caption;
    }
  };

  this.wGetInputDisplayValue = function(display){
    if(typeof this.inputDisplay == 'object' && this.inputDisplay != null){
      return this.inputDisplay.value;
    }
    return '';
  };

  this.wGetInputDisplay = function(){
    return this.inputDisplay;
  };

}










function wglInputUserAdmin(input, input_display, listObject, imgObject, type, userType, group){

  this.inputObject  = input;
  this.inputId         = input.name;
  this.inputDisplay = input_display;
  this.imgObject    = imgObject;
  this.imgOpen      = '/weblication/grid/gui/wImages/icon_small/open.gif';
  this.imgClose     = '/weblication/grid/gui/wImages/icon_small/close.gif';
  this.listObject     = listObject;
  this.height          = this.listObject.style.height;
  this.listId            = listObject.id;
  this.type             = type;
  this.userType     = userType;
  this.group           = group;
  this.maxEntries   = 10;

  this.wGetObjectList = function(term, maxEntries, respFuncId){
    if(maxEntries != '' && maxEntries != null){
      this.maxEntries = maxEntries;
    }
    if(typeof this.listObject == 'object' && this.listObject != null){
      var url = '/weblication/grid/scripts/wUsermanager.php?action=showmaskselectuserembed&inputId=' + this.inputId + '&limit='+ this.maxEntries +'&embedMode=public&term=' + term + '&group=' + this.group + '&type=' + this.userType + '&fieldsToSearch=firstname,surname,username';
      wGetUrlAjax(url, eval(respFuncId));
    }
  };

  this.wSetObjectList = function(responseStr){
    if(typeof this.listObject == 'object' && this.listObject != null){
      this.listObject.innerHTML = responseStr;
      var countElement = document.getElementById('countUserEntries_'+ this.inputId);
      var countUsers = countElement.innerHTML;
      if(countUsers == 0){
        this.listObject.style.height = 15 + 'px';
      }
      else if(countUsers < this.maxEntries){
        this.listObject.style.height = (15 * countUsers) + 'px';
      }
      else{
        this.listObject.style.height = this.height;
      }
    }
  };

  this.wGetCaption = function(user, respFuncId){
    var url = null;
    url = '/weblication/grid/scripts/wUsermanager.php?action=getuserdisplayname&user=' + user;
    if(url != null){
      wGetUrlAjax(url, eval(respFuncId));
    }
  };

  this.wSetCaption = function(caption){
    if(typeof this.inputDisplay == 'object' && this.inputDisplay != null){
      this.inputDisplay.value = caption;
    }
  };

  this.wSetInputValues = function(userId, caption){
    if(typeof this.inputObject == 'object' && this.inputObject != null){
      this.inputObject.value = userId;
    }
    if(typeof this.inputDisplay == 'object' && this.inputDisplay != null){
      this.inputDisplay.value = caption;
      this.inputDisplay.title = caption;
    }
  };

  this.wToggleList = function(){


  };

  this.wShowObjectList = function(){
    var dom = new wDomX()
    var prevSib = dom.wGetPreviousSibling(this.listObject);
    var childNodes = prevSib.childNodes;
    var height = -1;
    for(var i = 0; i < childNodes.length; i++){
      height = height + childNodes.item(i).clientWidth;
    }

    this.listObject.style.width = height + 'px';
    this.listObject.style.display = 'block';
  };

  this.wGetInputDisplayValue = function(display){
    if(typeof this.inputDisplay == 'object' && this.inputDisplay != null){
      return this.inputDisplay.value;
    }
    return '';
  };

  this.wGetInputDisplay = function(){
    return this.inputDisplay;
  };

  this.wGetListObject = function(){
    return this.listObject;
  };

  this.wResetInputs = function(caption){
    if(typeof this.inputDisplay == 'object' && this.inputDisplay != null){
      this.inputDisplay.value = '';
    }
    if(typeof this.inputObject == 'object' && this.inputObject != null){
      this.inputObject.value = '';
    }
  };
}







function wglContToggObjH(){
  this.bodys = new Array();
  this.imgs = new Array();
  this.title = '';

  this.constructor = function(title){
    this.bodys[0] = new Object();
    this.imgs[0] = new Object();
    this.title = title;
  };

  this.addContObj = function(id, title){
    this.bodys[0][id] = document.getElementById('wglContainerToogleBody_' + id);
    this.imgs[0][id] = document.getElementById('wglContainerToogleImg_' + id);
  };

  this.toggleDisplay = function(id){
    try{
      var display = 'none';
      var imgsrc = 'open';
      var imgtitle = ' einblenden';

      if(this.bodys[0][id].style.display == 'none'){
        display  = 'block';
        imgsrc   = 'close';
        imgtitle = ' ausblenden';
      }

      this.bodys[0][id].style.display = display;
      this.imgs[0][id].src = '/weblication/grid/gui/wImages/icon_small/' + imgsrc + '.gif';
      if(this.imgs[0][id].title != '' && this.imgs[0][id].title != null){
        this.imgs[0][id].title = this.title + imgtitle;
      }
    }
    catch(e){alert(e);}
  };
}

