// ----------------------------------------------------------------
//
//
// 共通変数
//
//
// ----------------------------------------------------------------
var _siteURL = document.location.protocol + "//" + document.domain;

// ----------------------------------------------------------------
//
//
// 共通関数
//
//
// ----------------------------------------------------------------
function mouseDown() {
	if (window.event.shiftKey == true) {
		strValue = new String(window.event.srcElement);
		if (strValue.indexOf("http", 0) >= 0) {
			alert("SHIFTキーを押しながらクリックはできません。");
			return false;
		}
	}
	if (window.event.button == 2 || window.event.button == 3) {
		alert("右クリックはできません。");
		return false;
	}
}
// ============================================================================
// Trim
// ============================================================================
function Trim(strValue) {
	if (strValue == null) {
		return "";
	} else if (strValue == "") {
		return "";
	}
	strValue = strValue.substring(0, strValue.length);
	return strValue;
}
// ============================================================================
// ロード時処理
// ============================================================================
function loadIndexPage() {
	// 背景タイマーセット
	setTitleTimer();
	setAlia(0);
	document.form.chiku[5].checked = true;
	// 非表示
	$("alia_0").style.display = "block";
	$("alia_1").style.display = "none";
	$("alia_2").style.display = "none";
	$("alia_3").style.display = "none";
	$("alia_4").style.display = "none";
	$("alia_5").style.display = "none";
	$("banner").style.display = "block";
	$("searchList").style.display = "none";
	$("detailSearch").style.display = "none";
	$("map").style.display = "none";
	// お知らせ表示
	var myAjax = new Ajax.Request("./classes/index/index/infomation.php", { 
		method: "post", 
		asynchronous:false,
		parameters: Form.serialize("form") });
	$("infomation").innerHTML = myAjax.transport.responseText;
	// お勧め
	var myAjax = new Ajax.Request("./classes/index/index/osusume.php", { 
		method: "post", 
		asynchronous:false,
		parameters: Form.serialize("form") });
	$("osusume").innerHTML = myAjax.transport.responseText;
	// 売買物件
	var myAjax = new Ajax.Request("./classes/index/index/baibai.php", { 
		method: "post", 
		asynchronous:false,
		parameters: Form.serialize("form") });
	$("baibai").innerHTML = myAjax.transport.responseText;
}
// ============================================================================
// ロード時処理
// ============================================================================
function loadTenpoPage() {
	// 背景タイマーセット
	setTitleTimer();
	//setAlia(0);
	document.form.chiku[5].checked = true;
	// 非表示
	//$("alia_0").style.display = "block";
	//$("alia_1").style.display = "none";
	//$("alia_2").style.display = "none";
	//$("alia_3").style.display = "none";
	//$("alia_4").style.display = "none";
	//$("alia_5").style.display = "none";
	$("banner").style.display = "block";
	$("searchList").style.display = "none";
	// お知らせ表示
	var myAjax = new Ajax.Request("./classes/index/index/infomation.php", { 
		method: "post", 
		asynchronous:false,
		parameters: Form.serialize("form") });
	$("infomation").innerHTML = myAjax.transport.responseText;
	// お勧め
	var myAjax = new Ajax.Request("./classes/index/index/osusume_tenpo.php", { 
		method: "post", 
		asynchronous:false,
		parameters: Form.serialize("form") });
	$("osusume").innerHTML = myAjax.transport.responseText;
}
// ============================================================================
// ロード時処理
// ============================================================================
function loadIndexPage2() {
	// 背景タイマーセット
	setTitleTimer();
	// 非表示
	$("banner").style.display = "block";
	// お勧め
	var myAjax = new Ajax.Request("./classes/index/index/osusume.php", { 
		method: "post", 
		asynchronous:false,
		parameters: Form.serialize("form") });
	$("osusume").innerHTML = myAjax.transport.responseText;
}
function setAlia(index) {
	$("alia_0").style.display = "none";
	$("alia_1").style.display = "none";
	$("alia_2").style.display = "none";
	$("alia_3").style.display = "none";
	$("alia_4").style.display = "none";
	$("alia_5").style.display = "none";
	$("alia_" + index).style.display = "block";
}
// 透明度が10になるまで+1加算する（タイマー）
var nTitle = 1;
function setTitleTimer() {
	setTimeout('setTitleTimer()',6000);
	if (nTitle == 1) {
		$("banner").style.background = "url('./images/title.jpg')";
		nTitle = 2;
	} else if (nTitle == 2) {
		$("banner").style.background = "url('./images/title2.jpg')";
		nTitle = 3;
	} else if (nTitle == 3) {
		$("banner").style.background = "url('./images/title3.jpg')";
		nTitle = 1;
	}
}
// HpbImgSwap:
//
function HpbImgSwap(imgName, imgSrc)
{
  var appVer=parseInt(navigator.appVersion);
  var isNC=false,isN6=false,isIE=false;
  if (document.all && appVer >= 4) isIE=true; else
    if (document.getElementById && appVer > 4) isN6=true; else
      if (document.layers && appVer >= 4) isNC=true;
  if (isNC||isN6||isIE)
  {
    if (document.images)
    {
      var img = document.images[imgName];
      if (!img) img = HpbImgFind(document, imgName);
      if (img) img.src = imgSrc;
    }
  }
}
// ============================================================================
// 検索時処理
// ============================================================================
function searchList(strKbn, strPage) {
	// 物件検索処理
	var myAjax = new Ajax.Request("./classes/index/search/search.php?kbn=" + strKbn + "&page=" + strPage, { 
		method: "post", 
		asynchronous:false,
		parameters: Form.serialize("form") });
	$("searchList").innerHTML = myAjax.transport.responseText;
	$("searchList").style.display = "block";
}
// ============================================================================
// 検索時処理
// ============================================================================
function searchTenpoList(strKbn, strPage) {
	// 物件検索処理
	var myAjax = new Ajax.Request("./classes/index/search/search_tenpo.php?kbn=" + strKbn + "&page=" + strPage, { 
		method: "post", 
		asynchronous:false,
		parameters: Form.serialize("form") });
	$("searchList").innerHTML = myAjax.transport.responseText;
	$("searchList").style.display = "block";
}
// ============================================================================
// 
// ============================================================================
var detailFlg = true;
function detailSearch() {
	if (detailFlg == true) {
		$("detailSearch").style.display = "block";
		detailFlg = false;
	} else {
		$("detailSearch").style.display = "none";
		detailFlg = true;
	}
}
function mapDisp(mapFlg) {
	if (mapFlg == true) {
		$("map").style.display = "block";
	} else {
		$("map").style.display = "none";
	}
}
// ----------------------------------------------------------------
// 問合せ送信
// ----------------------------------------------------------------
function sendMail() {
	if (confirm("お問合せを送信します。よろしいですか？") == false) {
		return false;
	}

	// 登録処理実行
	var myAjax = new Ajax.Request(_siteURL + "/classes/index/mail/sendmail.php", { 
		method: "post", 
		parameters: Form.serialize("form"),
		onComplete: sendMail_Comp });
}
function sendMail_Comp(httpObj) {
	//-- レスポンス取得
	strRtn = Trim(httpObj.responseText);
	alert(strRtn);
}
// ============================================================================
// 
// ============================================================================
function pageDetail(no) {
	//newWin = window.open("./classes/index/detail/PageView.php?no=" + no, "win", "resizable=yes,toolbar=yes,location=no,menubar=no,status=no,titlebar=no,toolbar=no","A", "A");
	window.open("./classes/index/detail/PageView.php?no=" + no, "", "toolbar=no,menubar=no,status=no,titlebar=no,scrollbars=yes,location=no,resizable=yes");
}
// ============================================================================
// 
// ==========================================================================
var map = null;
var geocoder = null;
function load(address) {
	if (GBrowserIsCompatible()) {
		// mapオブジェクトを生成する
		map = new GMap2(document.getElementById("map"));
		// geocoderオブジェクトを生成する
		geocoder = new GClientGeocoder();
		// controlを追加する
		map.addControl(new GSmallMapControl());
		geocoder.getLatLng(
			address,
			function(point) {
				// pointはGLatLngオブジェクト
				if (!point) {
					alert(address + "が地図に見つかりませんでした。");
				} else {
					map.setCenter(point, 13);
					// マーカオブジェクトを生成する
					var marker = new GMarker(point);
					// マーカを表示させる
					map.addOverlay(marker);
					// 住所を表示させる
					//marker.openInfoWindowHtml(address);
				}
			}
		);
		//$("map").style.display = "block";
	}
}  
var qsParm = new Array(); 
function retrieveGETqs() { 
	var query = window.location.search.substring(1); 
	var parms = query.split('&'); 
	for (var i=0; i<parms.length; i++) { 
		var pos = parms[i].indexOf('='); 
		if (pos > 0) { 
			var key = parms[i].substring(0,pos); 
			var val = parms[i].substring(pos+1); 
			qsParm[key] = val; 
		} 
	} 
}
function getQs(key) {
	if (qsParm[key] == null) {
		return "";
	} else {
		return qsParm[key];
	}
}
