
var height = screen.height;
var width = screen.width;
var leftpos = width / 2 - 50;
var toppos = height / 2 - 50;

var name = navigator.appName;
var isIE = false;

if (name == "Microsoft Internet Explorer") {
	isIE = true;
} 

function encode(str){ // Netscape fix
	return escape(str.replace(/ /g,'+'));
}

function view(what) {
	var url = 'viewer.asp?pic='+encode(what);
	window.open(url,'WIN','scrollbars=no,status=no,toolbar=no,resizable=no,location=no,menu=no,width=150,height=100,left=' + leftpos + ',top=' + toppos);
}

function getParams() {
	var idx = document.URL.indexOf('?');
	var params = new Array();
	if (idx != -1) {
		var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
		for (var i=0; i<pairs.length; i++) {
			nameVal = pairs[i].split('=');
			params[nameVal[0]] = nameVal[1];
	   }
	}
	return params;
}

params = getParams();

function resize() {
	alert("done loading");
	if (eval(pic).height) {
		alert("eval is ok");
		if (isIE) {
			myHeight = eval(pic).height + 30;
			myWidth = eval(pic).width + 12;
		} else {
			myHeight = eval(pic).height + 9;
			myWidth = eval(pic).width;
		}

		clearTimeout();
	
		var height = screen.height;
		var width = screen.width;
		var leftpos = width / 2 - myWidth / 2;
		var toppos = height / 2 - myHeight / 2; 
	
		self.moveTo(leftpos, toppos);
		self.resizeTo(myWidth, myHeight);
		if (isIE) {			
			document.il.src = eval(pic).src;
		}
	} else { 
		setTimeOut(resize(), 100);
	}
}

