/*
 * Smarthome - Ajax Scripting
 * Copyright Smarthome
 */

$(document).ready(function() {

  //--------------------------------- Sub Fungsi-fungsi penting --------------------------------------------
	//fungsi tab
	$("#wrap > ul").tabs();
	//---- Table daftar tarif
    $("#table_a").mastertable({
        urlGet:"application/mes/daftar/daftar.php",
        flook:"nama"
    },
    function(hal,juml,json) {
        var isi="";
        for(i = 0; i < json['alldata'].length; i++) {
            var n = i + 1;
			rc = (n%2 == 0) ? "0" : "1";
            var alamat = json['alldata'][i].alamat +" "+ json['alldata'][i].rt_rw +" "+ json['alldata'][i].kel +" "+ json['alldata'][i].kec +" "+ json['alldata'][i].kab +" "+ json['alldata'][i].prop ;
            isi += "<tr class=\"row"+rc+"\">"
                + "<td style=\"padding-left: 2px\" align='center'>" + (((hal - 1) * juml ) + n) + "</td>"
                + "</tr>";
		}
		return isi;
    },
    function domIsi() {
        // detail 
        $('.hidedata').click( function() {
        	//$("#table_a").show();
        	//$("#datadiv").hide();
        	
        });
    });
	//---- Reset Table
    $(".reset").click();
    //-------- Thickbox JS ---------------//
    

    //---- Fungsi AJAX ----//
	function ajak(urlnya,datanya) {
  	var resp = $.ajax({type: "POST",
                       url: urlnya,
                       beforeSend: function(){$("#loading_box").show("fast");}, 
					   complete: function(){ $("#loading_box").hide("slow");},  
                       async : false,
                       data: datanya
                      }).responseText;
    return resp;
  	}

    //---- Pesan Pada Thickbox ----//
	function showinfo(info) {
		$(".infonya").html("<img src=\"assets/images/warning_kecil.png\" />&nbsp;<span style=\"font-weight: bold;color: red\">" + info + "</span>");
		$(".infonya").show();
		setTimeout('$(".infonya").fadeOut("slow")', 2500);
	}
    
    //number format input
     function numbersonly(e) {
	    if ((e.which>47 && e.which<58)||(e.which>95 && e.which<106)|| e.which==8|| e.which==9|| e.which==13|| e.which==39|| e.which==37) {
	        return true;
	    } else {
	        return false;
	    }
	}
    //----------------------------------- End sub pemakaian obat & alkes -----------------------------------//
});//------------------------------------------- end Document Ready -----------------------------------//

