//Takes an element and changes its background color
//objectRef=element, state=1 || 0, set= # corresponding to color groups
function change_background(objectRef, state, set) {
		objectRef.style.backgroundColor = (1 == state) ? '#C8C8C8' : '#FFFFFF';
		return;
}
//end change_background

//function to determine whether radio buttons have been selected or not
function getSelectedRadio(buttonGroup) {
	   // returns the array number of the selected radio button or -1 if no button is selected
	   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
		  for (var i=0; i<buttonGroup.length; i++) {
			 if (buttonGroup[i].checked) {
				return i
			 }
		  }
	   } else {
		  if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
	   }
	   // if we get to this point, no radio button is selected
	   return -1;
	} // Ends the "getSelectedRadio" function

//MacroMedia's image swapping functions
		function MM_swapImgRestore() { //v3.0
		  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
		}
		
		function MM_preloadImages() { //v3.0
		  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
			var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
		}
		
		function MM_findObj(n, d) { //v4.01
		  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
			d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		  if(!x && d.getElementById) x=d.getElementById(n); return x;
		}
		
		function MM_swapImage() { //v3.0
		  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
		}
		
//end MM's functions

//form maxlength cursor focus function (ahhh! the poor grammer!) when a field's maxlength is reached/ change focus
function maxCheck(elmnt,content,nextelem)
{
if (content.length==elmnt.maxLength)
	{
		document.getElementById(nextelem).focus()
	}
}
//end of maxlength focus function
function maxCheck2(elmnt,content,nextelem)
{
if (content.length==elmnt)
	{
		document.getElementById(nextelem).focus()
	}
}

//pop up url, pretty self explanatory
function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=400,left = 312,top = 184');");
}

function compileJobs(){
	jobs=document.forms['checkform'].jobs
	txt=""
	var counting = 0;
	for (i=0;i<jobs.length;++ i){
		if (jobs[i].checked){
			txt=txt + jobs[i].value + ":::::";
			document.forms['checkform'].selections.value = txt;
			counting++;
		}
	}
	if(document.forms['checkform'].elements['userdefined'].checked){
		txt=txt + document.forms['checkform'].elements['userdefined'].value + ":::::";
		document.forms['checkform'].selections.value = txt;
		counting++;
	}
	if(counting > 3 || counting < 1){
		alert("Sorry, our system only accepts 1, 2 or 3 job selections at a time.");
		return false
	}else{
		return true
	}
}

function disenable(element, whatToDo){
	if(whatToDo == 'enable'){
		document.getElementById(element).disabled=false;
		}else{
		document.getElementById(element).disabled=true;
		}
}

function validate_required(field, alerttxt){
	with (field){
		if (value == null || value == ""){
			alerttxt = alerttxt + " must be filled out!";
			alert(alerttxt);
			return false
		}else{
			return true
			}
	}//end with
}//end function

function validate_email(field,alerttxt){
		with (field){
			apos=value.indexOf("@")
			dotpos=value.lastIndexOf(".")
			if (apos<1||dotpos-apos<2){
				alert(alerttxt);
				return false
			}else{
				return true
				}
		}//end with
	}//end function
	
Ajax.Responders.register({
	onCreate: function(){
		$('ajax_threads').update(Ajax.activeRequestCount);
		$('processing_gif').show();
		$('nonprocessing_gif').hide();
	},
	onComplete: function(){
		$('ajax_threads').update(Ajax.activeRequestCount);
		$('processing_gif').hide();
		$('nonprocessing_gif').show();
	}
});

function archiveopening(){
	return confirm('Are you Sure you want to Archive this opening?\n\nApplications submitted for this opening will still be saved, but no new applications will be accepted for it.\n\n Click Ok if you are sure you want to archive this opening.');
}
function archiveit(){
	return confirm('Are you Sure you want to Archive this application?');
}