
function WebBrowser() {

   var ua, s, i;

   this.InternetExplorer    = false;
   this.Netscape    = false;
   this.Opera    = false;
   this.version = null;
   this.OpenReportWindow = function ( url )
   {
      window.open(url,"reportingwindo",'height='+ this.GetScreenHeight( )+',width='+ this.GetScreenWidth()+',scrollbars=yes,toolbar=no,location=no,resizable=yes,left=0,top=0');
   }
   this.GetFormElement = function( ControlID )
   {
      if (this.InternetExplorer)
      {
         return document.getElementById( ControlID );
      } else if (this.Netscape)
      {
         return document.all[ ControlID ];
      } else
         return ControlID;
   }
   this.GetKeyPressed = function( event )
   {
			var keyCode;
			var returnVal = false;

			if (window.event) {
				e = window.event;
				keyCode = e.keyCode;
			} else {
				// a key, such as delete, was pressed; let it pass through
			if (e.keyCode == e.which) keyCode = null;
				// else if not a char we don't know what this is; let it pass through
			else if (e.charCode != e.which) keyCode = void 0;
// else a char - set it
			else keyCode = e.which;
			}
			return keyCode;
		
   }
   this.ProcessKeyButtonClick= function( buttonid, e )
   {
		keyCode = this.GetKeyPressed( e );
		if( keyCode == 13 )
		{
			//enter key was pressed
			button = this.GetFormElement( buttonid );
			button.click( );
			return false;
		}
		else
			return true;
   }
   this.ShowControl = function ( ControlID )
   {
   
		if (document.layers) 
		{
			e = document.layers[ControlID];
			if(e != null)
				e.visibility="show";
		}
		else 
		{
			e = document.getElementById(ControlID);
			if(e != null)
				e.style.visibility="visible";
		}
   }
   this.HideControl = function( ControlID )
   {
		if (document.layers)
		{
			var e = document.layers[ControlID];
			if(e != null)
				e.visibility="hide";
		}
		else
		{ 
			var e = document.getElementById(ControlID);
			if(e != null)
				e.style.visibility="hidden";
		}
   }
   this.GetScreenWidth = function( )
   {
      if ( typeof( window.innerWidth ) == 'number' )
      {
         return  screen.width;
      } else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ))
      {
         return screen.width;
         
      } else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
      {
         return  screen.width;
         
      }
   }
   this.GetScreenHeight = function( )
   {
      if ( typeof( window.innerWidth ) == 'number' )
      {
         return  screen.height;
      } else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ))
      {
         return screen.height;
         
      } else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
      {
         return  screen.height;
         
      }
   }
   this.FormatCurrency = function (num) {
      num = num.toString().replace(/\$|\,/g,'');
      if (isNaN(num))
         num = "0";
      sign = (num == (num = Math.abs(num)));
      num = Math.floor(num*100+0.50000000001);
      cents = num%100;
      num = Math.floor(num/100).toString();
      if (cents<10)
         cents = "0" + cents;
      for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
         num = num.substring(0,num.length-(4*i+3))+','+
               num.substring(num.length-(4*i+3));
      return(((sign)?'':'-') + '$' + num + '.' + cents);
   }
   this.MakeMoneyAmount = function (x)
   {
      try
      {
         x = x.replace(",","");
         var rt = parseFloat(x);
         if (isNaN(rt) )
            return 0;
         else
            return rt;
      }
      catch(e)
      {
         
         return parseFloat('0');
      }
   }
   

   ua = navigator.userAgent;

   s = "MSIE";
   if ((i = ua.indexOf(s)) >= 0)
   {
      this.InternetExplorer = true;
      this.version = parseFloat(ua.substr(i + s.length));
      return;
   }

   s = "Netscape6/";
   if ((i = ua.indexOf(s)) >= 0)
   {
      this.Netscape = true;
      this.version = parseFloat(ua.substr(i + s.length));
      return;
   }

   // Treat any other "Gecko" browser as NS 6.1.

   s = "Gecko";
   if ((i = ua.indexOf(s)) >= 0)
   {
      this.Netscape = true;
      this.version = 6.1;
      return;
   }

}
function WindowOption( )
{
   this.url = "";
   this.height = "0";
   this.width = "0";
   this.scrollbars="no";
   this.toolbar="no";
   this.location="no";
   this.resizable="no";
   this.left="0";
   this.top="0";
   
   this.FormatOptionString = function( )
   {
      return "height="+this.height+",width="+this.width+",scrollbars="+this.scrollbars+",toolbar="+this.toolbar+",location="+this.location+",resizable="+this.resizable+",left="+this.left+",top="+this.top;
   }
}
function ClientPostback( url, parameters )
{
	this.READY = 4;
	this.SUCCESS = 200;
	this.URL = url;
	this.Parameters = parameters;
	this.Request = null;
	this.OnComplete = null;
	this.Init = function( )
	{
		try
      {
         this.Request=new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch(e)
      {
         try
         {
            this.Request=new ActiveXObject("Microsoft.XMLHTTP");
         }
         catch(oc)
         {
            this.Request=null;
         }
      }

      if (!this.Request&&typeof XMLHttpRequest!="undefined")
      {
         this.Request=new XMLHttpRequest();
      }
		
	}
   this.Get = function( )
   {
		this.Init( );
		this.Request.onreadystatechange = this.OnComplete;
		this.Request.open("GET", this.URL, true);
		this.Request.send(null);
   }
   this.Post = function( )
   {
		this.Init( );
		this.Request.onreadystatechange =  this.OnComplete;
		this.Request.open("POST", this.URL, true);
		this.Request.send(this.parameters);
   }
   this.ResponseState = function( )
   {
		return this.Request.readyState;
   }
   this.ResponseStatus = function( )
   {
		return this.Request.status;
		
   }
   this.Message = function( )
   {
		return this.Request.responseText;
   }
  	
}


function popupMenu(e,path){
  if(document.all) e=window.event;
  e.cancelBubble=true;
  hideMyMenu();
  if(!document.all){
    myMenu = document.getElementById('myMenu');
    myMenu.style.left = e.pageX+'px';
    myMenu.style.top  = e.pageY+'px';
    myMenu.style.display = 'block';
  }
  else {
    myMenu = document.getElementById('myMenu');
    myMenu.style.left = (e.clientX+document.body.scrollLeft)+'px';
    myMenu.style.top  = (e.clientY+document.body.scrollTop )+'px';
    myMenu.style.display = 'block';
    myfield =  document.getElementById('directorypath');
    myfield.value = path;

  }
  return false;
}
function hideMyMenu(){
  if(myMenu){
    myMenu.style.display = 'none';
    myMenu = null;
  }
}
