public void toJSMatchCode(){
		boolean debugPHP = false;
		int numOfTabs = 0;

			Set<State> states = this.getStates();
			Set<State> acceptStates = this.getAcceptStates();
			printCodeLine(numOfTabs, "<!DOCTYPE html>");
			printCodeLine(numOfTabs, "<html>");
			printCodeLine(numOfTabs, "<head>");
			printCodeLine(numOfTabs, "<meta charset=\"UTF-8\">");
			printCodeLine(numOfTabs, "<title>vlab@ucsb : www.cs.ucsb.edu/~vlab</title>");
			printCodeLine(numOfTabs, "<script>");
//			printCodeLine(numOfTabs, "<?php");
//			numOfTabs++;
			printCodeLine(numOfTabs, "function stranger_match(str){");
			numOfTabs++;
			printCodeLine(numOfTabs, "var i = 0; var state = "+this.initial.id+";");
//			printCodeLine(numOfTabs, "var char_buff = preg_split('//', str, -1);");
			printCodeLine(numOfTabs, "var char_buff = str;");
			printCodeLine(numOfTabs, "while (i < (char_buff.length)){");
			numOfTabs++;
			if (debugPHP)
				printCodeLine(numOfTabs, "echo \"in state  =  \".state.\"         char =  \".char_buff[i].\"<br>\";");
			printCodeLine(numOfTabs, "switch (state){");
			numOfTabs++;
			for (State state : states){
				if (state.accept)
					acceptStates.add(state);
				printCodeLine(numOfTabs, "case "+state.id +":");
				numOfTabs++;
				boolean first = true;
				String ifStmt;
				for (Transition tr: state.transitions){
					if (first){
						first = false;
						ifStmt =  "if ";
					}else{
						ifStmt =  "} else if ";
					}
					printCodeLine(numOfTabs, ifStmt + "(char_buff[i] <= String.fromCharCode("+ ((int)tr.max) +") && char_buff[i] >= String.fromCharCode(" + ((int)tr.min) + ") ){ ");
					numOfTabs++;
					printCodeLine(numOfTabs, "state = " + tr.to.id +";");
					numOfTabs--;
				}
				printCodeLine(numOfTabs, "}");
				printCodeLine(numOfTabs, "i++;");
				printCodeLine(numOfTabs, "break;");
				numOfTabs--;
			}
			// end of switch
			numOfTabs--;
			printCodeLine(numOfTabs, "}");
			if (debugPHP)
				printCodeLine(numOfTabs, "echo \"out state  =  \".state.\"<br>\";");
			// end of while
			numOfTabs--;
			printCodeLine(numOfTabs, "}");
			// building accept states array
			String temp = "var accept = [";
			boolean first = true;
			for (State s: acceptStates){
				if(first)
					first = false;
				else
					temp += ", ";
				temp += s.id;
			}
			printCodeLine(numOfTabs, temp + "];");
			printCodeLine(numOfTabs, "return accept.indexOf(state) > -1;");
			numOfTabs--;
			// end of function
			printCodeLine(numOfTabs, "}");
			StringBuilder result = new StringBuilder();
			
			result.append("function myFunction() {\n");
			result.append("\tvar x=document.getElementById(\"fname\");\n");
			result.append("\tvar r=document.getElementById(\"result\");\n");
			result.append("\tif (!stranger_match(x.value)) {\n");
			result.append("\t\tr.style.color = \"rgb(0,255,0)\";\n");
			result.append("\t\tx.style.color = \"rgb(0,255,0)\";\n");
			result.append("\t\tr.innerHTML = \"&#10004;\";\n");
			result.append("\t} else {\n");
			result.append("\t\tr.style.color = \"rgb(255,0,0)\";\n");
			result.append("\t\tx.style.color = \"rgb(255,0,0)\";\n");
			result.append("\t\tr.innerHTML = \"&#10008;\";\n");
			result.append("\t}\n");
			result.append("\t\n}\n");
			result.append("\twindow.onload = myFunction;\n");
			result.append("</script>\n</head>\n<body>\n");
			result.append("Enter your string: <input type=\"text\" id=\"fname\" oninput=\"myFunction()\">&nbsp; <span id=\"result\" style=\"color:red\"></span>\n");
			result.append("<p>As you type the characters, a function is triggered which validates input string.</p>\n");
			result.append("</body>\n</html>");
			
			printCodeLine(numOfTabs, result.toString());
//			numOfTabs--;
//			printCodeLine(numOfTabs, "?>");		
	}