jQuery.fn.nextInArray=function(element){var nextId=0;for(var i=0;ithis.length-1)nextId=0;return this[nextId];};jQuery.fn.clearForm=function(){return this.each(function(){var type=this.type,tag=this.tagName.toLowerCase();if(tag=='form')return jQuery(':input',this).clearForm();if(type=='text'||type=='password'||tag=='textarea')this.value='';else if(type=='checkbox'||type=='radio')this.checked=false;else if(tag=='select')this.selectedIndex=-1;});};jQuery.fn.tagName=function(){return this.get(0).tagName;};jQuery.fn.exists=function(){return jQuery(this).length>0?true:false;};function isNumber(val){return/^\d+/.test(val);} function pushDataToParam(data,pref){pref=pref?pref:'';var res=[];for(var key in data){var name=pref&&pref!=''?pref+'['+key+']':key;if(typeof data[key]==='array'||typeof data[key]==='object'){res=jQuery.merge(res,pushDataToParam(data[key],name));}else{res.push(name+'='+data[key]);}} return res;} jQuery.fn.serializeAnythingPts=function(addData){var toReturn=[];var els=jQuery(this).find(':input').get();jQuery.each(els,function(){if(this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type))){var val=jQuery(this).val();toReturn.push(encodeURIComponent(this.name)+'='+encodeURIComponent(val));}});if(typeof addData!='undefined'){toReturn=jQuery.merge(toReturn,pushDataToParam(addData));} return toReturn.join('&').replace(/%20/g,'+');};jQuery.fn.serializeAssoc=function(){var data=[];jQuery.each(this.serializeArray(),function(key,obj){var a=obj.name.match(/(.*?)\[(.*?)\]/);if(a!==null){var subName=a[1];var subKey=a[2];if(!data[subName])data[subName]=[];if(data[subName][subKey]){if(jQuery.isArray(data[subName][subKey])){data[subName][subKey].push(obj.value);}else{data[subName][subKey]=[];data[subName][subKey].push(obj.value);}}else{data[subName][subKey]=obj.value;}}else{if(data[obj.name]){if(jQuery.isArray(data[obj.name])){data[obj.name].push(obj.value);}else{data[obj.name]=[];data[obj.name].push(obj.value);}}else{data[obj.name]=obj.value;}}});return data;};jQuery.fn.serializeObject=function(){var obj={};jQuery.each(this.serializeArray(),function(i,o){var n=o.name,v=o.value;obj[n]=obj[n]===undefined?v:jQuery.isArray(obj[n])?obj[n].concat(v):[obj[n],v];});return obj;};str_replace_all=function(str,token,newToken,ignoreCase){var _token;str+='';var i=-1;if(typeof token==='string'){if(ignoreCase){_token=token.toLowerCase();while((i=str.toLowerCase().indexOf(_token,i>=0?i+newToken.length:0))!==-1){str=str.substring(0,i)+newToken+str.substring(i+token.length);}}else{return str.split(token).join(newToken);}} return str;};function str_replace(haystack,needle,replacement){var temp=haystack.split(needle);return temp.join(replacement);} function str_repeat(input,multiplier){var buf='';for(var i=0;i0){var result=new Array();if(f_backwards){var r=f_string.length%f_split_length;if(r>0){result[result.length]=f_string.substring(0,r);f_string=f_string.substring(r);}} while(f_string.length>f_split_length){result[result.length]=f_string.substring(0,f_split_length);f_string=f_string.substring(f_split_length);} result[result.length]=f_string;return result;} return false;} function hexdec(hex_string){hex_string=(hex_string+'').replace(/[^a-f0-9]/gi,'');return parseInt(hex_string,16);} function dechex(number){if(number<0){number=0xffffffff+number+1;} return parseInt(number,10).toString(16);} function str_pad(input,pad_length,pad_string,pad_type){var half='',pad_to_go;var str_pad_repeater=function(s,len){var collect='',i;while(collect.length0){if(pad_type=='STR_PAD_LEFT'){input=str_pad_repeater(pad_string,pad_to_go)+input;}else if(pad_type=='STR_PAD_RIGHT'){input=input+str_pad_repeater(pad_string,pad_to_go);}else if(pad_type=='STR_PAD_BOTH'){half=str_pad_repeater(pad_string,Math.ceil(pad_to_go/2));input=half+input+half;input=input.substr(0,pad_length);}} return input;} function nameToClassId(name){return str_replace(str_replace(name,']',''),'[','');} function strpos(haystack,needle,offset){var i=haystack.indexOf(needle,offset);return i>=0?i:false;} function extend(Child,Parent){var F=function(){};F.prototype=Parent.prototype;Child.prototype=new F();Child.prototype.constructor=Child;Child.superclass=Parent.prototype;} function toeRedirect(url,newWnd){if(newWnd){var win=window.open(url,'_blank');win.focus();}else{document.location.href=url;}} function toeReload(url){if(url)toeRedirect(url);document.location.reload();} jQuery.fn.toeRebuildSelect=function(data,useIdAsValue,val){if(jQuery(this).tagName()=='SELECT'&&typeof data=='object'){if(jQuery(data).length>0){if(typeof val=='undefined')val=false;if(jQuery(this).children('option').length){jQuery(this).children('option').remove();} if(typeof useIdAsValue=='undefined')useIdAsValue=false;var selected='';for(var id in data){selected='';if(val&&((useIdAsValue&&id==val)||data[id]==val))selected='selected';jQuery(this).append('');}}}};function toeInArray(needle,haystack){if(typeof haystack=='object'){for(var k in haystack){if(haystack[k]==needle)return k;}}else if(typeof haystack=='array'){return jQuery.inArray(needle,haystack);} return-1;} jQuery.fn.setReadonly=function(){jQuery(this).addClass('toeReadonly').attr('readonly','readonly');};jQuery.fn.unsetReadonly=function(){jQuery(this).removeClass('toeReadonly').removeAttr('readonly','readonly');};jQuery.fn.getClassId=function(pref,test){var classId=jQuery(this).attr('class');classId=classId.substr(strpos(classId,pref+'_'));if(strpos(classId,' '))classId=classId.substr(0,strpos(classId,' '));classId=classId.split('_');classId=classId[1];return classId;};function toeTextIncDec(textFieldId,inc){var value=parseInt(jQuery('#'+textFieldId).val());if(isNaN(value))value=0;if(!(inc<0&&value<1)){value+=inc;} jQuery('#'+textFieldId).val(value);} function toeStrFirstUp(str){str+='';var f=str.charAt(0).toUpperCase();return f+str.substr(1);} function parseStr(str,array){var strArr=String(str).replace(/^&/,'').replace(/&$/,'').split('&'),sal=strArr.length,i,j,ct,p,lastObj,obj,lastIter,undef,chr,tmp,key,value,postLeftBracketPos,keys,keysLen,fixStr=function(str){return decodeURIComponent(str.replace(/\+/g,'%20'));};if(!array){array={};} for(i=0;i-1){key=key.slice(0,key.indexOf('\x00'));} if(key&&key.charAt(0)!=='['){keys=[];postLeftBracketPos=0;for(j=0;jct&&p.match(/^\d+$/g)){ct=+p;}}} key=ct+1;}} lastObj[key]=value;}} return array;} function toeListablePts(params){this.params=jQuery.extend({},params);this.table=jQuery(this.params.table);this.paging=jQuery(this.params.paging);this.perPage=this.params.perPage;this.list=this.params.list;this.count=this.params.count;this.page=this.params.page;this.pagingCallback=this.params.pagingCallback;var self=this;this.draw=function(list,count){this.table.find('tr').not('.ptsExample, .ptsTblHeader').remove();var exampleRow=this.table.find('.ptsExample');for(var i in list){var newRow=exampleRow.clone();for(var key in list[i]){var element=newRow.find('.'+key);if(element.length){var valueTo=element.attr('valueTo');if(valueTo){var newValue=list[i][key];var prevValue=element.attr(valueTo);if(prevValue)newValue=prevValue+' '+newValue;element.attr(valueTo,newValue);}else element.html(list[i][key]);}} newRow.removeClass('ptsExample').show();this.table.append(newRow);} if(this.paging){this.paging.html('');if(count&&count>list.length&&this.perPage){for(var i=1;i<=Math.ceil(count/this.perPage);i++){var newPageId=i-1,newElement=newPageId==this.page?jQuery(''):jQuery('');if(newPageId!=this.page){newElement.attr('href','#'+newPageId).click(function(){if(self.pagingCallback&&typeof self.pagingCallback=='function'){self.pagingCallback(parseInt(jQuery(this).attr('href').replace('#','')));return false;}});} newElement.addClass('toePagingElement').html(i);this.paging.append(newElement);if(i%20==0&&i)this.paging.append('
');}}}};if(this.list)this.draw(this.list,this.count);} function setCookiePts(c_name,value,exdays){var exdate=new Date();exdate.setDate(exdate.getDate()+exdays);var value_prepared='';if(typeof value=='array'||typeof value=='object'){value_prepared='_JSON:'+JSON.stringify(value);}else{value_prepared=value;} var c_value=escape(value_prepared)+(exdays==null?'':'; expires='+exdate.toUTCString())+'; path=/';document.cookie=c_name+'='+c_value;} function getCookiePts(name){var parts=document.cookie.split(name+'=');if(parts.length==2){var value=unescape(parts.pop().split(';').shift());if(value.indexOf('_JSON:')===0){value=JSON.parse(value.split('_JSON:').pop());} return value;} return null;} function delCookiePts(name){document.cookie=name+'=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';} function callUserFuncArray(cb,parameters){var func;if(typeof cb==='string'){func=typeof this[cb]==='function'?this[cb]:(func=new Function(null,'return '+cb)());}else if(Object.prototype.toString.call(cb)==='[object Array]'){func=typeof cb[0]=='string'?eval(cb[0]+"['"+cb[1]+"']"):(func=cb[0][cb[1]]);}else if(typeof cb==='function'){func=cb;} if(typeof func!=='function'){throw new Error(func+' is not a valid function');} return typeof cb[0]==='string'?func.apply(eval(cb[0]),parameters):typeof cb[0]!=='object'?func.apply(null,parameters):func.apply(cb[0],parameters);} jQuery.fn.zoom=function(level,position){position=position?position:'center center';var scaleCss=level==1?'none':'scale('+level+')';jQuery(this).data('zoom',level);return jQuery(this).css({'-moz-transform':scaleCss,'-moz-transform-origin':position,'-o-transform':scaleCss,'-o-transform-origin':position,'-webkit-transform':scaleCss,'-webkit-transform-origin':position,transform:scaleCss,'transform-origin':position,});};jQuery.fn.scrollWidth=function(){var inner=document.createElement('p');inner.style.width='100%';inner.style.height='200px';var outer=document.createElement('div');outer.style.position='absolute';outer.style.top='0px';outer.style.left='0px';outer.style.visibility='hidden';outer.style.width='200px';outer.style.height='150px';outer.style.overflow='hidden';outer.appendChild(inner);document.body.appendChild(outer);var w1=inner.offsetWidth;outer.style.overflow='scroll';var w2=inner.offsetWidth;if(w1==w2)w2=outer.clientWidth;document.body.removeChild(outer);return w1-w2;};function toeGetImgAttachId(img){var classesStr=jQuery(img).attr('class'),aid=0;if(classesStr&&classesStr!=''){var matches=classesStr.match(/wp-image-(\d+)/);if(matches&&matches[1]){aid=parseInt(matches[1]);}} return aid;} function toeGetHashParams(){var hashArr=window.location.hash.split('#'),res=[];for(var i in hashArr){if(hashArr[i]&&hashArr[i]!=''){res.push(hashArr[i]);}} return res;} function traverseElement(el,regex,textReplacerFunc,to){if(!/^(script|style)$/.test(el.tagName)){var child=el.lastChild;while(child){if(child.nodeType==1){traverseElement(child,regex,textReplacerFunc,to);}else if(child.nodeType==3){textReplacerFunc(child,regex,to);} child=child.previousSibling;}}} function textReplacerFunc(textNode,regex,to){textNode.data=textNode.data.replace(regex,to);} function replaceWords(html,words){var container=document.createElement('div');container.innerHTML=html;for(var replace in words){traverseElement(container,new RegExp(replace,'g'),textReplacerFunc,words[replace]);} return container.innerHTML;} function toeSelectText(element){var doc=document,text=jQuery(element).get(0),range,selection;if(doc.body.createTextRange){range=doc.body.createTextRange();range.moveToElementText(text);range.select();}else if(window.getSelection){selection=window.getSelection();range=doc.createRange();range.selectNodeContents(text);selection.removeAllRanges();selection.addRange(range);}} jQuery.fn.animationDuration=function(seconds,isMili){if(isMili){seconds=parseFloat(seconds)/1000;} var secondsStr=seconds+'s';return jQuery(this).css({'webkit-animation-duration':secondsStr,'-moz-animation-duration':secondsStr,'-o-animation-duration':secondsStr,'animation-duration':secondsStr,});};function ptsStrToMs(strDate){var dateHours=strDate.split(' ');if(dateHours.length==2){strDate=dateHours[0]+' ';var hms=dateHours[1].split(':');for(var i=0;i<3;i++){strDate+=hms[i]?hms[i]:'00';if(i<2)strDate+=':';}} var date=new Date(str_replace(strDate,'-','/')),res=0;if(date){res=date.getTime();} return res;} function mtRand(min,max){return Math.floor(Math.random()*(max-min+1))+min;} Date.prototype.format=function(e){var t='';var n=Date.replaceChars;for(var r=0;r=0&&e.charAt(r-1)=='\\'){t+=i;}else if(n[i]){t+=n[i].call(this);}else if(i!='\\'){t+=i;}} return t;};Date.replaceChars={shortMonths:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Pts','Nov','Dec'],longMonths:['January','February','March','April','May','June','July','August','September','Ptsober','November','December'],shortDays:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],longDays:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d:function(){return(this.getDate()<10?'0':'')+this.getDate();},D:function(){return Date.replaceChars.shortDays[this.getDay()];},j:function(){return this.getDate();},l:function(){return Date.replaceChars.longDays[this.getDay()];},N:function(){return this.getDay()+1;},S:function(){return this.getDate()%10==1&&this.getDate()!=11?'st':this.getDate()%10==2&&this.getDate()!=12?'nd':this.getDate()%10==3&&this.getDate()!=13?'rd':'th';},w:function(){return this.getDay();},z:function(){var e=new Date(this.getFullYear(),0,1);return Math.ceil((this-e)/864e5);},W:function(){var e=new Date(this.getFullYear(),0,1);return Math.ceil(((this-e)/864e5+e.getDay()+1)/7);},F:function(){return Date.replaceChars.longMonths[this.getMonth()];},m:function(){return(this.getMonth()<9?'0':'')+(this.getMonth()+1);},M:function(){return Date.replaceChars.shortMonths[this.getMonth()];},n:function(){return this.getMonth()+1;},t:function(){var e=new Date();return new Date(e.getFullYear(),e.getMonth(),0).getDate();},L:function(){var e=this.getFullYear();return e%400==0||(e%100!=0&&e%4==0);},o:function(){var e=new Date(this.valueOf());e.setDate(e.getDate()-((this.getDay()+6)%7)+3);return e.getFullYear();},Y:function(){return this.getFullYear();},y:function(){return(''+this.getFullYear()).substr(2);},a:function(){return this.getHours()<12?'am':'pm';},A:function(){return this.getHours()<12?'AM':'PM';},B:function(){return Math.floor(((((this.getUTCHours()+1)%24)+this.getUTCMinutes()/60+this.getUTCSeconds()/3600)*1e3)/24);},g:function(){return this.getHours()%12||12;},G:function(){return this.getHours();},h:function(){return((this.getHours()%12||12)<10?'0':'')+(this.getHours()%12||12);},H:function(){return(this.getHours()<10?'0':'')+this.getHours();},i:function(){return(this.getMinutes()<10?'0':'')+this.getMinutes();},s:function(){return(this.getSeconds()<10?'0':'')+this.getSeconds();},u:function(){var e=this.getMilliseconds();return(e<10?'00':e<100?'0':'')+e;},e:function(){return'Not Yet Supported';},I:function(){var e=null;for(var t=0;t<12;++t){var n=new Date(this.getFullYear(),t,1);var r=n.getTimezoneOffset();if(e===null)e=r;else if(re)break;} return(this.getTimezoneOffset()==e)|0;},O:function(){return(-this.getTimezoneOffset()<0?'-':'+')+(Math.abs(this.getTimezoneOffset()/60)<10?'0':'')+Math.abs(this.getTimezoneOffset()/60)+'00';},P:function(){return(-this.getTimezoneOffset()<0?'-':'+')+(Math.abs(this.getTimezoneOffset()/60)<10?'0':'')+Math.abs(this.getTimezoneOffset()/60)+':00';},T:function(){var e=this.getMonth();this.setMonth(0);var t=this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/,'$1');this.setMonth(e);return t;},Z:function(){return-this.getTimezoneOffset()*60;},c:function(){return this.format('Y-m-d\\TH:i:sP');},r:function(){return this.toString();},U:function(){return this.getTime()/1e3;},};function ptsCallWpMedia(params){params=params||{};if(typeof wp!=='undefined'&&wp.media&&wp.media.editor)wp.media.editor.open(params.id);wp.media.editor.insert=function(html){if(wp.media.editor._attachSent){wp.media.editor._attachSent=false;return;} if(html&&html!=''){var imgUrl=jQuery(html).attr('src');if(imgUrl){params.clb({},{},imgUrl);}}};wp.media.editor.send.attachment=function(opts,attach){wp.media.editor._attachSent=true;var imgUrl=opts.size&&attach.sizes[opts.size]&&attach.sizes[opts.size].url?attach.sizes[opts.size].url:attach.url;params.clb(opts,attach,imgUrl);};window.original_send_to_editor=window.send_to_editor;window.send_to_editor=function(html){};} function ptsMceMoveToolbar(editor,clientX){var panel=editor.theme.panel;if(!panel)return;var panelRect=panel.layoutRect(),bodyElement=jQuery(editor.bodyElement),bodyOffset=bodyElement.offset(),newX=clientX-panelRect.w/2,newY=bodyOffset.top-30;if(newY<=150){newY+=bodyElement.height()+30;} if(newX<0)newX=0;panel.moveTo(newX,panelRect.y?panelRect.y:newY);panel._ptsOriginalTop=newY;} function getSelectionCoords(win){win=win||window;var doc=win.document;var sel=doc.selection,range,rects,rect;var x=0,y=0;if(sel){if(sel.type!='Control'){range=sel.createRange();range.collapse(true);x=range.boundingLeft;y=range.boundingTop;}}else if(win.getSelection){sel=win.getSelection();if(sel.rangeCount){range=sel.getRangeAt(0).cloneRange();if(range.getClientRects){range.collapse(true);rects=range.getClientRects();if(rects.length>0){rect=range.getClientRects()[0];} if(!rect){return false;} x=rect.left;y=rect.top;} if(x==0&&y==0){var span=doc.createElement('span');if(span.getClientRects){span.appendChild(doc.createTextNode('\u200b'));range.insertNode(span);rect=span.getClientRects()[0];x=rect.left;y=rect.top;var spanParent=span.parentNode;spanParent.removeChild(span);spanParent.normalize();}}}} return{x:x,y:y};} function get_class(obj){if(obj instanceof Object&&!(obj instanceof Array)&&!(obj instanceof Function)&&obj.constructor){var arr=obj.constructor.toString().match(/function\s*(\w+)/);if(arr&&arr.length==2){return arr[1];}} return false;} function serialize(mixed_val){switch(typeof mixed_val){case'number':if(isNaN(mixed_val)||!isFinite(mixed_val)){return false;}else{return(Math.floor(mixed_val)==mixed_val?'i':'d')+':'+mixed_val+';';} case'string':return's:'+mixed_val.length+':"'+mixed_val+'";';case'boolean':return'b:'+(mixed_val?'1':'0')+';';case'object':if(mixed_val==null){return'N;';}else if(mixed_val instanceof Array){var idxobj={idx:-1};var map=[];for(var i=0;i1?this.eq(0):this,n=r.get(0),f=i.width(),h=i.height(),o=o?o:'both',l=e===!0?n.offsetWidth*n.offsetHeight:!0;if('function'==typeof n.getBoundingClientRect){var g=n.getBoundingClientRect(),u=g.top>=0&&g.top0&&g.bottom<=h,c=g.left>=0&&g.left0&&g.right<=f,v=t?u||s:u&&s,b=t?c||a:c&&a;if('both'===o)return l&&v&&b;if('vertical'===o)return l&&v;if('horizontal'===o)return l&&b;}else{var d=i.scrollTop(),p=d+h,w=i.scrollLeft(),m=w+f,y=r.offset(),z=y.top,B=z+r.height(),C=y.left,R=C+r.width(),j=t===!0?B:z,q=t===!0?z:B,H=t===!0?R:C,L=t===!0?C:R;if('both'===o)return!!l&&p>=q&&j>=d&&m>=L&&H>=w;if('vertical'===o)return!!l&&p>=q&&j>=d;if('horizontal'===o)return!!l&&m>=L&&H>=w;}}};})(jQuery);(function(window){window.htmlentities={encode:function(str){var buf=[];for(var i=str.length-1;i>=0;i--){buf.unshift(['&#',str[i].charCodeAt(),';'].join(''));} return buf.join('');},decode:function(str){return str.replace(/&#(\d+);/g,function(match,dec){return String.fromCharCode(dec);});},};})(window);