var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);

function getRef(id) {
    if (isDOM) return document.getElementById(id);
    if (isIE4) return document.all[id];
    if (isNS4) return document.layers[id];
}

var isNS = navigator.appName == "Netscape";

function moveRightEdge() {
    var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;
    if (isNS4) {
        yMenuFrom   = sky.top;
        yMenuTo     = windows.pageYOffset + 76;   // À§ÂÊ À§Ä¡
    } else if (isDOM) {
        yMenuFrom   = parseInt (sky.style.top, 10);
        yMenuTo     = (isNS ? window.pageYOffset : document.body.scrollTop) + 76; // À§ÂÊ À§Ä¡
    }

    timeoutNextCheck = 500;

    if (yMenuFrom != yMenuTo) {

        yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
        if (yMenuTo < yMenuFrom)
            yOffset = -yOffset;
        if (isNS4)
            sky.top += yOffset;
        else if (isDOM)
            sky.style.top = parseInt (sky.style.top, 10) + yOffset;
            timeoutNextCheck = 10;
    }

    setTimeout ("moveRightEdge()", timeoutNextCheck);

}

var recentImgArr = new Array();
var recentUpNo = 0; 
var recentDownNo = 2;

var recentGoodsList;
var recentGoodsListArr;
var recentGoodsListCnt;

if(recentGoodsList = getCookie("RECENT_GOODS_LIST")) {
    recentGoodsListArr = recentGoodsList.split("|");
    recentGoodsListCnt = recentGoodsListArr.length;

    for(var i=0;i<recentGoodsListArr.length;i++) {
        recentImgArr[i] = recentGoodsListArr[i];
    }

    function product()
    {
        var strText1 = '<A HREF=http://www.stylebag.co.kr/Goods/GoodsView.php?GOODS_ID='+recentImgArr[0]+'&CONTENTS_ID=96 hidefocus=true><IMG SRC=http://image.stylebag.co.kr/Goods/50/'+recentImgArr[0]+'_50_1.jpg BORDER=0 WIDTH=43 HEIGHT=43></a>';
        var strText2 = '<A HREF=http://www.stylebag.co.kr/Goods/GoodsView.php?GOODS_ID='+recentImgArr[1]+'&CONTENTS_ID=96 hidefocus=true><IMG SRC=http://image.stylebag.co.kr/Goods/50/'+recentImgArr[1]+'_50_1.jpg BORDER=0 WIDTH=43 HEIGHT=43></a>';
        var strText3 = '<A HREF=http://www.stylebag.co.kr/Goods/GoodsView.php?GOODS_ID='+recentImgArr[2]+'&CONTENTS_ID=96 hidefocus=true><IMG SRC=http://image.stylebag.co.kr/Goods/50/'+recentImgArr[2]+'_50_1.jpg BORDER=0 WIDTH=43 HEIGHT=43></a>';

        document.writeln("<div id=\"sky_resent\" style=\"position:absolute; left:900px; top:20px; width:62px; height:40px; z-index:30; \">");
    
        if(recentGoodsListCnt > 0) {
            var bHeight = 30;   // ±âº»³ôÀÌ
            var rHeight = 60;   // »óÇ°°³´ç ³ôÀÌ
            var rCnt    = recentGoodsListCnt;
            var tHeight = 0;

            if(rCnt > 3) {
                rCnt = 3;
            }

            tHeight = ( rHeight * rCnt ) + bHeight;

            document.writeln("    <TABLE WIDTH=\"62\" CELLPADDING=\"0\" CELLSPACING=\"0\" BORDER=\"0\">");
			document.writeln("    	  <TR><TD ALIGN=\"CENTER\">"+SKY_BANNER1_URL+"</TD></TR>");
            document.writeln("    	  <TR HEIGHT=\"2\"><TD></TD></TR>");
	        document.writeln("    	  <TR><TD ALIGN=\"CENTER\">"+SKY_BANNER2_URL+"</TD></TR>");
	        document.writeln("    	  <TR><TD ALIGN=\"CENTER\">"+SKY_BANNER3_URL+"</TD></TR>");
            document.writeln("    	  <TR HEIGHT=\"5\"><TD></TD></TR>");
            document.writeln("        <TR><TD><A HREF=\"http://www.stylebag.co.kr/Goods/GoodsMyList.php\" hidefocus=\"true\"><img src=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_01.jpg\" BORDER=\"0\" alt=\"¿À´Ãº» »óÇ° ¸®½ºÆ®\"></A></TD></TR>");
            document.writeln("		   <TR><TD background=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_bg.jpg\" HEIGHT=\"15\" WIDTH=\"62\" ALIGN=\"CENTER\" ><FONT COLOR=\"FB4166\">(<SPAN id=recentImgCnt></SPAN>)</FONT></TD></TR>");
            document.writeln("        <TR>");
            document.writeln("            <TD>");
            document.writeln("                <TABLE WIDTH=\"62\" HEIGHT=\""+tHeight+"\" CELLPADDING=\"0\" CELLSPACING=\"0\" BORDER=\"0\" background=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_bg.jpg\">");
            document.writeln("                    <TR><TD width=\"62\" height=\"20\" align=\"center\"><A HREF=\"javascript:imgUp();\" hidefocus=\"true\"><img src=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_prev_bt.jpg\" BORDER=\"0\" alt=\"´ÙÀ½ »óÇ°º¸±â\"></A></TD></TR>");
            document.writeln("                    <TR><TD height=\"5\"></TD></TR>");
            document.writeln("                    <TR><TD align=\"center\"><div id=recentImg_1></div></TD></TR>");
            document.writeln("                    <TR><TD height=\"2\"></TD></TR>");
			if(rCnt > 1) {
            document.writeln("    				   <TR><TD><IMG SRC=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_bg_line.jpg\" BORDER=\"0\"></TD></TR>");
            document.writeln("                    <TR><TD height=\"2\"></TD></TR>");
            document.writeln("                    <TR><TD align=\"center\"><div id=recentImg_2></div></TD></TR>");
            document.writeln("                    <TR><TD height=\"2\"></TD></TR>");
            document.writeln("    				   <TR><TD><IMG SRC=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_bg_line.jpg\" BORDER=\"0\"></TD></TR>");
			}
            document.writeln("                    <TR><TD height=\"2\"></TD></TR>");
            document.writeln("                    <TR><TD align=\"center\"><div id=recentImg_3></div></TD></TR>");
            document.writeln("                    <TR><TD height=\"10\"></TD></TR>");
            document.writeln("    				   <TR><TD ALIGN=\"CENTER\"><A HREF=\"javascript:imgDown();\" hidefocus=\"true\"><IMG SRC=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_next_bt.jpg\" BORDER=\"0\" alt=\"ÀÌÀü »óÇ°º¸±â\"></A></TD></TR>");
            document.writeln("                    <TR><TD height=\"10\"></TD></TR>");
            document.writeln("    				   <TR><TD><IMG SRC=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_gray_line.jpg\" BORDER=\"0\"></TD></TR>");
            document.writeln("    			  	   <TR HEIGHT=\"4\"><TD BACKGROUND=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_gray_bg.jpg\"></TD></TR>");
            document.writeln("    				   <TR><TD><A HREF=\"http://www.stylebag.co.kr/Goods/GoodsCartList.php\" hidefocus=\"true\"><IMG SRC=\"http://image.stylebag.co.kr/WWW/20081201/sky/wish_bt.jpg\" BORDER=\"0\" alt=\"Âò¸®½ºÆ® º¸±â\"></A></TD></TR>");
            document.writeln("    				   <TR HEIGHT=\"2\"><TD BACKGROUND=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_gray_bg.jpg\"></TD></TR>");
            document.writeln("    				   <TR><TD><A HREF=\"http://www.stylebag.co.kr/Goods/GoodsCartList.php\" hidefocus=\"true\"><IMG SRC=\"http://image.stylebag.co.kr/WWW/20081201/sky/cart_bt.jpg\" BORDER=\"0\" alt=\"Àå¹Ù±¸´Ï º¸±â\"></A></TD></TR>");
            document.writeln("    				   <TR HEIGHT=\"4\"><TD BACKGROUND=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_gray_bg.jpg\"></TD></TR>");
            document.writeln("    				   <TR><TD><IMG SRC=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_02.jpg\" BORDER=\"0\"></TD></TR>");
            document.writeln("    			  </TABLE>");
            document.writeln("    		  </TD>");
            document.writeln("    	   </TR>");
            document.writeln("    	  <TR HEIGHT=\"5\"><TD></TD></TR>");
            document.writeln("    	  <TR><TD ALIGN=\"CENTER\"><A HREF=\"#\"><IMG SRC=\"http://image.stylebag.co.kr/WWW/20081201/sky/top.jpg\" BORDER=\"0\" alt=\"TOP\"></A></TD></TR>");
            document.writeln("   </TABLE>");

            recentImgCnt.innerHTML = recentGoodsListCnt;

        }

        document.writeln("</div>");

        for(var i=1;i<recentGoodsListArr.length+1;i++) {
            if(i < 4) {
                eval("recentImg_" + i +  ".innerHTML = strText"+i);
            }
        }

    }

    function imgUp()
    {
        var recentFirstNo = recentUpNo;
        if (recentFirstNo == -1)
        {
            alert("¿À´Ã º» »óÇ°ÀÌ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù.");
        }
        else if (recentFirstNo <= 0)
        {
            alert("¿À´Ã º» ¸¶Áö¸· »óÇ°ÀÔ´Ï´Ù.");
        }
        else
        {
            var strText1 = '<A HREF=http://www.stylebag.co.kr/Goods/GoodsView.php?GOODS_ID='+recentImgArr[recentFirstNo-1]+'&CONTENTS_ID=96 hidefocus=true><IMG SRC=http://image.stylebag.co.kr/Goods/50/'+recentImgArr[recentFirstNo-1]+'_50_1.jpg BORDER=0 WIDTH=43 HEIGHT=43></a>';
            var strText2 = '<A HREF=http://www.stylebag.co.kr/Goods/GoodsView.php?GOODS_ID='+recentImgArr[recentFirstNo]+'&CONTENTS_ID=96 hidefocus=true><IMG SRC=http://image.stylebag.co.kr/Goods/50/'+recentImgArr[recentFirstNo]+'_50_1.jpg BORDER=0 WIDTH=43 HEIGHT=43></a>';
            var strText3 = '<A HREF=http://www.stylebag.co.kr/Goods/GoodsView.php?GOODS_ID='+recentImgArr[recentFirstNo+1]+'&CONTENTS_ID=96 hidefocus=true><IMG SRC=http://image.stylebag.co.kr/Goods/50/'+recentImgArr[recentFirstNo+1]+'_50_1.jpg BORDER=0 WIDTH=43 HEIGHT=43></a>';

            for(var i=1;i<recentGoodsListArr.length+1;i++) {
                if(i < 4) {
                    eval("recentImg_" + i +  ".innerHTML = strText"+i);
                } else {
                    break;
                }
            }

            recentUpNo      = recentFirstNo-1;
            recentDownNo    = recentFirstNo+1;
        }
    }

    function imgDown()
    {
        var recentLastNo = recentDownNo;
        var nMaxCnt = recentGoodsListCnt-1;

        if (recentLastNo == -1)
        {
            alert("¿À´Ã º» »óÇ°ÀÌ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù.");
        }
        else if (recentLastNo >= nMaxCnt)
        {
            alert("¿À´Ã º» Ã³À½ »óÇ°ÀÔ´Ï´Ù.");
        }
        else
        {
            var strText1 = '<A HREF=http://www.stylebag.co.kr/Goods/GoodsView.php?GOODS_ID='+recentImgArr[recentLastNo-1]+'&CONTENTS_ID=96 hidefocus=true><IMG SRC=http://image.stylebag.co.kr/Goods/50/'+recentImgArr[recentLastNo-1]+'_50_1.jpg BORDER=0 WIDTH=43 HEIGHT=43></a>';
            var strText2 = '<A HREF=http://www.stylebag.co.kr/Goods/GoodsView.php?GOODS_ID='+recentImgArr[recentLastNo]+'&CONTENTS_ID=96 hidefocus=true><IMG SRC=http://image.stylebag.co.kr/Goods/50/'+recentImgArr[recentLastNo]+'_50_1.jpg BORDER=0 WIDTH=43 HEIGHT=43></a>';
            var strText3 = '<A HREF=http://www.stylebag.co.kr/Goods/GoodsView.php?GOODS_ID='+recentImgArr[recentLastNo+1]+'&CONTENTS_ID=96 hidefocus=true><IMG SRC=http://image.stylebag.co.kr/Goods/50/'+recentImgArr[recentLastNo+1]+'_50_1.jpg BORDER=0 WIDTH=43 HEIGHT=43></a>';

            for(var i=1;i<recentGoodsListArr.length+1;i++) {
                if(i < 4) {
                    eval("recentImg_" + i +  ".innerHTML = strText"+i);
                }
            }

            recentUpNo      = recentLastNo-1;
            recentDownNo    = recentLastNo+1;
        }
    }

    product();

    if (isNS4) {
        var sky = document["sky_resent"];
        sky.top = top.pageYOffset + 76;
        sky.visibility = "visible";
        moveRightEdge();
    } else if (isDOM) {
        var sky = getRef('sky_resent');
        sky.style.top = (isNS ? window.pageYOffset : document.body.scrollTop) + 76;
        sky.style.visibility = "visible";
        moveRightEdge();
    }
}else{
    function product_blank()
    {
        document.writeln("<div id=\"sky_resent\" style=\"position:absolute; left:900px; top:20px; width:62px; height:40px; z-index:30; \">");
		document.writeln("    <TABLE WIDTH=\"62\" CELLPADDING=\"0\" CELLSPACING=\"0\" BORDER=\"0\">");
		document.writeln("    	  <TR><TD ALIGN=\"CENTER\">"+SKY_BANNER1_URL+"</TD></TR>");
		document.writeln("    	  <TR HEIGHT=\"2\"><TD></TD></TR>");
        document.writeln("    	  <TR><TD ALIGN=\"CENTER\">"+SKY_BANNER2_URL+"</TD></TR>");
        document.writeln("    	  <TR><TD ALIGN=\"CENTER\">"+SKY_BANNER3_URL+"</TD></TR>");
		document.writeln("    	  <TR HEIGHT=\"5\"><TD></TD></TR>");
		document.writeln("        <TR><TD><A HREF=\"http://www.stylebag.co.kr/Goods/GoodsMyList.php\" hidefocus=\"true\"><img src=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_01.jpg\" BORDER=\"0\" alt=\"¿À´Ãº» »óÇ° ¸®½ºÆ®\"></A></TD></TR>");
		document.writeln("		   <TR><TD background=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_bg.jpg\" HEIGHT=\"15\" WIDTH=\"62\" ALIGN=\"CENTER\" ><FONT COLOR=\"FB4166\">(0)</FONT></TD></TR>");
		document.writeln("        <TR>");
		document.writeln("            <TD>");
		document.writeln("                <TABLE WIDTH=\"62\" HEIGHT=\"60\" CELLPADDING=\"0\" CELLSPACING=\"0\" BORDER=\"0\" background=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_bg.jpg\">");
		document.writeln("                    <TR><TD height=\"40\"></TD></TR>");
		document.writeln("    				   <TR><TD><IMG SRC=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_gray_line.jpg\" BORDER=\"0\"></TD></TR>");
		document.writeln("    			  	   <TR HEIGHT=\"4\"><TD BACKGROUND=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_gray_bg.jpg\"></TD></TR>");
		document.writeln("    				   <TR><TD><A HREF=\"http://www.stylebag.co.kr/Goods/GoodsCartList.php\" hidefocus=\"true\"><IMG SRC=\"http://image.stylebag.co.kr/WWW/20081201/sky/wish_bt.jpg\" BORDER=\"0\" alt=\"Âò¸®½ºÆ® º¸±â\"></A></TD></TR>");
		document.writeln("    				   <TR HEIGHT=\"2\"><TD BACKGROUND=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_gray_bg.jpg\"></TD></TR>");
		document.writeln("    				   <TR><TD><A HREF=\"http://www.stylebag.co.kr/Goods/GoodsCartList.php\" hidefocus=\"true\"><IMG SRC=\"http://image.stylebag.co.kr/WWW/20081201/sky/cart_bt.jpg\" BORDER=\"0\" alt=\"Àå¹Ù±¸´Ï º¸±â\"></A></TD></TR>");
		document.writeln("    				   <TR HEIGHT=\"4\"><TD BACKGROUND=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_gray_bg.jpg\"></TD></TR>");
		document.writeln("    				   <TR><TD><IMG SRC=\"http://image.stylebag.co.kr/WWW/20081201/sky/view_02.jpg\" BORDER=\"0\"></TD></TR>");
		document.writeln("    			  </TABLE>");
		document.writeln("    		  </TD>");
		document.writeln("    	   </TR>");
		document.writeln("    	  <TR HEIGHT=\"5\"><TD></TD></TR>");
		document.writeln("    	  <TR><TD ALIGN=\"CENTER\"><A HREF=\"#\"><IMG SRC=\"http://image.stylebag.co.kr/WWW/20081201/sky/top.jpg\" BORDER=\"0\" alt=\"TOP\"></A></TD></TR>");
		document.writeln("   </TABLE>");
        document.writeln("</div>");
	}

    product_blank();

    if (isNS4) {
        var sky = document["sky_resent"];
        sky.top = top.pageYOffset + 75;
        sky.visibility = "visible";
        moveRightEdge();
    } else if (isDOM) {
        var sky = getRef('sky_resent');
        sky.style.top = (isNS ? window.pageYOffset : document.body.scrollTop) + 76;
        sky.style.visibility = "visible";
        moveRightEdge();
    }
}