
//---------------------------
function cSearchAll(me, groupName){
//Valid ticks for Search All
//---------------------------
	var parent1 = document.getElementsByTagName("span");
	var thisChild = "";
	
	for (var i=0; i < parent1.length; i++){	
		
		if (parent1[i].getAttribute("group")==groupName){
			
			thisChild = parent1[i].firstChild;
			
			if (thisChild != null) {		
				if (thisChild.nodeType == 1 ){
					if (document.getElementById(thisChild.id) != null) {
						if (me.checked == true){
							document.getElementById(thisChild.id).checked = true;
						}else{
							document.getElementById(thisChild.id).checked = false;
						}
					}
				}
			}
		}
	}
}	

//---------------------------
function cSearchAllReset(me, sAllID){
//Reset an item from a search location
//---------------------------
	document.getElementById(sAllID).checked = false;
}

//---------------------------
function cSearchAllResetAll(me, sGroup, bKeepSelected){
//Reset all items in a certain group
//---------------------------
    var bMeChecked = me.checked;
	var parent1 = document.getElementsByTagName("span");
	var thisChild = "";
	
	for (var i=0; i < parent1.length; i++){	
		if (parent1[i].getAttribute("group")==sGroup){			
			thisChild = parent1[i].firstChild;

			if (thisChild != null) {		
				if (thisChild.nodeType == 1 ){
					if (document.getElementById(thisChild.id) != null) document.getElementById(thisChild.id).checked = false;
				}
			}
		}
	}
	
	if (me != null && bKeepSelected)
	{
	    me.checked = bMeChecked;
	}
}

//---------------------------
function validateSearch(groups, sMsg){
//Be sure all is ticked when user submits form.
//---------------------------
	//check to see if there is a location selected.
	var parent1 = document.getElementsByTagName("span");
	var thisChild = "";
	var arrGroup = new Array();
	var isValid = false;
	
	arrGroup = groups.split(';');
	
	for (var i=0; i < parent1.length; i++){	
	
		for (var k=0; k < arrGroup.length; k++){	
			if (arrGroup[k]!=null){
				if (parent1[i].getAttribute("group")==arrGroup[k]){			
					thisChild = parent1[i].firstChild;
				
					if (thisChild != null) {		
						if (thisChild.nodeType == 1 ){
							if (document.getElementById(thisChild.id) != null) {
								if (document.getElementById(thisChild.id).checked==true){
									isValid = true;
								}
							}
						}
					}
				}
			}
		}
	}
	
	if (isValid==true) {
		return true;
	}else{
		alert(sMsg);
		return false;
	}

}

//---------------------------
function validateEmail(txtBox){
//validate email subscribe
//---------------------------
	oTxtBox = document.getElementById(txtBox);
	if (oTxtBox == null) return false;
	if (oTxtBox.value == "") {
		alert("Please enter a value")
		return false;
	}
	
	if (isValidEmail(oTxtBox.value)){
		return true;
	}else{
		alert("You have entered an invalid email address.");
		return false;
	}
}
