function init_event() {
    $('draw').addEventListener('click', function() {
        text2canvas();
    }, false);
}

function text2canvas() {
    var txt = $('txt').value;
    if(txt == "") return;

    var canvas = $('cnvs');
        canvas.width = 300;
        canvas.height = 100;
    var ctx = canvas.getContext('2d');
        ctx.clearRect(0, 0, 300, 100);
        ctx.translate(10, 50);
        ctx.fillStyle = "Red";
        ctx.mozTextStyle = "30pt sans-serf";
        ctx.mozDrawText(txt);
}


function $(id) {
    return $[id] || ($[id] = document.getElementById(id));
}

window.addEventListener('load', function() {
    init_event();
}, false);

