﻿Array.prototype.Remove=function(a){if(a>=0&&a<this.length){this.splice(a,1)}return this};Array.prototype.RemoveLast=function(){this.splice(this.length-1,1);return this};Array.prototype.Find=function(c){var a=-1;for(var b=0;b<this.length;b++){if(this[b]==c){a=b;break}}return a};Array.prototype.FindObj=function(d,b){var a=-1;for(var c=0;c<this.length;c++){if(this[c][d]==b){a=c;break}}return a};Array.prototype.FindAll=function(d,a){var c=[];for(var b=0;b<this.length;b++){if(this[b][d]==a){c.push(this[b])}}return c};Array.prototype.FindPrp=function(c){var a=-1;for(var b=0;b<this.length;b++){if(this[b][c]){a=b;break}}return a};Array.prototype.AddUnique=function(b,c){var a=this.FindObj(c,b[c]);if(a==-1){this.push(b);return -1}return a};
function daysInMonth(a){return 32-new Date(a.getFullYear(),a.getMonth(),32).getDate()}Date.prototype.getDayInYear=function(){var a=new Date(this.getFullYear(),0,1);var b=this-a;return Math.round(b/1000/60/60/24)+1};Date.prototype.getWeek=function(){var a=new Date(this.getFullYear(),0,1);var e=new Date(this.getFullYear(),11,31);var c=new Date(a);var d=this.getDayInYear();var b=0;if(this.getMonth()==0&&this.getDate()<=3&&this.getDayMon()>3){b=new Date(this.getFullYear()-1,11,31).getWeek()}else{if(this>c.add("y",1).add("d",0-c.getDayMon())){if(e.getDayMon()<3){b=1}}if(b==0){b=Math.ceil((d+a.getDayMon())/7);if(a.getDayMon()>3){b=b-1}}}return b};Date.prototype.getTimeString=function(a){var b=((this.getHours()<10)?"0":"")+this.getHours()+":"+((this.getMinutes()<10)?"0":"")+this.getMinutes();return b};Date.prototype.getWeekInMonth=function(){var a=0;var d=new Date(this);d.setDate(1);var b=d.getDayMon()-1;var c=this.getDate()+b-a;return Math.floor((c)/7)+1};Date.prototype.getNumberOfWeeksInMonth=function(a){var b=4;var c=daysInMonth(a);a.setDate(c);b=a.getWeekInMonth();return b};Date.prototype.compare=function(a,b){var c=false;switch(a.toLowerCase()){case"d":if(this.getYear()==b.getYear()&&this.getMonth()==b.getMonth()&&this.getDate()==b.getDate()){c=true}}return c};Date.prototype.getDayMon=function(){if(this.getDay()==0){return 6}return this.getDay()-1};Date.prototype.add=function(a,b){var c=this;if(!a||b==0){return c}switch(a.toLowerCase()){case"ms":c.setMilliseconds(c.getMilliseconds()+b);break;case"s":c.setSeconds(c.getSeconds()+b);break;case"mi":c.setMinutes(c.getMinutes()+b);break;case"h":c.setHours(c.getHours()+b);break;case"d":c.setDate(c.getDate()+b);break;case"mo":c.setMonth(c.getMonth()+b);break;case"y":c.setFullYear(c.getFullYear()+b);break}return c};Date.prototype.toFormat=function(){format=(arguments.length>0)?arguments[0]:Date.Format;format=format.replace("y",this.getFullYear());format=format.replace("m",(this.getMonth()+1>9)?this.getMonth()+1:"0"+(this.getMonth()+1));format=format.replace("d",(this.getDate()>9)?this.getDate():"0"+this.getDate());format=format.replace("h",this.getHours());format=format.replace("m",this.getMinutes());return format};Date.prototype.toShortFormat=function(){return this.getDate()+" "+window.Translate.Months[this.getMonth()].substr(0,3)};Date.prototype.parseFormat=function(b){var a=Date.Format.replace("y","").replace("m","").replace("d","").charAt(0);var d=Date.Format.split(a);var c=b.split(a);this.setDate(1);for(i=0;i<d.length;i++){if(d[i]=="y"){this.setFullYear(parseInt(c[i]))}else{if(d[i]=="m"){this.setMonth(parseInt(c[i].replace(/^0+/,""))-1)}else{if(d[i]=="d"){this.setDate(parseInt(c[i].replace(/^0+/,"")))}}}}};Date.prototype.getTimeUTC=function(){var a=new Date(this);a.add("mi",0-a.getTimezoneOffset());return a.getTime()};
String.prototype.trimEnd=function(b){var a=new RegExp(b+"$");return this.replace(a,"")};

