//SELECT -> LAYER변환
function getSelectToLayer(obj, lwidth, href, index) {
    obj.style.display = 'none';
    var newsb = obj.id + "_sbj";
    var newid = obj.id + "_tmp";
    var newim = obj.id + "_img";
    var LayerTag = "";

    LayerTag += "<TABLE WIDTH='" + lwidth + "' CELLSPACING=0 CELLPADDING=0 STYLE='position:absolute;cursor:default;z-index:" + index + "'>";
    LayerTag += "<TR HEIGHT=1><TD></TD></TR><TR><TD valign='top'>";
    LayerTag += "<TABLE BGCOLOR='#FFFFFF' HEIGHT=15 WIDTH=100% CELLSPACING=0 CELLPADDING=0 STYLE='border:1 solid #D9D4C2;line-height:117%;' onmouseover='getSelectLayerOver(this,document.all." + newim + ",document.all." + newid + ");' onmouseout='getSelectLayerOut(this,document.all." + newim + ",document.all." + newid + ");'>";

    LayerTag += "<TR WIDTH=100% onclick='getSelectSubLayer(document.all." + newid + ",document.all." + newsb + ");'>";
    LayerTag += "<TD ID='" + newsb + "' WIDTH=95% onblur='getSelectLayerBlur(this);' style='padding:3 0 0 0;'>&nbsp;" + obj.options[obj.selectedIndex].text + "</TD>";
    LayerTag += "<TD ALIGN=RIGHT style='cursor:hand;'><IMG ID='" + newim + "' SRC='../../images/common/button/select_button.gif' ALIGN=absmiddle STYLE='filter:gray();'></TD></TR>";

    LayerTag += "</TABLE>";

    LayerTag += "<TABLE onblur='getSubLayerClose(this);' ID='" + newid + "' WIDTH=100% CELLSPACING=0 CELLPADDING=0 STYLE='display:none;border:1 solid #D9D4C2;' BGCOLOR='#FFFFFF'>";
    for (var i = 0; i < obj.length; i++) {
        //LayerTag += "<TR onmouseover='getSelectMoveLayer(this);' onmouseout='getSelectMoveLayer1(this);' onclick=\"getSelectChangeLayer(document.all."+obj.id+",document.all."+newid+",document.all."+newsb+",'"+obj.options[i].text+"','"+obj.options[i].value+"','"+href+"');\" ";
        LayerTag += "<TR onmouseover='getSelectMoveLayer(this);' onmouseout='getSelectMoveLayer1(this);' onclick=\"getSelectChangeLayer(document.all." + obj.id + ",document.all." + newid + ",document.all." + newsb + ",'" + obj.options[i].text + "','" + obj.options[i].value + "');\" ";

        if (obj.value == obj.options[i].value) {
            LayerTag += "STYLE='background:#FFFFFF;color:#666666;'><TD>&nbsp;";
        }
        else {
            LayerTag += "STYLE='background:#FFFFFF;color:#666666;'><TD>&nbsp;";
        }

        LayerTag += obj.options[i].text;
        LayerTag += "</TD></TR>";
    }
    LayerTag += "</TABLE>";
    LayerTag += "</TD></TR></TABLE><IMG SRC='' WIDTH='" + lwidth + "' HEIGHT=0>";
    //alert("아니..");
    document.write(LayerTag);
}

//서브레이어보이기
function getSelectSubLayer(obj, sobj) {
    if (obj.style.display == 'none') {
        sobj.style.background = '#FFFFFF';
        sobj.style.color = '#666666';
        obj.style.display = 'block';
        obj.focus();
    }
    else {
        sobj.style.background = '#FFFFFF';
        sobj.style.color = '#666666';
        obj.style.display = 'none';
    }
}

//서브레이어체크
function getSelectSubLayer1(obj) {
    if (obj.style.display != 'none') {
        obj.style.display = 'none';
    }
}

//타이틀레이어 MouseOver
function getSelectLayerOver(obj, img, nobj) {
    if (nobj.style.display == 'none') {
        obj.style.border = '1 solid #D9D4C2';
        img.style.filter = '';
    }
}

//타이틀레이어 MouseOut
function getSelectLayerOut(obj, img) {
    obj.style.border = '1 solid #D9D4C2';
    img.style.filter = 'gray()';
}


//서브레이어 MouseOver
function getSelectMoveLayer(obj) {
    if (obj.style.color == '#666666') {
        obj.style.background = '#F0F0F0';
        obj.style.color = '#FFFFFF';
    }
}
//서브레이어 MouseOut
function getSelectMoveLayer1(obj) {
    obj.style.background = '#FFFFFF';
    obj.style.color = '#666666';
}

//새레이어선택
//function getSelectChangeLayer(obj,fobj,sobj,text,value,href)
function getSelectChangeLayer(obj, fobj, sobj, text, value) {
    fobj.style.display = 'none';
    sobj.innerHTML = '&nbsp;' + text;
    sobj.style.background = '#FFFFFF';
    sobj.style.color = '#FFFFFF';
    sobj.focus();
    focus();
    obj.value = value;
    /*if (href)
    {
    if (href.indexOf('submit()') != -1)
    {
    eval(href);
    }
    else {
    location.href = href + value;
    }
    return false;
    }
    else return true;*/
    // alert("tset");
}

//타이틀레이어 blur
function getSelectLayerBlur(obj) {
    obj.style.background = '#FFFFFF';
    obj.style.color = '#666666';
}

//서브레이어 닫기
function getSubLayerClose(obj) {
    if (obj.style.display != 'none') {
        setTimeout("document.all." + obj.id + ".style.display = 'none'", 200);
    }
}



//document.title = "♡ 빙그레 요플레 since 1983 - 당신에게 좋아요 ♡";
document.title = "대한민국 1등! 빙그레 요플레";



//퍼블리셔가 추가한 스크립트
function flashWrite(url, w, h, bg, wmode, id) {
    var flashStr =
    "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' id='" + id + "' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0' width='" + w + "' height='" + h + "' align='top'>" +
	    "<param name='movie' value='" + url + "' />" +
	    "<param name='bgcolor' value='" + bg + "' />" +
	    "<param name='wmode' value='" + wmode + "' />" +
        "<embed id='" + id + "' src='" + url + "' wmode='" + wmode + "' bgcolor='" + bg + "' menu='false' quality='high' width='" + w + "' height='" + h + "' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='https://www.macromedia.com/go/getflashplayer' />" +
	"</object>";
    document.write(flashStr);
}

function flashWrite2(url, w, h, bg, wmode, id, base) {
    var flashStr =
    "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' id='" + id + "' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0' width='" + w + "' height='" + h + "' align='top'>" +
	    "<param name='movie' value='" + url + "' />" +
	    "<param name='bgcolor' value='" + bg + "' />" +
	    "<param name='base' value='" + base + "' />" +
	    "<param name='wmode' value='" + wmode + "' />" +
        "<embed id='" + id + "' src='" + url + "' wmode='" + wmode + "' bgcolor='" + bg + "' menu='false' quality='high' width='" + w + "' height='" + h + "' base='" + base + "' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='https://www.macromedia.com/go/getflashplayer' />" +
	"</object>";
    document.write(flashStr);
}

function flashWrite3(url, w, h, bg, wmode, id, base) {
    var flashStr =
    "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' id='" + id + "' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0' width='" + w + "' height='" + h + "' align='top'>" +
	    "<param name='movie' value='" + url + "' />" +
	    "<param name='bgcolor' value='" + bg + "' />" +
	    "<param name='base' value='" + base + "' />" +
	    "<param name='wmode' value='" + wmode + "' />" +
        "<embed id='" + id + "' src='" + url + "' wmode='" + wmode + "' bgcolor='" + bg + "' menu='false' quality='high' width='" + w + "' height='" + h + "' base='" + base + "' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='https://www.macromedia.com/go/getflashplayer' />" +
	"</object>";
    return flashStr;
}

function MakeFlashString(source,id,width,height,wmode, otherParam)
{
	return "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0\" width="+width+" height="+height+" id="+id+"><param name=wmode value="+wmode+" /><param name=movie value="+source+" /><param name=quality value=high />"+otherParam+"<embed src="+source+" quality=high wmode="+wmode+" type=\"application/x-shockwave-flash\" pluginspage=\"https://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash\" width="+width+" height="+height+" align='top'></embed></object>";
}

function openPopup(url, title, width, height) {
    window.open(url, title, "width=" + width + " height=" + height + "");
}

function showLayerPopup(wrap, contents, background, popup) {
    $("#" + wrap).show();
    
    var top = -($("#" + popup).height() / 2);
    var left = -($("#" + popup).width() / 2);

    $("#" + popup).css({
        "top" : "50%",
        "left": "50%",
        
        "margin-top" : top + "px",
        "margin-left": left + "px"
    });
    resize(contents, background);
    
    window.onresize = function() {
        resize(contents, background);
    }

    location.href = "#header";
}

function showLayerPopup2(wrap, contents, background, popup, w, h) {
    $("#" + wrap).show();

    var top = -h / 2;
    var left = -w;

    $("#" + popup).css({
        "margin-top" : top + "px",
        "margin-left": left + "px"
    });

    resize(contents, background);
    
    window.onresize = function() {
        resize(contents, background);
    }

    location.href = "#header";
}

function hideLayerPopup(wrap) {
    $("#" + wrap).hide();
}

function resize(contents, background) {
    var wrapWidth = document.getElementById(contents).clientWidth;          //컨텐츠 넓이
    var wrapHeight = document.getElementById(contents).clientHeight;        //컨텐츠 높이
    var bodyWidth = document.body.clientWidth;                              //화면 전체 가로크기(스크롤 안쪽)
    var bodyHeight = document.body.clientHeight;                            //화면 전체 세로크기
    if (bodyWidth <= wrapWidth) {                                           //가로 스크롤이 생기면
        document.getElementById(background).style.width = wrapWidth + "px"; //컨텐츠 크기로
    } else {                                                                //가로 스크롤이 안생기면
        document.getElementById(background).style.width = bodyWidth;           //화면 전체 크기로
    }
    if (bodyHeight <= wrapHeight) {                                         //세로 스크롤이 생기면
        document.getElementById(background).style.height = wrapHeight + "px";//컨텐츠 크기로
    } else {
        document.getElementById(background).style.height = "100%";          //화면 전체 크기로
    }
}

//URL 형식 체크
function checkUrl(strUrl) {
    var expUrl = /^(http\:\/\/)?((\w+)[.])+(me|asia|biz|cc|cn|com|de|eu|in|info|jobs|jp|kr|mobi|mx|name|net|nz|org|travel|tv|tw|uk|us)(\/(\w*))*$/i;
    return expUrl.test(strUrl);
}

//프린트 팝업
function goPrint(url,width) {
    //window.print();
    window.open(url, "print", "width="+width+", height=800, top=50, left=50, status=no, scrollbars");
}

function needLogin() {
    alert("로그인 하시기 바랍니다.");
    location.href = "/yo_members/login/login.asp?referer="+ encodeURIComponent(document.URL);
}


/*통합네비게이션*/
/* Menu flash */
function openMenu(){
	document.getElementById('gnb').style.height = '102px';
	document.getElementById('gnb').style.zIndex = 300;
}
function closeMenu(){
	document.getElementById('gnb').style.height= '28px';
	document.getElementById('gnb').style.zIndex = 10;
}

/*맨위로*/
function goTop() {
	window.scroll(0, 0);
}
