function genpass_button(id) {
	//document.write('<input type="submit" id="'+id+'_generate" value="Generate" onclick="genpass_randomize(\''+id+'\'); return false">');
	document.write('<button id="'+id+'_generate" type="button" onclick="genpass_randomize(\''+id+'\')" title="Generates a password at random">Generate</button>');

        // grey out button if password box isn't empty
        document.getElementById(id + '_generate').disabled =
        document.getElementById(id).value != '';
}

function genpass_randomize(id) {
	newpass     = '';
	vowels      = new Array('a', 'a', 'a', 'e', 'e', 'e', 'e', 'i', 'i', 'i',
        'o', 'o', 'o', 'u', 'u', 'y', 'ai', 'au', 'ay', 'ea');
	consonants  = new Array('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm',
        'n', 'p', 'qu', 'r', 's', 't', 'v', 'w', 'x', 'z', 'th', 'st');
    
    while(newpass.length < 6) {
        if(Math.floor(Math.random() * 2) == 0) {
            newpass += vowels[Math.floor(Math.random() * vowels.length)];
        } else {
            newpass += consonants[Math.floor(Math.random() * consonants.length)];
        }
    }

	document.getElementById(id).type='text';
	document.getElementById(id).value = newpass;

	return newpass;
}

