var altL = "左へ";
var altR = "右へ";
var iconpath = "/page_img/"
var lURL,rURL,dist,suffix;

browserType="";
if(navigator.userAgent.indexOf("MSIE") != -1){
	browserType="IE";
}
else if(navigator.userAgent.indexOf("Firefox") != -1){
	browserType="Firefox";
}
else if(navigator.userAgent.indexOf("Safari") != -1){
	browserType="Safari";
}
else if(navigator.userAgent.indexOf("Gecko") != -1){
	browserType="Gecko";
}
else if(navigator.userAgent.indexOf("Netscape") != -1){
	browserType="NN";
}

//キーが押されたら移動
function movePage(event){
	if(browserType=="IE"){
		var key=window.event.keyCode;
		var ctrlFlg=window.event.ctrlKey;
		var altFlg=window.event.altKey;
		var shiftFlg=window.event.shiftKey;
	}
	else if(browserType=="Gecko" || browserType=="Firefox" || browserType=="NN" || browserType=="Safari"){
		var key=event.which;
		var ctrlFlg=event.ctrlKey;
		var altFlg=event.altKey;
		var shiftFlg=event.shiftKey;
	}
	if(!ctrlFlg && !altFlg && !shiftFlg){
		if(key=="37"){
			if(typeof(prevURL) !="undefined"){
				location.href=prevURL;
			}
			if(typeof(leftURL) !="undefined"){
				location.href=leftURL;
			}
		}
		if(key=="39"){
			if(typeof(nextURL) !="undefined"){
				location.href=nextURL;
			}
			if(typeof(rightURL) !="undefined"){
				location.href=rightURL;
			}
		}
	}
}


//矢印表示
function showArrow(){
	//用意
	if(typeof(arrowDistance) =="undefined"){
		dist = 800;
	} else {
		dist = arrowDistance;
	}
	if(typeof(iconNameSuffix) =="undefined"){
		suffix = "";
	} else {
		suffix = iconNameSuffix;
	}
	if(typeof(leftURL) !="undefined"){
		lURL = leftURL;
	}
	if(typeof(rightURL) !="undefined"){
		rURL = rightURL;
	}
	if(typeof(prevURL) !="undefined"){
		lURL = prevURL;
	}
	if(typeof(nextURL) !="undefined"){
		rURL = nextURL;
	}
	
	var imgPathR = iconpath + "yajiR" + suffix + ".gif";
	var imgPathL = iconpath + "yajiL" + suffix + ".gif";
	
	//DOM
	var bodyelem = document.getElementsByTagName("body")[0];

	var div1 = document.createElement("div");
	div1.setAttribute("id","pageKey");
	bodyelem.appendChild(div1);

	var divC = document.createElement("div");
	divC.setAttribute("id","pageCenter");
	div1.appendChild(divC);

	var divL = document.createElement("div");
	divL.setAttribute("id","pageLeft");
	divC.appendChild(divL);

	var divR = document.createElement("div");
	divR.setAttribute("id","pageRight");
	divC.appendChild(divR);
	
	if(typeof(lURL) !="undefined"){
		var ancL = document.createElement("a");
		ancL.setAttribute("href",lURL);
		divL.appendChild(ancL);

		var img = document.createElement("img");
		img.setAttribute("src",imgPathL);
		img.setAttribute("alt",altL);
		img.setAttribute("border","0");
		img.setAttribute("id","yajiL");
		ancL.appendChild(img);
	}
	
	if(typeof(rURL) !="undefined"){
		var ancR = document.createElement("a");
		ancR.setAttribute("href",rURL);
		divR.appendChild(ancR);

		var img = document.createElement("img");
		img.setAttribute("src",imgPathR);
		img.setAttribute("alt",altR);
		img.setAttribute("border","0");
		img.setAttribute("id","yajiR");
		ancR.appendChild(img);
	}
	//CSS
	addRule( "div#pageKey", "text-align:center;width:100%;height:40px;bottom:50px;position:fixed;left:0;visibility:hidden;" );
	addRule( "div#pageCenter", "margin:0 auto;width:" + dist + "px;height:40px;visibility:hidden;" );
	addRule( "div#pageRight", "margin:0;width:50%;height:40px;text-align:right;float:left;visibility:hidden;" );
	addRule( "div#pageLeft", "margin:0;width:50%;height:40px;text-align:left;float:left;visibility:hidden;" );
	addRule( "img#yajiL", "visibility:visible;" );
	addRule( "img#yajiR", "visibility:visible;" );
}

//CSS生成関数
function addRule(selector, rule){
	var ss = document.styleSheets[0];
	
	if (document.all) {
		ss.addRule(selector, rule);
	} else {
		ss.insertRule(selector + " {" + rule + "}", ss.cssRules.length);
	}
}


