/**
 * @Name     
 * @Desc    サイト全般に使用
 * @Author  inexio[ http://www.inexio.jp/ ]
 * @Date    2010/09/27 15:16
**/

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."));  
        }
      }
    }
  }
}



$(function()
{
	var currentSize = readCookie('glasspower.jp_FontSize');

	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('glasspower.jp_FontSize', 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;
}

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 optionalInterface()
{
    var URL_NAME = location.hostname;
    if( URL_NAME == "bizsearch-asp.accelatech.com" )
    {
        URL_NAME = "http://www.glasspower.jp/";
    }
    else
    {
        URL_NAME = "/";
    }
    document.write("<dl id=\"fontChange\">");
    document.write("<dt><img src=\"" + URL_NAME + "images/shared/txt_font.gif\" alt=\"フォントサイズ\" /></dt>");
    document.write("<dd id=\"font1\"><a href=\"javascript:void(0);\" title=\"小\" class=\"small\">小</a></dd>");
    document.write("<dd id=\"font2\"><a href=\"javascript:void(0);\" title=\"中\" class=\"middle\">中</a></dd>");
    document.write("<dd id=\"font3\"><a href=\"javascript:void(0);\" title=\"大\" class=\"large\">大</a></dd>");
    document.write("</dl>");
    document.write("<div id=\"serchBox\">");
    document.write("<form name=\"AccelaBizSearchASPForm\" id=\"bizsearchAspForm\" action=\"http://bizsearch-asp.accelatech.com/bizasp/index.php\" method=\"get\">");
    document.write("<input type=\"text\" name=\"q\" value=\"\" id=\"bizsearchAspQuery\" autocomplete=\"off\" />");
    document.write("<input type=\"submit\" id=\"serchSubmit\" value=\" 検 索 \" />");
    document.write("<input type=\"hidden\" name=\"corpId\" value=\"atc100231\" id=\"bizsearchAspCorpId\" />");
    document.write("<input type=\"hidden\" name=\"en\" value=\"\" />");
    document.write("<input type=\"hidden\" name=\"sg\" value=\"1\" />");
    document.write("</form>");
    document.write("</div>");
}



function bannerArea()
{

  var URL_PRO = location.protocol;
  if( URL_PRO == "https:" )
  {
    URL_PRO = "http://www.glasspower.jp/";
  }
  else
  {
    URL_PRO = "/";
  }
  var URL_NAME = location.hostname;
  if( URL_NAME == "bizsearch-asp.accelatech.com" )
  {
    URL_NAME = "http://www.glasspower.jp/";
  }
  else
  {
    URL_NAME = "/";
  }
	document.write("<ul class=\"bannerList\">");
  document.write("<li><a href=\"" + URL_PRO + "ability/eco/saving/\" title=\"節電シミュレーション\"><img src=\"/images/shared/btn_simu_off.png\" alt=\"節電シミュレーション\" /></a></li>");
  document.write("<li><a href=\"" + URL_PRO + "ability/safety/guideline/\" title=\"学校のガラスの見分け方\"><img src=\"/images/shared/btn_guide_off.png\" alt=\"学校のガラスの見分け方\" /></a></li>");
  document.write("</ul>");
	document.write("<dl class=\"bannerGroup\">");
	document.write("<dt><img src=\"" + URL_NAME + "images/shared/txt_group_title01.gif\" alt=\"こんな活動をしています\" /></dt>");
	document.write("<dd>");
	document.write("<ul>");
	document.write("<li><a href=\"" + URL_PRO + "about/donation/\" title=\"防災ガラス寄贈プロジェクト\"><img src=\"" + URL_NAME + "images/shared/btn_donation_off.jpg\" alt=\"防災ガラス 寄贈プロジェクト\" /></a></li>");
  //document.write("<li><a href=\"" + URL_PRO + "ability/safety/guideline/\" title=\"学校のガラスの見分け方\"><img src=\"" + URL_NAME + "images/shared/btn_guideline_off.jpg\" alt=\"学校のガラスの見分け方\" /></a></li>");
	document.write("<li><a href=\"" + URL_PRO + "about/classwork/\" title=\"ガラスの出張授業\"><img src=\"" + URL_NAME + "images/shared/btn_classwork_off.jpg\" alt=\"学ぼう ガラスの出張授業\" /></a></li>");
	document.write("<li><a href=\"" + URL_PRO + "ability/safety/demonstration/\" title=\"破壊実演出張サービス\"><img src=\"" + URL_NAME + "images/shared/btn_demonstration_off.jpg\" alt=\"防災ガラス 破壊実演出張サービス\" /></a></li>");
	document.write("</ul>");
	document.write("</dd>");
	document.write("</dl>");
	document.write("<ul class=\"bannerList\">");
	document.write("<li><a href=\"" + URL_PRO + "samples/\" title=\"エコ防災の見本帳\"><img src=\"" + URL_NAME + "images/shared/btn_sample_off.jpg\" alt=\"エコ防災の見本帳 エコ防災化に取り組む地域や建築物などをご紹介します！\" /></a></li>");
	document.write("</ul>");
	document.write("<dl class=\"bannerGroup\">");
	document.write("<dt><img src=\"" + URL_NAME + "images/shared/txt_group_title02.gif\" alt=\"スペシャルコンテンツ\" /></dt>");
	document.write("<dd>");
	document.write("<ul>");
	document.write("<li><a href=\"" + URL_PRO + "classroom/\" title=\"ドクターGのガラス教室\"><img src=\"" + URL_NAME + "images/shared/btn_classroom_off.jpg\" alt=\"ドクターGのよくわかるガラス教室\" /></a></li>");
	document.write("</ul>");
	document.write("</dd>");
	document.write("</dl>");
	document.write("<ul class=\"bannerList\">");
	document.write("<li><a href=\"http://www.itscom.net/safety/\" target=\"_blank\" title=\"「iTSCOM」のサイトを新規ページで開きます\"><img src=\"" + URL_NAME + "images/shared/btn_itscom_off.gif\" alt=\"ガラスパワーキャンペーンがラジオで紹介されました。「iTSCOM」サイトへ\" /></a>");
	document.write("<a href=\"" + URL_PRO + "news/2011/#news20110608-01\" title=\"「iTSCOM」のサイトを新規ページで開きます\"><img src=\"" + URL_NAME + "images/shared/btn_itscomguide_off.gif\" alt=\"視聴方法はこちら\" /></a></li>");
	document.write("</ul>");
}



function loadFlash(file,width,height)
{
	document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"" + width + "\" height=\"" + height + "\" id=\"flashImage\" align=\"middle\">");
	document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
	document.write("<param name=\"movie\" value=\"" + file + ".swf\" />");
	document.write("<param name=\"quality\" value=\"high\" />");
	document.write("<param name=\"wmode\" value=\"transparent\" />");
	document.write("<embed src=\"" + file + ".swf\" quality=\"high\" wmode=\"transparent\" width=\"" + width + "\" height=\"" + height + "\" name=\"flashImage\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" />");
	document.write("</object>");
}



var objWindow = null;
function popUpWindow(file,width,height,winWidth,winHeight)
{
    //popUpWindow = window.open("","newWindow","resize=0,scrollbars=0,menubar=0,directories=0,status=0,location=0,width=" + winWidth + ",height="+ winHeight");
    if (!objWindow || objWindow.close) {
    objWindow = window.open("","newWindow","width=" + winWidth + ",height="+ winHeight + ",resize=0,scrollbars=0,menubar=0,directories=0,status=0,location=0");
    }
    objWindow.document.open();
    objWindow.focus();
    objWindow.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
    objWindow.document.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
    objWindow.document.write("<head>");
    objWindow.document.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />");
    objWindow.document.write("<meta http-equiv=\"content-style-type\" content=\"text/css\" />");
    objWindow.document.write("<meta http-equiv=\"content-script-type\" content=\"text/javascript\" />");
    objWindow.document.write("<meta http-equiv=\"content-language\" content=\"ja\" />");
    objWindow.document.write("<meta name=\"author\" content=\"ガラスパワーキャンペーン事務局\" />");
    objWindow.document.write("<meta name=\"copyright\" content=\"Copyright &copy; ASAHI GLASS CO.,LTD. All Right Reserved.\" />");
    objWindow.document.write("<meta name=\"viewport\" content=\"width=" + winWidth + "\" />");
    objWindow.document.write("<style type=\"text/css\"><!-- body{margin:0;padding:0;text-align:center;} --></style>");
    objWindow.document.write("<title>ガラスパワーキャンペーン ～明日のためにガラスができること～｜ドクターGのガラス教室｜ドクターGの防災塾</title>");
    objWindow.document.write("<link rel=\"shortcut icon\" href=\"/favicon.ico\" type=\"image/ico\" />");
    objWindow.document.write("</head>");
    objWindow.document.write("<body>");
    objWindow.document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"" + width + "\" height=\"" + height + "\" id=\"flashImage\" align=\"middle\">");
    objWindow.document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
    objWindow.document.write("<param name=\"movie\" value=\"" + file + ".swf\" />");
    objWindow.document.write("<param name=\"quality\" value=\"high\" />");
    objWindow.document.write("<param name=\"wmode\" value=\"transparent\" />");
    objWindow.document.write("<embed src=\"" + file + ".swf\" quality=\"high\" wmode=\"transparent\" width=\"" + width + "\" height=\"" + height + "\" name=\"flashImage\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" />");
    objWindow.document.write("</object>");
    objWindow.document.write("</body>");
    objWindow.document.write("</html>");
    objWindow.document.close();
}



function javascriptCheck()
{
    document.write ("<p class=\"indent01 strong\">※現在お使いのブラウザはJavascriptの設定が有効になっています。このままの状態で本サイトをご覧ください。</p>");
}



