/*
 * ActivexCtrl.js
 *
 * Copyright (c) Sangah Management Consulting / Solution SI Team. Since 2006
 * All rights reserved by SAPP (Struts Architectures' Progressive Package) Solution.
 * All source codes are ONLY for "SAPP Solution".
 *
 * Created by mornya, 2007.01
 * Modified by mornya, 2008.03.03 (refactoring)
 */

ActiveX = function() {}

/*
 * ActiveX.Flash : Initialize Flash object
 *   movie	- swf name
 *   id		- id
 *   width	- width
 *   height	- height
 */
ActiveX.prototype.Flash = function (pathSwf, id, width, height)
{
	document.write(
		"<OBJECT id='"+id+"' classId='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codeBase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,16,0' width='"+width+"' height='"+height+"'>" +
		"<PARAM name='allowScriptAccess' value='always'>" +
		"<PARAM name='movie' value='"+pathSwf+"'>" +
		"<PARAM name='quality' value='high'>" +
		"<PARAM name='wmode' value='transparent'>" +
		"<EMBED src='"+pathSwf+"' quality='high' wmode='transparent' allowScriptAccess='always' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+width+"' height='"+height+"'></embed>" +
		"</OBJECT>"
	);
}

/*
 * ActiveX.Grid : Initialize VSFlexGrid object
 *   id		- grid id
 *   width	- width
 *   height	- height
 */
ActiveX.prototype.Grid = function (id, width, height)    
{
	if (width == null) width = "100%";
	if (height == null) height = "100%";
	document.write(
		"<OBJECT id='"+id+"' classId='clsid:C945E31A-102E-4a0d-8854-D599D7AED5FA' width="+width+" height="+height+" style='border:0px solid transparent; left:0px; top:0px;'>" +
		"<PARAM name='Rows' value='1'>" +
		"<PARAM name='Cols' value='1'>" +
		"<PARAM name='FontName' value='굴림'>" +
		"<PARAM name='FontSize' value='9'>" +
		"<PARAM name='BorderStyle' value='0'>" + // Borderless
		"</OBJECT>"
	);
}

/*
 * ActiveX.Chart : Initialize ComponentOne Chart object
 *   id		- chart id
 *   width	- width
 *   height	- height
 */
ActiveX.prototype.Chart = function (id, width, height)
{
	if (width == null) width = "100%";
	if (height == null) height = "100%";
	document.write("<OBJECT id='"+id+"' classId='CLSID:58A968A5-E3CE-4743-9CE4-A27357009527' width='"+width+"' height='"+height+"'></OBJECT>");
}

/*
 * ActiveX.Chart3D : Initialize ComponentOne Chart 3D object
 *   id		- chart id
 *   width	- width
 *   height	- height
 */
ActiveX.prototype.Chart3D = function (id, width, height)
{
	if (width == null) width = "100%";
	if (height == null) height = "100%";
	document.write("<OBJECT id='"+id+"' classId='CLSID:BBFE3130-FC0E-40DA-B4E0-26C07D7D9B05' width='"+width+"' height='"+height+"'></OBJECT>");
}

/*
 * ActiveX.ezView : Initialize Sangah ezView object
 *   id		- object id
 *   width	- width
 *   height	- height
 */
ActiveX.prototype.ezView = function (id, width, height)
{
	if (width == null) width = "100%";
	if (height == null) height = "100%";
	document.write("<OBJECT id='"+id+"' name='"+id+"' classId='clsid:E462FEBB-9DC8-47E7-8298-F9D2E3A5CAAF' width='"+width+"' height='"+height+"'></OBJECT>");
}

/*
 * ActiveX.ImageConvert : Initialize thumbnail image generator
 *   width	- width
 *   height	- height
 */
ActiveX.prototype.ImageConvert = function (width, height)
{
	if (width == null) width = "0";
	if (height == null) height = "0";
	document.write("<OBJECT id='convert' classId='clsid:4D68352C-0948-47BC-A0A6-38B4E673E5AB' width='"+width+"' height='"+height+"'></OBJECT>");
}

/*
 * ActiveX.DwgConvert : Initialize DWG file format converter
 */
ActiveX.prototype.DwgConvert = function ()
{
	document.write("<OBJECT id='dwg' name='dwg' classId='clsid:BF922F52-DA10-4C0A-AE00-4142DF5E426D' width='0' height='0'></OBJECT>");
}

/*
 * ActiveX.DwfViewer : Initialize View DWF file format
 */
ActiveX.prototype.DwfViewer = function ()
{
	document.write("<OBJECT id='viewer' classId='clsid:5F2238BF-5216-4C6E-8316-E817D674DD6C' width='0' height='0'>");
	document.write("<PARAM name='title' value='viewer'>");
	document.write("<PARAM name='width' value='900'>");
	document.write("<PARAM name='height' value='700'>");
	document.write("<PARAM name='posx' value='50'>");
	document.write("<PARAM name='posy' value='30'>");
	document.write("</OBJECT>");
}

/*
 * ActiveX.STransUpload : Initialize STrans Upload object
 *   width	- width
 *   height	- height
 *   n		- max count
 *   m		- max size
 *   s		- file open type
 *   sp		- server save path
 *   sIp	- server ip
 *   sPort	- server port
 */
ActiveX.prototype.STransUpload = function (width, height, n, m, s, sp, sIp, sPort)
{
	document.write(
		"<OBJECT id='upload' classId='clsid:2FFF2F4D-F92E-4BB6-8021-C3C3CDCFE73A' width='"+width+"' height='"+height+"'>" +
		"<PARAM name='nWidth' value='"+width+"'>" +
		"<PARAM name='nHeight' value='"+height+"'>" +
		"<PARAM name='nColorR' value='-1'>" +
		"<PARAM name='nColorG' value='100'>" +
		"<PARAM name='nColorB' value='135'>" +
		"<PARAM name='nMaxCount' value='"+n+"'>" +
		"<PARAM name='nMaxSize' value='"+m+"'>" +
		"<PARAM name='nTransOption' value='1'>" +
		"<PARAM name='nViewType' value='1'>" +
		"<PARAM name='nTransDlg' value='0'>" +
		"<PARAM name='nTransType' value='1'>" +
		"<PARAM name='nFileTree' value='1'>" +
		"<PARAM name='sSearch' value='"+s+"'>" +
		"<PARAM name='sSavePath' value='"+sp+"'>" +
		"<PARAM name='sIp' value='"+sIp+"'>" +
		"<PARAM name='nPort' value='"+sPort+"'>" +
		"</OBJECT>"
	);
}

/*
 * ActiveX.STransDownload : Initialize STrans Download object
 *   width	- width
 *   height	- height
 *   sIp	- server ip
 *   sPort	- server port
 *   sP		- authorization (removable 1:no, 2:yes)
 */
ActiveX.prototype.STransDownload = function (width, height, sIp, sPort, sP)
{
	document.write(
		"<OBJECT id='download' classId='clsid:D55D98E8-CEC5-404C-B5F4-57BEBB4C06C2' width='"+width+"' height='"+height+"'>" +
		"<PARAM name='nWidth' value='"+width+"'>" +
		"<PARAM name='nHeight' value='"+height+"'>" +
		"<PARAM name='nColorR' value='-1'>" +
		"<PARAM name='nColorG' value='100'>" +
		"<PARAM name='nColorB' value='135'>" +
		"<PARAM name='nViewType' value='1'>" +
		"<PARAM name='nTransDlg' value='0'>" +
		"<PARAM name='nTransType' value='1'>" +
		"<PARAM name='nFileTree' value='1'>" +
		"<PARAM name='sIp' value='"+sIp+"'>" +
		"<PARAM name='nPort' value='"+sPort+"'> " +
		"<PARAM name='nAcl' value='"+sP+"'>" +
		"</OBJECT>"
	);
}

/*
 * ActiveX.STransDownloadFBS : Initialize STrans Download object -  Client Local HardDrive
 *   width	- width
 *   height	- height
 *   sIp	- server ip
 *   sPort	- server port
 *   sP		- authorization (removable 1:no, 2:yes)
 */
ActiveX.prototype.STransDownloadFBS = function (width, height, sIp, sPort, sP)
{
	document.write(
		"<OBJECT ID='download' classId='clsid:D55D98E8-CEC5-404C-B5F4-57BEBB4C06C2' width='"+width+"' height='"+height+"'>" +
		"<param name='nWidth' value='"+width+"'>" +
		"<param name='nHeight' value='"+height+"'>" +
		"<param name='nColorR' value='-1'>" +
		"<param name='nColorG' value='100'>" +
		"<param name='nColorB' value='135'>" +
		"<param name='nViewType' value='1'>" +
		"<param name='nTransDlg' value='1'>" +
		"<param name='nTransType' value='1'>" +
		"<param name='nFileTree' value='1'>" +
		"<param name='sIp' value='"+sIp+"'>" +
		"<param name='nPort' value='"+sPort+"'> " +
		"<param name='nAcl' value='"+sP+"'>" +
		"</OBJECT>"
	);
}


/*
 * ActiveX.Hwp : Initialize Hangul Wordprocessor object
 *   id		- object id
 *   option	- options (ex. ALL/DEFAULT/CUSTOM)
 *   flags	- flags if option is CUSTOM (ex. "MENU,TABLE,IMAGE" -> TOOLBAR_MENU=true, TOOLBAR_TABLE=true, TOOLBAR_IMAGE=true)
 */
ActiveX.prototype.Hwp = function (id, option, flags)
{
	var arrOrder = [];
	arrOrder["MENU"] = "FALSE";
	arrOrder["STANDARD"] = "FALSE";
	arrOrder["FORMAT"] = "FALSE";
	arrOrder["DRAW"] = "FALSE";
	arrOrder["TABLE"] = "FALSE";
	arrOrder["IMAGE"] = "FALSE";
	arrOrder["HEADERFOOTER"] = "FALSE";
	arrOrder["SHOW"] = "FALSE";

	var arrFlags = [];

	switch (option) {
		case "ALL":
			arrOrder["MENU"] = "TRUE";
			arrOrder["STANDARD"] = "TRUE";
			arrOrder["FORMAT"] = "TRUE";
			arrOrder["DRAW"] = "TRUE";
			arrOrder["TABLE"] = "TRUE";
			arrOrder["IMAGE"] = "TRUE";
			arrOrder["HEADERFOOTER"] = "TRUE";
			arrOrder["SHOW"] = "TRUE";
			break;
		case "DEFAULT":
			// except TABLE,IMAGE,HEADERFOOTER
			arrOrder["MENU"] = "TRUE";
			arrOrder["STANDARD"] = "TRUE";
			arrOrder["FORMAT"] = "TRUE";
			arrOrder["DRAW"] = "TRUE";
			arrOrder["SHOW"] = "TRUE";
			break;
		case "DOCUMENT":
			// only STANDARD,SHOW
			arrOrder["STANDARD"] = "TRUE";
			arrOrder["SHOW"] = "TRUE";
			break;
		case "CUSTOM":
			arrFlags = flags.toUpperCase().split(",");
			for (var i=0; i<arrFlags.length; i++) arrOrder[arrFlags[i]] = "TRUE";
			break;
	}

	document.write(
		"<OBJECT id='"+id+"' style='LEFT: 0px; TOP: 0px' width='100%' height='100%' classId='CLSID:BD9C32DE-3155-4691-8972-097D53B10052'>" +
    	"<PARAM name='TOOLBAR_MENU'			value='" + arrOrder["MENU"] + "'>" +
    	"<PARAM name='TOOLBAR_STANDARD'		value='" + arrOrder["STANDARD"] + "'>" +
    	"<PARAM name='TOOLBAR_FORMAT'		value='" + arrOrder["FORMAT"] + "'>" +
    	"<PARAM name='TOOLBAR_DRAW'			value='" + arrOrder["DRAW"] + "'>" +
    	"<PARAM name='TOOLBAR_TABLE'		value='" + arrOrder["TABLE"] + "'>" +
    	"<PARAM name='TOOLBAR_IMAGE'		value='" + arrOrder["IMAGE"] + "'>" +
    	"<PARAM name='TOOLBAR_HEADERFOOTER'	value='" + arrOrder["HEADERFOOTER"] + "'>" +
    	"<PARAM name='SHOW_TOOLBAR'			value='" + arrOrder["SHOW"] + "'>" +
    	"<PARAM name='CursorType'			value='0'>" +
    	"<PARAM name='Device'				value='4'>" +
    	"</OBJECT>"
    );
}

/*
 * ActiveX.STree : Initialize Tree object
 *   id				- tree id
 *   width			- width
 *   height			- height
 *   colorR			- background RGB color red tone
 *   colorG			- background RGB color green tone
 *   colorB			- background RGB color blue tone
 *   singleSelect	- single select mode (0:disable, 1:active)
 *   rootLine		- root line mode (0:disable, 1:active)
 *   fontDisable	- font change menu (0:disable, 1:active)
 *   border			- border
 */
ActiveX.prototype.STree = function (id, width, height, colorR, colorG, colorB, singleSelect, rootLine, fontDisable, border)
{
	if (colorR == undefined) colorR = 255;
	if (colorG == undefined) colorG = 255;
	if (colorB == undefined) colorB = 255;
	if (fontDisable == undefined) fontDisable = 1;
	if (border == undefined) border = 0;
	if (singleSelect == undefined) singleSelect = 0;
	if (rootLine == undefined) rootLine = 1;

	document.write(
		"<OBJECT id='"+id+"' name='"+id+"' classId='clsid:8BBD9C1C-3BD2-4DD3-B639-A0D67088FA74' width='"+width+"' height='"+height+"'>" +
		"<PARAM name='colorR' value='"+colorR+"'>" +
		"<PARAM name='colorG' value='"+colorG+"'>" +
		"<PARAM name='colorB' value='"+colorB+"'>" +
		"<PARAM name='singleSelect' value='"+singleSelect+"'>" +
		"<PARAM name='rootLine' value='"+rootLine+"'>" +
		"<PARAM name='fontDisable' value='"+fontDisable+"'>" +
		"<PARAM name='border' value='"+border+"'>" +
		"</OBJECT>"
	);
}

/*
 * ChartInit : Initialize ComponentOne Chart object
 *   x     - width
 *   y     - height
 *   border- border
 */
ActiveX.prototype.ChartInit = function (x, y, border)
{
	if (x == null) x = "100%";
	if (y == null) y = "100%";
	document.write("<OBJECT id='chart' classId='CLSID:58A968A5-E3CE-4743-9CE4-A27357009527' width='"+x+"' height='"+y+"'></OBJECT>");
}

/*
 * ExternalBrowser : Initialize External browser object
 *   x     - width
 *   y     - height
 *   border- border
 */
ActiveX.prototype.ExternalBrowser = function (id, url, browserPath)
{
	document.write(
		"<OBJECT id='cybrowser' classid='clsid:0D6E9576-5DFE-40C0-B571-11126B899062' width='0' height='0'>" +
		"<param name='strurl' value='"+url+"'>" +
		"<param name='strbrowserpath' value='"+browserPath+"'>" +
		"<param name='nautoclose' value='1'>" +
		"<param name='nenablemax' value='1'>" +
		"<param name='nskintype' value='0'>" +
		"<param name='nbuttonshow' value='0'>" +
		"<param name='nversion' value='2'>" +
		"<param name='nenableresize' value='0'>" +
		"<param name='nwidth' value='1024'>" +
		"<param name='nheight' value='768'>" +
		"<param name='nmaxwidth' value='1024'>" +
		"<param name='nmaxheight' value='768'>" +
		"</OBJECT>"
	);
}

