function showPreview(imgPath, orientation) {
	
	var oBlock=document.getElementById('block');
	var oPreview_win=document.getElementById('preview_win');
	var oImg=document.getElementById('previewImg');

	oImg.className=orientation;
	oImg.src=imgPath;

	var winSize=getWindowSize();
	var scrollXY=getScrollXY();
	
	oPreview_win.style.top=scrollXY.scrollY+"px";
	oPreview_win.style.left=scrollXY.scrollX+"px";
	oPreview_win.style.height=winSize.height+"px";
	oPreview_win.style.width=winSize.width+"px";
	
	oBlock.style.top=scrollXY.scrollY+"px";
	oBlock.style.left=scrollXY.scrollX+"px";
	oBlock.style.height=winSize.height+"px";
	oBlock.style.width=winSize.width+"px";

	repostionClose(oPreview_win);
	repostionFrame(oPreview_win);

	oBlock.className="showBlock";
	oPreview_win.className="showPreview_win";
}

function hidePreview() {
	var oPreview_win=document.getElementById('preview_win');
	var oBlock=document.getElementById('block');

	oBlock.className="hideBlock";
	oPreview_win.className="hidePreview_win";
	
	document.getElementById('previewImg').className="";
	document.getElementById('previewImg').src="";
}

window.onscroll=function() {
	var oBlock=document.getElementById('block');
	var oPreview_win=document.getElementById('preview_win');
	var scrollXY=getScrollXY();
	
	if (oBlock.className=="showBlock") {
		oBlock.style.top=scrollXY.scrollY+"px";
		oBlock.style.left=scrollXY.scrollX+"px";
	}
	
	if (oPreview_win.className=="showPreview_win") {
		oPreview_win.style.top=scrollXY.scrollY+"px";
		oPreview_win.style.left=scrollXY.scrollX+"px";
	}
};

window.onresize=function() {
	var oBlock=document.getElementById('block');
	var oPreview_win=document.getElementById('preview_win');
	var winSize=getWindowSize();
	//var scrollXY=getScrollXY();

	//oPreview_win.style.top=scrollXY.scrollY+"px";
	oPreview_win.style.height=winSize.height+"px";
	oPreview_win.style.width=winSize.width+"px";
	
	//oBlock.style.top=scrollXY.scrollX+"px";
	oBlock.style.height=winSize.height+"px";
	oBlock.style.width=winSize.width+"px";
	
	repostionClose(oPreview_win);
	repostionFrame(oPreview_win);
};

function repostionClose(obj) {

	var w=parseInt(obj.style.width)-75;

	var oClose=document.getElementById("close");
	oClose.style.left=w+"px";
	oClose.style.top="10px";
}

function repostionFrame(obj) {
	//var oFrame=document.getElementById("img");
	var oFrame=document.getElementById('preview');
	var w=parseInt(obj.style.width);
	var h=parseInt(obj.style.height);
	
	if (w>350) 
		oFrame.style.left=w/2-175+"px";
	else
		oFrame.style.left="0px";

	if (h>300)
		oFrame.style.top=h/2-175+"px";
	else
		oFrame.style.top="0px";
}