

var maxWidth = 500;
var maxHeight = 400;

function getPosXY(a, offset)
{
	var p = offset?offset.slice(0):[0,0],tn;
	
	var t = a.offsetTop; 
	var l = a.offsetLeft; 
	var w = a.offsetWidth;
	var h = a.offsetHeight;
	while(a = a.offsetParent)
	{
		l += a.offsetLeft;
		t += a.offsetTop;
	}

	p[0] += l + w;
	p[1] += t;

	return p;
}

function checkComplete()
{
	if(checkComplete.__img && checkComplete.__img.complete)
	{
		checkComplete.__onload();
	}
}

checkComplete.__onload = function()
{
	clearInterval(checkComplete.__timeId);
	var w = checkComplete.__img.width;
	var h = checkComplete.__img.height;
	if(w >= h && w > maxWidth)
	{
		previewImage.style.width = maxWidth + 'px';
	}
	else if(h >= w && h > maxHeight)
	{
		previewImage.style.height = maxHeight + 'px';
	}
	else
	{
		previewImage.style.width = previewImage.style.height = '';
	}
	previewImage.src = checkComplete.__img.src;
	previewUrl.href = checkComplete.href;
	checkComplete.__img = null;
}

function showPreview(e)
{
	hidePreview();
	previewFrom = e.target || e.srcElement;
	previewImage.src = loadingImg;
	previewImage.style.width = previewImage.style.height = '';
	previewTimeoutId = setTimeout('_showPreview()', 500);
	checkComplete.__img = null;
}

function hidePreview(e)
{
	if(e)
	{
		var toElement = e.relatedTarget || e.toElement;
		while(toElement)
		{
			if(toElement.id == 'PreviewBox')
			{
				return;
			}
			toElement = toElement.parentNode;
		}
	}
	try
	{
		clearInterval(checkComplete.__timeId);
		checkComplete.__img = null;
		previewImage.src = loadingImg;
	}
	catch(e)
	{}
	clearTimeout(previewTimeoutId);
	previewBox.style.display = 'none';
}

function _showPreview()
{
	checkComplete.__img = new Image();
	if(previewFrom.tagName.toUpperCase() == 'A')
	{
		previewFrom = previewFrom.getElementsByTagName('img')[0];
	}
	var largeSrc = previewFrom.getAttribute("big_path");
	//var picLink = previewFrom.getAttribute("pic_link");
	var picLink = '###';
	if(!largeSrc)
	{
		return;
	}
	else
	{
		checkComplete.__img.src = largeSrc;
		checkComplete.href = picLink;
		checkComplete.__timeId = setInterval("checkComplete()", 300);
		var pos = getPosXY(previewFrom, [30, 0]);
		previewBox.style.left = pos[0] + 'px';
		previewBox.style.top = pos[1] + 'px';
		previewBox.style.display = 'block';
	}
}

document.writeln('<style type="text/css">');
document.writeln('div#PreviewBox{');
document.writeln('position:absolute;');
document.writeln('padding-left:6px;');
document.writeln('display: none;');
document.writeln('Z-INDEX:2006;');
document.writeln('}');
document.writeln('div#PreviewBox span{');
document.writeln('width:7px;');
document.writeln('height:13px;');
document.writeln('position:absolute;');
document.writeln('left:0px;');
document.writeln('top:9px;');
document.writeln('background:url(/info/image/previewbox_arrow.gif) 0 0 no-repeat;');
document.writeln('}');
document.writeln('div#PreviewBox div.Picture{');
document.writeln('float:left;');
document.writeln('border:1px #666 solid;');
document.writeln('background:#FFF;');
document.writeln('}');
document.writeln('div#PreviewBox div.Picture div{');
document.writeln('border:4px #e8e8e8 solid;');
document.writeln('}');
document.writeln('div#PreviewBox div.Picture div a img{');
document.writeln('margin:19px;');
document.writeln('border:1px #b6b6b6 solid;');
document.writeln('display: block;');
document.writeln('}');
document.writeln('</style>');




document.writeln('<div id="PreviewBox" onmouseout="hidePreview(event);">');
document.writeln('	<div class="Picture" onmouseout="hidePreview(event);">');
document.writeln('		<SPAN></SPAN>');
document.writeln('		<div>');
document.writeln('			<a id="previewUrl" target="_blank"><img oncontextmenu="return(false)" id="PreviewImage" border="0" onmouseout="hidePreview(event);" /></a>');
document.writeln('		</div>');
document.writeln('	</div>');
document.writeln('</div>');

document.writeln('<script language="javascript" type="text/javascript">');
document.writeln('var previewBox = document.getElementById("PreviewBox");');
document.writeln('var previewImage = document.getElementById("PreviewImage");');
document.writeln('var previewUrl = document.getElementById("previewUrl");');
document.writeln('var previewFrom = null;');
document.writeln('var previewTimeoutId = null;');
document.writeln('var loadingImg = "/info/image/previewbox_loading.gif";');
document.writeln('</script>');

