﻿function QuotedStrNull(a){if(!a){return(null)}else{return(a.QuotedStr())}}String.prototype.DupeString=function(d){var c;var b;var a;b=this.valueOf();c=b;for(a=1;a<d;a++){c+=b}return(c)};String.prototype.StrPadLeft=function(e,d){var b;var a;if(undefined===d){d="0"}b=this.valueOf();a=b.length;if(a>=e){return(b)}else{return(d.DupeString(e-a)+b)}};String.prototype.StrPadRight=function(e,d){var b;var a;if(undefined===d){d=" "}b=this.valueOf();a=b.length;if(a>=e){return(b)}else{return(b+d.DupeString(e-a))}};String.prototype.Format=function(){var f=new Array();var c=this.valueOf();var b=arguments.length;var e;var a;var g=0;var d=/\{(\d+)\}/g;while(e=d.exec(c)){f[f.length]=c.substring(g,e.index);a=parseInt(e[1]);if((a>=0)&&(a<b)){f[f.length]=String(arguments[a])}else{f[f.length]=e[0]}g=e.index+e[0].length}f[f.length]=c.substring(g,c.length);return(f.join(""))};String.prototype.Format2=function(){var a=this.Format.apply(this,arguments);return(a.replace(/\{\d+\}/g,""))};String.prototype.QuotedStr=function(){return("'"+this.replace(/'/g,"''")+"'")};String.prototype.QuotStr=function(){return(this.replace(/"/g,"&quot;"))};String.prototype.EscapeQuot=function(){return(this.replace(/"/g,'\\"'))};String.prototype.EscapeSQuot=function(){return(this.replace(/'/g,"\\'"))};String.prototype.DoubleSQuot=function(){return(this.replace(/'/g,"''"))};String.prototype.EscapeJson=function(){return(this.replace(/\\/g,"\\\\").EscapeSQuot())};String.prototype.LeftStr=function(a){return(this.substring(0,a))};String.prototype.RightStr=function(a){return(a?this.slice(-a):"")};String.prototype.MidStr=function(b,a){return(this.substr(b,a))};String.prototype.NlABr=function(){return(this.replace(/\n/g,"<br />"))};String.prototype.NlAEspacio=function(){return(this.replace(/\n/g," "))};String.prototype.AbreviarStr=function(d,e,g){function h(j){var i=j;var k=j.lastIndexOf("<");if(k!==-1){var l=j.lastIndexOf(">");if(k>l){i=j.substring(0,k)}k=i.lastIndexOf("<");if((k===i.length-1)||(i.charAt(k+1)!=="/")){l=i.lastIndexOf(">");i=i.substring(0,k)+i.substring(l+1,i.length)}}return(i)}function f(j){var i=j;var l=j.indexOf(">");if(l!==-1){var k=j.indexOf("<");if((k===-1)||(k>l)){i=j.substring(l+1,j.length)}k=i.indexOf("<");if((k===i.length-1)||(i.charAt(k+1)==="/")){l=i.indexOf(">");i=i.substring(0,k)+i.substring(l+1,i.length)}}return(i)}e=e||0;var b=this.valueOf();var a=b.length;if(a>d){if(!e){var c=d>>1;if(g){b=h(b.LeftStr(c))+"..."+f(b.RightStr(c))}else{b=b.LeftStr(c)+"..."+b.RightStr(c)}}else{if(g){b=h(b.LeftStr(d-3))+"..."}else{b=b.LeftStr(d-3)+"..."}}}return(b)};String.prototype.Trim=function(){return(this.replace(/^\s*(\S*(\s+\S+)*)\s*$/,"$1"))};String.prototype.ReverseString=function(){return(this.split("").reverse().join(""))};String.prototype.SetCharAt=function(b,a){return(this.LeftStr(b)+a+this.RightStr(this.length-b-1))};String.prototype.CleanStr=function(){var a=new Array();for(var b=0;b<this.length;b++){var d=this.charAt(b);switch(d){case"á":a.push("a");break;case"Á":a.push("A");break;case"é":a.push("e");break;case"É":a.push("E");break;case"í":a.push("i");break;case"Í":a.push("I");break;case"ó":a.push("o");break;case"Ó":a.push("O");break;case"ú":a.push("u");break;case"Ú":a.push("U");break;default:if((d.charCodeAt(0)<32)||(d.charCodeAt(0)>127)){a.push("_")}else{a.push(d)}}}return(a.join(""))};String.prototype.BreakStr=function(e,d){e=e||3;d=d||" ";var b=this.valueOf();var a=new RegExp("([^{0}]+)([^{1}]{{2}})".Format(d,d,e));while(a.test(b)){b=b.replace(a,"$1"+d+"$2")}return(b)};
