/*INISEAL:[tF2vyZMpt%2BfaiYrmfIgRjQWwD5s%3D%0A]*/
/*****************************************************************************
 * ÆÄÀÏ¸í : pbk-common-ecrm.js
 * ÀÛ¼ºÀÏ : 2008. 04. 19
 * ÀÛ¼ºÀÚ : ej
 * ¼³   ¸í : pbk-common.js¸¦ ±â´Éº° ºÐ¸®.
 * ===========================================================================
 * º¯°æÀÌ·Â:
 * DATE				AUTHOR		DESCRIPTION
 * ---------------------------------------------------------------------------
 * º¯°æ ÀÌ·ÂÀº ÀÌ°÷¿¡ Ãß°¡ ÇÕ´Ï´Ù.
 *****************************************************************************/
/**
 * °³ÀÎÁ¤º¸ °ü·Ã Script Á¤ÀÇ.
 * eCrm ·¹ÀÌ¾î Á¤ÀÇ Áö¿ìÁö ¸¶½Ã¿À.
 */
pbk.common.eCrm = function(){
	return{
		open : {
			//popupId : null,
			//linkObj : null,
			//adjustX : 0,
			//adjustY : 0,
			ecrm : function(popupId, linkObj, adjustX, adjustY, name, contentId, content) {
				if(name != undefined){
					var cookStr = name+"=done";
					if ( document.cookie.indexOf(name,"done") < 0 ){    	
					//linkObjId : String,layerId : String, adjustX :Number, adjustY : Number
		            	$(popupId).hide();		
		                $(popupId).show();
		                
		                //pbk.myhana.eCrm.open.popupId = popupId	
						//pbk.myhana.eCrm.open.linkObj = linkObj;
		                //pbk.myhana.eCrm.open.adjustX=  adjustX;
		                //pbk.myhana.eCrm.open.adjustY = adjustY;
	                
		                var position = Position.cumulativeOffset(linkObj);
		            }else{
		            	$(popupId).hide();
	            	}
	            }else{
		            	$(popupId).hide();		
		                $(popupId).show();
	                
		                var position = Position.cumulativeOffset(linkObj);
	            }
			},
			close : function(popupId) {
				$(popupId).style.display="none";
			},
			/**
	             * ÄíÅ°¸¦ ÀúÀåÇÑ´Ù.
	             * @param name ÄíÅ° ÀÌ¸§
	             * @param value ÄíÅ° °ª
	             * @param expires ÄíÅ°ÀÇ À¯È¿ ÀÏ
	             * @param path
	             * @param domain
	             * @param secure
	             */
			setCookie: function(name){
				/*name, value, expires, path, domain, secure*/
				cookie.setCookie(name, "done", cookie.getExpDate(0,24,0),'/','.hanabank.com');
			}
		},
		
		/**
		 * _utl Àº È£½ºÆ® ex) http://59.11.68.70 ºÎºÐÀº »©°í ³Ö´Â´Ù. ex) /a/pwn?default=http://111.60.3.31:8180/resource/images/common/blank.gif&ck=&m=10001&z=10001&s=&c=&id=<s:property value="%{loginSession.custInfo.custNo}"/>
		 * @param {Object} oIframe
		 * @param {Object} _url
		 */
		setEcrmToIframe : function(oIframe, _url) {
			alert("@deprecated : »èÁ¦¿¹Á¤");
			//È£½ºÆ®°¡ Á×¾îµµ ¹«½Ã¸¦ ÇÑ´Ù.
			var oSendForm = form.createForm([{id:'contentURL', value: eCrmHost+_url} , {id:'hostKilledIgnore', value: true}]);
			
			var hanaAjax = new hana.JHanaAjax('', false, true);
			hanaAjax.ajaxSubmit(pbk.APPLICATION_CONTEXT_ROOT 
					+ '/common/getRemoteSiteContent.do'
					, oSendForm
					, true
					, function(res, arg) {
						var resData = eval('(' + res.responseText + ')');
						var _content = resData.content;
						var _resCode = parseInt(resData.responseCode,10);
						
						if (_resCode >= 200 && _resCode <= 299){	//ÀÀ´äÄÚµå 200~299 ±îÁö°¡ Á¤»ó
							if(oIframe != null) {
							oIframe.document.body.innerHTML = _content;
							}
							pbk.common.eCrm.logingComplete();
							
							var innerDocument = window.frames['eCrmFrame'].document;
							
							if (innerDocument.forms['eCrmInfo'] != null && innerDocument.forms['eCrmInfo'] != undefined){
								//eCrm »çÀÌÁî Á¤º¸°¡ ÀÖÀ»°æ¿ì
								if (innerDocument.forms['eCrmInfo'].width != null && innerDocument.forms['eCrmInfo'].width != undefined){
									$('eCrmFrame').style.width = innerDocument.forms['eCrmInfo'].width.value;
								}
								
								if (innerDocument.forms['eCrmInfo'].height != null && innerDocument.forms['eCrmInfo'].height != undefined){
									$('eCrmFrame').style.height = innerDocument.forms['eCrmInfo'].height.value;
								}
								
							} else if (innerDocument.images.length == 1){	//ÀÌ¹ÌÁö°¡ 1°³ÀÎ°æ¿ì
								//ÀÌ¹ÌÁöÀÇ »çÀÌÁî¿¡ ¸Â°Ô iframeÀ» Á¶Á¤ÇÑ´Ù.
								var imgInfo = new Image();
							    imgInfo.src = innerDocument.images[0].src;
								$('eCrmFrame').style.width = imgInfo.width;
								$('eCrmFrame').style.height = imgInfo.height;
							}
						}
						
					} //[end] callback
					, 'EUC-KR');
		},
		
		setEcrmToDiv : function(_div, _url) {
			//È£½ºÆ®°¡ Á×¾îµµ ¹«½Ã¸¦ ÇÑ´Ù.
			var oSendForm = form.createForm([{id:'contentURL', value: eCrmHost+_url} , {id:'hostKilledIgnore', value: true}]);
			
			var hanaAjax = new hana.JHanaAjax(_div, false, true);
			hanaAjax.ajaxCommSubmit(pbk.APPLICATION_CONTEXT_ROOT 
					+ '/common/getRemoteSiteContentJSP.do'
					, oSendForm);
		},
		
		// Á¤»óÀÀ´äÀÎ°æ¿ì
		logingComplete : function(){
			
		},
		
		// ºñÀü»ó ÀÀ´äÀÎ°æ¿ì
		getRemoteSiteContentFail : function(){
			if ($('eCrmDefaultImg') != null && $('eCrmDefaultImg') != undefined){
				$('eCrmDefaultImg').style.display = '';	//µðÆúÆ® ÀÌ¹ÌÁö¸¦ º¸¿©ÁØ´Ù.	
			}
		}
	}
}();

