/**
 * WebHtmlEtc JS 클래스 리스트
 * WebFlashAtom
 * WebHtmlModelAtom
 * WebHtmlTagQuickLinkAtom
 * WebHyperDataLinkAtom
 * WebIFrameAtom
 * WebModelAtom
 * WebSchedulerAtom
 *
 */

/**
 * 웹플래시 아톰
 */
function WebFlashAtom (strVarName, strFilePath, nPlayerKind, nScriptIndex, bShowControlBar)
{
	this.m_strVarName = strVarName;
	this.m_strFilePath = strFilePath;
	this.m_nPlayerKind = nPlayerKind;
	
	this.m_nScriptIndex = nScriptIndex;
	
	this.m_bShowControlBar = bShowControlBar;
	
	this.m_heAtom = document.getElementById(strVarName);
	this.m_heWebFlashObject = null;
}

/**
 * @return 아톰타입 "WebFlashAtom"
 */
WebFlashAtom.prototype.getAtomType = function ()
{
	return "WebFlashAtom";
}

WebFlashAtom.prototype.getURI = function ()
{
	return WebFlashAtom.getURI (this.m_nPlayerKind, this.m_strFilePath);
}

WebFlashAtom.prototype.getVarName = function ()
{
	return this.m_strVarName;
}

WebFlashAtom.prototype.makeRequest = function (xnRequest)
{
	var xnAtom = XmlLib.createChild(xnRequest, "WebFlashAtom");
	
	XmlLib.setTextValue (xnAtom, this.m_strFilePath);
	
	xnAtom.setAttribute("VarName", this.m_strVarName);
}

/**
 * 아톰리스트에 추가
 */
WebFlashAtom.prototype.putAtom = function ()
{
	WebFlashAtom._atoms[this.m_strVarName] = this;
}

WebFlashAtom.prototype.getScriptIndex = function ()
{
	return this.m_nScriptIndex
}

/**
 *	웹플래시 아톰 초기화
 */
WebFlashAtom.prototype.init = function ()
{
	this.m_heWebFlashObject = document.getElementById("__WEB_FLASH_ATOM_" + this.m_strVarName);
}

WebFlashAtom.prototype.handleResult = function (xnAtom)
{
	if (WebFlashAtom.PLAYERTYPE_MCC_FLOATING == this.m_nPlayerKind)
	{
		// 플레이 리스트를 얻어옵니다.
		var strPlayList = XmlLib.getAttribute(xnAtom, "PlayList");
		if ("" != strPlayList)
		{
			this.setValue(strPlayList);
		}
	}
	
	var bPathSet = XmlLib.getAttribute(xnAtom, "PathSet") == "true" ? true : false;
	var strFileName = XmlLib.getTextValue(xnAtom);
	
	// e러닝이나 presales는 url을 넘겨 재생하므로, 그냥 넘긴다.
	if (WebFlashAtom.PLAYERTYPE_MCC_FLOATING == this.m_nPlayerKind ||
		WebFlashAtom.PLAYERTYPE_MCC_DOCKING == this.m_nPlayerKind)
	{
		if (strFileName != this.m_strFilePath || bPathSet)
		{
			this.setValue(strFileName);
		}
	}
	else
	{
		if (strFileName != this.m_strFilePath)
		{
			this.setValue(strFileName);
		}
	}
}

/*
 * 현재 동작중인 영상을 정지시키고, 또 다른 영상을 재생하기 위해서
 * 종전에 있던 object Node를 삭제하고, 새로 object Node를 구성합니다.
 * 
 * bPathSet : 스크립트 동작을 통해서 경로가 설정되었는지 여부
 */
WebFlashAtom.prototype.setValue = function (strFileName)
{
	var objCurrent = document.getElementById("__WEB_FLASH_ATOM_" + this.m_strVarName);
	
	if ( WebFlashAtom.PLAYERTYPE_FLASH == this.m_nPlayerKind)
	{
		var heParentDiv = document.getElementById(this.m_strVarName);
		
		if (null != objCurrent)
		{
			objCurrent.removeNode();
		}
		
		this.m_strFilePath = strFileName;
		var strTag = WebFlashAtom.getObjectTag(this.m_strVarName, this.m_nPlayerKind, this.m_strFilePath);
		
		heParentDiv.innerHTML = strTag;
	}
	else if (WebFlashAtom.PLAYERTYPE_MP == this.m_nPlayerKind)
	{
		var heParentDiv = objCurrent.parentNode;
		
		objCurrent.controls.stop();
		
		objCurrent.style.visibility = "hidden";
		objCurrent.removeNode();
		
		var heObject = document.createElement("object");
		var heParam = document.createElement("param");	
		
		heParam.name = "url";
		
		this.m_strFilePath = strFileName;
		
		if (this.m_strFilePath)
		{
			heParam.value = this.getURI(); //URI를 얻는다.
		}
		
		heObject.appendChild(heParam);
		
		var heMode = document.createElement("param");
		heMode.name = "uiMode";
		heMode.value = this.m_bShowControlBar ? "full" : "none";
		
		heObject.appendChild(heMode);
		
		heObject.id = "__WEB_FLASH_ATOM_" + this.m_strVarName;
		heObject.classid = "clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6";
		
		heObject.style.width = "100%";
		heObject.style.height = "100%";
		
		heParentDiv.appendChild(heObject);
	}
	else
	{
		this.m_strFilePath = strFileName;
		
		if (null != objCurrent && this.m_strFilePath && 0 < this.m_strFilePath.length)
		{
			if (WebFlashAtom.PLAYERTYPE_MCC_FLOATING && (0 < this.m_strFilePath.indexOf(".xml") || 0 < this.m_strFilePath.indexOf(".XML")))
			{
				objCurrent.Playlist = this.getURI();
				return ;
			}
			
			objCurrent.URL = this.getURI(); //URI를 얻는다.
		}
	}
}

/**
 * 선택표시 (f9 기능)
 */
WebFlashAtom.prototype.vanish = function ()
{
	// TODO : 선택표시 구현
}

WebFlashAtom.prototype.getProperty = function (wNameID, arArgs, objRetVal)
{
	switch (wNameID)
	{
		case 0 : case 203 :	
			objRetVal.setValue (this.m_strFilePath);		
			return StdCore.S_OK;

		case 1 : case 286 :	
			//return get_GdiProperty (286, arArgs, objRetVal);
		
		default : 
			return StdCore.E_NOT_DEF_PROPERTY;
	}
}

WebFlashAtom.prototype.setProperty = function (wNameID, arArgs, objRetVal)
{
	switch (wNameID)
	{	
		case 0 : case 203 : 
			var strValue = objRetVal.toStringX();
			this.setValue(strValue);
			break;
		case 1 : case 286 :	
			//return this.set_GdiProperty (286, arArgs, objRetVal);
			break;
		case 2 : case 435 :	// 그룹설정
			if (WebFlashAtom.PLAYERTYPE_MCC_FLOATING == this.m_nPlayerKind)
			{
				// 플레이 리스트를 얻어옵니다.
				var strPlayList = objRetVal.toStringX();
				if ("" != strPlayList)
				{
					this.setValue(strPlayList);
				}
			}
			break;
		default : return StdCore.E_NOT_DEF_PROPERTY;
	}
	return StdCore.S_OK;
}

WebFlashAtom.prototype.action = function (nPropID, arArgs, objRetVal)
{
	switch (nPropID)
	{
		default : 
			return this.getProperty (nPropID, arArgs, objRetVal);
	}
}

WebFlashAtom.PLAYERTYPE_FLASH = 0;
WebFlashAtom.PLAYERTYPE_MP = 1;
WebFlashAtom.PLAYERTYPE_MCC_DOCKING = 2;
WebFlashAtom.PLAYERTYPE_MCC_FLOATING = 3;

/**
 * 아톰리스트
 */
WebFlashAtom._atoms = new Object();

WebFlashAtom.getAtom = function (strVarName)
{
	return WebFlashAtom._atoms[strVarName];
}

/**
 *	웹플래시 아톰 초기화
 */
WebFlashAtom.init = function ()
{
	for (var strVarName in WebFlashAtom._atoms)
	{
		WebFlashAtom._atoms[strVarName].init();
	}
}

WebFlashAtom.makeRequest = function (xnAtomRequest)
{
	for (var strVarName in WebFlashAtom._atoms)
	{
		var objAtom = WebFlashAtom._atoms[strVarName];
		
		if (null != objAtom)
		{
			objAtom.makeRequest(xnAtomRequest);
		}
	}
}

/*
 * Active x의 설치여부를 판단합니다.
 */
WebFlashAtom.checkActiveX = function ()
{
	try
	{
		var objPlayer = new ActiveXObject("MEDIACOMPONENT.MediaComponentCtrl.1");
			
		if (objPlayer)
		{
			return true;
		}
	}
		
	catch (e) 
	{
		return false;
	}
	
	return false;
}

WebFlashAtom.getURI = function (nPlayerKind, strFilePath)
{
	var strURL = g_strServerURL;
	
	// 스크립트 '.그룹설정' 을 통해서 .xml 파일이 왔을 경우
	if ( (WebFlashAtom.PLAYERTYPE_MCC_FLOATING == nPlayerKind) &&
		 (-1 < strFilePath.indexOf(".xml") || -1 < strFilePath.indexOf(".XML")))
	{
		// 절대 경로
		if (0 == strFilePath.indexOf("http://"))
		{
			return strFilePath;	// 그대로의 주소를 넘김.
		}
		// @PATH 포함된 주소.
		else
		{
			return strURL + GetProjectName() + "/" + Utils.removePQPath(Utils.getPathString(strFilePath));	
		}
	}
		
	//http->mms
	if (WebFlashAtom.PLAYERTYPE_MCC_DOCKING == nPlayerKind ||
		WebFlashAtom.PLAYERTYPE_MCC_FLOATING == nPlayerKind)
	{
		strURL = strURL.replace("http://", "mms://");
		return strURL + GetProjectName() + "/" + Utils.removePQPath(Utils.getPathString(strFilePath));	
	}
	
	if (0 == strFilePath.indexOf("http://"))
	{
		return strFilePath;
	}
	
	return g_strServerURL + GetProjectName() + "/" + Utils.removePQPath(Utils.getPathString(strFilePath));
}

/**
 * 미디어 아톰의 Object 태그를 생성한다.
 * 미디어 아톰의 종류별로 <Object> 태그와 classID를 설정하여서 태그 생성
 * 미디어 경로 값이 있을 경우에는 바로 설정해서, 파일 다운로드가 바로 시작되도록 한다.  
 */
WebFlashAtom.makeObject = function (strVarName, nPlayerKind, strFilePath, bShowControlBar)
{
	var strTag = WebFlashAtom.getObjectTag(strVarName, nPlayerKind, strFilePath, bShowControlBar);
	
	if (null != strTag)
	{
		document.write(strTag);
	}
}

WebFlashAtom.getObjectTag = function (strVarName, nPlayerKind, strFilePath, bShowControlBar)
{
	var objAttrs = new Object();
	var objParams = new Object();
	var objEmbedAttr = new Object();
	
	objAttrs["id"] = "__WEB_FLASH_ATOM_" + strVarName;
	
	var strStyle = "width: 100%; height: 100%;"
	if (WebFlashAtom.PLAYERTYPE_MCC_FLOATING == nPlayerKind)
	{
		strStyle += " visibility:hidden;"
	}
	objAttrs["style"] = strStyle;
	objEmbedAttr["style"] = strStyle;
	
	if (WebFlashAtom.PLAYERTYPE_FLASH == nPlayerKind)
	{
		if (0 == strFilePath.length)
		{
			// 플래쉬 주소가 없는 경우에는 태그를 생성하지 않는다.
			return null;
		}
		
		var strUri = WebFlashAtom.getURI(nPlayerKind, strFilePath);
		objParams["movie"] = strUri;
		objEmbedAttr["src"] = strUri;
		
		if (is_iev && is_win)
		{
			objAttrs["classid"] = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
			objAttrs["codebase"] = "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0";
			objParams["allowScriptAccess"] = "always";
			objParams["quality"] = "high";
		}
		else
		{
			objEmbedAttr["type"] = "application/x-shockwave-flash";
			objEmbedAttr["pluginspace"] = "http://www.macromedia.com/go/getflashplayer";
		}
	}
	else if (WebFlashAtom.PLAYERTYPE_MP == nPlayerKind)
	{
		var strUri = WebFlashAtom.getURI(nPlayerKind, strFilePath);
		var strUIMode = (bShowControlBar) ? "full" : "none";
		objParams["uiMode"] = strUIMode;
		
		if (is_ie)
		{
			objParams["url"] = strUri;
			objAttrs["classid"] = "clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6";
		}
		else
		{
			objAttrs["type"] = "application/x-ms-wmp";
			objAttrs["data"] = strUri;
		}
	}
	else if (WebFlashAtom.PLAYERTYPE_MCC_DOCKING == nPlayerKind ||
				WebFlashAtom.PLAYERTYPE_MCC_FLOATING == nPlayerKind)
	{
		objAttrs["classid"] = "clsid:B43821EC-300E-4EB3-87E0-FAEE991CF885";
		objAttrs["codebase"] = "/ups/sys/cab/MediaComponent.ocx#version=1,0,0,23";
	}
	
	return WebFlashAtom.makeObjectTag(objAttrs, objParams, objEmbedAttr);
}

/**
 * Object 태그를 생성한다.
 * 
 * @param objAttrs : <Object> 태그에 설정될 Attribute 값
 *        objParams : <Object> 태그의 자식인 <Param> 태그에 설정될 값
 *        objEmbedAttr : <Object> 태그의 자식인 <Embed> 태그에 설정될 값
 */
WebFlashAtom.makeObjectTag = function (objAttrs, objParams, objEmbedAttr)
{
	var strTag = '<object ';
	for (var attr in objAttrs)
	{
		strTag += attr + '="' + objAttrs[attr] + '" ';
	}
	strTag += '>';
	
	for (var param in objParams)
	{
		strTag += '<param name="' + param + '" value="' + objParams[param] + '" /> ';
	}
	
	strTag += '<embed ';
	for (var attr in objEmbedAttr)
	{
		strTag += attr + '="' + objEmbedAttr[attr] + '" ';
	}
	strTag += ' ></embed></object>';
	
	return strTag;
}

/**
 *	웹임베디드 아톰
 */
function WebHtmlModelAtom (strVarName, strHtmlPath, bAutoSize, nScriptIndex, objResizableObject)
{
	this.m_strVarName = strVarName;
	this.m_nScriptIndex = nScriptIndex;
	this.m_strHtmlPath = strHtmlPath;
	this.m_bAutoSize = bAutoSize;
	
	this.m_objResizableObject = objResizableObject;
	
	this.m_heAtom = document.getElementById("__WEB_HTML_MODEL_" + strVarName);
	
	this.m_nOriginalHeight = this.m_heAtom.offsetHeight;
	this.m_nOriginalWidth = this.m_heAtom.offsetWidth;
}

/**
 *	웹임베디드 아톰 초기화
 */
WebHtmlModelAtom.prototype.init = function ()
{
	this.loadHTML(this.m_strHtmlPath);
}

WebHtmlModelAtom.prototype.getVarName = function ()
{
	return this.m_strVarName;
}

WebHtmlModelAtom.prototype.getScriptIndex = function ()
{
	return this.m_nScriptIndex;
}

WebHtmlModelAtom.prototype.getHTML = function ()
{
	return this.m_heAtom;
}

WebHtmlModelAtom.prototype.loadHTML = function (strPath)
{
	this.m_strHtmlPath = strPath;
	
	if (null != strPath && "" != strPath)
	{
		this.m_heAtom.src = strPath + "?" + this.m_strVarName;
	}
}

WebHtmlModelAtom.prototype.makeRequest = function (xnRequest)
{
	var xnAtom = XmlLib.createChild(xnRequest, "WebHtmlModelAtom");
	
	xnAtom.setAttribute("VarName", this.m_strVarName);
	xnAtom.setAttribute("RefVarName", this.m_strRefVarName);
	
	var strIframePath = "";
	try
	{
		strIframePath = this.m_heAtom.contentWindow.location.pathname;
	}
	catch (e)
	{
		strIframePath = this.m_heAtom.src;
	}
	
	XmlLib.setTextValue(xnAtom, decodeURI(strIframePath));
}

/**
 * 아톰리스트에 추가
 */
WebHtmlModelAtom.prototype.putAtom = function ()
{
	WebHtmlModelAtom._atoms[this.m_strVarName] = this;
}

WebHtmlModelAtom.prototype.handleResult = function (xnAtom)
{
	this.m_strRefVarName = xnAtom.getAttribute("RefVarName");
	var bMove = "true" == xnAtom.getAttribute("Move");
	var strRunPath = XmlLib.getTextValue(xnAtom);
	
	// 이동해야 한다면
	if (bMove)
	{
		// 모델을 연결한다.
		this.loadHTML(strRunPath);
	}
}

/**
 * 웹모델 아톰에 모델이 Embed되면 그 모델의 크기에 맞게 웹모델 아톰의 프레임도 size가 초기화 된다.
 */
WebHtmlModelAtom.prototype.initSize = function (nWidth, nHeight)
{
	if (this.m_bAutoSize)
	{
		if (null != this.m_heAtom)
		{		
			if (this.m_nOriginalHeight > nHeight)
			{
				nHeight = this.m_nOriginalHeight;
			}
			
			var heWebHtmlModelBody = this.m_heAtom.contentWindow.document.body;
			
			nHeight = nHeight + (heWebHtmlModelBody.offsetHeight - heWebHtmlModelBody.clientHeight);
			
			var nResizeHeight = nHeight - this.m_heAtom.offsetHeight;
			this.m_heAtom.style.height = nHeight + "px";
			
			// 자신과 크기 변화에 관계된 아톰들의 위치 및 크기를 변경한다.
			this._changeAttributeRelationAtom(nResizeHeight, 0);
		}
	}
}

WebHtmlModelAtom.prototype.getAtomType = function ()
{
	return "WebHtmlModelAtom";
}

WebHtmlModelAtom.prototype.setValue = function (strValue)
{
	this.loadHTML(strValue);
}

WebHtmlModelAtom.prototype.getValue = function ()
{
	return this.m_strHtmlPath;
}

/**
 * 웹모델 아톰에 Embed된 모델에서 resize가 발생하면 웹모델 아톰의 프레임도 resize가 된다.
 */
WebHtmlModelAtom.prototype.resize = function (nResizeHeight, nResizeWidth)
{
	var nHeight = this.m_heAtom.offsetHeight + nResizeHeight;
	
	// 최초 그려진 사이즈 보다 작으면 기본사이즈로 리사이즈 된다.
	if (this.m_nOriginalHeight > nHeight)
	{
		nHeight = this.m_nOriginalHeight;
		nResizeHeight = nHeight - this.m_heAtom.offsetHeight;
	}
		
	this.m_heAtom.style.height = nHeight + "px";
	
	// 자신과 크기 변화에 관계된 아톰들의 위치 및 크기를 변경한다.
	this._changeAttributeRelationAtom(nResizeHeight, nResizeWidth);
}

/**
 * 인자로 받은 값만큼 top을 변경시킨다
 * 
 * @param nRepositionValue (top 변경 값)
 */
WebHtmlModelAtom.prototype.repositionYPos = function (nRepositionValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nTop = this.m_heAtom.offsetTop;
	
	this.m_heAtom.style.top = (nTop + nRepositionValue) + "px";
}

/**
 * 인자로 받은 값만큼 left를 변경시킨다
 * 
 * @param nRepositionValue (left 변경 값)
 */
WebHtmlModelAtom.prototype.repositionXPos = function (nRepositionValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nLeft = this.m_heAtom.offsetLeft;
	
	this.m_heAtom.style.left = (nLeft + nRepositionValue) + "px";
}

/**
 * 인자로 받은 값만큼 높이를 변화시킨다
 * 
 * @param nResizeValue (높이 변경 값)
 */
WebHtmlModelAtom.prototype.resizeHeight = function (nResizeValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nHeight = this.m_heAtom.offsetHeight;
	
	this.m_heAtom.style.height = (nHeight + nResizeValue) + "px";
}

/**
 * 인자로 받은 값만큼 넓이를 변화시킨다
 * 
 * @param nResizeValue (높이 변경 값)
 */
WebHtmlModelAtom.prototype.resizeWidth = function (nResizeValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nWidth = this.m_heAtom.offsetWidth;
	
	this.m_heAtom.style.width = (nWidth + nResizeValue) + "px";
}

/**
 * 선택표시 (f9 기능)
 */
WebHtmlModelAtom.prototype.vanish = function ()
{
	// 선택표시 구현
}

/**
 * 웹모델 아톰의 크기 변화에 관계된 아톰들의 위치 및 크기를 변경 한다
 */
WebHtmlModelAtom.prototype._changeAttributeRelationAtom = function (nResizeHeight, nResizeWidth)
{
	if (null != this.m_heAtom)
	{
		this.m_objResizableObject.commitBoundsStatus(nResizeHeight, nResizeWidth);
	}
}

WebHtmlModelAtom.prototype.getProperty = function (nNameID, arArgs, objRetVal)
{
	switch (nNameID)
	{
		case 0 : case 203 :
			objRetVal.setValueType(CVariantX._vtString, this.getValue());
			return StdCore.S_OK;
		default : return StdCore.E_NOT_DEF_PROPERTY;
	}
}

WebHtmlModelAtom.prototype.setProperty = function (nNameID, arArgs, objRetVal)
{		
	switch (nNameID)
	{
		case 0 : case 203 : 
			this.setValue(objRetVal.toStringX());
			return StdCore.S_OK;
		default : return StdCore.E_NOT_DEF_PROPERTY;
	}
}

WebHtmlModelAtom.prototype.action = function (nNameID, arArgs, objRetVal)
{
	switch (nNameID)
	{
		case 6 : case 306 :
		{
			this.loadHTML(this.getValue());
			return StdCore.S_OK;
		}

		default : return this.getProperty (nNameID, arArgs, objRetVal);
	}
}


/**
 * 아톰리스트
 */
WebHtmlModelAtom._atoms = new Object();

/**
 *	웹임베디드 아톰 초기화
 */
WebHtmlModelAtom.init = function ()
{
	for (var strVarName in WebHtmlModelAtom._atoms)
	{
		WebHtmlModelAtom._atoms[strVarName].init();
	}
}

WebHtmlModelAtom.getAtom = function (strVarName)
{
	return WebHtmlModelAtom._atoms[strVarName];
}

WebHtmlModelAtom.makeRequest = function (xnRequest)
{
	for (var strVarName in WebHtmlModelAtom._atoms)
	{
		var objAtom = WebHtmlModelAtom._atoms[strVarName];
		if (null != objAtom)
		{
			objAtom.makeRequest(xnRequest);
		}
	}
}

/**
 * 웹모델 아톰에 모델이 Embed되면 그 모델의 크기에 맞게 웹모델 아톰의 프레임도 size가 초기화 된다.
 */
WebHtmlModelAtom.initSize = function (strVarName, nWidth, nHeight)
{
	var objAtom = WebHtmlModelAtom._atoms[strVarName];
	
	if (null != objAtom)
	{
		objAtom.initSize(nWidth, nHeight);
	}
}

/**
 * 웹모델 아톰에 Embed된 모델에서 resize가 발생하면 웹모델 아톰의 프레임도 resize가 된다.
 */
WebHtmlModelAtom.resize = function (strVarName, nResizeHeight, nResizeWidth)
{
	var objAtom = WebHtmlModelAtom._atoms[strVarName];
	
	if (null != objAtom)
	{
		objAtom.resize(nResizeHeight, nResizeWidth);
	}
}

/**
 * WebHtmlTagQuickLinkAtom JS 클래스 리스트
 * WebHtmlTagAtom
 * WebQuickLinkAtom
 */

function WebHtmlTagAtom (strVarName, nScriptIndex, objResizableObject, strHyperLinkName, nOriginalHeight, nOriginalWidth, bIsAutoSize)
{
	this.m_strVarName = strVarName;
	this.m_nScriptIndex = nScriptIndex; 
	this.m_objResizableObject = objResizableObject;
	this.m_nCurrentAtomHeight = 0;
	this.m_nCurrentAtomWidth = 0;
	this.m_nOriginalHeight = nOriginalHeight;
	this.m_nOriginalWidth = nOriginalWidth;
	this.m_bIsAutoSize = bIsAutoSize;
	
	this.m_heAtom = document.getElementById(this.m_strVarName);
	if (is_android || is_iphone)
	{
		this.m_heAtom.className = "webHTMLTag4Mobile"; //Model.css
	}
	
	this.m_strHyperLinkName = strHyperLinkName;
}

WebHtmlTagAtom.prototype = new Atom ();
WebHtmlTagAtom.prototype.constructor = WebHtmlTagAtom;

WebHtmlTagAtom.prototype.clear = function ()
{
	this._changeAttributeRelationAtom();
}

WebHtmlTagAtom.prototype.clone = function ()
{
	// 스크롤에 묶인다면 구현해야 한다.
}

WebHtmlTagAtom.prototype.getVarName = function ()
{
	return this.m_strVarName;
}

WebHtmlTagAtom.prototype.init = function ()
{
	this.m_nCurrentAtomHeight = this.m_heAtom.offsetHeight;
	this.m_nCurrentAtomWidth = this.m_heAtom.offsetWidth;
	
	this._changeAttributeRelationAtom();
}

WebHtmlTagAtom.prototype.getScriptIndex = function ()
{
	return this.m_nScriptIndex;
}

/**
 * 아톰리스트에 추가
 */
WebHtmlTagAtom.prototype.putAtom = function ()
{
	WebHtmlTagAtom._atoms[this.m_strVarName] = this;
}

WebHtmlTagAtom.prototype.setValue = function (strValue)
{
	this.m_heAtom.innerHTML = strValue;
}

WebHtmlTagAtom.prototype.getValue = function () 
{
	return this.m_heAtom.innerHTML;
}

WebHtmlTagAtom.prototype.makeRequest = function (xnRequest)
{
	var xnAtom = XmlLib.createChild(xnRequest, "WebHtmlTagAtom");
	xnAtom.setAttribute("VarName", this.m_strVarName);
	
	var strValue = this.getValue();
	XmlLib.setTextValue(xnAtom, strValue);
}

WebHtmlTagAtom.prototype.handleResult = function (xnAtom)
{
	var htmlString = XmlLib.getTextValue(xnAtom);
	this.setValue(htmlString);
}

/**
 * 인자로 받은 값만큼 top을 변경시킨다
 * 
 * @param nRepositionValue (top 변경 값)
 */
WebHtmlTagAtom.prototype.repositionYPos = function (nRepositionValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nTop = this.m_heAtom.offsetTop;
	
	this.m_heAtom.style.top = (nTop + nRepositionValue) + "px";
}

/**
 * 인자로 받은 값만큼 left를 변경시킨다
 * 
 * @param nRepositionValue (left 변경 값)
 */
WebHtmlTagAtom.prototype.repositionXPos = function (nRepositionValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nLeft = this.m_heAtom.offsetLeft;
	
	this.m_heAtom.style.left = (nLeft + nRepositionValue) + "px";
}

/**
 * 인자로 받은 값만큼 높이를 변화시킨다
 * 
 * @param nResizeValue (높이 변경 값)
 */
WebHtmlTagAtom.prototype.resizeHeight = function (nResizeValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nHeight = this.m_heAtom.offsetHeight;
	
	this.m_heAtom.style.height = (nHeight + nResizeValue) + "px";
}

/**
 * 인자로 받은 값만큼 넓이를 변화시킨다
 * 
 * @param nResizeValue (높이 변경 값)
 */
WebHtmlTagAtom.prototype.resizeWidth = function (nResizeValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nWidth = this.m_heAtom.offsetWidth;
	
	this.m_heAtom.style.width = (nWidth + nResizeValue) + "px";
}

/**
 * 선택표시 (f9 기능)
 */
WebHtmlTagAtom.prototype.vanish = function ()
{
	// 선택표시 구현
}

WebHtmlTagAtom.prototype.onClick = function ()
{
	// 하이퍼링크 동작, 가장 마지막에 수행해야 합니다. 다른 동작 추가시 위로 추가하세요
	if (null != this.m_strHyperLinkName && 0 != this.m_strHyperLinkName.length && ContainsWebHyperDataAtom())
	{
		var objHyperLinkAtom = Model.getAtom(this.m_strHyperLinkName, "", this.m_heAtom);
		if (null != objHyperLinkAtom)
		{
			// 먼저 하이퍼 링크의 링크 동작을 제외한 onClick을 수행한다. (스크립트동작)
			if (-1 != objHyperLinkAtom.onLinkClick())
			{
				objHyperLinkAtom.connectLink(this.m_heAtom);
			}
		}
	}
}

WebHtmlTagAtom.prototype.onMouseOver = function ()
{
	if (null != this.m_strHyperLinkName && 0 != this.m_strHyperLinkName.length && ContainsWebHyperDataAtom())
	{
		this.m_heAtom.style.cursor = "pointer";
	}
}

WebHtmlTagAtom.prototype.onMouseOut = function ()
{
	if (null != this.m_strHyperLinkName && 0 != this.m_strHyperLinkName.length && ContainsWebHyperDataAtom())
	{
		this.m_heAtom.style.cursor = "default";
	}
}

/**
 * 웹에디트 아톰의 크기 변화에 관계된 아톰들의 위치 및 크기를 변경 한다
 */
WebHtmlTagAtom.prototype._changeAttributeRelationAtom = function ()
{
	if (null != this.m_heAtom)
	{
		// 내용이 적더라도  웹에디트 아톰의 원래 높이보다 작아지지 않게 해준다.
		if (this.m_nOriginalHeight > this.m_nCurrentAtomHeight)
		{
			this.m_heAtom.style.height = this.m_nOriginalHeight + "px";
		}
		else
		{
			var nResizeHeight = 0;
			var nResizeWidth = 0;

			if(this.m_bIsAutoSize)
			{
				nResizeHeight = this.m_heAtom.scrollHeight - this.m_nOriginalHeight;
				nResizeWidth = this.m_heAtom.scrollWidth - this.m_nOriginalWidth;
			}
			else
			{
				nResizeHeight = this.m_heAtom.offsetHeight - this.m_nOriginalHeight;
				nResizeWidth = this.m_heAtom.offsetWidth - this.m_nOriginalWidth;
			}
		
			this.m_nCurrentAtomHeight = this.m_heAtom.offsetHeight;
			this.m_nCurrentAtomWidth = this.m_heAtom.offsetWidth;
		
			if (0 != nResizeHeight || 0 != nResizeWidth)
			{
				this.m_objResizableObject.commitBoundsStatus(nResizeHeight, nResizeWidth);
				
			}
		}
	}
}

WebHtmlTagAtom.prototype.setProperty = function (nNameID, arArgs, objRetVal)
{
	switch (nNameID)
	{
	case 0 : case 203 : return this.set_WebHtmlTagProperty (203, arArgs, objRetVal);
	}
}

WebHtmlTagAtom.prototype.set_WebHtmlTagProperty = function (nNameID, arArgs, objValue)
{
	switch(nNameID)
	{
	case 203:	// 값 (가장 많이 사용되므로 젤 위에 둔다)
		var strValue = objValue.toStringX();
		this.setValue(strValue);
		break;
	default:
		return StdCore.E_NOT_DEF_PROPERTY;
	}

	return StdCore.S_OK;
}

/**
 * 아톰리스트
 */
WebHtmlTagAtom._atoms = new Object();

WebHtmlTagAtom.getAtom = function (strVarName)
{
	return WebHtmlTagAtom._atoms[strVarName];
}

WebHtmlTagAtom.init = function ()
{
	for (var strVarName in WebHtmlTagAtom._atoms)
	{
		var objAtom = WebHtmlTagAtom._atoms[strVarName];
		
		objAtom.init();
	}
}

WebHtmlTagAtom.makeRequest = function (xnAtomRequest)
{
	for (var strVarName in WebHtmlTagAtom._atoms)
	{
		var objAtom = WebHtmlTagAtom._atoms[strVarName];
		
		objAtom.makeRequest(xnAtomRequest);
	}
}

WebHtmlTagAtom.onClick = function (strVarName, strScrollName, heAtom)
{
	var objAtom = WebHtmlTagAtom.getAtom(strVarName, strScrollName, heAtom);
	
	if (null != objAtom)
	{
		objAtom.onClick();
	}
}

WebHtmlTagAtom.onMouseOver = function (strVarName, strScrollName, heAtom)
{
	var objRect = WebHtmlTagAtom.getAtom(strVarName, strScrollName, heAtom);
	
	if (null != objRect)
	{
		objRect.onMouseOver();
	}
}

WebHtmlTagAtom.onMouseOut = function (strVarName, strScrollName, heAtom)
{
	var objRect = WebHtmlTagAtom.getAtom(strVarName, strScrollName, heAtom);
	
	if (null != objRect)
	{
		objRect.onMouseOut();
	}
}


/**
 *	웹 퀵링크 아톰
 */
function WebQuickLinkAtom (strVarName, arBindedAtom)
{
	this.m_strVarName = strVarName;
	this.m_arBindedAtom = arBindedAtom; // 묶인 아톰 리스트
	this.m_nCurrentScrollTop = document.body.scrollTop; // 현재 스크롤 위치
}

/**
 *	초기화
 */
WebQuickLinkAtom.prototype.init = function ()
{
	/**
	 *	묶인 아톰들은 다른 아톰보다 상위에 보여져야 하므로
	 *	zIndex를 높여준다.
	 */
	for (var i = 0; i < this.m_arBindedAtom.length; i += 1)
	{
		var strBindedAtomVarName = this.m_arBindedAtom[i];
		var heBindedAtom = document.getElementById(strBindedAtomVarName);
		//크로스 브라우저용 아톰
		var heBindedCrossAtom = document.getElementById(strBindedAtomVarName + "_cross");
		
		heBindedAtom.style.zIndex = 1;
		heBindedCrossAtom.style.zIndex = 1;
	}
}
WebQuickLinkAtom.prototype.getVarName = function ()
{
	return this.m_strVarName;
}

/**
 * 아톰리스트 추가
 */
WebQuickLinkAtom.prototype.putAtom = function ()
{
	WebQuickLinkAtom._atoms[this.m_strVarName] = this;
}

/**
 * 웹퀵링크에 묶인 아톰들의 Y축 위치 변경.
 */
WebQuickLinkAtom.prototype.repositionYPos = function ()
{
	var nNewScrollTop = document.documentElement.scrollTop;
	var nGap = nNewScrollTop - this.m_nCurrentScrollTop;
	
	if (0 == nGap)
	{
		window.setTimeout("WebQuickLinkAtom.repositionYPos()", 500);
		return;
	}
	
	//움질일 거리를 10단계로 나눠서 이동시킨다. 부드럽게 움직이는것처럼 보이게하는 효과.
	var nOffsetY = Math.ceil(Math.abs(nGap) / 10);
	if (0 > nGap)
	{
		nOffsetY = nOffsetY * (-1);
	}
	
    for (var i = 0; i < this.m_arBindedAtom.length; i += 1)
	{
		var strBindedAtomVarName = this.m_arBindedAtom[i];
		var heBindedAtom = document.getElementById(strBindedAtomVarName);
		
		//크로스 브라우저용 아톰
		var heBindedCrossAtom = document.getElementById(strBindedAtomVarName + "_cross");
		
		if ("line" == heBindedAtom.tagName)
		{
			var fromY = heBindedAtom.from.y;	// From.Y위치
			var toY = heBindedAtom.to.y;		// To.Y위치
			
			// line은 단위가 pt이고, nRowHeight는 단위가 px이므로 단위를 pt로 맞춰준다.
			var nValue = nOffsetY * 72 / 96;
				
			heBindedAtom.from.y += nValue;
			heBindedAtom.to.y += nValue;
		}
		else
		{
			heBindedAtom.style.top = Utils.parseInt (heBindedAtom.style.top) + nOffsetY + "px";
			heBindedCrossAtom.style.top = Utils.parseInt (heBindedAtom.style.top) + nOffsetY + "px";
		}
	}
	
    this.m_nCurrentScrollTop += nOffsetY;
    
    window.setTimeout("WebQuickLinkAtom.repositionYPos()", 10);
}

/**
 * 아톰리스트
 */
WebQuickLinkAtom._atoms = new Object();

/**
 *	웹 퀵링크 아톰리리스트 초기화
 */
WebQuickLinkAtom.init = function ()
{
	for (var strVarName in WebQuickLinkAtom._atoms)
	{			
		var objAtom = WebQuickLinkAtom._atoms[strVarName];
		
		objAtom.init();
	}
}

/**
 *	웹퀵링크에 묶인 아톰들의 Y축 위치 변경
 */
WebQuickLinkAtom.repositionYPos = function ()
{
	for (var strVarName in WebQuickLinkAtom._atoms)
	{			
		var objAtom = WebQuickLinkAtom._atoms[strVarName];
		
		objAtom.repositionYPos();
	}
}

/**
 * WebHyperDataLinkAtom JS 클래스 리스트
 * WebHyperDataAtom
 * WebHyperLinkAtom
 */

/**
 * 웹하이퍼링크  아톰
 * @since UPS1.0
 * @author 김지환
 */
function WebHyperDataAtom (strVarName,
						nScriptIndex,
						strRefVarName,
						strTableName,
						strFieldName,
						strFieldType,
						nFieldLen,
						bDefaultKey,
						nRunType,
						strRunPath,
						nLinkType,
						strParameter,
						bHideToolbar,
						nWindowWidth,
						nWindowHeight,
						bPlainHyperLink,
						bScrollBinded,
						strScrollName,
						objFont)
{
	this.Atom (strVarName, strRefVarName, "", -1, nScriptIndex)
	
	this.m_strTableName = strTableName;
	this.m_strFieldName = strFieldName;
	this.m_strFieldType = strFieldType;
	this.m_nFieldLen = nFieldLen;
	this.m_bDefaultKey = bDefaultKey;
	this.m_nRunType = nRunType;
	this.m_strRunPath = strRunPath;
	this.m_nLinkType = nLinkType;
	this.m_strParameter = strParameter;
	
	this.m_bScroll = bScrollBinded;
	this.m_strScrollName = strScrollName;
	
	// 새  창으로 연결시 툴바 숨김 여부
	this.m_bHideToolbar = bHideToolbar;
	// 새  창으로 연결시 윈도우 넓이
	this.m_nWindowWidth = nWindowWidth;
	// 새  창으로 연결시 윈도우 높이
	this.m_nWindowHeight = nWindowHeight;
	// 묶인 아톰이 없는 기본적인 하이퍼 링크인지 여부
	this.m_bPlainHyperLink = bPlainHyperLink;
	this.m_objFont = objFont;
	
	this.m_heAtom = document.getElementById("__WebHyperDataAtom_" + strVarName);
	
	this.m_nRowIndex = -1;
}

WebHyperDataAtom.prototype = new Atom ();
WebHyperDataAtom.prototype.constructor = WebHyperDataAtom;

/**
 * 스크롤에 묶였을 경우 행 clear 할 때 호출된다.
 */
WebHyperDataAtom.prototype.clear = function ()
{
	; // 아무 일도 하지 않는다.
}

// XmlAtomDefine에 설정된 아톰 타입 문자열을 리턴해야 한다.
WebHyperDataAtom.prototype.getAtomType = function ()
{
	return "WebHyperDataAtom";
}

WebHyperDataAtom.prototype.init = function ()
{
}

WebHyperDataAtom.prototype.getFieldType = function ()
{
	return this.m_strFieldType;
}

WebHyperDataAtom.prototype.getHTML = function ()
{
	return this.m_heAtom;
}

/**
 * 아톰리스트에 추가
 */
WebHyperDataAtom.prototype.putAtom = function ()
{
	WebHyperDataAtom._atoms[this.m_strVarName] = this;
}

WebHyperDataAtom.prototype.setHTML = function (heAtom)
{
	this.m_heAtom = heAtom;
}

WebHyperDataAtom.prototype.getFont = function ()
{
	return this.m_objFont;
}

WebHyperDataAtom.prototype.getRunType = function ()
{
	return this.m_nRunType;
}

WebHyperDataAtom.prototype.setRowIndex = function (nIndex)
{
	this.m_nRowIndex = nIndex;
}

WebHyperDataAtom.prototype.isSureInput = function ()
{
	return false;
}

WebHyperDataAtom.prototype.isSureInputScroll = function ()
{
	return false;
}

WebHyperDataAtom.prototype.displayValue = function ()
{
}

/**
 * 스크롤에 묶인 경우 유효행 체크를 합니다
 */
WebHyperDataAtom.prototype.checkSureInputScroll = function ()
{
	return false;
}

WebHyperDataAtom.prototype.setValue = function (strValue, nOccurEventType)
{
	// 값이  변경되었으면
	if (this.m_strRunPath != strValue)
	{
		this.m_strRunPath = strValue;
	}
}

WebHyperDataAtom.prototype.getValue = function ()
{
	return Utils.getPathString(this.m_strRunPath);	
}

/**
 * 객체 clone 메소드 입니다.
 * @param bIsHtml html 값을 설정할지 결정 
 */
WebHyperDataAtom.prototype.clone = function (bIsHtml)
{
	var objNewAtom = new WebHyperDataAtom(this.m_strVarName, this.m_nScriptIndex, this.m_strRefVarName, this.m_strTableName,
	 									  this.m_strFieldName, this.m_strFieldType, this.m_nFieldLen, this.m_bDefaultKey, 
										  this.m_nRunType, this.m_strRunPath, this.m_nLinkType, this.m_strParameter,
										  this.m_bHideToolbar, this.m_nWindowWidth, this.m_nWindowHeight, this.m_bPlainHyperLink,
										  this.m_bScroll, this.m_strScrollName, this.m_objFont);
					
	if (false != bIsHtml && null != this.m_heAtom)
	{
 		objNewAtom.setHTML(this.m_heAtom.cloneNode(true));
 	}
 	else
 	{
 		objNewAtom.setHTML(null);
 	}
 	
 	return objNewAtom;
}

WebHyperDataAtom.prototype.makeRequest = function (xnRequest)
{
	var xnAtom = XmlLib.createChild(xnRequest, "WebHyperDataAtom");

	//저장속성을 설정함
	xnAtom.setAttribute("SaveType", "");
	
	xnAtom.setAttribute("VarName", this.m_strVarName);
	xnAtom.setAttribute("RefVarName", this.m_strRefVarName);
	xnAtom.setAttribute("Parameter", this.m_strParameter);
	xnAtom.setAttribute("RunType", this.m_nRunType);
	xnAtom.setAttribute("TableName", this.m_strTableName);
	xnAtom.setAttribute("FieldName", this.m_strFieldName);
	xnAtom.setAttribute("FieldType", this.m_strFieldType);
	xnAtom.setAttribute("DefaultString", "");
	xnAtom.setAttribute("Prefix", "");
	
	xnAtom.setAttribute("WindowWidth", this.m_nWindowWidth);
	xnAtom.setAttribute("WindowHeight", this.m_nWindowHeight);
	
	XmlLib.setTextValue(xnAtom, this.m_strRunPath);
}

WebHyperDataAtom.prototype.handleResult = function (xnAtom)
{
	this.m_strRefVarName = xnAtom.getAttribute("RefVarName");
	this.m_strParameter = xnAtom.getAttribute("Parameter");
	var bMove = "true" == xnAtom.getAttribute("Move");
	var strValue = XmlLib.getTextValue(xnAtom);
	
	this.m_nWindowWidth = Utils.parseInt(xnAtom.getAttribute("WindowWidth"));
	this.m_nWindowHeight = Utils.parseInt(xnAtom.getAttribute("WindowHeight"));
	
	// 값이  변경되었으면
	if (this.m_strRunPath != strValue)
	{
		this.m_strRunPath = strValue;
	}
}

/**
 * 실행경로와 파라미터등을 이용하여 링크를 연결한다.
 */
WebHyperDataAtom.prototype.connectLink = function(heAtom, strScrollName)
{
	WebConnectionModel.open(this.m_nRunType, this.m_strRunPath, this.m_nLinkType, 
		this.m_bHideToolbar, this.m_nWindowHeight, this.m_nWindowWidth, 
		this.m_strParameter, this.m_strRefVarName, heAtom, strScrollName);
}

/**
 * 인자로 받은 값만큼 top을 변경시킨다
 * 
 * @param nRepositionValue (top 변경 값)
 */
WebHyperDataAtom.prototype.repositionYPos = function (nRepositionValue)
{
	if (null != this.m_heAtom)
	{
		var nTop = this.m_heAtom.offsetTop;
		this.m_heAtom.style.top = (nTop + nRepositionValue) + "px";
	}
}

/**
 * 인자로 받은 값만큼 left를 변경시킨다
 * 
 * @param nRepositionValue (left 변경 값)
 */
WebHyperDataAtom.prototype.repositionXPos = function (nRepositionValue)
{
	if (null != this.m_heAtom)
	{
		var nLeft = this.m_heAtom.offsetLeft;
		this.m_heAtom.style.left = (nLeft + nRepositionValue) + "px";
	}
}

/**
 * WebHyperDataAtom을 클릭했을 때, WebHyperDataAtom에 묶인 아톰을 클릭했을 때
 */
WebHyperDataAtom.prototype.onLinkClick = function ()
{
	var nScriptResult = ScriptAtomEvent.onClick(this.m_nScriptIndex);
	if (-1 != nScriptResult)
	{
		ScriptAtomEvent.onClickAfter(this.m_nScriptIndex);
	}
	
	return nScriptResult;
}

/**
 * 이벤트 순서: <a> onclick 이벤트 실행 -> 링크 이동
 */
WebHyperDataAtom.prototype.onClick = function ()
{
	if (-1 != ScriptAtomEvent.onClick(this.m_nScriptIndex))
	{
		ScriptAtomEvent.onClickAfter(this.m_nScriptIndex);
		
			this.connectLink();
			window.event.returnValue = false;
	}
	else
	{
		// 링크 이동 취소.
		window.event.returnValue = false;
	}	
}

/**
 * 선택표시 (f9 기능)
 */
WebHyperDataAtom.prototype.vanish = function ()
{
	// 선택표시
}

WebHyperDataAtom.prototype.getProperty = function (wNameID, pvaArgs, pRetVal)
{
	switch (wNameID)
	{
		case 0 : case 203 :	pRetVal.setValue (Utils.getPathString(this.m_strRunPath));		
			return StdCore.S_OK;
		case 1 : case 286 :	return this.get_GdiProperty (286, pvaArgs, pRetVal);
		default : return StdCore.E_NOT_DEF_PROPERTY;
	}
}

WebHyperDataAtom.prototype.setProperty = function (wNameID, pvaArgs, pRetVal)
{
	switch (wNameID)
	{
		case 0 : case 203 :
			var strPath = Utils.getPathString(pRetVal.toStringX());
			this.m_strRunPath = strPath;
			return StdCore.S_OK;
		case 1 : case 286 :	return this.set_GdiProperty (286, pvaArgs, pRetVal);
		default : return StdCore.E_NOT_DEF_PROPERTY;
	}
}

WebHyperDataAtom.prototype.action = function (wPropID, pvaArgs, pRetVal)
{
	switch (wPropID)
	{
		case 7 : case 306 :
		{
			this.connectLink();
			break;
		}
		case 8 : case 271 :	// 크기변경
		{
			if (null == pvaArgs ||  2 > pvaArgs.length)
				return StdCore.E_NOT_MATCH_PARAM_CNT;

			var nWidth  = pvaArgs[1].toInt();
            var nHeight = pvaArgs[2].toInt();
            
            this.m_nWindowWidth = nWidth;
            this.m_nWindowHeight = nHeight;
            break;
  		}
		default : return this.getProperty (wPropID, pvaArgs, pRetVal);
	}
	return StdCore.S_OK;
}

WebHyperDataAtom.EXE_PROGRAM = 0;
WebHyperDataAtom.EXE_URL = 1;

/**
 * 아톰리스트
 */
WebHyperDataAtom._atoms = new Object();

WebHyperDataAtom.getAtom = function (strVarName)
{
	return WebHyperDataAtom._atoms[strVarName];
}

WebHyperDataAtom.init = function ()
{
	for (var strVarName in WebHyperDataAtom._atoms)
	{
		var objAtom = WebHyperDataAtom._atoms[strVarName];
		
		objAtom.init();
	}
}

WebHyperDataAtom.makeRequest = function (xnAtomRequest)
{
	for (var strVarName in WebHyperDataAtom._atoms)
	{
		var objAtom = WebHyperDataAtom._atoms[strVarName];
		
		objAtom.makeRequest(xnAtomRequest);
	}
}

/**
 * WebHyperDataAtom을 클릭했을 때 
 */
WebHyperDataAtom.onLinkClick = function (strVarName)
{
	var objAtom = WebHyperDataAtom._atoms[strVarName];
	if (null != objAtom)
	{
		objAtom.onLinkClick();
	}
}

WebHyperDataAtom.onClick = function (strVarName)
{
	var objAtom = WebHyperDataAtom._atoms[strVarName];
	if (null != objAtom)
	{
		objAtom.onClick();
	}
}


/**
 * 웹하이퍼링크  아톰
 *
 * @since UPS1.0
 * @author 김지환
 */
function WebHyperLinkAtom (strVarName, nScriptIndex, strRefVarName, nRunType, strRunPath, nTextAlign, nLinkType, strParameter, bHideToolbar, nWindowWidth, nWindowHeight)
{
	this.m_strVarName = strVarName;
	this.m_nScriptIndex = nScriptIndex;
	this.m_strRefVarName = strRefVarName;
	this.m_nRunType = nRunType;
	this.m_strRunPath = strRunPath;
	this.m_nTextAlign = nTextAlign;
	this.m_nLinkType = nLinkType;
	this.m_strParameter = strParameter;
	
	// 새  창으로 연결시 툴바 숨김 여부
	this.m_bHideToolbar = bHideToolbar;
	// 새  창으로 연결시 윈도우 넓이
	this.m_nWindowWidth = nWindowWidth;
	this.m_nWindowHeight = nWindowHeight;
	
	this.m_heAtom = document.getElementById(strVarName);
}

WebHyperLinkAtom.prototype.init = function ()
{
}

WebHyperLinkAtom.prototype.getHTML = function ()
{
	return this.m_heAtom;
}

WebHyperLinkAtom.prototype.getVarName = function ()
{
	return this.m_strVarName;
}

WebHyperLinkAtom.prototype.makeRequest = function (xnRequest)
{
	var xnAtom = XmlLib.createChild(xnRequest, "WebHyperLinkAtom");
	
	xnAtom.setAttribute("VarName", this.m_strVarName);
	xnAtom.setAttribute("RefVarName", this.m_strRefVarName);
	xnAtom.setAttribute("Parameter", this.m_strParameter);
	xnAtom.setAttribute("RunType", this.m_nRunType);
	
	XmlLib.setTextValue(xnAtom, this.m_strRunPath);
}

WebHyperLinkAtom.prototype.handleResult = function (xnAtom)
{
	this.m_strRefVarName = xnAtom.getAttribute("RefVarName");
	this.m_strParameter = xnAtom.getAttribute("Parameter");
	var bMove = "true" == xnAtom.getAttribute("Move");
	var strRunPath = XmlLib.getTextValue(xnAtom);
	
	// 실행경로가 변경되었으면
	if (this.m_strRunPath != strRunPath)
	{
		this.m_strRunPath = strRunPath;
	}
	
	// 이동해야 한다면
	if (bMove)
	{
		// 링크를 연결한다.
		this.connectLink();
	}
}

/**
 * 실행경로와 파라미터등을 이용하여 링크를 연결한다.
 */
WebHyperLinkAtom.prototype.connectLink = function()
{
	WebConnectionModel.open(this.m_nRunType, this.m_strRunPath, this.m_nLinkType, 
		this.m_bHideToolbar, this.m_nWindowHeight, this.m_nWindowWidth, 
		this.m_strParameter, this.m_strRefVarName);
}

/**
 * 인자로 받은 값만큼 top을 변경시킨다
 * 
 * @param nRepositionValue (top 변경 값)
 */
WebHyperLinkAtom.prototype.repositionYPos = function (nRepositionValue)
{
	var nTop = this.m_heAtom.offsetTop;
	
	this.m_heAtom.style.top = (nTop + nRepositionValue) + "px";
}

/**
 * 인자로 받은 값만큼 left를 변경시킨다
 * 
 * @param nRepositionValue (left 변경 값)
 */
WebHyperLinkAtom.prototype.repositionXPos = function (nRepositionValue)
{
	var nLeft = this.m_heAtom.offsetLeft;
	
	this.m_heAtom.style.left = (nLeft + nRepositionValue) + "px";
}

/**
 * 이미지 Tag로 만들어진 WebHyperLinkAtom을 클릭했을 때 
 */
WebHyperLinkAtom.prototype.onLinkClick = function ()
{
	if (-1 != ScriptAtomEvent.onClick(this.m_nScriptIndex))
	{
		this.connectLink();
	}
	else
	{
		ScriptAtomEvent.onClickAfter(this.m_nScriptIndex);
	}
}

WebHyperLinkAtom.prototype.onMouseOver = function ()
{
	if (-1 != ScriptAtomEvent.onMouseOver(this.m_nScriptIndex))
	{
		ScriptAtomEvent.onMouseOverAfter(this.m_nScriptIndex);
	}
}

/**
 * 아톰리스트 추가
 */
WebHyperLinkAtom.prototype.putAtom = function ()
{
	WebHyperLinkAtom._atoms[this.m_strVarName] = this;
}

/**
 * 아톰리스트
 */
WebHyperLinkAtom._atoms = new Object();

WebHyperLinkAtom.getAtom = function (strVarName)
{
	return WebHyperLinkAtom._atoms[strVarName];
}

WebHyperLinkAtom.init = function ()
{
	for (var strVarName in WebHyperLinkAtom._atoms)
	{
		var objAtom = WebHyperLinkAtom._atoms[strVarName];
		
		objAtom.init();
	}
}

WebHyperLinkAtom.makeRequest = function (xnAtomRequest)
{
	for (var strVarName in WebHyperLinkAtom._atoms)
	{
		var objAtom = WebHyperLinkAtom._atoms[strVarName];
		
		objAtom.makeRequest(xnAtomRequest);
	}
}

/**
 * 이미지 Tag로 만들어진 WebHyperLinkAtom을 클릭했을 때 
 */
WebHyperLinkAtom.onLinkClick = function (strVarName)
{
	var objAtom = WebHyperLinkAtom._atoms[strVarName];
	if (null != objAtom)
	{
		objAtom.onLinkClick();
	}
}

/**
 * mouse over 이벤트 처리.
 */
WebHyperLinkAtom.onMouseOver = function (strVarName)
{
	var objAtom = WebHyperLinkAtom._atoms[strVarName];
	if (null != objAtom)
	{
		objAtom.onMouseOver();
	}
}

/**
 *	웹임베디드 아톰
 */
function WebIFrameAtom (strVarName, strHtmlPath)
{
	this.m_strVarName = strVarName;
	this.m_strHtmlPath = strHtmlPath;
	
	this.m_heAtom = document.getElementById(strVarName);
	this.m_heIFrame = document.getElementById("__WEB_IFRAME_ATOM_" + strVarName);
}

/**
 *	웹임베디드 아톰 초기화
 */
WebIFrameAtom.prototype.init = function ()
{
	// 초기화
}

WebIFrameAtom.prototype.getVarName = function ()
{
	return this.m_strVarName;
}

WebIFrameAtom.prototype.loadHTML = function (strPath)
{
	this.m_heIFrame.src = strPath;
}

WebIFrameAtom.prototype.makeRequest = function (xnRequest)
{
	var xnAtom = XmlLib.createChild(xnRequest, "WebIFrameAtom");
	
	xnAtom.setAttribute("VarName", this.m_strVarName);
	xnAtom.setAttribute("RefVarName", this.m_strRefVarName);
	
	var strIframePath = "";
	try
	{
		strIframePath = this.m_heIFrame.contentWindow.location.pathname;
	}
	catch (e)
	{
		strIframePath = this.m_heIFrame.src;
	}
	
	XmlLib.setTextValue(xnAtom, decodeURI(strIframePath));
}

/**
 * 아톰리스트에 추가
 */
WebIFrameAtom.prototype.putAtom = function ()
{
	WebIFrameAtom._atoms[this.m_strVarName] = this;
}

WebIFrameAtom.prototype.handleResult = function (xnAtom)
{
	this.m_strRefVarName = xnAtom.getAttribute("RefVarName");
	var bMove = "true" == xnAtom.getAttribute("Move");
	var strRunPath = XmlLib.getTextValue(xnAtom);
	
	// 이동해야 한다면
	if (bMove)
	{
		// 모델을 연결한다.
		this.loadHTML(strRunPath);
	}
}

/**
 * 아톰리스트
 */
WebIFrameAtom._atoms = new Object();

/**
 *	웹임베디드 아톰 초기화
 */
WebIFrameAtom.init = function ()
{
	for (var strVarName in WebIFrameAtom._atoms)
	{
		WebIFrameAtom._atoms[strVarName].init();
	}
}

WebIFrameAtom.getAtom = function (strVarName)
{
	return WebIFrameAtom._atoms[strVarName];
}

WebIFrameAtom.makeRequest = function (xnRequest)
{
	for (var strVarName in WebIFrameAtom._atoms)
	{
		var objAtom = WebIFrameAtom._atoms[strVarName];
		if (null != objAtom)
		{
			objAtom.makeRequest(xnRequest);
		}
	}
}

/**
 * 웹 모델 아톰, 다른 아톰을 임베드 하는 기능을 수행한다.
 * @since UPS1.0
 * @author 김지환
 */
function WebModelAtom (strVarName, // 1
					nScriptIndex, // 2
					strRefVarName, // 3
					strModelPath, // 4
					bAutoSize, // 5
					bScrollBar, // 6
					bSowBorder, // 7
					nOriginalHeight, // 8
					bVanish, // 9
					objResizableObject,	// 10
					nScriptIndex, //11
					bIsAlignCenter) //12
{
	this.m_strVarName = strVarName;
	this.m_nScriptIndex = nScriptIndex;
	this.m_strRefVarName = strRefVarName;
	this.m_strModelPath = Utils.removePQPath(strModelPath);
	this.m_bAutoSize = bAutoSize;
	this.m_bScrollBar = bScrollBar;
	this.m_bSowBorder = bSowBorder;
	this.m_nOriginalHeight = nOriginalHeight;
	this.m_bVanish = bVanish;
	this.m_objResizableObject = objResizableObject;
	this.m_nScriptIndex = nScriptIndex;
	this.m_bIsAlignCenter = bIsAlignCenter;
	
	/**
	 * 임베딩된 모델로 넘어간 참조아톰값.
	 */	
	this.m_strParameter = "";
	
	this.m_heAtom = document.getElementById("__WEBMODEL_" + this.m_strVarName);
	this.m_nOriginalWidth = this.m_heAtom.offsetWidth;
}

WebModelAtom.prototype.getAtomType = function ()
{
	return "WebModel";
}

WebModelAtom.prototype.getHTML = function ()
{
	return this.m_heAtom;
}

WebModelAtom.prototype.getVarName = function ()
{
	return this.m_strVarName;
}

WebModelAtom.prototype.getScriptIndex = function ()
{
	return this.m_nScriptIndex;
}

WebModelAtom.prototype.init = function ()
{	
	var strParameter = "";
	if (null != this.m_strParameter && 0 != this.m_strParameter.length)
	{
		strParameter = "C=" + this.m_strParameter;
	}
	
	this.loadModel(this.m_strModelPath, strParameter);
}

WebModelAtom.prototype.close = function ()
{
	if (IsDotNet() && -1 == strModelPath.indexOf(".QWP"))
	{
		//
	}
	else
	{
		this.m_heAtom.src = "";
	}	
}

WebModelAtom.prototype.makeRequest = function (xnRequest)
{
	var xnAtom = XmlLib.createChild(xnRequest, "WebModelAtom");
	
	xnAtom.setAttribute("VarName", this.m_strVarName);
	xnAtom.setAttribute("RefVarName", this.m_strRefVarName);
	
	XmlLib.setTextValue(xnAtom, this.m_strModelPath);
}

/**
 * 아톰리스트에 추가
 */
WebModelAtom.prototype.putAtom = function ()
{
	WebModelAtom._atoms[this.m_strVarName] = this;
}

WebModelAtom.prototype.handleResult = function (xnAtom)
{
	this.m_strRefVarName = xnAtom.getAttribute("RefVarName");
	var bMove = "true" == xnAtom.getAttribute("Move");
	var strRunPath = XmlLib.getTextValue(xnAtom);
	
	// 값(실행경로)를 넣어준다.
	this.setValue(strRunPath);
	
	// 이동해야 한다면
	if (bMove)
	{
		// 모델을 연결한다.
		this.loadModel(this.m_strModelPath);
	}
}

WebModelAtom.prototype.loadModel = function (strModelPath, strParameter)
{
	var strModelPathUpperCase = strModelPath.toUpperCase();
	
	if (IsDotNet() && -1 == strModelPathUpperCase.indexOf(".QWP"))
	{
		var strDotNetAreaID = "__WEBMODEL_DOTNET_" + this.m_strVarName;
		var heDotNetArea = document.getElementById(strDotNetAreaID);
		if (null != heDotNetArea && 0 < strModelPath.length)
		{
			//java 영역을 화면 감춤 상태로 만든다.
			if (null != this.m_heAtom)
			{
				this.m_heAtom.style.visibility = "hidden";
			}
			//.net 영역을 화면 보이기 상태로 만든다.
			heDotNetArea.style.visibility = "visible";
			
			var nOrginWidth = heDotNetArea.offsetWidth;
			var nOrginHeight = heDotNetArea.offsetHeight;
			
			//heDotNetArea.FrmWidth = "0";
			//heDotNetArea.FrmHeight = "0";
			heDotNetArea.PQINDEX = "1";
			heDotNetArea.PQINFO = "";
			heDotNetArea.OpenForm(g_strServerURL + GetProjectName() + "/" + strModelPath, true, false);

			var nWidth = nOrginWidth;
			var nHeight = nOrginHeight;
			if (this.m_bAutoSize)
			{
				nWidth = heDotNetArea.FrmWidth;
				nHeight = heDotNetArea.FrmHeight;
			}
			
			this.initSize(nWidth, nHeight, nOrginWidth, nOrginHeight);		
			
			if(this.m_bIsAlignCenter)
			{
				var AlignCenterDiv = document.getElementById("__WEBMODEL_AlignCenter_" + this.m_strVarName);
				
				var nTop = (AlignCenterDiv.offsetHeight - heDotNetArea.FrmHeight) / 2;
				var nHeight = (AlignCenterDiv.offsetWidth - heDotNetArea.FrmWidth) / 2;
				
				if(0 > nTop)
				{
					nTop = 0;
				}

				if(0 > nHeight)
				{
					nHeight = 0;
				}
				heDotNetArea.style.top = nTop +  "px";
				heDotNetArea.style.left = nHeight +  "px";		
			}
		}
	}
	else
	{
		if (null != this.m_heAtom && 0 < strModelPath.length)
		{
			//java 영역을 화면 보이기 상태로 만든다.
			this.m_heAtom.style.visibility = "visible";
			//.net 영역을 화면 감춤 상태로 만든다.
			if (IsDotNet())
			{
				var strDotNetAreaID = "__WEBMODEL_DOTNET_" + this.m_strVarName;
				var heDotNetArea = document.getElementById(strDotNetAreaID);
				if (null != heDotNetArea)
				{
					heDotNetArea.style.visibility = "hidden";
				}
			}
			
			var strPath = "";
			if (0 < strModelPathUpperCase.indexOf(".QPG"))
			{
				strPath = "/ups/Model.html?ModelName=" + GetProjectName() + "/" + strModelPath + "&E=" + this.m_strVarName;
				
				this.m_heAtom.style.border = "1px solid #A6A6A6";
				
				if (false == IsDotNet())
				{
					// qpg 파일 열릴때, 전역정보 설정을 수행하므로, 메뉴 눌렀을때 하지 않는다.
					//g_objModelCore._checkSolutionLogin(true);
				}
			}
			else if (0 < strModelPathUpperCase.indexOf(".QWP"))
			{
				// 메뉴나 하이퍼링크가 넘겨주는 파라미터가 우선 없으면 자신의 참조변수로 파라미터를 만든다.
				if (null == strParameter || 0 == strParameter.length)
				{
					strParameter = WebConnectionModel.makeParameter(this.m_strRefVarName);
				}
				
				if (null == strParameter || 0 == strParameter.length)
				{
					strParameter = "E=" + this.m_strVarName;
				}
				else
				{
					strParameter = strParameter + "&E=" + this.m_strVarName;
				}
				
				strParameter = strParameter + "&D=" + Utils.getCreateCondition(strModelPath);
				
				strPath = "/ups/" + GetProjectName() + "/" + 
					Utils.removePQPath(Utils.replace(Utils.getModelName(strModelPath), "\\.QWP", ".html")) + 
					"?" + strParameter;
				
				if (!this.m_bSowBorder)
				{
					this.m_heAtom.style.border = "0px";
				}
			}
		
			this.m_heAtom.src = strPath;
		}
	}
	
}

/**
 * 모델삽입 내의 document.body.scroll 속성 설정.
 * iframe 만 스크롤속성 설정했다고 스크롤이 없어지진 않는다.
 * @see ModelCore.prototype._setWebModelScroll ()
 */
WebModelAtom.prototype.setWebModelScroll = function ()
{
	var heWebModelBody = null;
	
	if(is_chrome || is_safari)
	{
		heWebModelBody = this.m_heAtom.contentWindow.document.body;
	}
	else
	{
		heWebModelBody = this.m_heAtom.contentWindow.document.documentElement;
	}

	if (heWebModelBody)
	{
		if (this.m_bAutoSize || this.m_bScrollBar)
		{
			if (!this.m_bAutoSize && (is_android || is_iphone))
			{
				heWebModelBody.scroll = "no";
			}
			else
			{
				if(is_chrome || is_safari)
				{
					heWebModelBody.style.overflow = "auto";
				}
				else if(is_ie)
				{
					this.m_heAtom.contentWindow.document.body.scroll = "yes";
				}
				else
				{
					this.m_heAtom.style.overflow = "auto";
				}
				
				var contentModel = this.m_heAtom.contentWindow.document.getElementById("ModelArea");
				this.initSize(contentModel.scrollWidth, contentModel.scrollHeight);
				
			}
		}
		else
		{
			heWebModelBody.scroll = "no";
		}
	}
}

/**
 * 웹모델 아톰의 값은 연결모델의 경로이다.
 */
WebModelAtom.prototype.setValue = function (strModelPath)
{
	// 웹페이지모델의 경로가 실제로 쓰일때는 *.QWP가 *.html로 변경된 상태이다.
	// 따라서 현재 웹페이지주소를 저장하는 등의 기능에서 넘어오는 모델삽입 아톰의 경로를 
	// *.html에서  *.QWP로 변경해준다.
	strModelPath = Utils.replace(strModelPath, ".html", ".QWP");
	if (this.m_strModelPath != strModelPath)
	{
		this.m_strModelPath = Utils.removePQPath(Utils.getPathString(strModelPath));
	}
}

WebModelAtom.prototype.getValue = function ()
{
	return this.m_strModelPath;
}

/**
 * 임베딩된 모델로 넘어간 참조아톰값을 저장한다.
 *
 * @param strParameter 입력란:값,입력란1:값
 */
WebModelAtom.prototype.setParameter = function (strParameter)
{
	this.m_strParameter = strParameter;
}

/**
 * 임베딩된 모델로 넘어간 참조아톰값을 가져온다.
 *
 * @return 입력란:값,입력란1:값
 */
WebModelAtom.prototype.getParameter = function ()
{
	return this.m_strParameter;
}

WebModelAtom.showWebModel = function ()
{
	var strModelPathUpperCase = strModelPath.toUpperCase();
	if (IsDotNet() && -1 == strModelPathUpperCase.indexOf(".QWP"))
	{
		for (var strVarName in WebModelAtom._atoms)
		{
			document.getElementById("__WEBMODEL_" + strVarName).style.visibility = "visible";
		}
	}
	else
	{
		for (var strVarName in WebModelAtom._atoms)
		{
			document.getElementById("__WEBMODEL_DOTNET_" + strVarName).style.visibility = "visible";
		}
	}
}

WebModelAtom.hideWebModel = function ()
{
	var strModelPathUpperCase = strModelPath.toUpperCase();
	if (IsDotNet() && -1 == strModelPathUpperCase.indexOf(".QWP"))
	{
		for (var strVarName in WebModelAtom._atoms)
		{
			document.getElementById("__WEBMODEL_" + strVarName).style.visibility = "hidden";
		}
	}
	else
	{
		for (var strVarName in WebModelAtom._atoms)
		{
			document.getElementById("__WEBMODEL_DOTNET_" + strVarName).style.visibility = "hidden";
		}
	}
}
/**
 * 웹모델 아톰에 모델이 Embed되면 그 모델의 크기에 맞게 웹모델 아톰의 프레임도 size가 초기화 된다.
 */
WebModelAtom.prototype.initSize = function (nWidth, nHeight, nOrginWidth, nOrginHeight)
{	
	var strModelPathUpperCase = this.m_strModelPath.toUpperCase();
	var heAtom = null;
	if (IsDotNet() && -1 == strModelPathUpperCase.indexOf(".QWP"))
	{
		heAtom = document.getElementById("__WEBMODEL_DOTNET_" + this.m_strVarName);
		if (null != heAtom)
		{		
			
			var nResizeWidth = nWidth - nOrginWidth;
			heAtom.style.width = nWidth + "px";
			
			var nResizeHeight = nHeight - nOrginHeight;
			heAtom.style.height = nHeight + "px";
			
			// 자신과 크기 변화에 관계된 아톰들의 위치 및 크기를 변경한다.
			this._changeAttributeRelationAtom(nResizeHeight, nResizeWidth);
		}
	}
	else
	{
		if (this.m_bAutoSize)
		{
			if (null != this.m_heAtom)
			{
				// 자동크기조정 일때, 스크롤 안 생기게 한다.
				this.m_heAtom.contentWindow.document.body.scroll = "no";
				this.m_heAtom.contentWindow.document.body.style.overflow = "hidden";
				
				// 최초 그려진 사이즈 보다 작으면 기본사이즈로 리사이즈 된다.
				var nResizeWidth = nWidth - this.m_heAtom.offsetWidth;
				this.m_heAtom.style.width = nWidth + "px";
				
				var nResizeHeight = nHeight - this.m_heAtom.offsetHeight;
				this.m_heAtom.style.height = nHeight + "px";
				
				// 자신과 크기 변화에 관계된 아톰들의 위치 및 크기를 변경한다.
				this._changeAttributeRelationAtom(nResizeHeight, nResizeWidth);
			}
		}
	}
}

/**
 * 웹모델 아톰에 Embed된 모델에서 resize가 발생하면 웹모델 아톰의 프레임도 resize가 된다.
 */
WebModelAtom.prototype.resize = function (nResizeHeight, nResizeWidth)
{
	var nHeight = this.m_heAtom.offsetHeight + nResizeHeight;
	
	// 최초 그려진 사이즈 보다 작으면 기본사이즈로 리사이즈 된다.
	if (this.m_nOriginalHeight > nHeight)
	{
		nHeight = this.m_nOriginalHeight;
		nResizeHeight = nHeight - this.m_heAtom.offsetHeight;
	}
		
	this.m_heAtom.style.height = nHeight + "px";
	
	// 자신과 크기 변화에 관계된 아톰들의 위치 및 크기를 변경한다.
	this._changeAttributeRelationAtom(nResizeHeight, nResizeWidth);
}

/**
 * 인자로 받은 값만큼 top을 변경시킨다
 * 
 * @param nRepositionValue (top 변경 값)
 */
WebModelAtom.prototype.repositionYPos = function (nRepositionValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nTop = this.m_heAtom.offsetTop;
	
	this.m_heAtom.style.top = (nTop + nRepositionValue) + "px";
}

/**
 * 인자로 받은 값만큼 left를 변경시킨다
 * 
 * @param nRepositionValue (left 변경 값)
 */
WebModelAtom.prototype.repositionXPos = function (nRepositionValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nLeft = this.m_heAtom.offsetLeft;
	
	this.m_heAtom.style.left = (nLeft + nRepositionValue) + "px";
}

/**
 * 인자로 받은 값만큼 높이를 변화시킨다
 * 
 * @param nResizeValue (높이 변경 값)
 */
WebModelAtom.prototype.resizeHeight = function (nResizeValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nHeight = this.m_heAtom.offsetHeight;
	
	this.m_heAtom.style.height = (nHeight + nResizeValue) + "px";
}

/**
 * 인자로 받은 값만큼 넓이를 변화시킨다
 * 
 * @param nResizeValue (높이 변경 값)
 */
WebModelAtom.prototype.resizeWidth = function (nResizeValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nWidth = this.m_heAtom.offsetWidth;
	
	this.m_heAtom.style.width = (nWidth + nResizeValue) + "px";
}

/**
 * 프로그램 모델 아톰이 품고 있는 임베딩된 모델의 주소를 갱신한다.
 *
 * @param strAddress 임베딩모델경로?C=참조아톰명:값,참조아톰명1:값
 */
WebModelAtom.prototype.updateAddress = function (strAddress)
{
	var arQueryList = strAddress.split("?");
	
	if (null != arQueryList && 0 < arQueryList.length)
	{
		this.setValue(arQueryList[0]);
		
		if (1 < arQueryList.length)
		{
			this.setParameter(arQueryList[1].substring(2));
		}
	}
	
	// 현재 window 안에 웹페이지주소 사각형아톰 주소를 Update한다.
	var strAddress = ModelCore.updateAddress();
	
	// 모든 프로그램모델 contentsWindow 안에 있는  웹페이지주소 사각형아톰 주소를 Update한다.
	WebModelAtom.updateAddressContentWindow(strAddress);
}

/**
 * 프로그램모델 contentsWindow 안에 있는  웹페이지주소 사각형아톰에 주소를 Update한다.
 */
WebModelAtom.prototype.updateAddressContentWindow = function (strAddress)
{
	var objContentWindow = this.m_heAtom.contentWindow; 
	if (objContentWindow)
	{
		if (objContentWindow.ContainsRectangleAtom && objContentWindow.ContainsRectangleAtom())
		{
			var objAtom = objContentWindow.RectangleAtom.getAtom("웹페이지주소");
			if (null != objAtom)
			{
				objAtom.setValue(strAddress);
			}
		}
	}
}

/**
 * 선택표시 (f9 기능)
 */
WebModelAtom.prototype.vanish = function ()
{
	// 먼저 모델삽입 안에 있는 아톰의 선택표시 실행
	var objContentWindow = this.m_heAtom.contentWindow;
	if (objContentWindow)
	{
		objContentWindow.Model.switchAllVanish();
	}
	
	// 자신의 선택표시 실행
	if (this.m_bVanish)
	{
		// 현재 감춤 상태이면 표시한다.
		if ("hidden" == this.m_heAtom.style.visibility)
		{
			this.m_heAtom.style.visibility = "visible";
		}
		else
		{
			// 표시된 상태이면 감춘다.
			this.m_heAtom.style.visibility = "hidden";
		} 
	}
}

WebModelAtom.prototype.adjustScroll = function ()
{
	if (document.body.scrollTop > this.m_heAtom.offsetTop)
	{
		document.body.scrollTop = this.m_heAtom.offsetTop;
	}
}

/**
 * 모델삽입 안의 모델을 인쇄합니다.
 */
WebModelAtom.prototype.printModel = function ()
{
	frames["__WEBMODEL_" + this.m_strVarName].focus();
	frames["__WEBMODEL_" + this.m_strVarName].print();
}



/////////////////////////
// private methods
/**
 * 웹모델 아톰의 크기 변화에 관계된 아톰들의 위치 및 크기를 변경 한다
 */
WebModelAtom.prototype._changeAttributeRelationAtom = function (nResizeHeight, nResizeWidth)
{
	if (null != this.m_heAtom)
	{
		this.m_objResizableObject.commitBoundsStatus(nResizeHeight, nResizeWidth);
	}
}

WebModelAtom.prototype.setProperty = function (wNameID, arArgs, objRetVal)
{		
	switch (wNameID)
	{
		case 0 : case 203 : 
		{
			this.setValue(objRetVal.toStringX());
		}
		return StdCore.S_OK;
	}
}

WebModelAtom.prototype.getProperty = function (wNameID, arArgs, objRetVal)
{
	switch (wNameID)
	{
		case 0 : case 203 :
		{
			objRetVal.setValueType(CVariantX._vtString, this.getValue());
		}
	}
}

WebModelAtom.prototype.action = function (nPropID, arArgs, objRetVal)
{
	switch (nPropID)
	{
		case 6 : case 306 :		// 이동 (실행경로로 모델이동)
		{
			this.loadModel(this.m_strModelPath);
			
			return StdCore.S_OK;
		}

		default : return this.getProperty (nPropID, arArgs, objRetVal);
	}
}


/**
 * 아톰리스트
 */
WebModelAtom._atoms = new Object();

WebModelAtom.getAtom = function (strVarName)
{
	if (strVarName in WebModelAtom._atoms)
	{
		return WebModelAtom._atoms[strVarName];
	}
}

WebModelAtom.init = function ()
{
	for (var strVarName in WebModelAtom._atoms)
	{
		var objAtom = WebModelAtom._atoms[strVarName];
		
		objAtom.init();
	}
}

WebModelAtom.allClose = function ()
{
	for (var strVarName in WebModelAtom._atoms)
	{
		var objAtom = WebModelAtom._atoms[strVarName];
		
		objAtom.close();
	}
}

WebModelAtom.makeRequest = function (xnRequest)
{
	for (var strVarName in WebModelAtom._atoms)
	{
		var objAtom = WebModelAtom._atoms[strVarName];
		if (null != objAtom)
		{
			objAtom.makeRequest(xnRequest);
		}
	}
}

/**
 * 웹모델 아톰에 모델이 Embed되면 그 모델의 크기에 맞게 웹모델 아톰의 프레임도 size가 초기화 된다.
 */
WebModelAtom.initSize = function (strVarName, nWidth, nHeight)
{
	var objAtom = WebModelAtom._atoms[strVarName];
	if (null != objAtom)
	{
		objAtom.initSize(nWidth, nHeight);
	}
}

/**
 * 웹모델 아톰에 Embed된 모델에서 resize가 발생하면 웹모델 아톰의 프레임도 resize가 된다.
 */
WebModelAtom.resize = function (strVarName, nResizeHeight, nResizeWidth)
{
	var objAtom = WebModelAtom._atoms[strVarName];
	
	if (null != objAtom)
	{
		objAtom.resize(nResizeHeight, nResizeWidth);
	}
}

/**
 * 프로그램 모델 아톰이 품고 있는 임베딩된 모델의 주소를 갱신한다.
 * @param strVarName 아톰변수명
 * @param strAddress 모델의 주소(참조아톰값 포함) 
 */
WebModelAtom.updateAddress = function (strVarName, strAddress)
{
	var objAtom = WebModelAtom._atoms[strVarName];
	if (null != objAtom)
	{
		objAtom.updateAddress(strAddress);
	}
}

/**
 * 모든 프로그램 모델 아톰의 참조아톰값을 한데 모아서 구성한다.
 * C=프로그램모델아톰명:모델경로&P=프로그램모델아톰명$입력란:값&C=프로그램모델아톰명1:모델경로&P=프로그램모델아톰명1$입력란:값&
 */
WebModelAtom.getParameters = function ()
{
	var strAllParameters = "";
	
	for (var strVarName in WebModelAtom._atoms)
	{
		var objAtom = WebModelAtom._atoms[strVarName];
		
		var strModelPath = objAtom.getValue();
		strAllParameters = strAllParameters + "C=" + strVarName + ":" + strModelPath + "&";
		
		var strParameters = objAtom.getParameter();
		if (0 < strParameters.length)
		{
			// &E=로 설정된 모델의 임베딩 정보는 제거한다.
			var nIndex = strParameters.indexOf("&E=");
			if (0 <= nIndex)
			{
				var nEndIndex = strParameters.indexOf("&", nIndex + 1);
				if (0 > nEndIndex)
				{
					strParameters = strParameters.substring(0, nIndex)
				}
				else
				{
					strParameters = strParameters.substring(0, nIndex) + strParameters.substring(nEndIndex);
				}
			}
			
			strParameters = "P=" + strVarName + "$" + strParameters;
			
			strAllParameters = strAllParameters + strParameters + "&";
		}
	}
	
	return strAllParameters;
}

/**
 * 모델삽입 내의 document.body.scroll 속성 설정.
 * iframe 만 스크롤속성 설정했다고 스크롤이 없어지진 않는다.
 * @see ModelCore.prototype._setWebModelScroll ()
 */
WebModelAtom.setWebModelScroll = function ()
{
	for (var strVarName in WebModelAtom._atoms)
	{
		WebModelAtom._atoms[strVarName].setWebModelScroll();
	}
}

/**
 * 모든 프로그램모델 contentsWindow 안에 있는  웹페이지주소 사각형아톰 주소를 Update한다.
 */
WebModelAtom.updateAddressContentWindow = function (strAddress)
{
	for (var strVarName in WebModelAtom._atoms)
	{
		var objAtom = WebModelAtom._atoms[strVarName];
		if (null != objAtom)
		{
			objAtom.updateAddressContentWindow(strAddress);
		}
	}
}

/**
 * 모델 삽입 아톰 내부 페이지가 변경될대, 스크롤 위치를 조정한다.
 */
WebModelAtom.adjustScroll = function (strVarName)
{
	var objAtom = WebModelAtom._atoms[strVarName];
	
	if (null != objAtom)
	{
		objAtom.adjustScroll();
	}
}

function WebSchedulerAtom (strVarName, strOpenFilePath, strCloseFilePath, strMenuPath, bAutoSize, objResizableObject)
{
	this.m_strVarName = strVarName;
	this.m_strOpenFilePath = strOpenFilePath
	this.m_strCloseFilePath = strCloseFilePath
	this.m_strMenuPath = strMenuPath;
	
	this.m_heAtom = document.getElementById("__WebScheduler_" + strVarName);
	this.m_heSchedulerButton = document.getElementById("__WebScheduler_Button_" + strVarName);
	
	this.m_bAutoSize = false;//bAutoSize;
	this.m_objResizableObject = objResizableObject;
}

WebSchedulerAtom.prototype.getVarName = function ()
{
	return this.m_strVarName;
}

WebSchedulerAtom.prototype.load = function ()
{
	var objSchedulerWindow = this.m_heAtom.contentWindow;
	if (null != objSchedulerWindow)
	{
		objSchedulerWindow.SchedulerLoader.init();
	}
}

WebSchedulerAtom.prototype.init = function ()
{
	var objSchedulerWindow = this.m_heAtom.contentWindow;
	this.m_heAtom.style.visibility = "visible";
	objSchedulerWindow.ScheduleGlobalManager.setUseSmartClient(IsDotNet());
	
	this.resize();
}

WebSchedulerAtom.prototype.unLoad = function ()
{
	var objSchedulerWindow = this.m_heAtom.contentWindow;
	if (null != objSchedulerWindow)
	{
		objSchedulerWindow.SchedulerLoader.unLoad();
	}
}

/**
 * 아톰리스트에 추가
 */
WebSchedulerAtom.prototype.putAtom = function ()
{
	WebSchedulerAtom._atoms[this.m_strVarName] = this;
}

WebSchedulerAtom.prototype.setLoginInfo = function (strID, strPassword)
{
	var objSchedulerWindow = this.m_heAtom.contentWindow;
	if (null != objSchedulerWindow)
	{
		objSchedulerWindow.SchedulerLoader.setLoginInfo(strID, strPassword);
	}
}

/**
 * 스케줄러 열기/닫기 버튼클릭, 스케줄러를 보이거나 감추고 버튼 이미지를 변경한다.
 */
WebSchedulerAtom.prototype.onClickButton = function ()
{
	// 현재 감춤이면
	if ("hidden" == this.m_heAtom.style.visibility)
	{
		// 스케줄러를 열고 / 버튼 이미지를 닫기로 변경한다.
		this.m_heAtom.style.visibility = "visible";
		this.m_heSchedulerButton.src = this.m_strCloseFilePath;

		WebModelAtom.showWebModel();
	}
	// 현재 열림이면
	else
	{
		// 스케줄러를 닫고 / 버튼 이미지를 열기로 변경한다.
		this.m_heAtom.style.visibility = "hidden";
		this.m_heSchedulerButton.src = this.m_strOpenFilePath;

		WebModelAtom.hideWebModel();
	}
}

/**
 * 다이어리를 Resize한다.
 */
WebSchedulerAtom.prototype.resize = function ()
{
	/*
	if (this.m_bAutoSize)
	{
		var objSchedulerWindow = this.m_heAtom.contentWindow;
		if (null != objSchedulerWindow)
		{
			// 나머지 영역의 크기, 윈도우에서 다이어리가 그려질 수 있는 영역을 구한다.
			var nRemainderWidth = document.body.offsetWidth - this.m_heAtom.offsetLeft;
			var nRemainderHeight = document.body.offsetHeight - this.m_heAtom.offsetTop;
			
			// 남머지 영역의 크기로 다이어리 크기의 스텝을 구한다.
			var nStep = objSchedulerWindow.DisplaySizeHandler.getSizeStep(nRemainderWidth, nRemainderHeight);
			var nOldStep = objSchedulerWindow.DisplaySizeHandler.getSizeStep(this.m_heAtom.offsetWidth, this.m_heAtom.offsetHeight);
			
			var arDiarySize = this._getSizeByStep(nStep);
			var arOldDiarySize = this._getSizeByStep(nOldStep);
			
			var nOffsetWidth = arDiarySize[0] - arOldDiarySize[0];
			var nOffsetHeight = arDiarySize[1] - arOldDiarySize[1];
			
			// 스케줄러를 리사이즈 한다.
			this.m_heAtom.style.width = arDiarySize[0];
			this.m_heAtom.style.height = arDiarySize[1];
			
			objSchedulerWindow.resize(arDiarySize[0], arDiarySize[1]);
			
			// 연계된 아톰의 리사이즈 및 위치이동을 수행한다.
			this.m_objResizableObject.commitBoundsStatus(nOffsetHeight, nOffsetWidth);
		}
	}
	else*/
	{
		var objSchedulerWindow = this.m_heAtom.contentWindow;		
		var nStep = objSchedulerWindow.DisplaySizeHandler.getSizeStep(this.m_heAtom.offsetWidth, this.m_heAtom.offsetHeight);
		//TODO 90% 외 디자인 완성 필요.
		var arDiarySize = this._getSizeByStep(1);
		this.m_heAtom.style.width = arDiarySize[0];
		this.m_heAtom.style.height = arDiarySize[1];
		objSchedulerWindow.resize(arDiarySize[0], arDiarySize[1]);
	}
}

WebSchedulerAtom.prototype.getConnectionModelMenu = function ()
{
	var arMenuInfo = new Array();
	arMenuInfo[0] = this.m_strMenuPath;
	arMenuInfo[1] = PQService.getMenuQMX(GetProjectName() + "/" + this.m_strMenuPath);
	
	return arMenuInfo;
}

/**
 * 인자로 받은 값만큼 top을 변경시킨다
 * 
 * @param nRepositionValue (top 변경 값)
 */
WebSchedulerAtom.prototype.repositionYPos = function (nRepositionValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nTop = this.m_heSchedulerButton.offsetTop;
	
	this.m_heSchedulerButton.style.top = (nTop + nRepositionValue) + "px";
}

/**
 * 인자로 받은 값만큼 left를 변경시킨다
 * 
 * @param nRepositionValue (left 변경 값)
 */
WebSchedulerAtom.prototype.repositionXPos = function (nRepositionValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nLeft = this.m_heSchedulerButton.offsetLeft;
	
	this.m_heSchedulerButton.style.left = (nLeft + nRepositionValue) + "px";
}

/**
 * 인자로 받은 값만큼 높이를 변화시킨다
 * 
 * @param nResizeValue (높이 변경 값)
 */
WebSchedulerAtom.prototype.resizeHeight = function (nResizeValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nHeight = this.m_heSchedulerButton.offsetHeight;
	
	this.m_heSchedulerButton.style.height = (nHeight + nResizeValue) + "px";
}

/**
 * 인자로 받은 값만큼 넓이를 변화시킨다
 * 
 * @param nResizeValue (높이 변경 값)
 */
WebSchedulerAtom.prototype.resizeWidth = function (nResizeValue)
{
	// 다이어리 아톰은 위치, 크기이동이 없고 열기/닫기  버튼만 적용된다.
	var nWidth = this.m_heSchedulerButton.offsetWidth;
	
	this.m_heSchedulerButton.style.width = (nWidth + nResizeValue) + "px";
}

/**
 * 다이어리 크기 스탭에 따른 아톰의 크기를 구한다.
 */
WebSchedulerAtom.prototype._getSizeByStep = function (nStep)
{
	switch (nStep)
	{
		case 0 : return new Array(952, 654);
		case 1 : return new Array(860, 598);
		case 2 : return new Array(765, 530);
		case 3 : return new Array(672, 470);
		case 4 : return new Array(580, 405);
	}
}

/**
 * 아톰리스트
 */
WebSchedulerAtom._atoms = new Object();

WebSchedulerAtom.getAtom = function (strVarName)
{
	for (var strKey in WebSchedulerAtom._atoms)
	{
		if (strKey == strVarName)
		{
			var objAtom = WebSchedulerAtom._atoms[strKey];
			
			if (null != objAtom)
			{
				return objAtom;
			}
		}
	}
	return null;
}

WebSchedulerAtom.load = function ()
{
	for (var strVarName in WebSchedulerAtom._atoms)
	{
		var objAtom = WebSchedulerAtom._atoms[strVarName];
		
		if (null != objAtom)
		{
			objAtom.load();
		}
	}
	
}

WebSchedulerAtom.init = function ()
{
	for (var strVarName in WebSchedulerAtom._atoms)
	{
		var objAtom = WebSchedulerAtom._atoms[strVarName];
		
		if (null != objAtom)
		{
			objAtom.init();
		}
	}
}

WebSchedulerAtom.setLoginInfo = function (strID, strPassword)
{
	for (var strVarName in WebSchedulerAtom._atoms)
	{
		var objAtom = WebSchedulerAtom._atoms[strVarName];
		
		if (null != objAtom)
		{
			objAtom.setLoginInfo(strID, strPassword);
		}
	}
}

/**
 * 스케줄러 열기/닫기 버튼클릭
 */
WebSchedulerAtom.onClickButton = function (strVarName)
{
	var objAtom = WebSchedulerAtom._atoms[strVarName];
	if (null != objAtom)
	{
		objAtom.onClickButton();
	}
}

WebSchedulerAtom.resize = function (event)
{
	for (var strVarName in WebSchedulerAtom._atoms)
	{
		var objAtom = WebSchedulerAtom._atoms[strVarName];
		
		if (null != objAtom)
		{
			return objAtom.resize();
		}
	}
}

WebSchedulerAtom.getConnectionModelMenu = function ()
{
	for (var strVarName in WebSchedulerAtom._atoms)
	{
		var objAtom = WebSchedulerAtom._atoms[strVarName];
		
		if (null != objAtom)
		{
			return objAtom.getConnectionModelMenu();
		}
	}
}

WebSchedulerAtom.unLoad = function (bSolutionLogout)
{
	for (var strVarName in WebSchedulerAtom._atoms)
	{
		var objAtom = WebSchedulerAtom._atoms[strVarName];
		objAtom.unLoad(bSolutionLogout);
	}
}

WebSchedulerAtom.isOpen = function ()
{
	var isOpened = false;
	for (var strVarName in WebSchedulerAtom._atoms)
	{
		var objAtom = WebSchedulerAtom._atoms[strVarName];
		if("visible" == objAtom.m_heAtom.style.visibility)
		{
			isOpened = true;
		}
	}

	return isOpened;
}
