/*
 * スキンサムネイル表示 JavaScript
 *
 *
 * Copyright (c) 2003 DRECOM CO.,LTD. All rights reserved.
 * 
 * info@drecom.co.jp
 * http://www.drecom.co.jp/
 */

//
// スキンのプレビューを表示するレイヤー
// 
DESIGN_PREVIEW_ID  = 'chrLayer';
gDesignPreviewLayer = null;


function getDesignPreviewLayer()
{
	if (null == gDesignPreviewLayer) {
		gDesignPreviewLayer = XBSLayer.makeLayer(DESIGN_PREVIEW_ID);
	}
	return gDesignPreviewLayer;
}
/**
 * サムネイル表示の際にサンプル画像をレイヤー表示するための関数
 * 
 * @param aFile ファイルの場所（パス）
 * @param aName スキンの名前
 * @param theEvent イベントオブジェクト
 */
function preView(aFile, aName, theEvent)
{
	var x, y;
	var lyer = getDesignPreviewLayer();
	if (theEvent == null) {
		theEvent = window.event;
	}
	x = XBSEvent.getMouseX(theEvent);
	y = XBSEvent.getMouseY(theEvent);
	
	getDesignPreviewLayer().setInnerHTML(genOutputHTML(aFile, aName));

	var preview_img = document.getElementsByName("preview_img");
	var img_width;
	
	try {
		img_width = preview_img[0].offsetWidth;
	} catch(e) {
		img_width = 250;
	}
	
	x = (x < 380) ? x + 65 : x - img_width - 100;
	y -= (y < 380) ? 70 : 150;
	
	lyer.setLeftTopPosition(x, y);
	lyer.setVisible(true);
}

function closepreView()
{
	getDesignPreviewLayer().setVisible(false);
}


function genOutputHTML(designFile, designname)
{
	var str = '';

	str+='<TABLE border="1" cellspacing="0" cellpadding="10" width="150">';
	str+='\n'+'<TR><TD bgcolor="#ffffff" align="center">'+'\n';
	str+='<FONT size="2" class="title12px">'+designname+'</FONT><BR>'+'\n';
	str+='<IMG name="preview_img" src="'+designFile+'" alt="now loading..."><BR>'+'\n';
	str+='</TD></TR></TABLE>'+'\n';

	return str;
}

