// 
// SDI.js - JavaScript Library
//
// Author: Kevin P. Wojdak (kwojdak@sdienterprises.com)
//
//
//


// 
//   Global Variables
//



// *******************************************************
// ******  Image pre-load for Navigation Rollovers  ******
// *******************************************************
//
// IMPORTANT:  Organized Alphabeticallly
//
if (document.images) {

	btnGoup    = new Image();
    btnGoup.src= "images/common/btnGo_off.gif" ;
    btnGodown  = new Image() ;
    btnGodown.src = "images/common/btnGo_on.gif" ;
    
    btnSearchup    = new Image();
    btnSearchup.src= "images/common/btnSearch_off.gif" ;
    btnSearchdown  = new Image() ;
    btnSearchdown.src = "images/common/btnSearch_on.gif" ;
	

}

//+----------------------------------------------------------------------------
//  Function:       btndown
//  Author:         Kevin P. Wojdak
//  Modified:       March 2008
//  Description:    Used to display the correct rollover image when the mouse rolls  
//                  over a button.
//  Arguments:      buttonname - name of the button image to get
//  Returns:        none
//+----------------------------------------------------------------------------
//
function btndown( buttonname )
{
    if (document.images) {
      document.getElementById(buttonname).src = eval( buttonname + "down.src" );
    }
}


//+----------------------------------------------------------------------------
//  Function:       btnup
//  Author:         Kevin P. Wojdak
//  Modified:       March 2008
//  Description:    Used to display the original button image when the mouse rolls  
//                  away from a button.
//  Arguments:      buttonname - name of the button image to get
//  Returns:        none
//+----------------------------------------------------------------------------
//
function btnup ( buttonname )
{
    if (document.images) {
      document.getElementById(buttonname).src = eval( buttonname + "up.src" );
    }
}

//+----------------------------------------------------------------------------
//  Function:       formChecker
//  Author:         Kevin P. Wojdak (kwojdak@usa.net)
//  Created:        May 2005
//  Description:    Debugging tool to verify that a form is passing the correct data
//                  to the backend.
//                  
//  Arguments:      form = form object to check
//  Returns:        none
//
//  Note:           
//+----------------------------------------------------------------------------
//
function formChecker(form) {
	if (!form) form = document.forms[0];
	var numFlds = form.elements.length;
	var strAlert = 'Results of Form Submit:\n\nnumber of fields = ' + numFlds + "\n\n";
	for(i=0; i<numFlds; i++) {
		var rank = i + 1;
		if (form.elements[i].type == 'radio' || form.elements[i].type == 'checkbox') {
			strAlert += rank + ") " + form.elements[i].id + " = " + form.elements[i].checked + "\n";
		} else if (form.elements[i].type.substr(0,6) == 'select') {
			strAlert += rank + ") " + form.elements[i].id + " = " + form.elements[i][form.elements[i].selectedIndex].text + "\n";
		} else {
			strAlert += rank + ") " + form.elements[i].id + " = " + form.elements[i].value + "\n";
		}
	}
	alert(strAlert);
	return false;
}


//+----------------------------------------------------------------------------
//  Function:       menuLeftNavOn
//  Author:         Kevin P. Wojdak, SDI
//  Description:    Provides a hover effect for the background div behind a link.
//                  
//  Arguments:      btnObj = object reference to DIV
//  Returns:        none
// 
//  Note:           
//+----------------------------------------------------------------------------
//
function menuLeftNavOn(btnObj) {
    btnObj.style.cursor = 'pointer';
    btnObj.style.backgroundColor = '#dfe0df';
    btnObj.style.color = '#000';
    
}

//+----------------------------------------------------------------------------
//  Function:       menuLeftNavOff
//  Author:         Kevin P. Wojdak, SDI
//  Description:    Returns the background div for a link to its original 
//                  settings after hover.
//                  
//  Arguments:      btnObj = object reference to DIV
//  Returns:        none
// 
//  Note:           
//+----------------------------------------------------------------------------
//
function menuLeftNavOff(btnObj) {
    btnObj.style.cursor = 'default';
    btnObj.style.backgroundColor = 'transparent';
    btnObj.style.color = '#ffffff';
    
}

//+----------------------------------------------------------------------------
//  Function:       CheckForAlphaNumericsOnly
//  Author:         Raj Alairys, SDI
//  Created:           May 2001
//  Description:    Returns the background div for a link to its original 
//                  settings after hover.
//                  
//  Arguments:      btnObj = object reference to DIV
//  Returns:        none
// 
//  Note:           
//+----------------------------------------------------------------------------
//
function CheckForAlphaNumericsOnly(theFormField)
{
	//Check the last character entered to see if it is alphanumeric. If not, alert the user.
	//Don't do anything if the user just blanked out the field ("" or null, depending on browser).
	//NOTE: There is a possibility that non-alphanumerics can still be entered:
	//The user may quickly hit a couple of keys before the fuction catches it.
	//This could probably be fixed by looping through the whole string each time, but that seems
	//simply too resouce-intensive.
	//Raj Alairys - May 9, 2001.

	var blnSuccess = true; //If things are OK, return true, else return false.
		
	if(!((theFormField.value.substring(theFormField.value.length-1,theFormField.value.length)>="0"
		&& theFormField.value.substring(theFormField.value.length-1,theFormField.value.length)<="9")
		|| (theFormField.value.substring(theFormField.value.length-1,theFormField.value.length)>="a"
		&& theFormField.value.substring(theFormField.value.length-1,theFormField.value.length)<="z")
		|| (theFormField.value.substring(theFormField.value.length-1,theFormField.value.length)>="A"
		&& theFormField.value.substring(theFormField.value.length-1,theFormField.value.length)<="Z"))
		&& !(theFormField.value=="" || theFormField.value == null))
	{
			alert("Alpha-numeric characters only, please.");
			theFormField.value = theFormField.value.substring(0,theFormField.value.length-1);
			blnSuccess = false; //Return false, so we know this keystroke didn't get entered.
	}

	return blnSuccess;
}
