﻿///$(document).ready(function(){
//
//
//	検索タイプを切り分け
//
//
//jQuery.noConflict();	//$関数の機能深設定（prototype.jsと干渉回避）
//
function getURL_String(){
	//
	//URLの？以降を取得
	get_text = document.location.search;
	get_text = get_text.substring(1,get_text.length);	//?を切り捨て
	//
	//nullチェック
	if (get_text == ""){
		$("#MapSearchWarpper").hide();
		$("#AdvancedSearchWarpper").hide();
		$("#referrerError").show();
		getCode = "non";
		return getCode;
	};
	//
	//Item & Group に分離
	//var getCode = new Array();
	getCode = get_text.split("&");
	//
	//Itemコードの取得
	//var getItem = new Array();
	//getItem = getCode[0].split("=");
	//
	//Groupコードの取得
	//var getGroup = new Array();
	//getGroup = getCode[1].split("=");
	//
	return getCode;
}
$(document).ready(function(){
	//
	//var getCode = new Array();
	var getCode = getURL_String();
	//
	if (getCode == "non"){return;}
	//
	var getItem = getCode[0].split("=");
	var getGroup = getCode[1].split("=");
	var fadeStat = "Land";	//default=Land
	//
	//
	// コードチェック からページを切り替える
	// 		newHouse と House は共通で使用する　（中古物件、新築･未入居物件）
	//
	if (getItem[1] == "Ditail"){//getItem[1] == "Map"
		//
		// こだわり検索Item表示
		//
		$("#MapSearchWarpper").hide();
		$("#referrerError").hide();
		$("#AdvancedSearchWarpper").show();
		if (getGroup[1] == "Land"){
			$("#SearchAprtment").hide();
			$("#SearchHouse").hide();
			$("#SearchLand").show();
				//
				//select search tab opacity
				$("#sahHouse").fadeTo("fast", 0.4);
				$("#sahNewHouse").fadeTo("fast", 0.4);
				$("#sahApartment").fadeTo("fast", 0.4);
				fadeStat = "sahLand";
//			return;
		}else if (getGroup[1] == "House"){
			$("#SearchLand").hide();
			$("#SearchAprtment").hide();
			$("#SearchHouse").show();
				//
				//select search tab opacity
				$("#sahLand").fadeTo("fast", 0.4);
				$("#sahNewHouse").fadeTo("fast", 0.4);
				$("#sahApartment").fadeTo("fast", 0.4);
				fadeStat = "sahHouse";
				new2usedTitleText("House");// 共通で使用するためタイトルを変更
				document.getElementById("newOsed").value = "used";
//			return;
		}else if (getGroup[1] == "Aprtment"){
			$("#SearchLand").hide();
			$("#SearchHouse").hide();
			$("#SearchAprtment").show();
				//
				//select search tab opacity
				$("#sahLand").fadeTo("fast", 0.4);
				$("#sahHouse").fadeTo("fast", 0.4);
				$("#sahNewHouse").fadeTo("fast", 0.4);
				fadeStat = "sahApartment";
//			return;
		}else if (getGroup[1] == "newHouse"){
			$("#SearchLand").hide();
			$("#SearchAprtment").hide();
			$("#SearchHouse").show();
				//
				//select search tab opacity
				$("#sahLand").fadeTo("fast", 0.4);
				$("#sahHouse").fadeTo("fast", 0.4);
				$("#sahApartment").fadeTo("fast", 0.4);
				fadeStat = "sahNewHouse";
				new2usedTitleText("newHouse");// 共通で使用するためタイトルを変更
				document.getElementById("newOsed").value = "newBuild";
//			return;
		}else{
			$("#MapSearchWarpper").hide();
			$("#AdvancedSearchWarpper").hide();
			$("#referrerError").show();
//			return;
		};
	}else if (getItem[1] == "Map"){
		//
		//マップ検索Item表示
		$("#AdvancedSearchWarpper").hide();
		$("#referrerError").hide();
		$("#MapSearchWarpper").show();
		if (getGroup[1] == "AreaMap"){
			$("#SearchVillMap").hide();
			$("#SearchAprtmentMap").hide();
			$("#SearchAreaMap").show();
//			return;
		}else if (getGroup[1] == "VillMap"){
			$("#SearchAreaMap").hide();
			$("#SearchAprtmentMap").hide();
			$("#SearchVillMap").show();
//			return;
		}else if (getGroup[1] == "AprtmentMap"){
			$("#SearchAreaMap").hide();
			$("#SearchVillMap").hide();
			$("#SearchAprtmentMap").show();
//			return;
		}else{
			$("#MapSearchWarpper").hide();
			$("#AdvancedSearchWarpper").hide();
			$("#referrerError").show();
//			return;
		};
	}else{
		$("#MapSearchWarpper").hide();
		$("#AdvancedSearchWarpper").hide();
		$("#referrerError").show();
//		return;
	};
	//
	//default select search tab opacity
//	$("#sahHouse").fadeTo("fast", 0.4);
//	$("#sahApartment").fadeTo("fast", 0.4);
	//
	//select tab hover opacity
	$(".setTypeBtn").hover(
		function(){
			var idName = $(this).attr("id");
			if (idName != fadeStat){
				$(this).fadeTo("fast", 1.0);	//slow normal fast
			}
		},
		function(){
			var idName = $(this).attr("id");
			if (idName != fadeStat){
				$(this).fadeTo("fast", 0.4);	//slow normal fast
			}
		}
	);
	//
	//select tab click function
	//
	var stcHash = { sahLand: 'item=Ditail&id=Land', sahHouse: 'item=Ditail&id=House', sahApartment: 'item=Ditail&id=Aprtment', sahNewHouse: 'item=Ditail&id=newHouse' }
	$(".setTypeBtn").click(
		function(){
			var idName = $(this).attr("id");
			document.location = "searchtop.html?" + stcHash[idName];
		}
	);
	
});
function new2usedTitleText(txt){
	if (txt == "House"){
		document.getElementById("newAused").innerHTML = "一戸建物件"
	}else{
		document.getElementById("newAused").innerHTML = "新築・未入居物件"
	}
}
//
//=============================================================================
//
function msovMAP(tN){
	var tNS = tN.split("-");
	var idNa = "adLay" + tN;
	switch (tNS[1]){
		case "1":
			if (smp[1] == 0){document.getElementById(idNa).style.display = "block";}break;
		case "2":
			if (smp[2] == 0){document.getElementById(idNa).style.display = "block";}break;
		case "3":
			if (smp[3] == 0){document.getElementById(idNa).style.display = "block";}break;
		case "4":
			if (smp[4] == 0){document.getElementById(idNa).style.display = "block";}break;
		case "5":
			if (smp[5] == 0){document.getElementById(idNa).style.display = "block";}break;
		case "6":
			if (smp[6] == 0){document.getElementById(idNa).style.display = "block";}break;
		case "7":
			if (smp[7] == 0){document.getElementById(idNa).style.display = "block";}break;
		case "8":
			if (smp[8] == 0){document.getElementById(idNa).style.display = "block";}break;
	}
}
function msotMAP(tN){
	var tNS = tN.split("-");
	var idNa = "adLay" + tN;
	switch (tNS[1]){
		case "1":
			if (smp[1] == 0){document.getElementById(idNa).style.display = "none";}break;
		case "2":
			if (smp[2] == 0){document.getElementById(idNa).style.display = "none";}break;
		case "3":
			if (smp[3] == 0){document.getElementById(idNa).style.display = "none";}break;
		case "4":
			if (smp[4] == 0){document.getElementById(idNa).style.display = "none";}break;
		case "5":
			if (smp[5] == 0){document.getElementById(idNa).style.display = "none";}break;
		case "6":
			if (smp[6] == 0){document.getElementById(idNa).style.display = "none";}break;
		case "7":
			if (smp[7] == 0){document.getElementById(idNa).style.display = "none";}break;
		case "8":
			if (smp[8] == 0){document.getElementById(idNa).style.display = "none";}break;
	}
}

//
//=============================================================================
//
var smp = new Array(0,0,0,0,0,0,0,0,0);
//
$(document).ready(function(){
	//
	var getCode = getURL_String();
	//
	if (getCode == "non"){return;}
	//
	var getItem = getCode[0].split("=");
	var getGroup = getCode[1].split("=");
	//
	// House newHouse を共通で使用するため
	if (getGroup[1] == "newHouse"){
		getGroup[1] = "House";
	}
	var formNAME = "fom" + getGroup[1];
	//------------------------------------
	var arryCssBGC = new Array("#AAEEAA","#C4E1E1","#F4CCCC","#F7D5F7","#AAEEEE","#D5D5F7","#EEEEAA","#CCCCCC");
	var arryEleNam = new Array("smap1101","smap2102","smap3103","smap4106","smap5104","smap6105","smap7107","smap8108");
	var arryTxtGBC = new Array(".collP1",".collP2",".collP3",".collP4",".collP5",".collP6",".collP7",".collP8");
	//var arryMap = new Array("advwLayer1","advwLayer2","advwLayer3","advwLayer4","advwLayer5","advwLayer6","advwLayer7","advwLayer8");
	//------------------------------------
	var allCFlg = false;
	//
	//全域指定
	//
	$(".allKzwSW").click(function(){
		var n = -1;
		var arryMap = this.name;
		allCFlg = true;
		checkONOFF(this.name, arryEleNam, formNAME, arryTxtGBC, arryCssBGC, smp, n, allCFlg);
		allCFlg = false;
	});
	//
	//旧軽井沢
	//
	$(".smap1,.collP1").click(function(){
		var n = 0;
		checkONOFF(this.title, arryEleNam, formNAME, arryTxtGBC, arryCssBGC, smp, n, allCFlg);
	});
	//
	//新軽井沢
	//
	$(".smap2,.collP2").click(function(){
		var n = 1;
		checkONOFF(this.title, arryEleNam, formNAME, arryTxtGBC, arryCssBGC, smp, n, allCFlg);
	});
	//
	//南ヶ丘･南原
	//
	$(".smap3,.collP3").click(function(){
		var n = 2;
		checkONOFF(this.title, arryEleNam, formNAME, arryTxtGBC, arryCssBGC, smp, n, allCFlg);
	});
	//
	//南軽井沢
	//
	$(".smap4,.collP4").click(function(){
		var n = 3;
		checkONOFF(this.title, arryEleNam, formNAME, arryTxtGBC, arryCssBGC, smp, n, allCFlg);
	});
	//
	//中軽井沢
	//
	$(".smap5,.collP5").click(function(){
		var n = 4;
		checkONOFF(this.title, arryEleNam, formNAME, arryTxtGBC, arryCssBGC, smp, n, allCFlg);
	});
	//
	//千ヶ滝
	//
	$(".smap6,.collP6").click(function(){
		var n = 5;
		checkONOFF(this.title, arryEleNam, formNAME, arryTxtGBC, arryCssBGC, smp, n, allCFlg);
	});
	//
	//追分
	//
	$(".smap7,.collP7").click(function(){
		var n = 6;
		checkONOFF(this.title, arryEleNam, formNAME, arryTxtGBC, arryCssBGC, smp, n, allCFlg);
	});
	//
	//御代田
	//
	$(".smap8,.collP8").click(function(){
		var n = 7;
		checkONOFF(this.title, arryEleNam, formNAME, arryTxtGBC, arryCssBGC, smp, n, allCFlg);
	});
//
//レイヤーのONOFF、チェックボックスONOFF、チェックボックスバックグラウンド
//
function checkONOFF(thisN, arryEleNam, formNAME, arryTxtGBC, arryCssBGC, smp, n, allCFlg){
	var strDef = "adLay";
	if (!allCFlg){
		var arryMap = strDef + thisN.charAt(thisN.length-1) + "-" + (n+1);
		if (smp[n+1] == 0){
			document.getElementById(arryMap).style.display = "block"; 
			var en = arryEleNam[n];
			document.forms[formNAME].elements[en].checked = true;
			$(arryTxtGBC[n]).css("background-color",arryCssBGC[n]);
			smp[n+1] = 1;
		}else{
			document.getElementById(arryMap).style.display = "none"; 
			var en = arryEleNam[n];
			document.forms[formNAME].elements[en].checked = false;
			$(arryTxtGBC[n]).css("background-color","#FFFFFF");
			smp[n+1] = 0;
		}
	}else{
		if (smp[n+1] == 0){
			for (var i=0 ;i<arryCssBGC.length ;i++ ){
				var arryMap = thisN + (i+1);
				document.getElementById(arryMap).style.display = "block"; 
				var en = arryEleNam[i];
				document.forms[formNAME].elements[en].checked = true;
				$(arryTxtGBC[i]).css("background-color",arryCssBGC[i]);
			}
			for (var i=0 ;i<smp.length ;i++ ){smp[i] = 1;}
		}else{
			for (var i=0 ;i<arryCssBGC.length ;i++ ){
				var arryMap = thisN + (i+1);
				document.getElementById(arryMap).style.display = "none"; 
				var en = arryEleNam[i];
				document.forms[formNAME].elements[en].checked = false;
				$(arryTxtGBC[i]).css("background-color","#FFFFFF");
			}
			for (var i=0 ;i<smp.length ;i++ ){smp[i] = 0;}
		}
	}
}
});
//
//
//
/*====================================================================================================
//////////////////////////////////////////////////////////////////////////////////////////////////////

 Author : http://www.yomotsu.net
 created: 2008/03/04
 update : 2008/06/06
 Licensed under the GNU Lesser General Public License version 2.1
 
 image map 箇所の area 要素用ロールオーバー

//////////////////////////////////////////////////////////////////////////////////////////////////////
====================================================================================================*/

var yomotsuSwapImageMap = {

	main : function(){
	
	
var element = document.getElementById("boxBorder");
var area = element.getElementsByTagName("area");
//alert(area.length);
	
	
	
	
//		var area = document.getElementsByTagName("area");
		for(i=0;i<area.length;i++){
			area[i].onmouseover = yomotsuSwapImageMap.over;
			area[i].onmouseout = yomotsuSwapImageMap.out;
		}
	},
	
	over : function(){
		var i, j,
		img = document.images,
		area = this.parentNode.getElementsByTagName("area"),
		mapIdReg = new RegExp ("\\b"+this.parentNode.id+"\\b");
		
		for(i=0;i<area.length;i++){
			if(area[i]===this){
				for (j = 0; j <img.length; j++) {
					if (img[j].src.match(/_swap0\.(png|gif|jpg)\b/)&&img[j].getAttribute("usemap").match(mapIdReg)){
						img[j].src = img[j].src.replace('_swap0.', '_swap'+(i+1)+'.');
					}
					else if((img[j].style.filter)&&(img[j].style.filter.match(/_swap0\.png\b/))&&img[j].getAttribute("usemap").match(mapIdReg)){//(IE5.5-6 && png)
						img[j].style.filter = img[j].style.filter.replace('_swap0.', '_swap'+(i+1)+'.');
					}
				}
			}
		}

	},
	
	out : function(){
		var i, j,
		img = document.images,
		area = this.parentNode.getElementsByTagName("area"),
		mapIdReg = new RegExp ("\\b"+this.parentNode.id+"\\b");
		
		for(i=0;i<area.length;i++){
			if(area[i]===this){
				for (j = 0; j <img.length; j++) {
					if (img[j].src.match(/_swap[0-9]{1,}\.(png|gif|jpg)\b/)&&img[j].getAttribute("usemap").match(mapIdReg)){
						img[j].src = img[j].src.replace('_swap'+(i+1)+'.', '_swap0.');
					}
					else if((img[j].style.filter)&&(img[j].style.filter.match(/_swap[0-9]{1,}\.png\b/))&&img[j].getAttribute("usemap").match(mapIdReg)){//(IE5.5-6 && png)
						img[j].style.filter = img[j].style.filter.replace('_swap'+(i+1)+'.', '_swap0.');
					}
				}
			}
		}
	},
	
	addEvent : function(){
		try {
			window.addEventListener('load', this.main, false);
		} catch (e) {
			window.attachEvent('onload', this.main);
		}
	}
}

yomotsuSwapImageMap.addEvent();










