var useBrowser ="none";
var targetId = "none";

var flagVariation = 0;
var variationValue = 1;
var alphaValue = 0;
var intervalValue = 15;

var windowHeight = 0;
var windowHeight_Min = 500;
var windowHeight_Var = -45;
var windowHeight_BoxVar = -105;

function midashiAction(mId,mFlag){
	if (mId == "midashi0"){
		if (mFlag!="0"){
			document.getElementById('midashi_logo_00').style.backgroundColor = "white";
			document.getElementById('midashi_logo_00').style.color = "#FA6666";
			document.getElementById('midashi_logo_00').style.borderColor = "#FA6666";
			document.getElementById('midashi_logo_00').style.borderStyle = "double";
			document.getElementById('midashi_logo_00').style.cursor = "pointer";
		}else{
			document.getElementById('midashi_logo_00').style.backgroundColor = "#FA6666";
			document.getElementById('midashi_logo_00').style.color = "white";
			document.getElementById('midashi_logo_00').style.borderColor = "black";
			document.getElementById('midashi_logo_00').style.borderStyle = "double";
			document.getElementById('midashi_logo_00').style.cursor = "default";
		}
	}else if (mId == "midashi1"){
		if (mFlag!="0"){
			document.getElementById('midashi_logo_01').style.backgroundColor = "white";
			document.getElementById('midashi_logo_01').style.color = "#66BB66";
			document.getElementById('midashi_logo_01').style.borderColor = "#66BB66";
			document.getElementById('midashi_logo_01').style.borderStyle = "double";
			document.getElementById('midashi_logo_01').style.cursor = "pointer";
		}else{
			document.getElementById('midashi_logo_01').style.backgroundColor = "#66BB66";
			document.getElementById('midashi_logo_01').style.color = "white";
			document.getElementById('midashi_logo_01').style.borderColor = "black";
			document.getElementById('midashi_logo_01').style.borderStyle = "double";
			document.getElementById('midashi_logo_01').style.cursor = "default";
		}
	}else if (mId == "midashi2"){
		if (mFlag!="0"){
			document.getElementById('midashi_logo_02').style.backgroundColor = "white";
			document.getElementById('midashi_logo_02').style.color = "#6666EE";
			document.getElementById('midashi_logo_02').style.borderColor = "#6666EE";
			document.getElementById('midashi_logo_02').style.borderStyle = "double";
			document.getElementById('midashi_logo_02').style.cursor = "pointer";
		}else{
			document.getElementById('midashi_logo_02').style.backgroundColor = "#6666EE";
			document.getElementById('midashi_logo_02').style.color = "white";
			document.getElementById('midashi_logo_02').style.borderColor = "black";
			document.getElementById('midashi_logo_02').style.borderStyle = "double";
			document.getElementById('midashi_logo_02').style.cursor = "default";
		}
	}
	setAlphaTargetId(mId,mFlag);
}
function menuAction(mId,mFlag){
	if (mId == "menuNo00_S"){
		if (mFlag=="0"){
			document.getElementById('menuNo00').style.backgroundImage = "url(./images/button_bg_img.jpg)";
			document.getElementById('menuNo00').style.cursor = "default";
		}else if (mFlag=="1"){
			document.getElementById('menuNo00').style.backgroundImage = "url(./images/button_bg_act_img.jpg)";
			document.getElementById('menuNo00').style.cursor = "pointer";
		}else{
			document.getElementById('menuNo00_S').style.display = "none";
			return;
		}
	}else if (mId == "menuNo01_S"){
		if (mFlag=="0"){
			document.getElementById('menuNo01').style.backgroundImage = "url(./images/button_bg_img.jpg)";
			document.getElementById('menuNo01').style.cursor = "default";
		}else if (mFlag=="1"){
			document.getElementById('menuNo01').style.backgroundImage = "url(./images/button_bg_act_img.jpg)";
			document.getElementById('menuNo01').style.cursor = "pointer";
		}else{
			document.getElementById('menuNo01_S').style.display = "none";
			return;
		}
	}else if (mId == "menuNo02_S"){
		if (mFlag=="0"){
			document.getElementById('menuNo02').style.backgroundImage = "url(./images/button_bg_img.jpg)";
			document.getElementById('menuNo02').style.cursor = "default";
		}else if (mFlag=="1"){
			document.getElementById('menuNo02').style.backgroundImage = "url(./images/button_bg_act_img.jpg)";
			document.getElementById('menuNo02').style.cursor = "pointer";
		}
		return;
	}else if (mId == "menuNo03_S"){
		if (mFlag=="0"){
			document.getElementById('menuNo03').style.backgroundImage = "url(./images/button_bg_img.jpg)";
			document.getElementById('menuNo03').style.cursor = "default";
		}else if (mFlag=="1"){
			document.getElementById('menuNo03').style.backgroundImage = "url(./images/button_bg_act_img.jpg)";
			document.getElementById('menuNo03').style.cursor = "pointer";
		}
		return;
	}else if (mId == "menuNo04_S"){
		if (mFlag=="0"){
			document.getElementById('menuNo04').style.backgroundImage = "url(./images/button_bg_img.jpg)";
			document.getElementById('menuNo04').style.cursor = "default";
		}else if (mFlag=="1"){
			document.getElementById('menuNo04').style.backgroundImage = "url(./images/button_bg_act_img.jpg)";
			document.getElementById('menuNo04').style.cursor = "pointer";
		}else{
			document.getElementById('menuNo04_S').style.display = "none";
			return;
		}
	}else if (mId == "menuNo05_S"){
		if (mFlag=="0"){
			document.getElementById('menuNo05').style.backgroundImage = "url(./images/button_bg_img.jpg)";
			document.getElementById('menuNo05').style.cursor = "default";
		}else if (mFlag=="1"){
			document.getElementById('menuNo05').style.backgroundImage = "url(./images/button_bg_act_img.jpg)";
			document.getElementById('menuNo05').style.cursor = "pointer";
		}
		return;
	}
	setAlphaTargetId(mId,mFlag);
}
function setAlphaTargetId(mId,mFlag){
	if (targetId != document.getElementById(mId)){
		setDisplay(mId);
		flagVariation = mFlag;
		if (flagVariation == 0){
			alphaValue = 10;
		}else{
			alphaValue = 0;
		}
		setAlpha();
	}else{
		flagVariation = mFlag;
		setAlpha();
	}
}
function setDisplay(mId){
	if (targetId != "none"){
		targetId.style.display = "none";
	}
	targetId = document.getElementById(mId);
	targetId.style.display = "block";	
}
function changeAlpha(){
	if (targetId != "none" && flagVariation != 2){
		if (flagVariation == 0 && alphaValue > 0){
			alphaValue = alphaValue - variationValue;
			if (alphaValue <= 0){
				alphaValue = 0;
				flagVariation = 2;
				targetId.style.display = "none";
				targetId = "none";
				return;
			}
		}
		if (flagVariation == 1 && alphaValue < 10){
			alphaValue = alphaValue + variationValue;
			if (alphaValue >= 10){
				alphaValue = 10;
				flagVariation = 2;
			}
		}
		setAlpha();
	}
}
function setAlpha(){
    targetId.style.filter = 'alpha(opacity=' + (alphaValue * 10) + ')';
   	targetId.style.MozOpacity = alphaValue / 10;
   	targetId.style.opacity = alphaValue / 10;
}

setInterval("changeAlpha()",intervalValue);

window.onload = function checkBrowser() {
	if(/a/[-1]=='a'){
		useBrowser= "FireFox";
		variationValue = 1;
		intervalValue = 100;
	}else{
		variationValue = 1;
		intervalValue = 100;
	}
	resizeHeight();
}
window.onresize = resizeHeight;

function resizeHeight() {

	tmpHeight = document.all ? document.documentElement.clientHeight : window.innerHeight;
	if ( tmpHeight <= 0 || windowHeight == tmpHeight){
		return;
	}
	if ( tmpHeight < windowHeight_Min ) {
		tmpHeight = windowHeight_Min;
	}
	if (windowHeight != tmpHeight){
		windowHeight = tmpHeight;
		if (document.all) {
			var tmp = windowHeight + windowHeight_Var;
			document.styleSheets[0].addRule("#base .header-main_ni", "height:" + tmp + "px");
			tmp = windowHeight + windowHeight_BoxVar;
			document.styleSheets[0].addRule(".menu_right", "height:" + tmp + "px");
		} else {
			var tmp = windowHeight + windowHeight_Var;
			document.styleSheets[0].insertRule("#base .header-main_ni {height:" + tmp + "px}", document.styleSheets[0].cssRules.length);
			tmp = windowHeight + windowHeight_BoxVar;
			document.styleSheets[0].insertRule(".menu_right {height:" + tmp + "px}", document.styleSheets[0].cssRules.length);
		}
	}
}