// JavaScript Document
function dropdownlist(listindex)
{
document.FDaftar.programstudi.options.length = 0;
switch (listindex)
{
	case "FISIP" :
		document.FDaftar.programstudi.options[0]=new Option("S1 Administrasi Negara","S1 Administrasi Negara");
		document.FDaftar.programstudi.options[1]=new Option("S1 Komunikasi","S1 Komunikasi");
		break;
	case "FKIP" :
		document.FDaftar.programstudi.options[0]=new Option("S1 Bimbingan dan Konseling","S1 Bimbingan dan Konseling");
		document.FDaftar.programstudi.options[1]=new Option("S1 Pendidikan Bahasa Inggris","S1 Pendidikan Bahasa Inggris");
		break;
	case "Ekonomi" :
		document.FDaftar.programstudi.options[0]=new Option("S1 Manajemen","S1 Manajemen");
		break;
	case "Pertanian" :
		document.FDaftar.programstudi.options[0]=new Option("S1 Peternakan","S1 Peternakan");
		document.FDaftar.programstudi.options[1]=new Option("S1 Agribisnis","S1 Agribisnis");
		break;
	case "Agama Islam" :
		document.FDaftar.programstudi.options[0]=new Option("S1 Muamalat","S1 Mu'amalat");
		break;
	case "Teknik" :
		document.FDaftar.programstudi.options[0]=new Option("D3 Teknik Mesin","D3 Teknik Mesin");
		document.FDaftar.programstudi.options[1]=new Option("S1 Teknik Mesin","S1 Teknik Mesin");
		document.FDaftar.programstudi.options[2]=new Option("S1 Teknik Informatika","S1 Teknik Informatika");
		break;
	case "Kesehatan Masyarakat" :
		document.FDaftar.programstudi.options[0]=new Option("S1 Kesehatan Masyarakat","S1 Kesehatan Masyarakat");
		break;
	case "Hukum" :
		document.FDaftar.programstudi.options[0]=new Option("S-1 Ilmu Hukum","S-1 Ilmu Hukum");
		break;
	case "S2 Komunikasi" :
		document.FDaftar.programstudi.options[0]=new Option("S-2 Ilmu Komunikasi","S-2 Ilmu Komunikasi");
		break;
	case "SEMUA" :
		document.FDaftar.programstudi.options[0]=new Option("-------- SEMUA --------","SEMUA");
		break;
	case "" :
		document.FDaftar.programstudi.options[0]=new Option("-------- Pilih Fakultas --------","");
		break;
}
return true;
}
function submitonce(theform){
	//if IE 4+ or NS 6+
	if (document.all||document.getElementById){
		//screen thru every element in the form, and hunt down "submit" and "reset"
		for (i=0;i<theform.length;i++){
			var tempobj=theform.elements[i]
			if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
			//disable em
			tempobj.disabled=true
		}
	}
}

function openWin(theURL,winName,wWidth,wHeigt) 
	{
	sWidth = wWidth;
	sHeight = wHeigt;
	pTop = (screen.height) ? (screen.height-wHeigt)/2 : 0;
	pLeft =  (screen.width) ? (screen.width-sWidth)/2 : 0;
	settings = 'height='+sHeight+',width='+sWidth+',top='+pTop+',left='+pLeft+',toolbar=0,location=0,status=1,menubar=0,scrollbars=1,resizable=0'
	window.open(theURL,winName,settings);
}
function getkey(e)
{
if (window.event)
   return window.event.keyCode;
else if (e)
   return e.which;
else
   return null;
}
function goodchars(e, goods, field)
{
var key, keychar;
key = getkey(e);
if (key == null) return true;

keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
goods = goods.toLowerCase();

// check goodkeys
if (goods.indexOf(keychar) != -1)
	return true;
// control keys
if ( key==null || key==0 || key==8 || key==9 || key==27 )
   return true;
   
if (key == 13) {
	var i;
	for (i = 0; i < field.form.elements.length; i++)
		if (field == field.form.elements[i])
			break;
	i = (i + 1) % field.form.elements.length;
	field.form.elements[i].focus();
	return false;
	};
// else return false
return false;
}
function handleEnter (field, event)
{
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		var i;
		for (i = 0; i < field.form.elements.length; i++)
			if (field == field.form.elements[i])
				break;
		i = (i + 1) % field.form.elements.length;
		field.form.elements[i].focus();
		return false;
	} 
	else
	return true;
}
function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '');
}
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}
function isEmail(str) 
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	return false
	}
	if (str.indexOf(at,(lat+1))!=-1){
	return false
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	return false
	}
	if (str.indexOf(dot,(lat+2))==-1){
	return false
	}
	if (str.indexOf(" ")!=-1){
	return false
	}
	return true
}

function setFocusStep1() {
	document.FDaftar.fakultas.focus();
}
function setFocusStep2() {
	document.FDaftar.namaayah.focus();
}
function cekStep1(theForm) 
{
	if(trim(theForm.fakultas.value) == "" || trim(theForm.fakultas.value) == "-") 
	{
		alert('Anda belum memilih fakultas');
		theForm.fakultas.focus();
		return(false);
	}
	else if(trim(theForm.programstudi.value) == '' || trim(theForm.programstudi.value) == "-") 
	{
		alert('Anda belum memilih program studi!');
		theForm.programstudi.focus();
		return(false);
	}
	else if(trim(theForm.namalengkap.value) == '' || trim(theForm.namalengkap.value) == "-") 
	{
		alert('Isikan nama lengkap anda!');
		theForm.namalengkap.focus();
		return(false);
	}
	else if(trim(theForm.tmplahir.value) == '' || trim(theForm.tmplahir.value) == "-") 
	{
		alert('Isikan tempat lahir anda sesuai ijazah!');
		theForm.tmplahir.focus();
		return(false);
	}
	else if(trim(theForm.alamatrumah.value) == '' || trim(theForm.alamatrumah.value) == "-") 
	{
		alert('Isikan alamat anda!');
		theForm.alamatrumah.focus();
		return(false);
	}
	else if(trim(theForm.kota.value) == '' || trim(theForm.kota.value) == "-") 
	{
		alert('Isikan nama kota!');
		theForm.kota.focus();
		return(false);
	}
	else if(trim(theForm.email.value) != '' && !isEmail(trim(theForm.email.value)))
	{
		alert('Isikan alamat email dengan benar!');
		theForm.email.focus();
		return(false);
	}
	else
	{
		if (confirm('Apakah data yang anda isikan sudah benar?') == true)
		{
			submitonce(theForm);
			return(true);
		}
		else
		{
			return(false);
		}
	}
}
function cekStep2(theForm) 
{
	if(trim(theForm.namaayah.value) == "" || trim(theForm.namaayah.value) == "-") 
	{
		alert('Isikan nama ayah!');
		theForm.namaayah.focus();
		return(false);
	}
	else if(trim(theForm.namaibu.value) == '' || trim(theForm.namaibu.value) == "-") 
	{
		alert('Isikan nama ibu!');
		theForm.programstudi.focus();
		return(false);
	}
	else if(trim(theForm.alamatwali.value) == '' || trim(theForm.alamatwali.value) == "-") 
	{
		alert('Isikan alamat!');
		theForm.alamatwali.focus();
		return(false);
	}
	else if(trim(theForm.kotaayah.value) == '' || trim(theForm.kotaayah.value) == "-") 
	{
		alert('Isikan nama kota!');
		theForm.kotaayah.focus();
		return(false);
	}
	else if(trim(theForm.namasekolah.value) == '' || trim(theForm.namasekolah.value) == "-") 
	{
		alert('Isikan nama sekolah asal!');
		theForm.namasekolah.focus();
		return(false);
	}
	else if(trim(theForm.alamatsekolah.value) == '' || trim(theForm.alamatsekolah.value) == "-") 
	{
		alert('Isikan alamat sekolah!');
		theForm.alamatsekolah.focus();
		return(false);
	}
	else if(trim(theForm.kotasekolah.value) == '' || trim(theForm.kotasekolah.value) == "-") 
	{
		alert('Isikan nama kota!');
		theForm.kotasekolah.focus();
		return(false);
	}	
	else if(theForm.setuju.checked == false) 
	{
		alert('Klik tanda pernyataan kebenaran informasi anda!');
		theForm.setuju.focus();
		return(false);
	}	
	else
	{
		if (confirm('Apakah data yang anda isikan sudah benar?') == true)
		{
			submitonce(theForm);
			return(true);
		}
		else
		{
			return(false);
		}
	}
}
function expandForm(objName)
{
	hideForm();
	document.getElementById(objName).style.display="block"
}
function hideForm()
{
	document.getElementById("fpindahan").style.display="none"
	document.getElementById("fprestasi").style.display="none"
}
function cekGuestbook(theForm) 
{
	if(trim(theForm.txtName.value) == "" || trim(theForm.txtName.value) == "-") 
	{
		alert('Isikan nama anda!');
		theForm.txtName.focus();
		return(false);
	}
	else if(trim(theForm.txtLocation.value) == '')
	{
		alert('Isikan nama kota lokasi anda!');
		theForm.txtLocation.focus();
		return false;
	}
	else if(trim(theForm.txtEmail.value) != '' && !isEmail(trim(theForm.txtEmail.value)))
	{
		alert('Alamat email salah. Email boleh dikosongkan.');
		theForm.txtEmail.focus();
		return false;
	}
	else if(trim(theForm.txtMessage.value) == '')
	{
		alert('Isikan komentar atau pesan anda!');
		theForm.txtMessage.focus();
		return false;
	}
	else if(trim(theForm.sccode.value) == "" || trim(theForm.sccode.value) == "-") 
	{
		alert("Ketiikan kode validasi bukutamu.!");
		theForm.sccode.focus();
		return(false);
	}
	else
	{
		//submitonce(theForm);
		return true;
	}
}
function cekReport(theForm) 
{
	if(trim(theForm.fakultas.value) == "" || trim(theForm.fakultas.value) == "-") 
	{
		alert('Anda belum memilih fakultas');
		theForm.fakultas.focus();
		return(false);
	}
	else if(trim(theForm.programstudi.value) == '' || trim(theForm.programstudi.value) == "-") 
	{
		alert('Anda belum memilih program studi!');
		theForm.programstudi.focus();
		return(false);
	}
	else
	{
		return(true);
	}
}
function cekLulus(theForm) 
{
	if(trim(theForm.no_daftar.value) == "" || trim(theForm.no_daftar.value) == "-") 
	{
		alert('Isikan Nomor Pendaftaran Anda');
		theForm.no_daftar.focus();
		return(false);
	}
	else
	{
		return(true);
	}
}