/* =======================================

	Common JS

========================================== */

(function($){ // start jquery

/* win/mac
========================================== */
$(function(){
	var UA = navigator.userAgent;
	if(UA.match(/[Ww]in/)) {
		$('body').addClass('win');
	} else if(UA.match(/[Mm]ac/)) {
		$('body').addClass('mac');
	}
});


/* Smooth Scroll
========================================== */
$(function(){ 
	$('a[href^=#]:not(a[href$=#])').click(function(){
		var href= this.hash;
		var $target = $(href == '#_top' ? 'body' : href);

		// アンカーリンクがあるページでだけ以下を実行
		if($target.size()){
			var top = $target.offset().top;
			$($.browser.safari ? 'body' : 'html').animate({scrollTop:top}, 500, 'swing');
		}
		return false;
	});
});


/* IE6で砂時計回避
========================================== */
try {
	document.execCommand('BackgroundImageCache', false, true);
}catch(e){}


/* IEでクリッカブルマップの線を消す（ただし、タブでリンクの移動ができなくなる）
=========================================== */
$(function(){
	$('area').focus(function(){ $(this).blur();});
});


/* フォーム注意書きの追加
=========================================== */

$(function() {
	var Obj = $('#page85 form#inquiryform-1 table#iqfm-input-1');
	$('td#iqfm-input-1', Obj).append(
	'<p class="caption">（ニックネーム可）</p>'
	);
	$('td#iqfm-input-9', Obj).append(
	'<p class="caption">（なぜ選んだのか・事前検査・医師やスタッフの対応・手術当日・術後検査・ アフターケア・術後の経過・現在の状態など）</p>'
	);
});


/* flatHeights
=========================================== */

$(function() {
	$('.home #main #topNavi>ul>li').flatHeights();
});


})(jQuery); // end jquery



/* Rollover
========================================== */
function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");
		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_off."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}
		}
	}
}
if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}

