<!--
/*

 -------------------------------------------------------------------------------
|  Copyright (C) 2004 Azalea Technology. 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.                                                            |
 -------------------------------------------------------------------------------

 Organization: Physicians Contracting Organization of Texas
       Domain: www.pcot.org
      Purpose: HTML form utility function library
	     Date: Tuesday, November 2, 2004 11:05 PM CST
   Programmer: Benjamin Roberts (broberts@azaleatech.com)
               Azalea Technology, LLC.
               P.O. Box 131150
			   Tyler, TX 75713-1150
*/

// 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;
}

// 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 (!(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(!(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);
}

function hideBlock(nr){
	if (document.layers) document.layers[nr].display = 'none';
	else if (document.all) document.all[nr].style.display = 'none';
	else if (document.getElementById) document.getElementById(nr).style.display = 'none';
}

function showBlock(nr){
	if (document.layers) document.layers[nr].display = 'block';
	else if (document.all) document.all[nr].style.display = 'block';
	else if (document.getElementById) document.getElementById(nr).style.display = 'block';
}

function blocking(nr){
	if (document.layers){
		current = (document.layers[nr].display == 'none') ? 'block' : 'none';
		document.layers[nr].display = current;
	}
	else if (document.all){
		current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
		document.all[nr].style.display = current;
	}
	else if (document.getElementById){
		vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
		document.getElementById(nr).style.display = vista;
	}
}

	
//-->
