		var choices = {};
		var remembered = {};
		var questions = new Array();
		var currentQuestion = null;
		var stepStack = new Array();
						
		function Question( id, pri ) {
			this.id = id;
			this.extension = "html";
			this.pri = pri;
			this.requirements = new Array();
			this.exceptions = new Array();			
			this.addRequirement = function(  ) {
				var test = new Array();
				for (var i=0;i<arguments.length;i++) {					
					test[i] = arguments[i];
				}			
				this.requirements[this.requirements.length] = test;
			}
			this.addException = function( name, value ) {
				var test = new Array();
				for (var i=0;i<arguments.length;i++) {					
					test[i] = arguments[i];
				}			
				this.exceptions[this.exceptions.length] = test;
			}		
			
			this.checkRequirement = function( req ) {
				for (var j=0;j<req.length;j+=2) {
					var name=req[j];
					var value=req[j+1];
					if (choices[name] && choices[name] == value) {
						return true;
					} 				
				}
				return false;
			}
			this.checkException = function( req ) {
				for (var j=0;j<req.length;j+=2) {
					var name=req[j];
					var value=req[j+1];
					if (choices[name] && choices[name] == value) {
						return false;
					}	
				}
				return true;
			}
				
			this.applies = function() {				
				for (var i=0;i<this.requirements.length;i++) {
					if (!this.checkRequirement(this.requirements[i])) return false;												
				}
				for (var i=0;i<this.exceptions.length;i++) {
					if (!this.checkException(this.exceptions[i])) return false;	
				}
				return true;
			}			
			questions[questions.length] = this;
		}
		function sortQuestions( a, b ) {
			return a.pri - b.pri;
		}
		
		function nextStep() {
			if (!contentLoaded) {
				return;
			}
			
			var content = document.getElementById("CONTENT");
			if (content && CONTENT.store) {
				if (!CONTENT.store()) {
					alert("You must completely fill out the form before you can move on");
					return;
				}				
			}
			if (currentQuestion != null) {
				stepStack[stepStack.length] = currentQuestion;
			}
			
			if (content && CONTENT.closeButton) {
			  window.close();
			  return;
			}
			
			if (currentQuestion != null && currentQuestion.terminal) {
			  if (currentQuestion.submit) submitData();
			  else window.close();
			  return;
			}
						
			if (content) {
				var q = getNextQuestion();
				if (q) {					
					contentLoaded = false;					
					currentQuestion = q;					
					content.src = q.id+"."+q.extension;													
				} 
				
			}
		}
		
		function debug(){
			var s = "";
			var count = 0;
			for (key in choices) {
				if (choices[key] != null) {
					var t = key+':'+choices[key];
					s = s + t.length + ':' + t;
					count++;
				}
			} 
			s = count + ':' + s;
			alert( s );
		}
		
		function submitData(){
			var s = "";
			var count = 0;
			for (key in choices) {
				if (choices[key] != null) {
					var t = key+':'+choices[key];
					s = s + t.length + ':' + t;
					count++;
				}
			} 
			s = count + ':' + s;
			
			var submitForm = getForm('submit');
			if (submitForm) {			
				var ie5 = (navigator.userAgent.indexOf("MSIE 5") != -1 && navigator.userAgent.indexOf("MSIE 5.5") == -1);
				if (!ie5 && encodeURIComponent) {
					submitForm['content'].value = encodeURIComponent(s);
				} else {
					submitForm['content'].value = escape(s);
				}
							
				submitForm.submit();
			}
		}
		
		function getForm( name ) {
			if (CONTENT && CONTENT.document) {
				var cforms = CONTENT.document.forms;
				for (var i=0;i<cforms.length;i++) {
					if (cforms[i].name == name) {
						return cforms[i];
					}
				}
			}
			return null;
		}
		
		function prevStep() {
			if (!contentLoaded) return;
			var content = document.getElementById("CONTENT");
			if (content) {
				var lastQuestion = currentQuestion;
				if (CONTENT.unstore) CONTENT.unstore();				
				if (stepStack.length > 0) {
					currentQuestion = stepStack[stepStack.length-1];
					stepStack.length = stepStack.length-1;				
					content.src = currentQuestion.id+"."+currentQuestion.extension;					
				} else if (currentQuestion != null) {
					currentQuestion = null;		
					content.src = "intro.html";							
				}
			}
		}		
				
		function getNextQuestion() {			
			if (!sorted) {
				questions.sort(sortQuestions)	
				sorted = true;
			}
			var currentPri = 0;
			if (currentQuestion != null) {
			   currentPri = currentQuestion.pri;
			}
			for (var i=0;i<questions.length;i++) {
				var q = questions[i];
				if (q.pri > currentPri && q.applies()) {							
					return q;
				}
			}
			
		}
		
		function questionLoaded( questionid ) {
			contentLoaded = true;							
			if (currentQuestion) {
				document.prev.style.display = '';	
				document.next.style.display = '';				
				document.prev.src = 'prev.gif';								
				document.next.src = 'next.gif';
			} else {
				document.prev.style.display = 'none';	
			}
			if (CONTENT.disablenext) {
			   document.next.style.display = 'none';
			}
			if (CONTENT.disableprev) {
			   document.prev.style.display = 'none';
			}
						
			if (CONTENT.submitButton) {
				document.next.src = 'submit.gif';
			} else if (CONTENT.closeButton) {
				document.next.src = 'close.gif';	
			}
			 			
			
			if (CONTENT.question && currentQuestion) currentQuestion.text = CONTENT.question;		
		}
		
		var sorted = false; 
		var contentLoaded = false;
		
		/*----------- LIBRARY FUNCTION FOLLOW -----------------*/
		
		
		function validateForm( form ) {
			var testValues = {};
			storeForm( form, testValues );
			var elements = form.elements;
			for (var i=0;i<elements.length;i++) {
				var element = elements[i];
				if (element.name && element.name.length > 0) {
					if (testValues[element.name] && testValues[element.name].length > 0) {
						// NO-OP
					} else {
						return false;
					}
				}
			}
			return true;
		}
		
		function loadForm( form, result ) {
			var elements = form.elements;
			for (var i=0;i<elements.length;i++) {
				var element = elements[i];
				if (element.name && element.name.length > 0) {
					switch( element.type ) {
						case 'hidden':
						case 'text':	
						case 'password':	
						case 'select-one':
						case 'select-multiple':	
						case 'textarea':																
							if (result[ element.name ]) {
							 	element.value = result[ element.name ];
							} 
							break;
						case 'radio':
						case 'checkbox':
							if (result[ element.name ] && containsString(result[ element.name ], element.value)) {
								element.checked = true;
							}
							break;
						default:
							break;	
					}
				}
			}		
		}
		
		function storeForm( form, result ) {
			var elements = form.elements;
			for (var i=0;i<elements.length;i++) {
				var element = elements[i];
						
				if (element.name && element.name.length > 0) {
					switch( element.type ) {
						case 'hidden':
						case 'text':	
						case 'text':
						case 'password':	
						case 'select-one':
						case 'select-multiple':
						case 'textarea':																	
							if (element.value.length > 0) result[ element.name ] = element.value
							break;
						case 'radio':
						case 'checkbox':
							if (element.checked && element.value.length > 0) {
								if (result[ element.name ]) {
									result[ element.name ] = result[ element.name ]+','+element.value
								} else {
									result[ element.name ] = element.value;
								}
										
							}
							break;
						default:
							break;	
					}
				}
			}		
		}
		
		function copy( source, dest ) {
			for (key in source) {
				var value = source[key];
				if (value != null) dest[key] = source[key];
			} 
		}
		
		function outputResult( result ) {
			var s = "";
			for (key in result) {
				s = s+key+'='+result[key]+'\n';
			} 
			return s;
		}
		
		function unstoreForm( form, result ) {
			var elements = form.elements;
			for (var i=0;i<elements.length;i++) {
				var element = elements[i];
				if (element.name && element.name.length > 0 && result[ element.name ]) {
					result[ element.name ] = null;					
				}
			}		
		}
		
		function containsString( input, value ) {
			var values = input.split(",");
			for (var i=0;i<values.length;i++) {
				if (value == values[i]) return true;
			}
			return false;
		}
		
		
		
		// WIZARD DEFINITION
		var q = new Question("start",1);

		q = new Question("edition",2);
		q.addException("start","trouble purchasing");
		q.addException("start","suggestion");
		q.addException("start","dictionary");	
		
		q= new Question("institutiononline",2.2);
		q.addRequirement("start","institution");		
		q.addRequirement("edition","online");
		
		q = new Question("subnature",2.1);
		q.addRequirement("edition","online");
		q.addException("start","trouble evaluating");		
		q.addException("start","institution");			
				
		q = new Question("trialnature",2.1);
		q.addRequirement("edition","online");
		q.addException("start","customer trouble");	
		q.addException("start","institution");		
		
		q = new Question("desktopnature",2.1);
		q.addRequirement("edition","desktop");
		
		q = new Question("desktopversion",2.2);
		q.addRequirement("edition","desktop");
		q.addException("desktopnature","redownload");

		q = new Question("wordversion",2.3);
		q.addRequirement("edition","wordplugin");
		
		q = new Question("usewordwith",2.4);
		q.addRequirement("edition","wordplugin");
		
				
		q = new Question("computer",3);
		q.addException("institutiononline","change authentication");
		q.addException("start","suggestion");		
		q.addException("start","trouble purchasing");
		q.addException("start","dictionary");	
		q.addException("subnature","cantlogin");
		q.addException("subnature","liketocancel");
		q.addException("subnature","other");	
		q.addException("desktopnature","redownload");
		
		q = new Question("kb",2.5);
		q.extension="jsp";
		q.addException("kbhelped","no");	
		q.addRequirement("edition","online");	
		q.addRequirement("subnature","cantlaunch");	
		
		q = new Question("os",4);
		q.addRequirement("computer","another computer");		

		q = new Question("winos",5);
		q.addRequirement("os","Windows");
				
		q = new Question("macos",5);
		q.addRequirement("os","OS X");
		
		q = new Question("installerran",6);
		q.addRequirement("edition","desktop");
		q.addException("desktopnature","other");
		q.addException("desktopnature","redownload");	
		
		q = new Question("installcomplete",7);
		q.addRequirement("installerran","yes");
		
		
		q = new Question("programran",7.5);
		q.addRequirement("installcomplete","yes");
				
		q = new Question("errors",80);
		q.addRequirement("installcomplete","no",
						 "programran","no");
				
		
				
		q = new Question("dodiagnostic",80);
		q.addRequirement("edition","online");
		q.addRequirement("computer","this computer");
		q.addException("desktopnature","other");	
		
		q = new Question("diagnostic",90);
		q.addRequirement("dodiagnostic","yes");
				
		q = new Question("kb",91);
		q.extension="jsp";
		q.addException("kbhelped","no");	
		q.addRequirement("subnature","liketocancel",
						 "subnature","cantlogin",
						 "desktopnature","redownload",
						 "javaTest","fail");
		
		
						 
		
		q = new Question("finish",0);
		q.addRequirement("kbhelped","yes");
		q.terminal = true;		
							
		q = new Question("moreinfo",100);
		q.addException("start","suggestion");
				
		q = new Question("suggestion",100);
		q.addRequirement("start","suggestion");

		q = new Question("email",101);
		q.terminal = true;
		q.submit = true;
