// Check for multiple submit

var ONE = false;
var RSAAppletEnable = false;
//daniel add
function changeIt(objName)
{
	//The image object accessed through its id we mentioned in the DIV block which is going to be visible 
	//alert('show hidden');
//currently
	var obj = document.getElementById(objName);
	
	//An array that hold the IDs of images that we mentioned in their DIV blocks
	var objId = new Array();
	
	//Storing the image IDs into the array starts here
	objId[0] = "buttonsubmit";
	objId[1] = "buttonprocess";
	var i;
	var tempObj;
	for(i=0;i<objId.length;i++)
	{
		if(objName == objId[i])
		{
			obj.style.display = "block";
		}
		else
		{
			tempObj = document.getElementById(objId[i]);
			tempObj.style.display = "none";	
		}
	}
	return;	
}
//end daniel add
function clickOnce(Set)
{
var result;
//Daniel add 
if (document.getElementById('linksubmit')){
	document.getElementById('linksubmit').removeAttribute('href');
	if (document.getElementById('buttonsubmit')){
		if(document.getElementById('buttonprocess'))
			changeIt('buttonprocess');
	}
}
//end Daniel add
if (document.getElementById("linkcancel")){
	document.getElementById("linkcancel").removeAttribute("href");
}

if (ONE)
{
alert("You can only submit this request once!");
result = false;
}  
else
result = true;    

if (Set)
ONE = true;
return result;
}

function send(form)
{
if (clickOnce(true))
{
return true;
}
else
return false;
}

//open new window for help menu
function newWindow(param) {
catWindow = window.open(param, 'catWin', 'toolbar=no,scrollbars=yes,resizable=no,width=500,height=400');
}

//disable right click
function right(e) {
	
if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)){
alert("Maaf, fungsi klik tombol kanan (right click) telah dinonaktifkan");
return false;
}else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)){
alert("Maaf, fungsi klik tombol kanan (right click) telah dinonaktifkan");
return false;
}

return true;
}

document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;


var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) 
{
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}

function containsElement(arr, ele) 
{
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}

function getIndex(input) 
{
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}

function setFocus(theObject) 
{
if (theObject) {
if (theObject.type!="hidden") {
if (!theObject.disabled) {
theObject.focus();
}
}
}
}
