$(function()
	{

    var accept = [
	['1'], 
	['2'], 
	['3'], 
	['4'], 
	['3'],
	['13'],
	['13'],
    ];


    function countFilled() {
        var count = 0;
        for (var i = 1; i <= 7; i++) {
            var str = $("#i" + i + '>input').val().toLowerCase().trim();
            if (str !== '') {
                count++;
            }
        }
        return count;
    }
	function countLetters(){
        var count = 0;
        for (var i = 1; i <= 7; i++) {
            var str = $("#i" + i + '>input').val().length;            
            if (str < 1) {
                count++;
            }
        }
        return count;
	}
    function checkAll(mark) {
        var err = 0;
        for (var i = 1; i <= 7; i++) {
			
            var str = $("#i" + i + '>input').val().toLowerCase().trim();
	    
            if (accept[i-1].indexOf(str) < 0) {
                err++;
            }
        }
        return err;
    }
    $("input").each(function () {
        var readOnly = this.readOnly
        if (!readOnly)
            $(this).val('');
    });

    $(".letterinput").keyup(function () {
        if (countFilled() === 7 && countLetters() === 0) {
            if (checkAll(false) !== 0) {
                checkAll(true);
                $('#jplayer_wrong').jPlayer('play');
                
            } else {
                
                $('#jplayer_well').jPlayer('play');
              }
        }
    });
    
    
    
});
