﻿function Text() {}

if (!Array.prototype.push) {Array.prototype.push=function () {for (var iArg=0;iArg<arguments.length;iArg++) this[this.length]=arguments[iArg];return this.length;}}
Array.prototype.indexOf=function (v) {var i=0;while (i<this.length && this[i]!=v) i++;return i==this.length ? -1 : i;}
Array.prototype.remove=function (iIndex) {if (iIndex<0 || iIndex>=this.length) return;for (var i=iIndex+1;i<this.length;i++) this[i-1]=this[i];this.length--;return this;}
String.prototype.ToRX=function () {return this.replace(/(\(|\)|\{|\}|\[|\]|\:|\^|\$|\!|\=|\+|\*|\/|\,|\-|\||\?)/g,"\\$1");}
Object.prototype.Hash=function (funcs) {var s="\n";for (var i in this) {if (typeof this[i]=="function" && !funcs) continue;s+=i+"\t\t"+this[i]+"\n";}return s;}

function QS() {}
QS.Init=function () {this.Length=0;this.Data=[];var qs=location.href.split("?")[1],item;if (!qs) return;qs=qs.split("&");for (var i=0;i<qs.length;i++) {item=qs[i].split("=");item[1]=unescape(item[1]) || "";this.Data[item[0].toLowerCase()]=item[1];this.Data[i]=new QS.Item(item[0],item[1]);this.Length++;}}
QS.Get=function (item) {return this.Data[(item+"").toLowerCase()];}
QS.Item=function (name,value) {this.Name=name;this.Value=value;}
QS.Item.prototype.toString=function () {return this.Name+"="+this.Value;}
QS.Add=function () {var a;if (typeof arguments[0]=="string" && arguments[1]!=undefined) a=[new this.Item(arguments[0],arguments[1])];else if (arguments[0] instanceof Array) a=arguments[0];else a=arguments;var qs="",hash="",rxQS,item,value;if (/\?([^#]*)(#.*)?$/.test(location.href)) {qs=RegExp.$1;hash=RegExp.$2;}for (var i=0;i<a.length;i++) {if (!(a[i] instanceof QS.Item)) continue;item=a[i].Name;value=a[i].Value;rxQS=new RegExp("(^|&)"+item.ToRX()+"=?[^\&#]*(&|$)");qs=rxQS.test(qs) ? qs.replace(rxQS,"$1"+item+"="+value+"$2") : qs+(qs ? "&" : "")+item+"="+value;}location.href="?"+qs+hash;}

function Cookies() {}
Cookies.Get=function (name) {if (DOM.doc.cookie && new RegExp("\\b"+name+"=([^;]*)").test(DOM.doc.cookie)) return unescape(RegExp.$1);}
Cookies.Set=function (name,value) {var d=new Date();d.setTime(d.getTime()+365*24*3600*1000);DOM.doc.cookie=name+"="+escape(value)+"; expires="+d.toGMTString();/*path=/; */}
Cookies.Del=function (name) {if (this.Get(name)) DOM.doc.cookie=name+"=; expires=Thu, 01-Jan-70 00:00:01 UTC";}

Text.Pad=function (s,n) {n=n || 2;return "000000000000000000000".substr(0,n-(""+s).length)+s;}
Text.Escape=function (str,html) { if (typeof str=="string" && str.length) {if (!html) {str=str.replace(/>/g,"&gt;").replace(/</g,"&lt;");}else {str=str.replace(/\r?\n/g,"<br/>");}str=str.replace(/"/g,"&quot;").replace(/'/g,"&#39;");}return str;}
QS.Init();

function copy(s) {
	if (window.clipboardData) clipboardData.setData("Text",s);
}
