//±Ý¹é¸®´º¾ó ¿ìÃøÄü¿µ¿ª ÇÃ·¡½¬ ÀÎÅÍÆäÀÌ½º
function doActionByQuickmenu(actor){
	if(actor == "PRINT_ALL"){				//ÀüÃ¼ÀÎ¼â
		//hidePrimaryServiceByPrint();
		print_all();
	} else if(actor == "PRINT_PART"){	//ºÎºÐÀÎ¼â
		//hidePrimaryServiceByPrint();
		print_part();
	} else if(actor == "ASSET"){				//ÀÚ»êÇöÈ²
		location.href = "/xecureBridge.jsp?url=/newonline/asset/asset_all.jsp";
	} else if(actor == "TRANSFER"){		//ÀÚ±ÝÀÌÃ¼
		//location.href = "/index.jsp?returnUrl=/wts/webDeskGateway.jsp%3FreturnUrl%3D%2Fonlinewicket%2Ftransfer%2Ftransfer_step1.jsp";
	//	location.href = "/xecureBridge.jsp?url=/newonline/transfer/transfer_step1.jsp";
	//	location.href = "/newonline/transfer/transfer_step1.jsp";

		location.href = "/xecureBridge.jsp?url=/newonline/transfer/transfer_step1.jsp";
	} else if(actor == "TODAY"){			//¿À´Ãº»»óÇ°(¸ñ·Ï)
		return getTodayProducts();
	} else if(actor == "COMPARE"){			//ºñ±³ÇÏ±â
		//ÇÔ¼öÁ÷Á¢È£Ãâ
	} else if(actor == "WISH_ADD"){		//°ü½É»óÇ°µî·Ï
		//ÇÔ¼öÁ÷Á¢È£Ãâ
	} else if(actor == "WISH_VIEW"){		//°ü½É»óÇ°°¡±â
		location.href = "/newmall/wish/wish01.jsp";
	} else{	//¿µ¾÷Á¡¾È³»
		popup("http://truefriend.chzero.com/search.jsp", "tBranchPopup", 870, 620, "no");
	}
}

function addToMyProductList_newmall(param) {
	
	var arr = param.split(";");
	if(arr.length != 2) {
		alert("»óÇ°°ª¿¡ ¿À·ù°¡ ÀÖ½À´Ï´Ù.");
		return;
	}
	
	var iframeName = "TodayProductAddFrame";
	var targetFrame = document.all[iframeName];
	var targetUrl = "about:blank";
	if (arr[1]=="F") {
		targetUrl = "/newmall/wish/wish_tr.jsp?mode=insert&productKind=F&chk="+arr[0];
	} else if (arr[1]=="R") {
		targetUrl = "/newmall/wish/wish_tr.jsp?mode=insert&productKind=R&chk="+arr[0];
	}
	
	if (!targetFrame) {
		var iframe = document.createElement("IFRAME");
		iframe.name = iframeName;
		iframe.src = targetUrl;
		iframe.style.width = "1px";
		iframe.style.height = "1px";
		document.body.appendChild(iframe);
	} else {
		window.open(targetUrl,iframeName,"");
	}
}

function compareCheckedProducts_newmall(param) {
	var products = param.split("|");
	if (products.length==0) {
		alert("ºñ±³ÇÒ »óÇ°À» ¼±ÅÃÇÏ¼¼¿ä.");
		return;
	} else if (products.length<2) {
		alert("ºñ±³ÇÒ »óÇ°À» ÃÖ¼ÒÇÑ 2°³ÀÌ»ó ¼±ÅÃÇÏ¼Å¾ß ÇÕ´Ï´Ù.");
		return;
	}
	
	var badIndex = "";
	var isFund = true;
	var chk = "";
	for (var i=0; i<products.length; i++) {
		if (chk!="") chk += "&";
		chk += "chk="+products[i];
	}
	
	window.open("/newmall/product/fund/popup_com.jsp?"+chk, "popWin", "width=780, height=550, toolbar=no, scrollbars=yes, resizeble=yes");	
}

function goTodayProduct(type, id) {
//	alert("type : "+type+", id : "+id);
	
	var sViewPageUrl = "";
	if(type == "F") {
		sViewPageUrl = "/newmall/product/fund/fund_view.jsp?pfundCd="+id;
	} else if(type == "E") {
		sViewPageUrl = "/newmall/product/els/els_view.jsp?num="+id;
	} else if(type == "R") {
		sViewPageUrl = "/newmall/product/rap/product/pro_view.jsp?num="+id;
	}

	if(sViewPageUrl == "") {
		alert("Àß¸øµÈ Á¤º¸ÀÔ´Ï´Ù.");
	} else {
		location.href = sViewPageUrl;
	}
}

function goThisTodayProduct(sType, sCode, sOption) {
	var sViewPageUrl = "";
	if (sType=="F") {
		if (sOption=="FOREIGN") {
			sViewPageUrl = "/mall/product/fund/foreign_fund_view.jsp?pfundCd="+sCode+"&fundType=FOREIGN";
		} else {
			sViewPageUrl = "/mall/product/fund/fund_view.jsp?pfundCd="+sCode+"&fundType=DOMESTIC";
		}
	} else if (sType=="E") {
		sViewPageUrl = "/mall/product/els/pro_intro.jsp?num="+sCode;
	} else if (sType=="R") {
		sViewPageUrl = "/mall/product/rap/product/pro_view.jsp?num="+sCode;
	}
	if (sViewPageUrl=="") {
		alert("Àß¸øµÈ Á¤º¸ÀÔ´Ï´Ù.");
	} else {
		location.href = sViewPageUrl;
	}
}

//¿À´Ãº»»óÇ° ÄíÅ° °¡Á®¿À±â
function getTodayProducts() {
	var sViewProductCookieFoot = Get_Cookie("sViewProductCookie");
	var rtnStr = "";
	if(sViewProductCookieFoot != null && sViewProductCookieFoot != '' && sViewProductCookieFoot != 'null') {
		var sViewProductCookieArray = sViewProductCookieFoot.split(";");
		if(sViewProductCookieArray != 'null' && sViewProductCookieArray != null && sViewProductCookieArray.length > 0) {
			for(var j=0;j<sViewProductCookieArray.length;j++) {
				var sViewProductArray2 = sViewProductCookieArray[j].split("|");
				if(sViewProductArray2.length == 3) {
					rtnStr += (j == 0) ? "" : ";";
					if(sViewProductArray2[1].indexOf("/") >= 0) {
						rtnStr += sViewProductArray2[1].split("/")[0];
					} else {
						rtnStr += sViewProductArray2[1];
					}
					rtnStr += "|"+sViewProductArray2[0]+"|";
					rtnStr += sViewProductArray2[2].replace(/%26nbsp%3B/gi, " ");
				}
			}
		}
	} 
	return rtnStr;
}


//ÁÖ¿ä¼­ºñ½º|¿À´Ãº»»óÇ° ÇÃ·¡½¬ÇÚµé¸µ///////////////////////////////////////////////////////////////////////////////////////////////////
function getSWF(flashName){
	if (navigator.appName.indexOf("Microsoft") != -1){
		return window[flashName];
	} else{
		return document[flashName];
	}
}

/*
<ÁÖ¿ä¼­ºñ½º º¸ÀÓ>
*/
function showMainTradeServiceFlash(){
	try{
		hideTodayViewProductFlash();
		if(getSWF('primary_service').width > 1){
			hideMainTradeServiceFlash();
		} else{
			document.getElementById('divPrimaryServiceFlashIframe').style.display = 'inline';
			getSWF('primary_service').width = 963;
			getSWF('primary_service').height = 221;
			getSWF('primary_service').startFlash();
		}
	} catch(e){}
}

/*
<ÁÖ¿ä¼­ºñ½º ¼û±è>
*/
function hideMainTradeServiceFlash(){
	try{
		getSWF('primary_service').closeFlash();
		getSWF('primary_service').width = 1;
		getSWF('primary_service').height = 1;
		document.getElementById('divPrimaryServiceFlashIframe').style.display = 'none';
	} catch(e){}
}

/*
<¿À´Ãº»»óÇ° º¸ÀÓ>
*/
function showTodayViewProductFlash(){
	try{
		hideMainTradeServiceFlash();
		if(getSWF('todayview_product').width > 1){
			hideTodayViewProductFlash();
		} else{
			document.getElementById('divTodayViewProductFlashIframe').style.display = 'inline';
			getSWF('todayview_product').width = 382;
			getSWF('todayview_product').height = 210;
			getSWF('todayview_product').startFlash();
		}
	} catch(e){}
}

/*
<¿À´Ãº»»óÇ° ¼û±è>
*/
function hideTodayViewProductFlash(){
	try{
		getSWF('todayview_product').closeFlash();
		getSWF('todayview_product').width = 1;
		getSWF('todayview_product').height = 1;
		document.getElementById('divTodayViewProductFlashIframe').style.display = 'none';
	} catch(e){}
}

//[TODO REMOVE]ÀÓ½Ã°Ô½ÃÆÇ¿¬°á
function goTestFeedback(){
	var linemap = document.getElementById('historyArea');
	try{
		popup('http://210.96.164.80/csound/login.asp', 'tCustomerFeedback', 800, 600, 'yes');
	} catch(e){}
}


//ÁÖ¿ä¼­ºñ½º|¿À´Ãº»»óÇ° ÇÃ·¡½¬ÇÚµé¸µ///////////////////////////////////////////////////////////////////////////////////////////////////

//¿À¸¥ÂÊ Äü¸Þ´º
document.write('<div style="position:absolute;top:160px;left:965px;">');
document.write('	<ul class="img_list">');
document.write('		<li><img src="/images/new_common/main_tradservice.gif" alt="ÁÖ¿ä°Å·¡¼­ºñ½º" style="cursor:hand;" onclick="showMainTradeServiceFlash();" /><li>');
document.write('		<li><img src="/images/new_common/today_viewproduct.gif" alt="¿À´Ãº»»óÇ°" style="cursor:hand;" onclick="showTodayViewProductFlash();" /><li>');
document.write('	</ul>');
document.write('</div>');
document.write('<div id="divPrimaryServiceFlashIframe" style="position:absolute;top:158px;left:5px;width:953px;height:200px;filter:alpha(opacity=0);display:none;"><iframe src="" width="100%" height="100%" border="0" frameborder="0" marginwidth="0" marginheight="0" style="filter:alpha(opacity=0);"></iframe></div>');
document.write('<div id="divPrimaryServiceFlash" style="position:absolute;top:158px;left:5px;display:inline;">');
document.write('	<script type="text/javascript">');
document.write('		printFlashEmbedTag("primary_service", "/images/newmall/flash/mainTradeService.swf", "1", "1", "wmode=transparent");');
document.write('	</script>');
document.write('</div>');
document.write('<div id="divTodayViewProductFlashIframe" style="position:absolute;top:158px;left:584px;width:372px;height:200px;filter:alpha(opacity=0);display:none;"><iframe src="" width="100%" height="100%" border="0" frameborder="0" marginwidth="0" marginheight="0" style="filter:alpha(opacity=0);"></iframe></div>');
document.write('<div id="divTodayViewProductFlash" style="position:absolute;top:158px;left:584px;display:inline;">');
document.write('	<script type="text/javascript">');
document.write('		printFlashEmbedTag("todayview_product", "/images/newmall/flash/todayViewProduct.swf", "1", "1", "wmode=transparent");');
document.write('	</script>');
document.write('</div>');
document.write('<div style="position:absolute;top:300px;left:960px;" id="newmall_quick">');
document.write('	<img src="/images/new_common/right_quick.gif" alt="" usemap="#right_quick" /><br />');
document.write('</div>');
//¸Ê ¸µÅ©
document.write('<map name="right_quick">');
document.write('<area alt="ÀÎ¼âÇÏ±â" coords="4,18,33,35" href="#" onclick="doActionByQuickmenu(\'PRINT_ALL\');" />');
document.write('<area alt="ºÎºÐÀÎ¼â" coords="4,37,33,54" href="#" onclick="doActionByQuickmenu(\'PRINT_PART\');" />');
document.write('<area alt="ÀÚ»êÇöÈ²" coords="4,85,33,101" href="#" onclick="doActionByQuickmenu(\'ASSET\');" />');
document.write('<area alt="ÀÚ±ÝÀÌÃ¼" coords="4,103,33,119" href="#" onclick="doActionByQuickmenu(\'TRANSFER\');" />');
document.write('<area alt="°ü½É»óÇ°" coords="4,121,33,152" href="#" onclick="doActionByQuickmenu(\'WISH_VIEW\');" />');
document.write('<area alt="¿µ¾÷Á¡¾È³»" coords="4,214,33,242" href="#" onclick="doActionByQuickmenu(\'BRANCH\');" />');
document.write('<area alt="top" coords="1,252,39,268" href="#" />');
document.write('</map>');
//ÁÖ¿ä¼­ºñ½º|¿À´Ãº»»óÇ° ÇÃ·¡½¬ÇÚµé¸µ///////////////////////////////////////////////////////////////////////////////////////////////////


function FloatObject() {
	// Constant
	this.TOP_SPACE = 60;
	this.SPEED = 10;

	// Attribute
	this.objName = "";
	this.posX = 0;
	this.posY = 0;
	this.scrollHeight = 0;
	this.objHeight = 0;
	this.obj = null;
	this.objWidth = 0;
	this.contentWidth = 965;
}

FloatObject.prototype.main = function(objname, posX, posY) {
	this.initObj(objname, posX, posY);

	var obj = this.getRef();
	obj.style.top = document.body.scrollTop + posY;
	obj.style.visibility = "visible";

	obj.style.left = document.body.clientWidth-this.objWidth;
	window.setInterval(this.objName+".calXYBanner()", 10);
}

FloatObject.prototype.getRef = function() {
	var isDOM = (document.getElementById ? true : false);
	var isIE4 = ((document.all && !isDOM) ? true : false);
	var isNS4 = (document.layers ? true : false);
	var isNS = navigator.appName == "Netscape";

	if(isDOM) return document.getElementById(this.objName);
	if(isIE4) return document.all[this.objName];
	if(isNS4) return document.layers[this.objName];
}

FloatObject.prototype.initObj = function(objname, posX, posY) {
	this.objName = objname;
//	this.posX = posX;
	this.posX = this.contentWidth;
//	this.objWidth = posX;
	this.posY = posY;
	this.scrollHeight = document.body.scrollHeight;
	this.objHeight = this.getRef().offsetHeight;
	this.obj = this.getRef();
}

FloatObject.prototype.calXYBanner = function() {
	var obj = this.obj;
	obj.style.left = this.posX;
//	var xVal = document.body.clientWidth - this.objWidth;
//	obj.style.left = (xVal < this.contentWidth) ? this.contentWidth : xVal;
//	obj.style.left = xVal;
	var yBannerPos, yScrollTopPos;
	var yLimitPos; 
	var interval;
	var yNewPos;
	var yNewTop;
	var dHeight = this.posY;
	yScrollTopPos = parseInt(document.body.scrollTop, 10);
	yBannerPos = parseInt(obj.style.top, 10);
	
	if(document.body.scrollTop < dHeight) {
		yLimitPos = dHeight;
	} else {
		yLimitPos = document.body.scrollTop + this.TOP_SPACE;
	}

	
	if(yBannerPos != yLimitPos) {
		yNewPos = Math.ceil(Math.abs(yLimitPos - yBannerPos) / this.SPEED);
		
		if(yLimitPos < yBannerPos) {
			yNewPos = -yNewPos;
		}

		yNewTop = parseInt(obj.style.top, 10) + yNewPos;
//		if( (yNewTop+this.objHeight) > document.body.scrollHeight-document.getElementById("Footer_Area").offsetHeight) {
//			obj.style.top = document.body.scrollHeight - document.getElementById("Footer_Area").offsetHeight - this.objHeight;
//		} else {
//			obj.style.top = yNewTop;
//		}
		obj.style.top = yNewTop;
	}
}

var newmall_quick = new FloatObject();
newmall_quick.main("newmall_quick", 64, 250);		//µÎ¹øÂ° ÀÎÀÚ´Â leftÀ§Ä¡°¡ ¾Æ´Ô. Äü divÀÇ ³ÊºñÀÓ. ÄüÀÇ left´Â È­¸é³Êºñ-Äü³Êºñ.
