function cdv(T) {var M=0,S=1;for(;T;T=Math.floor(T/10))
S=(S+T%10*(9-M++%6))%11;return S?S-1:'K';}

function valid_run_chars(e)
{
	var unicode = e.charCode? e.charCode : e.keyCode;

	if (unicode == 8 ||         // backspace
			unicode == 9 ||     // tab
			unicode == 13 ||    // enter
			unicode == 39 ||    // arrow-right
			unicode == 37)      // arrow-left
		return true;

	if (unicode == 45 ||        // '-'
			unicode == 46)      // '.'
		return true;

	if (unicode >= 48 && unicode <= 57) // '0 - 9'
		return true;

	if (unicode == 107 || unicode == 75) // 'k' 'K'
		return true;

	//alert(unicode);
	return false;
}

function valid_serie_chars(e)
{
        var unicode = e.charCode? e.charCode : e.keyCode;

        if (unicode == 8 ||     // backspace
                        unicode == 9 ||     // tab
                        //unicode == 13 ||    // enter
                        unicode == 39 ||    // arrow-right
                        unicode == 37)      // arrow-left
                return true;

        if (unicode >= 48 && unicode <= 57) // '0 - 9'
                return true;

        if (unicode == 65 || unicode == 97) // 'A, a'
                return true;

/*
		if (unicode >= 97 && unicode <= 122) // 'a - z'
			return true;

		if (unicode >= 65 && unicode <= 90) // 'A - Z'
			return true;
*/

        return false;
}

function check_run(run)
{
	if (run == "")
		return false;

	var run_ = run.replace(/\./g,"");
	var rundv = new Array();
	rundv = run_.split('-');

	if (rundv.length != 2)
		return false;

	if (rundv[1] == 'k')
		rundv[1] = 'K';

	if (cdv(parseInt(rundv[0])) != rundv[1])
		return false;
	else
		return true;
}

