/**
* @package 'Route Groups for Google Maps'
* This file is explicitly in the public domain.
*/

	// MTSUtil namespace
	var MTSUtil = {};

	MTSUtil.extend = function(subClass, baseClass) {
	   function inheritance() {}
	   inheritance.prototype = baseClass.prototype;
	
	   subClass.prototype = new inheritance();
	   subClass.prototype.constructor = subClass;
	   subClass.baseConstructor = baseClass;
	   subClass.superClass = baseClass.prototype;
	}

	MTSUtil.CallDelayed = function(object, method, parameters) {
		var dcObj = object;
        var dcMethod = method;
		var dcParams = parameters;

		function dcCallback(){
			dcMethod.call(dcObj, dcParams);
    	}

		var dcTimer = setTimeout(dcCallback, 1000);
	}

	MTSUtil.KeyModMonitor = {
		shiftKey : false,
		ctrlKey : false,
		altKey : false,
		okdh : null,
		okuh : null,
		monitorON : function() {
			if (this.okdh == null) {
				this.okdh = document.onkeydown;
				this.okuh = document.onkeyup;
				document.onkeydown = this.kdh;
				document.onkeyup = this.kuh;
			}
		},
		kh  : function(e) {
				if (!e) var e = window.event;
				var kmm = MTSUtil.KeyModMonitor;
				kmm.shiftKey = kmm.ctrlKey = kmm.altKey = false;
				if (e.shiftKey) kmm.shiftKey = true;
				if (e.ctrlKey) kmm.ctrlKey = true;
				if (e.altKey) kmm.altKey = true;
			},
		kdh : function(e) {
				MTSUtil.KeyModMonitor.kh(e);
				if (MTSUtil.KeyModMonitor.okdh) MTSUtil.KeyModMonitor.okdh.call(e);
			},
		kuh : function(e) {
				MTSUtil.KeyModMonitor.kh(e);
				if (MTSUtil.KeyModMonitor.okuh) MTSUtil.KeyModMonitor.okuh.call(e);
			}
	}
	
	
	MTSUtil.dump = function(arr,level) {
		var dumped_text = "";
		if(!level) level = 0;
		
		//The padding given at the beginning of the line.
		var level_padding = "";
		for(var j=0;j<level+1;j++) level_padding += "    ";
		
		if(typeof(arr) == 'object') { //Array/Hashes/Objects 
			for(var item in arr) {
				var value = arr[item];
				
				if(typeof(value) == 'object') { //If it is an array,
					dumped_text += level_padding + "'" + item + "' ...\n";
					dumped_text += MTSUtil.dump(value,level+1);
				} else if (typeof(value) == 'function') {
					dumped_text += level_padding + "'" + item + "' => \"" + "(func)" + "\"\n";
				} else {
					//dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
					dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
				}
			}
		} else if (typeof(arr) == 'function') {
			dumped_text = "(func)";    
		} else { //Stings/Chars/Numbers etc.
			dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
		}
		return dumped_text;
	}

