/*================================================================================*/
/*                                                                                */
/*             BW2Technologies.Web.JScript.Framework (Alpha V1.0.0.0)             */
/*                                                                                */
/*                             Web-Framework Global                               */
/*                                                                                */
/*              Copyright © 2006-2010 by BW2Technologies (HP. Lassnig)            */
/*                           mail to : hansi@lassnig.ch                           */
/*                                                                                */
/*================================================================================*/

/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/


function __emePaymentResponse(strRes) {
         try {
             alert('Window : ' + window.parent);
         } catch (e) { alert('Alert : ' + e); }
     }

function __emePaymentDatatrans() {
         try {
             var oIF = __bw2GetElementById('FramePayment');

             if (oIF) {
                try {
                    alert('Loc : ' + oIF.contentWindow.location);

                    if (oIF.contentWindow.PaymentState) {
                        alert('Forms : ' + oIF.contentWindow.PaymentState);
                    }
//                    var oF = oIF.contentWindow.document.getElementsByTagName('FORM');
//                    var oF = oIF.contentWindow.document.forms[0];
//                    if (!oF) oF = oIF.contentWindow.document.oForm;

//                    alert('Form : ' + oF.name);

//                alert('2. ' + oF);

//                if (oF) {
//                   var strR = oF.action.toLowerCase();

//                   alert(strR);

//                   if (strR.indexOf('paymentresponse.aspx?state=success') > -1) {
//                      window.location='Default.aspx?Payment=Success';
//                   } else if (strR.indexOf('paymentresponse.aspx?state=error') > -1) {
//                      window.location='Default.aspx?Payment=Error';
//                   } else if (strR.indexOf('paymentresponse.aspx?state=cancel') > -1) {
//                      window.location='Default.aspx?Payment=Cancel';
//                   } else {
//                      setTimeout('__emePaymentDatatrans()', 5000); 
//                   }
//                } else {
//                   alert('No Form');
//                }
                  setTimeout('__emePaymentDatatrans()', 5000); 

                } catch (ex) {
                    alert('Loop : ' + ex);
                    setTimeout('__emePaymentDatatrans()', 5000); 
                }
             }
         } catch (e) {alert('Alert : ' + e);}
}


/*================================================================================*/
/* <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.className = _oSkinCssClasses['FORM_SHADOW'];
         oDW.style.position = 'absolute';
         oDW.style.zIndex = 1000;
         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;

         /*--- 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.ParentObject = 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.ParentObject = 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);
         }
}

/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/
