//Script yang dipakai pada module view
function fillelements(szEl,szFields) {
	var fields = szFields.split(",");
	var elm = szEl.split(",");
	for (x=0;x<elm.length;x++) {
		window.opener.document.form1.elements[elm[x]].value=fields[x];
	}
	window.close();
}
function doTooltip(e, msg) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.show(e, msg);
}

function hideTip() {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.hide();
}
function doTooltipImg(e, msg) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.show(e, '<img src="' + msg + '" border="0">');
}

function cekgalo() {
  var checkname = document.getElementsByName('opsi[]');
  for (i = 0; i < checkname.length; i++)
  checkname[i].checked = document.form2.allbox.checked? true:false
}

function cekcheckbox(conf) {
	var opt = document.getElementsByName('opsi[]');
	ada = false;
	for (i=0; i<opt.length; i++) {
		if (opt[i].checked==true) {
			ada = true;
			break;
		}
	}
	if (ada==false) {
		alert("Silahkan pilih salah satu data.");
		return false;
	} else {
		if (conf==1) {
			if (confirm("Hapus record terpilih?")==true) {
				return true;
			} else {
				return false;
			}
		} else {
			return true;
		}
	}
}

function cekpilihannyo()
{
	
	if (document.form1.kolom_cari.value == '<?php echo $cbyfield; ?>') {
		showdiv('n2');
		hidediv('n1');
	} else {
		showdiv('n1');
		hidediv('n2');
		document.form1.cari.focus();
	}
}

function urut(n)
{
	npil = document.form1.kolom_urut.value;
	if (n == npil) {
		if (document.form1.urut.checked==true) {
			document.form1.urut.checked=false;
		} else {
			document.form1.urut.checked=true;
		}
	}
	document.form1.kolom_urut.value = n;
	document.form1.submit();	

	
}

//menampilkan-menyembunyikan elemen div
function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = '';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = '';
		}
		else { // IE 4
			document.all.id.style.display = '';
		}
	}
}

function checkinput(obForm,szFields)
{
  var fields = szFields.split(",")
  var szMissing= new Array();
  for (x=0;x<fields.length;x++) {
	if (obForm.elements[fields[x]].value.length==0) {
	   szMissing[szMissing.length]=new String(' ' + obForm.elements[fields[x]].id);
	}
  }
  if (szMissing.length) {
	alert("Field"+((szMissing.length>1)?"":"")+szMissing.join(",")+" harus diisi.");
	return false
  }
  return true; 
}

function windowpopup(url,widh,hegt)
{
  var w = 0, h = 0;
  var leftc = (screen.width-widh)/2, topc = (screen.height-hegt)/2;

var winPop = window.open(url,'winPop','width='+widh+',height='+hegt+',left='+leftc+',top='+topc+''+',menubar=0'+',toolbar=0'+',status=0'
+',scrollbars=1'+',resizable=1')  
}

//<input type="checkbox" name="all" onClick="checkall(document.mylist.checkGroup,this)">
function checkall(checkname, exby) {
  for (i = 0; i < checkname.length; i++)
  checkname[i].checked = exby.checked? true:false
}

//frm = form element, ex : 0, msg = message
function checkform(frm,msg)
{
	var count = document.forms[frm].elements.length;
	for (a=0; a<count; a++) {
		if ((document.forms[frm].elements[a].value == '') && (document.forms[frm].elements[a].id == 'ck')) {
			alert(msg);
			document.forms[frm].elements[a].focus();
			return false;
			exit;
		}
	}
	return true;
}