/**
 * @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);
}
else if(window.attachEvent)
{
  window.attachEvent("onload", sourceReplace);
}



$(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>");
};

