// 
// NOTES: Apr 25.2006
// UpgradeTag: DirtySave=YES
//

var bDirty = false;
var bDirtySave = false;


function window_onbeforeunload() {

	//window.alert(bDirty);
	//window.alert(bDirtySave);

	if (bDirty!=null) {
		if (bDirty == true) {
			if (bDirtySave==true) {
				bDirtySave=false;
				return 'There are some un-saved modifications to the form. Pressing OK will automatically save your changes!';
			}
			else	{
				return 'If you press OK, you will loose all of your changes!'; 	
			}
		}	
	}
}

function firstFocus()
// Don't send focus to embedded directories
{
   if (document.forms.length > 0)
   {
	for (d=0;d<document.forms.length;d++)
	{
	   var TForm = document.forms[d];
		
	   // July 29.2004 some forms do not have name property?
           if (TForm.name.length>0)
	   {

		if ((TForm.name.substring(0,6)!='up_dir')&& // embedded directories
			(TForm.name.substring(0,7)!='frmPoll'))  // embedded wizards
		{	
			//window.alert(TForm.name.substring(0,7));	
			for (i=0;i<TForm.length;i++)
			{
			   if ((TForm.elements[i].type=="text")||
			     (TForm.elements[i].type=="textarea")||
			     (TForm.elements[i].type=="checkbox")||
			     (TForm.elements[i].type.toString().charAt(0)=="s"))
			   {
			      if ((TForm.elements[i].offsetHeight>0)&& // hidden tabs
					(TForm.elements[i].disabled==false))   // disabled fields
					{
			  		TForm.elements[i].focus();
			      	break;
					}
			   }
			}
		}
	   }
	}
   }
}


function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function Impersonate(host,site){
}

function Old_Impersonate(host,site){
	var winWelcome;
	var strLogin = 'NTImpersonate:readfiles@';
	winWelcome = window.open (host + strLogin + site + '/NTImpersonate.asp', 'winWelcome', 'width=40,height=20,top=1000,toolbar=no,directories=no, location=no,status=no,scrollbars=no,resizeable=no,menubar=no');
	if (winWelcome != null){
		if (winWelcome.opener == null)   
			winWelcome.opener = self;
	}
}

function setallChecks(objCheckAll,objCheck) {
	for (var i = 0; i < objCheck.length; i++) {
		objCheck[i].checked=objCheckAll.checked;
	   }
}
