// Custom js functions

// Remove element from array
Array.prototype.remove = function (element)
{
	var result = false;
	var array = [];
	for (var i = 0; i < this.length; i++) {
		if (this[i] == element) {
			result = true;
		} else {
			array.push(this[i]);
		}
	}
	this.length = 0;
	for ( i = 0; i < array.length; i++) {
		this.push(array[i]);
	}
	array = null;
	return result;
};

Object.prototype.clone = function() {
	var newObj = (this instanceof Array) ? [] : {};
  	for (i in this) {
  		if (i == 'clone') continue;
    	if (this[i] && typeof this[i] == "object") {
      		newObj[i] = this[i].clone();
    	} 
		else {
			newObj[i] = this[i];
		}
  	}
	return newObj;
};

function $() 
{
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++)
	{
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

function makeDiv ( id, left, top, height, width, blnDisplay ){
	var tmpDiv = document.createElement( "div" );
	tmpDiv.setAttribute( "id", id );
	tmpDiv.style.position = "absolute";
	tmpDiv.style.left = left + "px";
	tmpDiv.style.top = top + "px";
	tmpDiv.style.height = height + "px";
	tmpDiv.style.width = width + "px";
	tmpDiv.style.display = blnDisplay ? "block" : "none";
	return tmpDiv;
}

function toggle( obj ){
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}
function show( obj ){
	if(typeof obj === "string"){
		obj = document.getElementById(obj);
	}
	obj.style.display = '';
}
function hide( obj ){
	if(typeof obj === "string"){
		obj = document.getElementById(obj);
	}
	obj.style.display = 'none';
}

function copyObject( obj )
{
	return obj.slice(0);
	
   	//for ( i in obj )
       //	this[ i ] = obj[ i ];
}
