// alert("dbx.js");

function dbxPopUp(linkTarget,vlParameter)
{
  // oeffnet neues Fenster
  // scrollbars=yes, resizable=yes ist fest
  // vlParameter = valueList:wert1=1,wert2=2,  
  // ziel
  // arrParameters[wert1] = 1;
  // arrParameters[wert2] = 2;  
  // alert("dbxPopUp");
  vlParameterPreSet = "setID=0,name=dbxPopUp,setFocus=1,left=9999,top=9999,width=400,height=400,scrollbars=yes,resizable=yes,";
  vlParameter  = vlParameterPreSet + vlParameter;
  arrParameter = dbxValueList(vlParameter,",");
  
  // alertArray(arrParameter);
  
  if(arrParameter["left"] == "9999" 
  || arrParameter["top"]  == "9999")
  {
  arrParameter["left"] = (screen.width  / 2) - (arrParameter["width"]  / 2);
  arrParameter["top"]  = (screen.height / 2) - (arrParameter["height"] / 2);
  }
  
  objPopUp = window.open(linkTarget, arrParameter["name"], "width="+arrParameter["width"]+
     ", height="+arrParameter["height"]+
	 ", left="+arrParameter["left"]+
	 ", top="+arrParameter["top"]+
	 ", scrollbars="+arrParameter["scrollbars"]+ 
	 ", resizable="+arrParameter["resizable"]);

  if(arrParameter["setFocus"]==1)
  { objPopUp.focus(); }
  
  if(arrParameter["setID"] != 0)
  { objPopUp.setID = arrParameter["setID"]; }
  
  // return true;
  
  if(objPopUp) 
  {  return true; }
  else 
  { return false; }	 
 
}


function openPopup(pFilename,pWidth,pHeight) 
{
  strSendParameter = "width="+pWidth+",height="+pHeight;
  dbxPopUp(pFilename,strSendParameter);
}



function dbxValueList(vlParameter,strSeparator)
{

    if(!strSeparator) strSeparator = ",";
    arrRetArr = new Array();
    arrAllPa  = vlParameter.split(strSeparator);
    anzAllPa  = arrAllPa.length;
    // alert(anzAllPa);

    for(i=0;i<anzAllPa;i++)
    {
    arrTemp  = arrAllPa[i].split("=");
    strTemp0 = arrTemp[0];
    strTemp1 = arrTemp[1];
    arrRetArr[strTemp0] = strTemp1; 
    }

    // alertArray(arrRetArr)

    return arrRetArr;
 
} // function




function nextEntry(intAktWert,intGrenzWert,initPlusMinus)
// aufruf
// 3,6,add -> 4 | 6,6,add -> 6 | 7,6,add ->6
// --------------------------------------------------
{
    alert(intAktWert + " | " + intGrenzWert + " | " + initPlusMinus);
	
	// Addieren
    if(initPlusMinus == "add")
    {
    intNeuWert = (intAktWert*1) + 1;
    if(intNeuWert > intGrenzWert) intNeuWert = intGrenzWert;
    }
    
    // Subtrahieren
    if(initPlusMinus == "sub")
    {
    intNeuWert =  (intAktWert*1) - 1;;
    if(intNeuWert < intGrenzWert) intNeuWert = intGrenzWert; 
    }

    return intNeuWert;
}




function alertArray(arrToShow)
// -----------------------------------------------------------------------------
{
    var nl         = "\n";
    var ct         = 0;
    var strShow    = "";

    for(var valAttribute in arrToShow)
    {
    ct++;
    strShow = strShow + valAttribute + " : " + arrToShow[valAttribute] + nl; 
    }

    strShow = "Count: " + ct + nl + strShow;

    alert(strShow);

    return;
} // function











function leadingZeros(pValue,pCntLength)
// -----------------------------------------------------------------------------
{
  var strPrefix = "0";
  var strResult = "";
  var strMinus  = "";  

  strMinus  = (pValue < 0) ? "-" : "";
  strResult = (strPrefix == "0") ? strMinus : ""; 
  
  pValue      = Math.abs(parseInt(pValue,10)); 
  pCntLength -= (""+pValue).length; 
  
  for(var cnt=1; cnt<=pCntLength;cnt++) 
  { strResult+=""+strPrefix; } 
  
  strResult += ((strPrefix != "0") ? minus : "") + pValue; 
  return strResult; 
}
