function isEnter(e)
{	var isTrue = false;
	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	var keyCode = (isNN) ? e.which : e.keyCode; 
	if (keyCode==13) isTrue = true;
	return isTrue;
}
function isValidNumber(obj, decimals)
{
	fieldValue = obj.value;
	var retValue = true;
	if (obj.value == "") return true;
	if (isNaN(fieldValue))	//is it Not A Number ?
	{
		retValue = false;
	}
	else
	{	//This is a number, but check the decimals
		timeshundred = parseFloat(fieldValue * Math.pow(10, decimals));
		integervalue = parseInt(parseFloat(fieldValue) * Math.pow(10, decimals));
		if (timeshundred != integervalue)
			retValue = false;
	}
	if (!retValue)
	{
		alert("Invalid number : " + obj.value);
		obj.value = "";
		obj.select();
		obj.focus();
	}
	return retValue;
}
function isValidDate(fieldName)
{
	var dateStr = fieldName.value;
	var strday = "";
	var strmonth = "";
	var stryear = "";
	// Checks for the following valid date formats:
	// DD/MM/YY   DD/MM/YYYY   DD-MM-YY   DD-MM-YYYY
	// Also separates date into month, day, and year variables
	if (dateStr == "") return false;
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

	// To require a 4 digit year entry, use this line instead:
	// var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;

	var matchArray = dateStr.match(datePat); // is the format ok?
	
	if (matchArray == null)
	{
		alert("Date is not in a valid format.")
		fieldName.select();
		fieldName.focus();
		return false;
	}
	month = matchArray[3]; // parse date into variables
	day = matchArray[1];
	year = matchArray[4];
//	alert(matchArray[0]); // tanggal
//	alert(matchArray[1]); // 2 digit pertama
//	alert(matchArray[2]); // -
//	alert(matchArray[3]); // 2 digit kedua
//	alert(matchArray[4]); // tahun
	if (month < 1 || month > 12) // check month range
	{
		alert("Month must be between 1 and 12.");
		fieldName.select();
		fieldName.focus();
		return false;
	}
	if (day < 1 || day > 31)
	{
		alert("Day must be between 1 and 31.");
		fieldName.select();
		fieldName.focus();
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31)
	{
		alert("Month "+month+" doesn't have 31 days!")
		fieldName.select();
		fieldName.focus();
		return false
	}
	if (month == 2)  // check for february 29th
	{
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap))
		{
			alert("February [" + year + "] doesn't have " + day + " days!");
			fieldName.select();
			fieldName.focus();
			return false;
		}
	}
	if (year.length <4)
	{
		if (year >= 90) 
			stryear =  "19"
		else
			stryear =  "20";
	}
	stryear =  stryear + year;
	if (month.length == 1) strmonth = "0";
	strmonth = strmonth + month;
	if (day.length == 1) strday = "0";
	strday = strday + day;
	fieldName.value = strday + "-" + strmonth + "-" + stryear
	return true;  // date is valid
}
function writetolayer(lay,txt) 
{	var ie4 = (document.all) ? true : false;
	var ns4 = (document.layers) ? true : false;
	var ns6 = (document.getElementById && !document.all) ? true : false;
	if (ie4) document.all[lay].innerHTML = txt;
	if (ns4) 
	{
		document[lay].document.write(txt);
		document[lay].document.close();
	}
}
function go_Page(p_URL, p_Option, p_Page, p_PageTotal, p_Param)
{   var ls_Param = ""
	if (p_Option =='FIRST')	{ if (p_Page >1) ls_Param = "Page=1"; }
	if (p_Option =='PREV')	{ if (p_Page >1) ls_Param = "Page=" + (p_Page-1); }
	if (p_Option =='NEXT')	{ if (p_Page < p_PageTotal && p_PageTotal > 1) ls_Param = "Page=" + (p_Page+1); }
	if (p_Option =='LAST')	{ if (p_Page < p_PageTotal && p_PageTotal > 1) ls_Param = "Page=" + p_PageTotal; }
	if (p_Option =='GO')	{ if (p_Page > 0 && p_Page <=p_PageTotal) ls_Param = "Page=" + p_Page; }
	if (ls_Param != "")	location.replace(p_URL + "?" + ls_Param + p_Param);
}	
function OpenWindow(p_Name, p_URL, p_Width, p_Height, p_Scroll, p_Resize, p_Menu) 
{//	var li_Width = 500;
//  var li_Height = 400;
    var li_Top = (window.screen.availHeight/2)- (p_Height/2);
    var li_Left=((window.screen.availWidth/2)-(p_Width/2));
    var ls_Feature = "toolbar=no,location=no,titlebar=no,directories=no,status=no,copyhistory=no,";
    if (p_Scroll) 
		ls_Feature += "scrollbars=yes,"
	else
		ls_Feature += "scrollbars=no,";
    if (p_Resize) 
		ls_Feature += "resizable=yes,"
	else
		ls_Feature += "resizable=no,";
    if (p_Menu) 
		ls_Feature += "menubar=yes,"
	else
		ls_Feature += "menubar=no,";
	
    window.open(p_URL,p_Name,ls_Feature + "width=" + p_Width + ",height=" + p_Height + ", top=" + li_Top + ",left=" + li_Left ,false);
}
function go_OnFocus(obj, cls){	obj.className = cls;}
function go_OnBlur(obj, cls){	obj.className = cls;}
function ShowHide(MyItem)
{
	if(MyItem.style.display=="none")
	{
		MyItem.style.display="";
	}else
	{
		MyItem.style.display="none";
	}
}