/* 이미지 on/off */
function imgOver(obj) {
    if (obj.src.indexOf("_on.gif") == -1 && obj.src.indexOf("_ov.gif") == -1) {
        obj.src = obj.src.replace('.gif', '_on.gif');
    }
}
function imgOut(obj, type) {
    if (type != "on") {
        obj.src = obj.src.replace('_on.gif', '.gif');
    }
}


function adjustImageWidth(target_img, maxWidth) {
    var newHeight, newWidth;
    var newImg;

    newImg = new Image();
    newImg.src = target_img.src;
    imgw = newImg.width;
    imgh = newImg.height;

    if (imgw > maxWidth) {
        newWidth = maxWidth;
        newHeight = imgh;

        newWidth = Math.min(newWidth, Math.round((imgw * newHeight) / imgh));
        newHeight = Math.min(Math.round((imgh * newWidth) / imgw), newHeight);

        target_img.width = newWidth;
        target_img.height = newHeight;
    }
}

function fncImagePopup(image) {
    var winImagePopup = window.open("", "winImagePopup", "location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no")
    winImagePopup.focus();
    winImagePopup.document.open();
    winImagePopup.document.write("<HTML><HEAD>");
    winImagePopup.document.write("<TITLE>이미지보기</TITLE>");
    winImagePopup.document.write("</HEAD><BODY topmargin=\"0\" leftmargin=\"0\">");
    winImagePopup.document.write("<img src=\"" + encodeURI(decodeURI(image)) + "\" id=\"ImagePopup\" onLoad=\"window.resizeBy(Math.min(this.width,screen.availWidth-70)-document.body.clientWidth,Math.min(document.body.scrollHeight,screen.availHeight-70)-document.body.clientHeight);window.resizeBy(0,Math.min(document.body.scrollHeight,screen.availHeight-70)-document.body.clientHeight);window.moveBy(Math.min(0,screen.availWidth-(window.screenLeft+document.body.clientWidth+30)),Math.min(0,screen.availHeight-(window.screenTop+document.body.clientHeight+30)));\" onClick=\"window.close()\">");
    winImagePopup.document.write("</BODY></HTML>");
    winImagePopup.document.close();
}


function $get() {
    var ret = [];
    for (var i = 0; i < arguments.length; i++) {
        if (typeof arguments[i] == 'string') {
            ret.push(document.getElementById(arguments[i]));
        } else {
            ret.push(arguments[i]);
        }
    }
    return ret[1] ? ret : ret[0];
}

String.prototype.trim = function() {
    return this.replace(/^\s{1,}|\s{1,}$/g, "");
}

function www_download_file(fullpath, fname) {
    location.href = "/Mypage/DownloadFile.aspx?target=" + (fullpath) + "&fname=" + (fname);
}

///////////////////////////////////////////////////////
// 우편번호 관련 ,  작성자 : 장준영
/////////////////////////////////////////////////////////////////////////////
//우편번호 팝업
function PopOpenZipCode(url, zip, addr1, addr2) {
    window.open(url + "?zip=" + zip + "&addr1=" + addr1 + "&addr2=" + addr2, 'zip_pop', 'width=460,height=450');
    /*
    alert(url);
    alert(zip);
    alert(addr1);
    alert(addr2);
    */
}
//팝업->부모창
/*
* arg 1,2   는  [element id : value] 형태
*/
function SelectZipcode(zip, addr1, addr2) {
    document.getElementById(zip[0]).value = zip[1];    //우편번호
    document.getElementById(addr1[0]).value = addr1[1];    //주소
    if (addr2) {    //나머지주소 입력란 포커스이동
        document.getElementById(addr2).focus();
    }
    return true;
}

function irivermusicLogin() {
    var obj = document.frm_irivermusic_login;
    obj.method = "post";
    obj.target = "_new";
    obj.action = "https://www.iriver.co.kr:441/irivermusic/irivermusic_login.aspx";
    obj.submit();
}



