// ----------------------- Generic functionality ---------------------------- //
// Swap CSS rule if JS is running for a launcher icon class


function showIcons()
{
 var icos, i;
 icos=document.getElementsByTagName('a');
 for(i in icos)
  {
  if(/ico/.test(icos[i].className))
   {
    icos[i].style.visibility='visible';
   }
  }
}


// ==============================================
// Toggle Display of an object via DOM/CSS

function toggleViz(obj)
{
  if(document.getElementById(obj).style.display == "none")
    document.getElementById(obj).style.display = "block";
  else
    document.getElementById(obj).style.display = "none";
}

// ==============================================
// Quick Show-Hide Function via DOM/CSS

function showit(boxid){ 
   document.getElementById(boxid).style.display="block"; 
} 

function hideit(boxid){ 
   document.getElementById(boxid).style.display="none"; 
}


// ==============================================
// Limit the number of check boxes that can be checked, alert if exceded
function checkLimit(checkBox, checkLimit) {
	var checkCnt = 0;
	var checkForm = checkBox.form;
	var checkName = checkBox.name;
	var checkMax = checkForm[checkName].length;
	for (var i = 0; i < checkMax; i++) {
		if (checkForm[checkName][i].checked == true) {
	    	checkCnt += 1;
	   	}
	}
	if (checkCnt > checkLimit) {
		alert("You are only allowed to select " + checkLimit+".");
		checkBox.checked = false;
	}
}

function howheardExtras(howHeardFld) {
	var selectedVal = howHeardFld.options[howHeardFld.selectedIndex].value;
	var otherVal = 7;
	var repVal = 5;
	
	if (selectedVal == otherVal) {
		hideit('repLabel');
		hideit('repField');
		showit('otherLabel');
		showit('otherField');
	} else if (selectedVal == repVal) {
		hideit('otherLabel');
		hideit('otherField');
		showit('repLabel');
		showit('repField');
	} else {
		hideit('otherLabel');
		hideit('otherField');
		hideit('repLabel');
		hideit('repField');
	}
}

function jobtypeOther(jobTypeFld) {
	var selectedVal = jobTypeFld.options[jobTypeFld.selectedIndex].value;
	var otherVal = 9;
	
	if (selectedVal == otherVal) {
		showit('otherJTLabel');
		showit('otherJTField');
	} else {
		hideit('otherJTLabel');
		hideit('otherJTField');
	}
}