// son of suckerfish menu script from:
// http://www.htmldog.com/articles/suckerfish/dropdowns/

var IMAGE_DIR = "../images/";

check = []; // this is an array that stores all the true/false values for each checkbox 

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i = 0; i < sfEls.length; i++) {
		sfEls[i].onmouseover = function() {
			this.className += " sfhover";
			this.style.zIndex = 200; // this line added to force flyout to be above relatively positioned stuff in IE
		}
		sfEls[i].onmouseout = function() {
			this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


// deprecated 
// dual_mode_radio_button can be safely deleted 
function dual_mode_radio_button(id) {
	if (id == 0){
		document.getElementById('imgCheck'   + 0).src   = IMAGE_DIR + 'on_hover.png';  // change the image
		document.getElementById('imgCheck'   + 1).src   = IMAGE_DIR + 'off_hover.png'; // change the image
		document.getElementById('inputCheck' + 0).value = 'on';						   // change the field value
		document.getElementById('inputCheck' + 1).value = 'off';					   // change the field value
	}
	else {
		document.getElementById('imgCheck'   + 1).src   = IMAGE_DIR + 'on_hover.png';  // change the image
		document.getElementById('imgCheck'   + 0).src   = IMAGE_DIR + 'off_hover.png'; // change the image
		document.getElementById('inputCheck' + 1).value = 'on';						   // change the field value
		document.getElementById('inputCheck' + 0).value = 'off';					   // change the field value
	}
}

// this is more generic of the dual_mode_radio_button 
// i.e use where you have multiple radio buttons in a single form 
function dual_mode_radio_(id, x, y, state) {
	if (x == 0){ 
		document.getElementById('imgCheck' + x).src = IMAGE_DIR + 'on_hover.png';  // change the image
		document.getElementById('imgCheck' + y).src = IMAGE_DIR + 'off_hover.png'; // change the image
	} else {     
		document.getElementById('imgCheck' + x).src = IMAGE_DIR + 'on_hover.png';  // change the image
		document.getElementById('imgCheck' + y).src = IMAGE_DIR + 'off_hover.png'; // change the image
	}
	if (state == 1){
		document.getElementById('inputCheck' + id).value = 'on';		
	} else {
		document.getElementById('inputCheck' + id).value = 'off'; 						 
	}
}


function checkBox(id) {
	if (document.getElementById('inputCheck' + id).value == 'off') {
		document.getElementById('imgCheck'   + id).src   = IMAGE_DIR + 'true.png';     // change the image
		document.getElementById('inputCheck' + id).value = 'on';                         // change the field value
	} else {
		document.getElementById('imgCheck'   + id).src   = IMAGE_DIR + 'false.png';    // change the image
		document.getElementById('inputCheck' + id).value = 'off';                        // change the field value

		document.getElementById('inputCheckAll').src     = IMAGE_DIR + 'false.png';      
		document.getElementById('inputCheckAll').value   = 'off';  

	}
}


function checkBoxAll(num) {
	if (document.getElementById('inputCheckAll').value == 'off') {
		for (var i = 0; i < num; i++) {
			document.getElementById('imgCheck'   + i).src   = IMAGE_DIR + 'true.png';  // change the image
			document.getElementById('inputCheck' + i).value = 'on';                      // change the field value
		}
		document.getElementById('inputCheckAll').src   = IMAGE_DIR + 'true.png';       // change the image
		document.getElementById('inputCheckAll').value = 'on';  
	} else {
		for (var i = 0; i < num; i++) { 
			document.getElementById('imgCheck'   + i).src   = IMAGE_DIR + 'false.png'; // change the image
			document.getElementById('inputCheck' + i).value = 'off';                     // change the field value
		}
		document.getElementById('inputCheckAll').src   = IMAGE_DIR + 'false.png';      // change the image
		document.getElementById('inputCheckAll').value = 'off';  
	}
}
