<!--
/*

  -------------------------------------------------------------------------------
 |  Copyright (C) 2005 Azalea Technology, LLC. All rights reserved.              |
 |-------------------------------------------------------------------------------|
 |  Unauthorized removal of this notice is considered a violation of the         |
 |  license agreement under which this Code may be used. This work is protected  |
 |  under United States copyright law and the similar law(s) of other countries  |
 |  under which such as work is afforded legal protection, and upon conviction   |
 |  of such a violation in a court of applicable jurisdiction, such person(s)    |
 |  may be subject to the maximum allowable penalty as permitted under such law. |
 |-------------------------------------------------------------------------------|
 |  You acknowledge and agree that information presented to you through this     |
 |  site (the "Web Site") is protected by all applicable copyrights, trademarks, |
 |  service marks, patents or other proprietary rights and laws, and by virtue   |
 |  of accessing the Web Site, except as expressly authorized by the Azalea      |
 |  Technology, LLC., you agree not to modify, rent, lease, loan, sell,          |
 |  distribute, store, or create derivative works based on the Web Site, in      |
 |  whole or in part.                                                            |
  ------------------------------------------------------------------------------- 
 |  Decrypting or otherwise decoding the following programming language code is  |
 |  strictly prohibited except as expressly authorized by Azalea Technology,     |
 |  LLC. Upon conviction of such a violation in a court of applicable            |
 |  jurisdiction, such person(s) may be subject to the maximum allowable penalty |
 |  as permitted under such law.                                                 |
  -------------------------------------------------------------------------------
          Module: forms.js
         Version: 1.0
		 Purpose: Form validation function library

      Programmer: Benjamin Roberts
                  Azalea Technology, LLC.
                  P.O. Box 131150
                  Tyler, TX 75713-1150
                  broberts@azaleatech.com

         License: HGR General Contractors, L.P.
                  Single Domain (www.hgrgc.com); 10/24/2005
  -------------------------------------------------------------------------------
*/

// CHECK A LIST OF SELECT BOXES TO MAKE SURE AT LEAST ONE IS SELECTED
function option_checked(obj){
	if(!obj) return false;
	if(!obj.length){
		if(obj.checked) return true;
		else return false;
	}
	for(var i=0;i<obj.length;i++){
		if(obj[i].checked) return true;
	}
	return false;
}

function option_all_checked(obj){
	if(!obj) return false;
	if(!obj.length){
		if(obj.checked) return true;
		else return false;
	}
	for(var i=0;i<obj.length;i++){
		if(!obj[i].checked) return false;
	}
	return true;
}

function option_index_checked(obj){
	if(!obj) return null;
	if(!obj.length) return null;
	for(var i=0;i<obj.length;i++){
		if(obj[i].checked) return i;
	}
	return null;
}

// CLEAR A LIST OF RADIO BUTTONS
function clear_radio_buttons(obj){
	if(!obj) return false;
	if(!obj.length){
		if(obj.checked){
			obj.checked=false;
			return true;
		}
		else return false;
	}
	for(i=0;i<obj.length;i++) obj[i].checked=false;
	return true;
}

// JUMP TO NEXT FIELD ON X NUMBER OF CHARACTERS IN CURRENT FIELD
function jump(x,obj_current,obj_next){
	if(!obj_current||!obj_next||obj_current.value.length==undefined||isNaN(parseInt(x))) return false;
	if(obj_current.value.length>=x) obj_next.focus();
}

// LOCK ALL FORM BUTTONS AFRER CLICK
function toggleFormButtonLock(form_obj,lock,buttonTxt){
    if(form_obj){ // check to make sure form object exists
    	if (!(browser.isOpera||browser.isUnknown)){
    		for (var i=0; i<form_obj.elements.length; i++){
    			if (form_obj.elements[i].type == 'submit' || form_obj.elements[i].type == 'button' || form_obj.elements[i].type == 'reset'){
    				form_obj.elements[i].disabled = lock;
    				if(buttonTxt!="") form_obj.elements[i].value = buttonTxt;
    			}
    		}
    	}
    }
}

// LOCK BUTTON AFRER CLICK
function toggleButtonLock(form_obj,form_obj_button,lock,buttonTxt,submitForm){
	if(form_obj&&form_obj_button){ // Check to make sure form object and button object exists
        if(!(browser.isOpera||browser.isUnknown)){
    		if(form_obj_button.type == 'submit' || form_obj_button.type == 'button' || form_obj_button.type == 'reset'){
    			form_obj_button.disabled = lock;
    			if(buttonTxt!="") form_obj_button.value = buttonTxt;
    		}
    		if(submitForm) form_obj.submit();
    	}
    	else if(submitForm) form_obj.submit();
    }
}

// DETECTS IF THE CAPS LOCK KEY IS DEPRESSED
function checkCapsLock(e){
	var myKeyCode=0;
	var myShiftKey=false;
	var myMsg='Your Caps Lock is On. Passwords are case sensitive.\n\nTo avoid entering your password incorrectly,\nyou should press Caps Lock to turn it off.';

	// Internet Explorer 4+
	if(document.all){
		myKeyCode=e.keyCode;
		myShiftKey=e.shiftKey;
	}
	// Netscape 4
	else if(document.layers){
		myKeyCode=e.which;
		myShiftKey=(myKeyCode==16) ? true : false;
	}
	// Netscape 6
	else if(document.getElementById){
		myKeyCode=e.which;
		myShiftKey=(myKeyCode==16) ? true : false;
	}

	// alert("myKeyCode = "+myKeyCode+"\nmyShiftKey = "+myShiftKey);
	// Upper case letters are seen without depressing the Shift key, therefore Caps Lock is on
	if ((myKeyCode >= 65 && myKeyCode <= 90) && !myShiftKey) alert(myMsg);

	// Lower case letters are seen while depressing the Shift key, therefore Caps Lock is on
	else if ((myKeyCode >= 97 && myKeyCode <= 122) && myShiftKey) alert(myMsg);
}

//-->