//---------------------------------------------------------------------------
// トップページ地域検索用
//---------------------------------------------------------------------------
function form_area_post(apoint) {
	if (document.area_form.select_type[0].checked) {
		window.location.href="/digest/?mode=buy&area="+apoint;
	} else if (document.area_form.select_type[1].checked) {
		window.location.href="/digest/?mode=lease&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);
		}
	}
//]]>

//---------------------------------------------------------------------------
// 分譲地リスト取得
//---------------------------------------------------------------------------
	function bj_list_get(pno,bno,bid,cid,id) {
		ajax = false;
		// IE以外
		if(window.XMLHttpRequest) {
			ajax = new XMLHttpRequest();
		// IE用
		} else if(window.ActiveXObject) {
			try {
				ajax = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				ajax = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		var dd = new Date();
		ajax.open("GET", "/detail/bj_list_get.cfm?bj_pno="+pno+"&bj_bno="+bno+"&bj_bid="+bid+"&bj_cid="+cid+"&bj_dd="+dd, false);
		ajax.send("");
		if (ajax.readyState == 4 && (ajax.status == 200 || window.location.href.indexOf("http") == -1)) {
			document.getElementById("pun-"+id).href = 'javascript:void(0);';
			document.getElementById("facilities-box").innerHTML = ajax.responseText;
		}
	}

//---------------------------------------------------------------------------
// 文字スクロール
//---------------------------------------------------------------------------
if (window.addEventListener) { //for W3C DOM
		window.addEventListener("load", init_scroll_load, false);
} else if (window.attachEvent) { //for IE
		window.attachEvent("onload", init_scroll_load);
} else {
		window.onload = init_scroll_load;
}

function init_scroll_load() {
	new Marquee('m1',{amount:6,delay:70});
}

var Marquee = function ( id, opt ){
    if( ! document.getElementById(id) ) throw 'invalid id. [' + id + ']';
    var option = opt || {};
    this.id     = id;
    this.amount = option.amount || 6;
    this.delay  = option.delay  || 100;
    this.position = Number.POSITIVE_INFINITY; // means out of range.
    this._wrap();
    this.start();
}

Marquee.prototype = {
    /* wrap child nodes */
    _wrap : function() {
        var t = document.getElementById( this.id );
        with ( t.style ){
            position = 'relative'; // for ie6.
            overflow = 'hidden';
        }
        var w = document.createElement( 'div' );
        with ( w.style ){
            margin     = '0';
            padding    = '0';
            background = 'transparent';
            border     = 'none';
        }
        t.normalize();
        while( t.firstChild ){
            w.appendChild( t.removeChild( t.firstChild ) );
        }
        t.appendChild(w);
        /* get minimum width. */
        w.style.position = 'absolute';
        this.minWidth = w.offsetWidth;
        /* put back */
        w.style.position = 'relative';
        w.style.width = '100%'; // for ie6.
    },
    start : function() {
        this.stop();
        this._next();
    },
    _next : function() {
        var t = document.getElementById( this.id );
        this.curWidth = Math.min(t.offsetWidth,t.parentNode.offsetWidth); // dirty. (for "overflow:hidden" parent)
        this.position = this.position - this.amount;
        if ( this._isOutOfRange() ) {
            this.position = this._startPosition();
        }
        var w = t.firstChild;
        w.style.left = this.position + 'px';
        var self = this;
        this.tid = window.setTimeout(
            function(){ self._next(); },
            this.delay
        );
    },
    _startPosition : function() {
        return ( this.amount > 0 ) ?  this.curWidth
                                   : -this.minWidth;
    },
    _isOutOfRange : function() {
        return this.position < -this.minWidth || this.curWidth < this.position;
    },
    stop : function() {
        if ( this.tid ) window.clearTimeout( this.tid );
        this.tid = null;
    },
    isMarqueeing : function() {
        return ( this.tid ) ? true : false;
    }
}
//---------------------------------------------------------------------------
// お気に入りに追加　Firefoxにも対応
//---------------------------------------------------------------------------
function addBookmark(title,url) { 
    if (window.sidebar) { 
        window.sidebar.addPanel(title, url,""); 
    } else if( document.all ) { 
        window.external.AddFavorite( url, title); 
    } else if( window.opera && window.print ) { 
        return true; 
    } 
}
