//-----------------------------------------------------------------------------
// ポップカレンダー
// 要 jquery.js, popwindow.js, popwindow.css, popcalendar.css, pop_calendar.php
//-----------------------------------------------------------------------------

var setCaleType;
//------------------------------------------------------------------------------
//カレンダー
//------------------------------------------------------------------------------
function popCalendar(y, m, d, type){
    if(type == 1 || type == 2)  setCaleType = type;
    if(document.getElementById("windowBack") === null){
        setWindowBack("カレンダー（日付をクリックしてください）"); //背景とタイトルのセット
    }
    
    if(y==0 && m==0 && d==0){
        if(!document.evtform.sttday_y){
            if(setCaleType == 1){
                y = document.evtform.sy.value;
                m = document.evtform.sm.value;
                d = document.evtform.sd.value;
            }else{
                if(document.evtform.ey.value != "-" &&
                   document.evtform.em.value != "-" &&
                   document.evtform.ed.value != "-" ){
                    y = document.evtform.ey.value;
                    m = document.evtform.em.value;
                    d = document.evtform.ed.value;
                }
            }
        }else{
            if(setCaleType == 1){
                y = document.evtform.sttday_y.value;
                m = document.evtform.sttday_m.value;
                d = document.evtform.sttday_d.value;
            }else{
                y = document.evtform.endday_y.value;
                m = document.evtform.endday_m.value;
                d = document.evtform.endday_d.value;
            }
        }
    }
    //var date = new Date();
    //var timestamp = date.getTime(); //キャッシュ利用を防ぐため
    var url = "pop_calendar.php?y=" + y + "&m=" + m + "&d=" + d; // +"&time" + timestamp;

    $("#datMain").load(url, function(){
        
        $("#windowMain").css({height:"auto", width:"400px"});
    
        if(popWinExist == 0){
            centerWindow();
        }
        popWinExist = 1;
        
    });


    //alert(popWinExist);
}
function setDay(y, m, d){
    closeWindow();
    //alert(y+"-"+m+"-"+d);
    if(!document.evtform.sttday_y){
        if(setCaleType == 1){
            document.evtform.sy.value = y;
            document.evtform.sm.value = m;
            document.evtform.sd.value = d;
        }else{
            document.evtform.ey.value = y;
            document.evtform.em.value = m;
            document.evtform.ed.value = d;
        }
    }else{
        if(setCaleType == 1){
            document.evtform.sttday_y.value = y;
            document.evtform.sttday_m.value = m;
            document.evtform.sttday_d.value = d;
        }else{
            document.evtform.endday_y.value = y;
            document.evtform.endday_m.value = m;
            document.evtform.endday_d.value = d;
        }
    }
}


