/* Flash Tags
==================================================================================================== */
/* Flash Plugin Check
---------------------------------------------------------------------------------------------------- */
var MM_contentVersion = 8;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if (plugin) {
  var words = navigator.plugins["Shockwave Flash"].description.split(" ");
  for (var i = 0; i < words.length; ++i) {
    if (isNaN(parseInt(words[i]))) continue;
    var MM_PluginVersion = words[i];
  }
  var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
  document.write('<scr' + 'ipt language="VBScript"\> \n');	//FS hide this from IE4.5 Mac by splitting the tag
  document.write('on error resume next \n');
  document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
  document.write('</scr' + 'ipt\> \n');
}

/* Write Flash Tags
---------------------------------------------------------------------------------------------------- */
function flashTagsTop() {
  var flashFileName = "common/swf/index"
  if (MM_FlashCanPlay) {
    //document.write('<p>');
    AC_FL_RunContent('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','574','height','230','src',flashFileName,'quality','high','pluginspage','http://www.adobe.com/go/getflashplayer','imageTop',flashFileName,'wmode','transparent' ); //end AC code
    //document.write('</p>');
  } else {
    document.write('<p><img src="'+flashFileName+'.jpg" alt="" width="574" height="230" /></p>');
    document.write('<blockquote class="fontSmall">');
    document.write('<p class="fontCaution"><strong>x</strong> Flashムービーが再生できません！</p>');
    document.write('<p>Flashムービーをご覧になるためには、最新のAdobe Flash Playerのダウンロードが必要となります。</p>');
    document.write('<ul><li><a href="http://www.adobe.com/go/getflashplayer" target="_blank">Adobe Flash Playerのダウンロード</a></li></ul>');
    document.write('</blockquote>');
  }
}
  
// 文字サイズ切り替え　Cookie使用
/*$(function(){
	$("#contents").css("font-size",$.cookie('fsize'));
});
function font(size){
	$("#contents").css("font-size",size);
	$.cookie("fsize",size,{expires:30,path:'/'});
}*/

// カルーセル(jCarousel)
/*$(function(){
	$(".carousel").carousel({ 
		dispItems: 4,
		loop: true,
		autoSlide: true, 
		autoSlideInterval: 10000
	});
});*/

// Vi画像のスライドショー
/*
function viCycle () {
	$(document).ready(function(){
		// Vi画像置換（フェード）
		$('#fadeImage').cycle({ 
			fx:     'fade', // or fade or zoom or scrollRight
			//easing: 'bounceout',
			speed:  1000,
			timeout: 7000
		});
	});
}
viCycle();
*/
// ナビゲーショ
$(function () {
	if ($.browser.msie && $.browser.version < 7) return; 
		$('#navigation li')
		.removeClass('highlight')
		.find('a')
		.append('<span class="hover" />').each(function () {
			var $span = $('> span.hover', this).css('opacity', 0);
			$(this).hover(function () {
				$span.stop().fadeTo(500, 1);// on hover
			}, function () {
				$span.stop().fadeTo(500, 0);// off hover
			});
	});
});


// スキップリンク
$(function() {
    var $sidebar   = $("#upto"),
        $window    = $(window),
        offset     = $sidebar.offset(),
        topPadding = 275;
    $window.scroll(function() {
            		var wHeight = $window.height();
        if ($window.scrollTop() < offset.top) {
            $sidebar.stop().animate({
                marginTop: $window.scrollTop() - offset.top + (wHeight - topPadding)
            });
//alert(wHeight);
        } else {
            $sidebar.stop().animate({
                marginTop: 0
            });
        }
    });
});



// CSSの補助
$(function() {
	$("#campaign img:first").css("margin-right","28px");
});



// jCalendar
/*$(document).ready(function() {
  $('fieldset.jcalendar').jcalendar();
});
*/


$(function() {
	var calImg = $('div#calendar').find('img').attr('src');
	var replaceDir = calImg.slice(-11,-4);
	var date = new Date();
	var year = date.getFullYear();
	var month = date.getMonth() +1;
	var currentMonth = year+'/0'+month;
	var changeDir = calImg.replace(replaceDir,currentMonth);
	$('div#calendar').find('img').attr('src',changeDir);
	var replacedcalImg = $('div#calendar').find('img').attr('src');
	if(calImg != replacedcalImg) {
		$('div#calendar').find('img').remove();
		InitCalendar('calendar');
		$('div#calendar table th:eq(0)').css('background-color','#F9D4CF');
		$('div#calendar table th:eq(6)').css('background-color','#DCF8FF');
		$('div#calendar p#caltitle').after('<p class="clearFix" id="calnote"><span id="calholiday"></span>休診<span id="calhalf"></span>午後休診</p>');
	}
});
