/*================================================================================*/
/*                                                                                */
/*             BW2Technologies.Web.JScript.Framework (Alpha V1.0.0.0)             */
/*                                                                                */
/*                             Web-Framework Global                               */
/*                                                                                */
/*              Copyright © 2006-2007 by BW2Technologies (HP. Lassnig)            */
/*                                                                                */
/*================================================================================*/

/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/


/*================================================================================*/
/* <Function> Debuging : Write Debug-Information to the Debug-Window </Function>
/*================================================================================*/
function __bw2Debug(strMessage) {
         var oDW = __bw2GetElementById('oBW2DebugWindowView');
         if (oDW != null) oDW.innerHTML = strMessage;
}

/*================================================================================*/
/* <Function> Debuging : Create a Debug-Window </Function>
/*================================================================================*/
function __bw2DebugCreate(strHtmlObjectID, nWidth, nHeight, nLeft, nTop) {
         if (!strHtmlObjectID) strHtmlObjectID = 'oForm';
		 var oObj = __bw2GetElementById(strHtmlObjectID);

		 if (!oObj) return;
         if (!nWidth) nWidth = __bw2WindowWidth() / 2;
         if (!nHeight) nHeight = 100;
         if (!nLeft) nLeft = 10;
         if (!nTop) nTop = __bw2WindowHeight() - nHeight - 10;

         /*--- Form-Body ---*/         
         var oDW = document.createElement('DIV');

         oDW.id = 'oBW2DebugWindow';
         oDW.style.position = 'absolute';
         oDW.style.left = nLeft;
         oDW.style.top = nTop;
         oDW.style.width = nWidth;
         oDW.style.height = nHeight;
         oDW.OffsetX = nLeft;
         oDW.OffsetY = __bw2WindowHeight() - nTop;

         oDW.style.border = '1px solid black';
         oDW.style.backgroundColor = 'red'; //'#F4F0A2';
         oDW.style.fontFamily = 'Arial, Tahoma';
         oDW.style.fontSize = '11px';
         oDW.style.fontStyle = 'normal';

         oDW.Type = 'form';
         oDW.Moving = true;
         oDW.Zorder = true;
         
         if (_fIE) oDW.style.filter = 'progid:dximagetransform.microsoft.shadow(direction=150, strength=3, color=#a0a0a0)';

         /*--- Form-Caption ---*/         
         var oDWC = document.createElement('DIV');

         oDWC.style.position = 'absolute';
         oDWC.style.left = 0;
         oDWC.style.top = 0;
         
         if (_fIE) {
            oDWC.style.cursor = 'hand';
            oDWC.style.width = nWidth - 2;
            oDWC.style.height = 20;
         } else {
            oDWC.style.cursor = 'pointer';
            oDWC.style.width = nWidth - 2;
            oDWC.style.height = 16;
         } 

         oDWC.style.borderBottom = '1px solid black';
         oDWC.style.backgroundColor = '#F0E68C';
         oDWC.style.color = '#555555';
         oDWC.style.paddingLeft = '2px';
         oDWC.style.paddingTop = '2px';
         oDWC.style.fontFamily = 'Arial, Tahoma';
         oDWC.style.fontSize = '11px';
         oDWC.style.fontStyle = 'normal';
         oDWC.innerHTML = 'BW2 Debug-View';

         oDWC.Moving = true;
         oDWC.BaseObject = oDW; 

         /*--- Form-View ---*/         
         var oDWV = document.createElement('DIV');

         oDWV.id = 'oBW2DebugWindowView';
         oDWV.style.position = 'absolute';
         oDWV.style.left = 0;

         if (_fIE) {
            oDWV.style.top = 20;
            oDWV.style.width = nWidth - 2;
            oDWV.style.height = nHeight - 22;
         } else {
            oDWV.style.top = 19;
            oDWV.style.width = nWidth - 6;
            oDWV.style.height = nHeight - 25;
         } 

         oDWV.style.padding = '3px';
         oDWV.style.backgroundColor = '#F4F0A2';
         oDWV.style.fontFamily = 'Arial, Tahoma';
         oDWV.style.fontSize = '11px';
         oDWV.style.fontStyle = 'normal';
         oDWV.style.overflow = 'auto';

         oDWV.Moving = false;
         oDWV.BaseObject = oDW; 

         /*--- Adding Objects ---*/ 
         oDW.appendChild(oDWC);
         oDW.appendChild(oDWV);
         oObj.appendChild(oDW);
         
         if (_fIE) __bw2AddEventListener(window, 'RESIZE', __bw2DebugPosition, false);

         __bw2AddEventListener(oDW, 'mousedown', __bw2ObjectMove, false);
}

/*================================================================================*/
/* <Function> Debuging : Positioning Debug-Window by Resize & Scroll </Function>
/*================================================================================*/
function __bw2DebugPosition() {
         try {
             var oDW = __bw2GetElementById('oBW2DebugWindow')
             if (!oDW) return;

             with (oDW) {
                  //__bw2Debug('Window With/Height : ' + __bw2WindowWidth() + '/' + __bw2WindowHeight() + ', ' + OffsetX)

                  if (!OffsetX) {
                     style.left = 10;
                  } else {
                     style.left = OffsetX;
                  }
                     
                  if (!OffsetY) {
                     style.top = __bw2WindowHeight() - offsetHeight - 10;
                  } else {
                     if (offsetTop < 0) {
                        OffsetY = __bw2WindowHeight();
                        style.top = 0;
                     //} else if (OffsetY > 20) {
                     //   OffsetY = 20;
                     //   style.top = __bw2WindowHeight() - OffsetY;

                     } else {
                        style.top = __bw2WindowHeight() - OffsetY;
                     }  
                  }
             }
         } catch (e) {
             //alert('__bw2DebugPosition : ' + e);
         }
}

/*================================================================================*/
/* <Function> Debuging : Show Debug-Window </Function>
/*================================================================================*/
function __bw2DebugON() {
         try {
//alert('__bw2DebugON');
             var oDW = __bw2GetElementById('oBW2DebugWindow');
             if (!oDW) return;

             with (oDW) {
                  style.display = 'block';
             }
         } catch (e) {
             alert('__bw2DebugON : ' + e);
         }
}

/*================================================================================*/
/* <Function> Debuging : Hide Debug-Window </Function>
/*================================================================================*/
function __bw2DebugOFF() {
         try {
//alert('__bw2DebugOFF');
             var oDW = __bw2GetElementById('oBW2DebugWindow');
             if (!oDW) return;

             with (oDW) {
                  style.display = 'none';
             }
         } catch (e) {
             alert('__bw2DebugOFF : ' + e);
         }
}

/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/

