/*-----------------------------------------
 *1,2共用
 *-----------------------------------------*/
function kosuuCtrl (value) {
    var obj    = document.frm.opt_kosuu;
    var nowval = obj.value;

    nowval =  Number(nowval) + Number(value);
    if (nowval <= 0) nowval = 1;

    obj.value = nowval;

    return false;
}


/*-----------------------------------------
 *以降は2でのみ使用
 *-----------------------------------------*/

//-----------------------------------------
//初期化
//-----------------------------------------
function init(){
    dispPrice();
}


//-----------------------------------------
//プルダウンを開く
//-----------------------------------------
function openColorSize (id) {
    var tmpNowSize  = document.getElementById('tmpNowSize');
    var tmpNowColor = document.getElementById('tmpNowColor');

    //----------------
    //Close
    //----------------
    document.getElementById(tmpNowSize.value).style.display  = 'none';
    document.getElementById(tmpNowColor.value).style.display = 'none';

    //消えない現象つぶし
    document.getElementById('sizeDefault').style.display  = 'none';
    document.getElementById('colorDefault').style.display = 'none';


    //----------------
    //Open
    //----------------
    document.getElementById('size'+id).style.display  = 'block';
    document.getElementById('color'+id).style.display = 'block';

    //----------------
    //Set
    //----------------
    tmpNowSize.value  = 'size' + id;
    tmpNowColor.value = 'color' + id;
    document.getElementById('body_type').value = id;

    document.getElementById('body_size').value = '';
    document.getElementById('color_cd').value  = '';

    document.getElementById('size'+id+'-pull').selectedIndex  = 0;
    document.getElementById('color'+id+'-pull').selectedIndex = 0;

    //----------------
    //Price
    //----------------
    dispPrice();
}


//-----------------------------------------
//価格取得
//-----------------------------------------
function getPrice (value, id) {
    //----------------
    //セット
    //----------------
    document.getElementById(id).value = value;

    //----------------
    //値取得
    //----------------
    var product_id   = document.getElementById('product_id').value;
    var product_type = document.getElementById('product_type').value;
    var body_cd      = document.getElementById('body_type').value;
    var body_size    = document.getElementById('body_size').value;
    var color_cd     = document.getElementById('color_cd').value;

    //----------------
    //チェック
    //----------------
    if( ! (body_cd && body_size && color_cd)                             //未定義の物があれば終了
            && ( body_cd == "" || body_size == "" || color_cd == "") ) { //空であれば終了

        return false;
    }

    //----------------
    //callback
    //----------------
    var callback = {
        success:function(httpObj) {
            var res = httpObj.responseText;

            if (res == -1)
                dispPrice();
            else
                dispPrice(res);
        }
    }

    //----------------
    //取得
    //----------------
    var url = '/pl/getprice'
        + '?product_id='   + product_id
        + '&product_type=' + product_type
        + '&body_cd='      + body_cd
        + '&color_cd='     + color_cd
        + '&body_size='    + body_size;

    YAHOO.util.Connect.asyncRequest('get' , url , callback , null);
}



//-----------------------------------------
//ヘルプ
//-----------------------------------------
function openHelp (id) {
    var url = 'http://clubt.jp/pl/help/'+id;

    //開く
    var swin = window.open(
        url,
        'clubthelp',
        'width=700,height=500,location=no,directories=no,toolbar=yes,status=yes,menubar=no,scrollbars=yes,resizable=yes'
    );

    //開かれたかチェック
    if (swin.closed) {
        alert("ウィンドウが開きませんでした。ポップアップブロック機能をOFFにするなどしてください");
        return false;
    }

    return false;
}

function openHelp2(id) {
    var base = 'http://clubt.jp/pl/general/';
    var list = {
        'TM085-CVT'    : 'size_1.html#p1',
        'TM085-CVTKnt' : 'size_1.html#p1',
        'CB5866'       : 'size_1.html#p5',
        'TM101-LVC'    : 'size_1.html#p2',
        'TM021-NCS'    : 'size_3.html#p1',
        'TM137-RSS'    : 'size_1.html#p3',
        'TM139-RLS'    : 'size_1.html#p4',
        'TM160-WCN'    : 'size_2.html#p1',
        'TM161-WRT'    : 'size_2.html#p2',
        'TM162-WCS'    : 'size_2.html#p3',
        'TM165-WLC'    : 'size_2.html#p4',
        'TM166-WQS'    : 'size_2.html#p5'
    }

    if (!list[id]) return false;
    var url = base + list[id];
    var swin = window.open(url, 'clubthelp');

    return false;
}

//-----------------------------------------
//価格表示
//-----------------------------------------
function dispPrice (p) {
    var price_display = document.getElementById('price_display');
    if(!p)
        price_display.innerHTML = '変更後単価：<font color=Gray>@????円</font>';
    else
        price_display.innerHTML = '変更後単価：<font color=Red><b>@' + p + '円</b></font>';
}
