var NS4 = (document.layers);
var IE4 = (document.all);

function CekAngka(e) {
	if (IE4) {
		if (e.keyCode == 13) return;
		if (e.keyCode < 48 || e.keyCode > 57) e.keyCode= 0;
	}
	else if (NS4) {
		if (e.which == 13) return;
		if (e.which < 48 || e.which > 57) return false;
	}
}

function BodyLoad() {
	if (parent != self) {
		top.location.href = self.location.href;
		return false;
	}
	if (NS4) {
		document.captureEvents(Event.KEYPRESS);
		document.onkeypress = CekAngka;
	}
	if (document.frmLogin.txtNIM.value.length == 10) document.frmLogin.txtPIN.focus();
	else document.frmLogin.txtNIM.focus();
}

function BodyLoad2() {
	if (parent != self) {
		top.location.href = self.location.href;
		return false;
	}
	if (NS4) {
		document.captureEvents(Event.KEYPRESS);
		document.onkeypress = CekAngka;
	}
//	if (document.frmBooking.txtKode.value.length == 10) document.frmLogin.txtPIN.focus();
	//else 
	//document.frmBooking.txtKode.focus();
}


function errMsg(msg, elemToFocus) {
	alert(msg);
	elemToFocus.focus();
	return false;
}

function Validate(theForm) {
	if (theForm.txtNIM.value == "")
		return errMsg("Masukkan NIM Anda.", theForm.txtNIM);
	if (theForm.txtNIM.value.length < 10)
		return errMsg("NIM yang Anda masukkan tidak valid:\nkurang dari 10 karakter.", theForm.txtNIM);
	if (theForm.txtPIN.value == "")
		return errMsg("Masukkan PIN Anda.", theForm.txtPIN);
	if (theForm.txtPIN.value.length < 6)
		return errMsg("PIN yang Anda masukkan tidak valid:\nkurang dari 6 karakter.", theForm.txtPIN);
	return true;
}


function Validate2(theForm) {
	if (theForm.txtKode.value == "")
		return errMsg("Masukkan Kode Booking Anda.", theForm.txtKode);
	
	if (theForm.txtKode.value.length < 10)
		return errMsg("Kode Booking yang Anda masukkan tidak valid:\nkurang dari 10 karakter.", theForm.txtKode);
	return true;
}