window.onload = function(){
	//reSize();
}

window.onresize = function(){
	//reSize();
}

function tabMenu(objNum){
	var tabLink = null;
	for (var i=0; i < 3; i++){
		if (i==objNum) document.getElementById("tabContents"+objNum).style.display = 'block';
		else document.getElementById("tabContents"+i).style.display = 'none';
	}

	document.getElementById("mainTab").src = "/images/main/mnMainTab0" + objNum + ".gif";

	switch (objNum) {
		case 0:
			tabLink = "/board/list.do?boardId=A2NS";
			break;
		case 1:
			tabLink = "/board/list.do?boardId=A2PS";
			break;
		case 2:
			tabLink = "/board/list.do?boardId=A4AT";
			break;
	}

	document.getElementById("tabMoreLink").href = tabLink;
	}



function reSize() {
	var getCHeight = document.body.clientHeight;
	var getSHeight = document.body.scrollHeight;
	if (getCHeight <= getSHeight) document.getElementById('flashLayer').style.height = getSHeight;
	else document.getElementById('flashLayer').style.height = getCHeight;
	var getCWidth = document.body.clientWidth;
	var getSWidth = document.body.scrollWidth;
	if (getCWidth <= getSWidth) document.getElementById('flashLayer').style.width = getSWidth;
	else document.getElementById('flashLayer').style.width = getCWidth;
}

function todaysMarketOpen(){
	//alert();
	if(document.body.offsetHeight > 600)document.getElementById('flashLayer2').style.top = document.body.offsetHeight/2 -280 + "px";
	//window.scroll(0,0);
	var htmlz = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="750" height="560">';
	htmlz += '<param name="movie" value="/images/flashes/todaysMarket.swf">';
	htmlz += '<param name="quality" value="high">';
	htmlz += '<embed src="/images/flashes/todaysMarket.swf" quality="high" pluginspage="www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="750" height="560"></embed></object>';
	document.getElementById('flashLayer2').innerHTML = htmlz;
	document.getElementById('flashLayer').style.display='block';
	document.getElementById('flashLayer2').style.display = 'block';
}

function todaysMarketClose(){
	document.getElementById('flashLayer2').innerHTML = '';
	document.getElementById('flashLayer').style.display='none';
	document.getElementById('flashLayer2').style.display='none';
}

/* Flash load(url, width, height) */
function getFlash(swfName, widLength, heiLength){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+widLength+'" height="'+heiLength+'">');
	document.write('<param name="movie" value="'+swfName+'">');
	document.write('<param name="quality" value="high">');
	document.write('<embed src="'+swfName+'" quality="high" pluginspage="www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+widLength+'" height="'+heiLength+'"></embed></object>');
}

/* Flash load Trans(url, width, height, id) */
function getFlashTrans(swfName, widLength, heiLength, id){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+widLength+'" height="'+heiLength+'" id="'+id+'">');
	document.write('<param name="movie" value="'+swfName+'" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="allowScriptAcess"" value="sameDomain" />');
	document.write('<embed src="'+swfName+'" quality="high" pluginspage="www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+widLength+'" height="'+heiLength+'" allowScript="sameDomain" wmode="transparent" id="'+id+'"></embed></object>');
}

/* com page*/
function layerDisplay(objId){
	var dis = document.getElementById(objId);
	if(dis.style.display != 'inline') dis.style.display = 'inline';
	else dis.style.display = 'none';
}

/*
function tvOpen(swfUrl, idx, code, title){
	var recmdContents = document.getElementById('recmdContents');
	var reCmdSwf = document.getElementById('reCmdSwf');
	var reCmdLink = document.getElementById('reCmdLink');
	var reCmdTit = document.getElementById('reTitle');
	var widLength = '457';
	var heiLength = '205';
	reCmdTit.innerText = title;
	if (recmdContents.style.display == ''){
		var linkValue = 'http://media.miraeasset.com/media.contents.servlet.MediaSvt?media_idx='+ idx + '&code=' + code + '&mode=view&listmode=webzineList';
		var htmlz = '<object id="mainMediaPlayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+widLength+'" height="'+heiLength+'" id="mediaPlayer" >';
		htmlz += '<param name="movie" value="/images/flashes/main/mediaPlayer.swf?swfAddress='+swfUrl + '">';
		htmlz += '<param name="wmode" value="transparent">';
		htmlz += '<param name="quality" value="high">';
		htmlz += '<embed src="/images/flashes/main/mediaPlayer.swf?swfAddress='+swfUrl+ '" quality="high" pluginspage="www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+widLength+'" height="'+heiLength+'" wmode="transparent"  id="mediaPlayer"></></embed></object>';

		reCmdSwf.innerHTML = htmlz;
		reCmdLink.href = 'http://media.miraeasset.com/media.contents.servlet.MediaSvt?media_idx='+ idx + '&code=' + code + '&mode=view&listmode=webzineList';
		reCmdLink.onclick = function(){
			reCmdSwf.innerHTML = '';
			recmdContents.style.display = '';
		}
		recmdContents.style.display = 'inline';
		setLinks(linkValue);
	}
	else {
		reCmdSwf.innerHTML = '';
		recmdContents.style.display = '';
	}
}
*/

function tvOpen(swfUrl, idx, code, title){
//url = 'http://media.miraeasset.com/media.contents.servlet.MediaSvt?media_idx='+ idx + '&code=' + code + '&mode=view&listmode=webzineList';
var opop = window.open(swfUrl,"tvOpen");
opop.target = "_blank";

/*
 var f = document.mediafrm;
 alert(f);
 mediafrm.action = 'http://media.miraeasset.com/media.contents.servlet.MediaSvt';
 mediafrm.media_idx.value = idx;
 mediafrm.code.value = code;
 mediafrm.mode.value = "view";
 mediafrm.listmode.value = "webzineList";
 alert(mediafrm.media_idx.value);
 alert(mediafrm.code.value);
 alert(mediafrm.mode.value);
 mediafrm.target = "_blank";
 mediafrm.submit();
 */
}

function windowOpen(objLink, winTit, wid, hei, scrollyn){

	if (!hei){
		var hei = wid;
		var wid = winTit;
		var winTit = "nullTit";
	}
	if (!scrollyn) {
		scrollyn = 'N';
	}
	window.open(objLink, winTit, 'scrollbars=' + (scrollyn == 'N' ? 'no' : 'yes') + ', status=no,width='+wid+',height='+hei);
}

//popup
function popOpen_getCookie( name )
{
        var nameOfCookie = name + "=";
        var x = 0;
        while ( x <= document.cookie.length )
        {
                var y = (x+nameOfCookie.length);
                if ( document.cookie.substring( x, y ) == nameOfCookie ) {
                        if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
                                endOfCookie = document.cookie.length;
                        return unescape( document.cookie.substring( y, endOfCookie ) );
                }
                x = document.cookie.indexOf( " ", x ) + 1;
                if ( x == 0 )
                        break;
        }
        return "";
}




 /*
if (popOpen_getCookie("pop110711") != "done") {
	window.open('/popup/110711/popup.html','pop110711', 'scrollbars=no, status=no, resize=no, width=270, height=345, left=0, top=0');
}
 */


function sitemapOpen() {
	$("topSitemap").setStyle({
		 height: '290px'
	});
}

function sitemapClose() {
	$("topSitemap").setStyle({
		 height: '30px'
	});
}

function globalFamilyOpen() {
	$("globalFamilyBox").setStyle({
		height: '393px',
		marginTop: '-319px'
	});
}

function globalFamilyClose() {
	$("globalFamilyBox").setStyle({
		height: '74px',
		marginTop: '0'
	});

}

function linksShow(obj) {
	var id = obj;
	$(id).show();
}

function linksHide(obj) {
	var id = obj;
	$(id).hide();
}

function recLinkTo(index) {
	switch(index) {
	case 0 : this.location.href="/board/list.do?boardId=A2PR&cate=01";
		break;
	case 1 : this.location.href="/board/list.do?boardId=A2PR&cate=02";
		break;
	case 2 : this.location.href="/board/list.do?boardId=A2PR&cate=03";
		break;
	case 3 : this.location.href="/board/list.do?boardId=A2PR&cate=04";
		break;

	}
}




function setEmbed(){
	var objId = new String;
	var parameter = new String;
	var clsid = new String;
	var codebase = new String;
	var pluginspage = new String;
	var embedType = new String;
	var src = new String;
	var width = new String;
	var height = new String;
	this.init = function(oSrc, oWidth, oHeight, oId) {
		thisFileName = getFileName(oSrc).split(".")[0];
		thisFileType = getFileName(oSrc).split(".")[1];
		thisFileType = thisFileType.replace(" ", "");

		if (!oId){
			oId = thisFileName;
		}

		switch(thisFileType){
			case "swf" : {
				embedType = "application/x-shockwave-flash";
				mediaType = "flash";
				} break;
			case "wmv" : {
				embedType = "video/x-ms-wmv";
				mediaType = "movie";
				} break;
			case "wma" : {
				embedType = "audio/x-ms-wma";
				mediaType = "movie";
				} break;
			case "mp3" : {
				embedType = "audio/mpeg";
				mediaType = "movie";
				} break;
			case "asf" : {
				embedType = "video/x-ms-asf ";
				mediaType = "movie";
				} break;
			case "avi" : {
				embedType = "video/x-msvideo";
				mediaType = "movie";
				} break;
			case "mpeg" :
			case "mpg" : {
				embedType = "video/mpeg";
				mediaType = "movie";
				} break;
		}

		if (mediaType == "flash"){
			clsid = "D27CDB6E-AE6D-11cf-96B8-444553540000";
			codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0";
			pluginspage = "http://www.macromedia.com/go/getflashplayer";
			parameter += "<param name='quality' value='high'>\n";
		}
		else if (mediaType == "movie"){
			clsid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6";
			codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715";
			pluginspage="http://www.microsoft.com/windows/mediaplayer/download/default.asp";
		}

		if (thisFileType == "mov"){
			clsid="CLSID:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";
			codebase="http://www.apple.com/qtactivex/qtplugin.cab";
			pluginspage="http://www.microsoft.com/windows/mediaplayer/download/default.asp";
			embedType="video/quicktime";
		}

		src = oSrc;
		width = oWidth;
		height = oHeight;
		objId = oId;
	}

	this.param = function(parm , value) {
		parameter += "<param name='"+parm +"' value='"+ value + "'>\n";
	}


	this.show = function(chk) {
		if (clsid){
			obj = '<object classid="clsid:'+ clsid +'" codebase="'+ codebase +'" width="'+ width +'" height="'+ height +'" id="' + objId + '">\n';
			obj += '<param name="src" value="'+ src + '">\n';
			obj += '<param name="url" value="'+ src + '">\n';
			obj += parameter;
			obj += '<!--[if !IE]>-->';
			obj += '<object data="' + src + '" type="' + embedType + '" width="'+ width +'" height="'+ height +'" name="' + objId + '" >';
			obj += '<param name="src" value="'+ src + '">\n';
			obj += parameter;
			obj += 'You need to get the latest <a href="http://www.macromedia.com/go/getflashplayer">Flash Player</a> to see this object.<br />';
			obj += '최신의 <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14157&sliceId=1">플래시 플레이어</a>가 필요합니다.';
			obj += '</object>\n';
			obj += '<!--<![endif]-->';
			obj += '</object>\n';
			//eval("window." + objId + " = document.getElementById('" + objId + "');");
		}

		if(!chk){
			document.write(obj);
		}else{
			chk.innerHTML = obj;
		}
	}
}

function getFileName(uri){
	if(uri.indexOf("#")>0)uri = uri.substr(0,uri.indexOf("#"));
	if(uri.indexOf("&")>0)uri = uri.substr(0,uri.indexOf("&"));
	if(uri.indexOf("?")>0)uri = uri.substr(0,uri.indexOf("?"));
	var thisUriArray = uri.split(/\//);
	var thisFileName = thisUriArray[thisUriArray.length-1];
	return thisFileName;
}

function getSWF(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
		if (window.document[movieName])	return window.document[movieName];
    }
	else {
		if (!window.document[movieName]) return document.getElementById(movieName);
		if(document[movieName].length != undefined)	return document[movieName][1];
    }
}


function IE_HtmlRewrite(objParent) {
	if (window.ActiveXObject && objParent) {
		objParent.innerHTML = objParent.innerHTML;
	}
}

(function($){
//jQuery start
jQuery.fn.chgImg = function(on,options){
	if(this[0] == null) return false;
	var settings = {
		imgType : "gif",
		replaceTxt : "_on"
	}
	settings = $.extend(settings, options || {});
	settings.imgType = "." + settings.imgType;
	settings.replaceTxt = settings.replaceTxt+settings.imgType;
	
	var chkOn = $(this).attr("src").indexOf(settings.replaceTxt) != -1;
	if(on){
		if(chkOn){
			$(this).unbind("mouseout");
			return;
		}else{
			$(this).attr("src",$(this).attr("src").replace(settings.imgType,settings.replaceTxt));
		}
	}else if(chkOn){
		$(this).attr("src",$(this).attr("src").replace(settings.replaceTxt,settings.imgType));
	}
}

jQuery.fn.rolloverImg = function(options){
	var obj = $(this).attr("src") == null ? $("img",this) : this;
	$(obj).hover(function(){
		$(this).chgImg(1,options);
	},function(){
		$(this).chgImg(0,options);
	});
}

/* main visual */
jQuery.fn.mainVisual = function(){
	var o=$(this);
	var oi=o.find("img");
	var len=oi.length;
	var curr=0,dist;

	var imgMove=function(){
		dist = 0;
		move(oi.eq(curr),2000,"",function(){$(this).hide();});
		if(len>curr+1){
			curr += 1;
		}else{
			curr=0;
		}
		dist = 1;
		oi.eq(curr).show().css("opacity","0");;
		move(oi.eq(curr),2000,"");
	}

	function move(el,dur,eas,fn){
		el.stop().animate({opacity:dist},{
			duration:dur,
			easing:eas,
			complete:fn
		});
	}

	oi.eq(curr).show().css("opacity","1");
	setInterval(imgMove,5000);

}

jQuery.fn.familyLink = function(){
	var o,o1,o2,o3;
	var w,h,w2,tw,maxw,tgX,tgY,pdL,pdT,cntX,cntY,z,ease,pre,active;
	o=$(this);o1=$(o).find("li");o2=$(o1).find("img:first");o3=$(o1).find("img.on");
	w=63;h=69;w2=110;twd=61;tw=124;tgX=0;tgY=0;cntX=0;cntY=0;pre=0;
	maxw=w*2,z=1;
	sp=130,ease="easeOutSine",sp2=150,ease2="easeOutSine";
	active=0;

	function defPos(){
		o1.each(function(i){
			if(cntY==0){
				cntX++;
			}else{
				cntX--;
			}
			tgX=(cntX*w);
			tgY=(cntY*h);
			if(i==0){
				$(this).css({left:0,top:tgY});
			}else{
				$(this).css({left:tgX,top:tgY});
			}
			if(cntY==0 && maxw<=tgX){
				cntX=3;
				cntY++;
			}
		});
		o1.eq(0).addClass("unfold").animate({width:tw},sp2,ease2);
		o3.eq(0).css({opacity:0}).show().stop().animate({opacity:1},sp,ease);
	}
	function moving(c){
		var el=o1.eq(c);
		var el_pre=o1.eq(pre);
		var currTop=parseInt(el.css("top"));
		var currLeft=parseInt(el.css("left"));
		var preTop=parseInt(el_pre.css("top"));
		var preLeft=parseInt(el_pre.css("left"));
		o1.each(function(i){
			if(c==i) return;
			var thisTop=parseInt($(this).css("top"));
			var thisLeft=parseInt($(this).css("left"));
			tgX=thisLeft;
			if(thisTop==0){
				tgY=0;
			}else{
				tgY=h;
			}
			if(currLeft<maxw){
				if(thisTop==currTop){
					if(thisLeft+w>maxw){
						tgY=thisTop==0?h:0;
					}else if(thisLeft>currLeft){
						tgX=thisLeft+w;
					}
				}else{
					if(currTop==preTop) return;
					if(thisLeft>=maxw){
						tgX=thisLeft-w;
					}
				}
			}else{
				if(currTop==preTop) return;
				if(thisTop==currTop){
					if(thisLeft-w<0){
						tgY=thisTop==0?h:0;
					}else{
						tgX=thisLeft-w;
					}
				}else{
					if(thisLeft>=maxw) return
					tgX=thisLeft+w;
				}
			}
			if(tgX>maxw){
				tgX=maxw;
			}else if(tgX<0){
				tgX=0;
			}
			//o1.eq(i).css({zIndex:z++});
			o1.eq(i).animate({top:tgY,left:tgX},sp2,ease2);
		});
		setTimeout(function(){
			if(currLeft>=maxw){
				el.animate({left:w,width:tw},sp2,ease2,function(){active=0;});
			}else{
				el.animate({width:tw},sp2,ease2,function(){active=0;});
			}
		},20);
	}
	function unfold(i){
		o1.eq(i).addClass("unfold").css({zIndex:1})
		o2.eq(i).stop().animate({opacity:0},sp,ease);
		o3.eq(i).css({opacity:0}).show().stop().animate({opacity:1},sp,ease);
		moving(i);
	}
	function fold(i){
		el = o1.eq(pre);
		el.removeClass("unfold").animate({width:twd},sp,ease);
		el.find("img:first").stop().animate({opacity:1},sp,ease);
		el.find(".on").stop().animate({opacity:0},sp,ease,function(){
			$(this).hide();
			pre = i;
		});
	}
	function init(){
		defPos();
		o1.each(function(i){
			$(this).mouseover(function(){
				clearTimeout(setTimer);
				if(active || pre == i) return false;
				active=1;
				unfold(i);
				fold(i);
			});
		});
		setTimeout(rolling,timeout);
	}
	
	var setTimer,timeout=4000;
	function rolling(){
		clearTimeout(setTimer);
		if(o.find(".unfold").next().is("li")){
			o.find(".unfold").next().mouseover();
		}else{
			o1.eq(0).mouseover();
		}
		setTimer = setTimeout(rolling,timeout);
	}
	
	o.hover(function(){
		clearTimeout(setTimer);
	},function(){
		clearTimeout(setTimer);
		setTimer = setTimeout(rolling,timeout);
	});
	
	init();
}

jQuery.fn.accordionTab = function(){
	var o = $(this);
	var o_t1 = $(o).find(".tit01");
	var o_t2 = $(o).find(".tit02");
	var o_div = $(o).find("div.con");
	var o_div_last = o_div.filter(":last");
	var a_H = 55;
	var tgH = a_H;
	var o_clk, o_clk_prev, curr;

	var setTimer;
	function rolling(){
		if(o_div.filter(":visible").next()[0] != undefined){
			curr = o_div.filter(":visible").next();
		}else{
			curr = o_div.filter(":first").prev();
		}
		curr.find(".tit01 a").click();
		setTimer = setTimeout(rolling,5000);
	}

	var fn_after = function(){
		o_clk_prev.hide();
	}

	function reset(){
		o_clk_prev = o_div.filter(":visible");
		tgH = 0;
		move(o_clk_prev,400,"easeOutExpo",fn_after);
		o_t1.hide();
		o_t2.show();
		o_clk_prev.prev().find(".tit01").show();
		o_clk_prev.prev().find(".tit02").hide();
	}

	function openEl(){
		reset();
		tgH = a_H;
		move(o_clk,400,"easeOutExpo");
	}

	function move(el,dur,eas,fn){
		el.show().stop().animate({height:tgH},{
			duration:dur,
			easing:eas,
			complete:fn
		});
	}

	function init(){
		o_div.filter(":hidden").height(0);
		setTimer = setTimeout(rolling,5000);
		o_t1.filter(":first").hide();
		o_t2.filter(":first").show();
		o_div.filter(":first").show().height(a_H);
	}


	o.hover(function(){
		clearTimeout(setTimer);
	},function(){
		setTimer = setTimeout(rolling,5000);
	});
	o_t1.find("a").click(function(){
		o_t1 = $(this).parent();
		o_t2 = $(this).parent().next();
		o_clk = $(this).parents("h2").eq(0).next();
		openEl(this);
		return false;
	})

	init();
}

jQuery.fn.verticalRolling = function(options){
	var settings = {
		min : 0,
		spd : 5000,
		dir : "up"
	}
	settings = $.extend(settings, options || {});
	if($("li",this).size()<=settings.min) return false;

	var hgt = -($("li",this).height()+parseInt($("li",this).css("paddingTop"))+parseInt($("li",this).css("paddingBottom")));
	var o = this;
	var el,el2;
	var rollingTime;
	var rolling = function(){
		el = $("li:first",o);
		if(settings.dir == "up"){
			$(el).animate({marginTop:hgt+"px"},500,"easeInOutCubic",function(){$(el).css({marginTop:"0"}).parent().append($(el))});
		}else{
			el2 = $("li:last",o);
			$(el).animate({marginTop:0},500,"easeInOutCubic",function(){$(el2).css({marginTop:hgt+"px"}).parent().prepend($(el2))});
		}

		rollingTime = setTimeout(rolling,settings.spd);
	}
	$(this).hover(function(){
		clearTimeout(rollingTime);
	},function(){
		rollingTime = setTimeout(rolling,settings.spd);
	});
	rollingTime = setTimeout(rolling,settings.spd);
}



function todaysMarkets(){
	var o=$(".worldMap");
	var o_p=o.find(".pos img");
	var o_p2=o.find(".pos2 img");
	var o_t=o.find(".tooltip img");
	var len=o_p.length-1;
	var w,l,t,n=0,n_prev=0;
	function setPos(){
		o_t.each(function(i){
			w=o_t.eq(i).width()/2-4;
			l=parseInt(o_p.eq(i).css("left"))-w;
			t=parseInt(o_p.eq(i).css("top"))-30;
			o_t.eq(i).attr("tgY_d",t)
			 .attr("tgY",t+11)
			 .css({left:l})
			 .css({top:t});
		});
		cycleArea();
	}
	function showArea(i){
		n_prev=n;
		o_p2.eq(i).fadeIn();
		t=o_t.eq(i).attr("tgY");
		o_t.eq(i).css({opacity:0}).animate({opacity:1,top:t},"",function(){
			setTimeout(cycleArea,1500);
		});
	}
	function hideArea(i){
		o_p2.eq(i).fadeOut();
		t=o_t.eq(i).attr("tgY_d");
		o_t.eq(i).animate({opacity:0,top:t},"",function(){showArea(n);});
		//alert(n_prev+" "+n);
	}
	function cycleArea(){
		do{
			n=Math.ceil(Math.random()*len);
		}while(n==n_prev);
		hideArea(n_prev);
	}
	
	function init(){
		setPos();
	}
	init();
	o.click(function(){
		todaysMarketOpen();
	});
}

jQuery.fn.horizontalRolling = function(options){
	var settings = {
		min : 2,
		spd : 5000,
		dir : "left"
	}
	settings = $.extend(settings, options || {});

	var o = this;
	var o_ul = $("ul",this);
	var o_li = $("li",this);

	if(o_li.length<=settings.min) return false;

	var wth = -(o_li.width()+parseInt(o_li.css("paddingLeft"))+parseInt(o_li.css("paddingRight")));
	var el;
	var active=0;
	var rollingTime;
	var rolling = function(){
		active=1;
		el = $("li:first",o);
		if(settings.dir == "left"){
			el.animate({marginLeft:wth+"px"},500,"easeInOutCubic",function(){
				active=0;
				el.css({marginLeft:"0"})
				o_ul.append(el)
			});
		}else{
			el = $("li:last",o);
			o_ul.prepend(el)
			el.css({marginLeft:wth+"px"});
			el.animate({marginLeft:0},500,"easeInOutCubic",function(){
				active=0;
			});
		}
	}

	function loop(){
		rolling();
		rollingTime = setTimeout(loop,settings.spd);
	}

	function init(){
		rollingTime = setTimeout(loop,settings.spd);
		o.hover(function(){
			clearTimeout(rollingTime);
		},function(){
			rollingTime = setTimeout(loop,settings.spd);
		});
	}

	$(nextBtn).click(function(){
		if(!active){
			rolling(settings.dir = "left")
		}
	});

	$(prevBtn).click(function(){
		if(!active){
			rolling(settings.dir = "right")
		}
	});

	init();
}

function loadDataBanner(){
	var o = $(".quickLink");
	function insertItem(item,idx){
		var imgfile = item.attr("imgfile");
		var linkurl = item.attr("linkurl");
		var html=""
		html+='<li><a href="http://'+linkurl+'" target="_blank"><img src="http://www.miraeasset.co.kr/upload/'+imgfile+'" alt="" /></a></li>\n'
		o.append(html);
	};
	
	$.ajax({
		url: "/source/getBannerList.do?bannerType=1",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('ROWS').each(function(i){
				var item = $(this);
				insertItem(item,i);
			});
			$(".quickLink").verticalRolling({min:2,spd:5000});
		}
	});
}

function loadDataProdServ(){
	var o = $(".serviceBox .prodService");
	function insertItem(item,idx){
		var index = item.attr("index");
		var mainimg = item.attr("mainimg");
		var titleimg = item.attr("titleimg");
		var html=""
		html+='<h2 class="mid">\n'
		html+='<div class="tit01"><a href="#"><img src="http://www.miraeasset.co.kr/upload/'+titleimg+'" alt="" /></a></div>\n'
		html+='<div class="tit02">\n'
		html+='<img src="http://www.miraeasset.co.kr/upload/'+titleimg+'" alt="" />\n'
		html+='<p class="more"><a href="/board/list.do?boardId=A2PR&cate=0'+(idx+1)+'"><img src="/images/main/btn_more.gif" alt="more" /></a></p>\n'
		html+='</div>\n'
		html+='</h2>\n'
		html+='<div class="con"><a href="/board/list.do?boardId=A2PR&cate=0'+(idx+1)+'"><img src="http://www.miraeasset.co.kr/upload/'+mainimg+'" alt="" /></a></div>\n'
		
		o.append(html);
	};
	
	$.ajax({
		url: "/source/getRecommendProduct.do",
		dataType: "xml",
		success: function(xml) {
			$(xml).find('ROWS').each(function(i){
				var item = $(this);
				insertItem(item,i);
			});
			o.find("h2:first").attr("class","top");
			o.find("h2:last").attr("class","btm");
			$(".prodService").accordionTab();
		}
	});
}

$(function(){
	$("#mainVisual").mainVisual();
	$(".familyLink").familyLink();
	loadDataBanner();
	loadDataProdServ();
	$(".mediacon").horizontalRolling({spd:5000});
});

$(window).load(function(){
	todaysMarkets();
});

//jQuery end
})(jQuery);


/* Add GA tracking to Chart of the day */
Event.observe(window, 'load', function() {
	if ($$(".jsGaChartEvent").length>0) {
		$$(".jsGaChartEvent")[0].onclick = function(){
			var objDate = $$(".jsGaChartEventDate")[0];
			var innerTxt="";
			if (objDate.textContent) {innerTxt = objDate.textContent;}
			else if (objDate.innerText) {innerTxt = objDate.innerText;}
			else {innerTxt = objDate.innerHTML;}
			var strDate = new Date(innerTxt);
			var lab = strDate.getMonth() + 1;
			lab = strDate.getFullYear() + "-" + lab + "-" + strDate.getDate();
			lab = "Chart of the day: " + lab;
			gaTrackEvent(this, "Click", "Home", lab)
		}
	}
});

Event.observe(window, 'load', function() {
	if ($("jsSlideSet")) {
		var slideSet = Class.create();
		slideSet.prototype = {
			TARGET_PREFIX: "jsSlideTarget",
			TRIGGER_PREFIX: "jsSildeTrigger",
			CLASSNAME: "selected",
			slideInterval: 0,
			isLcoked: false,
			slideShowCur: 0,
			slideShowNext: 1,
			initialize: function(){
				var arrTrigger = $("jsSlideSet").getElementsByClassName(this.TRIGGER_PREFIX);
				var arrTarget = $("jsSlideSet").getElementsByClassName(this.TARGET_PREFIX);
				var curSlideID = arrTarget[0].id; //id of the 1st slide
				for (var i=0; i<arrTrigger.length; i++) {
					arrTrigger[i].onclick = function(){
						clearInterval(slideSet01.slideInterval);
						var slideTargetID = this.id.replace(slideSet01.TRIGGER_PREFIX, slideSet01.TARGET_PREFIX);
						for (var i=0; i<arrTarget.length; i++) {
							if (arrTarget[i].style.zIndex == 200 && arrTarget[i].style.display != "none") {
								curSlideID = arrTarget[i].id;
							}
						}
						if (curSlideID != slideTargetID && !slideSet01.isLcoked) {
							slideSet01.switchSlide( curSlideID, slideTargetID );
						}
						gaTrackEvent(this,'Click','Home','Main visual#');
						return false;
					}
				}
				this.slideInterval = setInterval ( function(){slideSet01.slideShow()}, 7000 );
			},
			slideShow: function(){
				var arrTarget = $("jsSlideSet").getElementsByClassName(this.TARGET_PREFIX);
				this.switchSlide(arrTarget[this.slideShowCur].id, arrTarget[this.slideShowNext].id);
				this.slideShowCur = this.slideShowNext;
				this.slideShowNext++;
				this.slideShowNext = this.slideShowNext>=arrTarget.length?0:this.slideShowNext;
			},
			switchSlide: function(curSlideID, slideTargetID){
				Effect.Appear( $(slideTargetID), {
					beforeStart: function() {
						slideSet01.isLcoked = true;
						var arrTarget = $("jsSlideSet").getElementsByClassName(slideSet01.TARGET_PREFIX);
						for (var i=0; i<arrTarget.length; i++) {
							arrTarget[i].style.zIndex = 100;
						}
						$(slideTargetID).style.zIndex = 200;
						var slideTriggerID = slideTargetID.replace(slideSet01.TARGET_PREFIX, slideSet01.TRIGGER_PREFIX);
						var arrTrigger = $("jsSlideSet").getElementsByClassName(slideSet01.TRIGGER_PREFIX);
						for (var i=0; i<arrTrigger.length; i++) {
							var strClass = arrTrigger[i].className;
							arrTrigger[i].className = strClass.indexOf(slideSet01.CLASSNAME)>-1?strClass.replace(slideSet01.CLASSNAME,""):strClass;
						}
						var strClass = $(slideTriggerID).className;
						$(slideTriggerID).className = strClass.indexOf(slideSet01.CLASSNAME)>-1?strClass:strClass+" "+slideSet01.CLASSNAME;
					},
					afterFinish:function(){
						$(curSlideID).style.display = "none";
						slideSet01.isLcoked = false;
					}
				});
			}
		};
		var slideSet01 = new slideSet();
	}
});

/******* Add GA event tracking INLINE ********
obj: this
cat: default is "Click"
act: default is "All pages".
     If not defined, get from breadcrumb
lab: default is innerHTML of <a>.
     If value ends with "#", it adds the innerHTML of <a> at the end.
*********************************************/
function gaTrackEvent(obj, cat, act, lab) {
	try {
		if (typeof cat=='undefined' || cat=='' ) cat = 'Click';
		if (typeof act=='undefined' || act=='' ) {
			act = 'All pages';
			if ($("titleDiv")) {
				divTitle = $$("#titleDiv .loca")[0];
				if (divTitle.textContent) {
					act = divTitle.textContent;
				} else if (divTitle.innerText) {
					act = divTitle.innerText;
				} else {
					act = divTitle.innerHTML;
				}
			}
		}
		var innerTxt="";
		if (obj.textContent) {
			innerTxt = obj.textContent;
		} else if (obj.innerText) {
			innerTxt = obj.innerText;
		} else {
			innerTxt = obj.innerHTML;
		}
		if (typeof lab=='undefined' || lab=='' ) {
			lab = innerTxt;
		} else if (lab.charAt(lab.length-1)=="#") {
			lab = lab.replace("#", " - ");
			lab += innerTxt;
		}
		pageTracker._trackEvent(cat, act, lab);
		//alert("pageTracker._trackEvent is sent!\n\nCategory: " + cat + "\nAction: " + act + "\nLabel: " + lab)
	}
	catch (err) {
	}
}


