
				// equivalent of PHP function "var_dump" (copied from phpjs.org); used for debugging
	function varDump(variable, maxDeep) {
		var deep = 0;
		var maxDeep = maxDeep || 5;

		function fetch(object, parent) {
			var buffer = '';
			deep++;

			for (var i in object) {
				if (parent) {
					objectPath = parent + '.' + i;
				} else {
					objectPath = i;
				}

				buffer += objectPath + ' (' + typeof object[i] + ')';

				if (typeof object[i] == 'object') {
					buffer += "\n";
					if (deep < maxDeep) {
						buffer += fetch(object[i], objectPath);
					}
				} else if (typeof object[i] == 'function') {
					buffer += "\n";
				} else if (typeof object[i] == 'string') {
					buffer += ': "' + object[i] + "\"\n";
				} else {
					buffer += ': ' + object[i] + "\n";
				}
			}

			deep--;
			return buffer;
		}

		if (typeof variable == 'object') {
			return fetch(variable);
		}

		return '(' + typeof variable + '): ' + variable + "\n";
	}
				// shorthand way to view (in an alert) the 1st level of var_dump on an element; used for debugging
	function dbvd( item ) {
		alert ( varDump ( item, 1 ) );
	}
				// shorthand way to view (in an alert) the 1st level of var_dump on an element; used for debugging
	function dbvd2( item ) {
		alert ( varDump ( item, 2 ) );
	}

	function quack( text ){
		alert ( 'Quack!\n\n' + text );
	}

function str_replace(search, replace, subject, count) {
	// Replaces all occurrences of search in haystack with replace  
	// 
	// version: 905.1721
	// discuss at: http://phpjs.org/functions/str_replace
	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: Gabriel Paderni
	// +   improved by: Philip Peterson
	// +   improved by: Simon Willison (http://simonwillison.net)
	// +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
	// +   bugfixed by: Anton Ongson
	// +      input by: Onno Marsman
	// +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +    tweaked by: Onno Marsman
	// +      input by: Brett Zamir (http://brettz9.blogspot.com)
	// +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   input by: Oleg Eremeev
	// +   improved by: Brett Zamir (http://brettz9.blogspot.com)
	// +   bugfixed by: Oleg Eremeev
	// %          note 1: The count parameter must be passed as a string in order
	// %          note 1:  to find a global variable in which the result will be given
	// *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
	// *     returns 1: 'Kevin.van.Zonneveld'
	// *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
	// *     returns 2: 'hemmo, mars'
	var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
			f = [].concat(search),
			r = [].concat(replace),
			s = subject,
			ra = r instanceof Array, sa = s instanceof Array;
	s = [].concat(s);
	if (count) {
		this.window[count] = 0;
	}

	for (i=0, sl=s.length; i < sl; i++) {
		if (s[i] === '') {
			continue;
		}
		for (j=0, fl=f.length; j < fl; j++) {
			temp = s[i]+'';
			repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
			s[i] = (temp).split(f[j]).join(repl);
			if (count && s[i] !== temp) {
				this.window[count] += (temp.length-s[i].length)/f[j].length;}
		}
	}
	return sa ? s : s[0];
}

function substr_count( haystack, needle, offset, length ) {
	// Returns the number of times a substring occurs in the string  
	// 
	// version: 810.1317
	// discuss at: http://phpjs.org/functions/substr_count
	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   bugfixed by: Onno Marsman
	// *    example 1: substr_count('Kevin van Zonneveld', 'e');
	// *    returns 1: 3
	// *     example 2: substr_count('Kevin van Zonneveld', 'K', 1);
	// *     returns 2: 0
	// *     example 3: substr_count('Kevin van Zonneveld', 'Z', 0, 10);
	// *     returns 3: false
	var pos = 0, cnt = 0;

	haystack += '';
	needle += '';
	if(isNaN(offset)) offset = 0;
	if(isNaN(length)) length = 0;
	offset--;

	while( (offset = haystack.indexOf(needle, offset+1)) != -1 ){
		if(length > 0 && (offset+needle.length) > length){
			return false;
		} else{
			cnt++;
		}
	}
	return cnt;
}
function explode (delimiter, string, limit) {
    // Splits a string on string separator and return array of components. If limit is positive only limit number of components is returned. If limit is negative all components except the last abs(limit) are returned.  
    // 
    // version: 1009.2513
    // discuss at: http://phpjs.org/functions/explode
    // +     original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: kenneth
    // +     improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: d3x
    // +     bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: explode(' ', 'Kevin van Zonneveld');
    // *     returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
    // *     example 2: explode('=', 'a=bc=d', 2);
    // *     returns 2: ['a', 'bc=d']
 
    var emptyArray = { 0: '' };
    
    // third argument is not required
    if ( arguments.length < 2 ||
        typeof arguments[0] == 'undefined' ||
        typeof arguments[1] == 'undefined' ) {
        return null;
    }
 
    if ( delimiter === '' ||
        delimiter === false ||
        delimiter === null ) {
        return false;
    }
 
    if ( typeof delimiter == 'function' ||
        typeof delimiter == 'object' ||
        typeof string == 'function' ||
        typeof string == 'object' ) {
        return emptyArray;
    }
 
    if ( delimiter === true ) {
        delimiter = '1';
    }
    
    if (!limit) {
        return string.toString().split(delimiter.toString());
    } else {
        // support for limit argument
        var splitted = string.toString().split(delimiter.toString());
        var partA = splitted.splice(0, limit - 1);
        var partB = splitted.join(delimiter.toString());
        partA.push(partB);
        return partA;
    }
}

function implode (glue, pieces) {
    // Joins array elements placing glue string between items and return one string  
    // 
    // version: 1009.2513
    // discuss at: http://phpjs.org/functions/implode
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Waldo Malqui Silva
    // +   improved by: Itsacon (http://www.itsacon.net/)
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: implode(' ', ['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: 'Kevin van Zonneveld'
    // *     example 2: implode(' ', {first:'Kevin', last: 'van Zonneveld'});
    // *     returns 2: 'Kevin van Zonneveld'
    var i = '', retVal='', tGlue='';
    if (arguments.length === 1) {
        pieces = glue;
        glue = '';
    }
    if (typeof(pieces) === 'object') {
        if (pieces instanceof Array) {
            return pieces.join(glue);
        }
        else {
            for (i in pieces) {
                retVal += tGlue + pieces[i];
                tGlue = glue;
            }
            return retVal;
        }
    }
    else {
        return pieces;
    }
}
