function popWindow(url, width, height, win, scrollbars) {
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	if (win == undefined) win = "_blank";
	if (scrollbars != 1) scrollbars = 0;
	newwindow = window.open(url, win, 'toolbar=0,location=0,status=0,menubar=0,scrollbars=' + scrollbars + ',resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
	if (window.focus) newwindow.focus();
}
function openWindow(url, win){
	if (win == undefined) win = "_blank";
	newwindow = window.open(url, win);
	if (window.focus) newwindow.focus();
}
function popIcon(image){
	//alert("icon download: "+image);
	popWindow("content/icon.html", 510, 220, "gallery", 0);
}
function popWallpaper(image){
	//alert("wallpaper download: "+image);
	//popWindow("content/wallpapers.html?image=" + image, screen.width, screen.height, "wallpaper", 1);
	popWindow("content/wallpapers.html?image=" + image, 800, 600, "wallpaper", 1);
}

function popHint(file){
 popWindow("content/hint.html?file="+file, 510, 220, "hint", 0);
}

function getURLVar(param) {
	var q = document.location.search || document.location.hash;
	if(q) {
		var pairs = q.substring(1).split("&");
		for (var i=0; i < pairs.length; i++) {
			if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
				return pairs[i].substring((pairs[i].indexOf("=")+1));
			}
		}
	}
	return "";
}

function params(qp) { 
	try{r=unescape(location.search.match(new RegExp(qp+"=+([^&]*)"))[1]);}
	catch(e){r='';} 
	return r; 
}
