// JavaScript Document

function FirstScreen(){
	var box = "box_0";
	divObj = document.getElementsByTagName('div');
	matchDivObj= new RegExp(box);
	for(i=0; i < divObj.length; i++){
		if(divObj[i].id.match(matchDivObj)){
			divObj[i].style.display = 'none';
		}
	}
	
	var box00 = "box_00";
	bElements00 = document.getElementById(box00);
	if(bElements00 != null){
		bElements00.style.display = 'block';
	}
}

//クリック
function ClickBox(id,cid){
	SelectReSet();
	ShowObj(id,cid);
}
//全てリセット
function SelectReSet(){
	var box = "box_0";
	divObj = document.getElementsByTagName('div');
	matchDivObj= new RegExp(box);
	for(i=0; i < divObj.length; i++){
		if(divObj[i].id.match(matchDivObj)){
			divObj[i].style.display = 'none';
		}
	}
	
	var change = "change0";
	liObj = document.getElementsByTagName('li');
	matchLiObj = new RegExp(change)
	for(j=0; j < liObj.length; j++){
		if(liObj[j].id.match(matchLiObj)){
			liObj[j].className = '';
		}
	}
	
}

//タブ選択、任意のボックス表示
function ShowObj(id,cid){
	bElements = document.getElementById(id);
	cElements = document.getElementById(cid);
	if(bElements != null){
		bElements.style.display = 'block';
		cElements.className = 'news_tabli';
	}
}

function ClickBox02(id){
	SelectReSet02();
	ShowObj02(id);
}

function SelectReSet02(){
	hideObj02('box_00');
	hideObj02('box_01');
	hideObj02('box_02');
	hideObj02('box_03');
	hideObj02('box_04');
}

function ShowObj02(id){
	bElements = document.getElementById(id);
	if(bElements != null){
		bElements.style.display = 'block';
	}
	
}

function hideObj02(id){
	
	bElements = document.getElementById(id);
	if(bElements != null){
		bElements.style.display = 'none';
	}
}

//window.onload = GetPageBox;

function GetPageBox(){
	var get = getRequest();
	imgId = "switch_btn_00";
	if(get['Section'] != null){
		if(get['Section'] == 'guest'){
			id = 'box_00';
			imgId = "switch_btn_00";
		}else if(get['Section'] == 'rest'){
			id = 'box_01';
			imgId = "switch_btn_01";
		}else if(get['Section'] == 'banguet'){
			id = 'box_03';
			imgId = "switch_btn_03";
		}else if(get['Section'] == 'bridal'){
			id = 'box_02';
			imgId = "switch_btn_02";
		}else if(get['Section'] == 'fit'){
			id = 'box_04';
			imgId = "switch_btn_04";
		}
		hideObj02('box_00');
		hideObj02('box_01');
		hideObj02('box_02');
		hideObj02('box_03');
		ShowObj02(id);
	}
	
	SelectImg = document.getElementById(imgId);
	if(SelectImg != null){
		SelectImg.setAttribute("src", SelectImg.getAttribute("src").replace("_out.", "_over."));
	}
}

function getRequest(){
	if(location.search.length > 1) {
		var get = new Object();
		var ret = location.search.substr(1).split("&");
		for(var i = 0; i < ret.length; i++) {
			var r = ret[i].split("=");
			get[r[0]] = r[1];
		}
		return get;
	} else {
		return false;
	}
}

var SelectImg;
var defaultImg = "news_menu01_out";

function smartRollover2() {
	if(document.getElementsByTagName) {
        var images = document.getElementsByTagName("img");
        for(var i=0; i < images.length; i++) {
            /*
            //デフォルト
			if(images[i].getAttribute("src").match("news_menu01_out.jpg")){
				SelectImg = images[i];
			}
			*/
			if(images[i].getAttribute("src") != null){
				
				if(images[i].getAttribute("src").match("_out.")){
	                images[i].onmouseover = function() {
						//オーバー時
						this.setAttribute("src", this.getAttribute("src").replace("_out.", "_over."));
	                }
					images[i].onclick = function() {
						if(SelectImg != null){
							SelectImg.setAttribute("src", SelectImg.getAttribute("src").replace("_over.", "_out."));
						}
						SelectImg = this;
						hideObj02('box_00');
						hideObj02('box_01');
						hideObj02('box_02');
						hideObj02('box_03');
						hideObj02('box_04');
						ShowObj02(this.id.replace("switch_btn_", "box_"))
					}
	                images[i].onmouseout = function() {
	                    if(this != SelectImg){
							this.setAttribute("src", this.getAttribute("src").replace("_over.", "_out."));
						}
	                }
					images[i].onUnload = function() {
	                    if(this != SelectImg){
							this.setAttribute("src", this.getAttribute("src").replace("_over.", "_out."));
						}
	                }
	            }
	            
            }
            
        }
        if(SelectImg != null){
			SelectImg.setAttribute("src", SelectImg.getAttribute("src").replace("_out.", "_over."));
		}
    }
	GetPageBox();
}

if(window.addEventListener) {
    window.addEventListener("load", smartRollover2, false);
}else if(window.attachEvent) {
    window.attachEvent("onload", smartRollover2);
}

