var currentlyActiveInputRef = false;
var currentlyActiveInputClassName = false;

function highlightActiveInput() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'inputHighlighted';
  currentlyActiveInputRef = this;
}

function highlightPasswordInput() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'passwordHighlighted';
  currentlyActiveInputRef = this;
}

function highlightLongPasswordInput() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'passwordLongHighlighted';
  currentlyActiveInputRef = this;
}

function highlightPhoneInput() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'txtPhoneHighlighted';
  currentlyActiveInputRef = this;
}

function highlightPaymentInput() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'paymentAmountHighlighted';
  currentlyActiveInputRef = this;
}


function highlightMemberInput() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'memberHighlighted';
  currentlyActiveInputRef = this;
}

function highlightCcInput() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'ccHighlighted';
  currentlyActiveInputRef = this;
}
function highlightText14Input() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'text14Highlighted';
  currentlyActiveInputRef = this;
}

function highlightText20Input() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'text20Highlighted';
  currentlyActiveInputRef = this;
}

function highlightText10Input() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'text10Highlighted';
  currentlyActiveInputRef = this;
}

function highlightText30Input() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'text30Highlighted';
  currentlyActiveInputRef = this;
}

function highlightListInput() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'listHighlighted';
  currentlyActiveInputRef = this;
}

function highlightCourseInput() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'courseHighlighted';
  currentlyActiveInputRef = this;
}

function highlightListPrefix() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'PrefixHighlighted';
  currentlyActiveInputRef = this;
}
function highlightListState() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'listStateHighlighted';
  currentlyActiveInputRef = this;
}
function highlightPaymentAmountInput() {
  if(currentlyActiveInputRef) {
    currentlyActiveInputRef.className = currentlyActiveInputClassName;
  }
  currentlyActiveInputClassName = this.className;
  this.className = 'paymentAmountHighlighted';
  currentlyActiveInputRef = this;
}
function blurActiveInput() {
  this.className = currentlyActiveInputClassName;
}

function initInputHighlightScript() {
  var tags = ['INPUT','TEXTAREA','SELECT','BUTTON'];
  for(tagCounter=0;tagCounter<tags.length;tagCounter++){
    var inputs = document.getElementsByTagName(tags[tagCounter]);
    for(var no=0;no<inputs.length;no++){

      if(inputs[no].className && inputs[no].className=='doNotHighlightThisInput')continue;

      if(inputs[no].tagName.toLowerCase()=='input' && inputs[no].type.toLowerCase()=='text' && inputs[no].className.toLowerCase()=='textinput'){
        inputs[no].onfocus = highlightActiveInput;
        inputs[no].onblur = blurActiveInput;
      }  // if

      if(inputs[no].tagName.toLowerCase()=='input' && inputs[no].type.toLowerCase()=='password' && inputs[no].className.toLowerCase()!='passwordlong'){
        inputs[no].onfocus = highlightPasswordInput;
        inputs[no].onblur = blurActiveInput;
      }  // if password
      
      if(inputs[no].tagName.toLowerCase()=='input' && inputs[no].type.toLowerCase()=='password' && inputs[no].className.toLowerCase()=='passwordlong'){
        inputs[no].onfocus = highlightLongPasswordInput;
        inputs[no].onblur = blurActiveInput;
      }  // if password


      
     if(inputs[no].tagName.toLowerCase()=='input' && inputs[no].type.toLowerCase()=='text' && inputs[no].className.toLowerCase()=='memberinput' ){

	inputs[no].onfocus = highlightMemberInput;
        inputs[no].onblur = blurActiveInput;
      }  // if member
      
     if(inputs[no].tagName.toLowerCase()=='input' && inputs[no].type.toLowerCase()=='text' && inputs[no].className.toLowerCase()=='ccinput' ){

	inputs[no].onfocus = highlightCcInput;
        inputs[no].onblur = blurActiveInput;
      }  // if credit card
      
      if(inputs[no].tagName.toLowerCase()=='input' && inputs[no].type.toLowerCase()=='text' && inputs[no].className.toLowerCase()=='text14input' ){

	inputs[no].onfocus = highlightText14Input;
        inputs[no].onblur = blurActiveInput;
      }  // 14 char input
      
      if(inputs[no].tagName.toLowerCase()=='input' && inputs[no].type.toLowerCase()=='text' && inputs[no].className.toLowerCase()=='text20input' ){

	inputs[no].onfocus = highlightText20Input;
        inputs[no].onblur = blurActiveInput;
      }  // 20 char input
      
        if(inputs[no].tagName.toLowerCase()=='input' && inputs[no].type.toLowerCase()=='text' && inputs[no].className.toLowerCase()=='text30input' ){

	inputs[no].onfocus = highlightText30Input;
        inputs[no].onblur = blurActiveInput;
      }  // 30 char input
      
      if(inputs[no].tagName.toLowerCase()=='input' && inputs[no].type.toLowerCase()=='text' && inputs[no].className.toLowerCase()=='text10input' ){

	inputs[no].onfocus = highlightText10Input;
        inputs[no].onblur = blurActiveInput;
      }  // 10 char input
     
     if(inputs[no].className.toLowerCase()=='listinput'  ){
	inputs[no].onfocus = highlightListInput;
        inputs[no].onblur = blurActiveInput;
      }  // if list
      
      if(inputs[no].className.toLowerCase()=='courselist'  ){
	inputs[no].onfocus = highlightCourseInput;
        inputs[no].onblur = blurActiveInput;
      }  // if course list
      
      if(inputs[no].className.toLowerCase()=='liststate'  ){
	inputs[no].onfocus = highlightListState;
        inputs[no].onblur = blurActiveInput;
      }  // if State List
      
      if(inputs[no].className.toLowerCase()=='prefix'  ){
	inputs[no].onfocus = highlightListPrefix;
        inputs[no].onblur = blurActiveInput;
      }  // if State List
      
      if(inputs[no].className.toLowerCase()=='button'  ){
	inputs[no].onfocus = highlightActiveInput;
        inputs[no].onblur = blurActiveInput;
      }  // if button
      
      if(inputs[no].className.toLowerCase()=='txtphone'  ){
	inputs[no].onfocus = highlightPhoneInput;
        inputs[no].onblur = blurActiveInput;
      }  // if list

	if(inputs[no].className.toLowerCase()=='paymentamount'  ){
	inputs[no].onfocus = highlightPaymentInput;
        inputs[no].onblur = blurActiveInput;
      }  // if list
      if(inputs[no].className.toLowerCase()=='paymentamount'){
        inputs[no].onfocus = highlightPaymentAmountInput;
        inputs[no].onblur = blurActiveInput;
      }  // if payment
    } // for
  } // for
} // main
