window.$K=(function(){'use strict';var domloaded=false;var $K={emptyFunction:function(){},resultFunction:function(){return true;},isMobile:function(){return(typeof window.orientation !=='undefined')||(navigator.userAgent.indexOf('IEMobile')!==-1);},init:function(element){forEach(element.querySelectorAll('input,textarea,select'),function(elem){var tagName=$G(elem).tagName.toLowerCase(),type=elem.get('type'),type=type?type.toLowerCase():'';if(elem.initObj !==true){if(tagName=='select'){elem.initObj=true;if(elem.get('checkbox')!==null){new GSelect(elem);}}else if(tagName=='textarea'||(type !=='hidden'&&type !=='radio'&&type !=='checkbox'&&type !=='button'&&type !=='submit')){var obj=new Object();obj.tagName=tagName;obj.type=type;elem.initObj=true;obj.title=elem.title;obj.required=elem.get('required');obj.disabled=elem.get('disabled')!==null;obj.maxlength=floatval(elem.get('maxlength'));obj.pattern=elem.get('pattern');if(obj.pattern !==null){obj.pattern=new RegExp('^(?:'+obj.pattern+')$');elem.setAttribute('pattern','(.*){0,}');}obj.dataset=elem.dataset;if(typeof obj.dataset=='undefined'){obj.dataset={};forEach(elem.attributes,function(){var hs=this.name.match(/^data\-(.+)/);if(hs){obj.dataset[hs[0]]=this.value;}});}if(obj.tagName=='textarea'){if(obj.maxlength>0||obj.required||obj.pattern){var _docheck=function(){if(this.value==''&&obj.required !==null){this.addClass('required');this.invalid(obj.title !==''?obj.title:trans('Please fill in')+(this.placeholder==''?'':' '+this.placeholder));}else if(this.value !=''&&obj.pattern&&!obj.pattern.test(this.value)){this.invalid(obj.title !==''?obj.title:trans('Invalid data'));}else if(obj.required !==null||obj.pattern){this.reset();}};elem.srcObj=obj;elem.addEvent('keyup',_docheck);elem.addEvent('change',_docheck);}}else if(obj.tagName=='input'){var c=elem.hasClass('currency number integer color inputgroup');if(c !==false){obj.type=c;}if(elem.min){obj.min=elem.min;}if(elem.max){obj.max=elem.max;}var autofocus=elem.get('autofocus'),text=elem;if(obj.type=='date'||obj.type=='datetime'){new GCalendar(elem);}else if(obj.dataset['keyboard']||obj.type=='number'||obj.type=='integer'||obj.type=='tel'||obj.type=='email'||obj.type=='url'||obj.type=='color'||obj.type=='currency'){var o={type:'text',name:elem.name,disabled:obj.disabled};if(elem.id !=''){o.id=elem.id;}text=$G().create('input',o);if(elem.value !=''){text.value=elem.value;}if(obj.title !=''){text.title=obj.title;}if(elem.size){text.size=elem.size;}if(elem.placeholder){text.placeholder=elem.placeholder;}if(obj.maxlength>0){text.maxlength=obj.maxlength;}if(elem.readOnly){text.readOnly=true;}if(obj.type=='currency'){text.digit=floatval(obj.dataset['digit']?obj.dataset['digit']:2);}text.className=elem.className;text.initObj=true;elem.replace(text);if(obj.type=='color'){new GDDColor(text,function(c){this.input.style.backgroundColor=c;this.input.style.color=this.invertColor(c);this.input.value=c;this.input.callEvent('change');});}else if(obj.type=='email'||obj.type=='url'){if(obj.pattern==null){if(obj.type=='email'){obj.pattern=/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/;}else{obj.pattern=/^[a-z0-9\-\.:\/\#%\?\&\=_@~]{3,}$/i;}}text.addEvent('keyup',_docheck);text.addEvent('change',_docheck);}else{if(!obj.dataset['keyboard']){if(obj.type=='integer'){obj.dataset['keyboard']='1234567890-';}else if(obj.type=='currency'){obj.dataset['keyboard']='1234567890.,';}else if(obj.type=='number'||obj.type=='tel'){obj.dataset['keyboard']='1234567890';}}if(obj.dataset['keyboard']){obj.pattern=new RegExp('^(?:['+obj.dataset['keyboard'].preg_quote()+']+)$');if(obj.type=='integer'||obj.type=='currency'||obj.type=='number'){new GInput(text,obj.dataset['keyboard'],function(){if(obj.min){this.value=Math.max(obj.min,floatval(this.value));}if(obj.max){this.value=Math.min(obj.max,floatval(this.value));}if(obj.type=='currency'){this.value=toCurrency(this.value,this.digit);}});}else{new GInput(text,obj.dataset['keyboard']);}}}}else if(obj.type=='file'){if(elem.hasClass('g-file')){var p=elem.parentNode;elem.setStyle('opacity',0);elem.style.cursor='pointer';elem.style.position='absolute';elem.style.left=0;elem.style.top=1;p.style.position='relative';var display=document.createElement('input');display.setAttribute('type','text');display.id=elem.id;elem.id=elem.id+'_tmp';display.disabled=true;display.placeholder=elem.placeholder;p.appendChild(display);elem.style.zIndex=text.style.zIndex+1;elem.style.height='100%';elem.style.width='100%';elem.addEvent('change',function(){if(this.files){var input=this,hs,files=[],preview=$E(this.get('data-preview')),max=floatval(input.get('data-max')),validImageTypes=['image/gif','image/jpeg','image/jpg','image/png'];if(preview){preview.innerHTML='';}forEach(input.files,function(){if(max>0&&this.size>max){input.invalid(input.title);}else{files.push(this.name);input.valid();if(preview){hs=/\.([a-z0-9]+)$/.exec(this.name.toLowerCase());var div=document.createElement('div');div.className='file-thumb';if(hs){div.innerHTML=hs[1];}preview.appendChild(div);if(validImageTypes.includes(this.type)&&window.FileReader){var r=new FileReader();r.onload=function(evt){div.innerHTML='';div.style.backgroundImage='url('+evt.target.result+')';};r.readAsDataURL(this);}}}});display.value=files.join(',');$G(display).callEvent('change',{value:this.value,files:this.files});}});elem.initObj=true;}}else if(obj.type=='range'){new GRange(elem);}else if(obj.type=='inputgroup'){new GInputGroup(elem);}else if(elem.get('list')){new Datalist(elem);}else if(obj.pattern){new GMask(text,function(){return obj.pattern.test(this.value);});}if(elem.hasClass('showpassword')!==false){var span=document.createElement('span');text.parentNode.appendChild(span);span.onclick=function(){var type=text.getAttribute('type')==='password'?'text':'password';text.setAttribute('type',type);};}if(typeof obj.dataset !=='undefined'){for(var prop in obj.dataset){if(obj.dataset[prop] !==null){text.setAttribute('data-'+prop,obj.dataset[prop]);}}}if(autofocus !==null){text.focus();if(obj.type=='text'){text.select();}}if(obj.pattern||obj.required){text.srcObj=obj;}}}}});var checkbox_loading=true,wCheckboxChanged=function(e){this.checkId.disabled=!this.checked;if(!checkbox_loading&&this.checked){this.checkId.focus();}};forEach(element.querySelectorAll('.w_checkbox input[type=checkbox]'),function(elem){if(!elem.checkId){var id=elem.name.replace('checkbox_','').replace('[','').replace(']','');if($E(id)){elem.checkId=$E(id);$G(elem).addEvent('change',wCheckboxChanged);wCheckboxChanged.call(elem);}}});window.setTimeout(function(){checkbox_loading=false;},1);}};if(typeof Array.prototype.indexOf !='function'){Array.prototype.indexOf=function(t,i){i||(i=0);var l=this.length;if(i<0){i=l+i;}for(;i<l;i++){if(this[i]==t){return i;}}return-1;};}if(typeof forEach !='function'){window.forEach=function(a,f){var i,l=a.length,x=[];for(i=0;i<l;i++){x.push(a[i]);}for(i=0;i<l;i++){if(f.call(x[i],x[i],i)==true){break;}}};}window.floatval=function(val){var n=parseFloat(typeof val=='string'?val.replace(/[^0-9\-\.]/g,''):val);return isNaN(n)?0:n;};window.toCurrency=function(val,digit,zero){if(typeof digit=='undefined'){val=floatval(val).toFixed(2);}else if(typeof digit=='number'){val=floatval(val).toFixed(digit);}else if(typeof val=='number'){val=new String(floatval(val));}var ds=val.split('.'),val=ds[0].replace(/(\d)(?=(\d{3})+(?!\d))/g,'$1,');if(zero&&/[0]+/g.test(ds[1])){ds[1]=null;}return val+(ds[1]?'.'+ds[1]:'');};window.round=function(val,digit){var value=Math.round(val*Math.pow(10,digit))/ Math.pow(10,digit);if(val-value>0){return value+Math.floor((2*Math.round((val-value)*Math.pow(10,digit+1)))/ 10)/ Math.pow(10,digit);}else{return value;}};window.copyToClipboard=function(text){var el=document.createElement('textarea');el.value=text;el.setAttribute('readonly','');el.style.position='absolute';el.style.top='-1000px';document.body.appendChild(el);el.select();document.execCommand('copy');document.body.removeChild(el);};window.trans=function(val){try{var patt=/^[_]+|[_]+$/g;return eval(val.replace(/[\s]/g,'_').replace('?','').replace(patt,'').toUpperCase());}catch(e){return val;}};window.jsonToParams=function(json,separator){var ret=[];for(var k in json){ret.push(k+'='+json[k]);}return ret.join(separator?separator:'&');};window.jwt_decode=function(token){var base64Url=token.split('.')[1],base64=base64Url.replace(/-/g,'+').replace(/_/g,'/'),jsonPayload=decodeURIComponent(atob(base64).split("").map(function(c){return "%"+("00"+c.charCodeAt(0).toString(16)).slice(-2);}).join(""));return JSON.parse(jsonPayload);};window.debug=function(val){var p=document.createElement('p'),div=$E('gdebug');if(!div){div=document.createElement('div');div.id='gdebug';document.body.appendChild(div);div.style.cssText='left:0;bottom:0;width:100%;height:100px;color:#F00;background-color:#FFF;position:fixed;line-height:1;padding:10px;overflow:auto;';}p.style.cssText='margin:0;';p.innerText=val;div.appendChild(p);div.scrollTop=div.scrollHeight;};window.timeToMinute=function(time){var sp=time.split(':');if(sp.length==1){return 0;}else{return(floatval(sp[0])*60)+floatval(sp[1]);}};window.timeToSecond=function(time){var sp=time.split(':');if(sp.length==1){return 0;}else{return(floatval(sp[0])*60)+(floatval(sp[1]*60)+floatval(sp[2]));}};Function.prototype.bind=function(o){var __method=this;return function(){return __method.apply(o,arguments);};};Date.prototype.fromTime=function(mktime){return new Date(mktime*1000);};Date.prototype.format=function(fmt){var result='';for(var i=0;i<fmt.length;i++){result+=this.formatter(fmt.charAt(i));}return result;};Date.prototype.formatter=function(c){switch(c){case 'd':return this.getDate().toString().leftPad(2,'0');case 'D':return Date.dayNames[this.getDay()];case 'y':return this.getFullYear().toString();case 'Y':return(this.getFullYear()+Date.yearOffset).toString();case 'm':return(this.getMonth()+1).toString().leftPad(2,'0');case 'M':return Date.monthNames[this.getMonth()];case 'F':return Date.longMonthNames[this.getMonth()];case 'H':return this.getHours().toString().leftPad(2,'0');case 'h':return this.getHours();case 'A':return this.getHours()<12?'AM':'PM';case 'a':return this.getHours()<12?'am':'pm';case 'I':return this.getMinutes().toString().leftPad(2,'0');case 'i':return this.getMinutes();case 'S':return this.getSeconds().toString().leftPad(2,'0');case 's':return this.getSeconds();default:return c;}};Date.prototype.tomktime=function(){return Math.floor(this.getTime()/ 1000);};Date.prototype.moveDate=function(value){this.setDate(this.getDate()+value);return this;};Date.prototype.moveMonth=function(value){this.setMonth(this.getMonth()+value);return this;};Date.prototype.moveYear=function(value){this.setFullYear(this.getFullYear()+value);return this;};Date.prototype.isLeapYear=function(){var year=this.getFullYear();return(year&3)==0&&(year % 100||(year % 400==0&&year));};Date.prototype.daysInMonth=function(){var arr=Array(31,28,31,30,31,30,31,31,30,31,30,31);arr[1]=this.isLeapYear()?29:28;return arr[this.getMonth()];};Date.prototype.dayOfWeek=function(){var a=parseInt((14-this.getMonth())/ 12);var y=this.getFullYear()-a;var m=this.getMonth()+12*a-2;var d=(this.getDate()+y+parseInt(y / 4)-parseInt(y / 100)+parseInt(y / 400)+parseInt((31*m)/ 12))% 7;return d;};Date.prototype.compare=function(d){if(Object.isString(d)){d=new Date(d.replace(/-/g,'/'));}var days=Math.floor((this.getTime()-d.getTime())/ 86400000),numDays=[31,28,31,30,31,30,31,31,30,31,30,31];if(days<0){var fromDate=this.getDate(),fromMonth=this.getMonth(),fromYear=this.getFullYear(),toDate=d.getDate(),toMonth=d.getMonth(),toYear=d.getFullYear();if(d.isLeapYear()){numDays[1]=29;}}else{var fromDate=d.getDate(),fromMonth=d.getMonth(),fromYear=d.getFullYear(),toDate=this.getDate(),toMonth=this.getMonth(),toYear=this.getFullYear();if(this.isLeapYear()){numDays[1]=29;}}var diffYear=toYear-fromYear,diffMonth=toMonth-fromMonth,diffDate=toDate-fromDate;if(diffDate<0){diffMonth--;toMonth=toMonth==0?11:toMonth-1;diffDate=numDays[toMonth]+diffDate;}if(diffMonth<0){diffYear--;diffMonth=12+diffMonth;}return{day:diffDate,month:diffMonth,year:diffYear,days:days};};Date.monthNames=[ 'Jan.','Feb.','Mar.','Apr.','May.','Jun.','Jul.','Aug.','Sep.','Oct.','Nov.','Dec.' ];Date.longMonthNames=[ 'January','February','March','April','May','June','July','August','September','October','November','December' ];Date.longDayNames=[ 'Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday' ];Date.dayNames=['Su.','Mo.','We.','Tu.','Th.','Fr.','Sa.'];Date.yearOffset=0;String.prototype.entityify=function(){return this.replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;').replace(/'/g,'&#39;').replace(/\\/g,'&#92;').replace(/\//g,'&#47;').replace(/&/g,'&amp;').replace(/\{/g,'&#x007B;').replace(/\}/g,'&#x007D;');};String.prototype.unentityify=function(){return this.replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&quot;/g,'"').replace(/&#[0]?39;/g,"'").replace(/&#92;/g,'\\').replace(/&#47;/g,'/').replace(/&amp;/g,'&').replace(/&#x007B;/g,'{').replace(/&#x007D;/g,'}');};String.prototype.toJSON=function(){try{var datas=JSON.parse(this);return typeof datas==='object'?datas:false;}catch(e){return false;}};String.prototype.toInt=function(){return floatval(this);};String.prototype.currFormat=function(){return floatval(this).toFixed(2);};String.prototype.preg_quote=function(){return this.replace(/([-.*+?^${}()|[\]\/\\])/g,'\\$1');};String.prototype.capitalize=function(){return this.replace(/\b[a-z]/g,function(m){return m.toUpperCase();});};String.prototype.evalScript=function(){var regex=/<script.*?>(.*?)<\/script>/g;var t=this.replace(/[\r\n]/g,'').replace(/\/\/<\!\[CDATA\[/g,'').replace(/\/\/\]\]>/g,'');var m=regex.exec(t);while(m){try{eval(m[1]);}catch(e){}m=regex.exec(t);}return this;};String.prototype.leftPad=function(c,f){var r='';for(var i=0;i<c-this.length;i++){r=r+f;}return r+this;};String.prototype.trim=function(){return this.replace(/^(\s|&nbsp;)+|(\s|&nbsp;)+$/g,'');};String.prototype.ltrim=function(){return this.replace(/^(\s|&nbsp;)+/,'');};String.prototype.rtrim=function(){return this.replace(/(\s|&nbsp;)+$/,'');};String.prototype.strip_tags=function(allowed){allowed=(((allowed||'')+'').toLowerCase().match(/<[a-z][a-z0-9]*>/g)||[]).join('');var tags=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;var php=/<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;return this.replace(php,'').replace(tags,function($0,$1){return allowed.indexOf('<'+$1.toLowerCase()+'>')>-1?$0:'';});};String.prototype.toDOM=function(){var s=function(a){return a .replace(/&gt;/g,'>').replace(/&lt;/g,'<').replace(/&nbsp;/g,' ').replace(/&quot;/g,'"').replace(/&#[0]?39;/g,"'").replace(/&#92;/g,'\\').replace(/&amp;/g,'&');};var t=function(a){return a.replace(/ /g,'');};var u=function(a){var b=document.createDocumentFragment();var c=a.indexOf(' ');if(c==-1){var d=a.toLowerCase();b.appendChild(document.createElement(d));}else{d=t(a.substring(0,c)).toLowerCase();if(document.all&&(d=='input'||d=='iframe')){try{b.appendChild(document.createElement('<'+a+'/>'));return b;}catch(e){}}a=a.substring(c+1);b.appendChild(document.createElement(d));while(a.length>0){var e=a.indexOf('=');if(e>=0){var f=t(a.substring(0,e)).toLowerCase();var g=a.indexOf('"');a=a.substring(g+1);g=a.indexOf('"');var h=s(a.substring(0,g));a=a.substring(g+2);if(document.all&&f=='style'){b.lastChild.style.cssText=h;}else if(f=='class'){b.lastChild.className=h;}else{b.lastChild.setAttribute(f,h);}}else{break;}}}return b;};var v=function(a,b,c){var d=a;var e=b;c=c.toLowerCase();var f=e.indexOf('</'+c+'>');d=d.concat(e.substring(0,f));e=e.substring(f);while(d.indexOf('<'+c)!=-1){d=d.substring(d.indexOf('<'+c));d=d.substring(d.indexOf('>')+1);e=e.substring(e.indexOf('>')+1);f=e.indexOf('</'+c+'>');d=d.concat(e.substring(0,f));e=e.substring(f);}return b.length-e.length;};var w=function(a){var b=document.createDocumentFragment();while(a&&a.length>0){var c=a.indexOf('<');if(c==-1){a=s(a);b.appendChild(document.createTextNode(a));a=null;}if(c>0){var d=s(a.substring(0,c));b.appendChild(document.createTextNode(d));a=a.substring(c);}if(c==0){var e=a.indexOf('<!--');if(e==0){var f=a.indexOf('-->');var g=a.substring(4,f);g=s(g);b.appendChild(document.createComment(g));a=a.substring(f+3);}else{var h=a.indexOf('>');if(a.substring(h-1,h)=='/'){var i=a.indexOf('/>');var j=a.substring(1,i);b.appendChild(u(j));a=a.substring(i+2);}else{var k=a.indexOf('>');var l=a.substring(1,k);var m=document.createDocumentFragment();m.appendChild(u(l));a=a.substring(k+1);var n=a.substring(0,a.indexOf('</'));a=a.substring(a.indexOf('</'));if(n.indexOf('<')!=-1){var o=m.lastChild.nodeName;var p=v(n,a,o);n=n.concat(a.substring(0,p));a=a.substring(p);}a=a.substring(a.indexOf('>')+1);m.lastChild.appendChild(w(n));b.appendChild(m);}}}}return b;};return w(this);};String.prototype.toDate=function(){var patt=/(([0-9]{4,4})-([0-9]{1,2})-([0-9]{1,2})(\s([0-9]{1,2}):([0-9]{1,2})(:([0-9]{1,2}))?)?|today|tomorrow|yesterday)([\s]{0,}([+-])[\s]{0,}([0-9]+))?/,hs=patt.exec(this),d;if(hs){if(typeof hs[2]=='undefined'){d=new Date();}else{d=new Date(floatval(hs[2]),floatval(hs[3])-1,hs[4],floatval(hs[6]),floatval(hs[7]),floatval(hs[9]),0);}if(hs[1]=='yesterday'){d.setDate(d.getDate()-1);}else if(hs[1]=='tomorrow'){d.setDate(d.getDate()+1);}if(hs[11]=='+'&&floatval(hs[12])>0){d.setDate(d.getDate()+floatval(hs[12]));}else if(hs[11]=='-'&&floatval(hs[12])>0){d.setDate(d.getDate()-floatval(hs[12]));}return d;}else{return null;}};Number.prototype.format=function(decimals,dec_point,thousands_sep){decimals=isNaN((decimals=Math.abs(decimals)))?2:decimals;dec_point=dec_point==undefined?'.':dec_point;thousands_sep=thousands_sep==undefined?',':thousands_sep;var n=this,s=n<0?'-':'',i=String(parseInt((n=Math.abs(Number(n)||0).toFixed(decimals)))),j=(j=i.length)>3?j % 3:0;return(s+(j?i.substr(0,j)+thousands_sep:'')+i.substr(j).replace(/(\d{3})(?=\d)/g,'$1'+thousands_sep)+(decimals?dec_point+Math.abs(n-i).toFixed(decimals).slice(2):''));};document.viewport={getWidth:function(){return(document.documentElement.clientWidth||document.body.clientWidth||self.innerWidth);},getHeight:function(){return(document.documentElement.clientHeight||document.body.clientHeight||self.innerHeight);},getscrollTop:function(){return(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop);},getscrollLeft:function(){return(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft);}};document.css=function(css,id){var style=document.createElement('style');if(id){style.id='css_'+id;if($E('css_'+id)){$E('css_'+id).parentNode.removeChild($E('css_'+id));}}if(css !==null){if(style.styleSheet){style.styleSheet.cssText=css;}else{style.appendChild(document.createTextNode(css));}document.getElementsByTagName('head')[0].appendChild(style);}};Object.extend=function(d,s){for(var property in s){d[property]=s[property];}return d;};Object.extend(Object,{isObject:function(o){return typeof o=='object';},isFunction:function(o){return typeof o=='function';},isString:function(o){return typeof o=='string';},isNumber:function(o){return typeof o=='number';},isNull:function(o){return typeof o=='undefined';},isGElement:function(o){return(o !=null&&typeof o=='object'&&'Ready' in o&&'element' in o);},toArray:function(o){var prop,result=[];for(prop in o){result.push(o[prop]);}return result;}});window.GClass={create:function(){return function(){this.initialize.apply(this,arguments);};}};window.GNative=GClass.create();GNative.prototype={initialize:function(){this.elem=null;},Ready:function(f){var s=this;var p=function(){if(domloaded&&s.element()){f.call($G(s.elem));}else{window.setTimeout(p,10);}};p();},after:function(e){var p=this.parentNode;if(this.nextSibling==null){p.appendChild(e);}else{p.insertBefore(e,this.nextSibling);}return e;},before:function(e){var p=this.parentNode;if(p.firstChild==this){p.appendChild(e);}else{p.insertBefore(e,this);}return e;},insert:function(e){e=$G(e);this.appendChild(e);return e;},copy:function(o){return $G(this.cloneNode(o||true));},replace:function(e){var p=this.parentNode;p.insertBefore(e,this.nextSibling);p.removeChild(this);return $G(e);},remove:function(){if(this.element()){this.parentNode.removeChild(this);}return this;},setHTML:function(o){try{this.innerHTML=o;}catch(e){o=o .replace(/[\r\n\t]/g,'').replace(/<script[^>]*>.*?<\/script>/gi,'');this.appendChild(o.toDOM());}return this;},getTop:function(){return this.viewportOffset().top;},getLeft:function(){return this.viewportOffset().left;},getWidth:function(){return this.getDimensions().width;},getHeight:function(){return this.getDimensions().height;},getClientWidth:function(){return(this.clientWidth-parseInt(this.getStyle('paddingLeft'))-parseInt(this.getStyle('paddingRight')));},getClientHeight:function(){return(this.clientHeight-parseInt(this.getStyle('paddingTop'))-parseInt(this.getStyle('paddingBottom')));},viewportOffset:function(){var t=0,l=0,p=this;while(p){t+=parseInt(p.offsetTop);l+=parseInt(p.offsetLeft);p=p.offsetParent;}if(this.getBoundingClientRect){return{top:t,left:this.getBoundingClientRect().left};}else{return{top:t,left:l};}},getDimensions:function(){var ow,oh;if(this==document){ow=Math.max(Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),Math.max(document.body.offsetWidth,document.documentElement.offsetWidth),Math.max(document.body.clientWidth,document.documentElement.clientWidth));oh=Math.max(Math.max(document.body.scrollHeight,document.documentElement.scrollHeight),Math.max(document.body.offsetHeight,document.documentElement.offsetHeight),Math.max(document.body.clientHeight,document.documentElement.clientHeight));}else{var d=this.getStyle('display');if(d !='none'&&d !==null){ow=this.offsetWidth;oh=this.offsetHeight;}else{var s=this.style;var ov=s.visibility;var op=s.position;var od=s.display;s.visibility='hidden';s.position='absolute';s.display='block';ow=this.clientWidth;oh=this.clientHeight;s.display=od;s.position=op;s.visibility=ov;}}return{width:ow,height:oh};},getOffsetParent:function(){var e=this.offsetParent;if(!e){e=this.parentNode;while(e !=document.body&&e.style.position=='static'){e=e.parentNode;}}return GElement(e);},getCaretPosition:function(){if(document.selection){var range=document.selection.createRange(),textLength=range.text.length;range.moveStart('character',-this.value.length);var caretAt=range.text.length;return{start:caretAt,end:caretAt+textLength};}else if(this.selectionStart||this.selectionStart=='0'){return{start:this.selectionStart,end:this.selectionEnd};}},setCaretPosition:function(start,length){if(this.setSelectionRange){this.focus();this.setSelectionRange(start,start+length);}else if(this.createTextRange){var range=this.createTextRange();range.collapse(true);range.moveEnd('character',start+length);range.moveStart('character',start);range.select();}return this;},getStyle:function(s){s=s=='float'&&this.currentStyle?'styleFloat':s;s=s=='borderColor'?'borderBottomColor':s;var v=this.currentStyle?this.currentStyle[s]:null;v=!v&&window.getComputedStyle?document.defaultView.getComputedStyle(this,null).getPropertyValue(s.replace(/([A-Z])/g,'-$1').toLowerCase()):v;if(s=='opacity'){return Object.isNull(v)?100:floatval(v)*100;}else{return v;}},setStyle:function(p,v){if(p=='opacity'){if(window.ActiveXObject){this.style.filter='alpha(opacity='+v*100+')';}this.style.opacity=v;}else if(p=='float'||p=='styleFloat'||p=='cssFloat'){if(Object.isNull(this.style.styleFloat)){this.style['cssFloat']=v;}else{this.style['styleFloat']=v;}}else if(p=='backgroundColor'&&this.tagName.toLowerCase()=='iframe'){if(document.all){this.contentWindow.document.bgColor=v;}else{this.style.backgroundColor=v;}}else if(p=='borderColor'){this.style.borderLeftColor=v;this.style.borderTopColor=v;this.style.borderRightColor=v;this.style.borderBottomColor=v;}else{this.style[p]=v;}return this;},center:function(){var size=this.getDimensions();if(this.getStyle('position')=='fixed'){this.style.top=(document.viewport.getHeight()-size.height)/ 2+'px';this.style.left=(document.viewport.getWidth()-size.width)/ 2+'px';}else{this.style.top=document.viewport.getscrollTop()+(document.viewport.getHeight()-size.height)/ 2+'px';this.style.left=document.viewport.getscrollLeft()+(document.viewport.getWidth()-size.width)/ 2+'px';}return this;},get:function(p){try{return this.getAttribute(p);}catch(e){return null;}},set:function(p,v){try{this.setAttribute(p,v);}catch(e){}return this;},hasClass:function(v){var vs=v.split(' ');var cs=this.className.split(' ');for(var c=0;c<cs.length;c++){for(v=0;v<vs.length;v++){if(vs[v] !=''&&vs[v]==cs[c]){return vs[v];}}}return false;},addClass:function(v){if(this.className||this.className===''){if(!v){this.className='';}else{var rm=v.split(' '),cs=[];forEach(this.className.split(' '),function(c){if(c !==''&&rm.indexOf(c)==-1){cs.push(c);}});cs.push(v);this.className=cs.join(' ');}}return this;},removeClass:function(v){if(this.className||this.className===''){var rm=v.split(' ');var cs=[];forEach(this.className.split(' '),function(c){if(c !==''&&rm.indexOf(c)==-1){cs.push(c);}});this.className=cs.join(' ');}return this;},replaceClass:function(source,replace){if(this.className||this.className===''){var rm=(replace+' '+source).split(' ');var cs=[];forEach(this.className.split(' '),function(c){if(c !==''&&rm.indexOf(c)==-1){cs.push(c);}});cs.push(replace);this.className=cs.join(' ');}return this;},hide:function(){this.display=this.getStyle('display');this.setStyle('display','none');return this;},show:function(){if(this.getStyle('display')=='none'){this.setStyle('display','block');}return this;},visible:function(){return this.getStyle('display')!='none';},toggle:function(){if(this.visible()){this.hide();}else{this.show();}return this;},nextNode:function(){var n=this;do{n=n.nextSibling;}while(n&&n.nodeType !=1);return n;},previousNode:function(){var p=this;do{p=p.previousSibling;}while(p&&p.nodeType !=1);return p;},firstNode:function(){var p=this.firstChild;do{p=p.nextSibling;}while(p&&p.nodeType !=1);return p;},nextTab:function(){var tag,result,self=this,check=null;forEach(document.forms,function(){return forEach(this.getElementsByTagName('*'),function(){if(this==self.elem){check=this;}else if(check !=null){if(this.tabIndex>=0&&this.disabled !=true&&this.style.display !='none'&&this.offsetParent !=null){result=this;return true;}}});});return result;},sendKey:function(keyCode){return this.callEvent('keypress',{keyCode:keyCode});},callEvent:function(t,params){var evt;if(document.createEvent){evt=document.createEvent('Events');evt.initEvent(t,true,true);for(var prop in params){evt[prop]=params[prop];}this.dispatchEvent(evt);}else if(document.createEventObject){evt=document.createEventObject();for(var prop in params){evt[prop]=params[prop];}this.fireEvent('on'+t,evt);}return this;},addEvent:function(t,f,c){var ts=t.split(/[\s,]/g),input=this;forEach(ts,function(e){if(input.addEventListener){c=!c?false:c;input.addEventListener(e,f,c);}else if(input.attachEvent){input['e'+e+f]=f;input[e+f]=function(){input['e'+e+f](window.event);};input.attachEvent('on'+e,input[e+f]);}});return this;},removeEvent:function(t,f,c){var ts=t.split(/[\s,]/g),input=this;forEach(ts,function(e){if(input.removeEventListener){c=!c?false:c;input.removeEventListener(e=='mousewheel'&&window.gecko?'DOMMouseScroll':e,f,c);}else if(input.detachEvent){input.detachEvent('on'+e,input[e+f]);input['e'+e+f]=null;input[e+f]=null;}});return this;},highlight:function(o){this.addClass('highlight');var self=this;window.setTimeout(function(){self.removeClass('highlight');},1);return this;},fadeIn:function(oncomplete){this.addClass('fadein');var self=this;window.setTimeout(function(){self.removeClass('fadein');if(Object.isFunction(oncomplete)){oncomplete.call(this);}},1000);return this;},fadeOut:function(oncomplete){this.addClass('fadeout');var self=this;window.setTimeout(function(){self.removeClass('fadeout');if(Object.isFunction(oncomplete)){oncomplete.call(this);}},1000);return this;},setValue:function(v){function _find(e,a){var s=e.getElementsByTagName('option');for(var i=0;i<s.length;i++){if(s[i].value==a){return i;}}return-1;}if(this.time){this.time.setTime(v);}else if(this.calendar){this.value=v;}else if(this.datalist){this.selectedIndex=v;}else{v=decodeURIComponent(v);var t=this.tagName.toLowerCase();if(t=='img'){this.src=v;}else if(t=='select'){this.selectedIndex=_find(this,v);}else if(t=='input'){if(this.type=='checkbox'||this.type=='radio'){this.checked=v==this.value;}else{this.value=v.unentityify();}}else if(t=='textarea'){this.value=v.unentityify();}else{this.setHTML(v);}}return this;},getText:function(){if(!Object.isNull(this.elem.selectedIndex)){if(this.elem.selectedIndex==-1){return null;}return this.elem.options[this.elem.selectedIndex].text;}else if(this.elem.innerHTML){return this.elem.innerHTML;}return this.elem.value;},setOptions:function(json,value){if(this.tagName.toLowerCase()=='select'){for(var i=this.options.length;i>0;i--){this.removeChild(this.options[i-1]);}var selectedIndex=0;if(json){var i=0;for(var key in json){if(key==value){selectedIndex=i;}var option=document.createElement('option');option.innerHTML=json[key];option.value=key;this.appendChild(option);i++;}}this.selectedIndex=selectedIndex;}},getSelectedText:function(){var text='';if(this.selectionStart){if(this.selectionStart !=this.selectionEnd){text=this.value.substring(this.selectionStart,this.selectionEnd);}}else if(document.selection){var range=document.selection.createRange();if(range.parentElement()===this){text=range.text;}}return text;},setSelectedText:function(value){if(this.selectionStart){if(this.selectionStart !=this.selectionEnd){this.value=this.value.substring(0,this.selectionStart)+value+this.value.substring(this.selectionEnd);}}else{var range=document.selection.createRange();if(range.parentElement()===this){range.text=value;}}return this;},findLabel:function(){var result=null,id=this.id;forEach(document.getElementsByTagName('label'),function(){if(this.htmlFor !=''&&this.htmlFor==id){result=this;return true;}});return result;},element:function(){return Object.isString(this.elem)?document.getElementById(this.elem):this.elem;},elems:function(tagname){return this.getElementsByTagName(tagname);},create:function(tagname,o){var v;if(tagname=='iframe'||tagname=='input'){var n=o.name||o.id||'';var i=o.id||o.name||'';if(window.ActiveXObject){try{if(tagname=='iframe'){v=document.createElement('<iframe id="'+i+'" name="'+n+'" scrolling="no" />');}else{v=document.createElement('<input id="'+i+'" name="'+n+'" type="'+o.type+'" />');}}catch(e){v=document.createElement(tagname);v.name=n;v.id=i;}}else{v=document.createElement(tagname);v.name=n;v.id=i;}}else{v=document.createElement(tagname);}if(this.elem){this.appendChild(v);}for(var p in o){v[p]=o[p];}return $G(v);},msgBox:function(value,className,autohide,id){var parent,parent_id=id?id+'_parent':'body_msg_div_parent';if($E(parent_id)){parent=$E(parent_id);}else{parent=document.createElement('div');parent.id=parent_id;parent.className='msgbox';this.elem.appendChild(parent);}if(value&&value !=''){var div,innerDiv;if(id&&$E(id)){innerDiv=$E(id);div=innerDiv.parentNode;}else{div=document.createElement('div');innerDiv=document.createElement('div');if(id){innerDiv.id=id;}var span=document.createElement('span');span.innerHTML='&times;';span.className='closebtn';div.appendChild(span);div.appendChild(innerDiv);parent.appendChild(div);}div.className='alert '+(className||'message');innerDiv.innerHTML=value;}forEach(parent.getElementsByClassName('closebtn'),function(){if(this.onclick===null){var span=this;span.onclick=function(){var parent=this.parentNode;parent.style.opacity='0';if(this.timer){clearTimeout(this.timer);}setTimeout(function(){parent.remove();},600);};if(typeof autohide==='undefined'||autohide===true){span.timer=setTimeout(function(){span.click();},3000);}}});},valid:function(className){if(this.ret){if(this.ret.hasClass('validationResult')){this.ret.remove();this.ret=false;}else{this.ret.replaceClass('invalid','valid');this.ret.innerHTML=this.retDef?this.retDef:'';}}this.replaceClass('invalid wait','valid'+(className?' '+className:''));return this;},invalid:function(value,className){if(!this.ret){if(typeof this.dataset !=='undefined'&&typeof this.dataset.result==='string'&&this.dataset.result !==''&&$E(this.dataset.result)){this.ret=$G(this.dataset.result);}else{var id=this.id||this.name;if($E('result_'+id)){this.ret=$G('result_'+id);}}if(this.ret&&!this.retDef){this.retDef=this.ret.innerHTML;}}if(this.ret){if(value&&value !=''){this.ret.innerHTML=value;}this.ret.replaceClass('valid','invalid'+(className?' '+className:''));}this.replaceClass('valid wait','invalid');return this;},reset:function(){if(this.ret){if(this.ret.hasClass('validationResult')){this.ret.remove();this.ret=false;}else{this.ret.replaceClass('invalid valid','');this.ret.innerHTML=this.retDef?this.retDef:'';}}this.replaceClass('invalid valid wait required','');return this;},init:function(e){this.elem=e;var elem=this.element();if(!elem){return this;}else{this.elem=elem;for(var p in this){if(p !='elements'){elem[p]=this[p];}}return elem;}}};var ajaxAccepts={xml:'application/xml,text/xml',html:'text/html',text:'text/plain',json:'application/json,text/javascript',all:'text/html,text/plain,application/xml,text/xml,application/json,text/javascript'};window.GAjax=GClass.create();GAjax.prototype={initialize:function(options){this.options={method:'post',cache:false,asynchronous:true,contentType:'application/x-www-form-urlencoded',CORS:false,encoding:'UTF-8',Accept:'all',onTimeout:$K.emptyFunction,onError:$K.emptyFunction,onProgress:$K.emptyFunction,timeout:0,loadingClass:'show',headers:{}};for(var property in options){this.options[property]=options[property];}this.options.method=this.options.method.toLowerCase();this.loader=null;},xhr:function(){return new XMLHttpRequest();},send:function(url,parameters,callback){var self=this;this._xhr=this.xhr();this._abort=false;if(!Object.isNull(this._xhr)){var option=this.options;if(option.method=='get'){url+='?'+parameters;parameters=null;}else{parameters=parameters===null?'':parameters;}if(option.cache==false){var match=/\?/;url+=(match.test(url)?'&':'?')+new Date().getTime();}this._xhr.withCredentials=option.CORS;this._xhr.open(option.method,url,option.asynchronous);if(option.method=='post'){this._xhr.setRequestHeader('X-Requested-With','XMLHttpRequest');this._xhr.setRequestHeader('Accept',ajaxAccepts[option.Accept]);if(option.contentType&&option.encoding){this._xhr.setRequestHeader('Content-Type',option.contentType+';charset='+option.encoding);}}for(var prop in option.headers){this._xhr.setRequestHeader(prop,option.headers[prop]);}if(option.timeout>0){this._xhr.timeout=option.timeout;this._xhr.ontimeout=function(e){self.hideLoading();option.onTimeout.bind(self);};}this._xhr.onreadystatechange=function(){if(self._xhr.readyState==4){self.hideLoading();window.clearTimeout(self.calltimeout);if(self._xhr.status==200&&!self._abort&&Object.isFunction(callback)){self.responseText=self._xhr.responseText;self.responseXML=self._xhr.responseXML;callback(self);}else{option.onError(self);}}};if(this._xhr.upload){this._xhr.upload.onprogress=function(e){if(e.lengthComputable){option.onProgress.call(e,e.loaded,e.total);}else{option.onProgress.call(e,e.loaded,0);}};}self.showLoading();this._xhr.send(parameters);if(!option.asynchronous){window.clearTimeout(this.calltimeout);this.responseText=this._xhr.responseText;this.responseXML=this._xhr.responseXML;}}return this;},autoupdate:function(url,interval,getRequest,callback){this._xhr=this.xhr();this.interval=interval*1000;if(!Object.isNull(this._xhr)){this.url=url;this.getRequest=getRequest;this.callback=callback;this._abort=false;this._getupdate();}return this;},_getupdate:function(){if(this._abort==false){var parameters=null;var url=this.url;var option=this.options;if(Object.isFunction(this.getRequest)){if(option.method=='get'){url+='?'+this.getRequest();}else{parameters=this.getRequest();}}parameters=option.method=='post'&&parameters==null?'':parameters;if(option.cache==false){var match=/\?/;url+=(match.test(url)?'&':'?')+new Date().getTime();}var xhr=this._xhr;var temp=this;xhr.open(option.method,url,true);if(option.method=='post'){xhr.setRequestHeader('X-Requested-With','XMLHttpRequest');xhr.setRequestHeader('Accept',ajaxAccepts[option.Accept]);if(option.contentType&&option.encoding){xhr.setRequestHeader('Content-Type',option.contentType+';charset='+option.encoding);}}for(var prop in option.headers){this._xhr.setRequestHeader(prop,option.headers[prop]);}temp.showLoading();xhr.send(parameters);xhr.onreadystatechange=function(){if(xhr.readyState==4&&xhr.status==200){temp.hideLoading();if(temp.callback){temp.callback(xhr);}window.clearTimeout(temp.calltimeout);_nextupdate();}};var _nextupdate=function(){temp.timeinterval=window.setTimeout(temp._getupdate.bind(temp),temp.interval);};this.calltimeout=window.setTimeout(function(){window.clearTimeout(temp.timeinterval);xhr.abort();_nextupdate();},this.interval);}},getRequestBody:function(pForm){pForm=$E(pForm);var nParams=[];forEach(pForm.getElementsByTagName('*'),function(){if(!this.disabled){var t=this.tagName.toLowerCase();if(t=='input'){if((this.checked==true&&this.type=='radio')||(this.checked==true&&this.type=='checkbox')||(this.type !='radio'&&this.type !='checkbox')){nParams.push(this.name+'='+this.value);}}else if(t=='select'){nParams.push(this.name+'='+this.value);}else if(t=='textarea'){nParams.push(this.name+'='+encodeURIComponent(this.innerHTML));}}});return nParams.join('&');},showLoading:function(){if(this.loading){if(this.loading=='wait'&&this.center==false){if(this.loader==null){this.loader=new GLoading();}this.loader.show();}else if($E(this.loading)){this.wait=$G(this.loading);if(this.center){this.wait.center();}this.wait.addClass(this.options.loadingClass);}}return this;},hideLoading:function(){if(this.loading){if(this.loader){this.loader.hide();}else if(this.wait){this.wait.removeClass(this.options.loadingClass);}}return this;},initLoading:function(loading,center,c){this.loading=loading;this.center=center;if(c){this.options.loadingClass=c;}return this;},abort:function(){clearTimeout(this.timeinterval);this._abort=true;return this;}};var gform_id=0;window.GForm=GClass.create();GForm.prototype={initialize:function(frm,frmaction,loading,center,onbeforesubmit){frm=$G(frm);if(frmaction){frm.set('action',frmaction);}this.loader=null;this.submitButton=frm.querySelector('[type=submit]');this.loading=loading||this.submitButton||'wait';this.center=center;this.onbeforesubmit=Object.isFunction(onbeforesubmit)?onbeforesubmit:$K.resultFunction;var self=this;frm.onsubmit=function(){var loading=true;var ret=true;if(self.onbeforesubmit.call(this)){forEach(this.querySelectorAll('input,textarea'),function(elem){if(elem.srcObj){var title=elem.srcObj.title,val=elem.value;if(elem.srcObj.required !==null&&val==''){if(title==''&&elem.placeholder !=''){title=elem.placeholder;}title=trans('Please fill in')+' '+title;alert(title.strip_tags());elem.addClass('equired').highlight().focus();ret=false;return true;}else if(elem.srcObj.pattern&&val !==''&&!elem.srcObj.pattern.test(val)){if(title==''&&elem.placeholder !=''){title=elem.placeholder;}var label=elem.findLabel();title=trans('Invalid data').replace('XXX',label?label.innerText:elem.name)+' '+title;title=title.strip_tags();elem.invalid(title);alert(title);elem.highlight().focus();elem.select();ret=false;return true;}else{elem.reset();}}});if(ret&&Object.isFunction(self.callback)){self.showLoading();var uploadCallback=function(){if(!loading){try{self.responseText=io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;self.responseXML=io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;}catch(e){}self.hideLoading();self.form.method=old_method;self.form.target=old_target;if(self.form.encoding){self.form.encoding=old_enctype;}else{self.form.enctype=old_enctype;}window.setTimeout(function(){io.removeEvent('load',uploadCallback);io.remove();},1);window.setTimeout(function(){self.callback(self);},1);}};var io=self.createIframe();io.addEvent('load',uploadCallback);var old_target=this.target||'';var old_method=this.method||'post';var old_enctype=this.encoding?this.encoding:this.enctype;if(this.encoding){this.encoding='multipart/form-data';}else{this.enctype='multipart/form-data';}this.target=io.id;this.method='post';window.setTimeout(function(){loading=false;frm.submit();},50);ret=false;}}else{ret=false;}return ret;};frm.GForm=this;this.form=frm;$K.init(frm);},onsubmit:function(callback){this.callback=callback;return this;},submit:function(callback){var loading=true,old_target=null,old_method=null,self=this;this.showLoading();var uploadCallback=function(){if(!loading){self.hideLoading();try{self.responseText=io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;self.responseXML=io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;}catch(e){}self.form.method=old_method;self.form.target=old_target;window.setTimeout(function(){io.removeEvent('load',uploadCallback);io.remove();},1);window.setTimeout(function(){callback(self);},1);}};if(this.form.encoding){this.form.encoding='multipart/form-data';}else{this.form.enctype='multipart/form-data';}var io=this.createIframe();io.addEvent('load',uploadCallback);old_target=this.form.target||'';old_method=this.form.method||'post';this.form.target=io.id;this.form.method='post';window.setTimeout(function(){loading=false;self.form.submit();},50);return this;},createIframe:function(){var frameId='GForm_Submit_'+gform_id+'_'+(this.form.id||this.form.name),io=$G(document.body).create('iframe',{id:frameId,name:frameId});io.style='position:absolute;width:1px;height:1px;inset:-9999px;display:none;';gform_id++;return io;},showLoading:function(){if(this.submitButton){this.submitButton.disabled=true;}if(this.loading&&$E(this.loading)){this.loading=$G(this.loading);if(this.center){this.loading.center();}this.loading.addClass('show');}return this;},hideLoading:function(){if(this.loading&&$E(this.loading)){this.loading.removeClass('show');}else if(this.loader){this.loader.removeClass('wait');}if(this.submitButton){this.submitButton.disabled=false;}return this;},initLoading:function(loading,center){this.loading=loading;this.center=center;return this;}};window.GModal=GClass.create();GModal.prototype={initialize:function(options){this.id='modaldiv';this.btnclose='btnclose';this.backgroundClass='modalbg';this.onhide=$K.emptyFunction;this.onclose=$K.emptyFunction;for(var property in options){this[property]=options[property];}var self=this;var checkESCkey=function(e){if(GEvent.keyCode(e)==27||e.key=='Escape'||e.key=='Esc'){self.hide();GEvent.stop(e);}};var container_div='GModal_'+this.id;var doc=$G(document);doc.addEvent('keydown',checkESCkey);if(!$E(container_div)){var div=doc.createElement('div');div.id=container_div;doc.body.appendChild(div);var c=doc.createElement('div');div.appendChild(c);c.className=this.id;var s=doc.createElement('span');div.appendChild(s);s.className=this.btnclose;s.title=trans('Close');s.onclick=function(){self.hide();};}this.div=$G(container_div);this.body=$G(this.div.firstChild);},content:function(){return this.body;},show:function(value,className){this.body.setHTML(value);this.overlay();if(className){this.div.className=className+' show';}else{this.div.className='show';}var self=this;window.setTimeout(function(){var dm=self.body.getDimensions(),hOffset=dm.height-self.body.getClientHeight()+parseInt(self.body.getStyle('marginTop'))+parseInt(self.body.getStyle('marginBottom'))+40,h=document.viewport.getHeight()-hOffset;if(dm.height>h){self.div.style.height=h+'px';}self.div.center();},500);return this;},hide:function(){this.div.style.height=null;this.div.style.width=null;this.div.style.top='-100%';this.div.className='';var self=this;this.iframe.fadeOut(function(){self._hide.call(self);});return this;},overlay:function(){var frameId='iframe_'+this.div.id,self=this;if(!$E(frameId)){var io=$G(document.body).create('iframe',{id:frameId,height:'100%',frameBorder:0});io.setStyle('position','fixed');io.setStyle('zIndex',999);io.className=this.backgroundClass;io.style.display='none';}this.iframe=$G(frameId);if(this.iframe.style.display=='none'){this.iframe.style.left='0px';this.iframe.style.top='0px';this.iframe.style.display='block';this.iframe.fadeIn();$G(self.iframe.contentWindow.document).addEvent('click',function(e){self.hide();});var d=$G(document).getDimensions();this.iframe.style.height=d.height+'px';this.iframe.style.width='100%';}return this;},_hide:function(){this.iframe.style.display='none';this.body.innerHTML='';if(Object.isFunction(this.onclose)){this.onclose.call(this);}}};window.GFx=$K.emptyFunction;GFx.prototype={_run:function(){this.playing=true;this.step();},stop:function(){this.playing=false;this.options.onComplete.call(this.Element);}};window.GScroll=GClass.create();GScroll.prototype=Object.extend(new GFx(),{initialize:function(container,scroller){this.options={speed:20,duration:1,pauseit:1,scrollto:'top'};this.container=$G(container);this.scroller=$G(scroller);this.container.addEvent('mouseover',function(){this.rel='pause';});this.container.addEvent('mouseout',function(){this.rel='play';});this.container.rel='play';this.playing=false;},play:function(options){for(var property in options){this.options[property]=options[property];}this.scrollerTop=0;this.scrollerLeft=0;this._run();return this;},step:function(){if(this.container.rel=='play'||this.options.pauseit !=1){var size=this.container.getDimensions();if(this.options.scrollto=='bottom'){this.scrollerTop=this.scrollerTop>size.height?0-this.scroller.getHeight():this.scrollerTop+this.options.duration;this.scroller.style.top=this.scrollerTop+'px';}else if(this.options.scrollto=='left'){this.scrollerLeft=this.scrollerLeft+this.scroller.getWidth()<0?size.width:this.scrollerLeft-this.options.duration;this.scroller.style.left=this.scrollerLeft+'px';}else if(this.options.scrollto=='right'){this.scrollerLeft=this.scrollerLeft>size.width?0-this.scroller.getWidth():this.scrollerLeft+this.options.duration;this.scroller.style.left=this.scrollerLeft+'px';}else{this.scrollerTop=this.scrollerTop+this.scroller.getHeight()<0?size.height:this.scrollerTop-this.options.duration;this.scroller.style.top=this.scrollerTop+'px';}}this.timer=window.setTimeout(this.step.bind(this),this.options.speed);}});window.preload=GClass.create();preload.prototype={initialize:function(img,onComplete){var temp=new Image();if(img.src){temp.src=img.src;temp.original=img;}else{temp.src=img;}var _preload=function(){if(temp.complete){onComplete.call(temp);}else{window.setTimeout(_preload,30);}};window.setTimeout(_preload,30);}};window.GEvent={isButton:function(e,code){var button;e=window.event||e;if(e.which==null){button=e.button<2?0:e.button==4?1:2;}else{button=e.which<2?0:e.which==2?1:2;}return button===code;},isLeftClick:function(e){return GEvent.isButton(e,0);},isMiddleClick:function(e){return GEvent.isButton(e,1);},isRightClick:function(e){return GEvent.isButton(e,2);},isCtrlKey:function(e){return window.event?window.event.ctrlKey:e.ctrlKey;},isShiftKey:function(e){return window.event?window.event.shiftKey:e.shiftKey;},isAltKey:function(e){return window.event?window.event.altKey:e.altKey;},element:function(e){e=window.event||e;var node=e.target?e.target:e.srcElement;return e.nodeType==3?node.parentNode:node;},keyCode:function(e){e=window.event||e;return e.which||e.keyCode;},stop:function(e){e=window.event||e;if(e.stopPropagation){e.stopPropagation();}e.cancelBubble=true;if(e.preventDefault){e.preventDefault();}e.returnValue=false;},pointer:function(e){e=window.event||e;return{x:e.pageX||e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft),y:e.pageY||e.clientY+(document.documentElement.scrollTop||document.body.scrollTop)};},pointerX:function(e){return GEvent.pointer(e).x;},pointerY:function(e){return GEvent.pointer(e).y;}};window.Cookie={get:function(k){var v=document.cookie.match('(?:^|;)\\s*'+k.preg_quote()+'=([^;]*)');return v?decodeURIComponent(v[1]):null;},set:function(k,v,options){var _options={path:false,domain:false,duration:false,secure:false};for(var property in options){_options[property]=options[property];}v=encodeURIComponent(v);if(_options.domain){v+=';domain='+_options.domain;}if(_options.path){v+=';path='+_options.path;}if(_options.duration){var date=new Date();date.setTime(date.getTime()+_options.duration*24*60*60*1000);v+=';expires='+date.toGMTString();}if(_options.secure){v+=';secure';}document.cookie=k+'='+v;return this;},remove:function(k){Cookie.set(k,'',{duration:-1});return this;}};window.GLoading=GClass.create();GLoading.prototype={initialize:function(){this.waittime=0;this.loading=null;},show:function(){window.clearTimeout(this.waittime);if(this.loading==null&&!$E('wait')){var div=document.createElement('dl');div.id='wait';div.innerHTML='<dt></dt><dd></dd>';document.body.appendChild(div);}this.loading=$G('wait');this.loading.addClass('show');return this;},hide:function(){if(this.loading){this.loading.replaceClass('show','complete');var self=this;this.waittime=window.setTimeout(function(){self.loading.removeClass('wait show complete');},500);}return this;}};window.GValidator=GClass.create();GValidator.prototype={initialize:function(input,events,validtor,action,callback,form){this.timer=0;this.req=new GAjax();this.interval=1000;this.input=$G(input);this.input.Validator=this;this.title=this.input.get('title');this.validtor=validtor;this.action=action;this.callback=callback;this.form=form;var temp=this;if(form&&form !==''){form=$G(form);form.addEvent('submit',function(){temp.abort();});}forEach(events.split(','),function(){temp.input.addEvent(this,temp.validate.bind(temp));});},validate:function(){this.abort();var ret=Object.isFunction(this.validtor)?this.validtor.call(this.input):true;if(this.form&&ret&&this.action&&ret !==''&&this.action !==''){this.input.addClass('wait');var temp=this;this.timer=window.setTimeout(function(){temp.req.send(temp.action,ret,function(xhr){temp.input.removeClass('wait');if(temp.callback){ret=temp.callback.call(temp,xhr);}else{ret=xhr.responseText;}if(!ret||ret==''){temp.valid();}else{try{ret=eval(ret);}catch(e){}temp.invalid(ret);}});},this.interval);}},abort:function(){window.clearTimeout(this.timer);this.req.abort();this.input.reset();return this;},interval:function(value){this.interval=value;return this;},valid:function(className){this.input.valid(className);},invalid:function(value,className){this.input.invalid(value,className);},reset:function(){this.input.set('title',this.title);this.input.reset();}};window.GDrag=GClass.create();GDrag.prototype={initialize:function(src,options){this.options={beginDrag:$K.emptyFunction,moveDrag:$K.emptyFunction,endDrag:$K.emptyFunction,srcOnly:true};for(var property in options){this.options[property]=options[property];}this.src=$G(src);var self=this;function _mousemove(e){self.mousePos=GEvent.pointer(e);self.options.moveDrag.call(self);}function cancelEvent(e){GEvent.stop(e);}function _mouseup(e){document.removeEvent('mouseup',_mouseup);document.removeEvent('mousemove',_mousemove);document.removeEvent('selectstart dragstart',cancelEvent);if(self.src.releaseCapture){self.src.releaseCapture();}self.mousePos=GEvent.pointer(e);GEvent.stop(e);self.options.endDrag.call(self.src);}function _mousedown(e){var delay,src=GEvent.element(e),temp=this;function _cancelClick(){window.clearTimeout(delay);this.removeEvent('mouseup',_cancelClick);}if((!self.options.srcOnly||src==self.src)&&GEvent.isLeftClick(e)){GEvent.stop(e);self.mousePos=GEvent.pointer(e);if(this.setCapture){this.setCapture();}delay=window.setTimeout(function(){document.addEvent('mouseup',_mouseup);document.addEvent('mousemove',_mousemove);document.addEvent('selectstart dragstart',cancelEvent);self.options.beginDrag.call(self);},100);temp.addEvent('mouseup',_cancelClick);}else if($K.isMobile()){src.callEvent('click');}}this.src.addEvent('mousedown',_mousedown);function touchHandler(e){var touches=e.changedTouches,first=touches[0],type='';switch(e.type){case 'touchstart':type='mousedown';break;case 'touchmove':type='mousemove';break;case 'touchend':type='mouseup';break;default:return;}var simulatedEvent=document.createEvent('MouseEvent');simulatedEvent.initMouseEvent(type,true,false,window,1,first.screenX,first.screenY,first.clientX,first.clientY,false,false,false,false,0,null);first.target.dispatchEvent(simulatedEvent);e.preventDefault();}this.src.addEvent('touchstart touchmove touchend',touchHandler,false);}};window.GDragMove=GClass.create();GDragMove.prototype={initialize:function(move_id,drag_id,options){this.options={beginDrag:$K.resultFunction,moveDrag:$K.resultFunction,endDrag:$K.emptyFunction,srcOnly:true};for(var property in options){this.options[property]=options[property];}this.dragObj=$G(drag_id);this.dragObj.style.cursor='move';this.moveObj=$G(move_id);var Hinstance=this;function _beginDrag(){if(Hinstance.options.beginDrag.call(Hinstance.moveObj,{mousePos:this.mousePos,mouseOffset:Hinstance.mouseOffset})){Hinstance.mouseOffset={x:this.mousePos.x-Hinstance.moveObj.getStyle('left').toInt(),y:this.mousePos.y-Hinstance.moveObj.getStyle('top').toInt()};}}function _moveDrag(){if(Hinstance.options.moveDrag.call(Hinstance.moveObj,{mousePos:this.mousePos,mouseOffset:Hinstance.mouseOffset})){Hinstance.moveObj.style.top=this.mousePos.y-Hinstance.mouseOffset.y+'px';Hinstance.moveObj.style.left=this.mousePos.x-Hinstance.mouseOffset.x+'px';}}function _endDrag(){Hinstance.options.endDrag.call(Hinstance.moveObj,{mousePos:this.mousePos,mouseOffset:Hinstance.mouseOffset});}var o={beginDrag:_beginDrag,moveDrag:_moveDrag,endDrag:_endDrag,srcOnly:this.options.srcOnly};new GDrag(this.dragObj,o);}};window.GMask=GClass.create();GMask.prototype={initialize:function(id,onkeypress){var input=$G(id),tmp=this;this.maxlength=floatval(input.maxlength);this.disabled=input.disabled;this.required=input.required;if(input.min){this.min=floatval(input.min);}if(input.max){this.max=floatval(input.max);}if(input.pattern){this.pattern=new RegExp(input.pattern);input.setAttribute('pattern','(.*){0,}');}function checkKey(e){if(e.key){return /^(Backspace|(Arrow)?Left|(Arrow)?Right|Enter|Tab|Delete)$/.test(e.key);}else{var key=GEvent.keyCode(e);if(key==8||key==37||key==39||key==13||key==9||key==46){return true;}else{return false;}}}var doActive=function(e){var el=e.target;tmp.oldCursor=el.getCaretPosition();tmp.key=false;tmp.oldValue=el.value;};var doKeydown=function(e){var el=e.target;tmp.oldCursor=el.getCaretPosition();tmp.key=checkKey(e);tmp.oldValue=el.value;if(tmp.maxlength>0&&!tmp.key&&!GEvent.isCtrlKey(e)&&tmp.oldCursor.start==tmp.oldCursor.end){if(el.value.length>=tmp.maxlength){GEvent.stop(e);return false;}}};var doInput=function(e){var ret=true,el=e.target,value=el.value;if(value !=''&&!tmp.key&&!GEvent.isCtrlKey(e)){e.key=value.substr(tmp.oldCursor.start,1);if(Object.isFunction(onkeypress)){ret=onkeypress.call(el,e);}else if(tmp.pattern){ret=tmp.pattern.test(value);}if(tmp.maxlength>0&&value.length>tmp.maxlength){el.value=value.substr(0,tmp.maxlength);el.setSelectionRange(tmp.oldCursor.end,tmp.oldCursor.end);}else if(!ret){el.value=tmp.oldValue;el.setSelectionRange(tmp.oldCursor.end,tmp.oldCursor.end);}}};input.addEvent('focus',doActive);input.addEvent('keydown',doKeydown);input.addEvent('input',doInput);}};window.GInput=GClass.create();GInput.prototype={initialize:function(id,inputchar,onchanged){this.input=$G(id);this.input.addClass('ginput');this.keyboard=inputchar.split('');this.onchanged=onchanged||$K.emptyFunction;this.maxlength=floatval(this.input.maxlength);var self=this;if($K.isMobile()){this.panel=new GDropdown(this.input,{float:false});this.input.readOnly=true;this.input.addEvent('click',function(e){self.input.setCaretPosition(self.input.value.length,1);self._draw();GEvent.stop(e);return false;});$G(document.body).addEvent('click',function(e){if(!$G(GEvent.element(e)).hasClass('ginput')){self.panel.hide();self._dochanged();if(self.panel.input){if(self.panel.input_value !=self.panel.input.value){self.panel.input.callEvent('change');}self.panel.input=null;}}});}else{this.input.addEvent('focus',function(){self.input.select();});}new GMask(this.input,function(e){return self.keyboard.indexOf(e.key)>-1;});this.input.addEvent('change',function(){self._dochanged();});this._dochanged();},_dochanged:function(){this.onchanged.call(this.input);},_createButton:function(parent,text,title,className){var a=document.createElement('a');a.innerHTML=text;a.title=title;if(className){parent.className=className;}parent.appendChild(a);},_draw:function(){var dropdown=this.panel.getDropdown(),self=this,panel=document.createElement('table');dropdown.innerHTML='';panel.className='ginput';dropdown.appendChild(panel);var tr=document.createElement('tr'),td=document.createElement('td');td.className='buttons';td.rowSpan=2;tr.appendChild(td);forEach(this.keyboard,function(){self._createButton(td,this,this);});td=document.createElement('td');tr.appendChild(td);panel.appendChild(tr);self._createButton(td,'x','Backspace','backspace');tr=document.createElement('tr');td=document.createElement('td');tr.appendChild(td);panel.appendChild(tr);self._createButton(td,'&crarr;','Enter','enter');forEach(panel.getElementsByTagName('a'),function(){$G(this).addEvent('click',function(e){var elem=GEvent.element(e);if(elem.parentNode.className=='backspace'){if(document.selection){self.input.focus();document.selection.empty();}else{var text=self.input.value,startPos=self.input.selectionStart,endPos=self.input.selectionEnd;if((startPos>0&&endPos>0)||endPos>startPos){startPos=startPos==endPos?startPos-1:startPos;text=text.slice(0,startPos)+text.slice(endPos);self.input.value=text;self.input.selectionStart=startPos;self.input.selectionEnd=startPos;}self.input.focus();}GEvent.stop(e);}else if(elem.parentNode.className !='enter'){var text=this.innerHTML;self.input.focus();if(document.selection){sel.setSelectedText(text);}else if(self.input.selectionStart||self.input.selectionStart===0){var startPos=self.input.selectionStart,endPos=self.input.selectionEnd,value=self.input.value.substring(0,startPos)+text+self.input.value.substring(endPos,self.input.value.length);if(self.maxlength==0||value.length<=self.maxlength){self.input.value=value;self.input.selectionStart=startPos+text.length;self.input.selectionEnd=startPos+text.length;}else{self.input.selectionStart=startPos;self.input.selectionEnd=endPos;}}else{text=self.input.value+text;if(self.maxlength==0||text.length<=self.maxlength){self.input.value=text;}}GEvent.stop(e);}});});this.panel.show();this.panel.input=this.input;this.panel.input_value=this.input.value;}};window.GDropdown=GClass.create();GDropdown.prototype={initialize:function(src,o){this.src=src;this.options={autoHeight:false,float:true,id:'gdropdown',className:'gdropdown'};for(var prop in o){this.options[prop]=o[prop];}if(!$E(this.options.id)){var div=document.createElement('div');document.body.appendChild(div);div.id=this.options.id;}this.dropdown=$G(this.options.id);this.dropdown.style.display='none';},getDropdown:function(){return this.dropdown;},getPosition:function(){var e=this.src.parentNode,position=getComputedStyle(this.src)['position'];while(e !=document.body&&position !='absolute'&&position !='fixed'){e=e.parentNode;position=getComputedStyle(e)['position'];}return position=='fixed'?'fixed':'absolute';},show:function(){if(this.options.className){this.dropdown.classList.add(this.options.className);}this.dropdown.style.zIndex=1001;if(this.options.float===true||(this.options.float==='auto'&&!$K.isMobile())){this.dropdown.style.position=this.getPosition();var vpo=this.src.viewportOffset(),input_height=this.src.getHeight(),dm=this.dropdown.getDimensions(),scrolltop=document.viewport.getscrollTop(),doc_height=document.viewport.getHeight(),top_space=vpo.top-scrolltop,bottom_space=doc_height-top_space-input_height;if(this.options.autoHeight){var space=Math.max(top_space,bottom_space);if(dm.height>space){this.dropdown.style.height=(space-10)+'px';dm=this.dropdown.getDimensions();}}if(top_space>=bottom_space){this.dropdown.style.top=Math.max(vpo.top-dm.height-5,0)+'px';}else{this.dropdown.style.top=(vpo.top+input_height+5)+'px';}var l=Math.max(vpo.left+dm.width>document.viewport.getWidth()?vpo.left+this.src.getWidth()-dm.width:vpo.left,document.viewport.getscrollLeft()+5);this.dropdown.style.left=l+'px';}else{this.dropdown.style.left=0;this.dropdown.style.right=0;this.dropdown.style.bottom=0;this.dropdown.style.position='fixed';this.dropdown.classList.add('mobile_fixed');}this.dropdown.style.display='block';},hide:function(){if(this.options.className){this.dropdown.classList.remove(this.options.className);}this.dropdown.style.display='none';this.dropdown.style.height='auto';},showing:function(){return this.dropdown.style.display=='block';}};window.GCalendar=GClass.create();GCalendar.prototype={initialize:function(elem){elem=$E(elem);this.input=document.createElement('div');if(elem.id&&elem.id !=''){this.input.id=elem.id;}else{this.input.id=elem.name.replace(/\[.*?\]/,'');}this.input.className='input-gcalendar input-select';this.input.tabIndex=0;this.input.style.cursor='pointer';elem.parentNode.appendChild(this.input);this.display=document.createElement('div');this.display.id=elem.id+'_display';this.input.appendChild(this.display);this.display.innerHTML='Please';this.hidden=document.createElement('input');this.hidden.type='hidden';this.hidden.name=elem.name;this.input.appendChild(this.hidden);this.placeholder=document.createElement('div');this.placeholder.className='placeholder';this.placeholder.style.position='absolute';this.input.appendChild(this.placeholder);this.calendar=new GDropdown(this.input,{float:'auto'});this.mdate=null;this.xdate=null;this.mode=0;this.datetime=elem.type.toLowerCase()!='date';if(this.datetime){this.displayFormat='d M Y H:I';this.format='y-m-d H:I';}else{this.displayFormat='d M Y';this.format='y-m-d';}this.date=null;this.hour=0;this.minute=0;this.cdate=new Date();var self=this;$G(this.input).addEvent('click',function(e){self.mode=0;self.cdate.setTime(self.date?self.date.valueOf():new Date());self._draw();GEvent.stop(e);return false;});this.input.addEvent('keydown',function(e){var key=GEvent.keyCode(e);if(key==9){self.calendar.hide();}else if(key==32){self._toogle(e);}else if(key==37||key==39){self.moveDate(key==39?1:-1);self._draw();GEvent.stop(e);}else if(key==38||key==40){if(GEvent.isShiftKey(e)){self.moveYear(key==40?1:-1);}else if(GEvent.isCtrlKey(e)){self.moveMonth(key==40?1:-1);}else{self.moveDate(key==40?7:-7);}self._draw();GEvent.stop(e);}else if(key==8&&self.input.hasClass('readonly disabled')==false){self.setDate(null);GEvent.stop(e);}else{GEvent.stop(e);}});$G(document.body).addEvent('click',function(e){if(!($G(GEvent.element(e)).hasClass('input-gcalendar')||$G(GEvent.element(e).parentNode).hasClass('input-gcalendar'))){self.calendar.hide();}});Object.defineProperty(this.input,'min',{get:function(){return self.mdate;},set:function(value){self.minDate(value);}});Object.defineProperty(this.input,'max',{get:function(){return self.xdate;},set:function(value){self.maxDate(value);}});Object.defineProperty(this.input,'placeholder',{get:function(){return self.placeholder.innerHTML;},set:function(value){self.placeholder.innerHTML=value;}});Object.defineProperty(this.input,'text',{get:function(){return self.display.innerHTML;},set:function(value){self.display.innerHTML=value;}});Object.defineProperty(this.input,'value',{get:function(){return self.getDateFormat(self.format);},set:function(value){self.setDate(value);}});Object.defineProperty(this.input,'date',{get:function(){return self.getDate();},set:function(value){self.setDate(value);}});Object.defineProperty(this.input,'disabled',{get:function(){return self.input.hasClass('disabled')?true:false;},set:function(value){if(value){self.input.addClass('disabled');}else{self.input.removeClass('disabled');}},});Object.defineProperty(this.input,'readOnly',{get:function(){return self.input.hasClass('readonly')?true:false;},set:function(value){if(value){self.input.addClass('readonly');}else{self.input.removeClass('readonly');}},});this.input.calendar=this;if(elem.min){this.input.min=elem.min;}if(elem.max){this.input.max=elem.max;}if(elem.disabled){this.input.disabled=true;}if(elem.readOnly){this.input.readOnly=true;}this.input.placeholder=elem.placeholder;elem.parentNode.removeChild(elem);this.input.value=elem.value;},_dochanged:function(){if(this.xdate&&this.date&&this.date>this.xdate){this.date.setTime(this.xdate.valueOf());}else if(this.mdate&&this.date&&this.date<this.mdate){this.date.setTime(this.mdate.valueOf());}if(this.date){this.cdate.setTime(this.date.valueOf());this.display.innerHTML=this.date.format(this.displayFormat);this.hidden.value=this.date.format(this.format);}else{this.cdate.setTime(new Date());this.display.innerHTML='';this.hidden.value='';}this.placeholder.style.display=this.hidden.value==''&&this.placeholder.innerHTML !=''?'block':'none';var self=this;window.setTimeout(function(){self.input.callEvent('change');});},_toogle:function(e){if(this.calendar.showing()){this.calendar.hide();}else{this.mode=0;if(this.date){this.cdate.setTime(this.date.valueOf());}else{this.cdate.setTime(new Date());}this.hour=this.cdate.getHours();this.minute=this.cdate.getMinutes();this._draw();}GEvent.stop(e);},_draw:function(){if(this.input.hasClass('readonly disabled')==false){var self=this,calendar=this.calendar.getDropdown();calendar.innerHTML='';var div=document.createElement('div');calendar.appendChild(div);div.className='gcalendar';var p=document.createElement('p');div.appendChild(p);var a=document.createElement('a');p.appendChild(a);a.innerHTML='&larr;';a.style.cursor='pointer';$G(a).addEvent('click',function(e){self._move(e,-1);GEvent.stop(e);return false;});if(this.mode==2){var start_year=this.cdate.getFullYear()-6;a=document.createElement('span');a.appendChild(document.createTextNode(start_year+Date.yearOffset+'-'+(start_year+11+Date.yearOffset)));p.appendChild(a);a.style.cursor='pointer';}else{a=document.createElement('a');a.innerHTML=this.cdate.format('M');a.style.cursor='pointer';$G(a).addEvent('click',function(e){self.mode++;self._draw();GEvent.stop(e);return false;});p.appendChild(a);a=document.createElement('a');a.innerHTML=this.cdate.format('Y');a.style.cursor='pointer';$G(a).addEvent('click',function(e){self.mode=2;self._draw();GEvent.stop(e);return false;});p.appendChild(a);if(this.datetime&&this.mode==0){var i,x,option,span,hour=document.createElement('select'),minute=document.createElement('select');for(i=0;i<24;i++){x=i.toString().leftPad(2,'0');option=document.createElement('option');if(x==self.hour){option.selected=true;}option.innerHTML=x;option.value=x;hour.appendChild(option);}p.appendChild(hour);span=document.createElement('span');span.innerText=':';p.appendChild(span);for(i=0;i<60;i++){x=i.toString().leftPad(2,'0');option=document.createElement('option');if(x==self.minute){option.selected=true;}option.innerHTML=x;option.value=x;minute.appendChild(option);}p.appendChild(minute);var timeClicked=function(e){GEvent.stop(e);return false;};$G(hour).addEvent('click',timeClicked);$G(minute).addEvent('click',timeClicked);var timeChange=function(){self.hour=parseInt(hour.value);self.minute=parseInt(minute.value);self.date.setHours(self.hour,self.minute,0);self._dochanged();};$G(hour).addEvent('change',timeChange);$G(minute).addEvent('change',timeChange);}}a=document.createElement('a');p.appendChild(a);a.innerHTML='&rarr;';a.style.cursor='pointer';$G(a).addEvent('click',function(e){self._move(e,1);GEvent.stop(e);return false;});var table=document.createElement('table'),thead=document.createElement('thead'),tbody=document.createElement('tbody'),intmonth=this.cdate.getMonth()+1,intyear=this.cdate.getFullYear(),cls='',today=new Date(),today_month=today.getMonth()+1,today_year=today.getFullYear(),today_date=today.getDate(),sel_month=this.date?this.date.getMonth()+1:today_month,sel_year=this.date?this.date.getFullYear():today_year,sel_date=this.date?this.date.getDate():today_date,r=0,c=0,bg,row,cell;table.appendChild(thead);table.appendChild(tbody);div.appendChild(table);if(this.mode==2){for(var i=start_year;i<start_year+12;i++){c=(i-start_year)% 4;if(c==0){row=tbody.insertRow(r);bg=bg=='bg1'?'bg2':'bg1';row.className='gcalendar_'+bg;r++;}cell=row.insertCell(c);cls='month';if(i==sel_year){cls=cls+' select';}if(i==today_year){cls=cls+' today';}cell.className=cls;cell.appendChild(document.createTextNode(i+Date.yearOffset));cell.oDate=new Date(i,1,1,12,0,0,0);$G(cell).addEvent('click',function(e){self.cdate.setTime(this.oDate.valueOf());self.mode--;self._draw();GEvent.stop(e);return false;});}}else if(this.mode==1){forEach(Date.monthNames,function(month,i){c=i % 4;if(c==0){row=tbody.insertRow(r);bg=bg=='bg1'?'bg2':'bg1';row.className='gcalendar_'+bg;r++;}cell=row.insertCell(c);cls='month';if(intyear==sel_year&&i+1==sel_month){cls=cls+' select';}if(intyear==today_year&&i+1==today_month){cls=cls+' today';}cell.className=cls;cell.appendChild(document.createTextNode(month));cell.oDate=new Date(intyear,i,1,0,0,0,0);$G(cell).addEvent('click',function(e){self.cdate.setTime(this.oDate.valueOf());self.mode--;self._draw();GEvent.stop(e);return false;});});}else{row=thead.insertRow(0);forEach(Date.dayNames,function(item,i){cell=document.createElement('th');row.appendChild(cell);cell.appendChild(document.createTextNode(item));});var tmp_prev_month=intmonth-1;var tmp_next_month=intmonth+1;var tmp_next_year=intyear;var tmp_prev_year=intyear;if(tmp_prev_month==0){tmp_prev_month=12;tmp_prev_year--;}if(tmp_next_month==13){tmp_next_month=1;tmp_next_year++;}var initial_day=1;var tmp_init=new Date(intyear,intmonth,1,0,0,0,0).dayOfWeek();var max_prev=new Date(tmp_prev_year,tmp_prev_month,0,0,0,0,0).daysInMonth();var max_this=new Date(intyear,intmonth,0,0,0,0,0).daysInMonth();if(tmp_init !==0){initial_day=max_prev-(tmp_init-1);}tmp_next_year=tmp_next_year.toString();tmp_prev_year=tmp_prev_year.toString();tmp_next_month=tmp_next_month.toString();tmp_prev_month=tmp_prev_month.toString();var pointer=initial_day;var flag_init=initial_day==1?1:0;var tmp_month=initial_day==1?intmonth:parseInt(tmp_prev_month);var tmp_year=initial_day==1?intyear:parseInt(tmp_prev_year);var flag_end=0;r=0;for(var x=0;x<42;x++){if(tmp_init !==0&&pointer>max_prev&&flag_init==0){flag_init=1;pointer=1;tmp_month=intmonth;tmp_year=intyear;}if(flag_init==1&&flag_end==0&&pointer>max_this){flag_end=1;pointer=1;tmp_month=parseInt(tmp_next_month);tmp_year=parseInt(tmp_next_year);}c=x % 7;if(c==0){row=tbody.insertRow(r);r++;}cell=row.insertCell(c);cell.oDate=new Date(tmp_year,tmp_month-1,pointer,0,0,0,0);cell.title=cell.oDate.format(self.displayFormat);cell.appendChild(document.createTextNode(pointer));var canclick=true;if(this.mdate !==null&&this.xdate !==null){canclick=cell.oDate>=this.mdate&&cell.oDate<=this.xdate;}else if(this.mdate !==null){canclick=cell.oDate>=this.mdate;}else if(this.xdate !==null){canclick=cell.oDate<=this.xdate;}if(canclick){cls=tmp_month==intmonth?'curr':'ex';}else{cls='ex';}$G(cell).addEvent('click',function(e){var c=this.hasClass('curr ex');if(c=='curr'){if(self.date===null){self.date=new Date();}self.date.setTime(this.oDate.valueOf());self.date.setHours(self.hour,self.minute,0);}else if(c=='ex'){self.date=null;}self._dochanged();$E(self.input).focus();});if(tmp_year==sel_year&&tmp_month==sel_month&&pointer==sel_date){cls=cls+' select';}if(tmp_year==today_year&&tmp_month==today_month&&pointer==today_date){cls=cls+' today';}cell.className=cls;pointer++;}}this.calendar.show();}},_move:function(e,value){if(this.mode==2){this.cdate.setFullYear(this.cdate.getFullYear()+value*12,1,1);}else if(this.mode==1){this.cdate.setFullYear(this.cdate.getFullYear()+value,1,1);}else{this.cdate.setMonth(this.cdate.getMonth()+value,1);}this._draw();GEvent.stop(e);},moveDate:function(day){if(this.date===null){this.date=new Date();}this.date.setDate(this.date.getDate()+day);this._dochanged();return this;},moveMonth:function(month){if(this.date===null){this.date=new Date();}this.date.setMonth(this.date.getMonth()+month);this._dochanged();return this;},moveYear:function(year){if(this.date===null){this.date=new Date();}this.date.setFullYear(this.date.getFullYear()+year);this._dochanged();return this;},setFormat:function(value){this.format=value;this._dochanged();return this;},setDisplayFormat:function(value){this.displayFormat=value;this._dochanged();return this;},setDate:function(date){if(date===null||date===''||!/[0-9]{2,4}\-[0-9]{1,2}\-[0-9]{1,2}(\s[0-9:]+)?/.test(date)){this.date=null;this.hour=0;this.minute=0;}else{this.date=this._toDate(date);this.hour=this.date.getHours();this.minute=this.date.getMinutes();}this._dochanged();return this;},getDate:function(){if(this.date){var d=new Date();d.setTime(this.date.valueOf());return d;}return null;},getDateFormat:function(format){if(this.date){format=format||this.format;return this.getDate().format(format);}return null;},minDate:function(date){if(date===null){this.mdate=null;}else if(Object.isString(date)&&date===''){if(this.mdate==null){this.mdate=new Date();}this.mdate.setTime(this.date?this.date.valueOf():new Date()).setHours(0,0,0);}else{this.mdate=this._toDate(date).setHours(0,0,0);}return this;},maxDate:function(date){if(date===null){this.xdate=null;}else if(Object.isString(date)&&date===''){if(this.xdate==null){this.xdate=new Date();}this.xdate.setTime(this.date?this.date.valueOf():new Date()).setHours(23,59,59);}else{this.xdate=this._toDate(date).setHours(23,59,59);}return this;},setText:function(value){this.display.innerHTML=value;},_toDate:function(date){var d=null;if(Object.isString(date)){d=date.toDate();d=d==null?new Date():d;}else{d=new Date();if(!Object.isNull(date)){d.setTime(date.valueOf());}}return d;}};window.GFxZoom=GClass.create();GFxZoom.prototype=Object.extend(new GFx(),{initialize:function(elem,options){this.options={duration:2,speed:1,offset:0,fitdoc:true,onComplete:$K.emptyFunction,onResize:$K.emptyFunction};for(var property in options){this.options[property]=options[property];}this.options.duration=this.options.duration>8?8:this.options.duration;this.options.duration-=this.options.duration % 2==0?0:1;this.Player=$G(elem);this.Player.style.zIndex=9999999;var tmp=this.Player.viewportOffset();this.t=tmp.top;this.l=tmp.left;tmp=this.Player.getDimensions();this.w=tmp.width;this.h=tmp.height;},play:function(dw,dh,dl,dt){var cw=document.viewport.getWidth();var ch=document.viewport.getHeight();if(this.options.fitdoc){if(dw>cw){dh=Math.round((cw*dh)/ dw);dw=cw;}if(dh>ch){dw=Math.round((ch*dw)/ dh);dh=ch;}dw=dw-this.options.offset;dh=dh-this.options.offset;}this.dw=dw;this.dh=dh;if(dl==null){dl=document.viewport.getscrollLeft()+(cw-dw)/ 2;}if(dt==null){dt=document.viewport.getscrollTop()+(ch-dh)/ 2;}this.lStep=(dl-this.l)/ 2 / this.options.duration;this.tStep=(dt-this.t)/ 2 / this.options.duration;this.wStep=(dw-this.w)/ 2 / this.options.duration;this.hStep=(dh-this.h)/ 2 / this.options.duration;this.timer=window.setInterval(this.step.bind(this),this.options.speed);this.options.onResize.call(this);},step:function(){if(this.w !=this.dw||this.h !=this.dh){this.l+=this.lStep;this.t+=this.tStep;this.w+=this.wStep;this.h+=this.hStep;this.Player.style.left=this.l+'px';this.Player.style.top=this.t+'px';this.Player.style.width=this.w+'px';this.Player.style.height=this.h+'px';this.options.onResize.call(this);}else{this.stop();}},stop:function(){window.clearInterval(this.timer);this.options.onComplete.call(this);}});window.Color=GClass.create();Color.prototype={initialize:function(value){if(Array.isArray(value)){this.r=value[0];this.g=value[1];this.b=value[2];this.a=value.length>3?value[3]:null;}else{var rgb=/#?([a-zA-Z0-9]{1,2})([a-zA-Z0-9]{1,2})([a-zA-Z0-9]{1,2})([a-zA-Z0-9]{0,2})$/.exec(value);if(rgb){this.r=rgb[1].length==2?parseInt(rgb[1],16):parseInt(rgb[1]+rgb[1],16);this.g=rgb[2].length==2?parseInt(rgb[2],16):parseInt(rgb[2]+rgb[2],16);this.b=rgb[3].length==2?parseInt(rgb[3],16):parseInt(rgb[3]+rgb[3],16);this.a=rgb[4]==''?null:rgb[4].length==2?parseInt(rgb[4],16):parseInt(rgb[4]+rgb[4],16);}else{this.r=0;this.g=0;this.b=0;this.a=null;}}},darken:function(amount){return new Color([ Math.max(0,Math.round(this.r-amount)),Math.max(0,Math.round(this.g-amount)),Math.max(0,Math.round(this.b-amount)),this.a ]);},lighten:function(amount){return new Color([ Math.min(255,Math.round(this.r+amount)),Math.min(255,Math.round(this.g+amount)),Math.min(255,Math.round(this.b+amount)),this.a ]);},invert:function(){return new Color([ this.r>128?0:255,this.g>128?0:255,this.b>128?0:255,this.a ]);},toString:function(){return('#'+this.r .toString(16).toUpperCase().leftPad(2,'0')+this.g .toString(16).toUpperCase().leftPad(2,'0')+this.b .toString(16).toUpperCase().leftPad(2,'0')+(this.a !==null&&this.a !==1?this.a .toString(16).toUpperCase().leftPad(2,'0'):''));},toRGB:function(){return this.a !==null&&this.a !==1?'rgba('+this.r+','+this.g+','+this.b+','+this.a+')':'rgb('+this.r+','+this.g+','+this.b+')';},toArray:function(){return [this.r,this.g,this.b,this.a];}};window.GDDColor=GClass.create();GDDColor.prototype={initialize:function(id,onchanged){this.Colors=Array('B71C1C','880E4F','4A148C','311B92','1A237E','0D47A1','304FFE','01579B','2387CA','006064','004D40','1B5E20','33691E','827717','FFD600','FF6F00','E65100','BF360C','3E2723','263238','FFFFFF','000000','T','C');this.cols=6;this.input=$G(id);this.input.addClass('gddcolor');if($K.isMobile()){this.input.readOnly=true;}this.onchanged=onchanged||$K.emptyFunction;this.color='';this.color_format=/^((transparent)|(\#[0-9a-fA-F]{6,6}))$/i;this.ddcolor=new GDropdown(this.input,{float:'auto'});var self=this;this.input.addEvent('click',function(e){self.createColors();self.ddcolor.show();self.showDemo(self.color);self.pickColor(self.color);GEvent.stop(e);return false;});new GMask(this.input,function(e){return /[0-9a-fA-F]/.test(e.key);});this.input.addEvent('keydown',function(e){var key=GEvent.keyCode(e);if(key==38||key==39||key==40||/^(Arrow)?(Up|Down|Right)$/.test(e.key)){self.createColors();self.ddcolor.show();$E('gddcolor_div').firstChild.firstChild.focus();GEvent.stop(e);return false;}});if(this.input.type=='text'){this.input.addEvent('keyup',function(){var value=this.value.toUpperCase();if(value !='TRANSPARENT'){var c=value.replace('#','').replace(/[^0-9A-F]+/,'');if(c !=''){this.value='#'+c;}}});}else{this.input.style.cursor='pointer';self.input.tabIndex=0;}$G(document.body).addEvent('click',function(e){if(!$G(GEvent.element(e)).hasClass('gddcolor')){self.ddcolor.hide();}});if(self.input.value){self.timer=window.setInterval(function(){if(!$E(self.input)){window.clearInterval(self.timer);}else if(self.input.value !==self.color){if(self.input.value==''){self.color='';self.input.style.color='#000000';self.input.style.backgroundColor='#FFFFFF';}else if(self.color_format.test(self.input.value)){self.color=self.input.value;self.input.style.color=self.invertColor(self.color);self.input.style.backgroundColor=self.color;}else{return;}self.pickColor(self.color);self.showDemo(self.color);self.input.callEvent('change');}},50);}},createColors:function(){var r=this.Colors.length / this.cols,t=this.input.tabIndex+1,dropdown=this.ddcolor.getDropdown(),ddcolor=document.createElement('div'),self=this,patt=/((color_)([0-9]+)_)([0-9]+)/;dropdown.innerHTML='';ddcolor.className='gddcolor';ddcolor.id='gddcolor_div';dropdown.appendChild(ddcolor);var _dokeydown=function(e){var key=GEvent.keyCode(e),hs=patt.exec(this.id),z=floatval(hs[3]),x=floatval(hs[4]);if(key>36&&key<41){if(key==37){x--;}else if(key==38){z--;}else if(key==39){x++;}else if(key==40){z++;}var el=$E(hs[2]+z+'_'+x);if(el){el.focus();self.showDemo(el.title);}GEvent.stop(e);}else if(key==13){self.doClick(this.title);GEvent.stop(e);}else if(key==32){if(r-z>1){self.pickColor(this.title);$E('color_'+(self.cols-1)+'_0').focus();}GEvent.stop(e);}else if(key==27||key==9){self.ddcolor.hide();self.input.focus();GEvent.stop(e);}};var c=0,a,p=document.createElement('p'),z;ddcolor.appendChild(p);forEach(this.Colors,function(color,n){if(n % self.cols==0){c++;}a=$G(document.createElement('a'));a.id='color_'+c+'_'+(n % self.cols);p.appendChild(a);a.tabIndex=t;t++;if(color=='T'){a.title='Transparent';a.innerHTML='T';a.className='item dark';}else if(color=='C'){a.title='Clear';a.style.backgroundColor='#EEEEEE';a.innerHTML='C';a.className='item dark';}else{z='#'+color;a.style.backgroundColor=z;a.title=z;a.className=color=='#FFFFFF'?'item dark':'item';}a.addEvent('click',function(e){if(this.title=='Clear'||this.title=='Transparent'||this.title=='#FFFFFF'){self.doClick(this.title);}else{self.pickColor(this.title);}GEvent.stop(e);return false;});a.addEvent('mouseover',function(){self.showDemo(this.title);});a.addEvent('keydown',_dokeydown);});this.demoColor=$G(document.createElement('p'));ddcolor.appendChild(this.demoColor);this.customColor=$G(document.createElement('p'));ddcolor.appendChild(this.customColor);t++;c++;for(r=0;r<self.cols;r++){a=$G(document.createElement('a'));this.customColor.appendChild(a);a.id='color_'+c+'_'+r;a.tabIndex=t;a.className='item';a.addEvent('click',function(){self.doClick(this.title);});a.addEvent('mouseover',function(){self.showDemo(this.title);});a.addEvent('keydown',_dokeydown);}},doClick:function(c){this.ddcolor.hide();if(c=='Clear'){c='';}this.color=c;this.onchanged.call(this,c);this.input.focus();},pickColor:function(c){if(this.customColor){var n,c=new Color(c),rgb=c.toArray(),m=Math.min(rgb[0],rgb[1],rgb[2]),o=Math.floor((255-m)/ this.cols);forEach(this.customColor.elems('a'),function(item,index){n=c.lighten(o*index);item.title=n.toString();item.style.backgroundColor=n.toString();item.style.color=n.invert().toString();});}},showDemo:function(c){if(this.demoColor){var a;if(c=='Transparent'){c='transparent';a=trans('Transparent');}else if(c=='Clear'){c='transparent';a=trans('Remove Color');}else{a=c;}this.demoColor.style.backgroundColor=c;this.demoColor.innerHTML=a;this.demoColor.style.color=this.invertColor(c);}},setColor:function(c){if(c !=''&&c !=this.color&&this.color_format.test(c)){this.doClick(c.toUpperCase());}},getColor:function(){return this.color;},invertColor:function(c){if(c.toLowerCase()=='transparent'){return this.ddcolor.getDropdown().style.color;}else{return new Color(c).invert().toString();}}};window.GLightbox=GClass.create();GLightbox.prototype={initialize:function(options){this.id='gslide_div';this.btnclose='btnclose';this.backgroundClass='modalbg';this.previewClass='gallery_preview';this.loadingClass='spinner';this.onshow=null;this.onhide=null;this.onclose=null;this.ondownload=null;for(var property in options){this[property]=options[property];}var self=this;var checkESCkey=function(e){var k=GEvent.keyCode(e);if(k==27){self.hide(e);}else if(k==37){self.showPrev(e);}else if(k==39){self.showNext(e);}};var container_div='GLightbox_'+this.id,doc=$G(document);doc.addEvent('keydown',checkESCkey);if(!$E(container_div)){var div=doc.createElement('div');doc.body.appendChild(div);div.id=container_div;div.style.left='100%';div.style.top='0';div.style.width='100%';div.style.height='100vh';div.style.position='fixed';div.style.zIndex=1000;var c=doc.createElement('div');div.appendChild(c);c.className=this.id;c.style.position='fixed';var c2=doc.createElement('figure');c.appendChild(c2);c2.className=this.previewClass;this.img=doc.createElement('img');this.img.alt='';c2.appendChild(this.img);new GDragMove(c,this.img);c=doc.createElement('figcaption');div.appendChild(c);this.loading=doc.createElement('span');div.appendChild(this.loading);this.loading.className=this.loadingClass;this.caption=doc.createElement('p');c.appendChild(this.caption);var btnclose=doc.createElement('span');div.appendChild(btnclose);btnclose.className=this.btnclose;btnclose.title=trans('Close');callClick(btnclose,function(){self.hide();});this.zoom=doc.createElement('span');div.appendChild(this.zoom);this.zoom.id='GLightbox_zoom';callClick(this.zoom,function(e){self._fullScreen(e);});this.prev=doc.createElement('span');div.appendChild(this.prev);this.prev.className='hidden';this.prev.title=trans('Prev');callClick(this.prev,function(){self.showPrev();});this.next=doc.createElement('span');div.appendChild(this.next);this.next.className='hidden';this.next.title=trans('Next');callClick(this.next,function(){self.showNext();});this.download=doc.createElement('a');div.appendChild(this.download);this.download.title=trans('Download');if(Object.isFunction(this.ondownload)){callClick(this.download,function(){self.ondownload(this.href);return false;});}}this.zoom=$E('GLightbox_zoom');this.div=$G(container_div);this.body=$G(this.div.firstChild);this.preview=$G(this.body.firstChild);this.img=this.preview.firstChild;this.body.style.overflow='hidden';this.currentId=0;this.imgs=[];},clear:function(){this.currentId=0;this.imgs.length=0;},add:function(a){var img=$E(a);img['data-id']=this.imgs.length;this.imgs.push(img);var self=this;callClick(img,function(){if(this.drag !==true){self.currentId=floatval(this['data-id']);self.show(this,false);}return false;});},showNext:function(){if(this.div.style.display=='block'&&this.imgs.length>0){this.currentId++;if(this.currentId>=this.imgs.length){this.currentId=0;}var img=this.imgs[this.currentId];this.show(img,false);}},showPrev:function(){if(this.div.style.display=='block'&&this.imgs.length>0){this.currentId--;if(this.currentId<0){this.currentId=this.imgs.length-1;}var img=this.imgs[this.currentId];this.show(img,false);}},_fullScreen:function(){if(this.div.style.display=='block'&&this.imgs.length>0){var img=this.imgs[this.currentId];this.show(img,this.zoom.className=='btnnav zoomout');}},show:function(obj,fullscreen){var img,title,self=this;if(obj.href){img=obj.href;title=obj.title;}else if(obj.src){img=obj.src;title=obj['data-id'];}else{img=obj.style.backgroundImage.substr(5,obj.style.backgroundImage.length-7);title=obj.title;}this.overlay();this.zoom.className=fullscreen?'btnnav zoomin':'btnnav zoomout';this.zoom.title=trans(fullscreen?'fit screen':'full image');this.loading.className=this.loadingClass+' show';if(this.currentId==0){this.prev.addClass('hide');}else if(this.prev.className !='btnnav prev'){this.prev.className='btnnav prev hide';}if(this.currentId==this.imgs.length-1){this.next.addClass('hide');}else if(this.next.className !='btnnav next'){this.next.className='btnnav next hide';}var ds=/.*\/([^\/]+\.[a-zA-Z]{3,4})$/.exec(img);if(ds){this.download.className='btnnav download';this.download.href=img;this.download.download=ds[1];}else{this.download.className='hidden';}window.setTimeout(function(){if(self.currentId==0){self.prev.className='hidden';}else{self.prev.className='btnnav prev';}if(self.currentId==self.imgs.length-1){self.next.className='hidden';}else{self.next.className='btnnav next';}},500);new preload(img,function(){self.loading.className=self.loadingClass;self.img.src=this.src;if(!fullscreen){var w=this.width;var h=this.height;var dm=self.body.getDimensions();var hOffset=dm.height-self.body.getClientHeight()+parseInt(self.body.getStyle('marginTop'))+parseInt(self.body.getStyle('marginBottom'));var wOffset=dm.width-self.body.getClientWidth()+parseInt(self.body.getStyle('marginLeft'))+parseInt(self.body.getStyle('marginRight'));var src_h=document.viewport.getHeight()-hOffset-20;var src_w=document.viewport.getWidth()-wOffset-20;var nw,nh;if(h>src_h){nh=src_h;nw=(src_h*w)/ h;}else if(w>src_w){nw=src_w;nh=(src_w*h)/ w;}else{nw=w;nh=h;}if(nw>src_w){nw=src_w;nh=(src_w*h)/ w;}else if(nh>src_h){nh=src_h;nw=(src_h*w)/ h;}self.img.style.width=nw+'px';self.img.style.height=nh+'px';}else{self.img.style.width='auto';self.img.style.height='auto';}if(title&&title !=''){self.caption.innerHTML=title.replace(/[\n]/g,'<br>');self.caption.parentNode.className='show';}else{self.caption.parentNode.className='';}self.div.style.display='block';self.div.firstChild.center();self.div.style.left=0;self.div.fadeIn(function(){self._show.call(self);});});return this;},hide:function(){if(Object.isFunction(this.onhide)){this.onhide.call(this);}var self=this;this.div.fadeOut();this.iframe.fadeOut(function(){self._hide.call(self);});return this;},overlay:function(){var frameId='iframe_'+this.div.id,self=this;if(!$E(frameId)){var io=$G(document.body).create('iframe',{id:frameId,height:'100%',frameBorder:0});io.setStyle('position','absolute');io.setStyle('zIndex',999);io.className=this.backgroundClass;io.style.display='none';}this.iframe=$G(frameId);if(this.iframe.style.display=='none'){this.iframe.style.left='0px';this.iframe.style.top='0px';this.iframe.style.display='block';this.iframe.fadeIn();$G(self.iframe.contentWindow.document).addEvent('click',function(e){self.hide();});var d=$G(document).getDimensions();this.iframe.style.height=d.height+'px';this.iframe.style.width='100%';}return this;},_show:function(){if(Object.isFunction(this.onshow)){this.onshow.call(this);}},_hide:function(){this.iframe.style.display='none';this.div.style.display='none';if(Object.isFunction(this.onclose)){this.onclose.call(this);}}};window.callClick=function(input,func){var doKeyDown=function(e){if(GEvent.keyCode(e)==13||e.key=='Enter'){if(func.call(this,e)!==true){GEvent.stop(e);return false;}}};input=$E(input);if(input&&input.onclick==null){input.style.cursor='pointer';input.tabIndex=0;input.onclick=func;$G(input).addEvent('keydown',doKeyDown);}};var GElement=new GNative();window.$G=function(e){return Object.isGElement(e)?e:GElement.init(e);};window.$E=function(e){e=Object.isString(e)?document.getElementById(e):e;return Object.isObject(e)?e:null;};var loadCompleted=function(){domloaded=true;if(document.addEventListener){document.removeEventListener('DOMContentLoaded',loadCompleted,false);window.removeEventListener('load',loadCompleted,false);}else{document.detachEvent('onreadystatechange',loadCompleted);window.detachEvent('onload',loadCompleted);}$G(document);$G(document.body);};if(document.addEventListener){document.addEventListener('DOMContentLoaded',loadCompleted,false);window.addEventListener('load',loadCompleted,false);}else{document.attachEvent('onreadystatechange',loadCompleted);window.attachEvent('onload',loadCompleted);}return $K;})();(function(){'use strict';window.GAutoComplete=GClass.create();GAutoComplete.prototype={initialize:function(id,o){var options={callBack:$K.emptyFunction,get:$K.emptyFunction,populate:$K.emptyFunction,populateLabel:$K.emptyFunction,onSuccess:$K.emptyFunction,onChanged:$K.emptyFunction,url:false,interval:500};for(var property in o){options[property]=o[property];}var cancelEvent=false,showing=false,listindex=0,list=[],req=new GAjax(),self=this;this.input=$G(id);this.text=this.input.value;this.dropdown=new GDropdown(this.input,{autoHeight:true,id:'gautocomplete_div',className:'gautocomplete'});var display=this.dropdown.getDropdown();function _movehighlight(id){listindex=Math.max(0,id);listindex=Math.min(list.length-1,listindex);var selItem=null;forEach(list,function(){if(listindex==this.itemindex){this.addClass('select');selItem=this;}else{this.removeClass('select');}});return selItem;}function _onSelect(){if(showing){_hide();try{self.input.datas=this.datas;options.callBack.call(this.datas,self.input);self.text=self.input.value;}catch(e){}}}function _onSuccess(){if(Object.isFunction(options.onSuccess)){try{var o={};o[self.input.id||self.input.name]=self.input.value;options.onSuccess.call(o);}catch(e){}}}var _mouseclick=function(){window.setTimeout(function(){self.input.focus();},1);_onSelect.call(this);_onSuccess();};var _mousemove=function(){_movehighlight(this.itemindex);};function _populateitems(datas){display.innerHTML='';list=[];var f,i,r,p,n;for(i in datas){if(datas[i]['options']){r=options.populateLabel.call(datas[i],self.input);p=r.toDOM();f=p.firstChild;$G(f).addClass('optgroup');display.appendChild(p);for(n in datas[i]['options']){r=options.populate.call(datas[i]['options'][n],self.input);if(r&&r !=''){p=r.toDOM();f=p.firstChild;f.datas=datas[i]['options'][n];$G(f).addEvent('mousedown',_mouseclick);f.addEvent('mousemove',_mousemove);f.itemindex=list.length;list.push(f);display.appendChild(p);}}}else{r=options.populate.call(datas[i],self.input);if(r&&r !=''){p=r.toDOM();f=p.firstChild;f.datas=datas[i];$G(f).addEvent('mousedown',_mouseclick);f.addEvent('mousemove',_mousemove);f.itemindex=list.length;list.push(f);display.appendChild(p);}}}_movehighlight(0);}function _hide(){self.input.removeClass('wait');self.dropdown.hide();showing=false;}var _search=function(){window.clearTimeout(self.timer);req.abort();if(self.text !=self.input.value){options.onChanged.call(self.input);}if(!cancelEvent&&options.url){var q=options.get.call(this);if(q&&q !=''){self.input.addClass('wait');self.timer=window.setTimeout(function(){req.send(options.url,q,function(xhr){self.input.removeClass('wait');if(xhr.responseText !==''){var datas=xhr.responseText.toJSON();listindex=0;if(datas){_populateitems(datas);}else{display.innerHTML=xhr.responseText;}self.dropdown.show();showing=true;}else{_hide();}});},options.interval);}else{_hide();}}cancelEvent=false;};function _showitem(item){if(item){var top=item.getTop()-display.getTop();var height=display.getHeight();if(top<display.scrollTop){display.scrollTop=top;}else if(top>=height){display.scrollTop=top-height+item.getHeight();}}}function _dokeydown(evt){var key=GEvent.keyCode(evt);if(key==40){_showitem(_movehighlight(listindex+1));cancelEvent=true;}else if(key==38){_showitem(_movehighlight(listindex-1));cancelEvent=true;}else if(key==13){cancelEvent=true;this.removeClass('wait');forEach(list,function(){if(this.itemindex==listindex){_onSelect.call(this);}});_onSuccess();}else if(key==32){if(this.value==''){_search();cancelEvent=true;}}if(cancelEvent){GEvent.stop(evt);}}this.input.addEvent('click',_search);this.input.addEvent('keyup',_search);this.input.addEvent('keydown',_dokeydown);this.input.addEvent('blur',_hide);$G(document.body).addEvent('click',_hide);},setText:function(value){this.input.value=value;this.text=value;},valid:function(){this.input.valid();this.text=this.input.value;return this.input;},invalid:function(){this.input.invalid();this.text=this.input.value;return this.input;},reset:function(){this.input.reset();this.text=this.input.value;return this.input;}};})();function initAutoComplete(id,link,displayFields,icon,options){var obj,df=displayFields.split(',');function doGetQuery(){var q=null,value=$E(id).value;if(value !=''){q=id+'='+encodeURIComponent(value);}return q;}function doCallBack(){for(var prop in this){if($E(prop)){$G(prop).setValue(this[prop]===null?'':this[prop]);}}obj.valid();}function doPopulateItem(){var datas=new Array();for(var i in df){if(this[df[i]] !==null&&this[df[i]] !=''){datas.push(this[df[i]]);}}return datas.join(' ').unentityify();}function doPopulateLabel(){return '<p><span class="icon-'+this.icon+'">'+this.label+'</span></p>';}function doPopulate(){if($E(id)){var row=o.populateItem.call(this);forEach($E(id).value.replace(/[\s]+/,' ').split(' '),function(){if(this.length>0){var patt=new RegExp('('+this.preg_quote()+')','gi');row=row.replace(patt,'<em>$1</em>');}});return '<p><span class="icon-'+(icon||this.icon||"search")+'">'+row+"</span></p>";}}var o={get:doGetQuery,populate:doPopulate,populateItem:doPopulateItem,populateLabel:doPopulateLabel,callBack:doCallBack,url:link};for(var prop in options){o[prop]=options[prop];}obj=new GAutoComplete(id,o);return obj;}(function(){"use strict";window.GDatalist=GClass.create();GDatalist.prototype={initialize:function(text,onChanged){if(!$E(text)){console.log('[Datalist] Cannot find target element '+text);return;}if($E(text).getAttribute('Datalist')){return;}this.input=$G(text);this.input.setAttribute('Datalist',true);this.datalist={};this.onChanged=onChanged||$K.returnFuntion;var _checkItemIndex=null,_inputItemIndex=this.input.value;this.changedTimeout=0;this.text=this.input.get('text');if(this.text===null){this.text='';this.customText=false;}else{this.customText=true;}this.input.removeAttribute('text');var cancelEvent=false,showing=false,listindex=0,list=[],self=this;this.input.reset=function(){_inputItemIndex=null;_checkItemIndex=null;self.input.value=null;};Object.defineProperty(this.input,'selectedIndex',{get:function(){return _inputItemIndex;},set:function(value){if(self.datalist[value]){self.input.value=self.datalist[value];}else{self.input.value='';}_inputItemIndex=value;_doChange();}});this.input.setDatalist=function(datas){self.datalist={};for(var key in datas){self.datalist[key]=datas[key];}listindex=0;self.input.value=self.datalist[_inputItemIndex]||self.text;};this.input.datalist=function(index){return self.datalist[index];};this.value_change=false;forEach($G(this.input.list).elems('option'),function(){self.datalist[this.value]=this.innerText;});this.input.list.remove();this.input.removeAttribute('list');this.input.value=this.datalist[_inputItemIndex]||this.text;this.dropdown=new GDropdown(this.input,{autoHeight:true,id:this.input.id+'_gautocomplete',className:'gautocomplete'});var display=this.dropdown.getDropdown();function _movehighlight(id){listindex=Math.max(0,id);listindex=Math.min(list.length-1,listindex);var selItem=null;forEach(list,function(){if(listindex==this.itemindex){this.addClass("select");selItem=this;}else{this.removeClass("select");}});return selItem;}function _onSelect(){if(showing){self.input.value=self.datalist[this.key];_inputItemIndex=this.key;self.value_change=false;_doChange();}}var _mouseclick=function(){_onSelect.call(this);window.setTimeout(function(){self.input.focus();},1);};var _mousemove=function(){_movehighlight(this.itemindex);};function _populateitem(key,text){var p=document.createElement('p');display.appendChild(p);p.innerHTML=text;$G(p).key=key;p.addEvent("mousedown",_mouseclick);p.addEvent("mousemove",_mousemove);p.itemindex=list.length;list.push(p);}function _hide(){self.dropdown.hide();showing=false;}var _search=function(){if(self.input.readOnly==false&&self.input.disabled==false){if(!cancelEvent){display.innerHTML="";var value,text=self.input.value,filter=new RegExp("("+text.preg_quote()+")","gi");listindex=0;list=[];if(self.datalist[_inputItemIndex] !=text){_inputItemIndex=null;self.value_change=true;}for(var key in self.datalist){value=self.datalist[key];if(text==''){_populateitem(key,value);}else{if(filter.test(value)){_populateitem(key,value.replace(filter,"<em>$1</em>"));}}}_movehighlight(0);if(list.length>0){window.setTimeout(function(){self.dropdown.show();},1);showing=true;}else{_hide();}}cancelEvent=false;}};function _showitem(item){if(item){var top=item.getTop()-display.getTop();var height=display.getHeight();if(top<display.scrollTop){display.scrollTop=top;}else if(top>=height){display.scrollTop=top-height+item.getHeight();}}}function _dokeydown(evt){var key=GEvent.keyCode(evt);if(key==40){_showitem(_movehighlight(listindex+1));cancelEvent=true;}else if(key==38){_showitem(_movehighlight(listindex-1));cancelEvent=true;}else if(key==13){cancelEvent=true;forEach(list,function(){if(this.itemindex==listindex){_onSelect.call(this);}});}else if(key==32){if(this.value==""){_search();cancelEvent=true;}}if(cancelEvent){GEvent.stop(evt);}}function _doChange(){if(_checkItemIndex !=_inputItemIndex){_checkItemIndex=_inputItemIndex;try{if(self.onChanged.call(self.input)){if(self.changedTimeout==0){self.changedTimeout=window.setTimeout(function(){self.changedTimeout=0;self.input.callEvent('change');},1);}}}catch(error){console.log(error);}}}this.input.addEvent("click",_search);this.input.addEvent("keyup",_search);this.input.addEvent("keydown",_dokeydown);this.input.addEvent("change",function(evt){window.clearTimeout(self.changedTimeout);self.changedTimeout=0;GEvent.stop(evt);_doChange();});this.input.addEvent("focus",function(){_search();this.select();});this.input.addEvent("blur",function(){if(self.value_change){if(!self.customText){self.input.value=null;}else{self.text=self.input.value;_inputItemIndex=null;}self.value_change=false;_doChange();}_hide();});_doChange();},isDatalist:function(){return this.input?true:false;}};window.Datalist=GClass.create();Datalist.prototype={initialize:function(text){this.input=$G(text);this.hidden=document.createElement("input");this.hidden.type='hidden';var name=this.input.name||this.input.id,id=this.input.id||this.input.name;this.hidden.name=name;this.input.id=id;if(name==id){this.input.name=name+'_text';}else{this.input.name=id;}this.hidden.value=this.input.value;var self=this,datalist=new GDatalist(text,function(){self.hidden.value=this.selectedIndex;return true;});if(datalist.isDatalist()){this.input.parentNode.appendChild(this.hidden);}else{this.hidden=null;}}};})();var GBanner=GClass.create();GBanner.prototype={initialize:function(div,options){this.options={className:"gbanner",slideTime:5000,backgroundImage:false,touchThumbnail:false,showNumber:false,loop:true};for(var property in options){this.options[property]=options[property];}this.slideshow=$G(div);this.slideshow.addClass(this.options.className);this.container=this.slideshow.querySelector("div");if(!this.container){this.container=document.createElement("div");this.slideshow.appendChild(this.container);}$G(this.container).className="slide_display";var tmp=this;this.next=this.container.create("span");this.next.className="btnnav next";this.next.title=trans("Next");callClick(this.next,function(){window.clearTimeout(tmp.SlideTime);tmp._nextSlide();});this.prev=this.container.create("span");this.prev.className="btnnav prev";this.prev.title=trans("Prev");callClick(this.prev,function(){window.clearTimeout(tmp.SlideTime);tmp._prevSlide();});this.buttons=$G(this.slideshow.create("div"));this.buttons.style.zIndex=2;this.buttons.className=this.options.touchThumbnail?'button_wrapper_thumbnail':'button_wrapper';this.button=$G(this.buttons.create("div"));this.button.className="button_container scroll";this.button.style.position="relative";this.datas=new Array();forEach(this.container.querySelectorAll(".figure"),function(){tmp._initItem(this);});this.drag=false;if(this.options.touchThumbnail){new GDragMove(this.button,this.buttons,{srcOnly:false,beginDrag:function(e){tmp.button.className="button_container";return true;},moveDrag:function(e){tmp.drag=true;var l=tmp.buttons.getWidth()-tmp.button.getWidth();if(l<0){tmp.button.style.left=Math.min(0,Math.max(l,e.mousePos.x-e.mouseOffset.x))+"px";}},endDrag:function(){tmp.button.className="button_container scroll";tmp.drag=false;return true;}});}this.currentId=-1;},add:function(picture,detail,url){var figure=document.createElement("figure");this.container.appendChild(figure);figure.className='figure';var img=document.createElement("img");img.src=picture;img.className="nozoom";figure.appendChild(img);if(detail&&detail !=""){var figcaption=document.createElement("figcaption");figure.appendChild(figcaption);var a=document.createElement("a");a.href=url;a.target="_blank";figcaption.appendChild(a);var span=document.createElement("span");span.innerHTML=detail;a.appendChild(span);}this._initItem(figure);return this;},JSONData:function(data){try{var datas=eval(data);for(var i=0;i<datas.length;i++){this.add(datas[i].picture,datas[i].detail||"",datas[i].url||"");}}catch(e){}return this;},_initItem:function(obj){var i=this.datas.length;this.datas.push($G(obj));var img=obj.querySelector("img"),a=$G(this.button.create("button"));var span=a.create("span");a.title=i;if(i==0){obj.addClass('show');}else{obj.removeClass('show');}if(img){if(this.options.backgroundImage){obj.style.backgroundImage="url("+img.src+")";img.style.display="none";}else{img.className="nozoom";}span.style.backgroundImage="url("+img.src+")";}else{span.style.backgroundImage=obj.style.backgroundImage;}if(this.options.showNumber){a.appendChild(document.createTextNode(i+1));}var tmp=this;a.style.cursor="pointer";a.addEvent("mouseup",function(){if(tmp.drag==false){window.clearTimeout(tmp.SlideTime);tmp._show(floatval(this.title));}});},_prevSlide:function(){if(this.datas.length>0){var next=this.currentId-1;if(next<0&&this.options.loop){next=this.datas.length-1;}this._playIng(next);}},_nextSlide:function(){if(this.datas.length>0){var next=this.currentId+1;if(next>=this.datas.length&&this.options.loop){next=0;}this._playIng(next);}},_playIng:function(id){if($E(this.slideshow.id)){this._show(id);if(this.datas.length>1){var temp=this;this.SlideTime=window.setTimeout(function(){temp.playSlideShow.call(temp);},this.options.slideTime);}}},playSlideShow:function(){this._nextSlide();return this;},_show:function(id){if(this.datas[id]){var figcaption;forEach(this.datas,function(item,index){figcaption=item.querySelector("figcaption");if(id==index){item.addClass('show');item.style.zIndex=1;if(figcaption){figcaption.className="show";}}else{item.removeClass('show');item.style.zIndex=0;if(figcaption){figcaption.className="";}}});this._setButton(id);this.currentId=id;}},_setButton:function(id){var tmp=this,current;forEach(this.button.elems("button"),function(){if(this.title==id){this.className="current";current=this;}else{this.className="";}});window.setTimeout(function(){var cw=tmp.buttons.getWidth(),bw=tmp.button.getWidth(),l=current.getLeft()-tmp.buttons.getLeft(),w=current.getWidth();if(bw>cw){if(l+w>cw){tmp.button.style.left=Math.min(0,Math.max(cw-bw,cw-(id+1)*w))+"px";}else if(l<0){tmp.button.style.left=Math.min(0,Math.max(cw-bw,-id*w))+"px";}}tmp.prev.style.left=id==0?-tmp.prev.getWidth()+"px":"0.5em";tmp.next.style.right=id==tmp.datas.length-1?-tmp.next.getWidth()+"px":"0.5em";},1);}};(function(){"use strict";window.GDragDrop=GClass.create();GDragDrop.prototype={initialize:function(id,options){this.options={dragClass:"icon-drag",itemClass:"sort",endDrag:$K.emptyFunction};for(var property in options){this.options[property]=options[property];}this.changed=false;var self=this,dropitems=new Array(),hoverItem=null,position=0;function checkMouseOver(item,mousePos){var elemPos=item.viewportOffset();var elemSize=item.getDimensions();var mouseover=mousePos.x>elemPos.left&&mousePos.y>elemPos.top;return(mouseover&&mousePos.x<elemPos.left+elemSize.width&&mousePos.y<elemPos.top+elemSize.height);}function doBeginDrag(){self.changed=false;self.dragItem=this;hoverItem=this;position=this.mousePos.y;}function doMoveDrag(){var temp=this;forEach(dropitems,function(){if(checkMouseOver(this,temp.mousePos)){if(this !=hoverItem){self.changed=true;if(temp.mousePos.y>position){temp.move.parentNode.insertBefore(temp.move,this.nextSibling);}else{temp.move.parentNode.insertBefore(temp.move,this);}hoverItem=this;return true;}}});position=this.mousePos.y;}function doEndDrag(){if(self.changed){self.options.endDrag.call(this);}}function _find(elem){if(elem.hasClass(self.options.dragClass)){return elem;}else{var els=$E(elem).getElementsByTagName("*");for(var i=0;i<els.length;i++){if($G(els[i]).hasClass(self.options.dragClass)){return els[i];}}}}var o={beginDrag:doBeginDrag,moveDrag:doMoveDrag,endDrag:doEndDrag};forEach($E(id).getElementsByTagName("*"),function(){if($G(this).hasClass(self.options.itemClass)){var drag=new GDrag(_find(this),o);drag.move=this;dropitems.push(this);}});}};})();function initFacebookButton(button,callback){callClick(button,function(){FB.login(function(response){if(response.authResponse){var accessToken=response.authResponse.accessToken;var uid=response.authResponse.userID;FB.api("/"+uid,{access_token:accessToken,fields:"id,first_name,last_name,email"},function(response){if(!response.error){var q=new Array();if($E("token")){q.push("token="+encodeURIComponent($E("token").value));}for(var prop in response){q.push(prop+"="+encodeURIComponent(response[prop]));}callback(q);}});}},{scope:"email,public_profile"});});}function initFacebook(appId,lng){window.fbAsyncInit=function(){FB.init({appId:appId,cookie:true,status:true,xfbml:true,version:"v7.0"});};loadJavascript("facebook-jssdk","//connect.facebook.net/"+(lng=="th"?"th_TH":"en_US")+"/sdk.js");}function fbLoginSubmit(q){send(WEB_URL+"index.php/"+($E("facebook_action")?$E("facebook_action").value:"index/model/fblogin/chklogin"),q.join("&"),function(xhr){var ds=xhr.responseText.toJSON();if(ds){if(ds.alert){alert(ds.alert);}if(ds.isMember==1){if($E("login_action")){window.location=$E("login_action").value;}else{window.location=window.location.href.replace("action=logout","action=login");}}}else if(xhr.responseText !=""){console.log(xhr.responseText);}});}var auth2;function initGooleSignin(google_client_id){loadJavascript("apis-google","https://apis.google.com/js/platform.js?onload=googleSigninLoad");window.google_client_id=google_client_id;}function googleSigninLoad(){gapi.load("auth2",function(){auth2=gapi.auth2.init({client_id:window.google_client_id+".apps.googleusercontent.com",cookiepolicy:"single_host_origin"});});}function initGoogleButton(button,callback){if($E(button)){window.setTimeout(function(){if(auth2){auth2.attachClickHandler($E(button),{},function(googleUser){var profile=googleUser.getBasicProfile(),q=new Array();if($E("token")){q.push("token="+$E("token").value);}q.push("id="+encodeURIComponent(profile.getId()));q.push("name="+encodeURIComponent(profile.getName()));q.push("image="+encodeURIComponent(profile.getImageUrl()));q.push("email="+encodeURIComponent(profile.getEmail()));callback(q);});}else{initGoogleButton(button,callback);}},100);}}function ggLoginSubmit(q){send(WEB_URL+"index.php/"+($E("google_action")?$E("google_action").value:"index/model/gglogin/chklogin"),q.join("&"),function(xhr){var ds=xhr.responseText.toJSON();if(ds){if(ds.alert){alert(ds.alert);}if(ds.isMember==1){if($E("login_action")){window.location=$E("login_action").value;}else{window.location=window.location.href.replace("action=logout","action=login");}}}else if(xhr.responseText !=""){console.log(xhr.responseText);}});}var GGraphs=(function(document){'use strict';var GGraphs=function(id,options){this.options={type:'line',rows:5,colors:[ '#438AEF','#FBB242','#DE4210','#259B24','#E91E63','#1F3D68','#FEE280','#1A9ADC','#C86A4C','#055CDA','#F2D086','#51627F','#F0B7A6','#DE8210','#7791BC' ],startColor:0,shadowColor:'rgba(0,0,0,0.2)',grid:true,gridHColor:'rgba(0,0,0,0.05)',gridVColor:'rgba(0,0,0,0.05)',zeroColor:'rgba(0,0,0,0.2)',barSpace:5,showTitle:true,lineWidth:2,linePointerSize:4,centerOffset:null,centerX:null,centerY:null,labelOffset:null,ringWidth:60,rotate:false,table:'auto',height:'200px'};for(let property in options){this.options[property]=options[property];}if(this.options.startColor>0){let temp=[],l=this.options.colors.length,i=Math.max(0,Math.min(l-1,this.options.startColor));for(let a=0;a<l;a++){temp.push(this.options.colors[i]);i=i<l-1?i+1:0;}this.options.colors=temp;}let wraper=$E(id),transparent=/rgba\([0-9a-fA-F,\s]+0\)/;this.graphs=$G(document.createElement('div'));this.graphs.style.height=this.options.height;wraper.insertBefore(this.graphs,wraper.firstChild);$G(wraper).addClass('ggraphs');this.panel=document.createElementNS('http://www.w3.org/2000/svg','svg');this.panel.style.width='100%';this.panel.style.height=this.options.height;this.graphs.appendChild(this.panel);this.backgroundColor=wraper.getStyle('backgroundColor');if(this.backgroundColor=='transparent'||transparent.test(this.backgroundColor)){this.backgroundColor=$G(document.body).getStyle('backgroundColor');}this.fontColor=wraper.getStyle('color');this.max=0;this.min=null;let self=this,table=null,_resize=function(){self._draw();};if(this.options.table=='auto'){table=wraper.getElementsByTagName('table')[0];}else if(this.options.table&&this.options.table !=''){table=document.getElementById(this.options.table);}if(table){this.setDatas(this._loadFromTable(table));}window.addEventListener('resize',_resize,true);};GGraphs.prototype.setDatas=function(datas){this.datas=this._reset();if(datas.headers.title){this.datas.headers.title=datas.headers.title;}if(datas.headers.items){this.datas.headers.items=datas.headers.items;}let self=this,headers=this.datas.headers;datas.rows.forEach(function(rows){let datas=[],d={},max=0,min=null,sum=0;if(rows.title){d.title=rows.title;}rows.items.forEach(function(item,row){sum=sum+item.value;max=Math.max(max,item.value);min=min==null?item.value:Math.min(min,item.value);if(!item.tooltip){item.tooltip=headers.title+' '+headers.items[row].text+' '+rows.title+' '+toCurrency(item.value,null,true);}datas.push({value:item.value,tooltip:item.tooltip});});d.items=datas;d.total=sum;if(min==max){min-=max;}d.max=max;d.min=min;self.datas.rows.push(d);self.max=Math.max(max,self.max);self.min=self.min==null?min:Math.min(min,self.min);if(self.min==self.max){self.max=self.min+self.options.rows;}});let range=this.max-this.min,rowHeight=Math.ceil(range / this.options.rows),p=1;while(Math.ceil(rowHeight / p)*p<=rowHeight){p=p*10;}if(p<rowHeight){rowHeight=Math.ceil(rowHeight / p)*p;if(this.min>=0){this.min=Math.floor(this.min / p)*p;}else if(this.max<=0){this.max=0;}}if(this.min>=0){this.max=this.min+(rowHeight*this.options.rows);}else{this.min=this.max-(rowHeight*this.options.rows);}this._draw();};GGraphs.prototype._loadFromTable=function(table){let datas=this._reset();table.querySelectorAll('thead:first-child>tr:first-child>th').forEach(function(item,index){if(index==0){datas.headers.title=item.innerHTML.strip_tags().replace(/&nbsp;/g,'');}else{let node=item.innerHTML,ds=/href=['"]([^'"]+)/.exec(node),hs=/target=['"]{0,}([_a-z]+)/.exec(node);datas.headers.items.push({text:node.strip_tags(),href:ds?ds[1]:null,target:hs?hs[1]:null});}});table.querySelectorAll('tbody>tr').forEach(function(tr){let rows=[],d={};tr.querySelectorAll('td,th').forEach(function(item){let val={};if(item.tagName=='TH'){d.title=item.innerHTML.strip_tags();}else{if(item.dataset.value){val.value=floatval(item.dataset.value);}else{val.value=floatval(item.innerHTML.replace(/,/g,''));}if(item.dataset.tooltip){val.tooltip=item.dataset.tooltip;}val.title=item.innerHTML.strip_tags();rows.push(val);}});d.items=rows;datas.rows.push(d);});return datas;};GGraphs.prototype._draw=function(){let dm=$G(this.graphs).getDimensions();this.panel.innerHTML='';this.panel.setAttribute('viewBox','0 0 '+dm.width+' '+dm.height);this.width=dm.width;this.height=dm.height;if(this.options.type=='line'){this._drawLine(false);}else if(this.options.type=='spline'){this._drawLine(true);}else if(this.options.type=='pie'){this._drawPie(false);}else if(this.options.type=='donut'){this._drawPie(true);}else if(this.options.type=='hchart'){this._drawHChart();}else{this._drawVChart();}};GGraphs.prototype._drawLine=function(spline){let options=this.options,self=this,headers=this.datas.headers.items,pointerStroke=(options.linePointerSize*options.ringWidth)/ 100,pointerSize=options.linePointerSize+pointerStroke,offsetRight=pointerSize,labelWidth=pointerSize,labelHeight=pointerSize,offsetBottom=0,step=(this.max-this.min)/ options.rows,labelValue=this.max,labelText,rc,labels=[];if(options.grid){if(options.rotate){headers.forEach(function(item){rc=self._getTextSize(item.text);offsetBottom=Math.max(offsetBottom,rc.width);offsetRight=rc.height / 2;});}else{rc=self._getTextSize(headers[headers.length-1].text);offsetBottom=Math.max(offsetBottom,rc.height);offsetRight=rc.width / 2;}}for(let r=0;r<=options.rows;r++){labelText=toCurrency(labelValue,null,true);labels.push(labelText);if(options.grid){rc=self._getTextSize(labelText);labelWidth=Math.max(labelWidth,rc.width);labelHeight=Math.max(labelHeight,rc.height);}labelValue-=step;}let top=options.grid?labelHeight / 2:offsetRight,bottom=this.height-offsetBottom-pointerSize-(options.rotate?5:0),clientHeight=bottom-top,rowHeight=clientHeight / options.rows,labeloffset=options.grid?10:0,y=top,x=labelWidth+labeloffset,columnWidth=(this.width-offsetRight-x)/ Math.max(1,headers.length-1),panel=this.panel;if(options.grid){labels.forEach(function(row){self.line(panel,labelWidth+labeloffset,y,self.width-offsetRight,y,options.gridVColor,1);self.text(panel,labelWidth,y,row,self.fontColor,'right');y+=rowHeight;});headers.forEach(function(row){self.line(panel,x,top,x,bottom,options.gridHColor,1);if(options.rotate){self.text(panel,x,bottom+top-pointerSize,row.text,self.fontColor,'left',true);}else{self.text(panel,x,bottom+top+pointerSize,row.text,self.fontColor,'center');}x+=columnWidth;});}let xp,yp,color,marker,point,id,zero=clientHeight+top-Math.floor((clientHeight*(0-self.min))/(self.max-self.min)),markers={};if(options.zeroColor&&this.min<0&&this.max>0){self.dash(panel,labelWidth+labeloffset,zero,self.width-offsetRight,zero,options.zeroColor,1);}this.datas.rows.forEach(function(rows,row){color=options.colors[row % options.colors.length];rows.items.forEach(function(item,index){x=labelWidth+labeloffset+(columnWidth*index);y=clientHeight+top-Math.floor((clientHeight*(item.value-self.min))/(self.max-self.min));if(index>0){if(spline){self.curve(panel,xp,yp,(xp+x)/ 2,yp,x,y,(xp+x)/ 2,y,color,options.lineWidth);}else{self.line(panel,xp,yp,x,y,color,options.lineWidth);}}marker={x:x,y:y,color:color,tooltip:item.tooltip};id=index+'_'+item.value;if(markers[id]){markers[id].push(marker);}else{markers[id]=[marker];}xp=x;yp=y;});});for(id in markers){let tooltip=[];markers[id].forEach(function(marker){tooltip.push(marker.tooltip);});markers[id].forEach(function(marker){point=self.circle(panel,marker.x,marker.y,options.linePointerSize,self.backgroundColor,marker.color,pointerStroke);self.setTooltip(point,tooltip.join("\n"));});};this._displayTitle(this.datas.rows);};GGraphs.prototype._drawPie=function(donut){let options=this.options,self=this,centerX=options.centerX==null?Math.round(this.width / 2):options.centerX,centerY=options.centerY==null?Math.round(this.height / 2):options.centerY,radius=centerY-(options.centerOffset||(this.height*0.15)),currentValue=0,currentRate=0,cummulatedValue=0,cummulatedRate=0,fillColor,piece,panel=this.panel,totalValue=this.datas.rows[0].total,labelOffset=options.labelOffset||(this.height*0.15),distance=(radius / 2.5)*(Math.pow(1-2.5 / radius,0.8)+1)+labelOffset;forEach(this.datas.rows[0].items,function(item,index){fillColor=options.colors[index % options.colors.length];currentValue=item.value;currentRate=currentValue / totalValue;if(currentRate==1.0){piece=self.circle(panel,centerX,centerY,radius,fillColor,self.backgroundColor);}else{piece=self.pie(panel,centerX,centerY,radius,cummulatedRate,cummulatedRate+currentRate,fillColor,self.backgroundColor);}self.setTooltip(piece,item.tooltip);let midAngle=cummulatedRate+currentRate / 2,labelX=Math.round(centerX+Math.sin(midAngle*Math.PI*2)*distance),labelY=Math.round(centerY-Math.cos(midAngle*Math.PI*2)*distance);self.line(panel,centerX,centerY,labelX,labelY,fillColor,1);if(labelX<centerX){self.line(panel,labelX-5,labelY,labelX,labelY,fillColor,1);self.text(panel,labelX-10,labelY,toCurrency(currentValue,null,true),fillColor,'right');}else{self.line(panel,labelX,labelY,labelX+5,labelY,fillColor,1);self.text(panel,labelX+10,labelY,toCurrency(currentValue,null,true),fillColor);}cummulatedValue+=currentValue;cummulatedRate=cummulatedValue / totalValue;});if(donut){self.circle(panel,centerX,centerY,radius*options.ringWidth / 100,self.backgroundColor);}this._displayTitle(this.datas.headers.items);};GGraphs.prototype._drawHChart=function(){let options=this.options,self=this,headers=this.datas.headers.items,offsetRight=0,labelWidth=0,labelHeight=0,step=(this.max-this.min)/ options.rows,labelValue=this.min,labelText,rc,offsetBottom=0,labels=[];if(options.grid){for(let r=0;r<=options.rows;r++){labelText=toCurrency(labelValue,null,true);labels.push(labelText);if(options.rotate){rc=self._getTextSize(labelText);offsetBottom=Math.max(offsetBottom,rc.width);offsetRight=rc.height / 2;}labelValue+=step;}if(!options.rotate){rc=self._getTextSize(labels[labels.length-1]);offsetBottom=rc.height;offsetRight=rc.width / 2;}headers.forEach(function(item){rc=self._getTextSize(item.text);labelWidth=Math.max(labelWidth,rc.width);labelHeight=Math.max(labelHeight,rc.height);});}let top=0,bottom=this.height-offsetBottom-(options.rotate?5:0),clientHeight=bottom-top,cellHeight=clientHeight / headers.length,labeloffset=options.grid?10:0,y=top,middleRow=cellHeight / 2,x=labelWidth+labeloffset,columnWidth=(this.width-offsetRight-x)/ options.rows,panel=this.panel;if(options.grid){headers.forEach(function(row){self.line(panel,labelWidth+labeloffset,y,self.width-offsetRight,y,options.gridVColor,1);self.text(panel,0,y+middleRow,row.text,self.fontColor,'left');y+=cellHeight;});self.line(panel,labelWidth+labeloffset,y,self.width-offsetRight,y,options.gridVColor,1);labels.forEach(function(row){self.line(panel,x,top,x,bottom,options.gridHColor,1);if(options.rotate){self.text(panel,x,bottom+top+5,row,self.fontColor,'left',true);}else{self.text(panel,x,bottom+top+labelHeight-5,row,self.fontColor,'center');}x+=columnWidth;});}let rowCount=this.datas.rows.length,itemHeight=Math.max(1,(cellHeight-(options.barSpace*(rowCount+1)))/ rowCount),barSpace=(cellHeight-(itemHeight*rowCount))/(rowCount+1),barHeight=itemHeight>4?itemHeight-2:itemHeight,rx=labelWidth+labeloffset,clientWidth=options.rows*columnWidth,zero=(self.min>=0?0:clientWidth-(clientWidth*self.max)/(self.max-self.min)),ry,rw,rect,color;if(options.zeroColor&&this.min<0&&this.max>0){self.line(panel,zero+rx,top,zero+rx,bottom,options.zeroColor,1);}this.datas.rows.forEach(function(rows,row){y=top;rows.items.forEach(function(item,index){color=options.colors[(rowCount>1?row:index)% options.colors.length];ry=y+(row*itemHeight)+((row+1)*barSpace);rw=Math.max(2,Math.abs((clientWidth*(item.value-Math.max(0,self.min)))/(self.max-self.min)));if(self.min>=0||item.value>0){if(itemHeight>4){self.rect(panel,zero+rx,ry+2,rw+2,barHeight,options.shadowColor);}rect=self.rect(panel,zero+rx,ry,rw,barHeight,color);}else if(self.max<=0||item.value<0){if(itemHeight>4){self.rect(panel,zero-rw+rx+2,ry+2,rw-2,barHeight,options.shadowColor);}rect=self.rect(panel,zero-rw+rx,ry,rw,barHeight,color);}else{rect=self.rect(panel,zero+rx-1,ry,2,barHeight,color);}self.setTooltip(rect,item.tooltip);y+=cellHeight;});});this._displayTitle(this.datas.rows);};GGraphs.prototype._drawVChart=function(){let options=this.options,self=this,headers=this.datas.headers.items,pointerStroke=(options.linePointerSize*options.ringWidth)/ 100,pointerSize=options.linePointerSize+pointerStroke,offsetRight=pointerSize,labelWidth=pointerSize,labelHeight=pointerSize,offsetBottom=0,step=(this.max-this.min)/ options.rows,labelValue=this.max,labelText,rc,labels=[];if(options.grid){if(options.rotate){headers.forEach(function(item){rc=self._getTextSize(item.text);offsetBottom=Math.max(offsetBottom,rc.width);offsetRight=rc.height / 2;});}else{rc=self._getTextSize(headers[headers.length-1].text);offsetBottom=Math.max(offsetBottom,rc.height);offsetRight=rc.width / 2;}}for(let r=0;r<=options.rows;r++){labelText=toCurrency(labelValue,null,true);labels.push(labelText);if(options.grid){rc=self._getTextSize(labelText);labelWidth=Math.max(labelWidth,rc.width);labelHeight=Math.max(labelHeight,rc.height);}labelValue-=step;}let top=options.grid?labelHeight / 2:offsetRight,bottom=this.height-offsetBottom-pointerSize-(options.rotate?5:0),clientHeight=bottom-top,rowHeight=clientHeight / options.rows,labeloffset=options.grid?10:0,y=top,x=labelWidth+labeloffset,cellWidth=(this.width-offsetRight-x)/ headers.length,midCell=cellWidth / 2,panel=this.panel;if(options.grid){labels.forEach(function(row){self.line(panel,labelWidth+labeloffset,y,self.width-offsetRight,y,options.gridVColor,1);self.text(panel,labelWidth,y,row,self.fontColor,'right');y+=rowHeight;});headers.forEach(function(row){self.line(panel,x,top,x,bottom,options.gridHColor,1);if(options.rotate){self.text(panel,x+midCell,bottom+top-pointerSize,row.text,self.fontColor,'left',true);}else{self.text(panel,x+midCell,bottom+top+pointerSize,row.text,self.fontColor,'center');}x+=cellWidth;});self.line(panel,x,top,x,bottom,options.gridHColor,1);}let colCount=this.datas.rows.length,itemWidth=Math.max(1,(cellWidth-(options.barSpace*(colCount+1)))/ colCount),barSpace=(cellWidth-(itemWidth*colCount))/(colCount+1),barWidth=itemWidth>4?itemWidth-2:itemWidth,rx,zero=self.min>=0?clientHeight:(clientHeight*self.max)/(self.max-self.min),rh,rect,color;if(options.zeroColor&&this.min<0&&this.max>0){self.line(panel,labelWidth+labeloffset,zero+top,self.width-offsetRight,zero+top,options.zeroColor,1);}this.datas.rows.forEach(function(rows,row){x=labelWidth+labeloffset;rows.items.forEach(function(item,index){color=options.colors[(colCount>1?row:index)% options.colors.length];rx=x+(row*itemWidth)+((row+1)*barSpace);rh=Math.max(2,Math.abs((clientHeight*(item.value-Math.max(0,self.min)))/(self.max-self.min)));if(self.min>=0||item.value>0){if(itemWidth>4){self.rect(panel,rx+2,zero-rh+top+2,barWidth,rh-2,options.shadowColor);}rect=self.rect(panel,rx,zero-rh+top,barWidth,rh,color);}else if(self.max<=0||item.value<0){if(itemWidth>4){self.rect(panel,rx+2,zero+top+1,barWidth,rh+1,options.shadowColor);}rect=self.rect(panel,rx,zero+top+1,barWidth,rh-1,color);}else{rect=self.rect(panel,rx,zero+top-1,barWidth,2,color);}self.setTooltip(rect,item.tooltip);x+=cellWidth;});});this._displayTitle(this.datas.rows);};GGraphs.prototype.setTooltip=function(item,text){let self=this,hideTooltip=function(){self.graphs.style.cursor='default';self.graphs.title='';},showTooltip=function(){self.graphs.style.cursor='pointer';self.graphs.title=text;};item.addEventListener('mouseover',hideTooltip);item.addEventListener('mousemove',showTooltip);item.addEventListener('mouseout',hideTooltip);};GGraphs.prototype._reset=function(){return{headers:{title:'',items:[]},rows:[]};};GGraphs.prototype._getFontSize=function(){let div=document.createElement('div'),atts={fontSize:'1em',padding:'0',position:'absolute',lineHeight:'1',visibility:'hidden'};for(let p in atts){div.style[p]=atts[p];}div.appendChild(document.createTextNode('M'));this.graphs.appendChild(div);let h=div.offsetHeight;this.graphs.removeChild(div);return h;};GGraphs.prototype._getTextSize=function(value){let svg=document.createElementNS('http://www.w3.org/2000/svg','svg'),text=document.createElementNS('http://www.w3.org/2000/svg','text');text.innerHTML=value;text.setAttribute('x',100);text.setAttribute('y',100);svg.appendChild(text);this.graphs.appendChild(svg);let rc=text.getBBox();this.graphs.removeChild(svg);return{width:rc.width,height:rc.height,};};GGraphs.prototype._displayTitle=function(headers){if(this.options.showTitle){let label,div,span,self=this,wrapper=this.graphs.parentNode,lbs=wrapper.getElementsByClassName('bottom_label');if(lbs.length==0){div=document.createElement('div');wrapper.insertBefore(div,this.graphs.nextSibling);div.className='bottom_label';}else{div=lbs[0];div.innerHTML='';}headers.forEach(function(item,index){if(item.title||item.text){label=document.createElement('div');span=document.createElement('span');span.style.backgroundColor=self.options.colors[index % self.options.colors.length];label.appendChild(span);if(item.text&&item.href){span=document.createElement('a');span.innerHTML=item.text;span.href=item.href.replace(/&amp;/g,'&');if(item.target){span.target=item.target;}}else{span=document.createElement('span');span.innerHTML=item.title?item.title:item.text;}label.appendChild(span);div.appendChild(label);}});}};GGraphs.prototype.circle=function(parent,cx,cy,r,color,strokeColor,strokeWidth){let circle=document.createElementNS('http://www.w3.org/2000/svg','circle');circle.setAttribute('cx',cx);circle.setAttribute('cy',cy);circle.setAttribute('r',r);circle.setAttribute('fill',color);if(strokeColor&&strokeWidth){circle.setAttribute('stroke',strokeColor);circle.setAttribute('stroke-width',strokeWidth);}parent.appendChild(circle);return circle;};GGraphs.prototype.pie=function(parent,cx,cy,r,from,to,color,strokeColor){let fromDegree=from*360-90,toDegree=to*360-90,over180=to-from>0.5?'1':'0',fromRadian=fromDegree*Math.PI / 180.0,toRadian=toDegree*Math.PI / 180.0,fromX=cx+r*Math.cos(fromRadian),fromY=cy+r*Math.sin(fromRadian),toX=cx+r*Math.cos(toRadian),toY=cy+r*Math.sin(toRadian),moveTo='M '+cx+' '+cy,lineTo1='L '+fromX+' '+fromY,arc='A '+r+' '+r+' 0 '+over180+' 1 '+toX+' '+toY,lineTo2='L '+cx+' '+cy,pie=document.createElementNS('http://www.w3.org/2000/svg','path');pie.setAttribute('d',moveTo+' '+lineTo1+' '+arc+' '+lineTo2+' Z');pie.setAttribute('fill',color);if(strokeColor){pie.setAttribute('stroke',strokeColor);pie.setAttribute('stroke-width',1);}parent.appendChild(pie);return pie;};GGraphs.prototype.curve=function(parent,x1,y1,cx1,cy1,x2,y2,cx2,cy2,stroke,width){let moveTo='M '+x1+' '+y1,curveTo='C '+cx1+' '+cy1+' '+cx2+' '+cy2+' '+x2+' '+y2,strokeWidth=undefined==width?1:width,curve=document.createElementNS('http://www.w3.org/2000/svg','path');curve.setAttribute('d',moveTo+' '+curveTo);curve.setAttribute('fill','transparent');curve.setAttribute('stroke',stroke);curve.setAttribute('stroke-width',strokeWidth);parent.appendChild(curve);return curve;};GGraphs.prototype.rect=function(parent,x,y,width,height,fill,stroke){let rect=document.createElementNS('http://www.w3.org/2000/svg','rect');rect.setAttribute('x',x);rect.setAttribute('y',y);rect.setAttribute('width',Math.max(0,width));rect.setAttribute('height',Math.max(0,height));rect.setAttribute('fill',fill);rect.setAttribute('stroke',stroke);parent.appendChild(rect);return rect;};GGraphs.prototype.line=function(parent,x1,y1,x2,y2,color,lineWidth){let moveTo='M '+x1+' '+y1,lineTo='L '+x2+' '+y2,line=document.createElementNS('http://www.w3.org/2000/svg','path');line.setAttribute('d',moveTo+' '+lineTo+' Z');line.setAttribute('fill','none');line.setAttribute('stroke',color);line.setAttribute('stroke-width',lineWidth);parent.appendChild(line);return line;};GGraphs.prototype.dash=function(parent,x1,y1,x2,y2,color,lineWidth){let moveTo='M '+x1+' '+y1,lineTo='L '+x2+' '+y2,line=document.createElementNS('http://www.w3.org/2000/svg','path');line.setAttribute('d',moveTo+' '+lineTo+' Z');line.setAttribute('fill','none');line.setAttribute('stroke',color);line.setAttribute('stroke-width',lineWidth);line.setAttribute('stroke-dasharray','5,5');parent.appendChild(line);return line;};GGraphs.prototype.text=function(parent,x,y,value,color,align,rotate){let text=document.createElementNS('http://www.w3.org/2000/svg','text');text.setAttribute('fill',color);text.setAttribute('x',x);text.setAttribute('y',y);text.setAttribute('alignment-baseline','middle');if(rotate){text.setAttribute('transform','rotate(90 '+x+' '+y+')');}if(align=='right'){text.setAttribute('text-anchor','end');}else if(align=='center'){text.setAttribute('text-anchor','middle');}else{text.setAttribute('text-anchor','start');}text.innerHTML=value;parent.appendChild(text);return text;};return GGraphs;})(document);(function(){"use strict";window.GRange=GClass.create();GRange.prototype={initialize:function(id,o){if(!$E(id)){console.log("[GRange] Cannot find target element "+id);return;}this.input=$G(id);if(this.input.getAttribute('GRange')){return;}this.input.setAttribute('GRange',true);this.rate=100;for(var prop in o){this[prop]=o[prop];}var minValue=floatval(this.input.get("min")||0),maxValue=floatval(this.input.get("max")||99),range=maxValue-minValue,values=[minValue,maxValue],step=floatval(this.input.get("step"));if(step==0){if(range<1){step=0.01;}else if(range<100){step=1;}else{step=Math.floor((range / 100)*1000)/ 1000;}}if(this.input.get("value")!=null){var vs=this.input.get("value").split(",");values[0]=floatval(vs[0]);if(vs[1]&&vs[1] !=""){values[1]=floatval(vs[1]);}}this.input.set("type","hidden");this.input.min=minValue;this.input.max=maxValue;this.input.step=step;this.oldvalue={value:this.input.get("value"),minValue:minValue,maxValue:maxValue,step:step};this.slider=$G(document.createElement("div"));this.width=this.slider.getDimensions().width;this.slider.className="grange_div";this.input.parentNode.appendChild(this.slider);if(this.input.get("range")!==null){this.range=$G(document.createElement("div"));this.range.className="grange_range";this.slider.appendChild(this.range);}this.pointerL=$G(document.createElement("div"));this.pointerL.className="grange_button btnleft";this.pointerL.tabIndex=0;this.slider.appendChild(this.pointerL);var HInstant=this;this.slider.addEvent("mousedown",function(e){var elem=GEvent.element(e);if(elem==HInstant.slider||elem==HInstant.range){var pos=GEvent.pointerX(e)-this.viewportOffset().left-HInstant.pointerL.getDimensions().width / 2,oldvalue=HInstant.getValue(),onchange=false,value,l=floatval(HInstant.pointerL.getStyle("left"));if(HInstant.pointerR&&pos>l){var r=floatval(HInstant.pointerR.getStyle("left"));if(pos>l&&(pos>r||r-pos<pos-l)){value=HInstant.setX(HInstant.pointerR,pos);}else{value=HInstant.setX(HInstant.pointerL,pos);}if(oldvalue[0] !=value[0]||oldvalue[1] !=value[1]){onchange=true;}}else{value=HInstant.setX(HInstant.pointerL,pos);if(value !=oldvalue){onchange=true;}}if(onchange){HInstant.input.callEvent("change");}}});this.slider.addEvent("click",function(e){var elem=GEvent.element(e);if(elem&&(elem==HInstant.pointerL||elem==HInstant.pointerR)){elem.focus();}});this.slider.addEvent("keydown",function(e){var key=GEvent.keyCode(e);if(key==37||key==39){var value=HInstant.getValue(),input=GEvent.element(e),step=floatval(HInstant.input.step),oldvalue=HInstant.getValue();if(key==37){if(HInstant.pointerR){if(input==HInstant.pointerR){value[1]=value[1]-step;}else{value[0]=value[0]-step;}}else{value=value-step;}}else if(key==39){if(HInstant.pointerR){if(input==HInstant.pointerR){value[1]=value[1]+step;}else{value[0]=value[0]+step;}}else{value=value+step;}}value=HInstant.setValue(value,input);if(HInstant.pointerR){if(oldvalue[0] !=value[0]||oldvalue[1] !=value[1]){HInstant.input.callEvent("change");}}else if(oldvalue !=value){HInstant.input.callEvent("change");}}else if(key==40&&HInstant.pointerR){HInstant.pointerL.focus();GEvent.stop(e);}else if(key==38&&HInstant.pointerR){HInstant.pointerR.focus();GEvent.stop(e);}});var o={moveDrag:function(e){var cw=HInstant.getWidth(),pos=Math.min(cw,Math.max(0,e.mousePos.x-e.mouseOffset.x));HInstant.setX(this,pos);},endDrag:function(e){HInstant.input.callEvent("change");}};new GDragMove(this.pointerL,this.pointerL,o);if(this.range){this.pointerR=$G(document.createElement("div"));this.pointerR.className="grange_button btnright";this.pointerR.tabIndex=0;this.slider.appendChild(this.pointerR);new GDragMove(this.pointerR,this.pointerR,o);this.setValue(values,null);}else{this.pointerR=null;this.setValue(values[0],null);}this.timer=window.setInterval(function(){if(!$E(HInstant.input)){window.clearInterval(HInstant.timer);}else{var w=HInstant.slider.getDimensions().width;if(w !=HInstant.width){HInstant.width=w;HInstant.setValue(HInstant.getValue(),null);}else if(HInstant.oldvalue.value !=HInstant.input.value||HInstant.oldvalue.minValue !=HInstant.input.min||HInstant.oldvalue.maxValue !=HInstant.input.max||HInstant.oldvalue.step !=HInstant.input.step){HInstant.setValue(HInstant.getValue(),null);}}},100);},setX:function(button,pos){button.style.left=pos+"px";var val=floatval(this.input.min)+(this.getRange()*pos)/ this.getWidth();if(this.pointerR){var values=this.getValue();if(this.pointerL==button){values[0]=val;if(val>values[1]){values[1]=val;}}else{values[1]=val;if(val<values[0]){values[0]=val;}}this.setValue(values,button);}else{this.setValue(val,button);values=val;}window.setTimeout(function(){button.focus();},1);return values;},getWidth:function(){return(this.slider.getDimensions().width-this.pointerL.getDimensions().width);},getRange:function(){return floatval(this.input.max)-floatval(this.input.min);},getValue:function(){if(this.pointerR){var values=this.input.value.split(",");return [floatval(values[0]),floatval(values[1])];}else{return floatval(this.input.value);}},calcValue:function(value){var step=floatval(this.input.step),ss=this.input.step.split(".");value=Math.round(value / step)*step;value=Math.min(floatval(this.input.max),value);value=Math.max(floatval(this.input.min),value);if(ss[1]&&ss[1] !=""){value=floatval(value.toFixed(ss[1].length));}return value;},setValue:function(value,button){var oldvalue=this.getValue(),cw=this.getWidth(),range=this.getRange(),min=floatval(this.input.min),oninput=false,bw=this.pointerL.getDimensions().width;if(this.pointerR){value[0]=this.calcValue(value[0]);value[1]=this.calcValue(value[1]);if(button !=null&&value[1]<value[0]){if(button==this.pointerR){value[0]=value[1];}else if(button==this.pointerL){value[1]=value[0];}}var l=value[0]-min,r=value[1]-min;this.pointerR.style.left=(cw*r)/ range+"px";this.range.style.left=bw / 2+(cw*l)/ range+"px";this.range.style.width=(cw*(r-l))/ range+"px";this.input.value=value.join(",");if(oldvalue[0] !=value[0]||oldvalue[1] !=value[1]){oninput=true;}}else{value=this.calcValue(value);var l=value-min;this.input.value=value;if(oldvalue !=value){oninput=true;}}this.oldvalue.value=this.input.value;this.pointerL.style.left=(cw*l)/ range+"px";if(oninput){this.input.callEvent("input");}return value;}};})();(function(){"use strict";window.GSelect=GClass.create();GSelect.prototype={initialize:function(elem){if(elem.checkbox !==null){var id=elem.id||elem.name.replace(/\[(.*?)\]/,'$1'),name=elem.name||elem.id,placeholder=elem.get('placeholder')||trans('Please select'),select=document.createElement('div'),display=document.createElement('div'),showing=0,list=[],listindex=0;select.id=id;select.className='dropdown input-select';select.tabIndex=0;select.style.cursor='pointer';elem.parentNode.appendChild(select);display.className='input-display';select.appendChild(display);$G(display).id=id+'_display';var panel=new GDropdown($G(select),{autoHeight:true,id:id+'_gautocomplete',className:'gautocomplete'});var dropdown=panel.getDropdown();dropdown.innerHTML='';Object.defineProperty(select,'disabled',{get:function(){return select.hasClass('disabled')?true:false;},set:function(value){if(value){select.addClass('disabled');}else{select.removeClass('disabled');}},});Object.defineProperty(select,'readOnly',{get:function(){return select.hasClass('readonly')?true:false;},set:function(value){if(value){select.addClass('readonly');}else{select.removeClass('readonly');}},});Object.defineProperty(select,'value',{get:function(){var results=[];forEach(select.getElementsByTagName('input'),function(){results.push(this.value);});return results;},set:function(value){_setValue(value);}});Object.defineProperty(select,'options',{set:function(value){list=[];dropdown.innerHTML='';listindex=0;for(var key in value){select.addItem(key,value[key],false);}},});if(elem.disabled){select.disabled=true;}if(elem.get('readonly')!=null){select.readonly=true;}function _doChanged(values){if(values.length==0){display.innerText=placeholder;}else if(values.length<3){var vs=[];forEach(values,function(){vs.push(this.innerText);});display.innerText=vs.join(',');}else{display.innerText='+'+values.length+' '+trans('items');}window.setTimeout(function(){select.callEvent('change');});}function _itemMouseDown(){if(!select.hasClass('readonly')){this.className=this.hasClass('icon-check')?'icon-uncheck':'icon-check';}if(showing>0){window.clearTimeout(showing);}showing=window.setTimeout(function(){showing=0;},1000);}function _itemMouseMove(){_movehighlight(this.itemindex);}select.addItem=function(value,text,checked){var item=document.createElement('label'),className=checked?'icon-check':'icon-uncheck';$G(item).itemindex=list.length;className+=listindex==item.itemindex?' select':'';item.className=className;item.value=value;item.changed=0;list.push(item);item.innerHTML=text;item.addEvent("click",function(){if(item.changed==0){item.changed=window.setTimeout(function(){item.changed=0;changed();},1);}select.focus();});item.addEvent("mousedown",_itemMouseDown);item.addEvent("mousemove",_itemMouseMove);dropdown.appendChild(item);};function _movehighlight(id){listindex=Math.max(0,id);listindex=Math.min(list.length-1,listindex);var selItem=null;forEach(list,function(){if(listindex==this.itemindex){this.addClass('select');selItem=this;}else{this.removeClass('select');}});return selItem;}function _setValue(value){var className,input,values=[];forEach(select.getElementsByTagName('input'),function(){select.removeChild(this);});forEach(dropdown.getElementsByTagName('label'),function(){if(value.indexOf(this.value)>-1||value.indexOf(floatval(this.value))>-1){className='icon-check';input=document.createElement('input');input.type='hidden';input.name=name+'[]';input.value=this.value;select.appendChild(input);values.push(this);}else{className='icon-uncheck';}this.className=className+(listindex==this.itemindex?' select':'');});_doChanged(values);}function changed(){var values=[];forEach(dropdown.getElementsByTagName('label'),function(){if(this.hasClass('icon-check')){values.push(this.value);}});_setValue(values);}function _showitem(item){if(item){var top=item.getTop()-dropdown.getTop();var height=dropdown.getHeight();if(top<dropdown.scrollTop){dropdown.scrollTop=top;}else if(top>=height){dropdown.scrollTop=top-height+item.getHeight();}}}function _dokeydown(evt){if(!select.hasClass('disabled')){var cancelEvent=false,key=GEvent.keyCode(evt);if(key==40){_showitem(_movehighlight(listindex+1));cancelEvent=true;}else if(key==38){_showitem(_movehighlight(listindex-1));cancelEvent=true;}else if(key==32&&!select.hasClass('readonly')){list[listindex].className=list[listindex].hasClass('icon-check')?'icon-uncheck select':'icon-check select';changed();cancelEvent=true;}if(cancelEvent){GEvent.stop(evt);}}}forEach(elem.getElementsByTagName('option'),function(){select.addItem(this.value,this.innerHTML,this.getAttribute('selected')!==null);});var bodyClick=function(e){if(GEvent.element(e)!=display&&showing==0){_hide();}};function _show(){if(!select.hasClass('disabled')){panel.show();$G(document.body).addEvent("click",bodyClick);}}function _hide(){panel.hide();$G(document.body).removeEvent("click",bodyClick);}select.addEvent("click",_show);select.addEvent("focus",_show);select.addEvent("keydown",_dokeydown);select.addEvent("blur",function(){if(showing==0){_hide();}});dropdown.addEvent("keydown",_dokeydown);elem.parentNode.removeChild(elem);changed();}}};})();(function(){'use strict';window.GSwipe=GClass.create();GSwipe.prototype={initialize:function(id,options){this.options={mouseOffset:5,beginDrag:$K.emptyFunction,moveDrag:$K.emptyFunction,endDrag:$K.emptyFunction};for(var property in options){this.options[property]=options[property];}this.scroller=$G(id);this.active=false;this.swipeDir=false;var self=this;function swipeMove(e){var touch=e;if(e.type=='touchmove'){touch=e.targetTouches[0]||e.changedTouches[0];}e.mousePos={x:touch.pageX,y:touch.pageY};var x=e.mousePos.x-self.mousePos.x,y=e.mousePos.y-self.mousePos.y;if(self.swipeDir===false){if(y<-self.options.mouseOffset){self.swipeDir='up';}else if(y>self.options.mouseOffset){self.swipeDir='down';}else if(x<-self.options.mouseOffset){self.swipeDir='left';}else if(x>self.options.mouseOffset){self.swipeDir='right';}}if(self.options.moveDrag.call(self,e)===false){GEvent.stop(e);}}function swipeEnd(e){if(self.active){self.active=false;self.scroller.removeEvent('mousemove,touchmove',swipeMove,false);document.removeEvent('mouseup,touchend',swipeEnd,false);document.removeEvent('selectstart,dragstart',cancelEvent);var touch=e;if(e.type=='touchend'){touch=e.targetTouches[0]||e.changedTouches[0];}e.mousePos={x:touch.pageX,y:touch.pageY};window.setTimeout(function(){self.options.endDrag.call(self,e);self.swipeDir=false;},1);}}function cancelEvent(e){GEvent.stop(e);}function swipeStart(e){self.active=true;self.scroller.addEvent('mousemove,touchmove',swipeMove,false);document.addEvent('mouseup,touchend',swipeEnd,false);document.addEvent('selectstart,dragstart',cancelEvent);if(self.options.beginDrag.call(self,e)===false){GEvent.stop(e);}}function doMousedown(e){if(GEvent.isLeftClick(e)){self.mousePos=GEvent.pointer(e);swipeStart(e);}}function doTouchstart(e){var touch=e.targetTouches[0]||e.changedTouches[0];self.mousePos={x:touch.pageX,y:touch.pageY};swipeStart(e);}function doClick(e){if(self.swipeDir !==false){GEvent.stop(e);}}this.scroller.addEvent('mousedown',doMousedown,false);this.scroller.addEvent('touchstart',doTouchstart,false);this.scroller.addEvent('click',doClick,false);}};})();(function(){"use strict";window.GTable=GClass.create();GTable.prototype={initialize:function(id,o){this.options={url:null,params:[],cols:[],action:null,actionCallback:null,actionConfirm:null,onBeforeDelete:null,onDelete:null,onAddRow:null,onInitRow:null,onChanged:null,pmButton:false,dragColumn:-1};for(var prop in o){if(prop=="debug"&&o.debug !=""){console.log(o.debug);}else{this.options[prop]=o[prop];}}this.table=$E(id);this.search=o["search"]||"";this.sort=o["sort"]||null;this.page=o["page"]||1;this.submit=null;if(this.options.onAddRow){this.options.onAddRow=window[this.options.onAddRow];if(!Object.isFunction(this.options.onAddRow)){this.options.onAddRow=null;}}if(this.options.onBeforeDelete){this.options.onBeforeDelete=window[this.options.onBeforeDelete];if(!Object.isFunction(this.options.onBeforeDelete)){this.options.onBeforeDelete=null;}}if(this.options.onDelete){this.options.onDelete=window[this.options.onDelete];if(!Object.isFunction(this.options.onDelete)){this.options.onDelete=null;}}if(this.options.onInitRow){this.options.onInitRow=window[this.options.onInitRow];if(!Object.isFunction(this.options.onInitRow)){this.options.onInitRow=null;}}if(this.options.onChanged){this.options.onChanged=window[this.options.onChanged];if(!Object.isFunction(this.options.onChanged)){this.options.onChanged=null;}}var hs,sort_patt=/sort_(none|asc|desc)\s(col_([\w]+))(|\s.*)$/,action_patt=/button[\s][a-z]+[\s]action/,temp=this;function _send(){var params=[],sort=[];if(temp.options.params){for(var key in temp.options.params){params.push(key+'='+encodeURIComponent(temp.options.params[key]));}}forEach($G(temp.table).elems("th"),function(){hs=sort_patt.exec(this.className);if(hs){if(hs[1]=="asc"){sort.push(hs[3]+"%20asc");}else if(hs[1]=="desc"){sort.push(hs[3]+"%20desc");}}});if(sort.length>0){params.push('sort='+sort.join(','));}send(temp.options.url,params.join('&'),function(xhr){var ds=xhr.responseText.toJSON();if(ds){var td,tr,tbody,tbodies=temp.table.getElementsByTagName('tbody');if(tbodies.length==0){tbody=document.createElement('tbody');temp.table.getElementsByTagName('table')[0].appendChild(tbody);}else{tbody=tbodies[0];tbody.innerHTML='';}for(var row in ds){tr=document.createElement('tr');for(var item in ds[row]){td=document.createElement('td');if(temp.options.cols[item]){for(var el in temp.options.cols[item]){if(el=='class'){td.className=temp.options.cols[item][el];}}}td.innerHTML=ds[row][item];tr.appendChild(td);}tbody.appendChild(tr);}temp.initTBODY(tbody,null);}if(temp.options.onChanged){temp.options.onChanged.call(temp,tbody,ds);}},this);}var _doSort=function(e){if((hs=sort_patt.exec(this.className))){var sort=[];if(GEvent.isCtrlKey(e)){var patt=new RegExp(hs[3]+"[\\s](asc|desc|none)");if(temp.sort){forEach(temp.sort.split(","),function(){if(!patt.test(this)){sort.push(this);}});}}else{forEach($G(temp.table).elems("th"),function(){var ds=sort_patt.exec(this.className);if(ds){this.className='sort_none col_'+ds[3]+(ds[4]?ds[4]:'');}});}if(hs[1]=="none"){this.className='sort_asc col_'+hs[3]+(hs[4]?hs[4]:'');sort.push(hs[3]+"%20asc");}else if(hs[1]=="asc"){this.className='sort_desc col_'+hs[3]+(hs[4]?hs[4]:'');sort.push(hs[3]+"%20desc");}else{this.className='sort_none col_'+hs[3]+(hs[4]?hs[4]:'');sort.push(hs[3]+"%20none");}if(temp.options.url){_send();}else{temp.sort=sort.join(",");window.location=temp.redirect();}}};var doAction=function(){var action="",cs=temp.getCheck();if(cs.length==0){alert(trans("Please select at least one item").replace(/XXX/,trans('Checkbox')));}else{cs=cs.join(",");var t,f=this.get("for"),fn=window[temp.options.actionConfirm];if($E(f).type.toLowerCase()=='text'){t=this.innerText;}else{t=$G(f).getText();}t=t?t.strip_tags():null;if(Object.isFunction(fn)){action=fn(t,$E(f).value,cs);}else{if(confirm(trans("You want to XXX the selected items?").replace(/XXX/,t))){action="module="+f+"&action="+$E(f).value+"&id="+cs;}}if(action !=""){temp.callAction(this,action);}}};var doSearchChanged=function(){if(temp.input_search.value==""){temp.input_search.parentNode.parentNode.className='search';}else{temp.input_search.parentNode.parentNode.className='search with_text';}};if(this.table){if(this.options.url){_send();}forEach($G(this.table).elems("th"),function(){if(sort_patt.test(this.className)){callClick(this,_doSort);}});this.initTR(this.table);forEach(this.table.elems("tbody"),function(){temp.initTBODY(this,null);});forEach(this.table.elems("label"),function(){if(action_patt.test(this.className)){callClick(this,doAction);}});if(this.options.dragColumn>-1){new GDragDrop(this.table,{dragClass:"icon-move",endDrag:function(){var trs=new Array();forEach(temp.table.elems("tr"),function(){if(this.id){trs.push(this.id.replace(id+"_",""));}});if(trs.length>1){temp.callAction(this,"action=move&data="+trs.join(","));}}});}forEach(this.table.elems("button"),function(){if(this.className=="clear_search"){temp.clear_search=this;temp.input_search=this.parentNode.firstChild.firstChild;callClick(this,function(){temp.input_search.value="";if(temp.submit){temp.submit.click();}});}else if(this.type=="submit"){temp.submit=this;}else if(this.id !=""){callClick(this,function(){temp._doButton(this);});}});if(this.options.action){window.setTimeout(function(){if($E(temp.table)){forEach(temp.table.elems("tbody"),function(){forEach(this.querySelectorAll("select,input,textarea"),function(){if(this.id !=""){$G(this).addEvent("change",function(){temp._doButton(this);});}});});}},1000);}if(temp.input_search){$G(temp.input_search).addEvent("change",doSearchChanged);doSearchChanged.call(temp);}if(typeof loader !=="undefined"){forEach(this.table.querySelectorAll("form.table_nav"),function(){this.onsubmit=function(){var urls=this.action.split("?"),obj=new Object();if(urls[1]){forEach(urls[1].split("&"),function(){var hs=this.split("=");if(hs.length==2&&hs[1] !=""){obj[hs[0]]=hs[1];}});forEach(this.querySelectorAll("input,select"),function(){obj[this.name]=this.value;});var q=new Array();for(var prop in obj){if(prop=="search"){q.push(prop+"="+encodeURIComponent(obj[prop]));}else if(prop !=""&&prop !="time"){q.push(prop+"="+obj[prop]);}}q.push("time="+new Date().getTime());loader.setParams(q.join("&"));}return false;};});}}},getCheck:function(){var cs=new Array(),chk=/check_[0-9]+/;forEach(this.table.elems("a"),function(){if(chk.test(this.id)&&$G(this).hasClass("icon-check")){cs.push(this.id.replace("check_",""));}});return cs;},callAction:function(el,action){var hs=this.options.action.split("?");if(hs[1]){action=hs[1]+"&"+action;}action+="&src="+this.table.id;if(el.value){action+="&value="+encodeURIComponent(el.value);}var temp=this;el.addClass("wait");send(hs[0],action,function(xhr){el.removeClass("wait");if(temp.options.actionCallback){var fn=window[temp.options.actionCallback];if(Object.isFunction(fn)){fn(xhr);}}else if(xhr.responseText !=""){alert(xhr.responseText);}else{window.location.reload();}});},_doButton:function(input){var action="",cs=[],patt=/^([a-z_\-]+)_([0-9]+)(_([0-9]+))?$/,q=input.get("data-confirm"),chk=input.get("data-checkbox");if(chk){cs=this.getCheck();if(cs.length==0){alert(trans("Please select at least one item").replace(/XXX/,trans('Checkbox')));return;}}if(this.options.actionConfirm){var fn=window[this.options.actionConfirm],hs=patt.exec(input.id);if(hs&&Object.isFunction(fn)){var t=input.getText();t=t?t.strip_tags():null;action=fn(t,hs[1],hs[2],hs[4]);}else{action="action="+input.id;}}else if(!q||confirm(q)){hs=patt.exec(input.id);if(hs){if(hs[1]=="delete"||hs[1]=="cancel"){if(cs.length>0&&confirm(trans("You want to XXX the selected items?").replace(/XXX/,trans(hs[1])))){action="action="+hs[1]+"&id="+hs[2]+(hs[4]?'&opt='+hs[4]:'');}else if(confirm(trans("You want to XXX?").replace(/XXX/,trans(hs[1])))){action="action="+hs[1]+"&id="+hs[2]+(hs[4]?'&opt='+hs[4]:'');}}else if(hs[4]){action="action="+hs[1]+"_"+hs[2]+"&id="+hs[4];}else{action="action="+hs[1]+"&id="+hs[2];}}else{action="action="+input.id;}}if(action !=""){if(cs.length>0){action+='&ids='+cs.join(',');}this.callAction(input,action);}},initTBODY:function(tbody,tr){var row=0,temp=this;forEach($G(tbody).elems("tr"),function(){if(temp.options.pmButton){this.id=temp.table.id+"_"+row;forEach(this.querySelectorAll("select,input,textarea"),function(){this.id=this.name.replace(/([\[\]_]+)/g,"_")+row;});}if(tr===null||tr===this){if(temp.options.onInitRow){temp.options.onInitRow.call(temp,this,row);}if(temp.options.action){var move=/(check|move)_([0-9]+)/;forEach($G(this).elems("a"),function(){var id=this.id;if(id&&!move.test(id)){callClick(this,function(){temp._doButton(this);});}});}}row++;});},initTR:function(el){var hs,a_patt=/(delete|icon)[_\-](plus|minus|[0-9]+)/,check_patt=/check_([0-9]+)/,temp=this;var aClick=function(){var c=this.className;if(c=="icon-plus"){var tr=$G(this.parentNode.parentNode.parentNode);var tbody=tr.parentNode;var ntr=tr.copy(false);tr.after(ntr);temp.initTR(ntr);if(temp.options.onAddRow){ret=temp.options.onAddRow.call(temp,ntr);}temp.initTBODY(tbody,ntr);ntr.highlight();ntr=ntr.elems("input")[0];if(ntr){ntr.focus();ntr.select();}}else if(c=="icon-minus"){var tr=$G(this.parentNode.parentNode.parentNode);var tbody=$G(tr.parentNode);var ret=true;if(temp.options.onBeforeDelete){ret=temp.options.onBeforeDelete.call(temp,tr);}if(ret){if(tbody.elems("tr").length>1){tr.remove();temp.initTBODY(tbody,false);if(temp.options.onDelete){temp.options.onDelete.call(temp);}}}}else if((hs=a_patt.exec(c))){var action="";if(hs[1]=="delete"&&confirm(trans("You want to XXX?").replace(/XXX/,trans("delete")))){action="action=delete&id="+hs[2];}if(action !=""&&temp.options.action){send(temp.options.action,action,function(xhr){var ds=xhr.responseText.toJSON();if(ds){if(ds.alert&&ds.alert !=""){alert(ds.alert);}else if(ds.action){if(ds.action=="delete"){var tr=$G(temp.table.id+"_"+ds.id);var tbody=tr.parentNode;tr.remove();temp.initTBODY(tbody,tr);}}}else if(xhr.responseText !=""){alert(xhr.responseText);}},this);}}};var saClick=function(){this.focus();var chk=this.hasClass("icon-check");forEach(el.elems("a"),function(){if(check_patt.test(this.id)){this.className=chk?"icon-uncheck":"icon-check";this.title=chk?trans("check"):trans("uncheck");}else if($G(this).hasClass("checkall")){this.className=chk?"checkall icon-uncheck":"checkall icon-check";this.title=chk?trans("select all"):trans("select none");}});return false;};var sClick=function(){this.focus();var chk=$G(this).hasClass("icon-check");this.className=chk?"icon-uncheck":"icon-check";this.title=chk?trans("check"):trans("uncheck");forEach(el.elems("a"),function(){if(this.hasClass("checkall")){this.className="checkall icon-uncheck";this.title=trans("select all");}});return false;};forEach($G(el).elems("a"),function(){if(a_patt.test(this.className)){callClick(this,aClick);}else if($G(this).hasClass("checkall")){this.title=trans("select all");callClick(this,saClick);}else if(check_patt.test(this.id)){this.title=trans("check");callClick(this,sClick);}});forEach(el.querySelectorAll('.icon-copy'),function(){callClick(this,function(){if(this.value){copyToClipboard(this.value);}else if(this.title){copyToClipboard(this.title);}else if(this.innerHTML){copyToClipboard(this.innerHTML.strip_tags());}else{return false;}document.body.msgBox(trans('successfully copied to clipboard'));return false;});});},setSort:function(sort,patt){var hs;forEach(this.table.elems("th"),function(){hs=patt.exec(this.className);if(hs){if(sort==hs[2]){this.className=this.className.replace("sort_"+hs[1],"sort_"+(hs[1]=="asc"?"desc":"asc"));}else{this.className=this.className.replace("sort_"+hs[1],"sort_none");}}});},redirect:function(){var hs,patt=/^(.*)=(.*)$/,urls={},u=window.location.href,us2=u.split("#"),us1=us2[0].split("?");forEach([us1[1],us2[1]],function(){if(this){forEach(this.split("&"),function(){if((hs=patt.exec(this))){hs[1]=hs[1].toLowerCase();hs[2]=hs[2].toLowerCase();if(hs[1] !="page"&&hs[1] !="sort"&&hs[1] !="search"&&!(hs[1]=="action"&&(hs[2]=="login"||hs[2]=="logout"))){urls[hs[1]]=this;}}else{urls[this]=this;}});}});var us=Object.toArray(urls);us.push("page="+this.page);if(this.sort){us.push("sort="+this.sort);}if(this.search){us.push("search="+encodeURIComponent(this.search));}if(us2.length==2){u=us2[0];if(us.length>0){u+="#"+us.join("&");}}else{u=us1[0];if(us.length>0){u+="?"+us.join("&");}}return u;}};})();var VScroller=GClass.create();VScroller.prototype={initialize:function(id,options){this.options={className:'vscroller',itemClass:'item',scrollerClass:'scrollable'};for(var property in options){this.options[property]=options[property];}this.container=$G(id);this.container.addClass(this.options.className);this.scroller=$G(this.container.getElementsByClassName(this.options.scrollerClass)[0]);this.position='';this.htmlElement=$G(document.querySelector('html'));this.smooth=this.htmlElement.hasClass('smooth');this.next=this.container.create('span');this.next.className='btnnav next';this.next.title=trans('Next');callClick(this.next,function(){move('next');});this.prev=this.container.create('span');this.prev.className='btnnav prev';this.prev.title=trans('Prev');callClick(this.prev,function(){move('prev');});var tmp=this;function doResize(){tmp.scroller.style.width=null;var items=tmp.scroller.getElementsByClassName(tmp.options.itemClass),cw=tmp.container.getWidth(),w=0.00;forEach(items,function(){this.style.width=null;w+=$G(this).getWidth();});var itemWidth=((w / items.length)*100)/ cw;tmp.scroller.style.width=w+'px';forEach(items,function(){this.style.width=((cw*itemWidth)/ 100)+'px';});if(tmp.scroller.getWidth()<=tmp.container.getWidth()){tmp.prev.style.display='none';tmp.next.style.display='none';}else{tmp.prev.style.display='block';tmp.next.style.display='block';}tmp.scroller.style.left='0px';checkButton()}$G(window).addEvent('resize',doResize);doResize();function move(page){var cw=tmp.container.getStyle('width').toInt(),cl=tmp.container.getLeft(),sl=tmp.scroller.getLeft(),l,w;forEach(tmp.scroller.getElementsByClassName(tmp.options.itemClass),function(){l=this.getLeft();w=this.offsetWidth;if(page=='next'){if(l+w-cl>cw){moveTo(sl-l);return true;}}else if(page=='prev'){if(l>0){moveTo(sl+cw-l);return true;}}});}function moveTo(x){tmp.scroller.addClass('animate');var cw=tmp.container.getWidth()-tmp.scroller.getWidth();tmp.scroller.style.left=Math.min(0,Math.max(cw,x))+'px';window.setTimeout(function(){tmp.scroller.removeClass('animate');checkButton();},500);}function checkButton(){var l=tmp.scroller.getLeft()-tmp.container.getLeft(),cw=tmp.container.getWidth()-tmp.scroller.getWidth();if(l==0){tmp.prev.addClass('hide');}else{tmp.prev.removeClass('hide');}if(l-cw<1){tmp.next.addClass('hide');}else{tmp.next.removeClass('hide');}}checkButton();new GSwipe(this.scroller,{beginDrag:function(){tmp.mouseOffset={x:this.mousePos.x-tmp.scroller.getStyle('left').toInt(),y:this.mousePos.y-tmp.scroller.getStyle('top').toInt()};if(tmp.smooth){tmp.htmlElement.removeClass('smooth');}},moveDrag:function(e){GEvent.element(e).drag=true;if(this.swipeDir=='left'||this.swipeDir=='right'){var cw=tmp.container.getWidth()-tmp.scroller.getWidth();if(cw<0){tmp.scroller.style.left=Math.min(0,Math.max(cw,e.mousePos.x-tmp.mouseOffset.x))+'px';}return false;}else if(this.swipeDir=='up'||this.swipeDir=='down'){var doc=document.documentElement,left=(window.pageXOffset||doc.scrollLeft)-(doc.clientLeft||0),top=(window.pageYOffset||doc.scrollTop)-(doc.clientTop||0);window.scroll({left:left,top:top-(e.mousePos.y-tmp.mouseOffset.y)});return false;}},endDrag:function(e){var src=GEvent.element(e),container_l=tmp.container.getLeft(),cw=tmp.container.getWidth(),offset=cw-tmp.scroller.getWidth(),curr=0,self=this,l,w;forEach(tmp.scroller.getElementsByClassName(tmp.options.itemClass),function(){l=this.getLeft();w=this.offsetWidth;if(self.swipeDir=='left'&&l>container_l){moveTo(Math.max(offset,0-curr));return false;}else if(self.swipeDir=='right'&&l+w-container_l>cw){moveTo(Math.min(0,cw-curr));return false;}else{curr+=w;}});if(tmp.smooth){tmp.htmlElement.addClass('smooth');}window.setTimeout(function(){src.drag=false;},1);}});}};window.GAds=(function(){"use strict";return{init:function(){var div=$G(document.currentScript.parentNode);var req=new GAjax();req.send(WEB_URL+'xhr.php','module=ads&id='+encodeURIComponent(window.location.href),function(xhr){div.innerHTML=xhr.responseText;initFavoriteButton(div);initSponsoredRoom(div);});}};})();function initSponsoredRoom(id){forEach($E(id).getElementsByClassName('sponsored_room'),function(){callClick(this,function(){window.location.href=WEB_URL+'news/sponsored_room_%E0%B8%AA%E0%B8%9B%E0%B8%AD%E0%B8%99%E0%B9%80%E0%B8%8B%E0%B8%AD%E0%B8%A3%E0%B9%8C_%E0%B8%A3%E0%B8%B9%E0%B8%A1_%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3';return false;});});}window.Popular=(function(){"use strict";return{init:function(tag){var div=$G(document.currentScript.parentNode);var req=new GAjax();req.send(WEB_URL+'xhr.php','module=room-popular&count=27&cols=1&tag='+tag+'&id='+encodeURIComponent(window.location.href),function(xhr){div.innerHTML=xhr.responseText;xhr.responseText.evalScript();});}};})();window.Standout=(function(){"use strict";return{init:function(){var div=$G(document.currentScript.parentNode);var req=new GAjax();req.send(WEB_URL+'xhr.php','module=room-standout&count=9&cols=1&id='+encodeURIComponent(window.location.href),function(xhr){div.innerHTML=xhr.responseText;xhr.responseText.evalScript();});}};})();window.Hotdeal=(function(){"use strict";return{init:function(){var div=$G(document.currentScript.parentNode);var req=new GAjax();req.send(WEB_URL+'xhr.php','module=hotdeal&id='+encodeURIComponent(window.location.href),function(xhr){div.innerHTML=xhr.responseText;initFavoriteButton(div);});}};})();window.Lastupdate=(function(){"use strict";return{init:function(cols,rows,count,params){var div=$G(document.currentScript.parentNode),req=new GAjax();params.module='project-lastupdate';params.cols=cols;params.rows=rows;params.count=count;req.send(WEB_URL+'xhr.php',jsonToParams(params),function(xhr){div.innerHTML=xhr.responseText;xhr.responseText.evalScript();initFavoriteButton(div);});}};})();var loader,modal=null;function send(target,query,callback,wait,c){var req=new GAjax();req.initLoading(wait||'wait',false,c);req.send(target,query,function(xhr){if(callback){callback.call(this,xhr);}});}var hideModal=function(){if(modal !=null){modal.hide();}};function showModal(src,qstr,doClose,className){send(src,qstr,function(xhr){var ds=xhr.responseText.toJSON();var detail='';if(ds){if(ds.alert){alert(ds.alert);}else if(ds.detail){detail=decodeURIComponent(ds.detail);}else if(ds.modal){detail=ds.modal;}}else{detail=xhr.responseText;}if(detail !=''){modal=new GModal({onclose:doClose}).show(detail,className);detail.evalScript();}});}function defaultSubmit(ds){var _alert='',_input=false,_url=false,_location=false,t,el,remove=/remove([0-9]{0,})/;function unentityify(text){return text.unentityify().replace('&nbsp;',' ').strip_tags().trim();}for(var prop in ds){var val=ds[prop];if(prop=='error'){_alert=eval(val);}else if(prop=='debug'){console.log(val);}else if(prop=='alert'){_alert=val;}else if(prop=='message'){document.body.msgBox(trans(val));}else if(prop=='warning'){document.body.msgBox(trans(val),'warning');}else if(prop=='tip'){document.body.msgBox(trans(val),'tip',false);}else if(prop=='modal'){if(val=='close'){if(modal){modal.hide();}}else{if(!modal){modal=new GModal();}modal.show(val);val.evalScript();}}else if(prop=='elem'){el=$E(val);if(el){if(ds.class){el.className=ds.class;}if(ds.title){el.title=ds.title;}}}else if(prop=='location'){_location=val;}else if(prop=='url'){_url=val;_location=val;}else if(prop=='open'){window.setTimeout(function(){window.open(val.replace(/&amp;/g,'&'));},1);}else if(prop=='tab'){initWriteTab('accordient_menu',val);}else if(prop=='valid'){if($E(val)){$G(val).valid();}}else if(remove.test(prop)){if($E(val)){$G(val).fadeOut(function(){$G(val).remove();});}}else if($E(prop)){$G(prop).setValue(decodeURIComponent(val).replace(/\%/g,'&#37;'));}else if($E(prop.replace('ret_',''))){el=$G(prop.replace('ret_',''));if(el.display){el=el.display;}if(val==''){el.valid();}else{if(val=='Please fill in'||val=='Please select'||val=='Please browse file'||val=='already exist'||val=='Please select at least one item'||val=='Invalid data'){var label=el.findLabel();if(label){t=unentityify(label.innerHTML);}else{if(typeof el.placeholder !='undefined'){t=unentityify(el.placeholder);}else{t='';}if(t==''){t=unentityify(el.title);}}if(t !=''){if(val=='already exist'){val=t+' '+trans(val);}else if(val=='Please select at least one item'){val=PLEASE_SELECT_AT_LEAST_ONE_ITEM.replace('XXX',t)}else if(val=='Invalid data'){val=INVALID_DATA.replace('XXX',t)}else{val=trans(val)+' '+t;}}else{val=trans(val);}}else if(val=='this'){t='';if(typeof el.title !='undefined'){t=unentityify(el.title);}if(t==''&&typeof el.placeholder !='undefined'){t=unentityify(el.placeholder);}val=t;}if(_input !=el){el.invalid(val);}if(_alert==''){_alert=val;_input=el;}}}}if(_alert !=''){alert(_alert);}if(_input){_input.focus();var tag=_input.tagName.toLowerCase();if(tag !='select'){_input.highlight();}if(tag=='input'){var type=_input.get('type').toLowerCase();if(type=='text'||type=='password'){_input.select();}}}if(_location){if(_location=='reload'){if(loader){loader.reload();}else{window.location.reload();}}else if(_location=='back'){if(loader){loader.back();}else{window.history.go(-1);}}else if(loader&&_location !=_url){loader.location(_location);}else{window.location=_location.replace(/&amp;/g,'&');}}}function doFormSubmit(xhr){var datas=xhr.responseText.toJSON();if(datas){defaultSubmit(datas);}else if(xhr.responseText !=''){console.log(xhr.responseText);}}function initWriteTab(id,sel){function _doclick(sel){forEach($E(id).getElementsByTagName('a'),function(){var a=this.id.replace('tab_','');if($E(a)){this.className=a==sel?'select':'';$E(a).style.display=a==sel?'block':'none';}});$E('tab').value=sel;}forEach($G(id).elems('a'),function(){if($E(this.id.replace('tab_',''))){callClick(this,function(){_doclick(this.id.replace('tab_',''));return false;});}});_doclick(sel);}var dataTableActionCallback=function(xhr){var el,prop,val,ds=xhr.responseText.toJSON();if(ds){for(prop in ds){val=ds[prop];if(prop=='location'){if(val=='reload'){if(loader){loader.reload();}else{window.location.reload();}}else{window.location=val;}}else if(prop=='open'){window.setTimeout(function(){window.open(val.replace(/&amp;/g,'&'));},1);}else if(prop=='remove'){if($E(val)){$G(val).remove();}}else if(prop=='alert'){alert(val);}else if(prop=='elem'){el=$E(val);if(el){el.className=ds.class;if(ds.title){el.title=ds.title;}}}else if(prop=='modal'){if(val=='close'){if(modal){modal.hide();}}else{modal=new GModal().show(val);val.evalScript();}}else if($E(prop)){$G(prop).setValue(val);}}}else if(xhr.responseText !=''){console.log(xhr.responseText);}};function checkUsername(){var patt=/[a-zA-Z0-9@\.\-_]+/;var value=this.value;var ids=this.id.split('_');var id='&id='+floatval($E(ids[0]+'_id').value);if(value==''){this.invalid(this.title);}else if(patt.test(value)){return 'value='+encodeURIComponent(value)+id;}else{this.invalid(this.title);}}function checkSubdomain(){var patt=/[a-z]+/;var value=this.value;var id='&id='+floatval($E('id').value);if(value==''){this.invalid(this.title);}else if(patt.test(value)){return 'value='+encodeURIComponent(value)+id;}else{this.invalid(this.title);}}function checkPassword(){var ids=this.id.split('_');var id='&id='+floatval($E(ids[0]+'_id').value);var Password=$E(ids[0]+'_password');var Repassword=$E(ids[0]+'_repassword');if(Password.value==''&&Repassword.value==''){if(id==0){this.Validator.invalid(this.Validator.title);}else{this.Validator.reset();}this.Validator.reset();}else if(Password.value==Repassword.value){Password.Validator.valid();Repassword.Validator.valid();}else{this.Validator.invalid(this.Validator.title);}}function checkIdcard(){var value=this.value,ids=this.id.split('_'),id='&id='+floatval($E(ids[0]+'_id').value);if(value.length==0){this.reset();}else if(value.length<9){this.invalid(this.title);}else{return 'value='+encodeURIComponent(value)+'&id='+id;}}function initMailserver(){var doChanged=function(){var a=this.value.toInt();$E('email_SMTPSecure').disabled=a==0;$E('email_Username').disabled=a==0;$E('email_Password').disabled=a==0;};var el=$G('email_SMTPAuth');el.addEvent('change',doChanged);doChanged.call(el);}function replaceURL(withParams,withoutParams,url){var q,prop,withParams=withParams||{},withoutParams=withoutParams||{},new_url=new Object(),qs=Array();url=url||window.location.toString();var urls=url.replace(/\#/g,'&').replace(/\?/g,'&').split('&');var l=urls.length;if(l>1){for(var n=1;n<l;n++){if(urls[n] !='action=login'&&urls[n] !='action=logout'){q=urls[n].split('=');if(q.length==2&&!(withoutParams[q[0]]&&(withoutParams[q[0]]==q[1]||withoutParams[q[0]]===null))){new_url[q[0]]=q[1];}}}}for(prop in withParams){new_url[prop]=withParams[prop];}for(prop in new_url){if(new_url[prop] !==null){qs.push(prop+'='+new_url[prop]);}else{qs.push(prop);}}if(qs.length>0){return urls[0]+'?'+qs.join('&');}else{return urls[0];}}function initSystem(){new Clock('local_time');new Clock('server_time');}function selectMenu(module){forEach(document.querySelectorAll('#topmenu>ul>li'),function(){if($G(this).hasClass(module)){this.addClass('select');}else{this.removeClass('select');}});forEach(document.querySelectorAll('.sidemenu>ul>li'),function(){if($G(this).hasClass(module)){this.addClass('select');}else{this.removeClass('select');}});}function selectMemberMenu(menu){forEach($E('member_menu').getElementsByTagName('li'),function(){if($G(this).hasClass(menu)){this.addClass('select');}else{this.removeClass('select');}});}function loadJavascript(id,src){var js,fjs=document.getElementsByTagName('script')[0];if(document.getElementById(id)){return;}js=document.createElement('script');js.id=id;js.src=src;fjs.parentNode.insertBefore(js,fjs);}function initEditInplace(id,model,addbtn){var patt=/list_([a-z]+)_([0-9]+)(_([0-9]+))?/;var o={onSave:function(v,editor){var req=new GAjax({asynchronous:false});req.initLoading(editor,false);req.send('index.php/'+model,'action='+this.id+'&value='+encodeURIComponent(v));ds=req.responseText.toJSON();if(ds){if(ds.alert){alert(ds.alert);}if(ds.editId){$E(ds.editId).innerHTML=ds.edit;}return true;}else if(req.responseText !=''){alert(req.responseText);}return false;}};function _doAction(c){var q='',hs=patt.exec(this.id);if(hs[1]=='add'){q='action='+this.id;}else if(hs[1]=='delete'&&confirm(trans('You want to XXX?').replace(/XXX/,trans('delete')))){q='action='+this.id;}else if(hs[1]=='color'){q='action='+this.id+'&value='+encodeURIComponent(c);}else if(hs[1]=='published'){q='action='+this.id+'&value='+this.className.replace('icon-published','');}else if(hs[1]=='status'){q='action='+this.id+'&value='+this.value;}if(q !=''){send('index.php/'+model,q,function(xhr){var ds=xhr.responseText.toJSON();if(ds){if(ds.data){$G(id).appendChild(ds.data.toDOM());_doInitEditInplaceMethod(ds.newId);$E(ds.newId.replace('list_','list_name_')).focus();}else if(ds.del){$G(ds.del).remove();}else if(ds.editId){hs=patt.exec(ds.editId);if(hs[1]=='color'){$E(ds.editId).title=trans('change color')+'('+ds.edit+')';$E(ds.editId).style.color=ds.edit;}else if(hs[1]=='published'){$E(ds.editId).className='icon-published'+ds.edit;$E(ds.editId).title=ds.edit==1?DISABLE:ENABLE;}}if(ds.alert){alert(ds.alert);}}else if(xhr.responseText !=''){alert(xhr.responseText);}},this);}}function _initOrder(){new GDragDrop(id,{dragClass:'icon-move',endDrag:function(){var trs=new Array();forEach($G(id).elems('li'),function(){if(this.id){trs.push(this.id);}});if(trs.length>1){send('index.php/'+model,'action=move&value='+trs.join(',').replace(/list_/g,''),doFormSubmit);}}});}function _doInitEditInplaceMethod(src){var loading=true,move=false;forEach($G(src).elems('*'),function(){var hs=patt.exec(this.id);if(hs){if($G(this).hasClass('editinplace')){new EditInPlace(this,o);}else if(hs[1]=='published'){callClick(this,_doAction);this.title=this.className=='icon-published1'?DISABLE:ENABLE;}else if(hs[1]=='color'){var t=this.title;this.title=trans('change color')+'('+t+')';new GDDColor(this,function(c){$E(this.input.id).style.color=c;if(!loading){_doAction.call(this.input,c);}}).setColor(t);}else if(hs[1]=='order'){move=true;}else{callClick(this,_doAction);}}});if(move){_initOrder();}loading=false;}callClick(addbtn,_doAction);_doInitEditInplaceMethod(id);}function initCopyToClipboard(id){forEach($E(id).querySelectorAll('.icon-copy'),function(){callClick(this,function(){copyToClipboard(this.title);document.body.msgBox(trans('successfully copied to clipboard'));return false;});});}function initFirstRowNumberOnly(tr){forEach($G(tr).elems('input'),function(item,index){if(index==0){new GMask(item,function(){return /^[0-9]+$/.test(this.value);});}});}function initEditProfile(prefix){prefix+=prefix==''?'':'_';$G(prefix+'country').addEvent('change',function(){var self=this;self.addClass('wait');new GAjax().send(WEB_URL+'index.php/index/model/province/toJSON','country='+this.selectedIndex,function(xhr){self.removeClass('wait');var items=xhr.responseText.toJSON(),province=$E(prefix+'province');if(items&&province){province.setDatalist(items['province']);}});});}function initMemberMenu(elem){forEach(elem.querySelectorAll('.do_login,.do_forgot,.do_register'),function(){callClick(this,doLogin);});}var createLikeButton,doLogin=function(){var hs=/(.*?)do_(login|forgot|register)/.exec(this.className);if(hs){showModal(WEB_URL+'xhr.php','module=member&action='+hs[2],null,'member_modal');}},doLoginSubmit=function(xhr){var el,t,ds=xhr.responseText.toJSON();if(ds){if(ds.alert&&ds.alert !=''){if(ds.alert=='Please fill in'&&ds.input&&$E(ds.input)){el=$E(ds.input);if(el.placeholder){t=el.placeholder.strip_tags();}else{t=el.title.strip_tags();}alert(trans(ds.alert)+' '+t);}else{alert(ds.alert);}}if(ds.action){if(ds.action==2||ds.action=='back'){if(loader){loader.back();}else if(document.referrer){window.location=document.referrer .toString().replace('action=logout','').replace(/\?\&/,'?').replace(/\?$/,'');}else{window.history.back();}}else if(ds.action==1||ds.action=='reload'){if(loader){loader.reload();}else{window.location=replaceURL({action:'login'});}}else if(/^http.*/.test(ds.action)){window.location=ds.action;}}if(ds.content&&$E('login-box')){hideModal();var content=decodeURIComponent(ds.content);var login=$G('login-box');login.setHTML(content);content.evalScript();if(loader){loader.init(login);}}if(ds.input){$G(ds.input).invalid().focus();}}else if(xhr.responseText !=''){console.log(xhr.responseText);}};function initWeb(module){module=module?module+'/':'';if(navigator.userAgent.indexOf('MSIE')>-1){document.body.addClass('ie');}forEach(document.body.elems('nav'),function(){if($G(this).hasClass('topmenu sidemenu slidemenu gddmenu')){new GDDMenu(this);}});var _scrolltop=0;var toTop=100;if($E('toTop')&&!$K.isMobile()){if($G('toTop').hasClass('fixed_top')){document.addEvent('toTopChange',function(){if(document.body.hasClass('toTop')){var _toTop=$G('toTop').copy();_toTop.zIndex=-1;_toTop.id='toTop_temp';_toTop.setStyle('opacity',0);_toTop.removeClass('fixed_top');$G('toTop').after(_toTop);}else if($E('toTop_temp')){$G('toTop_temp').remove();}});}toTop=$E('toTop').getTop();document.addEvent('scroll',function(){var c=this.viewport.getscrollTop()>toTop;if(_scrolltop !=c){_scrolltop=c;if($E('body')){if(c){$E('body').className='toTop';}else{$E('body').className='';}}else{if(c){document.body.addClass('toTop');}else{document.body.removeClass('toTop');}}document.callEvent('toTopChange');}});}var fontSize=floatval(Cookie.get(module+'fontSize'));document.body.set('data-fontSize',floatval(document.body.getStyle('fontSize')));if(fontSize>5){document.body.setStyle('fontSize',fontSize+'px');}forEach(document.body.elems('a'),function(){if(/^lang_([a-z]{2,2})$/.test(this.id)){callClick(this,function(e){var hs=/^lang_([a-z]{2,2})$/.exec(this.id);window.location=replaceURL({lang:hs[1]});GEvent.stop(e);});}else if(/font_size\s(small|normal|large)/.test(this.className)){callClick(this,function(e){fontSize=floatval(document.body.getStyle('fontSize'));var hs=/font_size\s(small|normal|large)/.exec(this.className);if(hs[1]=='small'){fontSize=Math.max(6,fontSize-2);}else if(hs[1]=='large'){fontSize=Math.min(24,fontSize+2);}else{fontSize=document.body.get('data-fontSize');}document.body.setStyle('fontSize',fontSize+'px');Cookie.set(module+'fontSize',fontSize);GEvent.stop(e);});}});if(module=='admin'){loader=new GLoader(WEB_URL+module+'loader.php/index/controller/loader/index',function(xhr){var scroll_to='scroll-to',content=$G('content'),datas=xhr.responseText.toJSON();document.body.onkeydown=null;if(datas){for(var prop in datas){var value=datas[prop];if(prop=='detail'){content.setHTML(value);loader.init(content);content.replaceClass('loading','animation');content.Ready(function(){$K.init(content);value.evalScript();});}else if(prop=='title'){document.title=value.unentityify();}else if(prop=='menu'){selectMenu(value);}else if(prop=='to'){scroll_to=value;}else if($E(prop)){$E(prop).innerHTML=value;}}if(Object.isFunction(createLikeButton)){createLikeButton();}if($E(scroll_to)){window.scrollTo(0,$G(scroll_to).getTop()-10);}}else if(xhr.responseText !=''){console.log(xhr.responseText);}},null,function(){$G('content').replaceClass('animation','loading');return true;});loader.initLoading('wait',false);loader.init(document);}$K.init(document.body);}if(navigator.userAgent.match(/(iPhone|iPod|iPad)/i)){document.addEventListener('touchstart',function(){},false);}function initLine(){callClick('line_test',function(){send(WEB_URL+'index.php/index/model/line/test','id='+$E('line_api_key').value);});}function initAffiliateInfo(){function doDownload(){var id=this.id.replace('card_download','affiliate_profile'),elem=$G(id);window.scrollTo(0,elem.getTop());var o={y:window.scrollY+elem.getTop(),x:elem.getLeft()};html2canvas(elem,o).then(canvas=>{var img=new Image();img.crossOrigin="Anonymous";img.id="getshot";img.src=canvas.toDataURL('image/png');document.body.appendChild(img);var a=document.createElement('a');a.download=id+'.png';a.href=img.src;a.click();document.body.removeChild(img);});}callClick('card_download_th',doDownload);callClick('card_download_en',doDownload);callClick('card_download_cn',doDownload);}function initSelectChange(module,ids){for(var prop in ids){$G(ids[prop]).addEvent('change',function(){var elem,q=['module='+module];for(var prop in ids){elem=$E(ids[prop]);q.push(elem.name+'='+elem.value);}window.location.href='index.php?'+q.join('&');});}}function initProvince(){var o={callBack:function(){$G("soi").valid().value=this.soi;$G("road").valid().value=this.road;$G("district").valid().value=this.district;$G("amphur").valid().value=this.amphur;$G("province").valid().value=this.province;$E("soi_id").value=this.soi_id;$E("road_id").value=this.road_id;$E("district_id").value=this.district_id;$E("amphur_id").value=this.amphur_id;$E("province_id").value=this.province_id;if($E('region')){$E('region').setValue(this.region);}if($E('longitude')&&this.longitude&&($E('longitude').value=='0'||$E('longitude').value=='')){$E('longitude').value=this.longitude;}if($E('latitude')&&this.latitude&&($E('latitude').value=='0'||$E('latitude').value=='')){$E('latitude').value=this.latitude;}},onChanged:function(){$G("soi").reset();$G("road").reset();$G("district").reset();$G("amphur").reset();$G("province").reset();$E("soi_id").value=0;$E("road_id").value=0;$E("district_id").value=0;$E("amphur_id").value=0;$E("province_id").value=0;}};initAutoComplete("soi",WEB_URL+"admin/index.php/index/model/location/soi","soi,road,district,amphur,province","location",o);initAutoComplete("road",WEB_URL+"admin/index.php/index/model/location/road","soi,road,district,amphur,province","location",o);initAutoComplete("district",WEB_URL+"admin/index.php/index/model/location/district","soi,road,district,amphur,province","location",o);initAutoComplete("amphur",WEB_URL+"admin/index.php/index/model/location/amphur","district,amphur,province","location",o);initAutoComplete("province",WEB_URL+"admin/index.php/index/model/location/province","soi,road,district,amphur,province","location",o);}function initProvinceX(){var doProvinceChanged=function(){var q='province_id='+document.getElementsByName('province_id')[0].value;send(WEB_URL+"admin/index.php/index/model/amphur/toJSON",q,function(xhr){var items=xhr.responseText.toJSON(),amphur_id=$E("amphur_id");if(items&&amphur_id){amphur_id.setDatalist(items['amphur_id']);}},this);};var doAmphurChanged=function(){var q='amphur_id='+document.getElementsByName('amphur_id')[0].value;send(WEB_URL+"admin/index.php/index/model/amphur/getLocation",q,function(xhr){var ds=xhr.responseText.toJSON();if(ds){var latitude=$E("latitude"),longitude=$E("longitude");if(latitude.value==''||latitude.value=='0'){latitude.value=ds.latitude;}if(longitude.value==''||longitude.value=='0'){longitude.value=ds.longitude;}}},this);};$G('province_id').addEvent('change',doProvinceChanged);$G('amphur_id').addEvent('change',doAmphurChanged);}function getCurrentTab(id){var result=null;forEach($E(id).getElementsByTagName('input'),function(){if(this.checked){result=this.id;}});return result;}function initSearchExport(){initAutoComplete("search",WEB_URL+"index.php/index/model/autocomplete/findCondo","name",null,{get:function(){return "room=0&condo="+encodeURIComponent($E("search").value);},callBack:function(){$E('search').value=this.name;$E("id").value=this.id;if(this.icon=="office"){$E("by").value='condo';}else if(this.icon=="railway"){$E("by").value="railway";}else if(this.icon=="place"){$E("by").value="place";}else if(this.icon=="map"){$E("by").value="map";}else{$E("by").value="education";}$G("search").valid();},onChanged:function(){$E("id").value=0;$E("by").value="condo";$G("search").invalid();}});var dropDownClick=function(){var hs=/([a-z_]+)_([\-0-9]+)$/.exec(this.id);if(hs){this.parentNode.parentNode.className='button-dropdown '+hs[1]+hs[2];$E(hs[1]).value=hs[2];tabChanged('export_tab');}};forEach($E('export_frm').getElementsByClassName('button-dropdown'),function(){$G(this).onmouseover=function(){this.addClass('hover');};$G(this).onmouseout=function(){this.removeClass('hover');};forEach(this.getElementsByTagName('li'),function(){callClick(this,dropDownClick);})});$G('type').addEvent('change',function(){tabChanged('export_tab');});forEach($E('export_tab').getElementsByTagName('input'),function(){$G(this).addEvent('change',function(){tabChanged('export_tab');});});tabChanged('export_tab');$E("search_form").onsubmit=function(){var search_tab=getCurrentTab('export_tab'),size_min=floatval($E("size_min").value),size_max=floatval($E("size_max").value),budget=floatval($E("budget").value),type=$E("type").value,sell=floatval($E("sell").value);if(size_min>0&&size_max>0&&size_max<=size_min){alert(trans('The largest size must be greater than the smallest size'));$G("size_max").invalid().focus();}else{var params=[ 'search='+encodeURIComponent($E("search").value.replace(/\[[0-9]+\]\s/,'').replace(/[\/]+/g,'&#47;')),'distance='+floatval($E("distance").value),'size_min='+size_min,'size_max='+size_max,'roomtype='+floatval($E("roomtype").value),'layout='+$E("layout").value,'by='+$E("by").value,'id='+$E("id").value ];if(budget>0){params.push('budget='+budget);}if($E('animal').checked){params.push("animal=1");}if(search_tab=='sale'){type=sell==2?2:0;if(sell==3){params.push("new=1");}}else if(search_tab=='resale'){type=8;if($E('resales').checked){params.push("new=1");}}else{if($E('deposit').checked){params.push("deposit=1");}}if(search_tab=='resale'||(search_tab=='sale'&&sell==3)){var furniture=floatval($E('resale_furniture').value);if(furniture>0){params.push("furniture="+furniture);}}else{var furniture=$E('furniture').value;if(furniture.length>0){params.push("furniture="+furniture.join(','));}}if(search_tab !='rent'){var quota=floatval($E('quota').value);if(quota>0){params.push("quota="+quota);}}params.push('type='+type);window.open(WEB_URL+'export.php?'+params.join('&'),'export');}return false;};}function tabChanged(tab){var search_tab=getCurrentTab(tab),sell=$E('sell').value,type=$E('type').value;$E('deposit').parentNode.style.display=search_tab=='rent'&&type !=9?'table-cell':'none';$E('sell').parentNode.style.display=search_tab=='rent'||search_tab=='resale'?'none':'table-cell';$E('quota').parentNode.parentNode.className=search_tab=='rent'?'hidden':'show';$E('resales').parentNode.style.display=search_tab=='resale'?'table-cell':'none';$E('type').parentNode.parentNode.className=search_tab=='rent'?'show':'hidden';$E('animal').parentNode.style.display=type==9&&search_tab=='rent'?'none':'table-cell';$E('layout').parentNode.style.display=type==9&&search_tab=='rent'?'none':'table-cell';$E('furniture').parentNode.parentNode.style.display=search_tab=='rent'||(search_tab=='sale'&&sell !=3)?'table-cell':'none';$E('resale_furniture').parentNode.parentNode.style.display=search_tab=='rent'||(search_tab=='sale'&&sell !=3)?'none':'table-cell';};function initProjectSearch(tab){new GForm('search_form');var dropDownClick=function(){var hs=/([a-z_]+)_([\-0-9]+)$/.exec(this.id);if(hs){this.parentNode.parentNode.className='button-dropdown '+hs[1]+hs[2];$E(hs[1]).value=hs[2];tabChanged('search_tab');}};forEach($E('search_form').getElementsByClassName('button-dropdown'),function(){$G(this).onmouseover=function(){this.addClass('hover');};$G(this).onmouseout=function(){this.removeClass('hover');};forEach(this.getElementsByTagName('li'),function(){callClick(this,dropDownClick);})});$G('type').addEvent('change',function(){tabChanged('search_tab');});initAutoComplete("search",WEB_URL+"index.php/index/model/autocomplete/findCondo","name",null,{get:function(){return "room=1&condo="+encodeURIComponent($E("search").value);},callBack:function(){$E('search').value=this.name;$E("id").value=this.id;if(this.icon=="office"){$E("by").value='condo';}else if(this.icon=="signout"){$E("by").value='room';}else if(this.icon=="railway"){$E("by").value="railway";}else if(this.icon=="place"){$E("by").value="place";}else if(this.icon=="map"){$E("by").value="map";}else{$E("by").value="education";}$G("search").valid();},onChanged:function(){$E("id").value=0;$E("by").value="condo";$G("search").invalid();}});$E("search_form").onsubmit=function(){var search_tab=getCurrentTab('search_tab'),q=$E("search").value,roomtype=floatval($E("roomtype").value),budget=floatval($E("budget").value),size_min=floatval($E("size_min").value),size_max=floatval($E("size_max").value),layout=$E("layout").value,by=$E("by").value,id=$E("id").value,type=$E("type").value,sell=floatval($E("sell").value),params=['distance='+floatval($E("distance").value)],url=WEB_URL;if(size_min>0&&size_max>0&&size_max<=size_min){alert(trans('The largest size must be greater than the smallest size'));$G("size_max").invalid().focus();}else{if(search_tab=='sale'){type=sell==2?2:0;if(sell==3){params.push("new=1");}}else if(search_tab=='resale'){type=8;if($E('resales').checked){params.push("new=1");}}else{if($E('deposit').checked){params.push("deposit=1");}}if(search_tab=='resale'||(search_tab=='sale'&&sell==3)){var furniture=floatval($E('resale_furniture').value);if(furniture>0){params.push("furniture="+furniture);}}else{var furniture=$E('furniture').value;if(furniture.length>0){params.push("furniture="+furniture.join(','));}}if(q==''){q='all';}else{q=encodeURIComponent(q.replace(/\[[0-9]+\]\s/,'').replace(/[\/]+/g,'&#47;'));}if(id>0&&(by=="condo"||by=="room")){url+=by+"/"+id+"/"+q+"/"+type;}else{url+="search/"+by+"/"+q+"/"+type+"/"+id;}if(roomtype>-1){params.push("roomtype="+roomtype);}if(layout>-1){params.push("layout="+layout);}if(search_tab !='rent'){var quota=floatval($E('quota').value);if(quota>0){params.push("quota="+quota);}}if(budget>0){params.push("budget="+budget);}if(size_min>0||size_max>0){params.push("size="+size_min+','+size_max);}if($E('animal').checked){params.push("animal=1");}if($E('room_sort')){params.push("sort="+floatval($E('room_sort').value));}if($E('room_sort_type')){params.push("sort_type="+$E('room_sort_type').checked?1:0);}if(params.length>0){url+="?"+params.join("&");}window.location.href=url;}return false;};forEach($E('search_tab').getElementsByTagName('input'),function(){$G(this).addEvent('change',function(){tabChanged('search_tab');});if(this.id==tab){this.checked=true;}});tabChanged('search_tab');}function initLinks(show_text,hide_text){var doClick=function(){var ul=$E(this.id.replace("_more","_links")),c=ul.className;if(c=="more"){ul.className="";this.innerHTML=show_text;}else{ul.className="more";this.innerHTML=hide_text;}};callClick("rent_more",doClick);callClick("sale_more",doClick);}function initEmailRoom(){var doChanged=function(){$E('room_rental_end_date').parentNode.parentNode.className=$E('room_type').value==1?'hidden':'item';};$G('room_type').addEvent('change',doChanged);doChanged.call(this);}function initProjectTab(loc){var loadingmap=true,loadingavgprice=true,doChanged=function(){var id=this.id;forEach($E('condo-tab').getElementsByTagName('input'),function(item){if(!(id==item.id&&item.checked)){item.checked=false;}});if(id=='condo-map'&&loadingmap){loadingmap=false;$E("here_condo_map").innerHTML='<iframe src="'+WEB_URL+'room.php?lat='+loc.lat+'&lng='+loc.lng+'"></iframe>';}else if(id=='condo-avgprice'&&loadingavgprice){loadingavgprice=false;}forEach($E('condo-tab-content').getElementsByClassName('item'),function(item){var c=$G(item).hasClass(id);if(c&&$E(c).checked){item.addClass('show');}else{item.removeClass('show');}});};forEach($E('condo-tab').getElementsByTagName('input'),function(item){$G(item).addEvent('change',doChanged);});var doAvgpriceChanged=function(){var q='condo_id='+loc.condo_id+'&room_id='+loc.room_id+'&hotdeal='+loc.hotdeal+'&price='+($E('avgprice_price_1').checked?1:0)+'&roomtype='+$E('avgprice_roomtype').value;if($E('avgprice_type_1').checked){$E('avgprice_period').disabled=false;q+='&period='+$E('avgprice_period').value;}else{$E('avgprice_period').disabled=true;q+='&period=0';}send(WEB_URL+"index.php/room/model/avgprice/get",q,function(xhr){$E('avgprice_graphs').innerHTML=xhr.responseText;});};var initAvgprice=function(){$G(this).addEvent('change',doAvgpriceChanged);};forEach($E('tab_avgprice').getElementsByTagName('input'),initAvgprice);forEach($E('tab_avgprice').getElementsByTagName('select'),initAvgprice);doAvgpriceChanged.call();}function initProjectView(detail){var lightbox=new GLightbox();forEach(document.querySelectorAll('.detail-sidebar-section img'),function(item){if(item.className=='vdo'){item.parentNode.onclick=function(){var vdo='<figure>';vdo+='<div class=youtube><iframe width=560 height=315 src="//www.youtube.com/embed/'+item.id+'?wmode=transparent&amp;autoplay=true" frameborder=0></iframe></div>';vdo+='</figure>';new GModal().show(vdo,'mv');};}else if(!$G(item).hasClass('nozoom')){lightbox.add(item);}});initShare(detail);initFloatSearch();initRoomSort();}function initRoomFixedTop(){var _scrolltop=false,elem=$G("roomFixedTop"),roomFixedBottom=$G("roomFixedBottom"),room_price=$G(elem.querySelector(".room_price")),offset=20;$G(document).addEvent("scroll",function(){if(window.innerWidth&&window.innerWidth>900){var c,sc=this.viewport.getscrollTop(),topHeight=$G("topHeader").getHeight(),toTop=elem.getTop()-topHeight-offset,t=sc+room_price.getTop()+room_price.getHeight()-roomFixedBottom.getTop();if(t>0){c=2;room_price.style.transform='translateY(-'+t+'px)';room_price.style.msTransform='translateY(-'+t+'px)';room_price.style.webkitTransform='translateY(-'+t+'px)';room_price.style.mozTransform='translateY(-'+t+'px)';room_price.style.transform='oTransform(-'+t+'px)';}else if(sc>toTop){c=1;}else{c=0;}if(_scrolltop !=c){_scrolltop=c;if(c>0){room_price.style.top=(topHeight+offset)+"px";room_price.style.width=elem.getWidth()+"px";room_price.addClass("fixedTop");}else{room_price.style.width=null;room_price.removeClass("fixedTop");}room_price.style.transform='translateY(0px)';room_price.style.msTransform='translateY(0px)';room_price.style.webkitTransform='translateY(0px)';room_price.style.mozTransform='translateY(0px)';room_price.style.oTransform='translateY(0px)';}}});$G(window).addEvent("resize",function(){if(window.innerWidth&&window.innerWidth>900){room_price.style.width=elem.getWidth()+"px";}else{room_price.removeClass("fixedTop");room_price.style.width=null;room_price.style.transform='translateY(0px)';room_price.style.msTransform='translateY(0px)';room_price.style.webkitTransform='translateY(0px)';room_price.style.mozTransform='translateY(0px)';room_price.style.oTransform='translateY(0px)';}});}function initRoomView(detail,id,type,visited_count){initRoomFooter();initShare(detail);initSendMail();if($E('map_image')){new GLightbox().add($E('map_image'));}initFavoriteButton('content');initFloatSearch();initPerprice(id,type);initProjectSearchAll();initRoomSort();if(visited_count){window.setTimeout(function(){showModal(WEB_URL+'xhr.php','module=help&id='+id+'&type='+type,null,'modal_form');},1000);}}function initPerprice(id,type){callClick('perprice_'+id+'_'+type,function(){showModal(WEB_URL+'xhr.php','module=perprice&id='+id+'&type='+type,null,'modal_form');return false;});}function initFloatSearch(){if($E('float_search')){callClick('float_search',function(){showModal(WEB_URL+'xhr.php',this.get('data-params'),null,'search_modal');});}}function initFavoriteButton(id){var patt=/(ads|adsf|hotdeal|hotdealf|favorite)_([0-9]+)/,ids=[],items=[],hs,doClick=function(){hs=patt.exec(this.id);if(hs){if(hs[1]=='favorite'){send(WEB_URL+"index.php/index/model/favorite/save",'id='+hs[2],doFormSubmit,this);}}};forEach($E(id).getElementsByTagName('a'),function(item){hs=patt.exec(this.id);if(hs){if(hs[1]=='favorite'){ids.push(hs[2]);items.push(this);}callClick(item,doClick);}});if(ids.length>0){send(WEB_URL+"index.php/index/model/favorite/get",'id='+ids.join(','),function(xhr){var ds=xhr.responseText.toJSON();if(ds){forEach(items,function(){this.className=ds[this.id.replace('favorite_','')]==1?'icon-heart favorite':'icon-heart';});}});}}function initRoomImage(detail,id){initRoomFooter();initShare(detail);initSendMail();callClick('favorite_button',function(){send(WEB_URL+"index.php/index/model/favorite/save",'id='+id,doFormSubmit,this);});}function initRoomFooter(){if($E('room_price')){callClick('room_price',function(){window.scrollTo(0,$G('roomFixedTop').getTop());if($E('room_price_chk')){$E('room_price_chk').checked=true;}});}}function initSendMail(){callClick('send-mail',function(){showModal(WEB_URL+'xhr.php','module=sendmail&url='+window.location.href+'&subject='+this.title,null,'modal_form');return false;});}function initShare(detail){callClick('share_button',function(){modal=new GModal().show(detail);forEach($G('modal_share').elems('a'),function(){callClick(this,function(){var u=this.getAttribute("data-url"),c=this.className,t=encodeURIComponent(window.document.title);if(c=="icon-facebook"){window.open("https://www.facebook.com/sharer.php?u="+u+"&t="+t,"sharer","toolbar=0,status=0,width=626,height=436");}else if(c=="icon-twitter"){window.open("https://www.twitter.com/share?url="+u+"&text="+t,"sharer","toolbar=0,status=0,width=626,height=436");}else if(c=="icon-line"){window.open("line://msg/text/"+t+"%0D%0A"+u,"sharer");}modal.hide();});});});}function initProjectSearchAll(){if($E('search_result')){var patt=/^viewall_([0-9]+)$/;forEach($E('search_result').getElementsByTagName('a'),function(){if(patt.test(this.id)){callClick(this,function(){send(WEB_URL+"xhr.php",this.getAttribute('data-param'),function(xhr){var datas=xhr.responseText.toJSON();$E('result_'+datas.id).innerHTML=datas.content;$E('viewall_'+datas.id).parentNode.style.display='none';initFavoriteButton('result_'+datas.id);},this);});}});}initRoomFooter();initFloatSearch();var doShowMap=function(){if(this.checked){if(!$E('map_iframe')){var google_map=$E('google_map');google_map.innerHTML='<iframe id="map_iframe" src="'+google_map.dataset.src+'" scrolling="no" title="'+google_map.dataset.title+'"></iframe>'}}let currentTime=new Date().getTime(),dataObject={checked:this.checked,expiresAt:currentTime+(60*60*1000)};localStorage.setItem('show_map',JSON.stringify(dataObject));window.scrollTo(0,0);};let storedData=localStorage.getItem('show_map'),checked=false;if(storedData){let dataObject=JSON.parse(storedData),currentTime=new Date().getTime();if(dataObject.checked&&currentTime<dataObject.expiresAt){checked=true;}else{localStorage.removeItem('show_map');}}$E('show_map').checked=checked;$G('show_map').addEvent('change',doShowMap);doShowMap.call($E('show_map'));}function initRoomSort(){var doSort=function(){window.location.href=replaceURL({sort:floatval($E('room_sort').value),sort_type:$E('room_sort_type').checked?1:0});};$G('room_sort').addEvent('change',doSort);$G('room_sort_type').addEvent('change',doSort);}function btnSendLine(id){var q='id='+id+'&from='+encodeURIComponent(window.location.href);send(WEB_URL+"index.php/room/model/line/send",q);}function initPostcondo(){initProperty(false);var userLogin=function(xhr){var ds=xhr.responseText.toJSON();if(ds){if(ds.alert){alert(ds.alert);}else{if(ds.id){$E('owner_id').value=ds.id;$E('signin_fb').parentNode.parentNode.style.display='none';}if(ds.name){$E('owner_name').value=ds.name;}if(ds.phone){$E('owner_phone').value=ds.phone;}}}else if(xhr.responseText !=""){console.log(xhr.responseText);}};if($E('signin_google')){initGoogleButton('signin_google',function(q){send(WEB_URL+"index.php/index/model/gglogin/getlogin",q.join("&"),userLogin);});}if($E('signin_fb')){initFacebookButton('signin_fb',function(q){send(WEB_URL+"index.php/index/model/fblogin/getlogin",q.join("&"),userLogin);});}}function initNewsList(){forEach($E('news_menu').getElementsByTagName('input'),function(){callClick(this,function(){var chks=[];forEach($E('news_menu').getElementsByTagName('input'),function(){if(this.checked){chks.push(this.value.replace('cat-',''));}});window.location.href=WEB_URL+'news.html?cat='+chks.join(',');});});}function initListingFilter(){var doChanged=function(){var type=$E('listing_type').value;$E('listing_period').parentNode.style.display=type=='rent'?'inline-block':'none';$E('listing_resales').parentNode.style.display=type=='resale'?'inline-block':'none';$E('listing_sale').parentNode.style.display=type=='sale'?'inline-block':'none';};$G('listing_type').addEvent('change',doChanged);doChanged.call(this);};function initProperty(admin){var loading=true;new GMultiSelect(["province_id","amphur_id","district_id","road_id","soi_id"],{action:WEB_URL+"admin/index.php/index/model/address/get",onchange:function(d){if(admin&&$E('condo_id').value==0&&this.value !='0'){send(WEB_URL+"admin/index.php/index/model/address/find",'value='+this.value,function(xhr){var ds=xhr.responseText.toJSON();if(ds&&!loading){$E('latitude').value=ds.latitude;$E('longitude').value=ds.longitude;}loading=false;});}}});function getMethod(){var value=null;forEach($E('method_ul').getElementsByTagName('input'),function(){if(this.checked){value=this.value;return;}});return value;}function getSaleValue(){var value=null;forEach(document.getElementsByName('sale'),function(){if(this.checked){value=this.value;return}});return value;}var rentChanged=function(){$E('rent_9').disabled=$E('check_9').checked?false:true;$E('rent_12').disabled=$E('check_12').checked?false:true;$E('rent_6').disabled=$E('check_6').checked?false:true;$E('rent_3').disabled=$E('check_3').checked?false:true;$E('rent_1').disabled=$E('check_1').checked?false:true;if(admin){$E('hotdeal_9').disabled=$E('check_9').checked?false:true;$E('hotdeal_12').disabled=$E('check_12').checked?false:true;$E('hotdeal_6').disabled=$E('check_6').checked?false:true;$E('hotdeal_3').disabled=$E('check_3').checked?false:true;$E('hotdeal_1').disabled=$E('check_1').checked?false:true;$E('commission_9').disabled=$E('check_9').checked?false:true;$E('commission_12').disabled=$E('check_12').checked?false:true;$E('commission_6').disabled=$E('check_6').checked?false:true;$E('commission_3').disabled=$E('check_3').checked?false:true;$E('commission_1').disabled=$E('check_1').checked?false:true;$E('commission_hotdeal_9').disabled=$E('check_9').checked?false:true;$E('commission_hotdeal_12').disabled=$E('check_12').checked?false:true;$E('commission_hotdeal_6').disabled=$E('check_6').checked?false:true;$E('commission_hotdeal_3').disabled=$E('check_3').checked?false:true;$E('commission_hotdeal_1').disabled=$E('check_1').checked?false:true;}};$G("check_9").addEvent("change",rentChanged);$G("check_12").addEvent("change",rentChanged);$G("check_6").addEvent("change",rentChanged);$G("check_3").addEvent("change",rentChanged);$G("check_1").addEvent("change",rentChanged);rentChanged.call();$G("rent_12").addEvent("change",function(){var rent_12=floatval($E('rent_12').value),rent_6=floatval($E('rent_6').value),rent_3=floatval($E('rent_3').value),rent_1=floatval($E('rent_1').value);if($E('commission_12')){$E('commission_12').value=toCurrency(rent_12);}if(rent_6==0){$E('rent_6').value=toCurrency(rent_12);if($E('commission_6')){$E('commission_6').value=toCurrency(rent_12 / 2);}}if(rent_3==0){$E('rent_3').value=toCurrency(rent_12+1000);if($E('commission_3')){$E('commission_3').value=toCurrency((((rent_12+1000)*3)*10)/ 100);}}if(rent_1==0){$E('rent_1').value=toCurrency(rent_12+2000);if($E('commission_1')){$E('commission_1').value=toCurrency((((rent_12+2000)*1)*10)/ 100);}}});var commissionChanged=function(){var hs=/(rent|hotdeal)_([0-9]+)/.exec(this.id);if(hs){var id=hs[1]=='rent'?'commission_':'commission_hotdeal_';if(hs[2]=='12'){$E(id+hs[2]).value=toCurrency(floatval(this.value));}else if(hs[2]=='6'){$E(id+hs[2]).value=toCurrency(floatval(this.value)*0.5);}else{$E(id+hs[2]).value=toCurrency(((floatval(this.value)*floatval(hs[2]))*10)/ 100);}}};$G("rent_6").addEvent("change",commissionChanged);$G("rent_3").addEvent("change",commissionChanged);$G("rent_1").addEvent("change",commissionChanged);$G("hotdeal_12").addEvent("change",commissionChanged);$G("hotdeal_6").addEvent("change",commissionChanged);$G("hotdeal_3").addEvent("change",commissionChanged);$G("hotdeal_1").addEvent("change",commissionChanged);var binCheck=function(){$E('property_check').className='hidden';var qs=[ 'room_id='+$E('id').value,'condo_id='+$E('condo_id').value ];if($E('floor')){qs.push('floor='+$E('floor').value);}if($E('size')){qs.push('size='+$E('size').value);}else if($E('rai')){var size=(floatval($E('rai').value)*400)+(floatval($E('ngan').value)*100)+floatval($E('wa').value);qs.push('size='+size);}send(WEB_URL+"admin/index.php/index/model/checker/bin",qs.join('&'),function(xhr){var ds=xhr.responseText.toJSON();if(ds){var active='',deleted='';for(var k in ds['active']){active+='<p><a href="index.php?module=property&id='+ds['active'][k].id+'#tb_upload">'+ds['active'][k].id+'</a><span title="'+ds['active'][k].owner_description+'">'+ds['active'][k].owner_description+'</span></p>';}for(var k in ds['deleted']){deleted+='<p><a href="index.php?module=property&id='+ds['deleted'][k].id+'#tb_upload">'+ds['deleted'][k].id+'</a><span title="'+ds['deleted'][k].owner_description+'">'+ds['deleted'][k].owner_description+'</span></p>';}$E('property_check').innerHTML=active;$E('property_check').className=active==''?'hidden':'warning';$E('property_deleted').innerHTML=deleted;$E('property_deleted').className=deleted==''?'hidden':'error';}},this);};if(admin){if($E('floor')){$G('floor').addEvent("change,blur",binCheck);}if($E('size')){$G('size').addEvent("change,blur",binCheck);}else{$G('rai').addEvent("change,blur",binCheck);$G('ngan').addEvent("change,blur",binCheck);$G('wa').addEvent("change,blur",binCheck);}$G('condo').addEvent("blur",binCheck);binCheck.call();}var available_rents=[],availableRentChanged=function(){var value=null;forEach(available_rents,function(){if(this.checked){value=this.value;}});if(value=='f'){$G($E('rental_end_date').parentNode.parentNode.parentNode).removeClass('hidden');}else{$G($E('rental_end_date').parentNode.parentNode.parentNode).addClass('hidden');}};forEach(document.getElementsByName('available_rent'),function(){$G(this).addEvent("change",availableRentChanged);available_rents.push(this);});availableRentChanged.call();var available_sales=[],owner_typies=[],availableSaleChanged=function(){var value=null;forEach(available_sales,function(){if(this.checked){value=this.value;}});if(value=='f'){$G('property_delete').removeClass('hidden');}else{$G('property_delete').addClass('hidden');}},ownertypeChanged=function(){var value=null;forEach(owner_typies,function(){if(this.checked){value=this.value;}});if(value==1){$G($E('revenue_sharing').parentNode.parentNode).removeClass('hidden');if($E('revenue_sharing').value==0){$E('revenue_sharing').value=30;}$G($E('exclusive_contract').parentNode.parentNode).removeClass('hidden');}else if(value==2){$G($E('revenue_sharing').parentNode.parentNode).addClass('hidden');$G($E('exclusive_contract').parentNode.parentNode).removeClass('hidden');}else{$G($E('revenue_sharing').parentNode.parentNode).addClass('hidden');$G($E('exclusive_contract').parentNode.parentNode).addClass('hidden');}};forEach(document.getElementsByName('available_sale'),function(){$G(this).addEvent("change",availableSaleChanged);available_sales.push(this);});availableSaleChanged.call();forEach(document.getElementsByName('owner_type'),function(){$G(this).addEvent("change",ownertypeChanged);owner_typies.push(this);});ownertypeChanged.call();function calcPrice(prefix,src){var method=getMethod(),sale_value=floatval($E(prefix+'sale_value').value),commission=floatval($E(prefix+'commission').value),specific_business_tax=floatval($E(prefix+'specific_business_tax').value),transfer_fee=floatval($E(prefix+'transfer_fee').value),amount_adjusted=floatval($E(prefix+'amount_adjusted').value),transfer_fee_value=0,specific_business_tax_value=0;if(src.id==prefix+'sale_value'){$G(prefix+'commission_value').setValue(toCurrency((3*sale_value)/ 100));}var commission_value=commission==1?floatval($G(prefix+'commission_value').getText()):0;if(method !='resale'){if(specific_business_tax==1){specific_business_tax_value=(3.3*sale_value)/ 100;}else if(specific_business_tax==2){specific_business_tax_value=(0.5*sale_value)/ 100;}if(transfer_fee==1){transfer_fee_value=(1*sale_value)/ 100;}else if(transfer_fee==2){transfer_fee_value=(2*sale_value)/ 100;}$E(prefix+'specific_business_tax_value').innerHTML=toCurrency(specific_business_tax_value);$E(prefix+'transfer_fee_value').innerHTML=toCurrency(transfer_fee_value);}if(prefix==''){$E('sale_price').value=toCurrency(sale_value+commission_value+amount_adjusted);}else{$E('hotdeal_sale').value=toCurrency(sale_value+commission_value+amount_adjusted);}}var calcRoomPrice=function(e){calcPrice('',GEvent.element(e));};$G('sale_value').addEvent('change',calcRoomPrice);$G('commission').addEvent('change',calcRoomPrice);$G('commission_value').addEvent('change',calcRoomPrice);$G('specific_business_tax').addEvent('change',calcRoomPrice);$G('transfer_fee').addEvent('change',calcRoomPrice);$G('amount_adjusted').addEvent('change',calcRoomPrice);var calcHotdealPrice=function(e){calcPrice('hotdeal_',GEvent.element(e));};if($E('hotdeal_sale_value')){$G('hotdeal_sale_value').addEvent('change',calcHotdealPrice);$G('hotdeal_commission').addEvent('change',calcHotdealPrice);$G('hotdeal_commission_value').addEvent('change',calcHotdealPrice);$G('hotdeal_specific_business_tax').addEvent('change',calcHotdealPrice);$G('hotdeal_transfer_fee').addEvent('change',calcHotdealPrice);$G('hotdeal_amount_adjusted').addEvent('change',calcHotdealPrice);}var methodChanged=function(){var method=getMethod(),sale=getSaleValue();$E('sale_block').className=method=='rent'?'hidden':'';$E('rent_block').className=method=='resale'||method=='sale'?'hidden':'';$E('sale').parentNode.className=method=='sale'?'item':'hidden';if(admin&&(method=='sale'&&sale==3)){if($E('newroom_comment')){$E('newroom_comment').style.display='block';}$E('resale_comment').style.display='none';$E('sale_comment').style.display='none';if($E('furniture')){$G($E('furniture').parentNode).addClass('hidden');$G($E('resale_furniture').parentNode.parentNode).removeClass('hidden');}$G($E('specific_business_tax').parentNode.parentNode.parentNode).addClass('hidden');$G($E('transfer_fee').parentNode.parentNode.parentNode).addClass('hidden');}else if(method=='resale'){if($E('newroom_comment')){$E('newroom_comment').style.display='none';}$E('resale_comment').style.display='block';$E('sale_comment').style.display='none';if($E('furniture')){$G($E('furniture').parentNode).addClass('hidden');$G($E('resale_furniture').parentNode.parentNode).removeClass('hidden');}$G($E('specific_business_tax').parentNode.parentNode.parentNode).addClass('hidden');$G($E('transfer_fee').parentNode.parentNode.parentNode).addClass('hidden');}else{if($E('newroom_comment')){$E('newroom_comment').style.display='none';}$E('resale_comment').style.display='none';$E('sale_comment').style.display='block';if($E('furniture')){$G($E('furniture').parentNode).removeClass('hidden');$G($E('resale_furniture').parentNode.parentNode).addClass('hidden');}$G($E('specific_business_tax').parentNode.parentNode.parentNode).removeClass('hidden');$G($E('transfer_fee').parentNode.parentNode.parentNode).removeClass('hidden');}if($E('options')){forEach($E('options').getElementsByTagName('input'),function(){if(this.value=='new_room'){this.parentNode.style.display=method=='resale'?'inline-block':'none';}else if(this.value=='quota'){this.parentNode.style.display=method=='resale'||method=='sale'||method=='both'?'inline-block':'none';}else if(this.value=='key_legal'){this.parentNode.style.display=method=='resale'?'none':'inline-block';}else if(this.value=='deposit_1'){this.parentNode.style.display=method=='rent'||method=='both'?'inline-block':'none';}});}calcPrice('',$G('sale_value'));if($E('hotdeal_sale_value')){calcPrice('hotdeal_',$G('hotdeal_sale_value'));}};forEach($E('method_ul').getElementsByTagName('input'),function(){$G(this).addEvent("change",methodChanged);});forEach(document.getElementsByName('sale'),function(){$G(this).addEvent("change",methodChanged);});methodChanged.call();initAutoComplete("condo",WEB_URL+"admin/index.php/index/model/autocomplete/findCondo","name",null,{get:function(){return 'condo='+encodeURIComponent($E('condo').value.replace(/\//g,'&#47;'))+'&category='+$E('category').value;},callBack:function(){$G("condo").valid().value=this.name.unentityify();$E("condo_id").value=this.id;},onChanged:function(){$E("condo_id").value=0;$G("condo").invalid();}});initAutoComplete("owner",WEB_URL+"admin/index.php/index/model/autocomplete/findCustomer","name",null,{get:function(){return 'name='+encodeURIComponent($E('owner').value);},callBack:function(){$G("owner").valid().value=this.name;$E("owner_id").value=this.id;if($G("owner_name").value==''){$G("owner_name").value=this.name;}if($G("owner_phone").value==''){$G("owner_phone").value=this.phone;}},onChanged:function(){$E("owner_id").value=0;$G("owner").invalid();}});}function initImages(module,id){forEach($G(id).elems("a"),function(){callClick(this,function(e){send(WEB_URL+"admin/index.php/index/model/images/action","id="+this.parentNode.id,doFormSubmit,this);GEvent.stop(e);});});forEach($G(id).elems("figure"),function(){callClick(this,function(e){window.open(this.style.backgroundImage.slice(4,-1).replace(/"/g,""));GEvent.stop(e);});});new GDragDrop(id,{endDrag:function(){var elems=new Array();forEach($G(id).elems("figure"),function(){if(this.id){elems.push(this.id.replace(module+"_",""));}});if(elems.length>1){send(WEB_URL+"admin/index.php/index/model/"+(module=='property'?'propertie':module)+"s/action","action=sort&id="+elems.join(","),doFormSubmit);}}});}function initRoomAppointment(){var statusChanged=function(){var status=$E('status').value;$E('reason').parentNode.parentNode.className=status==1||status==2?'item':'hidden';$E('next_appointment_date').parentNode.parentNode.className=status==2||status==4?'item':'hidden';};if($E('status')){$G('status').addEvent('change',statusChanged);statusChanged.call(this);}var doCalc=function(){var q="id="+floatval($E('id').value)+'&price='+floatval($E('price').value);if($E('period')){q+='&period='+floatval($E('period').value);}if($E('deposit')){q+='&deposit='+floatval($E('deposit').value);}send(WEB_URL+"index.php/room/model/appointmentcalc/execute",q,doFormSubmit,this);};if($E('price')){$G('price').addEvent('change',doCalc);}if($E('period')){$G('period').addEvent('change',doCalc);}if($E('deposit')){$G('deposit').addEvent('change',doCalc);}}var CHANGE_COLOR='เปลี่ยนสี';var CHECK='เลือก';var CHECKBOX='เช็คบ๊อกซ์';var DELETE='ลบ';var DISABLE='ปิดใช้งาน';var DOWNLOADING_IS_A_SIGNED_DOCUMENT='การดาวน์โหลดถือเป็นการลงชื่อรับเอกสาร';var ENABLE='เปิดใช้งาน';var INVALID_DATA='ข้อมูลไม่ถูกต้อง';var ITEMS='รายการ';var NEXT_MONTH='เดือนถัดไป';var PLEASE_BROWSE_FILE='กรุณาเลือกไฟล์';var PLEASE_FILL_IN='กรุณากรอก';var PLEASE_SAVE_BEFORE_CONTINUING='กรุณาบันทึก ก่อนดำเนินการต่อ';var PLEASE_SELECT='กรุณาเลือก';var PLEASE_SELECT_AT_LEAST_ONE_ITEM='กรุณาเลือก XXX อย่างน้อย 1 รายการ';var PREV_MONTH='เดือนก่อนหน้า';var SELECT_ALL='เลือกทั้งหมด';var SELECT_NONE='ไม่เลือกรายการใดเลย';var SORRY_XXX_NOT_FOUND='ขออภัย ไม่พบ XXX ที่ต้องการ';var SUCCESSFULLY_COPIED_TO_CLIPBOARD='สำเนาไปยังคลิปบอร์ดเรียบร้อยแล้ว';var SUCCESSFULLY_UPLOADED_XXX_FILES='อัปโหลดเรียบร้อย XXX ไฟล์';var THE_HIGHEST_PRICE_MUST_BE_GREATER_THAN_THE_LOWEST_PRICE='ราคาสูงสุดต้องมากกว่าราคาต่ำสุด';var THE_LARGEST_SIZE_MUST_BE_GREATER_THAN_THE_SMALLEST_SIZE='ขนาดใหญ่สุดต้องมากกว่าขนาดเล็กสุด';var THE_TYPE_OF_FILE_IS_INVALID='ชนิดของไฟล์ไม่ถูกต้อง';var UNCHECK='ไม่เลือก';var YOU_WANT_TO_XXX='คุณต้องการ XXX?';var YOU_WANT_TO_XXX_THE_SELECTED_ITEMS='คุณต้องการ XXX รายการที่เลือก?';Date.monthNames=["ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค."];Date.longMonthNames=["มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม"];Date.longDayNames=["อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัสบดี","ศุกร์","เสาร์"];Date.dayNames=["อา.","จ.","อ.","พ.","พฤ.","ศ.","ส."];Date.yearOffset=543;initFacebook("2252727828293868","th");initGooleSignin("321520214361-sn553k4pt9p64fq0ogu4m026c0ec2bba");