// JavaScript Document
$(function(){
//プリロードイメージ
	var buttonImg=$('#content img[src*="_off"]');
	buttonImg.each(function()
		{
			plImg=$(this).attr("src").split("_");
			if(plImg.length==3){
				crtFileType=plImg[2].split(".");
					$(this).attr("src",plImg[0]+"_"+plImg[1]+"_on."+crtFileType[1]);
					$(this).attr("src",plImg[0]+"_"+plImg[1]+"_off."+crtFileType[1]);
			}else if(plImg.length==2){
				crtFileType=plImg[1].split(".");
					$(this).attr("src",plImg[0]+"_on."+crtFileType[1]);
					$(this).attr("src",plImg[0]+"_off."+crtFileType[1]);
			}
		});
//ロールオーバー
	buttonImg.hover(
		function(){
			crtImg=$(this).attr("src").split("_");
			if(crtImg.length==3){
				crtFileType=crtImg[2].split(".");
				$(this).attr("src",crtImg[0]+"_"+crtImg[1]+"_on."+crtFileType[1]);
			}else if(crtImg.length==2){
				crtFileType=crtImg[1].split(".");
				$(this).attr("src",crtImg[0]+"_on."+crtFileType[1]);
			}
		},
		function(){
			crtImg=$(this).attr("src").split("_");
			if(crtImg.length==3){
				crtFileType=crtImg[2].split(".");
				$(this).attr("src",crtImg[0]+"_"+crtImg[1]+"_off."+crtFileType[1]);
				
				$("#" + crtTxtSize + " img").attr("src","/images/button/textSize/text_" + crtTxtSize + "_crt.gif");
			}else if(crtImg.length==2){
				crtFileType=crtImg[1].split(".");
				$(this).attr("src",crtImg[0]+"_off."+crtFileType[1]);
				
				$("#" + crtTxtSize + " img").attr("src","/images/button/textSize/text_" + crtTxtSize + "_crt.gif");
			}
		});
	
	
//ソーシャルブックマーク
	$("#sbm img").click(function()
	{
		switch ($(this).attr("id"))
		{
			case "bm-hatena":
				location.href='http://b.hatena.ne.jp/append?'+encodeURIComponent(window.location.href);
				break;
			case "bm-yahoo":
				window.open('http://bookmarks.yahoo.co.jp/bookmarklet/showpopup?t='+encodeURIComponent(document.title)+'&u='+encodeURIComponent(window.location.href)+'&opener=bm&ei=UTF-8','popup','width=550px,height=480px,status=1,location=0,resizable=1,scrollbars=0,left=100,top=50',0);
				break;
			case "bm-google":
				location.href='http://www.google.com/bookmarks/mark?op=edit&bkmk='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title);
				break;
			case "bm-livedoor":
				location.href='http://clip.livedoor.com/redirect?link='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title);
				break;
			case "bm-del":
				location.href='http://del.icio.us/post?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title);
				break;
			case "bm-fc2":
				location.href='http://bookmark.fc2.com/user/post?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);
				break;
			case "bm-buzzurl":
				location.href='http://buzzurl.jp/entry/'+window.location.href;
				break;
			default:
				break;
		}
	});
//外部リンク
	$("a[href^='/jump.php']").click(function()
	{
		$(this).attr("target","_blank");
	});
	$("#main a[href^='http://']").click(function()
	{
		crtLink = $(this).attr("href").split("/");
		if(crtLink[2] != "www.dr-lasik.com")
		{
			$(this).attr("target","_blank");
		}
	});

//文字サイズクッキー
	var mainTxt = "#main .main2 p, #main .main2 li, #index #main p";
	var crtTxtSize = $.cookie("txtSize");
	if(crtTxtSize == null) crtTxtSize = "small";
	$(mainTxt).css("font-size",crtTxtSize);
	$("#" + crtTxtSize + " img").attr("src","/images/button/textSize/text_" + crtTxtSize + "_crt.gif");
	$("#text_size a").click(function()
	{
		preTxtSize = crtTxtSize;
		crtTxtSize = $(this).attr("id");
		$(mainTxt).css("font-size",crtTxtSize);
		$.cookie("txtSize", crtTxtSize, { expires: 60, dmain: ".dr-lasik.com", path:"/"});
		$("#" + preTxtSize + " img").attr("src","/images/button/textSize/text_" + preTxtSize + "_off.gif"); 
		$("#" + crtTxtSize + " img").attr("src","/images/button/textSize/text_" + crtTxtSize + "_crt.gif");
	});
	/*
//地域別マップ
	var indexMap = $("#index #clinic_map");
	var mapPosition = $("#clinic_map a img");
	var changeMap = $("#change_map");
	mapPosition.hover(function()
		{
			changeMap.remove();
			crtId = $(this).attr("id");
			indexMap.prepend('<img src="images/photo/map_'+ crtId + '.jpg" width="340" height="240" id="change_map" />');
			changeMap = $("#change_map");
			changeMap.fadeIn(150,"swing");
		},function()
		{
			changeMap.fadeOut(500,"swing",function()
			{
				changeMap.remove();
			});
		});
	*/
	/*var mapCircle = $("#clinic_map #circle");
	var mapPosition = $("#clinic_map a img");
	mapPosition.hover(function()
		{
			mapCircle.queue("fx",[]).stop();
			mapCircle.css({"height":"1px","width":"1px","opacity":0});
			switch ($(this).attr("id"))
			{
				case "sapporo":
					mapCircle.css({"left":"246px","top":"16px"});
					crtPosX = "221px";
					crtPosY = "-9px";
					break;
				case "tokyo":
					mapCircle.css({"left":"206px","top":"179px"});
					crtPosX = "181px";
					crtPosY = "154px";
					break;
				case "nagoya":
					mapCircle.css({"left":"169px","top":"189px"});
					crtPosX = "144px";
					crtPosY = "163px";
					break;
				case "osaka":
					mapCircle.css({"left":"143px","top":"201px"});
					crtPosX = "118px";
					crtPosY = "176px";
					break;
				case "fukuoka":
					mapCircle.css({"left":"60px","top":"221px"});
					crtPosX = "35px";
					crtPosY = "196px";
					break;
			}
			mapCircle.animate({
				width:"50px",
				height:"50px",
				left:crtPosX,
				top:crtPosY,
				opacity:1},
				200,"swing");
		},function(){
			mapCircle.animate({"opacity":0},200,"swing");
		});*/

//altテスト
	/*$("img").each(function()
	{
		$(this).after('<div>' + $(this).attr("alt") + '</div>');
	});
	$("#header").append('<div>description: ' + $("meta:[name^='description']").attr("content") + '</div>');
	$("#header").append('<div>keywords   : ' + $("meta:[name^='keywords']").attr("content") + '</div>');*/
});

//ソーシャルブックマーク
function addBookmark(title,url) { 
    if (window.sidebar) { 
        window.sidebar.addPanel(title, url,""); 
    } else if( document.all ) { 
        window.external.AddFavorite( url, title); 
    } else if( window.opera && window.print ) { 
        return true; 
    } 
} 

