﻿//JavaScript
g_LoadedImg0 = new Array();
g_LoadedImg1 = new Array();
g_Level = "./";
var g_OpenImgTimerID;

(function(d,s,id)
{
	var js,fjs=d.getElementsByTagName(s)[0];
	if(d.getElementById(id)){return;}
	js=d.createElement(s);
	js.id=id;
	js.src="//connect.facebook.net/ja_JP/all.js#xfbml=1";
	fjs.parentNode.insertBefore(js,fjs);
}(document,'script','facebook-jssdk'));

function GetLevelTxt()
{
	var direct = 0;

	str = document.location;
	str = str.toString();
	str = str.replace("file:///D:/Web/TecSol/","http://tec-sol.com/");
	str = str.substring(str.indexOf(".com/")+5,str.length);

	for(i=0;i<=str.length;i++)
	{
		if(str.charAt(i) == "/")	direct++;
	}

	if(direct > 0)
	{
		level = "";
		for(a=1;a<=direct;a++)
		{
			level += "../";
		}
	}
	if(direct <= 0)
	{
		level = "./";
	}

	return level;
}

function PreLoadImg()
{
	g_Level = GetLevelTxt();
	g_Level += "common/img/";

	for(i=1;i<=4;i++)
	{
		// Mouseoutの画像
		g_LoadedImg0[i] = new Image();
		g_LoadedImg0[i].src = g_Level + "hnav" + i + "0.png";

		// Mouseoverの画像
		g_LoadedImg1[i] = new Image();
		g_LoadedImg1[i].src = g_Level + "hnav" + i + "1.png";
	}

	for(i=5;i<=7;i++)
	{
		g_LoadedImg0[i] = new Image();
		g_LoadedImg1[i] = new Image();
	}

	// Mouseoutの画像
	g_LoadedImg0[5].src = g_Level + "hnav_stmap0.png";
	g_LoadedImg0[6].src = g_Level + "hnav_eng0.png";
	g_LoadedImg0[7].src = g_Level + "hnav_jpn0.png";

	// Mouseoverの画像
	g_LoadedImg1[5].src = g_Level + "hnav_stmap1.png";
	g_LoadedImg1[6].src = g_Level + "hnav_eng1.png";
	g_LoadedImg1[7].src = g_Level + "hnav_jpn1.png";

	g_LoadedImg1[8] = new Image();
	g_LoadedImg1[8].src = g_Level + "lnav_bg.png";
}

function OpenImg(file_name,alt_text)
{
//	<div id="ShowArea" style="margin:0;padding:0;display:none;position:absolute;top:0;left:0;z-index:100;width:320px;hight:240px;background-color:#000;text-align:center;">&nbsp;</div>

	ImgObj = new Image();
	ImgObj.src = file_name;

	str = "<img id=\"ImgArea\" src=\"" + file_name + "\" alt=\"" + alt_text + "\" style=\"margin:15px;padding:0;border:none;display:block;\" />";
	str = str + "<form style=\"margin:0;\"><input type=\"button\" value=\"Close\" onClick=\"CloseImg()\"></form>";

	g_OpenImgTimerID = setInterval("ChangeImgPosSize(ImgObj)", 500);

	document.all["ShowArea"].innerHTML = str;
	document.all["ShowArea"].style.display = "block";
}

function ChangeImgPosSize(ImgObj)
{
	WDownSizeFlag = false;
	HDownSizeFlag = false;

	w = ImgObj.width;
	h = ImgObj.height;
	side_margin = 30;
	topbottom_margin = 80;

	if(window.innerWidth < (w + side_margin))
	{
		aspectratio = w / h;
		w = window.innerWidth - side_margin;
		h = parseInt(w / aspectratio);
		WDownSizeFlag = true;
	}
	if(window.innerHeight < (h + topbottom_margin))
	{
		aspectratio = w / h;
		h = window.innerHeight - topbottom_margin;
		w = parseInt(aspectratio * h);
		HDownSizeFlag = true;
	}
	document.all["ImgArea"].width = w;
	document.all["ImgArea"].height = h;
	document.all["ShowArea"].style.width = w + side_margin + "px";
	document.all["ShowArea"].style.height = h + topbottom_margin + "px";

	if(WDownSizeFlag)
	{
		positionL = 0;
	}
	else
	{
		positionL = parseInt((window.innerWidth - w)/2);
	}
	document.all["ShowArea"].style.left = positionL + "px";

	if(HDownSizeFlag)
	{
		positionT = window.pageYOffset;
	}
	else
	{
		positionT = window.pageYOffset + parseInt((window.innerHeight - (h + topbottom_margin))/2);
	}
	document.all["ShowArea"].style.top = positionT + "px";
}

function CloseImg()
{
	clearInterval(g_OpenImgTimerID);
	document.all["ShowArea"].innerHTML = "";
	document.all["ShowArea"].style.display = "none";
}

function WritePartition()
{
	g_Level = GetLevelTxt();

	// CommonPageHeader
	eleObj = document.getElementById("header");
	navEle = eleObj.getElementsByTagName("nav");

	str = navEle[0].innerHTML;

	i = str.indexOf("</li><li>",0);
	repStr = "</li><img src=\"" + g_Level + "common/img/hnav_prt.png\" /><li>";
	while(i > -1)
	{
		str = str.replace("</li><li>",repStr);
		i = str.indexOf("</li><li>",0);
	}

	navEle[0].innerHTML = str;

	// MainContent
	eleObj = document.getElementById("strct-main");
	navEle = eleObj.getElementsByTagName("nav");

	if((navEle.length > 0) && (navEle[0].className == "crumb"))
	{
		str = navEle[0].innerHTML;

		i = str.indexOf("</li><li>",0);
		while(i > -1)
		{
			str = str.replace("</li><li>","</li><svg><polygon fill=\"#1442cc\" points=\"0,0 2,0 5,4 2,8 0,8\" /></svg><li>");
			i = str.indexOf("</li><li>",0);
		}

		navEle[0].innerHTML = str;
	}
}

function WriteOrderQuote()
{
	g_Level = GetLevelTxt();

	eleObj = document.getElementById("strct-left");
	asdEle = eleObj.getElementsByTagName("aside");
	asdEleL = asdEle.length - 1;

	str = asdEle[asdEleL].innerHTML;

	insStr = "<ul>" +
		 "<li><a href=\"" + g_Level + "orderform.html\"><img src=\"" + g_Level + "common/img/shopcart_s.png\" alt=\"Order icon\" />ご注文</a></li>" +
		 "<li><a href=\"" + g_Level + "quoteform.html\"><img src=\"" + g_Level + "common/img/quote_s.png\" alt=\"Quote icon\" />お見積り</a></li>" +
		 "</ul>";

	asdEle[asdEleL].innerHTML = str + insStr;
}

function WriteFooter(FlagLinkToTop)
{
	g_Level = GetLevelTxt();
	var times = "";
	var DateObj = new Date();

	if(FlagLinkToTop >= 1)
	{
		document.write("<a href=\"#header\">ページの先頭へ</a>");
	}

	document.write("<ul>");
	document.write("<li><a href=\"", g_Level ,"terms.html\">ご利用条件</a></li>");
	document.write("<li><a href=\"", g_Level ,"privacy.html\">個人情報について</a></li>");
	document.write("<li><a href=\"", g_Level ,"spcf_business.html\">「特定商取引に関する法律」に基づく表示</a></li>");
	document.write("</ul>");

	times = DateObj.getFullYear();
	document.write("<p id=\"copyright\">株式会社テクソル Copyright &copy; ", times ," TecSol Inc. All rights reserved.</p>");
}

function WriteHTML5Logos()
{
	document.write("<svg height=\"64\" viewBox=\"0 0 361 200\">");
	document.write("<title>HTML5 Logos</title>");
	document.write("<polygon fill=\"#D9D9D9\" points=\"360.178,119.09 344.432,169.311 117.912,169.311 117.912,68.869 344.432,68.869 \"/>");
	document.write("<polygon fill=\"#E44D26\" points=\"12.895,183.937 0,39.305 141.693,39.305 128.784,183.914 70.76,200 \"/>");
	document.write("<polygon fill=\"#F16529\" points=\"70.847,187.704 117.733,174.705 128.765,51.13 70.847,51.13 \"/>");
	document.write("<polygon fill=\"#EBEBEB\" points=\"70.847,104.772 47.374,104.772 45.753,86.608 70.847,86.608 70.847,68.869 70.785,68.869 26.367,68.869 26.791,73.628 31.151,122.511 70.847,122.511 \"/>");
	document.write("<polygon fill=\"#EBEBEB\" points=\"70.847,150.841 70.77,150.861 51.014,145.527 49.75,131.38 40.15,131.38 31.943,131.38 34.43,159.232 70.766,169.319 70.847,169.297 \"/>");
	document.write("<path d=\"M13.184,0h9.014v8.906h8.246V0h9.016v26.97h-9.015v-9.031h-8.246v9.031h-9.015V0L13.184,0z\"/>");
	document.write("<path d=\"M51.313,8.944h-7.936V0h24.891v8.944h-7.939V26.97h-9.015L51.313,8.944L51.313,8.944z\"/>");
	document.write("<path d=\"M72.218,0h9.4l5.781,9.477L93.176,0h9.403v26.97h-8.978V13.603l-6.202,9.589h-0.154l-6.207-9.589V26.97h-8.82V0z\"/>");
	document.write("<path d=\"M107.065,0h9.018v18.056h12.677v8.915h-21.694V0z\"/>");
	document.write("<polygon fill=\"#FFFFFF\" points=\"70.785,104.772 70.785,122.511 92.628,122.511 90.569,145.516 70.785,150.855 70.785,169.311 107.15,159.232 107.417,156.235 111.585,109.535 112.019,104.772 107.238,104.772 \"/>");
	document.write("<polygon fill=\"#FFFFFF\" points=\"70.785,68.869 70.785,79.886 70.785,86.564 70.785,86.608 113.575,86.608 113.575,86.608 113.632,86.608 113.988,82.621 114.796,73.628 115.221,68.869 \"/>");
	document.write("<polygon id=\"chevron\" fill=\"#999999\" points=\"275.974,97.881 255.452,108.251 255.452,115.071 275.974,104.701 296.484,115.071 296.484,108.251 	\"/>");
	document.write("<polygon fill=\"#999999\" points=\"275.974,109.786 255.452,120.154 255.452,126.974 275.974,116.604 296.484,126.974 296.484,120.154 	\"/>");
	document.write("<polygon fill=\"#999999\" points=\"275.974,121.69 255.452,132.061 255.452,138.881 275.974,128.511 296.484,138.881 296.484,132.061 	\"/>");
	document.write("<path fill=\"#999999\" d=\"M183.311,103.09l-1.188,5.935h24.156l-0.754,3.834h-24.172l-1.171,5.935h24.156l-1.348,6.77l-9.735,3.224 l-8.438-3.224l0.576-2.937h-5.934l-1.411,7.123l13.954,5.341l16.088-5.341l2.134-10.716l0.433-2.148l2.743-13.795H183.311z\"/>");
	document.write("</svg>");
}

