function dumpAssoc(obj,varname)
{
	for(prop in obj)
	{
		x = confirm(varname + "[" + prop + "] = " + obj[prop]);
		if(!x)
			break;
	}
}

function Clone(that)
{
		for(i in that)
			this[i] = that[i];
}

function typeOf(value) {
	//taken from http://javascript.crockford.com/remedial.html
    var s = typeof value;
    if (s === 'object') {
        if (value) {
            if (typeof value.length === 'number' &&
                    !(value.propertyIsEnumerable('length')) &&
                    typeof value.splice === 'function') {
                s = 'array';
            }
        } else {
            s = 'null';
        }
    }
    return s;
}

function json_encode(value)
{
	encodestring = '';
	type = typeOf(value);
	switch(type)
	{
		case 'array': encodestring += json_array(value); break;
		case 'object': encodestring += json_object(value); break;
		case 'string':	encodestring += json_string(value); break;
		case 'number': //fall through
		case 'null':
		case 'boolean': encodestring += value; break;
		case 'undefined'://do not encode the following
		case 'function':break;
	}
	return encodestring;
}

function json_string(str)
{
	//just replace newlines and carrige returns
	str = str.replace(/\n/g,'\\n');
	str = str.replace(/\r/g,'\\r');
	return '"'+ str + '"';
}

function json_object(obj)
{
	json_obj_string = '';

	for(field in obj)
		if(!typeOf(obj[field]).match('function'))
			json_obj_string += ',"' + field + '":' + json_encode(obj[field]);

	return '{' + json_obj_string.substring(1) + '}';
}

function json_array(array)
{
	json_array_string = '';

	for(var i=0; i < array.length; i++)
		json_array_string += ',' + json_encode(array[i]);

	return '[' + json_array_string.substring(1) + ']';
}

function removeAllElementNodes(node)
{

	//loop through all of the outer siblings and be cross browser safe
	var lastChild = node.lastChild;
	var currentChild = node.firstChild;
	var gonext = true;
	while(gonext)  //3 == text 8 == comment
	{
		if(currentChild === lastChild)
			gonext = false;

		if(currentChild.nodeType == 1)
			if(gonext)	//save the next before deleting current
			{
				temp = currentChild.nextSibling;
				node.removeChild(currentChild);
				currentChild = temp;
			}
			else
			{
				node.removeChild(currentChild);
			}
		else
			if(gonext)
				currentChild = currentChild.nextSibling;
	}
}

String.prototype.trim = function() 
{ 
	tmp = this.replace(/^\s+|\s+$/g, '');
	return tmp;
}