Array.prototype.remove = function(item){
	var cnt = false;
	for(var i = this.length - 1; i >= 0; i--){
		if(this[i] == item) {
			this.splice(i,1);
			cnt++;
		}
	}
}

Array.prototype.indexOf = function(a){
	for(var i = 0; i < this.length; i++) if(this[i] == a) return i;
	return null;
}

Array.prototype.swap = function(a, b){
	var tmp = this[a];
	this[a] = this[b];
	this[b] = tmp;
}

Array.prototype.swapValues = function(a, b){
	ia = this.indexOf(a);
	ib = this.indexOf(b);
	var tmp = this[ia];
	this[ia] = this[ib];
	this[ib] = tmp;
}



function offsetX(obj){
	var oleft = 0;
	while(obj){
		oleft += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return oleft;
}

function offsetY(obj){
	var otop = 0;
	while(obj){
		otop += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return otop;
}


function solidscreen(opct){
	this.clickEnable = true;
	var obody = document.body;

	var odivelm = document.createElement('DIV');
	with(odivelm.style){
		position = 'absolute';
		width = obody.scrollWidth;
		height = obody.scrollHeight < obody.clientHeight ? obody.clientHeight : obody.scrollHeight;
		top = 0;
		left = 0;
	}

	var odiv = document.createElement('DIV');
	odiv.parent = this;
	with(odiv.style){
		width = obody.scrollWidth;
		height = obody.scrollHeight < obody.clientHeight ? obody.clientHeight : obody.scrollHeight;
	}

	this.clear = function(){
		try{
			this.element.elm.parentNode.removeChild(this.element.elm);
		}catch(err){}
		try{
			this.parent.hidescreen();
		}catch(err){}
	}

	odiv.onclick = function(){
		if(this.parent.clickEnable) this.parent.clear();
	}

	odivelm.appendChild(odiv);
	document.body.appendChild(odivelm);
	this.element = odiv;
	this.element.elm = odivelm;

	if(odiv.filters){
		odiv.style.background = 'url(/$files/img/_opct0.png)';
		odiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/$files/img/_opct" + (opct ? opct : '0') + ".png', sizingMethod='scale')";
	}else{
		odiv.style.background = 'url(/$files/img/_opct' + (opct ? opct : '0') + '.png)';
	}
}



function showbutton(obj){
	if(obj.odiv) return;
	var odiv = document.createElement("DIV");
	odiv.className = 'smalldowndutton';
	with(odiv.style){
		top = offsetY(obj) + (obj.offsetHeight-17) / 2 + 2;
		left = offsetX(obj) + obj.offsetWidth - 10;
	}
	document.body.appendChild(odiv);
	obj.odiv = odiv;
	obj.hidebutton = function(){
		if(!this.odiv) return;
		this.odiv.parentNode.removeChild(this.odiv);
		this.odiv = null;
	}
	obj.onmouseout = obj.hidebutton;
}