$(function(){
//無料ドクターメール相談
$('.blank').click(function(){
window.open($(this).attr('href') , '' , 'width=577 , height=681 , resizable=no , scrollbars=yes');
return false;
});

$id = $('body').attr('id');

if($id == 'reservation'){

var $target = $('table .reservedate td ul li dl dd select');

$target.change(function(){

var $class = $(this).parents('li').attr('class');
var $month = $(this).parent().children().siblings('select.month').attr('value');
var $date = $(this).parent().children().siblings('select.day').attr('value');
var $objHour = $(this).parent().children().siblings('select.hour');
var $hour = $(this).parent().children().siblings('select.hour').attr('value');

$today = new Date();
var $thisyear = $today.getFullYear();
var $thismonth = $today.getMonth()+1;
var $thisdate = $today.getDate();

if($month >= $thismonth){
$year = $thisyear;
} else {
$year = $thisyear + 1;
}

$day = new Date($year,$month-1,$date).getDay();

if($date != undefined){
if($day == 6 || $day == 0){
$objHour.children().each(function(){
if($(this).attr('value') == 9){
$(this).before('<option value="8">8</option>');
}
if($(this).attr('value') == 19 || $(this).attr('value') == 18){
$(this).remove();
}
});
} else {
if($class == 'first' && $objHour.children().length == 10 || $class == 'second' && $objHour.children().length == 11 || $class == 'third' && $objHour.children().length == 11){
$objHour.children('option:first').remove();
$objHour.append('<option value="18">18</option>');
$objHour.append('<option value="19">19</option>');
}
}
}
});

}

});
