/*****************************************************/
/** Title:         ICSS                             **/
/** Description:   JavaScript for user interface    **/
/** Copyright:     Copyright (c) 2003               **/
/** Company:       SAP AG                           **/
/** Author         Brigitte Doyon                   **/
/**                Djamal Ziani                     **/
/** Creation date: 22.07.2003                       **/
/** Version 	   4.0                              **/
/*****************************************************/


function explanationText(explanation, elementId) {
   if (document.getElementById(elementId).value == explanation ) {
        document.getElementById(elementId).value = "";
        document.getElementById(elementId).style.color= "#000000";
   } else {
      if (document.getElementById(elementId).value == "" ) {
        document.getElementById(elementId).value = explanation;
        document.getElementById(elementId).style.color= "#808080";
     }
   }
}


function changeB2CButtonStat(_id, enableFlag) {
  if (document.getElementById(_id) != null) {
      document.getElementById(_id).disabled = !enableFlag;
      if (!enableFlag) {
          document.getElementById(_id).className = "buttonDisabled";
       }
       else {
           document.getElementById(_id).className = "button2D";
      }
  }
}


function setB2BButtonStyle(buttontoProcess, enableFlag, spanToProcess, accessibility) {
    document.getElementById(buttontoProcess).disabled = !enableFlag;
    if (!enableFlag) {
	  document.getElementById(buttontoProcess).className = "buttonDisabled";
	  if (accessibility && spanToProcess != '')
           document.getElementById(spanToProcess).style.visibility = 'visible';
    } else {
        document.getElementById(buttontoProcess).className = "head";
	  if (accessibility && spanToProcess != '')
           document.getElementById(spanToProcess).style.visibility = 'hidden';
    }
}




function trimLeading(theText){
   var BegBlankChar = /^\s+/g;
   theText = theText.replace(BegBlankChar, "");
   return theText;
}


function isEmpty(theField){
  var long_text = trimLeading(document.getElementById(theField).value);
  if (long_text == '')
    return true;
  else
    return false;
}

function numbersonly(fieldId, e, dec) {
  var key;
  var keychar;
  if (window.event)
     key = window.event.keyCode;
  else if (e)
     key = e.which;
  else
     return true;
  keychar = String.fromCharCode(key);

  // control keys
  if ((key==null) || (key==0) || (key==8) ||
      (key==9) || (key==13) || (key==27) )
     return true;

  // numbers
  else if ((("0123456789").indexOf(keychar) > -1))
     return true;

  // decimal point jump
  else if (dec && ((keychar == ".") || (keychar == ","))) {
      var theValue = document.getElementById(fieldId).value;
      if ((theValue.indexOf(".") >= 0) || (theValue.indexOf(",") >= 0))
              return false;
       else
      return true;
     }
  else
     return false;
}


  function dynamicToggle(idName, openFlag) {
    opera = false;
    // Opera V6 cannot change style.display, but it can disguise itself
    // as nearly every browser. With the userAgent property we find out
    // its true nature.

    if (navigator.userAgent.indexOf("Opera") != -1){
      opera = true;
    }
    if (document.all && !opera) {
      // the world of the IEs
      openIcon = document.all(idName + "open");
      closeIcon = document.all(idName + "close");
      target = document.all(idName);
      if ((target.style.display == "none") || (openFlag == true)) {
                  target.style.display = "inline";
                  openIcon.style.display = "none";
                  closeIcon.style.display = "inline";
                  document.getElementById(idName + "d").value = "DISPLAY: inline";
      }else {
                  target.style.display = "none";
                  openIcon.style.display = "inline";
                  closeIcon.style.display = "none";
                  document.getElementById(idName + "d").value = "DISPLAY: none";
      }
    }
    else if (document.getElementById && !opera) {
      // the world of W3C without Opera
      openIcon = document.getElementById(idName + "open");
      closeIcon = document.getElementById(idName + "close");
      target = document.getElementById(idName);
      if ((target.style.display == "none") || (openFlag == true)) {
                  target.style.display = "table-row";
                  openIcon.style.display = "none";
                  closeIcon.style.display = "inline";
                  document.getElementById(idName + "d").value = "DISPLAY: inline";
      }else {
                  target.style.display = "none";
                  openIcon.style.display = "inline";
                  closeIcon.style.display = "none";
                  document.getElementById(idName + "d").value = "DISPLAY: none";
      }
    }
    else {
       // handle NS4.7 and Opera
      alert("ServerRequest");
    }
}

function toggle(idName, openFlag) {
    opera = false;
    // Opera V6 cannot change style.display, but it can disguise itself
    // as nearly every browser. With the userAgent property we find out
    // its true nature.

    if (navigator.userAgent.indexOf("Opera") != -1){
      opera = true;
    }
    if (document.all && !opera) {
      // the world of the IEs
      openIcon = document.all(idName + "open");
      closeIcon = document.all(idName + "close");
      target = document.all(idName);
      if ((target.style.display == "none") || (openFlag == true)) {
                  target.style.display = "inline";
                  openIcon.style.display = "none";
                  closeIcon.style.display = "inline";
      }else {
                  target.style.display = "none";
                  openIcon.style.display = "inline";
                  closeIcon.style.display = "none";
      }
    }
    else if (document.getElementById && !opera) {
      // the world of W3C without Opera
      openIcon = document.getElementById(idName + "open");
      closeIcon = document.getElementById(idName + "close");
      target = document.getElementById(idName);
      if ((target.style.display == "none") || (openFlag == true)) {
                  target.style.display = "table-row";
                  openIcon.style.display = "none";
                  closeIcon.style.display = "inline";
      }else {
                  target.style.display = "none";
                  openIcon.style.display = "inline";
                  closeIcon.style.display = "none";
      }
    }
    else {
       // handle NS4.7 and Opera
      alert("ServerRequest");
    }
}

function printEntity(_jsp) {
  var myBars = 'directories=no, menuBar=no, status=no';
  var myOptions = 'scrollbars=yes, innerWidth=500, innerHeigth = 400';
  var myFeatures = myBars + ',' + myOptions;
  var newWin = open('', 'myWin', myFeatures);
  newWin.location.href=_jsp;
  newWin.focus();
}
