function setChecked(state, theForm, formName){
	for(i=0; i<document.theForm.elements.length && document.theForm.elements[i].name==formName; i++)
		document.theForm.elements[i].checked=state;
}

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			{
			objCheckBoxes[i].checked = CheckValue;
			}
}

 function enClick(box)
  {
    box.checked = true;
  }

function ndsu_checkCalendarDates() {
	// If the start/end date are not equal, hide the whole repeat section
alert();
	if (document.getElementById("hdn_start_date").value != document.getElementById("hdn_end_date").value) {
		table.style.display = "none";
		table.style.visibility = "hidden";	
	}
	else {
		table.style.display = isIE() ? "inline" : "table";
		table.style.visibility = "visible";
	}
}

function ndsu_reserve(type, machid, start_date, resid, scheduleid, is_blackout, read_only, pending, start_time, end_time) {  
		if (is_blackout == null) { is_blackout = 0; }
		
		if (is_blackout != 1) {
			w = (type == 'r') ? 600 : 520;
			h = (type == 'm') ? 305 : 285;
		}
		else {
			w = (type == 'r') ? 600 : 425;
			h = (type == 'm') ? 230 : 210;
		}
		
		if (machid == null) { machid = ''; }
		if (start_date == null) { start_date = ''; }
		if (resid == null) { resid = ''; }
		if (scheduleid == null) { scheduleid = ''; }

		if (read_only == null) { read_only = ''; }
		if (pending == null) { pending = ''; }
		if (start_time == null) { start_time = ''; }
		if (end_time == null) { end_time = ''; }

		nurl = "ndsu.reserve.php?machid=" + machid;    
		var resWindow = window.open(nurl,"view_resource","width=" + w + ",height=" + h + ",scrollbars=yes,resizable=no,status=no");     
		resWindow.focus();
		void(0);   
}  

function ndsu_receipt(type, resid){
		w = 600;
		h = 600;
		
		nurl = "checkit.receipt.php?type=" + type +"&reservations=" + resid;    
		
		var resWindow = window.open(nurl,"view_resource","width=" + w + ",height=" + h + ",scrollbars=yes,resizable=no,status=no");     
		
		resWindow.focus();
		
		void(0);   
}