<!-- 

	var DB = new Object(); //global variable
	
	function changeDiv(obj) {
		var choice = "";
		var theForm = obj.form.name;
		
		switch(obj.type) {
			case "radio":
				choice = obj.value;
				break;
			case "select-one":
				choice = obj.options[obj.selectedIndex].value;
				break;
			default:
             	choice = obj.value; 
		}
		
		
		if (isDynamicQuestion(obj.name)) {
			var questionDB = DB[obj.name];
			//hide all the child questions in the form first
			for (var i=0; i < questionDB.length; i++) {
				hideQuestion(questionDB[i].child,theForm);
			}
			//reopen the selected child question
			if (choice != "") {
				for (var i=0; i < questionDB.length; i++) {
					var childQuestion = questionDB[i].child;
					if (choice == questionDB[i].ansID) {
						showQuestion(childQuestion,theForm);
					}
				}
			}
		}
	}			
		
	function hideQuestion(items,theForm) {
		hide(items);
		for (var q in items) {
			//if this is dynamic question?
			if (isDynamicQuestion(items[q])) {
				var questionDB = DB[items[q]];
				for (var i=0; i < questionDB.length; i++) {
					var childQuestion = questionDB[i].child;
					hideQuestion(childQuestion,theForm);
				}
			}
		}
	}
	
	function showQuestion(items,theForm) {
		show(items);
		for (var q in items) {
			//if this is dynamic question?
			if (isDynamicQuestion(items[q])) {
				var questionDB = DB[items[q]];
				var choice = getCurrentValue(items[q],theForm);
				if (choice != "") {
					for (var i=0; i < questionDB.length; i++) {
						childQuestion = questionDB[i].child;
						if (choice == questionDB[i].ansID) {
							showQuestion(childQuestion,theForm);
						} else {
							hide(childQuestion);
						}
						
					}
				}
			}
		}
	}
	
	//check whether a question is dynamic	
	function isDynamicQuestion(question) {
		for (var i in DB) {
			if (question == i) {
				return true;
			}
		}
		return false;
	}
	
	//get the current select form value specified by the element name
	function getCurrentValue(elemName,formName) {
		for (var e in document.forms[formName].elements) {
			if (e == elemName) {
				var elem = document.forms[formName].elements[elemName];
				if ( elem.type == 'text' || elem.type == 'select-one' || elem.type == 'hidden') {
					return elem.value;
				} else if (elem.type == 'radio') {
					if( typeof(elem.length) == 'undefined') {//single radio button!
						if (elem.checked == true) {
							return elem.value;
						}
					} else {
						for (var i =0; i < elem.length; i++) {
							if( elem[i].checked) {
								return elem[i].value;
							}
						}
					}
				} else if (elem.type == 'checkbox') {
					if (elem.checked == true) {
						return elem.value;
					}
				} else {//radio button group
					if (typeof (elem.length) != 'undefined') {
						for (var i =0; i < elem.length; i++) {
							if( elem[i].checked) {
								return elem[i].value;
							}
						}
					}
				}
			}
		}
		return '';
	}
	
	
	function getStyleObject(objectId) {
		if (document.getElementById && document.getElementById(objectId)) {
			return document.getElementById(objectId).style;
		} else if (document.all && document.all(objectId)) {
				return document.all(objectId).style;
		} else {
			return false;
		}
	}

	
	//function to hide div blocks
	function hide(items) {
		var theStyle;
		var theDiv = "";
		if (items) {
			for (var i = 0; i < items.length; i++) {
				theDiv = "block_" + items[i];
				theStyle = getStyleObject(theDiv);
				if (theStyle != false) {
					theStyle.display = "none";
				}
		    }
		}
	}
	
	//function to show div blocks
	function show(items) {
		var theStyle;
		var theDiv = "";
		if (items) {
			for (var i = 0; i < items.length; i++) {
				theDiv = "block_" + items[i];
				theStyle = getStyleObject(theDiv);
				if (theStyle != false) {
					theStyle.display = '';
				}
			}
		}
	}
	
	function showHide(the_div)
	{
	  var the_style = getStyleObject(the_div);
	  if (the_style != false)
	  {
	  	if (the_style.display == 'none') {
	    	the_style.display = '';
	  	} else {
	  		the_style.display = 'none';
	  	}
	  }
	}

// -->