
function imgViewInit(){
	var img = document.getElementsByTagName("IMG");
	for (var i=0;i<img.length;i++){
		if (img[i].className == "ip"){
			img[i].onclick = imgPopup;
		}
	}
}

var imgWin = null;

function imgPopup(e){
	imgClose();
	var url = '/cat_images/'+this.src.substring(this.src.lastIndexOf('/')+1, (this.src.lastIndexOf('t.') < 0 ? this.src.lastIndexOf('.') : this.src.lastIndexOf('t.')))+this.src.substring(this.src.lastIndexOf('.'));
	var width = parseInt(this.getAttribute("imgW"),10);
	var height = parseInt(this.getAttribute("imgH"),10);

	imgWin = window.open('/imgview.htm#'+url, 'picviewer', 'scrollbars=false');
	if (imgWin) imgWin.focus();
}


function imgClose(){
	if (imgWin) {
		imgWin.close();
		imgWin = null;
	}
}

function imgViewLoad(){
	document.getElementById("close").onclick = imgViewClose;
	var img = document.getElementById("imgd");
	img.onload = imgResize;
	img.src = window.location.href.substr(window.location.href.lastIndexOf('#')+1);
}

function imgResize(){
	var tb = document.getElementById("st");
	window.resizeTo(tb.offsetWidth+25, tb.offsetHeight+110);
}

function imgViewClose(){
	window.close();
}
