if(!Array.prototype.indexOf) {
	Array.prototype.indexOf = function(p_xVal) {
		if(!p_xVal){return -1;};
		for(var iIdx in this) {
			if(this[iIdx]==p_xVal) {
				return iIdx;
			};
		};
		return -1;		
	};
};

if(typeof Array.prototype.push != "function"){
	Array.prototype.push = function (){
		for(var i=0; i<arguments.length; i++){
        	this[this.length] = arguments[i];
        }
		return this.length;
	}
}

if(typeof Array.prototype.exclude != "function"){
	Array.prototype.exclude = function (p_xVal){
		var iIdx=this.indexOf(p_xVal);
		if(iIdx!=-1) {this.splice(iIdx,1);};
	}
}

if(typeof Array.prototype.include != "function"){
	Array.prototype.include = function (p_xVal){
		var iIdx=this.indexOf(p_xVal);
		if(iIdx!=-1) {this.push(p_xVal);};
	}
}

if(typeof Array.prototype.equal != "function"){
	Array.prototype.equal = function (p_xA){
		var i,iC=this.length;
		if(iC!=p_xA.length){return false;};
		for(i=0;i<iC;i++) {
			if(this[i]!==p_xA[i]){return false;};
		};
		return true;
	}
}

function $(name) {
	return document.getElementById(name);
};

function v_SetCookie(p_sName,p_sValue,p_iDays) {
	if(p_iDays){
		var xDate = new Date();
		xDate.setTime(xDate.getTime()+(p_iDays*24*60*60*1000));
		var sExpires = "; expires="+xDate.toGMTString();
	} else {
		var sExpires = "";
	};
	document.cookie = p_sName+"="+p_sValue+sExpires+"; path=/";
}

function v_GetCookie(p_sName,p_sDefault) {
	var sNameEQ=p_sName+"=";
	var aS=document.cookie.split(';');
	for(var i=0;i<aS.length;i++) {
		var sSub=aS[i];
		while(sSub.charAt(0)==' '){sSub=sSub.substring(1,sSub.length);};
		if(sSub.indexOf(sNameEQ)==0){return sSub.substring(sNameEQ.length,sSub.length);};
	}
	return p_sDefault;
}

function v_EraseCookie(p_sName) {
	v_SetCookie(p_sName,"",-1);
}

function v_URLEncode(text) {
	return encodeURIComponent(text);
}

function v_HTMLEncode(text) {
	var sLiteralChars=" 0123456789abcdefghijklmnopqrstuvwxyzABCDEDFGHIJKLMNOPQRSTUVWXYZ-_=./':;,+*-(){}[]";
	var sHexChars="0123456789abcdef";
	var sEncoded="";
	var i,iC=text.length;
	for(i=0;i<iC;i++) {
		var cCur=text.charAt(i);
		if(-1!=sLiteralChars.indexOf(cCur)) {
			sEncoded+=cCur;
		} else {
			if(cCur=="&") {
				sEncoded+="&amp;"
			} else if(cCur=="<") {
				sEncoded+="&lt;";
			} else if(cCur==">") {
				sEncoded+="&gt;";
			} else if(cCur=="\"") {
				sEncoded+="&quot;";
			} else {
				var iCode=cCur.charCodeAt(0);
				if(iCode<256)
				{
					sEncoded+="&#"+(iCode)+";";
				}
				else
				{
					sEncoded+="&#x"+sHexChars.charAt((iCode>>12)&0xf)+sHexChars.charAt((iCode>>8)&0xf)+sHexChars.charAt((iCode>>4)&0xf)+sHexChars.charAt((iCode)&0xf)+";";
				};
				
			};
		};
	};
	return sEncoded;
}

function VStringBuilder()
{
	this.aS=new Array("");
	this.Add=function(){
		var i;
		for(i=0;i<arguments.length;i++){ 
			this.aS.push(arguments[i]);
		};
	};
	this.GetString=function(){
		return this.aS.join("");
	};
	this.Clear=function(){
		this.aS.length=1;
	};
};

// get (roughly) the current inner window size
function v_GetViewHeight()
{
	if(self.innerHeight){	// all except Explorer
		return self.innerHeight;
	}else if(document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		return document.documentElement.clientHeight;
	}else if (document.body){// other Explorers
		return document.body.clientHeight;
	};
	return 800;
};

// get (roughly) the current inner window size
function v_GetViewWidth()
{
	if(self.innerWidth){	// all except Explorer
		return self.innerWidth;
	}else if(document.documentElement && document.documentElement.clientWidth) { // Explorer 6 Strict Mode
		return document.documentElement.clientWidth;
	}else if (document.body){// other Explorers
		return document.body.clientWidth;
	};
	return 600;
};

function v_Purge(d){
	if(!d){return;};
	var a = d.attributes, i, l, n;
	if(a){
		l=a.length;
		for(i=0;i<l;i+=1){
			n=a[i].name;
			if(typeof d[n]==='function'){
				d[n]=null;
				try{
					delete d[n];
				}catch(e) {};
			};
		};
	};
	a=d.childNodes;
	if(a){
		while(d.lastChild){
			pit_Purge(d.lastChild);
			d.removeChild(d.lastChild);
		};
	};
	delete d;
};

function v_MergeProperties(p_xOld,p_xAdd)
{
	if(!p_xOld)
	{
		p_xOld=new Object();
	};
	if(p_xAdd)
	{
		for(i in p_xAdd)
		{
			if(p_xAdd.hasOwnProperty(i))
			{
				p_xOld[i]=p_xAdd[i];
			};
		};
	};
	return p_xOld;
};

function v_Base(p_xSubClass,p_xBaseClass,p_sTypeName) {
	function VInheritance() {}
	VInheritance.prototype=p_xBaseClass.prototype;
	p_xSubClass.prototype=new Inheritance();
	p_xSubClass.prototype.Ctor=p_xSubClass;
	p_xSubClass.prototype.m_sTypeName=p_sTypeName;
	p_xSubClass.BaseCtor=p_xBaseClass;
	p_xSubClass.Super=p_xBaseClass.prototype;
}

function v_StopE(p_xE)
{
	if(!p_xE){var p_xE=window.event;}
	if(p_xE)
	{
		p_xE.cancelBubble=true;
		if(p_xE.stopPropagation){p_xE.stopPropagation();};
		if(p_xE.preventDefault){p_xE.preventDefault();};
		p_xE.returnValue=false;
	};
};

function v_Focus(p_xE)
{
	// dummy
};

