$(function(){
    /**
     * swapimage
     */
    $('.pcswapimage').mouseover(function() {
        $(this).pcswapimage();
    });
    $('.pcswapimage').mouseout(function() {
        $(this).pcswapimage();
    });

    $('.swapImage').mouseover(function() {
        $(this).pcswapimage();
    });
    $('.swapImage').mouseout(function() {
        $(this).pcswapimage();
    });
    /**
     * フォームのsubmit
     */
    var submitFormClass = '.pcform';
    $('.pcsubmit').click(function(e){
        e.preventDefault();
        $(this).pcsubmit(e, submitFormClass);
    });
    $('.pcsubmit').keypress(function(e){
        // スペース
        if (e.which == 32){
            $(this).pcsubmit(e, submitFormClass);
        }
    });

    /**
     * チェックボックスの全選択・解除のトグル
     */
    var checkboxClass = '.pccheckbox';
    $('.pctogglecheck').click(function(e){
        $(this).pctogglecheck(checkboxClass);
    });

    /**
     * ページ移動
     */
    $('.pcpageselect').change(function(e){
        $(this).pcpaging(e);
    }); 

    /**
     * 「自動ログインする」にチェック
     */
    $('.pcautoLogin').click(function(e){
        if ($('#autoLogin').attr('checked')) {
            $(this).pcdialogWithTitle("#autologin");
        }
    });

    /**
     * 買い物かご内でプルダウンの変更があった
     */
    $('.pccartchange').change(function(e) {
        // photoCartDetailIDを求めて、買い物かごの内容を反映する
        $(this).pcApplyCart(e, './apply_photo.php');
    });

    /**
     * 写真の拡大表示（Flash呼び出し）
     * windowサイズに応じて表示サイズを変える
     */
    $('.pcshowlargephoto').click(function(e) {
        thicksize = 588;                                                   
        href = $(this).attr("href");
        e.preventDefault();
        w = $(window).width();
        h = $(window).height();
        minimumSize = Math.min(w, h);
        if (minimumSize < thicksize) {
            href = href
                 + "&width=" + minimumSize
                 + "&height=" + minimumSize;
        } else {
            href = href
                 + "&width=650+&height=630"
        }
        tb_show('', href, '');
        return false;
    });
});
