
function focusOnCode() {
    document.tester.code.focus();
}

function submitOnTab(keyevent) {
    // this should be set as attribute onkeypress for the code field
    // keycode 9 is tab, keycode 13 is enter
    if (keyevent && keyevent.keyCode == 9) {
	document.tester.submit();
    } else {
	return true;
    }
}

function showfull(name) {
    document.tester.code.value = "displayas full;\nshow get "+name+";\n";
    document.tester.submit();
}

function search(stat,value) {
    document.tester.code.value = "show search "+stat+",'"+value+"';";
    document.tester.submit();
}


// Define constants.  Some of these are filled in initHandler() only 
// after we know which form is the character form. 
sample = new Array();

sample[1] = "# get Pokemon number 144\nget 144";
sample[2] = "# get Pokemon named Eevee\nget eevee";
sample[3] = "# find Pokemon with 'chu' in their name\nsearch name,chu";
sample[4] = "# find electrics with 'chu' in their name\nsearch name,chu,types,electric";
sample[5] = "# show image, name, & speed\ndisplayas image,name,speed;\nshow search name,chu";
sample[6] = "# show image, name, & speed\ndisplayas image,name,speed;\n# show in order of speed\nsortby speed;\nshow search type,bug,type,poison;\n";
sample[7] = "# show as image, name & type\ndisplayas image,name,types;\nshow search type,dragon\n";
sample[8] = "# show name & attack\ndisplayas name,attack;\nsortby attack;\nshow all\n";
sample[9] = "# show who evolves into many forms\nfor $m (all) {\n$n = count $m->evolvesinto;\nshow $m,$n if ($n > 1);\n}\n";
sample[10] = "# show type combos & how many of each\nfor $m (all) {\n    $t{$m->types}++;\n}\nfor $x (keys %t) {\n    show $x,$t{$x};\n}\n";

function usesample(i) {
    // This should be inserted into a link by 
    // <a href="" onClick="usesample(2)"> 2 </a>
    document.tester.code.value = sample[i];
    document.tester.submit();
}
