document.write('<style tyle="text/css">#container #content #main #swfdisp ul {display:none;}</style>');

$(function(){

$class = $("body").attr("class");
$id = $("body").attr("id");

if($('#smartphone').length === 1){
	$('body').css('background-position','center 90px');
}

$('.blank').click(function(){
	var ua = $.browser;

	if(ua.msie){
		window.open($(this).attr('href') , '' , 'width=618 , height=768 , resizable=no , scrollbars=yes');
	}
	else {
		window.open($(this).attr('href') , '' , 'width=615 , height=748 , resizable=no , scrollbars=yes');
	}
	return false;
});

$('.blank2').click(function(){
	var ua = $.browser;

	if(ua.msie){
		window.open($(this).attr('href') , '' , 'width=718 , height=768 , resizable=no , scrollbars=yes');
	}
	else {
		window.open($(this).attr('href') , '' , 'width=715 , height=748 , resizable=no , scrollbars=yes');
	}
	return false;
});

//マップポップアップ
$('a.map').click(function(){
var ua = $.browser;

if(ua.msie){
window.open($(this).attr('href') , '' , 'width=722 , height=810 , resizable=no , scrollbars=yes');
}
else {
window.open($(this).attr('href') , '' , 'width=720 , height=810 , resizable=no , scrollbars=yes');
}
return false;
});

if($id != 'index' && $class.indexOf("voice") != -1){
$(".popup a").lightBox({
overlayBgColor: "#fff",
overlayOpacity: 0.5,
containerBorderSize: 10,
imageLoading: "../../img/lightbox-ico-loading.gif",
imageBtnPrev: "../../img/lightbox-btn-prev.gif",
imageBtnNext: "../../img/lightbox-btn-next.gif",
imageBtnClose: "../../img/lightbox-btn-close.gif",
fixedNavigation: true
});
}

/*
if($class.indexOf('form') != -1){
$("#button li input[type='image']").hover(
function(){
$(this).attr('src',$(this).attr('src').replace('.gif','_h.gif'));
},
function(){
$(this).attr('src',$(this).attr('src').replace('_h.gif','.gif'));
});
}
*/

if($class.indexOf('qa') != -1){
$("#menu ul li ul li").each(function(){
$now = $(this).attr('class');
if($now.indexOf($id) != -1){
$(this).addClass('active');
}
});

$("#menu ul li ul li").hover(
function(){
$(this).addClass('hover');
},
function(){
$(this).removeClass('hover');
});
}

$('#pagetop').click(function () {
$(this).blur();
$('html,body').animate({ scrollTop: 0 }, '20000');
return false;
});

function countdown(){
today = new Date();
todaySec = today.getTime();

var year;
var month;
var lastday; //末日
year = new Date().getFullYear();
month = new Date().getMonth()+1;

var nextYear;
var nextMonth;
	
//次月取得
if (month == 12){
//翌年の1月に変更
nextYear = year+1;
nextMonth = 1;
} else {
nextYear = year;
nextMonth = month+1;
}

//末日取得
lastday = new Date(nextYear, nextMonth-1, 0);
lastday = lastday.getDate();

//endday = new Date(nextYear,nextMonth-1,1);
var endYear = $("input[name='endYear']").attr('value');
var endMonth = $("input[name='endMonth']").attr('value') - 1;
var endDay = $("input[name='endDay']").attr('value');
endday = new Date(endYear,endMonth,endDay,23,59,59);
enddaySec = endday.getTime();

least = enddaySec - todaySec;

oneday = 1000 * 60 * 60 * 24;
onehour = 1000 * 60 * 60;
oneminute = 1000 * 60;
onesecond = 1000;


leastDay = Math.floor(least / oneday);

leastHour = Math.floor((least - leastDay * oneday) / onehour);

leastMinute = Math.floor((least - ((leastDay * oneday) + (leastHour * onehour))) / oneminute);

leastSecond = Math.floor((least - ((leastDay * oneday) + (leastHour * onehour) + (leastMinute * oneminute))) / onesecond);

function format(num,x) {
    num = String(num);
    return (num.length < x) ? new Array((x - num.length) + 1).join('0') + num: num;
};

leastDay = String(leastDay);
leastHour = format(leastHour,2);
leastMinute = format(leastMinute,2);
leastSecond = format(leastSecond,2);

$targetDay = $('span.days');
$targetHour = $('span.hour');
$targetMinute = $('span.minute');
$targetSecond = $('span.second');

$targetDay.empty();
$targetHour.empty();
$targetMinute.empty();
$targetSecond.empty();

$targetDay.prepend(leastDay);
$targetHour.prepend(leastHour);
$targetMinute.prepend(leastMinute);
$targetSecond.prepend(leastSecond);
}

setInterval(countdown,1000);

if($class.indexOf('introduction') != -1){
var params = {};
params.wmode = "transparent";
var attributes = {};

if($id == 'index'){
var flashvars = {clinic:"tokyo"};
swfobject.embedSWF("../swf/scroll.swf", "swfdisp_tokyo", "240", "240", "9.0.0", false, flashvars, params, attributes);
var flashvars = {clinic:"fukuoka"};
swfobject.embedSWF("../swf/scroll.swf", "swfdisp_fukuoka", "240", "240", "9.0.0", false, flashvars, params, attributes);

} else if($id == 'tokyo'){
var flashvars = {clinic:"tokyo"};
swfobject.embedSWF("../swf/clinic.swf", "swfdisp", "500", "350", "9.0.0", false, flashvars, params, attributes);
} else if($id == 'fukuoka'){
var flashvars = {clinic:"fukuoka"};
swfobject.embedSWF("../swf/clinic.swf", "swfdisp", "500", "350", "9.0.0", false, flashvars, params, attributes);
}
}

});

