/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function resizeImg(obj,div){
    $(div).style.width = obj.width;
    $(div).style.height = obj.height;

    if(obj.height > 300){
        $(div).style.height = '300px';
    }
    if(obj.width > 300){
        obj.style.width = "300px";
        $(div).style.width = '300px';
    }
    if(obj.width < 100 || obj.height < 100){
        obj.style.display = 'none';
        $(div).style.display = 'none';
    }
}

function select_menu(target){
    if (window.Modalbox){
        $('send_to_mesg').style.display = "none";
        $('send_to_mail').style.display = "none";
        $('send_to_basket').style.display = "none";
        window.Modalbox.options.resizeDuration = 0;
        $(target).style.display = "inline";
        window.Modalbox.resizeToContent();
        window.Modalbox.options.resizeDuration = .25;

    }
}
function confirm_mall_stop(){
    checked_confirm = confirm('현재 몰에 게재되어 있는 모든 상품의 이미지를 사용할 수 없게 됩니다. \n 계속 진행하겠습니까?');
    if(!checked_confirm){
        $('request_stop_display_request_type_01').checked = true;
    }
}

/*
 * 상품상세에서 본 이미지 확인을 위한 popup창 컨트롤러
 * 2009-06-01 poprdo@gmail.com
 * 미구현
if(window.prdImg){
    var prdImg = new Object();
}

prdImg.Methods = {
    originWidth:null,
    originHeight:null,
    prod_resize_img:function(imgobj,size){
        this.originWidth = imgobj.width;
        this.originHeight = imgobj.height;
        if(imgobj.width > imgobj.height){
            imgobj.width = size;
        }else{
            imgobj.height = size;
        }
    },
    prod_show_origin_img:function(){
        
    }
}
*/
/*
 * 2009-06-08 친구장바구니로 보내기 - 친구 전체선택
 */
function all_my_frd(){
    $('my_frd')
}

function moveSelectField(field){
    var fromSelect;
    var targSelect;
    if(field=="add"){
        fromSelect = $('my_frd');
        targSelect = $('sel_frd');
    }else{
        fromSelect = $('sel_frd');
        targSelect = $('my_frd');
    }
    
    if(fromSelect.selectedIndex < 0) return;
    options = fromSelect.options;
    for(var i=options.length-1;i>=0;i--){
        if(options[i].selected){
            selOption = fromSelect.options(i);
            var oOptionFrom = document.createElement("OPTION");
            targSelect.add(oOptionFrom);
            oOptionFrom.innerText = selOption.innerText;
            oOptionFrom.value = selOption.value;
            oOptionFrom.selected=true;
            fromSelect.remove(i);
        }
    }
}

function all_sel_frd(field,checked){
    sel = $(field);
    for(var i=0;i<sel.options.length;i++){
        sel.options[i].selected = checked;
    }
}

function checkSubmitSelect(){
    var fromSelect = $('sel_frd');
    $('tofriend_select_frd').value = "";
    if(fromSelect == null || fromSelect.options.length <= 0) return false;
    for(var i=0;i<fromSelect.options.length;i++){
        $('tofriend_select_frd').value += fromSelect.options[i].value + ","
    //fromSelect.options[i].checked = true;
    }
    return true;
}

function resize_show_img(img_id){
    var view = $(img_id);
    var w = view.width;
    var h = view.height;
    if(h>w && w*3/2 > h){
       view.height = 300;
       view.width = w*(300/h)
    }else{
       view.width = 300;
    }
}
function new_img(img_id,img_src){
    $(img_id) = new Image();
    $(img_id).name = img_src
    $(img_id).onload = resize_show_img;
    $(img_id).onerror = "this.src='/images/main/NO_PICTURE.jpg'";
    $(img_id).src = img_src;
    //$(img_id) = view_img;
}

