{
   /***************************************************************************
      EKOGlobal.js  v. 1.0

      Copyright (c) 2003 Paladin Data Systems. All rights reserved.
      Created 5/2/2003 by Brian Pursel @ Paladin Data Systems
      Last modified:

      This script library provides global client side functions for the EKO
      application.
   ****************************************************************************/

   function OpenWindow ( url, fullscreen, top, left, newWidth, newHeight )
   {
      maximize = ( fullscreen == "yes" ) ? "channelmode=yes,fullscreen=yes" : "channelmode=no,fullscreen=no";
      newX = left; newY = top;
      if ( left == -1 ) { newX = (screen.width / 2) - (newWidth / 2); }
      if ( top == -1 ) { newY = (screen.height / 2) - (newHeight / 2); }
      window.open( url,
                  "",
                  "height=" + newHeight + ",width=" + newWidth +
                  "screenX=" + newX + ",left=" + newX + ",screenY=" + newY + ",top=" + newY +
                  maximize + ",status=yes,titlebar=no,menubar=no,location=no,hotkeys=no,dependent=yes" );
   }

   function OpenURL ( url, fullscreen, top, left, newWidth, newHeight )
   {
      maximize = ( fullscreen == "yes" ) ? "channelmode=yes,fullscreen=yes" : "channelmode=no,fullscreen=no";
      newX = left; newY = top;
      if ( left == -1 ) { newX = (screen.width / 2) - (newWidth / 2); }
      if ( top == -1 ) { newY = (screen.height / 2) - (newHeight / 2); }
      window.open( url,
                  "_self",
                  "height=" + newHeight + ",width=" + newWidth +
                  "screenX=" + newX + ",left=" + newX + ",screenY=" + newY + ",top=" + newY +
                  maximize + ",status=yes,titlebar=no,menubar=no,location=no,hotkeys=no,dependent=no" );
   }

   function OpenURLForSave ( url, fullscreen, top, left, newWidth, newHeight )
   {
      var newWin;
      maximize = ( fullscreen == "yes" ) ? "channelmode=yes,fullscreen=yes" : "channelmode=no,fullscreen=no";
      newX = left; newY = top;
      if ( left == -1 ) { newX = (screen.width / 2) - (newWidth / 2); }
      if ( top == -1 ) { newY = (screen.height / 2) - (newHeight / 2); }
      newWin = window.open( url,
                  "_new",
                  "height=" + newHeight + ",width=" + newWidth +
                  "screenX=" + newX + ",left=" + newX + ",screenY=" + newY + ",top=" + newY +
                  maximize + ",status=yes,titlebar=yes,menubar=yes,location=no,hotkeys=no,dependent=no" );
      if (newWin)
      {
         //newWin.document"javascript:document.exec('SaveAs',null,'BadDataFile.txt')";
      }
   }

   function OpenModalDialog( url, centerDialog, top, left, newWidth, newHeight ) 
   {
      //
      if ( centerDialog == "yes" )
      {
         newX = left; newY = top;
         newX = (screen.width / 2) - (newWidth / 2);
         newY = (screen.height / 2) - (newHeight / 2);
         top = ""; left = "";
      }
      window.showModalDialog( url, 
         "",
         "dialogHeight: " + newHeight + "px; dialogWidth:" + newWidth + 
         "px; dialogTop: " + top + "px; dialogLeft: " + top + "px; " +
         "edge: Flat; center: Yes; help: No; resizable: No; status: Yes; unadorned: Yes;" );

      return false;
   }   
   
   function ChangePassword()
   {
      OpenWindow('ChangePassword.aspx','no',-1,-1,315,200);
      return false;
   }
   
   function UrlEncode( pStr ) 
   {
      return escape(pStr).replace(/\+/g, '%2C').replace(/\"/g,'%22').replace(/\'/g, '%27');
   }

   function ShowSupportPopup()
   {
      //OpenWindow('http://home.ekosystem.us/support/support.htm','no',-1,-1,400,370);
      OpenWindow('/ekofiles/public/support/support.htm','no',-1,-1,400,370);
      return false;
   }

   function ShowPopup()
   {
      //
   }
   
   //Added 12/1/2004
   //This function is used to open: PExpenses.aspx called in the PDetail.aspx.cs
   //                               EMapQuerySettings.aspx called in the EMapQuery.aspx.cs
   //When called, this function checks if an instance of this window already exists.
   //If not, it will open the window.  If yes, it will close the existing window and open a new one.
   //Parameter 'name' must be unique for each window and must be a single word.
   //For example: OpenDependentWindow("PExpenses.aspx", "P_Expenses",'no',-1,-1,720,330);
   
   function OpenDependentWindow ( url, name, fullscreen, top, left, newWidth, newHeight )
   {
      maximize = ( fullscreen == "yes" ) ? "channelmode=yes,fullscreen=yes" : "channelmode=no,fullscreen=no";
      newX = left; newY = top;
      if ( left == -1 ) { newX = (screen.width / 2) - (newWidth / 2); }
      if ( top == -1 ) { newY = (screen.height / 2) - (newHeight / 2); }
      
      if( typeof( popupWin ) != "object" || popupWin.closed )
      {
         popupWin = window.open( url,
                  name,
                  "height=" + newHeight + ",width=" + newWidth +
                  "screenX=" + newX + ",left=" + newX + ",screenY=" + newY + ",top=" + newY +
                  maximize + ",status=yes,titlebar=no,menubar=no,location=no,hotkeys=no,dependent=yes" );
      }
      else 
      {
         popupWin.close();
         popupWin = window.open( url,
                  name,
                  "height=" + newHeight + ",width=" + newWidth +
                  "screenX=" + newX + ",left=" + newX + ",screenY=" + newY + ",top=" + newY +
                  maximize + ",status=yes,titlebar=no,menubar=no,location=no,hotkeys=no,dependent=yes" );
      }
      popupWin.focus();      
   }
   
   //Use this function to automatically close the window after the parent window is closed.
   //the parameter 'interval' is used to specify the delay to close after the parent is closed.
   //1000 for 1 second, 2000 for 2 seconds, etc...
   //Put the function in the body onload event: onload="SelfClose(1000);"
   //or in the <Script> section:
   //<Script>
   //SelfClose(1000);
   //</Script>
   //This function is used in PExpenses.aspx and EMapQuerySettings.aspx
   function SelfClose( interval )
   {
      window.setInterval( "timeOut()", interval );
   }
   
   //this function is used by the SelfClose function above
   function timeOut()
   {
      if ( opener.closed )
         self.close();
   }
   //END - added 12/1/2004
 
   // Clears a textbox if called from the OnClick event
   // Added on 3/25/05
   function ClearText( pTextbox )
   {
      pTextbox.value = "";
   }
   
   // Invokes the click event of a form button from another control.
   // Typically called from a read-only text box linked to a lookup button.
   // Added on 4/15/05.
   function InvokeButton( pButtonName )
   {
      var button;
      button = document.getElementById( pButtonName );
      if ( button )
      {
         button.click();
      }
      return false;
   }

   // Handles click events generated from a lookup item textbox
   // Note: pLookupIdTextBox can contain names of multiple controls separated by "|"
   // Added on 4/15/05
   function LookupTextClick( pLookupTextObj, pLookupIdTextBox, pLookupButtonName )
   {
      var button;
      var idFields;
      
      if ( pLookupTextObj )
      {
         // If Lookup textbox is empty, call lookup button. Otherwise clear the text and id value
         //
         if ( pLookupTextObj.value == "" ) 
         { 
            if ( document.getElementById( pLookupButtonName ) )
            {
               InvokeButton( pLookupButtonName ); 
            }
         }
         else // Clear entries
         {
            pLookupTextObj.value = "";
            idFields = pLookupIdTextBox.split( "|" );
            for ( i = 0; i <= idFields.length; ++i )
            {
               if ( document.getElementById( idFields[i] ) )
               {
                  document.getElementById( idFields[i] ).value = "";
               }
            }
         }
      }
   }         

   // Used on button objects to offset right onmousedown events
   function ButtonDown( pButton )
   {      
      pButton.style.marginLeft = 1;
      pButton.style.marginTop = 1;
   }
   // Used on button objects to restore offset onmouseup events
   function ButtonUp( pButton )
   {
      pButton.style.marginLeft = 0;
      pButton.style.marginTop = 0;
   }
   
}