function popWindow(url, width, height, win, scrollbars, track_code) {
	track(track_code);
	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, track_code){
	track(track_code);
	if (win == undefined) win = "_blank";
	newwindow = window.open(url, win);
	if (window.focus) newwindow.focus();
}
function popGallery(image, track_code){
	popWindow("content/gallery.html?image=" + image, 800, 600, "gallery", 0, track_code);
}
function popWallpaper(image, track_code){
	popWindow("content/wallpapers.html?image=" + image, screen.width, screen.height, "wallpaper", 1, track_code);
}

function track(track_string){
	if (track_string != undefined && track_string != ""){
		var track_array = track_string.split(";");
		if (track_array[0] == "") track_array.shift();
		if (track_array[track_array.length - 1] == "") track_array.pop();
		PSTrackPage( track_array[0] , track_array[1] );
	}
}


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 "";
}