<h6 class="text-center text-uppercase">ALAT TOGEL KONVERSI TOTO SGP</h6>
    <hr class="w-75 d-block mx-auto">

	<script type="text/javascript">
function hapus(){
    var fom = document.fom;
    result.style.display="none";
    eval("fom.s1").value="";
    eval("fom.s2").value="";
    eval("fom.s3").value="";
    eval("fom.s4").value="";
    eval("fom.s5").value="";
    eval("fom.s6").value="";
    eval("fom.s7").value="";
    eval("fom.s1").focus();
}
function convert(){
    var fom = document.fom;
    var s1 = eval("fom.s1");
    var s2 = eval("fom.s2");
    var s3 = eval("fom.s3");
    var s4 = eval("fom.s4");
    var s5 = eval("fom.s5");
    var s6 = eval("fom.s6");
    var s7 = eval("fom.s7");
    if ((!s1.value) || (!s2.value) || (!s3.value) || (!s4.value) || (!s5.value) || (!s6.value) || (!s7.value)){
        alert("Harus diisi dengan angka, tidak boleh kosong");
        s1.focus();
        return;
    }
    result.style.display="block";
    var myarray=[s1.value, s2.value, s3.value, s4.value, s5.value, s6.value]
    myarray.sort(function(a,b){return a - b});  
    no7 = s7.value;
    no1 = myarray[0];
    no2 = myarray[1];
    no3 = myarray[2];
    no4 = myarray[3];
    no5 = myarray[4];
    no6 =   myarray[5];
    var c = parseInt(myarray[0])+parseInt(myarray[1])+parseInt(myarray[2])+parseInt(myarray[3])+parseInt(myarray[4])+parseInt(myarray[5]);
    c = parseInt(c) * 2;
    c = parseInt(c) - parseInt(myarray[0]) - parseInt(myarray[5]);
    c = parseInt(c) + Number(s7.value);
    c = ""+c;
    if (c.length > 2){
        c = c.substr(1,2);
    }
    var d = c.substr(1);
    c = c.substr(0,1);
    var b = parseInt(myarray[3]) + parseInt(myarray[4]);
    b = ""+b;
    if (b.length > 2){
        b = b.substr(2,1);
    }else {
        b = b.substr(1);
    }
    var a = parseInt(myarray[1]) + parseInt(myarray[2]);
    a = ""+a;
    if (a.length >= 2){
        a = a.substr(1);
    }
    document.getElementById("result").innerHTML = a+""+b+""+c+""+d;
}
_dom = 0;
_dom=document.all?3:(document.getElementById?1:(document.layers?2:0));
</script>

<div class="row d-flex justify-content-center mb-3">
    <div class="col-xl-6 col-12">

	<form class="form-sgptoto rounded" name="fom">
	<div class="d-block mx-auto">
			<h3 class="fw-bold text-light">KONVERSI SGP TOTO</h3>
		</div>
    <table class="tbl-biru">
        <thead>
            <tr>
                <th class="text-light" colspan="6">Winning Numbers</th>
                <th class="text-light">-</th>
                <th class="text-light">Add</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td class="text-center"><input type="text" id="s1" class="form-control text-center bold" width="10%" maxlength="2" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"/></td>
                <td class="text-center"><input type="text" id="s2" class="form-control text-center bold" width="10%" maxlength="2" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"/></td>
                <td class="text-center"><input type="text" id="s3" class="form-control text-center bold" width="10%" maxlength="2" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"/></td>
                <td class="text-center"><input type="text" id="s4" class="form-control text-center bold" width="10%" maxlength="2" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"/></td>
                <td class="text-center"><input type="text" id="s5" class="form-control text-center bold" width="10%" maxlength="2" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"/></td>
                <td class="text-center"><input type="text" id="s6" class="form-control text-center bold" width="10%" maxlength="2" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"/></td>
                <td class="text-center">+</td>
                <td class="text-center"><input type="text" id="s7" class="form-control text-center bold" width="10%" maxlength="2" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');"/></td>
            </tr>
            <tr>
                <td colspan="8" class="text-center">
					<div class="my-2">
                    <button type="button" class="btn btn-success" onclick="convert();">Convert</button> <button type="button" class="btn btn-danger" onclick="hapus();">Hapus</button>
					</div>
                </td>
            </tr>
        <tbody>
            <tr>
                <td colspan="8" class="text-center">
					<h1 class="text-light">Hasil:</h1>
					<div class="bg-warning rounded bg-gradient">
					<h1 id="result" class="bold text-dark">XXXX</h1>
					</div>
				</td>
            </tr>
        </tbody>
    </table>
</form>



    <!-- <form class="form-sgptoto rounded">
		<div class="d-block mx-auto">
			<h3 class="fw-bold text-light">KONVERSI SGP TOTO</h3>
		</div>
		<label class="text-uppercase text-light">Winning Numbers</label>

        <table class="table text-center table-sm">
            <tbody>
                <tr>
                    <td><input class="input-konv" type="text" name="nomor_1" maxlength="2"></td>
                    <td><input class="input-konv" type="text" name="nomor_2" maxlength="2"></td>
                    <td><input class="input-konv" type="text" name="nomor_3" maxlength="2"></td>
                    <td><input class="input-konv" type="text" name="nomor_4" maxlength="2"></td>
                    <td><input class="input-konv" type="text" name="nomor_5" maxlength="2"></td>
                    <td><input class="input-konv" type="text" name="nomor_6" maxlength="2"></td>
                    <td><h6 class="fw-bold text-light tototd">+</h6></td>
                    <td><input class="input-konv" type="text" name="nomor_tambah" maxlength="2"></td>
                </tr>
            </tbody>
        </table>

		<h6 class="text-center text-light p-0 m-0 fw-bold">HASIL ANGKA :</h6>

		<div class="bg-warning rounded bg-gradient">
            <p><span class="p-1 bg-1 text-dark hasil">XXXX</span></p>
         </div>
        
            <div>
                <input id="hapustoto" class="btn btn-danger" type="reset" value="HAPUS">
            </div>
		</form> -->
    </div>
</div>


<div class="my-3">
<?php echo ftab("konversitoto", "change_text", "konversitoto"); ?>
</div>

<script type="text/javascript">

	$("input").on('keyup', function(){
		let length_1 = $('[name=nomor_1]').val().length;
		let length_2 = $('[name=nomor_2]').val().length;
		let length_3 = $('[name=nomor_3]').val().length;
		let length_4 = $('[name=nomor_4]').val().length;
		let length_5 = $('[name=nomor_5]').val().length;
		let length_6 = $('[name=nomor_6]').val().length;
		if (length_1 == 2){
			$('[name=nomor_2]').focus();
		}
		if (length_2 == 2){
			$('[name=nomor_3]').focus();
		}
		if (length_3 == 2){
			$('[name=nomor_4]').focus();
		}
		if (length_4 == 2){
			$('[name=nomor_5]').focus();
		}
		if (length_5 == 2){
			$('[name=nomor_6]').focus();
		}
		if (length_6 == 2){
			$('[name=nomor_tambah]').focus();
		}
		let nomor_1 = parseInt($('[name=nomor_1]').val());
		let nomor_2 = parseInt($('[name=nomor_2]').val());
		let nomor_3 = parseInt($('[name=nomor_3]').val());
		let nomor_4 = parseInt($('[name=nomor_4]').val());
		let nomor_5 = parseInt($('[name=nomor_5]').val());
		let nomor_6 = parseInt($('[name=nomor_6]').val());
		let nomor_tambah = parseInt($('[name=nomor_tambah]').val());
		let puluh = ((((nomor_1+nomor_2+nomor_3+nomor_4+nomor_5+nomor_6)*2)-nomor_1)-nomor_6)+nomor_tambah;
		puluh = puluh.toString();
		let total_puluh = puluh.substr(-2);

		let ratus = nomor_4 + nomor_5;
		ratus = ratus.toString();
		let total_ratus = ratus.substr(-1);

		let ribu = nomor_2 + nomor_3;
		ribu = ribu.toString();
		let total_ribu = ribu.substr(-1);

		let total = parseInt(total_ribu+total_ratus+total_puluh);

		$('.hasil').html(total);

	});

	$("#hapustoto").click(function () {
        $(".hasil").fadeOut(function () {
            $(".hasil").text('XXXX').fadeIn();
        })
    })

</script>