﻿// JScript File
// Originally created by Unknown Programmer
// Modified by Ben Liston on 10/10/08 to use new image names
// Used to capture the 'Enter' key for tracking pro numbers and logging in on the masterpage
// Also controls mouseover events on the navigation bar at the top of the masterpage

trapKeypressEvents();

function trapKeypressEvents(){

	
		
		// setup IE to listen for the keypress
		if (document.all) {
			document.onkeypress = keyPressHandler;
			
		// setup Gecko browsers to listen for the keypress
		} else if (document.getElementById) {
			document.addEventListener ("keypress",keyPressHandler,false);
		}
        
}

function keyPressHandler(e){	
	if (!e) e = window.event; 
	var myKey = e.keyCode;	
	if (myKey == 13){
		//first check to see if the user is NOT logged in
		if (document.all._ctl00_txtUserName){		
			if (document.all._ctl00_txtUserName.style.color=='black' || document.all._ctl00_txtPassword.style.color=='black'){
				
				//the following line disables the required field validator for the pro number field 
				//on the homepage so if does not show on the login postback event .
				if (document.all._ctl00_rfvProNum){				    
					document.all._ctl00_rfvProNum.enabled="false";
				}					
				__doPostBack('_ctl00$login$lbtnLogin','');
				return false;
				
			}else{
				return true;
			}
		}else{
			
		}		
	}
}


bName = navigator.appName;
bVer = parseInt(navigator.appVersion);
if ((bName == "Netscape" && bVer >= 3) || 
(bName == "Microsoft Internet Explorer" && bVer >= 4)) br = "n3"; 
else br = "n2";

  
if (br== "n3") {
img1on = new Image();  
img1on.src = "../Master/Images/mpNavigationOver1.gif";
img2on = new Image(); 
img2on.src = "../Master/Images/mpNavigationOver6.gif";
img3on = new Image(); 
img3on.src = "../Master/Images/mpNavigationOver3.gif";
img4on = new Image(); 
img4on.src = "../Master/Images/mpNavigationOver2.gif";
img5on = new Image(); 
img5on.src = "../Master/Images/mpNavigationOver4.gif";
img6on = new Image(); 
img6on.src = "../Master/Images/mpNavigationOver5.gif";

img1off = new Image();  
img1off.src = "../Master/Images/mpNavigation1.gif";
img2off = new Image(); 
img2off.src = "../Master/Images/mpNavigation6.gif";
img3off = new Image(); 
img3off.src = "../Master/Images/mpNavigation3.gif";
img4off = new Image(); 
img4off.src = "../Master/Images/mpNavigation2.gif";
img5off = new Image(); 
img5off.src = "../Master/Images/mpNavigation4.gif";
img6off = new Image(); 
img6off.src = "../Master/Images/mpNavigation5.gif";
}

function imgAct(imgName) {
if (br== "n3") {
    if(bName == "Microsoft Internet Explorer") document.all[imgName].src = eval(imgName + "on.src");
    else document[imgName].src = eval(imgName + "on.src");
}
}

function imgInact(imgName) {
if (br== "n3") {
	if(bName == "Microsoft Internet Explorer")document.all[imgName].src = eval(imgName + "off.src");
	else document[imgName].src = eval(imgName + "off.src");
}
}

function windowopen(terminal)
{
   msg = open(terminal,"DisplayWindow","width=290,height=150,scrollbars=NO,toolbar=no,directories=no,menubar=no");
   msg.focus();
}

function closewin(){
	if (msg != null);{
		msg.close();
	}
}

function setmsg(){
	msg = null;
}
    
function trimAll(sString)
{
    if(sString != "")
    {
        while (sString.substring(0,1) == ' ')
        {
            sString = sString.substring(1, sString.length);
        }
        while (sString.substring(sString.length-1, sString.length) == ' ')
        {
            sString = sString.substring(0,sString.length-1);
        }
    }
    
    return sString;
}