function cekEmptyTextBox(text) {
	result = false;
	if (text.value.replace(' ','') == '') {
		result = true;
	}
	return result;
}

function toUpper(o){
  o.value=o.value.toUpperCase();
}

function toUpperAlpha(o){
  o.value=o.value.toUpperCase().replace(/([^A-Z])/g,"");
}

function toUpperAlpha2(o){
  if(/[^0-9A-Z]/.test(o.value)){
    o.value=o.value.toUpperCase().replace(/([^0-9A-Z])/g,"");
  }
}

function toAlpha(o){
  if(/[^0-9]/.test(o.value)){
    o.value=o.value.toUpperCase().replace(/([^0-9])/g,"");
  }
}

function toAlphaWithDecimal(o) {
  if(/[^0-9.]/.test(o.value)){
    o.value=o.value.toUpperCase().replace(/([^0-9.])/g,"");
  }
}


function hideStartMenu() {
	//alert('fdsa');
	try {
		//parent.document.getElementsById('SPMenuHeader').hideAllMenus();
		parent.document.frmMain.btnHideMenu.click();
	}	catch (er){
	
		}
}

function test() {
	alert('fdsa');
}

function g(o){
  if(/[^0-9A-Z]/.test(o.value)){
    o.value=o.value.toUpperCase().replace(/([^0-9A-Z])/g,"");
  }
}

function window_onload(DataGrid, Table) { 
	var str; 

	str = document.all(DataGrid.id).outerHTML; 
	str = (str.substring((str.indexOf("<TABLE ")), (str.indexOf("/TR>"))+4) + "</TABLE>").replace(DataGrid.id , Table.id); 

	document.all(Table.id).outerHTML = str; 
	if (document.all(DataGrid.id).rows[1].cells[0].offsetWidth > 0) { 
		for (var i = 0; i < (document.all(DataGrid.id).rows[1].cells.length -1); i++) { 
			document.all(Table.id).rows[0].cells[i].width = document.all(DataGrid.id).rows[1].cells[i].offsetWidth; 
			document.all(DataGrid.id).rows[1].cells[i].width = document.all(DataGrid.id).rows[1].cells[i].offsetWidth; 
		} 
		document.all(DataGrid.id).rows[0].style.display="none"; 
	} else { 
		document.all(Table.id).rows[0].style.display="none"; 
	} 
} 

function popupOnTop(urlStr,width,height) {
	//window.showModalDialog(urlStr,null,'status:no;dialogWidth:' + width + 'px;dialogHeight:' + height + 'px;dialogHide:true;help:no;scroll:yes')
	//window.showModalDialog(urlStr,null,'status:no;dialogHide:true;help:no;scroll:yes')
	//window.showModalDialog(urlStr,null,'status:no;dialogWidth:clientwidth;dialogHeight:' + height + 'px;dialogHide:true;help:no;scroll:yes')
	window.showModalDialog (urlStr,null,"dialogHeight: 200px; dialogWidth:200px; dialogTop: 1px; dialogLeft: 1px; center: Yes; help: No; resizable: No;status: No; edge: Raised;");
	return;
}

function openColorDialog(urlStr,x,y) {
	var retvall="";
	//retvall=window.showModalDialog (urlStr,null,"dialogHeight: 250px; dialogWidth:400px; dialogTop:' + y + 'px; dialogLeft:' + x + 'px; center: yes; help: No; resizable: No;status: No; edge: Raised;");
	//alert(x);
	//alert(y);
	retvall=window.showModalDialog (urlStr,null,"dialogHeight: 250px; dialogWidth:400px; dialogTop:" + y + "px; dialogLeft:" + x + "px; help: No; resizable: No;status: No; edge: Raised;");
	//retvall=window.showModalDialog (urlStr,null,"dialogHeight: 250px; dialogWidth:400px;center: yes; help: No; resizable: No;status: No; edge: Raised;");
	return retvall;
}

function startOpenWin(OpenWin)
{var desktop=window.open(OpenWin,"StyleMotorcycles","toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,width=100%,height=100%,resizable=yes");}

function fnTrapKD(btn){
    if (document.all){
	    if (event.keyCode == 13) { 
			event.returnValue=false;
	        event.cancel = true;
			btn.click();
		} 
    } 
}

function clearSelect() {
	var x = document.getElementsByTagName("input");
	for (i = 0; i < x.length; i++) {
		x[i].value = x[i].value;
	}
	
	var y = document.getElementsByTagName("textarea");
	for (i = 0; i < y.length; i++) {
		y[i].value = y[i].value;
	}
}

function PopupWindow2(strURL,intHeight,intWidth)
{
	var newWindow;
	var intTop= (screen.height - intHeight) / 2;
	var intLeft= (screen.width - intWidth) / 2;
	var props = 'scrollBars=yes,resizable=yes,toolbar=no,menubar=no,location=no,directories=no,width='+intWidth+',height='+intHeight+',left='+intLeft+',top='+intTop+'';
	newWindow = window.open(strURL, "Lookup", props);
}


function toNumeric(o) {
  if(/[^0-9]/.test(o.value)){
    o.value=o.value.replace(/([^0-9])/g,"");
  }
}

function toNumericAmount(o) {
  if(/[^0-9,.]/.test(o.value)){
    o.value=o.value.replace(/([^0-9,.])/g,"");
  }
}


function formatDouble(num)
{
  num=formatClean(num);
  return num;
}

function formatClean(num)
{
	var sVal='';
	var nVal = num.length;
	var sChar='';     
    try
	{
		for(i=0;i<nVal;i++)
		{
			sChar = num.charAt(i);
			nChar = sChar.charCodeAt(0);
			if (((nChar >=48) && (nChar <=57)) || (nChar == 46))  { sVal += num.charAt(i); }
		}
	}
	catch (exception) { alertError("Format Clean",e); }
	return sVal;
}

//agus menu format
function formatNumber(num)
{       
	var sVal='';
	var minus='';
	var CommaDelimiter=',';
	try 
	{			
        if (num.lastIndexOf("-") == 0) { minus='-'; }
		num = formatClean(num);
		numArr = num.split ('.');		    
		num = parseInt(numArr[0]);
		var samount = new String(num);
		for (var i = 0; i < Math.floor((samount.length-(1+i))/3); i++)
		{
			samount = samount.substring(0,samount.length-(4*i+3))+ CommaDelimiter + samount.substring(samount.length-(4*i+3));
		}
			
	}
	catch (exception) { alertError("Format Number",exception); }
	if (numArr[1] == null) { numArr[1]="00"; }
	return samount+"."+numArr[1];
}
// agus menu error
function alertError(MethodName,e)
{
	if (e.description == null) { alert(MethodName + " Exception: " + e.message); }
	else {  alert(MethodName + " Exception: " + e.description); }
}


function textCounter(field,maxlimit) {
	if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit);
}




