<!--
//... globals needed for UserMaintenance

var today = new Date();
var expires = new Date(today.getTime() + (56 * 86400000));

function getBrowserVersion()
{	
	var iMSIE = navigator.userAgent.indexOf("MSIE") ;
	var nVersionNum = parseInt(navigator.userAgent.substring(iMSIE + 5, iMSIE + 6)) ;
	return nVersionNum ;
	//parseInt(sUA.substring(iMSIE + 5, iMSIE + 6)) ;
	
	//if(parseInt(navigator.appVersion) >= 5)
	//{
	//	if(navigator.appName == "Netscape")
	//		return false ;
	//	else
	//		return true ;
	//}
}

function ConfirmRecordDelete(stRedirectionURL)
{	
	if(confirm("Are you sure you want to delete this record?"))
		document.location.href = stRedirectionURL ;
}


function ResetLocationSelections(obj)
{
	var nCtr = 0 ;
	
	for (nCtr = 0; nCtr < obj.length; nCtr++) 
	{      
		obj.options[nCtr].selected=false ;
	}   
}


function CheckDataForSearchLookup(objForm)
{
	var bSubmitForm = false ;
	var stErrorMsg = "" ;
	
	stErrorMsg = "You must enter in a value to submit the form.\n" ;
	stErrorMsg += "Please choose the Cancel button if you wish to exit the screen" ;
	
	objForm.DataAction.value = 'LookUp'; 
	if(objForm.optSearch[0].checked == true)
	{
		if(objForm.txtPostId.value.length > 0)
			bSubmitForm = true ;
	}
	else
	{
		if(objForm.txtLastName.value.length > 0)
			bSubmitForm = true ;
	}
	
	if(bSubmitForm == true)
		objForm.submit() ;
	else
		alert(stErrorMsg) ;
} 

function OpenPostHelperPup(stPostInfo)
{
	var objPopWindow ;
	var stTemp ;
	
	stTemp = "<html><head><title>Post Information</title></head><body>" ;
	stTemp += stPostInfo ;
	stTemp += "</body></html>" ;
	objPopWindow = window.open('', 'PostExtraInfoPage','scrollbars,resizable,HEIGHT=300,WIDTH=300') ;
	objPopWindow.moveTo(5, 5) ;
	
/*	don't use	
	var coll = objPopWindow.document.all ;	
	if (coll!=null) 
	{		
		for (i=0; i<coll.length; i++) 
		{
			alert(coll.item(i).tagName) ;
			
			
			if(coll.item(i).id == "spanPostDataBlock")
			{
				objPopWindow.document.all.spanPostDataBlock.innerHTML = "tonyboy2" ;
				coll.spanPostDataBlock.innerHTML = stPostInfo ;
			}
		}
	}
*/	
	objPopWindow.document.write(stTemp) ;		
	objPopWindow.focus() ;	
	objPopWindow.location.reload() ;	
}
 
function SetRowBackGroundColor(bSetShade, objTableRow)
{
	if(bSetShade == true)
	{
		objTableRow.style.backgroundColor="#A9A9A9" ;
	}
	else
	{
		objTableRow.style.backgroundColor="#FFFFFF" ;
	}
}

function CheckRequiredFields(objForm)
{
	var i ;
	var bPassed = true ;
	var objLbl ;
	var re = /_REQ/ ;
	
	for(i=0; i<objForm.elements.length; i++)
	{
		if((objForm.elements[i].type == "text" || objForm.elements[i].type == "select-multiple") && objForm.elements[i].name.search(re) != -1)
		{
			objLbl = eval("document.all." + "lbl" + (i+1) + ".style") ;			
			if(objForm.elements[i].value.length == 0)
			{
				objLbl.color = "#FF0000" ;
				bPassed = false ;			
			}
			else
				objLbl.color = "#000000" ;
		}
	}
	
	if(bPassed == false)
		alert("There are required fields that must be filled in to proceed!") ;
	else
		objForm.submit() ;	
}

function clearOptions(objSelect)
{
	//...clear out the report to combo box and set the 1st element to be blank
	objSelect.length = 0 ;
	objSelect.options[0] = new Option('', '') ;
}


function ProcessDrillDown(objImg, objSpan)
{
	if(objImg.alt == "Expand")
	{	
		objImg.src = "../images/minus.gif" ;
		objImg.alt = "Contract" ;
		objSpan.style.display = "inline" ; 
	}
	else
	{
		objImg.src = "../images/plus.gif" ;
		objImg.alt = "Expand" ;
		objSpan.style.display = "none" ; 
	}
}

function CheckLogonForm(objForm)
{
	var stErrorMsg = "" ;
	
	stErrorMsg = "Logon ID and Password can not be blank.\n" ;
	
	if(objForm.txtLogonID.value.length > 0 && objForm.txtPassword.value.length > 0)
	{
		set();
		objForm.submit() ;
	}
	else
	{
		if(objForm.txtLogonID.value.length == 0)
			objForm.txtLogonID.focus() ;
		else
			objForm.txtPassword.focus() ;
						
		alert(stErrorMsg) ;
	}
} 

function CheckPasswordChangeForm(objForm)
{
	var stErrorMsg = "" ;
	var bPassed = true ;
	var objTemp ;
	var stTemp = "txtNewPassword" ;
	
	//... make sure all fields have something in them
	for(i=0; i<objForm.elements.length; i++)
	{
		if(objForm.elements[i].type == "password")
		{
			if(objForm.elements[i].value.length == 0 || objForm.elements[i].value == ' ')
			{
				stErrorMsg = "Input fields on this form may not be blank.\n" ;
				bPassed = false ;
				stTemp = "txtOldPassword"
				objForm.txtOldPassword.value = '' ;
				break ;
			}
		}
	}
	
	if(bPassed == true)
	{
		if(objForm.txtNewPassword.value != objForm.txtConfirmPassword.value)
		{
			stErrorMsg = "The new password did not match the confirmation password.\nPlease re-enter!" ;
			bPassed = false ;
		}
		else if (objForm.txtNewPassword.value.toLowerCase() == 'welcome')
		{
			stErrorMsg = "You can not change your password to the default password.\nPlease re-enter!" ;
			bPassed = false ;
		}
	}

	if(bPassed == true)
	{
		objForm.submit() ;
	}		
	else
	{
		objForm.txtNewPassword.value = '' ;
		objForm.txtConfirmPassword.value = '' ;
		
		objTemp = eval("objForm." + stTemp) ;	
		objTemp.focus() ;
	
		alert(stErrorMsg) ;
	}
}

function CheckSearchForm1(objForm, objWOStartMonth, objWOStartDay, objWOStartYear, objWOEndMonth, objWOEndDay, objWOEndYear)
{
	var i ;
	var nCtr = 0 ;
	var bSubmitForm = true ;
	var nWOStartMonth = parseInt(objWOStartMonth.value, 10) ;
	var nWOStartDay = parseInt(objWOStartDay.value, 10) ;
	var nWOStartYear = parseInt(objWOStartYear.value, 10) ;
	var nWOEndMonth = parseInt(objWOEndMonth.value, 10) ;
	var nWOEndDay = parseInt(objWOEndDay.value, 10) ;
	var nWOEndYear = parseInt(objWOEndYear.value, 10) ;
	var stTemp = "" ;

	for(i=0; i<objForm.elements.length; i++)
	{
		if(objForm.elements[i].type == "text" && objForm.elements[i].name.substr(3, 3) == "WOD")
			if(objForm.elements[i].value.length > 0)
				nCtr ++ ;
	}
	
	if(nCtr == 6)  //found all our date fields
	{
		stTemp = ValidateYear(objWOStartYear, objWOStartMonth, objWOStartDay, nWOStartYear, nWOStartMonth, nWOStartDay) ;
		if(stTemp.length == 0)
			stTemp = ValidateYear(objWOEndYear, objWOEndMonth, objWOEndDay, nWOEndYear, nWOEndMonth, nWOEndDay) ;
	}
	else if(nCtr > 0 && nCtr < 6)
	{
		stTemp = "To search on Work Order Date you must select both a start and end date." ;
	}
	
	if(stTemp.length > 0)
		alert(stTemp) ;
	else
		objForm.submit() ;
}

function CheckSearchForm(objForm, objWOStartDate, objWOEndDate)
{
	var i ;
	var nCtr = 0 ;
	var bSubmitForm = true ;
	var stTemp = "" ;

	for(i=0; i<objForm.elements.length; i++)
	{
		if(objForm.elements[i].type == "text" && objForm.elements[i].name.substr(3, 3) == "WOD")
			if(objForm.elements[i].value.length > 0)
				nCtr ++ ;
	}
	
	//if(nCtr == 6)  //found all our date fields
	//{
		//stTemp = ValidateYear(objWOStartYear, objWOStartMonth, objWOStartDay, nWOStartYear, nWOStartMonth, nWOStartDay) ;
		//if(stTemp.length == 0)
		//	stTemp = ValidateYear(objWOEndYear, objWOEndMonth, objWOEndDay, nWOEndYear, nWOEndMonth, nWOEndDay) ;
	//}
	//else if(nCtr > 0 && nCtr < 2)
	if(nCtr > 0 && nCtr < 6)
	{
		stTemp = "To search on Work Order Date you must select both a start and end date." ;
	}
	
	if(stTemp.length > 0)
		alert(stTemp) ;
	else
		objForm.submit() ;
}


function SetFocusToFirstElement(objForm)
{
	if (objForm.elements[0])
		objForm.elements[0].focus() ;
}

function CheckForEnterKey(objControl)
{
	if(window.event.keyCode == 13)
	{
		objControl.click() ;
	}
}

function LoadWindowArray(stWidth, stHeight, stScroll, stResize)
{
	var aWindowFeatures = new Array(4) ;
	
	/* the javascript array is a bit different than the vbscript array.  To use create
	a multidimensional array you must first new an array.  Then you have to new the next
	dimension off of each element in the original array.   TonyBoy 2/13/2002
	*/	
		
	aWindowFeatures[0] = new Array(2) ;
	aWindowFeatures[0][0] = "width" ;
	aWindowFeatures[0][1] = stWidth ;

	aWindowFeatures[1] = new Array(2) ;
	aWindowFeatures[1][0] = "height" ;
	aWindowFeatures[1][1] = stHeight ;

	aWindowFeatures[2] = new Array(2) ;
	aWindowFeatures[2][0] = "scrollbars" ;
	aWindowFeatures[2][1] = stScroll ;

	aWindowFeatures[3] = new Array(2) ;
	aWindowFeatures[3][0] = "resizable" ;
	aWindowFeatures[3][1] = stResize ;

//	aWindowFeatures[4] = new Array(2) ;
//	aWindowFeatures[4][0] = "location" ;
//	aWindowFeatures[4][1] = "yes" ;

	return aWindowFeatures ;
}


function LaunchPopUpWindow(stURLString, stWindowName, aWindowFeatures, bPDF)
{
	//... this is a generic function that will popup a new window
	var objPopWindow ;
	var stWindowFeatures = "" ;
	var i = 0 ;
	var j = 0 ;
	var nItems = aWindowFeatures.length ;
	var nSubItems = 0 ;
	
	if(bPDF==true)
		alert("Generating PDF document.\nThis may take a moment.  Thank you for your patience.\n\nPlease click Ok to continue.") ;
	
	for(i = 0; i<nItems; i++)
	{		
		if(i>0)
		{
			stWindowFeatures += ", " ;
		}

		nSubItems = aWindowFeatures[i].length ;
		for(j=0; j<nSubItems; j++)
		{
			if(j>0)
			{
				stWindowFeatures += "=" ;
			}
			stWindowFeatures += aWindowFeatures[i][j] ;
		}
	}

	objPopWindow = window.open(stURLString, stWindowName, stWindowFeatures) ;
	objPopWindow.moveTo(5, 5) ;
	objPopWindow.focus() ;
	
	//objPopWindow = window.open('', 'PostExtraInfoPage','scrollbars,resizable,HEIGHT=300,WIDTH=300') ;
}

function ValidateMonth(Monthfield, nMonth)
{
	var stTemp = "" ;
	
	if(isNaN(nMonth))
	{
		stTemp = "Please enter a numeric value for Month between 1 and 12" ;
		Monthfield.value = "" ;
		Monthfield.focus() ;	
	}
	else if(nMonth < 1 || nMonth > 12)
	{
		stTemp = "Value out of Range.   Please re-enter a value for Month between 1 and 12" ;
		Monthfield.value = "" ;
		Monthfield.focus() ;
	}
	return stTemp ;
}

function ValidateDay(Dayfield, Monthfield, nDay, nMonth)
{	
	var stTemp = "" ;

	stTemp = ValidateMonth(Monthfield, nMonth) ;
	
	if(stTemp.length == 0)
	{
		if(isNaN(nDay))
		{
			stTemp = "Please enter a numeric value for Day" ;
			Dayfield.value = "" ;
			Dayfield.focus() ;	
		}	
		else if ((nMonth == 4) || (nMonth == 6) || (nMonth == 9)
				|| (nMonth == 11))
		{
			if(nDay < 1 || nDay > 30)
			{
				stTemp = "Value out of Range.   Please re-enter a value for Day between 1 and 30" ;
				Dayfield.value = "" ;
				Dayfield.focus() ;
			}
		}
		else if ((nMonth == 1) || (nMonth == 3) || (nMonth == 5)
				|| (nMonth == 7) || (nMonth == 8) || (nMonth == 10)
				|| (nMonth == 12))
		{
			if(nDay < 1 || nDay > 31)
			{
				stTemp = "Value out of Range.   Please re-enter a value for Day between 1 and 31" ;
				Dayfield.value = "" ;
				Dayfield.focus() ;
			}
		}
		else if (nMonth == 2)
		{
			if(nDay < 1 || nDay > 29)
			{
				stTemp = "Value out of Range.   Please re-enter a value for Day between 1 and 29 (if leap year)" ;
				Dayfield.value = "" ;
				Dayfield.focus() ;
			}
		}
	}
	return stTemp ;
}

function ValidateYear(Yearfield, Monthfield, Dayfield, nYear, nMonth, nDay)
{	
	var stTemp = "" ;
	var bIsLeapYear = false ;
	var nTemp = Yearfield.value % 100 ;
	
	stTemp = ValidateDay(Dayfield, Monthfield, nDay, nMonth) ;

	if(stTemp.length == 0)
	{
		if (0 == (nTemp % 4) && nTemp != 00)
			bIsLeapYear = true ;
		else if (nTemp == 00)
		{
			if(0 == Yearfield.value % 400)
				bIsLeapYear = true ;
		}
	
		if(isNaN(nYear))
		{
			stTemp = "Please enter a numeric value for Year" ;
			Yearfield.value = "" ;
			Yearfield.focus() ;	
		}		
		else if(bIsLeapYear == false && nMonth == 2 && nDay == 29)
		{
			stTemp = "The entered Year is not a Leap Year '29' is not valid" ;
			Dayfield.value = "" ;
			Dayfield.focus() ;			
		}

		else if(Yearfield.value.length < 4)
		{
			stTemp = "Input for Year must be four digits" ;
			Yearfield.value = "" ;
			Yearfield.focus() ;
		}

		else if(Yearfield.value < 1900 || Yearfield.value > 2099)
		{
			stTemp = "Value out of Range.   Please re-enter a value for Day between 1900 and 2099" ;
			Yearfield.value = "" ;
			Yearfield.focus() ;
		}
		 
		 if(Yearfield.value.length < 4)
		{
			stTemp = "Input for Year must be four digits" ;
			Yearfield.value = "" ;
			Yearfield.focus() ;
		}
	}
	return stTemp ;
}


function LaunchCalendar(stURLString, objMonth, objDay, objYear)
{	
	window.monthField = objMonth ;
	window.dayField = objDay ;
	window.yearField = objYear ;
	
	LaunchPopUpWindow(stURLString + 'htm/calendar.htm', 'Calendar', LoadWindowArray('300', '435', '0', '1'));
	//LaunchPopUpWindow('http://tonyboy-server/labman/htm/calendar.htm', 'Calendar', LoadWindowArray('300', '435', '0', '1'));
}

function ResetFormFields(objForm)
{
	var i ;
	for(i=0; i<objForm.elements.length; i++)
	{
		if(objForm.elements[i].type == "text")
		{
			objForm.elements[i].value = "" ;
		}
	}
}

function ToolTipText(objImage, bMultipleItems, stItemType)
{
	var stTemp = "" ;

	if(bMultipleItems == true)
		stTemp = "Multiple " + stItemType + " exist for this order" ;
	else
		stTemp = stItemType ;

	objImage.title = stTemp ;
}

function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}
 
function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}
 
function set() {

    //alert(document.frmLogon.chkUserId.checked);
    //if (document.frmLogon.chkUserId.checked)
      //  Set_Cookie("userid",document.frmLogon.txtLogonID.value,expires);
    //else    
    	Set_Cookie("userid",'',expires);
    
    //if (document.frmLogon.chkPassword.checked)
    //    Set_Cookie("password",document.frmLogon.txtPassword.value,expires);
    //else    
    	Set_Cookie("password",'',expires);    
}

function get(objForm) {
    userid = Get_Cookie("userid")
   
    if (userid != null) {
        objForm.txtLogonID.value = userid;
        //objForm.chkUserId.checked = true;
    }
    password = Get_Cookie("password")
    if (password != null) {
        objForm.txtPassword.value = password;
        //objForm.chkPassword.checked = true;
    }
}

//-->
