<!--
function ltrim ( s )
{
	return s.replace( /^\s*/, "" )
}

function rtrim ( s )
{
	return s.replace( /\s*$/, "" );
}


function trim ( s )
{
	return rtrim(ltrim(s));
}

function isNumeric(str)
{
  var len= str.length;
  if (len==0)
    return false;
  //else
  var p=0;
  var ok= true;
  var ch= "";
  while (ok && p<len)
  {
    ch= str.charAt(p);
    if ('0'<=ch && ch<='9')
      p++;
    else
      ok= false;
  }
  return ok;
}

function isFloat(val)
{
     if(val.indexOf(".")!=-1) return false;
     var template = "x.ff";
     nval = val.replace(",",".")/1;
     if(isNaN(nval)) return false;
     // we are sure that we have a numeric value, let's see if we can find a . somewhere
     if((pos=val.indexOf("."))>0)
     {
          templatepos = template.indexOf(".");
          tmpf = template.length-templatepos-1;
          valf = val.length-pos-1;
          if(valf>tmpf) return false;
          else return true;
     }
     return true;
}

function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	alert("Your email format is incorrect")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]
if (user.match(userPat)==null) {
    // user is not valid
    alert("Your email format is incorrect")
    return false
}
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Your email format is incorrect")
		return false
	    }
    }
    return true
}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("Your email format is incorrect")
    return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   alert("Your email format is incorrect")
   return false
}
if (len<2) {
   var errStr="Your email format is incorrect"
   alert(errStr)
   return false
}
return true;
}

function isEmpty(str)
{
	var temp;
	temp=trim(str)
	if (temp.length==0)
	{
		return true
	}else
	{
		return false
	}
}

//CHECK WHETHER THE TEXT LENGTH IN 'FIELD' EXCEEDED THE 'MAXLIMIT', N DISPLAY CHARACTER LEFT AT 'COUNTFIELD' 
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else 
countfield.value = maxlimit - field.value.length;
}

function confirmdelete()
{
var agree=confirm("Do you want to delete this data ?");
if (agree)
	return true ;
else
	return false ;
}

//CHECK WHETHER THE 'STR' IS EMPTY OR NOT,IF IT IS EMPTY THEN THE 'STRNAME' WILL BE ADDED TO THE  ERROR 'MESSAGE'
function validateString(message, str, strname){
	if (isEmpty(str))
	{
 		message=message+strname+", ";
	}
	return message
}

//DISPLAY ERROR 'MESSAGE' IF ERROR EXIST ('MESSAGE'<>' ') N CANCEL SUBMIT IF ERROR EXIST ('MESSAGE'<>' ' OR 'VALID'=FALSE)
function validationMessage(message,valid)
{
if ((message==" ") && (valid))
{
 return true; 
}
else
{
	if (message!=" ")
	{
		message=message.substring(0,message.length-2)
 		message="Please input the" + message;
 		alert(message);
 	}
 	return false;
 }
}

      
function ValidateSearch()
{
	valid=true
	pesan=" "
	temp=document.formSearch.SearchStr.value.toUpperCase()
	temp=rtrim(ltrim(temp))
	pesan=validateString(pesan,temp,"Search String")
	var rep1=/\bAND\b/
	var rep2=/\bOR\b/
	temp2=temp
	while (temp2.match(rep1)!=null)
	{
		temp2=temp2.replace(rep1,"")	
	}
	while (temp2.match(rep2)!=null)
	{
		temp2=temp2.replace(rep2,"")	
	}
	if ((!(isEmpty(temp))) && (isEmpty(temp2)))
	{
 		alert("Please input more words beside 'AND' and 'OR'")
 		valid=false;
	}
	return validationMessage(pesan,valid)
}

function isDate(dateStr) {

    var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
    var matchArray = dateStr.match(datePat); // is the format ok?

    if (matchArray == null) {
    		alert("Please enter date.");
        //alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
        return false;
    }

    day = matchArray[1]; // parse date into variables
    month = matchArray[3];
    //month = matchArray[1]; // parse date into variables
    //day = matchArray[3];
    year = matchArray[5];

    if (month < 1 || month > 12) { // check month range
        alert("Month must be between 1 and 12.");
        //alert("Month must be between 1 and 12.");
        return false;
    }

    if (day < 1 || day > 31) {
    	 	alert("Day must be between 1 and 31.");
        //alert("Day must be between 1 and 31.");
        return false;
    }

    if ((month==4 || month==6 || month==9 || month==11) && day==31) {
        alert("Month "+month+" doesn't have 31 days!")
        //alert("Month "+month+" doesn't have 31 days!")
        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!")
            //alert("February " + year + " doesn't have " + day + " days!");
            return false;
        }
    }

		if (!((year>=1753) && (year<=9999)))
		{
			alert("Year must be between 1753 and 9999");
			return false;
		}
    return true; // date is valid
}

function cOn(td){
if(document.getElementById||(document.all && !(document.getElementById))){
td.style.backgroundColor="#F1F1F1";
td.style.cursor="hand";
}
}
function cOut(td){
if(document.getElementById||(document.all && !(document.getElementById))){
td.style.backgroundColor="#FDFBFC";
td.style.cursor="hand";
}
}

function popUpEmail(emailPar) 
{ 
	var realHeight=390; 
	var realWidth=350; 
	var halfHeight=(realHeight/2); 
	var halfWidth=(realWidth/2); 
	var iMyWidth; 
	var iMyHeight; 
	var address='SalesEmail.asp'
	if(emailPar!='') address=address+'?id='+emailPar
	//gets top and left positions based on user's resolution so hint window is centered. 
	iMyWidth = (window.screen.width/2) - (halfWidth+ 10);//half the screen width minus half the new window width (plus 10 pixel borders). 
	iMyHeight = (window.screen.height/2) - (halfHeight + 27);  //half the screen height minus half the new window height (plus title and status bars). 
	var win2 = window.open(address,"submitWin","status=no,height=" + realHeight + ",width=" + realWidth + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no");
}

function popUpPic(picPar) 
{ 
	var realHeight=415; 
	var realWidth=385; 
	var halfHeight=(realHeight/2); 
	var halfWidth=(realWidth/2); 
	var iMyWidth; 
	var iMyHeight; 
	var address='NewsPic.asp?id='+picPar
	//gets top and left positions based on user's resolution so hint window is centered. 
	iMyWidth = (window.screen.width/2) - (halfWidth+ 10);//half the screen width minus half the new window width (plus 10 pixel borders). 
	iMyHeight = (window.screen.height/2) - (halfHeight + 27);  //half the screen height minus half the new window height (plus title and status bars). 
	var win2 = window.open(address,"submitWin","status=no,height=" + realHeight + ",width=" + realWidth + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no");
}

function updateStatus(statusObj,ID,linkStr)
{
	var status
	if (statusObj.checked)
	{
		status='y'
	}
	else
	{
		status='n'
	}
	if (confirm("This action will also effect other related data, Do you still want to continue?"))
	{	
		window.location.href=linkStr + "id=" + ID + "&status=" + status
	}
	else
	{
			if (statusObj.checked)
			{
				statusObj.checked=false
			}
			else
			{
				statusObj.checked=true
			}
	}
}

function toPrice(price)
	{
		var tempPrice=''+price
		var result=''
		var i
		for (var counter=0;counter<tempPrice.length;counter++)
		{
			i=tempPrice.length-1-counter
			result=tempPrice.substr(i,1) + result
			if (i!=tempPrice.length)
			{
				if ((counter+1)%3==0)
				{
					result="." + result
				}
			}
		}
		if (result.substr(0,1)==".")
		{
			result=result.substr(1,result.length-1)
		}
		return result
	}
	
	function toIndDecimal(Decimalnumber)
	{
		var TempDecimalnumber=''+Decimalnumber
		while (TempDecimalnumber.indexOf(".")!=-1)
		{
			TempDecimalnumber=TempDecimalnumber.replace(".",",")
		}
		return TempDecimalnumber
	}
	
	function toEngDecimal(Decimalnumber)
	{
		var TempDecimalnumber=Decimalnumber
		while (TempDecimalnumber.indexOf(",")!=-1)
		{
			TempDecimalnumber=TempDecimalnumber.replace(",",".")
		}
		return TempDecimalnumber*1
	}
	
	function transformDate(DateString)
	{
		if (DateString.length>0)
		{
			dateString=DateString.split("/")
			var tanggal=dateString[1]
			if (tanggal.length<2)	tanggal="0" + tanggal
			var bulan=dateString[0]
			if (bulan.length<2) bulan="0" + bulan
			var tahun=dateString[2]
			return tanggal + "/" + bulan + "/" + tahun
		}
	}

	function changeRowColor()
	{
		if (rowColor==rowColor1)
			rowColor=rowColor2
		else
			rowColor=rowColor1
	}
	
	function toNumeric(str)
	{
		while(str.indexOf(".")!=-1)
  	{
  		str=str.replace(".","")
  	}
  	return str*1
	}

function isNumeric2(str)
{
	while(str.indexOf(".")!=-1)
  	{
  		str=str.replace(".","")
  	}
  var len= str.length;
  if (len==0)
    return false;
  //else
  var p=0;
  var ok= true;
  var ch= "";
  while (ok && p<len)
  {
    ch= str.charAt(p);
    if ('0'<=ch && ch<='9')
      p++;
    else
      ok= false;
  }
  return ok;
}

function popUpSubmit() 
{ 
	var realHeight=1; 
	var realWidth=1; 
	var halfHeight=(realHeight/2); 
	var halfWidth=(realWidth/2); 
	var iMyWidth; 
	var iMyHeight; 
	//gets top and left positions based on user's resolution so hint window is centered. 
	iMyWidth = 2000//half the screen width minus half the new window width (plus 10 pixel borders). 
	iMyHeight = 2000 //half the screen height minus half the new window height (plus title and status bars). 
	var win2 = window.open('',"submitWin","status=no,height=" + realHeight + ",width=" + realWidth + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");
}

function popUpStock(link) 
{ 
	var realHeight=400; 
	var realWidth=650; 
	var halfHeight=(realHeight/2); 
	var halfWidth=(realWidth/2); 
	var iMyWidth; 
	var iMyHeight; 
	//gets top and left positions based on user's resolution so hint window is centered. 
	iMyWidth = (window.screen.width/2) - (halfWidth+ 10); //half the screen width minus half the new window width (plus 10 pixel borders). 
	iMyHeight = (window.screen.height/2) - (halfHeight + 27); //half the screen height minus half the new window height (plus title and status bars). 
	var win2 = window.open(link,"stockWin","status=yes,height=" + realHeight + ",width=" + realWidth + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");  win2.focus(); 
}

function popUpInput(link) 
{ 
	var realHeight=160; 
	var realWidth=435; 
	var halfHeight=(realHeight/2); 
	var halfWidth=(realWidth/2); 
	var iMyWidth; 
	var iMyHeight; 
	//gets top and left positions based on user's resolution so hint window is centered. 
	iMyWidth = (window.screen.width/2) - (halfWidth+ 10); //half the screen width minus half the new window width (plus 10 pixel borders). 
	iMyHeight = (window.screen.height/2) - (halfHeight + 27); //half the screen height minus half the new window height (plus title and status bars). 
	var win2 = window.open(link,"stockWin","status=yes,height=" + realHeight + ",width=" + realWidth + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");  win2.focus(); 
}

function popUpSerial(link) 
{ 
	var realHeight=400; 
	var realWidth=650; 
	var halfHeight=(realHeight/2); 
	var halfWidth=(realWidth/2); 
	var iMyWidth; 
	var iMyHeight; 
	//gets top and left positions based on user's resolution so hint window is centered. 
	iMyWidth = (window.screen.width/2) - (halfWidth+ 10); //half the screen width minus half the new window width (plus 10 pixel borders). 
	iMyHeight = (window.screen.height/2) - (halfHeight + 27); //half the screen height minus half the new window height (plus title and status bars). 
	var serialWin = window.open(link,"serialWin","status=yes,height=" + realHeight + ",width=" + realWidth + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");  serialWin.focus(); 
}

function popUpSerial2(link) 
{ 
	var realHeight=480; 
	var realWidth=400; 
	var halfHeight=(realHeight/2); 
	var halfWidth=(realWidth/2); 
	var iMyWidth; 
	var iMyHeight; 
	//gets top and left positions based on user's resolution so hint window is centered. 
	//iMyWidth = (window.screen.width/2) - (halfWidth+ 10); //half the screen width minus half the new window width (plus 10 pixel borders). 
	iMyWidth = 1; 
	iMyHeight = (window.screen.height/2) - (halfHeight + 27); //half the screen height minus half the new window height (plus title and status bars). 
	var serialWin = window.open(link,"serialWin","status=yes,height=" + realHeight + ",width=" + realWidth + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");  serialWin.focus(); 
}

function popUpItem(link) 
{ 
	var realHeight=400; 
	var realWidth=350; 
	var halfHeight=(realHeight/2); 
	var halfWidth=(realWidth/2); 
	var iMyWidth; 
	var iMyHeight; 
	//gets top and left positions based on user's resolution so hint window is centered. 
	iMyWidth = (window.screen.width/2) - (halfWidth+ 10); //half the screen width minus half the new window width (plus 10 pixel borders). 
	iMyHeight = (window.screen.height/2) - (halfHeight + 27); //half the screen height minus half the new window height (plus title and status bars). 
	var serialWin = window.open(link,"serialWin","status=yes,height=" + realHeight + ",width=" + realWidth + ",resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");  serialWin.focus(); 
}

//untuk hide certain tag object
   HM_DOM = document.getElementById ? true : false;
   HM_IE  = document.all ? true : false;
   HM_NS4 = document.layers ? true : false;

   function HM_f_ToggleElementList(show,elList,toggleBy) {
      if(!(HM_DOM||HM_IE||HM_NS4)) return true;

      if(HM_NS4&&(toggleBy=="tag")) return true;

      for(var i=0; i<elList.length; i++) {
         var ElementsToToggle = [];
         switch(toggleBy) {
            case "tag":
               ElementsToToggle = 
     (HM_DOM) ? document.getElementsByTagName(elList[i]) :
     document.all.tags(elList[i]);
               break;
            case "id":
               ElementsToToggle[0] = 
     (HM_DOM) ? document.getElementById(elList[i]) :
     (HM_IE) ? document.all(elList[i]) : 
     document.layers[elList[i]];
               break;
         }
         for(var j=0; j<ElementsToToggle.length; j++) {
            var theElement = ElementsToToggle[j];
            if(!theElement) continue;
            if(HM_DOM||HM_IE) {
               theElement.style.visibility = 
                  show ? "inherit" : "hidden";
            } else {
               theElement.visibility = 
                  show ? "inherit" : "hide";
            }
         }
      }
      return true;
   }
   
   
   function invisibleAll(eObj) {
		if (document.myForm.elements)
		{
			for (var d=0;d<document.myForm.elements.length;d++)
			{
				if (document.myForm.elements[d]!=eObj) 
				{
					if(HM_DOM||HM_IE)
					{
						document.myForm.elements[d].style.visibility='hidden'
					}
					else
					{
						document.myForm.elements[d].visibility='hide'
					}
				}
			}
		}
	}
	
	function visibleAll() {
		if (document.myForm.elements)
		{
			for (var d=0;d<document.myForm.elements.length;d++)
			{
					if(HM_DOM||HM_IE)
					{
						document.myForm.elements[d].style.visibility='inherit'
					}
					else
					{
						document.myForm.elements[d].visibility='inherit'
					}
						
			}
		}
	}
-->
