<?php
$height = 0;
$jum = count($this->data->form);
foreach($this->data->form as $no => $row){
	if($height < $row['row']){
		$height = $row['row'];
	}
	$no++;
	if($no == $jum){
		if($row['input']['type'] == 'textarea'){
			$tambah = 100;
		}else{
			$tambah = 50;
		}
	}
}
$height = $height + $tambah;

$func = $this->basePath.'app/'.$this->modul.'/func.php';
require_once($func);
?>

<style>
#_closePopUp:focus{
	background-color: yellow;
}
#_rasioForm{
	border: 1px solid #cfcfcf;	
	-webkit-border-radius: 0px 0px 8px 8px; 
	-moz-border-radius: 0px 0px 8px 8px; 
	-khtml-border-radius: 0px 0px 8px 8px; 
	border-radius: 0px 0px 8px 8px;
	padding: 10px;
	height: <?php echo $height ?>px;
}
#_rasioForm #background{
	position: absolute;
}
#_rasioForm ._input{
	position: absolute;
}
#_rasioForm ._input input:focus{
	background-color: yellow;
}
#_rasioForm ._input ._label{
	font-size: 12px;
	float: left;
}
.tombol0{
	-webkit-border-radius: 8px 0px 0px 8px; 
	-moz-border-radius: 8px 0px 0px 8px; 
	-khtml-border-radius: 8px 0px 0px 8px; 
	border-radius: 5px 0px 0px 0px;
}
.rasioDet{
    border: 1px solid #cfcfcf;
    border-radius: 0px 0px 8px 8px;
    padding: 5px;
	margin-top: 5px;
	margin-bottom: 5px;
}
.tabButton2 {
    border: 1px solid #cfcfcf;
    border-radius: 8px 8px 0px 0px;
    margin-bottom: 5px;
    padding: 5px;
    text-align: left;
}
</style>

<div id="apankFormSelect" class="_popUpDef"></div>
<div id="apankFormFilter" class="_popUpDef"></div>
<div id="apankFormConfirm" class="_popUpDef"></div>
<form id="formAjaxDefault" action="#" method="post">
	<input type="hidden" name="_prosesAction" id="_prosesAction">
	<div id="apankFormDefDisplay" class="_popUpDef"></div>
	<div class="tabButton2">
		<?php
		$loadPrint 	= false;
		$loadView 	= false;
		$loadExcel 	= false;
		$loadPdf 	= false;
		
		foreach($this->data->button as $key => $row):
			if(strtoupper($row) == strtoupper('print')){
				$loadPrint = true;
			}
			if(strtoupper($row) == strtoupper('view')){
				$loadView = true;
			}
			if(strtoupper($row) == strtoupper('excel')){
				$loadExcel = true;
			}
			if(strtoupper($row) == strtoupper('pdf')){
				$loadPdf = true;
			}
		?>
			<input type="button" id="<?php echo $this->getParameter['controller'].$row ?>" name="<?php echo $row ?>" class="submit submitApankForm button<?php echo $row ?> tombol<?php echo $key ?>" value="<?php echo $row ?>">
		<?php endforeach; ?>
	</div>
	<div id="_rasioForm">
		<div id="background"><?php echo $this->data->background ?></div>
		<?php
		$no = 0;
		$select = array();
		foreach($this->data->form as $kNo => $row):
		?>
		<div class="_input" style="margin-left: <?php echo $row['col'] ?>px; margin-top: <?php echo $row['row'] ?>px">
			<?php 
			if(!empty($row['label']) and $row['label'] != false){ 
				$width = 100;
				if(!empty($row['label']['width'])){
					$width = $row['label']['width'];
				}
			?>
				<div class="_label" style="width: <?php echo $width ?>px">
					<?php echo $row['label']['name'] ?>
				</div>
			<?php } ?>
			<?php 
			if(!empty($row['input'])){ 
				$input = $row['input'];
				$jenis = $input['type'];
				if(!empty($input['attr']['select'])){
					$select[] = $input['attr']['select'];
				}
			?>
				<div style="float: left">
					<?php 
					echo $this->form->$jenis($jenis, $input['attr'], $input['attr']['name'], $no, $row['label']['name']);
					$no++;
					?>
				</div>
			<?php } ?>
		</div>
		<?php 
		endforeach;
		?>
	</div>
	
	<?php 
	$sel = new Select;
	foreach($select as $row){ 
		$row = strtoupper($row);
		$dataSel = $sel->$row();
		$dataSel = $sel->serialize($dataSel);
	?>
		<input type="hidden" id="select<?php echo $row ?>" value="<?php echo $dataSel ?>">
	<?php } ?>
	
	<?php if(!empty($this->data->detail)){ ?>
		<div id="<?php echo $this->getParameter['controller'].'Detail' ?>" class="rasioDet"></div>
	<?php } ?>
</form>
<div id="errorDisplay"><div>
<script type="text/javascript">
$(document).ready(function(){
	var _notNull = [];
	<?php 
	if(!empty($this->data->notNull)){
		foreach($this->data->notNull as $key => $row){ 
	?>
		_notNull[<?php echo $key ?>] = '<?php echo $row ?>';
		$('#<?php echo $row ?>').attr("notNull", true);
	<?php 
		}
	} 
	?>
	makeConfirm = function(){
		_button = "<div style='text-align: center'>";
		_button+= "<input id='<?php echo $this->getParameter['controller'] ?>ClosePopUp' type='text' class='textConfirm _buttonConfirm1' nom='1' readonly value='Tutup'>";
		_button+= "<input id='<?php echo $this->getParameter['controller'] ?>LoadPopUp' type='text' class='textConfirm _buttonConfirm2' nom='2' readonly value='Tampil'>";
		_button+= "</div>";
		
		makePopUpDefaultDisplay(300, 200, _button, "apankFormConfirm", 'confirm');
	}
	makeConfirm();
	$('.textConfirm').keyup(function(e){
		if(e.which === 37 || e.which === 39){
			_nom = $(this).attr("nom");
			_nom = parseInt(_nom);
			if(e.which == 37){
				_nom = _nom - 1;
			}
			if(e.which == 39){
				_nom = _nom + 1;
			}
			$("._buttonConfirm"+_nom).focus();
		}
		if(e.which === 13){
			$("#apankFormConfirm").css("display", "none");
			$('.urut_'+_focus).focus();
		}
	})
	$("#apankFormConfirm").css("display", "none");
	
	$('#apankFormCloseButton').live('click', (function(){
		$("._popUpDef").css("display", "none");
	}))
	$('.textFilter, #_tampilPrinter').live('keyup', (function(e){
		if(e.which === 27){
			$("#apankFormFilter").css("display", "none");
		}
	}))
	makeFilter = function(){
		_button = "<div style='text-align: center'>";
		_button+= "<table>";
		<?php 
		if($this->data->cetak != false){
			foreach($this->data->cetak->attr as $no => $row){ 
				if($row['filter'] == true){
					$size = 20;
					if(!empty($row['filter']['size'])){
						$size = $row['filter']['size'];
					}
		?>
			_button+= "<tr>";
			_button+= "<td width='100px'><?php echo $row['label'] ?></td>";
			_button+= "<td><input type='text' size='<?php echo $size ?>' id='filPrint<?php echo str_ireplace(".", "", $row['attr']) ?>' class='textFilter filter_<?php echo $no?> <?php echo $row['class'] ?>' no='<?php echo $no ?>'></td>";
			_button+= "</tr>";
		<?php 
				}
			}
		} 
		?>
		_button+= "<tr>";
		_button+= "<td width='100px'></td>";
		_button+= "<td><input type='button' id='_tampilPrinter' class='textFilter filter_<?php echo ($no) ?>' no='<?php echo ($no) ?>' value='Tampil'></td>";
		_button+= "</tr>";
		_button+= "</table>";
		_button+= "</div>";
		makePopUpDefaultDisplay(500, 100, _button, "apankFormFilter", 'filter');
	}
	$("#apankFormFilter").css("display", "none");
	makeFilter();
	$('.textFilter').keyup(function(e){
		_no = parseInt($(this).attr('no'));
		if(e.which === 40 || e.which === 13){
			_no = _no + 1;
		}
		if(e.which === 38){
			_no = _no - 1;
		}
		$('.filter_'+_no).focus();
		
		if(e.which === 27){
			$("#apankFormFilter").css("display", "none");
		}
	})
	
	makeDisplay = function(){
		_kode = "<?php echo $this->baseUrl.$this->getParameter['asliGetCotroller'] ?>/cetak/";
		<?php 
		if($this->data->cetak != false){
			foreach($this->data->cetak->attr as $no => $row){ 
				if($row['filter'] == true){
					$key = 'filPrint'.str_ireplace(".", "", $row['attr']);
		?>
			_kode+= '&<?php echo $key ?>='+str_ireplace("%", "||", str_ireplace("+", "___", $('#<?php echo $key ?>').val()));
		<?php 
				}
			} 
		}
		?>
		window.open(_kode);
	}
	$('#_tampilPrinter').click(function(){
		makeDisplay();
		$("#apankFormFilter").css("display", "none");
	})
	$('#_tampilPrinter').keyup(function(e){
		if(e.which === 13){
			makeDisplay();
			$("#apankFormFilter").css("display", "none");
		}
	})
	
	makeButton = function(){
		_button = "<div style='text-align: center'>";
		_button+= "<div style='text-align: center; margin-top: -10px; margin-bottom: 10px' id='_displayErrorPopUp'></div>";
		_button+= "<input id='<?php echo $this->getParameter['controller'] ?>EditButton' type='text' class='inputButton textButtonNew _buttonNewNom1' nom='1' readonly value='Edit'>";
		_button+= "<input id='<?php echo $this->getParameter['controller'] ?>prosesButton' type='submit' class='textButtonNew submitApankForm _buttonNewNom2' nom='2' value='Ok'>";
		_button+= "<input id='<?php echo $this->getParameter['controller'] ?>CancelButton' type='text' class='inputButton textButtonNew _buttonNewNom3' nom='3' readonly value='Cancel'>";
		_button+= "</div>";
		
		makePopUpDefaultDisplay(300, 200, _button, "apankFormDefDisplay", "button");
	}
	makeButton();
	$("#apankFormDefDisplay").css("display", "none");
	$(".textButtonNew").live("keyup", (function(e){
		if(e.which === 37 || e.which === 39){
			_nom = $(this).attr("nom");
			_nom = parseInt(_nom);
			if(e.which == 37){
				_nom = _nom - 1;
			}
			if(e.which == 39){
				_nom = _nom + 1;
			}
			$("._buttonNewNom"+_nom).focus();
		}
	}))
	$("#<?php echo $this->getParameter['controller'] ?>EditButton").live("keyup", (function(e){
		if(e.which === 13){
			makeEditNewForm();
		}
	}))
	$("#<?php echo $this->getParameter['controller'] ?>EditButton").live("click", (function(){
		makeEditNewForm();
	}))
	makeEditNewForm = function(){
		$("#apankFormDefDisplay").css("display", "none");
		$(".urut_"+_focus).focus();
	}
	$("#<?php echo $this->getParameter['controller'] ?>CancelButton").live("keyup", (function(e){
		if(e.which === 13){
			makeCancelNewForm();
		}
	}))
	$("#<?php echo $this->getParameter['controller'] ?>CancelButton").live("click", (function(){
		makeCancelNewForm();
	}))
	makeCancelNewForm = function(){
		$(".text, .select, .textarea, .checkbox").attr("disabled", "true");
		$("#apankFormDefDisplay").css("display", "none");
		makeLoadData("First");
	}
	
	
	$("#formAjaxDefault").postForm(
		{
			act: true,
			submitUrl: [
							["<?php echo $this->getParameter['controller'] ?>prosesButton", "errorDisplay", "<?php echo $this->baseUrl.$this->getParameter['asliGetCotroller'] ?>/proses/"],
						],
		}
	);
	
	
	
	$('#formAjaxDefault').submit(function(e){
		e.preventDefault();
	})

	
	$('#<?php echo $this->getParameter['controller'] ?>Prev').attr("urut", 0);
	$('#<?php echo $this->getParameter['controller'] ?>Next').attr("urut", 1);
	
	<?php if($this->data->add != true){ ?>
		$('.text, .textarea').attr('disabled', true);
	<?php } ?>
	$('.text').attr("autocomplete", 'off');
	var _jumI = "<?php echo $jum ?>";
	var _focus = 0;
	cekReadDis = function(_cls){
		_red = $(_cls).attr('readonly');
		_dis = $(_cls).attr('disabled');
		if(_red !== 'readonly' & _dis !== 'disabled'){
			return false;
		}
		return true;
	}
	makeFocusTrue = function(_cls, _no){
		$(_cls).focus();
		_focus = _no;
		return;
	}
	makeFocus = function(){
		for(_i = 0; _i < _jumI; _i++){
			_cls = ".urut_"+_i;
			_cek = cekReadDis(_cls);
			if(_cek === false){
				makeFocusTrue(_cls, _i);
				return;
			}
		}
	}
	makeFocus();
	
	makeDef = function(){
		$(".text, .select, .textarea, .checkbox, .radio").attr("disabled", true);
		$('#<?php echo $this->getParameter['controller'] ?>First').focus();
		makeLoadData("First");
	}
	
	makeFocusUrut = function(_no, _mode, _lastNo, _jumlh){
		if(_mode  === 27){
			$("#apankFormDefDisplay").removeAttr("style");
			function showDiv() {
				$('._buttonNewNom1').focus();
				clearInterval(timer);
			}
			var timer = setInterval( showDiv, 100);
		}
	
		if(_jumlh <= 50){
			if(_mode === 13 || _mode === 38 || _mode === 40){
				_after = undefined;
				if(_mode === 13 || _mode === 40){
					_after = $('.urut_'+_lastNo).attr("after");
					_no = _no + 1;
				}
				if(_mode === 38){
					_no = _no - 1;
				}
				_cls = ".urut_"+_no;
				_before = $(_cls).attr("before");
				if(_before === undefined){
					_foc = true;
				}else{
					_foc = makeFunction(_before, _lastNo, false);
				}
				if(_foc === true){
					
					if(_after === undefined){
						_cekAfter = true;
					}else{
						_cekAfter = makeFunction(_after, _lastNo, false);
						if(_cekAfter !== false){
							// _display = $('.urut_'+_lastNo).attr("display");
							// if(_display !== undefined){
								// makeFunction(_display, _lastNo, _cekAfter);
							// }
						}
					}

					if(_cekAfter !== false){
						_cekKode = $('.urut_'+_no).attr("name");
						if(_cekKode === undefined){
							if(_mode === 13 || _mode === 40){
								$("#apankFormDefDisplay").removeAttr("style");
								function showDiv() {
									$('._buttonNewNom1').focus();
									clearInterval(timer);
								}
								var timer = setInterval( showDiv, 100);
							}
						}else{
							if(_mode === 13 || _mode === 40){
								_nomm = _no - 1;
							}else{
								_nomm = _no;
							}
							_idNm = $('.urut_'+_nomm).attr('id');
							_next = true;
							for(_iN = 0; _iN < _notNull.length; _iN++){
								_jj = _notNull[_iN];
								if(_jj === _idNm){
									_vVal = $('#'+_idNm).val();
									if(_vVal === ''){
										_next = false;
									}
								}
							}
							// if(_mode === 38){
								// alert(_next+' => '+_idNm);
							// }
							if(_next === true){
								_cek = cekReadDis(_cls);
								if(_cek === false){
									makeFocusTrue(_cls, _no);
								}else{
									makeFocusUrut(_no, _mode, _lastNo, _jumlh + 1);
								}
							}
						}
					}
				}
				return;
			}else{
				makeFocusUrut(_no, _mode, _lastNo, _jumlh + 1);
			}
		}
	}
	_mode = false;
	functEnter = function(){
		$('.text, .textarea').keyup(function(e){
			_mode = 'enter';
			if(e.which === 27 || e.which === 13 || e.which === 38 || e.which === 40){
				_no = parseInt($(this).attr('no'));
				makeFocusUrut(_no, e.which, _no, 0);
			}
			_tgl = false;
			_cls = $(this).attr("class");
			_cls = _cls.split(" ");
			for(_i = 0; _i < _cls.length; _i++){
				_md = _cls[_i];
				if(_md === 'tanggal'){
					_tgl = true;
				}
			}
			if(_tgl === false){
				$('#ui-datepicker-div').empty();
			}
		})
	}
	functEnter();
	
	cekNull = function(_idNm){
		for(_iN = 0; _iN < _notNull.length; _iN++){
			_jj = _notNull[_iN];
			if(_jj === _idNm){
				_vVal = $('#'+_idNm).val();
				if(_vVal === ''){
					return false;
				}
			}
		}
		return true;
	}
	functClick = function(){
		$('.text, .textarea').click(function(){
			_mode = 'click';
			_key 	= $('.urut_'+_focus).attr('id');
			_after 	= $('#'+_key).attr("after");
			
			_res = true;
			if(_after !== undefined){
				_no 	= $('#'+_key).attr("no");
				_display= $('#'+_key).attr("display");
				_res = makeFunction(_after, _no, _display);
			}
			if(_res === true){
				_res = cekNull(_key);
				if(_res === true){
					_before = $(this).attr("before");
					_no 	= $(this).attr("no");
					_display= $(this).attr("display");
					if(_before !== undefined){
						_res = makeFunction(_before, _no, _display);
					}
				}
			}

			if(_res === true){
				_cls = '#'+this.id;
				_no = $(this).attr('no');
				makeFocusTrue(_cls, _no);
			}else{
				$('.urut_'+_focus).focus();
			}
		})
	}
	functClick();
	
	makeTimeFocus = function(){
		function showDiv() {
			$('.urut_'+_focus).focus();
			clearInterval(timer);
		}
		
		var timer = setInterval( showDiv, 300);
	}
	$('#_closePopUp').live('keypress', (function(e){
		makeTimeFocus();
	}))
	$('#_closePopUp, #apankFormCloseButton').live('click', (function(e){
		makeTimeFocus();
	}))
	makeNextFocusTrue = function(_no, _jum){
		if(_jum < 100){
			_no = parseInt(_no) + 1;
			_cls = '.urut_'+_no;
			_cek = cekReadDis(_cls);
			if(_cek === false){
				makeFocusTrue(_cls, _no);
			}else{
				makeNextFocusTrue(_no, _jum+1);
			}
		}
	}
	makeKiriKanan = function(_no, _jen){
		_no = parseInt(_no);
		if(_jen === 'min'){
			_no = _no - 1;
		}else{
			_no = _no + 1;
		}
		$('._urut_'+_no).focus();
	}
	makeAtasBawah = function(_no, _jen){
		_no = parseInt(_no);
		if(_jen === 'min'){
			_no = _no - 1;
		}else{
			_no = _no + 1;
		}
		if(_no === 0){
			$('._urut_0').focus();
		}else{
			$('._noGrid_'+_no).focus();
		}
	}
	$('._linkPopUp').live('keyup', (function(e){
		if(e.which === 37){
			makeKiriKanan($(this).attr('urut'), 'min');
		}
		if(e.which === 39){
			makeKiriKanan($(this).attr('urut'), 'plus');
		}
		if(e.which === 38){
			makeAtasBawah($(this).attr('nomor'), 'min');
		}
		if(e.which === 40){
			makeAtasBawah($(this).attr('nomor'), 'plus');
		}
		if(e.which === 27){
			$('#apankForm').empty();
		}
	}))
	
	
	var _loader = false;
	var _urut = 0;
	makeLoadData = function(_type){
		<?php if($loadDataNavigator == true){ ?>
			_type = _type.toLowerCase();
			$("#kodegrup").val("Load...");
			
			if(_loader !== false){
				_loader.abort();
			}
			
			_loader = $.ajax({
			type: "GET",
				url: "<?php echo $this->baseUrl.$this->getParameter['asliGetCotroller'] ?>/Find/&no="+_urut+"&jenis="+_type,
				data: $(this).serialize(),
				success: function(data) {
					$("#errorDisplay").html(data);
				}
			})	
		<?php } ?>
	}
	
	makeLoadData('First');

	makeAdd = function(){
		<?php if($loadAdd == true){ ?>
			<?php if($this->data->addClear == false){ ?>
				$(".text, .select, .textarea").removeAttr("disabled");
				$(".checkbox").removeAttr("disabled");
				makeFocus();
			<?php }else{ ?>
				$(".text, .select, .textarea").val("").removeAttr("disabled");
				$(".checkbox").removeAttr("checked").removeAttr("disabled");
				makeFocus();
			<?php } ?>
			$("#_prosesAction").val("simpan");
		<?php } ?>
	}
	
	makeEdit = function(){
		<?php if($loadEdit == true){ ?>
			$(".text, .select, .textarea").removeAttr("disabled");
			$(".checkbox").removeAttr("disabled");
			makeFocus();
			$("#_prosesAction").val("update");
		<?php } ?>
	}
	
	$.Shortcuts.add({
		type: "down",
		mask: "F",
		handler: function() {
			_urut = 0;
			makeLoadData("First");
		}
	}).start();
	$.Shortcuts.add({
		type: "down",
		mask: "L",
		handler: function() {
			_urut = 0;
			makeLoadData("Last");
		}
	}).start();
	$.Shortcuts.add({
		type: "down",
		mask: "N",
		handler: function() {
			_urut = $('#<?php echo $this->getParameter['controller'] ?>Next').attr("urut");
			makeLoadData("Next");
		}
	}).start();
	$.Shortcuts.add({
		type: "down",
		mask: "P",
		handler: function() {
			_urut = $('#<?php echo $this->getParameter['controller'] ?>Prev').attr("urut");
			makeLoadData("Prev");
		}
	}).start();
	$.Shortcuts.add({
		type: "down",
		mask: "B",
		handler: function() {
			<?php if($loadBrowse == true){ ?>
				makePopUpTop(1000, 70, "<?php echo $this->baseUrl.$this->getParameter['asliGetCotroller'].'/data/' ?>");
			<?php } ?>
		}
	}).start();
	$.Shortcuts.add({
		type: "down",
		mask: "A",
		handler: function() {
			_add = $('#<?php echo $this->getParameter['controller'].'Add' ?>').attr("id");
			if(_add !== undefined){
				makeAdd();
			}
		}
	}).start();
	$.Shortcuts.add({
		type: "down",
		mask: "E",
		handler: function() {
			<?php if($loadEdit == true){ ?>
				_add = $('#<?php echo $this->getParameter['controller'].'Edit' ?>').attr("id");
				if(_add !== undefined){
					makeEdit();
				}
			<?php } ?>
		}
	}).start();
	// $.Shortcuts.add({
		// type: "down",
		// mask: "Esc",
		// handler: function() {
			// makeDef();
			// $("#apankForm").empty();
			// $("#apankFormDefDisplay").css("display", "none");
		// }
	// }).start();
	$.Shortcuts.add({
		type: "down",
		mask: "D",
		handler: function() {
			makeDel();
		}
	}).start();
	$.Shortcuts.add({
		type: "down",
		mask: "T",
		handler: function() {
			<?php 
			if($loadPrint == true){
				if($this->data->cetak != false){ ?>
				$('#apankFormFilter').removeAttr("style");
				$('.filter_0').focus();
			<?php 
				}
			} 
			?>
		}
	}).start();
					
	makeDel = function(){
		<?php if($loadDel == true){ ?>
			$("#tempGridFocus").focus();
			if(confirm("Yakin menghapus?")){          
				
				_url = '<?php echo $this->baseUrl.$this->getParameter['asliGetCotroller'].'/delete/&del=true' ?>';
				<?php foreach($this->data->dBasePk as $row){ ?>
					_url+= "&<?php echo $row ?>="+str_ireplace("+", "___", $('#<?php echo $row?>').val());
				<?php } ?>
				
				$.ajax({
				type: "POST",
					url: _url,
					data: $(this).serialize(),
					success: function(data) {
						$("#errorDisplay").html(data);
					}
				})
			}
		<?php } ?>
	}
	
	$('#<?php echo $this->getParameter['controller'] ?>First').click(function(){
		_urut = 0;
		makeLoadData("First");
	})
	$('#<?php echo $this->getParameter['controller'] ?>Last').click(function(){
		_urut = 0;
		makeLoadData("Last");
	})
	$('#<?php echo $this->getParameter['controller'] ?>Next').click(function(){
		_urut = $(this).attr("urut");
		makeLoadData("Next");
	})
	$('#<?php echo $this->getParameter['controller'] ?>Prev').click(function(){
		_urut = $(this).attr("urut");
		makeLoadData("Prev");
	})
	$('#<?php echo $this->getParameter['controller'] ?>Browse').click(function(){
		<?php if($loadBrowse == true){ ?>
			makePopUpTop(1000, 70, "<?php echo $this->baseUrl.$this->getParameter['asliGetCotroller'].'/data/' ?>");
		<?php } ?>
	})
	$('#<?php echo $this->getParameter['controller'] ?>Add').click(function(){
		makeAdd();
	})
	$('#<?php echo $this->getParameter['controller'] ?>Edit').click(function(){
		makeEdit();
	})
	$('#<?php echo $this->getParameter['controller'] ?>Del').click(function(){
		makeDel();
	})
	$('#<?php echo $this->getParameter['controller'] ?>prinT').click(function(){
		<?php 
		if($loadPrint == true){
			if($this->data->cetak != false){ 
		?>
			$('#apankFormFilter').removeAttr("style");
			$('.filter_0').focus();
		<?php 
			}
		} 
		?>
	})
	
	
	_loadPopUp = false;
	$('#<?php echo $this->getParameter['controller'] ?>Data .inputGrid').live("keyup", (function(e){
		if(e.which === 13){
			if(_loadPopUp !== false){
				_loadPopUp.abort();
			}
			
			_loadPopUp = $.ajax({
				type: 'POST',
				url: '<?php echo $this->baseurl.'Basic/cariData/&modul='.$this->getParameter['controller'] ?>',
				data: $(this).serialize(),
				success: function(data) {
					$('#apankFormContent').html(data);
					_focus = $('#setFocus').val();
					$('#'+_focus).focus();
				},
			 });
		}
	}))
	_loadPopUpPilih = false;
	$('#<?php echo $this->getParameter['controller'] ?>Data ._inputPilih').live("keyup", (function(e){
		if(e.which === 13){
			if(_loadPopUpPilih !== false){
				_loadPopUpPilih.abort();
			}
			
			_val = parseInt($(this).val());
			_val = _val - 1;
			_p = _val - 1;
			_n = _val + 1;
			if(_p <= 0){
				_p = 0;
			}
			
			
			_loadPopUpPilih = $.ajax({
				type: 'POST',
				url: '<?php echo $this->baseurl.'Basic/pilih/&modul='.$this->getParameter['controller'] ?>&id='+$(this).attr('kode')+'&p='+_p+'&n='+_n,
				data: $(this).serialize(),
				success: function(data) {
					$('#errorDisplay').html(data);
					$('#apankForm').empty();
				},
			 });
		}
	}))
	
	makeNextFocus = function(_no, _jum){
		if(_jum <= 50){
			_no = parseInt(_no);
			_no = _no + 1;
			
			_idS = '.urut_'+_no;
			_idN = $(_idS).attr('id');
			if(_idN !== undefined){
				_red = $(_idS).attr('disabled');
				_dis = $(_idS).attr('readonly');

				if(_red === undefined & _dis === undefined){
					makeFocusTrue('.urut_'+_no, _no);
				}else{
					makeNextFocus(_no, _jum+1);
				}
				
			}
		}
	}
	makeCekNotNull = function(_no){
		_idNm = $('.urut_'+_no).attr('id');
		_next = true;
		for(_iN = 0; _iN < _notNull.length; _iN++){
			_jj = _notNull[_iN];
			if(_jj === _idNm){
				_vVal = $('#'+_idNm).val();
				if(_vVal === ''){
					_next = false;
				}
			}
		}

		if(_next === true){
			makeNextFocus(_no, 1);
		}
		$("._popUpDef").css("display", "none");
	}
	$('.meioMask').setMask();
	$('.tanggal').change(function(){
		_cekTgl(this.id);
	})
	$(".tanggal").datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'dd/mm/yy', 
		yearRange: '1900:2020',
	});
	$('.ui-widget-content').css('display', 'none');
	<?php if(!empty($this->data->detail)){ ?>
		loadDet = false;
		makeLoadDetail = function(_jenis){
			if(loadDet !== false){
				loadDet.abort();
			}
			loadDet = $.ajax({
			type: "POST",
				url: "<?php echo $this->baseurl.$this->getParameter['controller'] ?>/detail/&jenis="+_jenis+'&idRef='+$('#<?php echo $this->data->detail->idRef ?>').val(),
				data: $(this).serialize(),
				success: function(data) {
					$("#<?php echo $this->getParameter['controller'] ?>Detail").html(data);
				}
			})
		}
		makeLoadDetail("true");	
	<?php } ?>
	<?php if(!empty($this->data->funct)){ ?>
		makeFungsiControl("<?php echo $this->data->funct ?>");
	<?php } ?>

	loadAutoNumber = false;
	<?php
	if(!empty($this->data->autoNumber)){
		foreach($this->data->autoNumber as $key => $row){
			$id = "";
			$get = "";
			foreach($row['attr'] as $row2){
				if(!empty($id)){
					$id.= ", ";
				}
				$id.= "#$row2";
				$get.= '&$row2="+$("#$row2").val()';
			}
	?>	
		makeGenAutoNumber = function(){
			if(loadAutoNumber != false){
				loadAutoNumber.abort();
			}
			
			_url = "<?php echo $this->baseurl.$this->getParameter['controller'].'/'.$row["act"].'/' ?>";
			<?php 
			foreach($row['attr'] as $row2){
			?>
				_url+= "&<?php echo $row2 ?>="+str_ireplace("+", "||", str_ireplace("/", "___", $('#<?php echo $row2 ?>').val()));
			<?php } ?>
			
			$('#<?php echo $key ?>').val("Generate...");
			loadAutoNumber = $.ajax({
			type: "GET",
				url: _url,
				data: $(this).serialize(),
				success: function(data) {
					$('#<?php echo $key ?>').val(data);
				}
			})
		}
	
		$("<?php echo $id ?>").change(function(){
			makeGenAutoNumber();
		})
	<?php
		}
	}
	?>
})

</script>