//---------------------------------------------------------------------//
/*             Function to verify is the field is empty                */
//---------------------------------------------------------------------//
function DivCheck(CB){
	if (CB.checked) {
		heightLight(CB);
	} else {
		erase(CB);
	}
}
function heightLight(E){
//	while (E.tagName!="TD"){
//		E=E.parentElement;
//	}
//	E.className = "H";
}
function erase(E){
//	while (E.tagName!="TD"){
//		E=E.parentElement;
//	}
//	E.className = "DivTable";
}

function OnOff(form, name, self) {
	dml= eval("document." + form);
	len = dml.elements.length;
	var i=0;
	for( i=0 ; i<len ; i++) {
		if (dml.elements[i].name== name) {
			if (self.checked) {
				dml.elements[i].checked = true;
				heightLight(dml.elements[i]);
			}else {
				dml.elements[i].checked = false;
				erase(dml.elements[i]);
			}
		}
	}
}

// developed by BL 07/20/2003
// number of checkbox /radio button checked.
function NumberChecked(form, strname) {
	var icnt = 0;
	var dml= eval("document." + form);
	var len = dml.elements.length;
	var i=0;
	for( i=0 ; i<len ; i++) {
		if (eval("dml.elements[i].name=='" + strname + "' && dml.elements[i].checked")) {
			icnt += 1;
		}
	}
	return icnt;
}
function ChangeChild(parent, form, child, childvalue, header, inarray){
	var strSelected = "";
	var strchoices = "";
	var dml= eval("document." + form);
	var len = dml.elements.length;
	var sarray, aValue;
	var strParentField = "";
	if (inarray == "catarray") {
		sarray = catarray
		strParentField = "Major Category";
	}else if (inarray == "cityarray") {
		sarray = cityarray
		strParentField = "City";
	}else if (inarray == "classifiedarray") {
		strParentField = "Main Type";
		sarray = classifiedarray
	}else  {
		strParentField = "Event Type";
		sarray = eventarray
	}
	var i=0, j=0, k=0, m=0;
	for( i=0 ; i<len ; i++) {
		if (eval("dml.elements[i].name=='" + parent + "' && dml.elements[i].checked")) {
			for (j=0; j<sarray.length;j++) {
				if (dml.elements[i].value == sarray[j][0]) {
					aValue = childvalue.split(", ")
					var StrCheck="", StrTR=""
					for (m=0; m<aValue.length; m++) {
    						if (aValue[m] == sarray[j][1]) {
    							StrCheck = " checked "
    							break;
    						}
					}
					
					strchoices += "<tr>"
    					strchoices += "<td width=15 align=center><input type=checkbox name='" + child + "' style='height:18px;width=18px' value=\"" + sarray[j][1] + "\" onclick=" + "\"" + "DivCheck(this);" + "\"" + " " + StrCheck + "></td>" ;
	    				strchoices += "<td align=left class=Choice>&nbsp;<span class=ChoiceSpan onclick=" + "\"" + "document." + form + "." + child + "[" + k + "].click()" + "\"" + " style='cursor:hand;'>" + sarray[j][1] + " (" + sarray[j][0] + ") </span></td>" 
	    				strchoices += "</tr>" 					
					k +=1;
				}
			}			
		}
	}

	strhtml ="<div class='DIVCHOICE' align='center'>"
	strhtml += "<table border=0 cellpadding=0 cellspacing=0 class='DivTable' width='100%'>"	;
	if (k == 0) {
		strhtml += "<tr style='padding:3px;' class='BoxHeader'>";
		strhtml += "<td align='left' class='text1'><b>" + header + "</b></td>";
		strhtml += "</tr>"
		strhtml += "<tr>";
		strhtml += "<td class=Choice colspan=2>Choose " + strParentField + "</td>";
		strhtml += "</tr>"
	}
	else {
		strhtml += "<tr class='BoxHeader'>";
		strhtml += "<td align='center' class='text1' width='15' title='Check All/Uncheck All'>";
		strhtml += "<input type='checkbox' style='height:18px;width=18px' onclick=" + "\"" + "OnOff('" + form + "','" + child +"',this);" + "\"" + " ></td>\n";
		strhtml += "<td align='left' class='text1'><b>" + header + "</b></td>";
		strhtml += "</tr>"
		strhtml += strchoices;
	}
	strhtml += "</table>"
	strhtml += "</div>"		
			
	if (inarray == "catarray") {
		subCat.innerHTML = strhtml;
	}else if (inarray == "cityarray") {
		subCity.innerHTML = strhtml;
	}else if (inarray == "classifiedarray") {
		subType.innerHTML = strhtml;
	}else {
		subEvent.innerHTML = strhtml;
	}
}
