function resizeWindow(w,h,force) {
	if (window.innerWidth && window.innerHeight) {
		var wdiff = window.outerWidth - window.innerWidth;
		var hdiff = window.outerHeight - window.innerHeight;
		
		var doit = false;
		if (window.innerWidth < w) {
			endw = w + wdiff;
			doit = true;
		} else {
			endw = window.outerWidth;
		}
		if (window.innerHeight < h) {
			endh = h + hdiff;
			doit = true;
		} else {
			endh = window.outerHeight;
		}
		if (force) {
			endw = w + wdiff;
			endh = h + hdiff;
		}
		
		if (doit || force) self.resizeTo(endw,endh);
	}
}

function dw(msg) {
	document.write(msg + "<br />");
}

function debug(msg) {
	var that = document.getElementById('debugDiv');
	if (that) {
		if (msg == "clear") {
			that.innerHTML = "";
		} else {
			if (that.innerHTML == "") that.innerHTML = "debug area";
			if (that.innerHTML.indexOf(msg) > -1) msg += " (dupe)";
			that.innerHTML = msg + "<br />" + that.innerHTML;
		}
	}
}

function randomNum(start,end) {
	var range = end - start + 1;
	var n = Math.floor(Math.random() * (range)) + start;
	return n.toString();
}

function toggle(which) {
	(document.getElementById(which).style.visibility == "hidden")?show(which):hide(which);
}

function show(which) {
	document.getElementById(which).style.visibility = "inherit";
}

function hide(which) {
	document.getElementById(which).style.visibility = "hidden";
}

function newImage(path) {
	var img = new Image();
	img.src = path;
	return img;
}
