function enter(input){
	var children = input.childNodes;
	for(var i=0; i<children.length; i++){
		if(children[i].tagName == 'UL'){
			children[i].style.visibility = 'visible';
			document.body.style.height = "1px";
			document.body.style.xIndex = "2000";
		}
	}
}

function leave(input){
	var children = input.childNodes;
	for(var i=0; i<children.length; i++){
		if(children[i].tagName == 'UL'){
			children[i].style.visibility = 'hidden';
			document.body.style.height = "auto";
		}
	}
}

function dlImg(newloc){
	if(document.getElementById("agree").checked){
		window.location=newloc;
	}else{
		alert("You must agree to the terms and conditions to download this image");
	}
}
function check_press_form(){
	if(document.getElementById("otherinput").checked){
		if(document.getElementById("othertext").value==''){
			alert("Please complete the 'other' text field");
			return false;
		}else{
			return true;
		}
	}
}
function eventTrigger (e) {
    if (! e)
        e = event;
    return e.target || e.srcElement;
}

function checkYesNo (e, msgId) {
    var obj = eventTrigger (e);
    //alert('You clicked on ' + obj.value);
    if(obj.value != 'Yes'){
    	document.getElementById(msgId).style.display = 'block';
    }else{
    	document.getElementById(msgId).style.display = 'none';
    }
    
    return true;
}
//function checkYesNo(yesNoName, msgId){
//	alert(yesNoName);
//	alert(document.getElementByName(yesNoName)[0]);
//}

function newWin(type, loc, width, height, title){
	//alert(type + " : " + loc + " : " + width + " : " + height + " : " + name + " : ");
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
	if(type == 'flash'){
		new_height = height+16;
	}else if(type == 'quicktime'){
		new_height = height + 32;
	}else{
		new_height = height;
	}
	var url = '/design/solar/pages/' + type + '.php?f=' + loc + '&w=' + width + '&h=' + height + '&t=' + title;
	newwindow=window.open(url,type,'left='+winl+',top='+wint+',height=' + new_height + ',width=' + width + ',scrollbars=no,toolbar=no,location=no,menubar=no,status=no');
	if (window.focus) {newwindow.focus()}
}

function changeCheckBox(){
	var checkboxes = document.getElementById("kbsearch").getElementsByTagName("input");
	if(this.name == "all"){
		if(this.checked){
			checkBoxState = true;
		}else{
			checkBoxState = false;
		}
		for(var j=0; j<checkboxes.length; j++){
			if(checkboxes[j].type == 'checkbox'){
				checkboxes[j].checked = checkBoxState;
			}
		}
	}else{
		//make sure all is unchecked
		if(!this.checked){
			for(var j=0; j<checkboxes.length; j++){
				if(checkboxes[j].name == "all"){
					checkboxes[j].checked = false;
				}
			}
		}
	}
}

function addKBCheck (){
	var searchBox = document.getElementById("kbsearch");
	if(searchBox){
		var checkboxes = searchBox.getElementsByTagName("input");
		for(var j=0; j<checkboxes.length; j++){
			if(checkboxes[j].type == 'checkbox'){
				checkboxes[j].onclick = changeCheckBox;
			}
		}
	}
}

window.onload = addKBCheck;
