var isIE=(document.all)?true:false var isNav=(document.layers)?true:false var done if(isIE)done="Done" else done="Document: Done" //Remove string c from string s function removestr(s,c){ if(s.indexOf(c)==-1)return s return s.substring(0,s.indexOf(c))+s.substring(s.indexOf(c)+c.length,s.length) } //pic05.gif --> return 5 function denum(s){ return s.substring(s.length-5,s.length).substring(0,1) } function setCookie(name,value,expire){ var dt=new Date() if(expire==1)expire=new Date(dt.getDate()+"/"+dt.getMonth()+"/"+(dt.getFullYear()+1))//expire in 1 year document.cookie=name+"="+escape(value)+((udf(expire))?"":("; expires="+expire.toGMTString())) } function getCookie(Name){ var search=Name+"=" if(document.cookie.length>0){ offset=document.cookie.indexOf(search) if(offset!=-1){ offset+=search.length end=document.cookie.indexOf(";", offset) if(end==-1) end=document.cookie.length return unescape(document.cookie.substring(offset, end)) } } } function greeting(){ d('สวัสดีครับ') } function max(x,y){ if(x>y)return x return y } function min(x,y){ if(x") } //Check if x is integer, if signed is true, check for both negative and positive, otherwise check only positive function isInt(x,signed){ x=1*x return isFloat(x,signed) && (Math.floor(x)==x) } //Check if x is float, if signed is true, check for both negative and positive, otherwise check only positive function isFloat(x,signed){ x=1*x if(udf(signed))signed=false if(isNaN(x))return false if(!signed && x<0)return false return true } //Check for undefined function udf(x){ x=""+x if(x=="undefined")return true else return false } function formatnumber(num,f){ if(udf(f))f=2 var i,t t="1"; for(i=0;i3){ l=r.length; if(l>=3)r2=","+r.substring(r.length,r.length-(3))+r2; r=r.substring(0,r.length-(3)); } s=r+r2+s; var t="0"; for(i=f;i>0;i--){ if(s.indexOf(".")==s.length-i)s+=t; t+="0"; } if(s.indexOf(".")<=s.length-(f+2))s=s.substring(0,s.indexOf(".")+(1+f)); if(f==0)s=s.substring(0,s.length-1) return s; } //Round x to baht currency function baht(x){ if(isNaN(x)!=true){ var price="" if(x.indexOf(".")!=-1){ c=x.substring(x.indexOf("."),x.length) b=formatnumber(c,2) b=b.substring(b.indexOf(".")+1,b.length) a=x.substring(0,x.indexOf(".")) } else{a=x;b=""} if((b>0)&&(b<=25)) price=a+".25" else if((b>25)&&(b<=50)) price=a+".50" else if((b>50)&&(b<=75)) price=a+".75" else if((b>75)&&(b<=99)||(b==0)) price=(a*1+1) else price=a} return price=formatnumber(price,2) } //Split string x to array with delimiter de function split(x,de){ var temp=new Array var i=0 while(x.indexOf(de)!=-1){ temp[i++]=x.substring(0,x.indexOf(de)) x=x.substring(x.indexOf(de)+de.length,x.length) } temp[i]=x return temp } //Fill 0 in front of x, with total length is n function z(x,n){ if(udf(n))n=10 x=""+x var l=x.length for(var i=0;i