//---------------------------------------------------------------------------
// トップページ地域検索用
//---------------------------------------------------------------------------
function form_area_post(apoint) {
	if (document.area_form.select_type[0].checked) {
//		window.location.href="../digest/?mode=buy&amp;type=2,3,4&amp;area="+apoint;
		window.location.href="../digest/?mode=buy&type=2,3,4&area="+apoint;
	} else if (document.area_form.select_type[1].checked) {
//		window.location.href="../digest/?mode=buy&amp;type=1&amp;area="+apoint;
		window.location.href="../digest/?mode=buy&type=1&area="+apoint;
	}
}

//---------------------------------------------------------------------------
// サイドメニュー検索用
//---------------------------------------------------------------------------
function form_word_post() {
	if (document.word_form.select_type[0].checked) {
		window.location.href="../digest/?mode=lease&keyword="+encodeURI(document.word_form.keyword.value);
	} else if (document.word_form.select_type[1].checked) {
		window.location.href="../digest/?mode=buy&keyword="+encodeURI(document.word_form.keyword.value);
	}
}

//---------------------------------------------------------------------------
// 画像表示ウィンドウ生成
//---------------------------------------------------------------------------
/*ZOOMPhoto*/
if (document.all && !window.opera){  // IE4以上
  myMarginX = 20; // マージン横幅
  myMarginY = 20; // マージン縦幅
}else if (document.getElementById || document.layers){ // NS4以上(OP)
  myMarginX = 16; // マージン横幅
  myMarginY = 16; // マージン縦幅
}else{  // IE3.02とする
  myMarginX = 22; // マージン横幅
  myMarginY = 6;  // マージン縦幅
}
function myGo(myJpeg,myTitle,myWidth,myHeight){
 myXX=myWidth + myMarginX;	// ウィンドウ横幅
 myYY=myHeight + myMarginY;	// ウィンドウ縦幅
 myWinName = "Win";					// ウィンドウ名
 myWinSize = "status=no,resizable=no,scrollbars=no"+",width=" + myXX + ",height=" + myYY; // ウィンドウオプション
 myWin = window.open("" , myWinName , myWinSize); // ウィンドウを開く
 myWin.document.open();
 myWin.document.write('<html>');
 myWin.document.write('<head>');
 myWin.document.write('<title>'+myTitle+'<','/title>');
 myWin.document.write('<','/head>');
 myWin.document.write('<body topmargin=0 leftmargin=0>');
 myWin.document.write('<div align=\"center\">');
 myWin.document.write('<a href=\"javascript:window.close();\">');
 myWin.document.write('<img src=\"'+myJpeg+'\" border=\"0\" alt=\"'+myTitle+'\">');
 myWin.document.write('</a>');
 myWin.document.write('</div>');
 myWin.document.write('<' , '/body>');
 myWin.document.write('<' , '/html>');
 myWin.document.close();
}

//---------------------------------------------------------------------------
// GoogleMap 詳細ページ用
//---------------------------------------------------------------------------
//<![CDATA[
	function load_map(ido, keido, s_name, r_scale) {
		if (GBrowserIsCompatible()) {
			var map = new GMap2(document.getElementById("map"));
			map.addControl(new GSmallMapControl());
			map.addControl(new GScaleControl());
			//緯度経度を入力する。
			map.setCenter(new GLatLng(ido, keido), r_scale);
			// ポップアップテキスト（名称、電話番号など）
			var infoText = "<b>"+s_name+"</b>";
			var marker = new GMarker(map.getCenter());
			GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(infoText);});
			map.addOverlay(marker);
		}
	}
//]]>

//---------------------------------------------------------------------------
// ヘッダーメニュー　ドロップダウン
//---------------------------------------------------------------------------
var DDSPEED = 10;
var DDTIMER = 15;

// main function to handle the mouse events //
function ddMenu(id,d){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearInterval(c.timer);
  if(d == 1){
    clearTimeout(h.timer);
    if(c.maxh && c.maxh <= c.offsetHeight){return}
    else if(!c.maxh){
      c.style.display = 'block';
      c.style.height = 'auto';
      c.maxh = c.offsetHeight;
      c.style.height = '0px';
    }
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }else{
    h.timer = setTimeout(function(){ddCollapse(c)},50);
  }
}

// collapse the menu //
function ddCollapse(c){
  c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
}

// cancel the collapse if a user rolls over the dropdown //
function cancelHide(id){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearTimeout(h.timer);
  clearInterval(c.timer);
  if(c.offsetHeight < c.maxh){
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(c,d){
  var currh = c.offsetHeight;
  var dist;
  if(d == 1){
    dist = (Math.round((c.maxh - currh) / DDSPEED));
  }else{
    dist = (Math.round(currh / DDSPEED));
  }
  if(dist <= 1 && d == 1){
    dist = 1;
  }
  c.style.height = currh + (dist * d) + 'px';
  c.style.opacity = currh / c.maxh;
  c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
    clearInterval(c.timer);
  }
}
