var omitformtags=["input", "textarea", "select"]

omitformtags=omitformtags.join("|")

function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}

function reEnable(){
return true
}

if (typeof document.onselectstart!="undefined")
document.onselectstart=new Function ("return false")
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}

// ----------------------------------------------------------------
// disable right click
// ----------------------------------------------------------------
var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")	
// ----------------------------------------------------------------

// ----------------------------------------------------------------
// mulai fungsi jam
// ----------------------------------------------------------------

var dayarray=new Array("Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu")
var montharray=new Array("Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember")
//var montharray=new Array("Jan","Feb","Maret","April","Mei","Juni","Juli","Agst","Sept","Okt","Nov","Des")

function getthedate()
	{
	var mydate=new Date()
	var year=mydate.getYear()
	if (year < 1000)
		year+=1900
	var day=mydate.getDay()
	var month=mydate.getMonth()
	var daym=mydate.getDate()
	if (daym<10)
		daym="0"+daym
	var hours=mydate.getHours()
	var minutes=mydate.getMinutes()
	var seconds=mydate.getSeconds()
	var dn="AM"
	if (hours>=12)
		dn="PM"
	if (hours>12)
		{
		hours=hours-12
		}
	if (hours==0)
		hours=12
	if (minutes<=9)
		minutes="0"+minutes
	if (seconds<=9)
		seconds="0"+seconds

	//var cdate="<small><font color='000000' face='Verdana'>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn+"</font></small>"
	var cdate="<small><font color='000000' face='Verdana' size='1'>"+daym+" "+montharray[month]+" "+year+" "+hours+":"+minutes+":"+seconds+" "+dn+"</font></small>"
	if (document.all)
		document.all.clock.innerHTML=cdate
	else if (document.getElementById)
		document.getElementById("clock").innerHTML=cdate
	else
		document.write(cdate)
}

if (!document.all&&!document.getElementById)
	getthedate()
	
function loadjam()
	{
	if (document.all||document.getElementById)
		setInterval("getthedate()",1000)
	}
// ----------------------------------------------------------------


// ----------------------------------------------------------------
// mulai fungsi pop up untuk administrator
// ----------------------------------------------------------------
function display(page,action,param,w,h)
	{
	w*=100
	h*=100
	
	switch (action)
		{
		// gagal.login
		case 0: aid="uid"
		break
		// diklat.detail
		case 1: aid="mpid"
		break
		}
	
	if (window.showModalDialog)
		{
  		window.showModalDialog("./" + page +".php?"+aid+"="+param,"","dialogWidth: " + w +"px; dialogHeight: " + h +"px")
  		}
  	else
  		{
  		var d = new Date()
  		var ID = d.getDate()+""+d.getMonth() + 1+""+d.getFullYear()+""+d.getHours()+""+d.getMinutes()+""+d.getSeconds()
  		winHandle = window.open("./" + page +".php?"+aid+"="+param, ID, "modal,toolbar=false,location=false,directories=false,status=false,menubar=false,scrollbars=no,resizable=no,width=" + w + ",height=" + h)
    		winHandle.focus();
  		}
	}
// ----------------------------------------------------------------	

// ----------------------------------------------------------------
// mulai fungsi auto fit iframe
// ----------------------------------------------------------------
var iframeids=["myframe"]
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() 
	{
	var dyniframe=new Array()
	for (i=0; i<iframeids.length; i++)
		{
		if (document.getElementById)
			resizeIframe(iframeids[i])
		if ((document.all || document.getElementById) && iframehide=="no")
			{
			var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
			tempobj.style.display="block"
			}
		}
	}

function resizeIframe(frameid)
	{
	var currentfr=document.getElementById(frameid)
	if (currentfr && !window.opera)
		{
		currentfr.style.display="block"
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
			currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
			currentfr.height = currentfr.Document.body.scrollHeight;
		if (currentfr.addEventListener)
			currentfr.addEventListener("load", readjustIframe, false)
		else if (currentfr.attachEvent)	
			{
			currentfr.detachEvent("onload", readjustIframe) // Bug fix line
			currentfr.attachEvent("onload", readjustIframe)
			}
		}
	}

function readjustIframe(loadevt) 
	{
	var crossevt=(window.event)? event : loadevt
	var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
	if (iframeroot)
		resizeIframe(iframeroot.id);
	}

function loadintoIframe(iframeid, url)
	{
	if (document.getElementById)
	document.getElementById(iframeid).src=url
	}

if (window.addEventListener)
	window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
	window.attachEvent("onload", resizeCaller)
else
	window.onload=resizeCaller
// ----------------------------------------------------------------	

// ----------------------------------------------------------------
// Mulai fungsi admin
// ----------------------------------------------------------------
function checkAll() 
	{
	if ((document.checkboxform.jumlah_data.value/1)!=1)
		{
		for (var j = 0; j < (document.checkboxform.jumlah_data.value/1); j++) 
			{
			box = eval("document.checkboxform.pil[" + j + "]"); 
			if (box.checked == false) box.checked = true;		
   			}
   		pilihIni();
   		}
   	else
   		{
   		document.checkboxform.pil[0].checked = true;
   		pilihSatu();
		} 
	}

function uncheckAll() 
	{
	if ((document.checkboxform.jumlah_data.value/1)!=1)
		{
		for (var j = 0; j < (document.checkboxform.jumlah_data.value/1); j++) 
			{
			box = eval("document.checkboxform.pil[" + j + "]"); 
			if (box.checked == true) box.checked = false;
   			}
   		pilihIni();
   		}
   	else
   		{
   		document.checkboxform.pil.checked = false;
   		pilihSatu();
		}
	}
	
function pilihIni()
	{
	var tmpStr="";
	if ((document.checkboxform.jumlah_data.value/1)!=1)
		{		
		for (var j = 0; j < (document.checkboxform.jumlah_data.value/1); j++) 
			{
			box = eval("document.checkboxform.pil[" + j + "]");
			if (box.checked == true) tmpStr = tmpStr + box.value + "_";
			}
		checkboxform.kode.value = tmpStr;
		}
	else
		{
		pilihSatu();
		}
	}	

function pilihSatu()
	{
	var tmpStr="";
	if (document.checkboxform.pil.checked == true) tmpStr = tmpStr + document.checkboxform.pil.value + "_";
	checkboxform.kode.value = tmpStr;
	}
	
function pilihCumaSatu()
	{	
	var tmpStr="";
	if ((document.checkboxform.jumlah_data.value/1)!=1)
		{		
		for (var j = 0; j < (document.checkboxform.jumlah_data.value/1); j++) 
			{
			box = eval("document.checkboxform.pil[" + j + "]");
			if (box.checked == true) tmpStr = tmpStr + box.value + "_";
			}
		checkboxform.kode.value = tmpStr;
		}
	else
		{
		pilihSatu();
		}
	}	
// ----------------------------------------------------------------

// ----------------------------------------------------------------
// Mulai fungsi checkbox
// ----------------------------------------------------------------
function openHalaman(page,i) 
	{
	document.location=page + i;
	}
// ----------------------------------------------------------------

// ----------------------------------------------------------------
// Mulai fungsi multi pilih hot backup
// ----------------------------------------------------------------
function multiPilih(select)
	{
	var r = new Array();
  	for (var i = 0; i < select.options.length; i++)
    		if (select.options[i].selected)
      	r[r.length] = select.options[i].value;
	form1.kode.value = r;
	}
// ----------------------------------------------------------------

// ----------------------------------------------------------------
// Mulai disable enter
// ----------------------------------------------------------------
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;
	}      
// ----------------------------------------------------------------

// ----------------------------------------------------------------
// Mulai fungsi rata2 2 param
// ----------------------------------------------------------------
function rata2(param1,param2)
	{
	//param1=eval("document.form1." + param1 + ".value")/1;
	//param2=eval("document.form1." + param2 + ".value")/1;
	p1=eval("document." + param1 + ".value")/1;
	p2=eval("document." + param2 + ".value")/1;
	nilai_rata=(p1+p2)/2;
	document.form1.nilai_rata.value = nilai_rata;
	}
// ----------------------------------------------------------------

// ----------------------------------------------------------------
// Mulai fungsi submit sekali
// ----------------------------------------------------------------
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")
			if(tempobj.type.toLowerCase()=="submit")
			//disable em
			document.form1.Submit.disabled=true
			document.form1.Submit.value='Silakan Tunggu...'
			}
		}
	}
// ----------------------------------------------------------------

// ----------------------------------------------------------------
// Mulai fungsi submit sekali
// ----------------------------------------------------------------
function bookmarksite(title, url)
	{
	if (document.all)
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "")
	}
// ----------------------------------------------------------------
