// JavaScript Document

function show(image) 
{
	var reg = new RegExp("(_sma.)", "g");
	var bigurl = image.src.replace(reg, '_big.');	
	var e = document.getElementById('images');
	e.style.backgroundImage = "url(" + bigurl + ")";
}

function popup() {
	var e = document.getElementById('images');
	var s = e.style.backgroundImage;
	var bigurl = s.substring(4, s.length-1);
	var reg = new RegExp("(_big.)", "g");
	var giaurl = bigurl.replace(reg, '_gia.');	
	showImage(giaurl, 617, 617);
}

function showImage(url, width, height)
{
	var max_width = screen.width-100;
	var max_height = screen.height-100;
	var full_view = max_width>=width && max_height>=height;
	var win_width = full_view ? width : Math.min(width, max_width);
	var win_height = full_view ? height : Math.min(height, max_height);
	var win_top = Math.floor((screen.height - win_height - 16)/2);
	var win_left = Math.floor((screen.width - win_width)/2);
	var sb = full_view ? '' : ',scrollbars=yes';
	var wnd = window.open("", "wf2image", "width=" + win_width + ",height=" + win_height + ",left=" + win_left + ",top=" + win_top + sb );
	var doc = wnd.document;
		
	doc.open();
				
	doc.write('<html><head><title></title></head>');
	if(full_view) {
		doc.write('<body style="margin: 0; background-color: #000000; background: url('+url+') no-repeat 0 0;" onBlur="self.close()">'); 
	    doc.write(' ');
		doc.write('</body></html>');
		doc.close();
		wnd.onmouseup = function(event) {
			var e = event || window.event;
			if(e.button<2) wnd.close();
		}
	}
	else {
		doc.write('<body style="margin: 0; background-color: #000000;" onBlur="self.close()">'); 
		doc.write('<img onclick="window.close();" src="' + url + '" width="' + width + '" height="' + height + '" alt="" border="0">');
		doc.write('</body></html>');
		doc.close();
	}
	wnd.focus();
}