var img=null;
var image=null;
var idiv=null;

function whenLoaded() {
	idiv.style.cssText='';
	img.src=this.src;
	img.width=800;
	img.height=600;
}

function showPreview(self) {
	if (document.getElementById('dialog')) {
		var div = document.getElementById('dialog').parentNode;
		div.parentNode.removeChild(div);
	}
	var body = document.getElementsByTagName('body').item(0);
	var div = document.createElement('div');
	div.id = 'dialog';
	
	var href=self.href;
	var src=self.firstChild.src;
	idiv = document.createElement('div');
	idiv.style.cssText='padding: '+((600-32)/2)+'px '+((800-32)/2)+'px';
	var a = document.createElement('a');
	a.href=href;
	a.target='_blank';
	a.onclick = function() {
		$('#dialog').dialog('close');
	}
	img = document.createElement('img');
	img.width=32;
	img.height=32;
//	img.src=src.replace(/.?\.jpg/, 's.jpg');
//	img.src=src.replace('_color', '');
	img.src='/images/loading.gif';
	image=new Image();
	image.onload=whenLoaded;
	image.src=src.replace('_color', '');
	a.appendChild(img);
	idiv.appendChild(a);
	div.appendChild(idiv);
	body.appendChild(div);
	$('#dialog').dialog(
		{
			title: href, 
			width: 800, 
			height: (($.browser.msie) && ($.browser.version=='6.0'))?0:624, 
			show: 'fold', 
			modal: true,
			resizable: false,
			draggable: false 
		}
	);
	return false;
}
