function disableButton()
{
  var ml = document.frmApp;
  var len = ml.elements.length;
  for (var i = 0; i < len; i++) {
    var e = ml.elements[i];      
    if ((e.type=='button')||(e.type=='submit'))
    {
       e.disabled = true;
    }
  }
}

function popupWindow(iHeight)
{
var screenW = 640, screenH = 480;
if (parseInt(navigator.appVersion)>3) {
 screenW = screen.width;
 screenH = screen.height;
}
else if (navigator.appName == "Netscape" 
    && parseInt(navigator.appVersion)==3
    && navigator.javaEnabled()
   ) 
{
 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
 var jScreenSize = jToolkit.getScreenSize();
 screenW = jScreenSize.width;
 screenH = jScreenSize.height;
}

  win = window.open('','myWin','toolbars=0,location=0,status=0,scrollbars=0,directories=no,menubar=no,copyhistory=yes,width=450,height=' + iHeight);
  win.moveTo((screenW/2)-(450/2),(screenH/2)-(parseInt(iHeight)/2));
  document.frmApp.target='myWin';
  document.frmApp.submit();
}


function resetUser()
{
  if (typeof document.frmApp.mySelf!="undefined"){
    document.frmApp.mySelf.value="";
  }
}

function updateSort(oSort,oOrder,sSort,sSortOrder)
{
  document.getElementById("Loading").style.visibility='visible';
  if (typeof document.frmApp.HPage!="undefined")
  { 
     document.frmApp.HPage.value=0; 
  }
  document.frmApp.action='';
  oSort.value=sSort;
  switch(sSortOrder)
  {
    case 'ASC' : oOrder.value='DESC';break;
    case 'DESC': oOrder.value='ASC';break;
    default    : oOrder.value='ASC';break;
  }
  document.frmApp.submit();
}

function gotoPage(oPage, iPos)
{
  document.getElementById("Loading").style.visibility='visible';
  oPage.value=iPos;
  document.frmApp.action='';
  document.frmApp.submit();
}

function Check(item,OnOff)
{
  var ml = document.frmApp;
  var len = ml.elements.length;
  for (var i = 0; i < len; i++) {
    var e = ml.elements[i];
    if ((e.name == item)&&(e.disabled==false)) {
	e.checked=OnOff;
    }
  }
}

function CheckAll(sObject,OnOff)
{
  Check(sObject,OnOff);  
}

    function validateCheckBox(sObject)
    {
        var ml = document.frmApp;
	var len = ml.elements.length;
        var Result=0;
	for (var i = 0; i < len; i++) {
	    var e = ml.elements[i];
	    if (e.name == sObject) {
		if (e.checked==true)
                {
                  Result=1
                }
	    }
	}    
        if (Result==0)
        {
          return false;
        }
        else
        {
          return true;
        }
    }

function logout()
{
  win = window.open('','_parent','');
  document.getElementById("Loading").style.visibility='visible';
  document.frmApp.target='_parent';
  document.frmApp.Action.value='Logout';
  document.frmApp.action='_app.asp';
  document.frmApp.submit();
}

function goto(sURL)
{  
  win = window.open('','_parent','');
  document.getElementById("Loading").style.visibility='visible';
  document.frmApp.target='_parent';
  document.frmApp.action=sURL;
  document.frmApp.submit();
}

function echeck(str,msg) {
                // Function to validate e-mail address to the following format:
		// name@domain.domaintype
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var message=msg;
		if (str.indexOf(at)==-1){
		   alert(message)
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert(message)
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert(message)
		    return false
		}
      	        if (str.indexOf(at,(lat+1))!=-1){
		    alert(message)
		    return false
		}
      	        if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert(message)
		    return false
		}
 	        if (str.indexOf(dot,(lat+2))==-1){
		    alert(message)
		    return false
 	        } 
		if (str.indexOf(" ")!=-1){
		    alert(message)
		    return false
		}
		return true					
	}

function isURL(sURL)
{
  if (Len(sURL)>5)
  {
    PrefixHTTP = Left(sURL,7);
    PrefixHTTPS = Left(sURL,8);
    PrefixFTP = Left(sURL,6);
  }
  else
  {
    PrefixHTTP = " ";
    PrefixHTTPS = " ";
    PrefixFTP = " ";
  }
  if ((PrefixHTTP.toUpperCase()!='HTTP://')&&(PrefixHTTPS.toUpperCase()!='HTTPS://')&&(PrefixFTP.toUpperCase()!='FTP://'))
  {
     return false;
  }
  return true;
}


function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         return false;
         }
      }
   return true;
   
   }


function InStr(strSearch, charSearchFor)
/*
InStr(strSearch, charSearchFor) : Returns the first location a substring (SearchForStr)
                           was found in the string str.  (If the character is not
                           found, -1 is returned.)
                           
Requires use of:
	Mid function
	Len function
*/
{
	for (i=0; i < Len(strSearch); i++)
	{
	    if (charSearchFor == Mid(strSearch, i, 1))
	    {
			return i;
	    }
	}
	return -1;
}



        function Mid(str, start, len)
        /***
                IN: str - the string we are LEFTing
                    start - our string's starting position (0 based!!)
                    len - how many characters from start we want to get

                RETVAL: The substring from start to start+len
        ***/
        {
                // Make sure start and len are within proper bounds
                if (start < 0 || len < 0) return "";

                var iEnd, iLen = String(str).length;
                if (start + len > iLen)
                        iEnd = iLen;
                else
                        iEnd = start + len;

                return String(str).substring(start,iEnd);
        }


// Keep in mind that strings in JavaScript are zero-based, so if you ask
// for Mid("Hello",1,1), you will get "e", not "H".  To get "H", you would
// simply type in Mid("Hello",0,1)

// You can alter the above function so that the string is one-based.  Just
// check to make sure start is not <= 0, alter the iEnd = start + len to
// iEnd = (start - 1) + len, and in your final return statement, just
// return ...substring(start-1,iEnd)



        function Left(str, n)
        /***
                IN: str - the string we are LEFTing
                    n - the number of characters we want to return

                RETVAL: n characters from the left side of the string
        ***/
        {
                if (n <= 0)     // Invalid bound, return blank string
                        return "";
                else if (n > String(str).length)   // Invalid bound, return
                        return str;                // entire string
                else // Valid bound, return appropriate substring
                        return String(str).substring(0,n);
        }



        function Len(str)
        /***
                IN: str - the string whose length we are interested in

                RETVAL: The number of characters in the string
        ***/
        {  return String(str).length;  }

function javascript_popup(url,name,toolbar,location,directories,status,menubar,scrollbars,resizable,width,height) 
	{
			var strWin;
			
			strWin = 'toolbar=' + toolbar;
			strWin = strWin + 'location=' + location + ',';
			strWin = strWin + 'directories=' + directories + ',';
			strWin = strWin + 'status=' + status + ',';
			strWin = strWin + 'menubar=' + menubar + ',';
			strWin = strWin + 'scrollbars=' + scrollbars + ',';
			strWin = strWin + 'resizable=' + resizable + ',';
			strWin = strWin + 'width=' + width + ',';
			strWin = strWin + 'height=' + height;
			
			sealWin=window.open(url,'_blank',strWin);
			
        self.name = "mainWin"; 
    }