// png24 at ie6.0
function setPng24(obj) {
    obj.width=obj.height=1;
    obj.className=obj.className.replace(/\bpng24\b/i,'');
    obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
    obj.src='';
    return '';
}


// font size
function FontPlus1(uid){
    var l = document.getElementById('entireWrap');
    var nSize = l.style.fontSize   ? l.style.fontSize   : '9pt';
    var iSize = parseInt(nSize.replace('pt',''));
    
    if (iSize < 13)
    {
        l.style.fontSize   = (iSize + 1) + 'pt';
        //l.style.lineHeight = '140%';
    }
}


function FontMinus1(uid){
    var l = document.getElementById('entireWrap');
    var nSize = l.style.fontSize ? l.style.fontSize : '9pt';
    var iSize = parseInt(nSize.replace('pt',''));
    
    if (iSize > 8)
    {
        l.style.fontSize = (iSize - 1) + 'pt';
        //l.style.lineHeight = '140%';
    }
}
function FontBasic(uid){
    var l = document.getElementById('entireWrap');
    var nSize = l.style.fontSize ? l.style.fontSize : '9pt';
    var iSize = parseInt(nSize.replace('pt',''));
    
        l.style.fontSize = 9 + 'pt';
}


function winopen(url,wdt,hgt,scl)
{
	/*
	// url : ÆË¾÷ url
	// wdt : ÆË¾÷ width °ª  
	// hgt : ÆË¾÷ height °ª
	// scl : ½ºÅ©·Ñ ¿©ºÎ (yes ¶Ç´Â no)
	*/ 
	var wleft = (screen.width-wdt)/2;
	var wtop = ((screen.height-hgt)/2)-50;
	var win = window.open (url,"winopen","width="+wdt+",height="+hgt+",left="+wleft+",top="+wtop+",scrollbars="+scl);
	win.focus();
}


function statePop(flag)
{	
	var layerState=document.getElementById('statePopLayer'+flag).style.display; 
	document.getElementById('statePopLayer'+flag).style.display=(layerState=='none')?'block':'none';
}



function calendar(obj,tg) 
{
    var tmpDisplay, oTagPosi, oWidth, oHeight, tmpX, tmpY;
    var oCal, calX, calY;

    try 
    {
        oCal = document.getElementById('calendarWrap');
        tmpDisplay = oCal.style.display;

        // ´Þ·ÂÀ» Ç¥½ÃÇÒ À§Ä¡ °¡Á®¿À±â
        oTagPosi = tagPosiXY(obj);
        oWidth = obj.width;
        oHeight = obj.height;
        tmpX = oTagPosi.left;
        tmpY = oTagPosi.top + oHeight;

        // Çö ´Þ·Â À§Ä¡ °¡Á®¿À±â
        calX = oCal.style.left.replace("px","");
        calY = oCal.style.top.replace("px", "");

        //´Þ·Â À§Ä¡ ÀÌµ¿.
        document.getElementById('calendarWrap').style.left = tmpX + "px";   // ´Þ·Â XÀ§Ä¡
        document.getElementById('calendarWrap').style.top = tmpY + "px";    // ´Þ·Â YÀ§Ä¡

        //°°Àº ÆäÀÌÁö³»¿¡ 1°³ ÀÌ»óÀÇ ´Þ·Â »ç¿ë½Ã ¸®ÅÏ¿µ¿ª ID°ªÀ» ¹Þ¾Æ ´Ù½Ã ºÒ·¯¿È.
        if (tg != "") {
            ifrmNode = "";
            ifrmSrc = "";
            tmpIFrmSrc = "";
            oNode = document.getElementById("calendarWrap");
            lng = oNode.childNodes.length;

            // iframe Ã£±â
            for (i = 0; i < lng; i++) {
                if (oNode.childNodes[i].tagName == "IFRAME") {
                    ifrmNode = oNode.childNodes[i];
                    ifrmSrc = oNode.childNodes[i].src;
                    break;
                }
            }

            // iframe.src ÀçÁ¤ÀÇ
            if (ifrmNode != "") {
                tmpFindPosi = ifrmSrc.indexOf("&rtnTxtNM");

                if (tmpFindPosi > -1) {
                    tmpIFrmSrc = ifrmSrc.substr(0, tmpFindPosi);
                    ifrmSrc = ifrmSrc.substr(tmpFindPosi + 9, ifrmSrc.length);
                    tmpFindPosi = ifrmSrc.indexOf("&");
                    if (tmpFindPosi > -1) {
                        tmpIFrmSrc += ifrmSrc.substr(tmpFindPosi, ifrmSrc.length);
                    }

                    ifrmSrc = tmpIFrmSrc;
                }

                ifrmNode.src = ifrmSrc + "&rtnTxtNM=" + tg;
            }
        }

        // ´Þ·Â Ç¥½Ã
        if (tmpDisplay == "block") {
            // ´Ù¸¥ À§Ä¡¿¡¼­ ´Þ·Â È£Ãâ½Ã À§Ä¡¸¸ º¯°æÇÔ.
            if (tmpX == calX && tmpY == calY) {
                document.getElementById('calendarWrap').style.display = "none";
            }
        } else {
            document.getElementById('calendarWrap').style.display = "block";
            ifmCalResize();
        }

    } catch (e) { }
}

// Å¬¸¯ÇÑ ÅÂ±× À§Ä¡°ª
function tagPosiXY(aTag)
{
	var leftPosi = 0;
	var topPosi = 0;
	var oTagPosi = new Object;

	leftPosi += aTag.offsetLeft;
	topPosi += aTag.offsetTop;
	do {
	    aTag = aTag.offsetParent;
		leftPosi += aTag.offsetLeft;
		topPosi += aTag.offsetTop;
	} while(aTag.tagName!="BODY");

	oTagPosi.left = leftPosi;
    oTagPosi.top = topPosi;

    return oTagPosi;
}



function expLayer(flag,ord,gubun,cnt){

	if (flag == 'show'){
	    for(var i = 0; i < cnt ; i++){
		if(ord == i){
		document.getElementById('expLayerWrap_'+i).style.display = "block";
	    }else{
	    document.getElementById('expLayerWrap_'+i).style.display = "none";
	    }
	    }
	} else if ( flag == 'hide'){
	
		document.getElementById('expLayerWrap_'+ord).style.display = "none";
	}
}

function goOut(ord){

    document.getElementById('expLayerWrap_'+ord).style.display = "none";
}
function goIn(ord){

    document.getElementById('expLayerWrap_'+ord).style.display = "block";
}
function addClass(element,value) {
  if (!element.className) {
    element.className = value;
  } else {
    newClassName = element.className;
    newClassName+= " ";
    newClassName+= value;
    element.className = newClassName;
  }
}

 
function stripeTables() {
	var selTbl = document.getElementById("striped");
	var tbodies = selTbl.getElementsByTagName("tbody");
	for (var i=0; i<tbodies.length; i++) {
		var odd = true;
		var rows = tbodies[i].getElementsByTagName("tr");
		for (var j=0; j<rows.length; j++) {
			if (odd == false) {
				odd = true;
			} else {
				addClass(rows[j],"odd");
				odd = false;
			}
		}
	}
}

function highlightRows() {
  var selTbl = document.getElementById("striped");
  var tbodies = selTbl.getElementsByTagName("tbody");
  for (var j=0; j<tbodies.length; j++) {
     var rows = tbodies[j].getElementsByTagName("tr");
     for (var i=0; i<rows.length; i++) {
           rows[i].oldClassName = rows[i].className
           rows[i].onmouseover = function() {
              if( this.className.indexOf("selected") == -1)
                 addClass(this,"highlight");
           }
           rows[i].onmouseout = function() {
              if( this.className.indexOf("selected") == -1)
                 this.className = this.oldClassName
           }
     }
  }
}
 
function stripeTablesDl() {
	var selTbl = document.getElementById("overStyle");
	var tbodies = selTbl.getElementsByTagName("ul");
	for (var i=0; i<tbodies.length; i++) {
		var odd = true;
		var rows = tbodies[i].getElementsByTagName("li");
		for (var j=0; j<rows.length; j++) {
			if (odd == false) {
				odd = true;
			} else {
				addClass(rows[j],"odd");
				odd = false;
			}
		}
	}
}

function highlightRowsDl() {
  if(!document.getElementsByTagName) return false;
  var selTblHigh = document.getElementById("overStyle");
  var tbodies = selTblHigh.getElementsByTagName("ul");
  for (var j=0; j<tbodies.length; j++) {
     var rows = tbodies[j].getElementsByTagName("li");
     for (var i=0; i<rows.length; i++) {
           rows[i].oldClassName = rows[i].className
           rows[i].onmouseover = function() {
              if( this.className.indexOf("selected") == -1)
                 addClass(this,"highlight");
           }
           rows[i].onmouseout = function() {
              if( this.className.indexOf("selected") == -1)
                 this.className = this.oldClassName
           }
     }
  }
}

function whoBuy(){
	var addrUri = document.getElementById('addr').href;
	var winWidth = 620;
	var winHeight = 600;
	var locLeft = Math.round(( screen.width / 2 ) - ( winWidth / 2 ));
	var locTop = Math.round(( screen.height / 2 ) - ( winHeight / 2 ));
	
	window.open(addrUri, 'popId', 'width='+winWidth+', height='+winHeight+', left='+Math.round(( screen.width / 2 ) - ( winWidth / 2 ))+', top='+Math.round(( screen.height / 2 ) - ( winHeight / 2 )));
}

window.onload = function () {
    if (document.getElementById("striped")) {
        stripeTables();
        highlightRows();
    } else if (document.getElementById("overStyle")) {
        stripeTablesDl();
        highlightRowsDl();
    }
    //highlightRows();
    // Àü¹®°¡¹æ¼ÛÀÇ »óÀ§ ¸Þ´º ·ÎµùÀ» À§ÇÔ
    //try {
    //    bannerLoading();
    //} catch (e) { }
}


/* image rollover script */
// Àü¹®°¡ ¹æ¼Û »ó´Ü ¹è³Ê ÄÁÆ®·Ñ
function proBannerOn(obj,nb) {
    var tmpNaviImgNM = "tBannerNavi", tmpTopBannerDiv = "topBanner";
    var tmpThisImgNM = obj.src;
    var tmpImgLng = document.getElementsByName(tmpNaviImgNM).length;
    var i;

    for (i = 0; i < tmpImgLng; i++) {
        document.getElementsByName(tmpNaviImgNM)[i].src = document.getElementsByName(tmpNaviImgNM)[i].src.replace("on.gif", "off.gif");
    }
    obj.src = obj.src.replace("off.gif", "on.gif");
    document.getElementById(tmpTopBannerDiv).innerHTML = topBannerVal(nb);
}
function menuOff(imgEl) {
	imgEl.src = imgEl.src.replace("on.gif", "off.gif");
}


/* ¸ÆÂ÷Æ® ´Ù¿î·Îµå */
function macChartDown() {
    var url = "/chart_mac/download/download.asp";

    var xmlRequest = createHttpRequest();
    if (xmlRequest == null) return;

    xmlRequest.open("GET", url, "true");
    xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=euc-kr");
    xmlRequest.send("");        //´Ù¿î·Îµå Áõ°¡ Ã³¸®¸¸ ÇÔ.

    location.href = "/chart_mac/download/MACchart_v100203.exe";
}



var menuArr = new Array(8);
menuArr[1] = "news";
menuArr[2] = "broad";
menuArr[3] = "price";
menuArr[4] = "invest";
menuArr[5] = "counselling";
menuArr[6] = "expert";
menuArr[7] = "platinum";

var menuCnt = 8;
var menuOrder = 0;
function chkMenuOrder(menuStr)
{
	for(i=1;i<menuCnt;i++)
	{
	    if(menuArr[i].indexOf(menuStr) >= 0)
	    {
	        menuOrder = i;
	    }
    }
}
/* image rollover script */
function menuOn(imgEl) {
	imgEl.src = imgEl.src.replace("off.gif", "on.gif");
}
function menuOnGnb(imgEl) 
{
	if(document.getElementById("topSearch"))
	{
	    document.getElementById("menuExtend8").style.display = "none";
	    document.getElementById('gnb').style.height  = "110px";
	}
	for(i=1;i<menuCnt;i++)
	{
        document.getElementById("gnbImg"+i).src	= document.getElementById("gnbImg"+i).src.replace("on.gif", "off.gif");
	}
    document.getElementById("gnbImg"+imgEl).src	= document.getElementById("gnbImg"+imgEl).src.replace("off.gif", "on.gif");
}

function menuOffGnb(j) 
{
	if(document.getElementById("topSearch"))
	{
	    document.getElementById('gnb').style.height  = "137px";
	    document.getElementById("menuExtend8").style.display = "block";
	}
	
	for(i=1;i<menuCnt;i++)
	{
        document.getElementById("gnbImg"+i).src	= document.getElementById("gnbImg"+i).src.replace("on.gif", "off.gif");
	}
    if(j != "") chkMenuOrder(j);
    if(menuOrder > 0)
    {
        document.getElementById("gnbImg"+menuOrder).src	= document.getElementById("gnbImg"+menuOrder).src.replace("off.gif", "on.gif");
    }
}


 
function menuOff(imgEl) {
	imgEl.src = imgEl.src.replace("on.gif", "off.gif");
}

function extendMenu(flag){
	menuOnGnb(flag)
	for(i=1;i<menuCnt;i++)  
	{
	    document.getElementById("menuExtend"+i).style.display = "none";
	}
	document.getElementById("menuExtend"+flag).style.display = "block";
}


/* focus */
$(document).ready(function(){
	closeready($('#focusWrap'),0);
});
var focusi = 1;
function focusOpen()
{
    var $foot = $(document.getElementById("focusWrap"))
    if(focusi % 2 == 1) alaltiopen($foot,300);
    else close($foot,300);
    focusi++;
}
function alaltiopen($elem,speed) {
    $elem.animate({ height: "192px"}, speed);
	document.getElementById("stateBtnA").src = document.getElementById("stateBtnA").src.replace("open","close");
	$elem.removeClass('closed1');
}

function close($elem,speed) {
	$elem.animate({ height: "35px"}, speed);
    $elem.addClass('closed1');        
	document.getElementById("stateBtnA").src = document.getElementById("stateBtnA").src.replace("close","open");
}

function closeready($elem,speed) {
	$elem.animate({ height: "35px"}, speed);
}

//  È­¸é Á¤Áß¾Ó¿¡ POPUP WINODOW OPEN

function popCwin( url, name, w, h, scroll) {

  var wl = (window.screen.width/2) - ((w/2) + 10);
  var wt = (window.screen.height/2) - ((h/2) + 50);

  var option = "height="+h+",width="+w+",left="+wl+",top="+wt+",screenX="+wl+",screenY="+wt+",scrollbars="+scroll + ", status=no";

  commonPopWin = window.open( url, name, option );
  commonPopWin.focus();
}

// ¿øÇÏ´Â À§Ä¡¿¡ POPUP WINODOW OPEN

function popUwin( url, name, w, h, wl, wt, scroll) {

  var option = "status=no,height="+h+",width="+w+",resizable=no,left="+wl+",top="+wt+",screenX="+wl+",screenY="+wt+",scrollbars="+scroll;

  commonPopWin = window.open( url, name, option );
  commonPopWin.focus();
}

// ¿øÇÏ´Â À§Ä¡¿¡ POPUP WINODOW OPEN

function popUwinGen( url) {
  commonPopWin = window.open( url);
  commonPopWin.focus();
}


function popViewChangeService()//º¯°æµÈ ÇØÁö ¿ä±Ý °è»ê Á¤Ã¥ º¸±â
{
    window.open("/common/popup/pop_stop_info.asp","pop_stop_info","width=100,height=100");
}

function goSite(val)
{
    if(val != "")
    {
        window.open(val,'¹Ù·Î°¡±â','left=50,top=50,width=768,height=770,toolbar=yes,menubar=no,status=yes,scrollbars=yes,resizable=yes');
    }
}

var autoSchZoneDis = "hide";
function extendSrch() {
    if (autoSchZoneDis == "hide") {
        document.getElementById("extendSrch").style.display = "block";
        autoSchZoneDis = "show";
    } else if (autoSchZoneDis == "show") {
        document.getElementById("extendSrch").style.display = "none";
        autoSchZoneDis = "hide";
    }
}

// ÀÚµ¿¿Ï¼º±â´É ¿µ¿ª ´Ý±â.
function extendSrchHide() {
    autoSchZoneDis = "show";
    setTimeout('extendSrch()', 200);
}

// ÀÚµ¿¿Ï¼º±â´É Ã³¸®.
function autoSearch(schTg, obj) {
    if (!obj) { return; }

    var lng = document.getElementById(schTg).length;
    var i, tmpSchTg = "";
    var tmpSchVal = obj.value;

    var url = "/include/autoSearchResult.asp";
    var paramVal = "";
    var method = "POST";

    for (i = 0; i < lng; i++) {
        if (document.getElementById(schTg)[i].selected) {
            tmpSchTg = document.getElementById(schTg)[i].vlaue;
            break;
        }
    }

    if (tmpSchTg == "" || tmpSchVal == "") { return; }

    sendRequest(url, "schTg=" + tmpSchTg + "&schVal" + tmpSchVal, autoSearchResult, "POST");
}

// ÀÚµ¿¿Ï¼º±â´É °á°ú Ã³¸®.
function autoSearchResult() {
    xmlRequest = httpRequest;

    if (xmlRequest == null || xmlRequest.readyState != 4) return;
    if (xmlRequest.responseText.length == 0) return;

    var value = xmlRequest.responseText;
    document.getElementById("extendSrch").innerHTML = value;

    autoSchZoneDis = "hide";
    extendSrch();
}

//ÀÚµ¿°Ë»ö±â´É °Ë»ö¾î Å¬¸¯½Ã Ã³¸®
function autoSchZoneClick(val) {
    document.getElementById("searchStr").value = val;
    searchFormCheck('btn');
}



/*  °Ë»ö °ü·Ã ½ºÅ©¸³Æ®...  */
//°Ë»öÃ¢ ÃÊ±âÈ­
function clearSearch() {
    document.searchForm.searchStr.style.backgroundImage = "";
    document.searchForm.searchStr.value = "";
    nextGbn = "A";
}
//°Ë»ö¾î Àü¼Û
function searchFormCheck(chkType) {
    var frm = document.searchForm;

    if (chkType == "oSmit") {   //onSubmit Ã³¸®½Ã
        if (nextGbn == "S" && reqStr == "") {
            window.open('/common/include/MainTop_Relay.asp?cur=54&url=http%3A%2F%2Fwww%2Ewowfa%2Eco%2Ekr%2Fcont%5Fpages%2Flecture%2Ehtml%3Fcode%3D146', "_blank", "width=800, height=600, scrollbars=yes, status = yes, toolbar=yes, location=yes, directories=yes,resizable=yes,menubar=yes");
            return false;
        } else {
            if (frm.searchPart.value == "total") {
                frm.query.value = frm.searchStr.value;
                frm.action = "/srctotal/search.asp";
            } else {
                frm.action = "/search/stock_list.asp";
            }

            if (frm.searchStr.value == "") {
                alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
                frm.searchStr.focus();
                return false;
            }
            return true;
        }
    } else {                    //¹öÆ° Å¬¸¯ Ã³¸®½Ã
        if (nextGbn == "S" && reqStr == "") {
            window.open('/common/include/MainTop_Relay.asp?cur=54&url=http%3A%2F%2Fwww%2Ewowfa%2Eco%2Ekr%2Fcont%5Fpages%2Flecture%2Ehtml%3Fcode%3D146', "_blank", "width=800, height=600, scrollbars=yes, status = yes, toolbar=yes, location=yes, directories=yes,resizable=yes,menubar=yes");
            return;
        } else {
            if (frm.searchPart.value == "total") {
                frm.query.value = frm.searchStr.value;
                frm.action = "/srctotal/search.asp";
            } else {
                frm.action = "/search/stock_list.asp";
            }

            if (frm.searchStr.value == "") {
                alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
                frm.searchStr.focus();
                return;
            }
            frm.submit();
        }
    }
}


function checkForm() 
{
	document.f.currPage.value = 1;
	if(document.f.listType) document.f.listType.value = "";
	document.f.submit();
}

function checkForm1() 
{
	document.f.currPage.value = 1;
	if(document.f.listType) document.f.listType.value = "";
	return true;    
}

function checkForm2() 
{
    document.f.skey.value = document.f2.skey.value;
	document.f.sval.value = document.f2.sval.value;
	document.f.currPage.value = 1;
	if(document.f.listType) document.f.listType.value = "";
	return true;    
}

function form2to1() 
{
	document.f.skey.value = document.f2.skey.value;
	document.f.sval.value = document.f2.sval.value;
	if(document.f.listType) document.f.listType.value = "";
	document.f.submit();
}
