/**
 * @Name     
 * @Desc    サイト全般に使用
 * @Author  Y.Okuyama[inexio]
 * @Date    2010/02/15 10:12
**/

function loadTopFlash()
{
	document.write("<h2>");
	document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"645\" height=\"430\" id=\"flashImage\" align=\"middle\">");
	document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
	document.write("<param name=\"movie\" value=\"/images/flash/movie.swf\" />");
	document.write("<param name=\"quality\" value=\"high\" />");
	document.write("<param name=\"wmode\" value=\"transparent\" />");
	document.write("<embed src=\"/images/flash/movie.swf\" quality=\"high\" wmode=\"transparent\" width=\"645\" height=\"430\" name=\"flashImage\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" />");
	document.write("</object>");
    document.write("<span>創業明治五年 信頼と確かな技術</span>");
    document.write("</h2>");
}

function sourceReplace()
{  
  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", sourceReplace, false);
  window.addEventListener("load", setupZoom, false);
}
else if(window.attachEvent)
{
  window.attachEvent("onload", sourceReplace);
  window.attachEvent("onload", setupZoom);
}





$(function()
{
	var currentSize = readCookie('onosekizaiFontSize');

	if (currentSize)
	{
		switchSize(currentSize);
	};

	$("a.small").click(function()
	{
		switchSize("sizeSmall");
		return false;
	});
  
	$("a.middle").click(function()
	{
 		switchSize("sizeMiddle");
 		return false;
 	});

	$("a.large").click(function()
	{
		switchSize("sizeLarge");
		return false;
 	});
});


function switchSize(className)
{
	$("body").removeAttr("class").addClass(className);
	createCookie('onosekizaiFontSize', className, 365);
};


// cookie script http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";

	document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');

	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
 	}
	return null;
}



function fontChange()
{
    document.write("<dl id=\"fontChange\">");
    document.write("<dt><img src=\"/shared/images/txt_font.gif\" alt=\"フォントサイズ\" /></dt>");
    document.write("<dd id=\"font1\"><a href=\"javascript:void(0);\" class=\"small\">小</a></dd>");
    document.write("<dd id=\"font2\"><a href=\"javascript:void(0);\" class=\"middle\">中</a></dd>");
    document.write("<dd id=\"font3\"><a href=\"javascript:void(0);\" class=\"large\">大</a></dd>");
    document.write("</dl>");
};



function feedPreview()
{
    var feed = new google.feeds.Feed("http://feeds.fc2.com/fc2/xml?host=onosekizaiten.blog23");
    feed.setNumEntries(5);
    feed.load(function(result)
    {
        if (!result.error)
        {
            var container = document.getElementById("feed");
            for (var i = 0; i < result.feed.entries.length; i++)
            {
                var entry = result.feed.entries[i];
                var dd = new Date(entry.publishedDate); // now
                var yearNum = dd.getYear();
                if (yearNum < 2000) yearNum += 1900;
                var date = "<dl class=\"news\">";
                container.innerHTML += date + "<dt>" + yearNum + "年"+(dd.getMonth()+1)+"月"+dd.getDate()+"日</dt>";
                container.innerHTML += date + "<dd><a href=\"" + entry.link + "\" target=\"_blank\" title=\"新規ページで表示します\" class=\"otherLink\">" + entry.title + "</a></dd>";
                container.innerHTML += date + "</dl>";
            }
        }
    });
}



function googleMapsIsawa()
{
    document.write("<p class=\"noParagraph\"><iframe width=\"645\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"http://maps.google.co.jp/maps?f=q&amp;hl=ja&amp;geocode=&amp;q=%E5%B0%8F%E9%87%8E%E7%9F%B3%E6%9D%90%E5%BA%97%E3%80%80%E7%9F%B3%E5%92%8C%E5%B1%95%E7%A4%BA%E5%A0%B4&amp;sll=35.661899,138.599224&amp;sspn=0.035007,0.070038&amp;ie=UTF8&amp;hq=%E5%B0%8F%E9%87%8E%E7%9F%B3%E6%9D%90%E5%BA%97%E3%80%80%E7%9F%B3%E5%92%8C%E5%B1%95%E7%A4%BA%E5%A0%B4&amp;hnear=&amp;ll=35.652662,138.625143&amp;spn=0.106417,0.222988&amp;z=13&amp;iwloc=A&amp;brcurrent=3,0x601bf850977851a9:0xc276c11755ca7309,0&amp;cid=7514378320065120742&amp;output=embed\"></iframe></p>");
    document.write("<p class=\"alRight small\"><a href=\"http://maps.google.co.jp/maps?f=q&amp;hl=ja&amp;geocode=&amp;q=%E5%B0%8F%E9%87%8E%E7%9F%B3%E6%9D%90%E5%BA%97%E3%80%80%E7%9F%B3%E5%92%8C%E5%B1%95%E7%A4%BA%E5%A0%B4&amp;sll=35.661899,138.599224&amp;sspn=0.035007,0.070038&amp;ie=UTF8&amp;hq=%E5%B0%8F%E9%87%8E%E7%9F%B3%E6%9D%90%E5%BA%97%E3%80%80%E7%9F%B3%E5%92%8C%E5%B1%95%E7%A4%BA%E5%A0%B4&amp;hnear=&amp;ll=35.632662,138.615143&amp;spn=0.106417,0.222988&amp;z=13&amp;iwloc=A&amp;brcurrent=3,0x601bf850977851a9:0xc276c11755ca7309,0&amp;cid=7514378320065120742&amp;source=embed\" class=\"otherLink\">大きな地図で見る</a></p>");
}
