// March 2006: NRAEF JavaScript Document //

function init_page(){
	var firstname = document.getElementById('firstname');
	firstname.focus();

	// check the status of the radio button list; if a button is checked, bold it's corresponding label on page load //
	var radios = document.getElementsByTagName('input');
	for (var i=0; i<radios.length; i++){
		if(radios[i].type == 'radio'){
			if(radios[i].checked == true){
				radios[i].nextSibling.className = 'strong';
			}
			else{
				radios[i].nextSibling.className = '';
			}
		}
	}
	// what to do when user clicks a radio button //
	for (var i=0; i<radios.length; i++){
		if(radios[i].type == 'radio'){
			radios[i].onclick = function(){
				if(this.blur)this.blur();
				return radioLabel('contactemail');
				}
		}
	}
	// check the status of the checkbox list; if a box is checked, bold it's corresponding label on page load //
	var boxes = document.getElementsByTagName('input');
	for (var i=0; i<boxes.length; i++){
		if(boxes[i].type == 'checkbox'){
			if(boxes[i].checked == true){
				boxes[i].nextSibling.className = 'strong';
			}
			else{
				boxes[i].nextSibling.className = '';
			}
		}
	}
	// what to do when user clicks a radio button //
	for (var i=0; i<boxes.length; i++){
		if(boxes[i].type == 'checkbox'){
			boxes[i].onclick = function(){
				if(this.blur)this.blur();
				return boxLabel();
				}
		}
	}
}
/* basic function to bold/unbold labels of radio button elements */
function radioLabel(name){
	var radios = document.getElementsByName(name);
		for (var index = 0; index < radios.length; index++){
     		var thisRadio = radios[index];
			if(thisRadio.checked){ 
         		thisRadio.nextSibling.className = 'strong';
       			}
	   		else{
		 		thisRadio.nextSibling.className = '';
	   			}
     	}
}
/* basic function to bold/unbold labels of checkbox elements */
function boxLabel(){
	var boxes = document.getElementsByTagName('input');
		for (var index = 0; index < boxes.length; index++){
			if(boxes[index].type == 'checkbox'){
     			var thisBox = boxes[index];
				if(thisBox.checked){ 
         			thisBox.nextSibling.className = 'strong';
       				}
	   			else{
		 			thisBox.nextSibling.className = '';
	   				}
     		}
		}
}
/* Script to fix IE focus issue for input elements. */
function fixElementFOCUS(){
	var allInputs = document.getElementById('biblio').getElementsByTagName('input');
		for (var i=0; i<allInputs.length; i++){
		if(allInputs[i].type == 'text'){
			allInputs[i].onfocus=function(){
			this.className+=" IEfocus";
			}
		}
		if(allInputs[i].type == 'text'){
			allInputs[i].onblur=function(){
			this.className=this.className.replace(new RegExp(" IEfocus\\b"), "");
			}
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", fixElementFOCUS);
/* Script to fix IE underline issue for radio elements. */
function fixInputRADIO(){
	var allInputs = document.getElementById('biblio').getElementsByTagName('input');
		for (var i=0; i<allInputs.length; i++){
		if(allInputs[i].type == 'radio'){
			allInputs[i].className+=" IEradio";
			}
		}
}
if (window.attachEvent) window.attachEvent("onload", fixInputRADIO);