function BrowserData()
	{
		this.userAgent = "Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 4.0)";
		this.browser = "MSIE";
		this.majorVer = 6;
		this.minorVer = "0";
		this.betaVer = "0";
		this.platform = "NT";
		this.platVer = "4.0";
		this.getsNavBar = true;
		this.doesActiveX = true;
		this.fullVer = 6;
	}
	var oBD = new BrowserData();
function loadHandler(theURL, winName, p_Width, p_Height, p_Scroll, p_Resize, p_Menu){
	if (oBD.fullVer >= '5.5'){
		window.showModalDialog(theURL, winName, 'dialogHeight: ' + p_Height +'px; dialogWidth: ' + p_Width + 'px; center: Yes; help: No; resizable: No; status: No;scrollbars:No');
	}
	else{
		OpenWindow(winName, theURL, p_Width, p_Height, p_Scroll, p_Resize, p_Menu);
	}
	}
	
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 isValidMonth(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;
		}
		else
		{
			if ((integervalue > 12) || (integervalue < 0) )
			{
				retValue = false;		
			}
		}
	}
	if (!retValue)
	{
		alert("Invalid Month : " + obj.value);
		obj.value = "";
		obj.select();
		obj.focus();
	}	
	return retValue;
}
function isValidHour(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;
		}
		else
		{
			if (integervalue > 24)
			{
				retValue = false;		
			}
		}
	}
	if (!retValue)
	{
		alert("Invalid Hour : " + obj.value);
		obj.value = "";
		obj.select();
		obj.focus();
	}	
	return retValue;
}
function isValidMinute(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;
		}
		else
		{
			if (integervalue > 59)
			{
				retValue = false;		
			}
		}
	}
	if (!retValue)
	{
		alert("Invalid Hour : " + 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

	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 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)-25;
    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 = "I" + cls + "F";}
function go_OnBlur(obj, cls){	obj.className = "I" + cls;}
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);
	//else location.replace(p_URL + "?page=" + p_Page);
}	
function go_Page_old(p_URL, p_Page, p_PageTotal, p_Option)
{   if (p_Page == "") p_Page = 0;
	p_Page = parseInt(p_Page);
	if (p_Option == "Next") p_Page++;
	if (p_Option == "Prev") p_Page--;
	if (p_Page <= 1) p_Page=1;
	if (p_Page > p_PageTotal) p_Page = p_PageTotal;
	// alert(p_URL + "&Page=" + p_Page);
	location.replace(p_URL + "&Page=" + p_Page);
	
}	
function WinOnLoad(obj, p_Index) {obj.elements[p_Index].focus();}

function FindComboValue(io_Combo, is_Value)
{
    /*----- Declare local variables -----*/
    var ln_index1, lb_found;
    
    lb_found = false;
    ln_index1 = 0;
    
    while (ln_index1 < io_Combo.options.length && !lb_found)
    {
        if (io_Combo.options[ln_index1].value == is_Value)
            lb_found = true;
        else
            ln_index1++;
    }
    
    if (lb_found)
        return ln_index1;
    else
        return -1;
}
//=====
/*
Form field Limiter script- By Dynamic Drive
For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
This credit MUST stay intact for use
*/

var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder,msgdis){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
if (window.event||e.target&&e.target==eval(placeholder)){
	if (lengthleft<0)	
	theform.value=theform.value.substring(0,maxlength)
	if (msgdis != "") writetolayer(msgdis, lengthleft)
}
}


function displaylimit(theform,thelimit,msgdis){
var limit_text='<b><span id="'+theform.toString()+'" style="Display:none">'+thelimit+'</span></b>'
if (document.all||ns6)
document.write(limit_text)
if (msgdis != "") writetolayer(msgdis, thelimit)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform,msgdis)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform,msgdis) }, true); 
}
}
//-----
function GetProdDesc(is_Value)
{
    //----- Declare local variables
    var la_Product = parent.fraVariable.A_Product;
    var ln_index1 = 0;
    //-----
    //alert();
    while (ln_index1 < la_Product.length )
    {
        if (la_Product[ln_index1][0] == is_Value)
        {
            return unescape(la_Product[ln_index1][1]);
        }
        else
            ln_index1 ++;
    }
    
    return '';
}

function endSplash() {
	if(document.layers) {
		var splash = document.tbl_splash;
		 splash.visibility = "hide";
		splash.style.display="none";
	}
	if(document.all) {
		var splash = document.all.tbl_splash;
		splash.style.display="none";
		
	}
	
}
var objFocus
function cancelSubmit() {
	objFocus.focus();
	return false;	
}
function hidestatus(pstatus){
	this.window.status=pstatus;
	return true;
}
function Right(str, n)
        /***
                IN: str - the string we are RIGHTing
                    n - the number of characters we want to return

                RETVAL: n characters from the right side of the string
        ***/
        {
                if (n <= 0)     // Invalid bound, return blank string
                   return "";
                else if (n > String(str).length)   // Invalid bound, return
                   return str;                     // entire string
                else { // Valid bound, return appropriate substring
                   var iLen = String(str).length;
                   return String(str).substring(iLen, iLen - n);
                }
        }

var ModalWin = null;
function modelesswin(url,mwidth,mheight){
	if (document.all&&window.print) //if ie5
	eval('window.showModelessDialog(url,"EDIT","help:0;resizable:1;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")')
	else
	eval('window.open(url,"EDIT","width='+mwidth+'px,height='+mheight+'px,resizable=1,scrollbars=1")')
}
function FocusModalWin(){
	setTimeout(CheckModalWin, 50);
}
function CheckModalWin(){

    	if (ModalWin && !ModalWin.closed) {
    		ModalWin.focus();
    	}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function hide_status(smsg)
{
  window.status = smsg;
  return true;
}
// handle date time input
var min_year = 1930; // defines lowest year in year menu
var max_year = 2020; // defines highest year in the year menu

// make this false to prevent the weekday element from being displayed
var weekday_showing = true;

// make this true to make month return a number (0-11)
var month_returned_as_number = true;

if (min_year <= 400)
 alert("Minimum year must be higher than 400 for this algorithm to work.");

function changeDays(numb,tgl_form,bln_form,thn_form) {
 mth = bln_form.selectedIndex;
 sel = thn_form.selectedIndex;
 yr = thn_form.options[sel].text;
 if (numb != 1) {
  numDays = numDaysIn(mth,yr);
  tgl_form.options.length = numDays;
  for (i=27;i<numDays;i++) {
    tgl_form.options[i].text = i+1;
  }
 }
 day = tgl_form.selectedIndex+1;
}

function numDaysIn(mth,yr) {
 if (mth==3 || mth==5 || mth==8 || mth==10) return 30;
 else if ((mth==1) && leapYear(yr)) return 29;
 else if (mth==1) return 28;
 else return 31;
}

function leapYear(yr) {
 if (((yr % 4 == 0) && yr % 100 != 0) || yr % 400 == 0)
  return true;
 else
  return false;
}

function arr() {
 this.length=arr.arguments.length;
 for (n=0;n<arr.arguments.length;n++) {
  this[n] = arr.arguments[n];
 }
}
 
// *** comment out the one you don't want to use ***
months = new arr("January","February","March","April","May",
 "June","July","August","September","October","November","December");

var cur = new Date("<%=now()%>");
 
function getWeekDay(mth,day,yr) {
 first_day = firstDayOfYear(yr);
 for (num=0;num<mth;num++) {
  first_day += numDaysIn(num,yr);
 }
 first_day += day-1;
 return first_day%7;
}

function firstDayOfYear(yr) {
 diff = yr - 401;
 return parseInt((1 + diff + (diff / 4) - (diff / 100) + (diff / 400)) % 7);
}

// fixes a Netscape 2 and 3 bug
function getFullYear(d) { // d is a date object
 yr = d.getYear();
 if (yr < 1000)
  yr+=1900;
 return yr;
}

