String.prototype.PSreplace = function ( pattern, replacement )
{
	var result = '', source = this, match;
	while ( source.length > 0 )
	{
		if ( match = source.match(pattern) )
		{
			result += source.slice(0,match.index);
			result += replacement( match );
			source = source.slice(match.index + match[0].length);
		}
		else
		{
			result += source;
			source = '';
		}
	}
	return result;
}

String.prototype.PSevalJSON = function ()
{
	var res = eval( '(' + this.replace(/(^\s*\/\*-secure-\s*([\s\S]*)\*\/)/,'$2').PSreplace(/((&quot;)|(&amp;quot;))|(\s*\n\s*)/,function ( match ) { return (match[1])?('"'):('<br/>'); } ) + ')' );
	return res;
}

function clone( obj )
{
    if(obj == null || typeof(obj) != 'object')
        return obj;
        
	var newObj = new Object();	
	for(var i in obj)
		newObj[i] = clone(obj[i]);

	return newObj;
}

function MultiArray( dims, n )
{
	n = n || 0;
	if ( n < dims.length )
	{
		var arr = new Array(dims[n]);
		for ( var i = arr.length-1; i>=0; i-- )
			arr[i] = MultiArray(dims, n+1 );
		return arr;
	}
	else
		return new Array();
}