function page_loading(){
	if(document.frm0.check_sess.value == "True"){
		span_login.style.display = "None";
		span_logout.style.display = "Block";
	}else{
		span_login.style.display = "Block";
		span_logout.style.display = "None";	
	}
}	

function adminloading(){
	window.status = "";
}

function textarea(val){
    val = val.replace(/\r\n/g, '<br>');
	val = val.replace(/\n/g, '<br>');
    val = val.replace(/\r/g, '<br>');	
	document.all["comment2"].value = val;
}

function select_category1(val){
	if(val != ""){
		location.href ="information.php?category_id1="+val;
	}else{
		location.href ="information.php";
	}
}

function select_category_personal(val){
	if(val != ""){
		location.href ="personal.php?category_id1="+val;
	}else{
		location.href ="personal.php";
	}
}

function select_category_learning1(val){
	if(val != ""){
		location.href ="learning.php?category_id1="+val;
	}else{
		location.href ="learning.php";
	}
}

function enable_subcategory(val){
	if(val == "8"){
		subctg.style.display = "Block";
	}else{
		subctg.style.display = "None";
	}
}

function validate_guestbook(){
	if(document.frmlogin.name.value == ""){
		alert("Silahkan isi nama anda!");
		document.frmlogin.name.focus();
		return false;
	}
	
	if(document.frmlogin.email.value != ""){
		var domain = document.frmlogin.email.value.substring(document.frmlogin.email.value.indexOf('@') + 1);
		if (domain.indexOf('.') == -1){
			alert("Format email salah!");
			document.frmlogin.email.focus();
			return false;
		}
		if (domain.indexOf('.') == 0 || domain.indexOf('.') == domain.length - 1){
			alert("Format email salah!");
			document.form1.frmlogin.focus();		
			return false;
		}
	}
	
	if(document.frmlogin.comment.value == ""){
		alert("Silahkan isi komentar, saran, kritik, atau pertanyaan anda!");
		document.frmlogin.comment.focus();
		return false;
	}
	
}

function personal_class(val,menu){
	if(val != ""){
		location.href = "personal.php?item="+menu+"&class_id="+val;
	}else{
		location.href = "personal.php?item="+menu;
	}
}

function personal_year(val,menu){
	if(val != ""){
		location.href = "personal.php?item="+menu+"&personal_year="+val;
	}else{
		location.href = "personal.php?item="+menu;
	}
}

function gallery_category(val){
	if(val != ""){
		location.href = "gallery.php?category_id="+val;
	}else{
		location.href = "gallery.php";
	}
}

function learning_classes(val,menu){
	if(val != ""){
		location.href = "learning.php?item="+menu+"&class_id="+val;
	}else{
		location.href = "learning.php?item="+menu;
	}
}

function article_subcategory(val,menu){
	if(val != ""){
		location.href = "information.php?item="+menu+"&subcategory_id="+val;
	}else{
		location.href = "information.php?item="+menu;
	}
}

function cekbukutamu(){
	var nama = document.formbukutamu.nama.value;
	var komentar = document.formbukutamu.komentar.value;
	if(nama == ""){
		alert("Silahkan isi nama anda");
		return false;		
	}else if(komentar == ""){
		alert("Silahkan isi komentar anda");
		return false;
	}else
		return true;
}

function NewWindow(mypage,myname,w,h,scroll){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable=yes,';
	  settings += 'toolbar=no';
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

//untuk set focus form tertentu
function setFocus(target_name)
{	
	target_name.focus();
}

