function google_map(ido, keido, mode){
	this.mode = mode;
	this.ido = ido;
	this.keido = keido;
	this.markers = new Array();
	this.all_tabs = new Array();
	this.div = document.getElementById("map");
	this.streetObj = new GStreetviewPanorama(document.getElementById("street"));

	this.map=new GMap2(this.div), {size:new GSize(800,600)};
	this.geocoder = new GClientGeocoder();
	this.map.enableContinuousZoom();
	if (!this.ido && !this.keido){
		this.ido = 33.5525090;
		this.keido = 130.4364570;
		//alert("検索結果がありません");
	}
	this.init_point = new GLatLng(this.ido, this.keido);
	this.map.setCenter(this.init_point);
	
	G_NORMAL_MAP.getMaximumResolution = function(){return 21;}

	//var screenXY = new GScreenPoint(0.5, 0.5, "fraction", "fraction");
    //var overlayXY = new GScreenPoint(0.5, 0.5, "fraction", "fraction");
    //var size = new GScreenSize(10, 10);
    //var soverlay = new GScreenOverlay("http://www.google.com/intl/en_ALL/mapfiles/dir_0.png", screenXY, overlayXY, size);
    //this.map.addOverlay(soverlay);
	
	//ストリートビューオーバーレイ（青紫の線）
	//streetview = new GStreetviewOverlay();
	//this.map.addOverlay(streetview);

	
	this.streetObj.setLocationAndPOV(this.init_point, {pitch:0});
	
	
	

if (document.URL.match(/bukken/i)) {
		//物件登録・編集画面
	    this.map.setZoom(20);
	}else{
		//物件詳細画面
		this.map.setZoom(15);
	}

	this.map.addControl(new GSmallMapControl());
	//this.map.addControl(new GLargeMapControl());
	if (document.getElementById("map_mode")) {
		if (document.getElementById("map_mode").innerHTML == 'search' || document.getElementById("map_mode").innerHTML == 'view') {
			this.map.addControl(new GMapTypeControl());
		}
		//else alert(document.getElementById("map_mode").innerHTML);
	}
	//賃貸物件に使うアイコン
	//アパート
	this.icon = new GIcon();
	this.icon.image = "/images/pin_apart.png";
	//this.icon.shadow = "/images/pin_shade_bukken.png";
	//this.icon.iconSize = new GSize(34, 32);
	this.icon.iconSize = new GSize(48, 37);
	//this.icon.shadowSize = new GSize(45, 32);
	//this.icon.iconAnchor = new GPoint(15, 36);
	this.icon.iconAnchor = new GPoint(8, 34);
	this.icon.infoWindowAnchor = new GPoint(15, 0);

	//マンション
	this.icon2 = new GIcon();
	this.icon2.image = "/images/pin_mansion.png";
	this.icon2.iconSize = new GSize(48, 37);
	this.icon2.iconAnchor = new GPoint(8, 34);
	this.icon2.infoWindowAnchor = new GPoint(15, 0);

	//一戸建て
	this.icon3 = new GIcon();
	this.icon3.image = "/images/pin_kodate.png";
	this.icon3.iconSize = new GSize(48, 37);
	this.icon3.iconAnchor = new GPoint(8, 34);
	this.icon3.infoWindowAnchor = new GPoint(15, 0);

	//SOHO
	this.icon4 = new GIcon();
	this.icon4.image = "/images/pin_soho.png";
	this.icon4.iconSize = new GSize(48, 37);
	this.icon4.iconAnchor = new GPoint(8, 34);
	this.icon4.infoWindowAnchor = new GPoint(15, 0);


	//マップを目的地までずらす関数
	this.center_map = function(center) {
		this.map.panTo(center);
		//alert("ok "+center.toString());
		if (this.mode == "edit") {
			this.markers[this.markers.length-1].setPoint(center);
		}
	};

	//登録時の「ズレ過ぎ」の計算に使用されるマップの中心を更新。
	this.set_hardcenter = function(center) {
		this.ido=center.lat();
		this.keido=center.lng();
	};

	this.center_map2 = function(point){
		
		this.map.setCenter(point);
	}
	
	this.autozoom = function() {
		//bounds = new GBounds(this.markers);
		var bounds = new GLatLngBounds();
		for (var i = 0; i < this.markers.length; i+=1) {
			bounds.extend(this.markers[i].getPoint());
		}
		var sw = bounds.getSouthWest();
		var ne = bounds.getNorthEast();
		var y2 = ne.lat();
		var x2 = ne.lng();
		var y1 = sw.lat();
		var x1 = sw.lng();
		var percent = 20;
		x1 -= (x2 - x1)*percent/100;
		x2 += (x2 - x1)*percent/100;
		y1 -= (y2 - y1)*percent/100;
		y2 += (y2 - y1)*percent/100;
		bounds.extend(new GLatLng(y1,x1));
		bounds.extend(new GLatLng(y2,x2));
		bounds.extend(new GLatLng(y1,x2));
		bounds.extend(new GLatLng(y2,x1));
		//alert(sw.lat()+','+sw.lng()+' / '+ne.lat()+','+ne.lng()+' /// '+y1+','+x1+' / '+y2+','+x2);
		var zoom = this.map.getBoundsZoomLevel(bounds);
		var bounds_center = bounds.getCenter();
		if (this.markers.length<1){
			//alert(this.markers.length);
			zoom = 11;
			bounds_center = new GLatLng(33.606578,130.417972);
		}
		//alert(zoom+" "+bounds.getCenter().toString());
		this.center_map(bounds_center);
		//this.add_marker(bounds_center);
		this.map.setZoom(zoom);
	};

	this.get_results_data = function() {
		if (document.getElementById("map_mode")) {
			this.map_mode=document.getElementById("map_mode").innerHTML;
		}
		if (document.getElementById("map_search")) {
			this.map_search=document.getElementById("map_search").innerHTML;
		}
		if (document.getElementById("map_ido")) {
			this.map_ido=document.getElementById("map_ido").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_ido.pop(); }
		}
		if (document.getElementById("map_keido")) {
			this.map_keido=document.getElementById("map_keido").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_keido.pop(); }
		}
		if (document.getElementById("map_name")) {
			this.map_name=document.getElementById("map_name").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_name.pop(); }
		}
		if (document.getElementById("map_jusho")) {
			this.map_jusho=document.getElementById("map_jusho").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_jusho.pop(); }
		}
		if (document.getElementById("map_madori")) {
			this.map_madori=document.getElementById("map_madori").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_madori.pop(); }
		}
		if (document.getElementById("map_chinryo")) {
			this.map_chinryo=document.getElementById("map_chinryo").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_chinryo.pop(); }
		}
		if (document.getElementById("map_shubetsu")) {
			this.map_shubetsu=document.getElementById("map_shubetsu").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_shubetsu.pop(); }
		}
		if (document.getElementById("map_kakaku")) {
			this.map_kakaku=document.getElementById("map_kakaku").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_kakaku.pop(); }
		}
		if (document.getElementById("map_id")) {
			this.map_id=document.getElementById("map_id").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_id.pop(); }
		}
		if (document.getElementById("map_chintaibaibai")) {
			this.map_chintaibaibai=document.getElementById("map_chintaibaibai").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_chintaibaibai.pop(); }
		}
		if (document.getElementById("map_fudosan_id")) {
			this.map_fudosan_id=document.getElementById("map_fudosan_id").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_fudosan_id.pop(); }
		}
		if (document.getElementById("map_fudosan_user")) {
			this.map_fudosan_user=document.getElementById("map_fudosan_user").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_fudosan_user.pop(); }
		}
		if (document.getElementById("map_fudosan_name")) {
			this.map_fudosan_name=document.getElementById("map_fudosan_name").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_fudosan_name.pop(); }
		}
		if (document.getElementById("map_fudosan_jusho")) {
			this.map_fudosan_jusho=document.getElementById("map_fudosan_jusho").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_fudosan_jusho.pop(); }
		}
		if (document.getElementById("map_fudosan_phone")) {
			this.map_fudosan_phone=document.getElementById("map_fudosan_phone").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_fudosan_phone.pop(); }
		}
		if (document.getElementById("map_fudosan_mail")) {
			this.map_fudosan_mail=document.getElementById("map_fudosan_mail").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_fudosan_mail.pop(); }
		}
		if (document.getElementById("map_pictures")) {
			this.map_pictures=document.getElementById("map_pictures").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_pictures.pop(); }
		}
		if (document.getElementById("map_logos")) {
			this.map_logos=document.getElementById("map_logos").innerHTML.split("|");
			if (this.map_mode == "search") { this.map_logos.pop(); }
		}
	};

	this.attach_click = function(pointer) {
		this.idokeido_listener = GEvent.addListener(this.map, "click", function(click_overlay, click_point) {
			if ( click_overlay !== null ) { return; }
			map1.center_map(click_point);
			var field_ido = document.getElementById("ido");
			if(field_ido) {
				field_ido.value = click_point.lat();
			}
			var field_keido = document.getElementById("keido");
			if(field_keido) {
				field_keido.value = click_point.lng();
			}
			if(map1.markers[map1.markers.length-1]) {
				var point_backup = new GLatLng(map1.ido,map1.keido);
				if (click_point.distanceFrom(point_backup)>1000) {
					//document.getElementById("idokeido_msg").innerHTML = "計算した緯度経度から１キロも外れるが、いいですか？";
					//alert(document.getElementById("idokeido_msg"));
					my_form.idokeido_msg.id.innerHTML = "計算した緯度経度から１キロも外れるが、いいですか？";
				} else { document.getElementById("idokeido_msg").innerHTML = ""; }
			}
		});
	};

	this.add_marker = function(point,i) {
		if (this.map_search == 'mixed') {
			if (this.markers.length === 0) {
				this.add_marker_fudosan(point);
			} else if (this.map_chintaibaibai[this.markers.length] == '売買') {
				this.add_marker_sale(point);
			} else {
				this.add_marker_rental(point);
			}
		}else if (this.map_search == 'fudosan') {
			this.add_marker_fudosan(point);
		}else if (this.map_mode == 'kakunin') {
			if (this.map_search == '賃貸') {
				this.add_marker_rental(point);
			}else if (this.map_search == '売買') {
				this.add_marker_sale(point);
			}else if (this.map_search == 'user') {
				this.add_marker_fudosan(point);
			}
		}else if (this.map_mode == 'home') {
			this.add_marker_fudosan(point);
		} else if (this.map_chintaibaibai) {
			//alert(this.map_id[this.markers.length]);
			if (this.map_chintaibaibai[this.markers.length] == '売買') {
				this.add_marker_sale(point);
			} else {
				if(this.map_shubetsu){
					if (this.map_shubetsu[i] == 'マンション') {
						this.add_marker_mansion(point);
					}else if (this.map_shubetsu[i] == '一戸建て') {
						this.add_marker_kodate(point);
					}else if (this.map_shubetsu[i] == 'SOHO') {
						this.add_marker_soho(point);
					}else{
						this.add_marker_rental(point);
					}
				} else {
						this.add_marker_rental(point);
				}
			}
		}else if (this.map_mode == 'edit') {
			if (this.map_search == 'user') {
				this.add_marker_fudosan(point);
			} else {
				this.add_marker_rental(point);
			}
		}else if (this.map_shubetsu[i] == 'マンション') {
			this.add_marker_mansion(point);
		}else if (this.map_shubetsu[i] == '一戸建て') {
			this.add_marker_kodate(point);
		}else if (this.map_shubetsu[i] == 'SOHO') {
			this.add_marker_soho(point);
		} else {
			this.add_marker_rental(point);
		}
	};

	this.add_marker_rental = function(point) {
		this.markers.push(new GMarker(point, this.icon));
		this.map.addOverlay(this.markers[this.markers.length-1]);
	};
	this.add_marker_mansion = function(point) {
		this.markers.push(new GMarker(point, this.icon2));
		this.map.addOverlay(this.markers[this.markers.length-1]);
	};
	this.add_marker_kodate = function(point) {
		this.markers.push(new GMarker(point, this.icon3));
		this.map.addOverlay(this.markers[this.markers.length-1]);
	};
	this.add_marker_soho = function(point) {
		this.markers.push(new GMarker(point, this.icon4));
		this.map.addOverlay(this.markers[this.markers.length-1]);
	};

/*
	this.add_marker_sale = function(point) {
		this.markers.push(new GMarker(point, this.icon3));
		this.map.addOverlay(this.markers[this.markers.length-1]);
	};

	this.add_marker_fudosan = function(point) {
		this.markers.push(new GMarker(point, this.icon2));
		this.map.addOverlay(this.markers[this.markers.length-1]);
	};
*/
	this.change_marker = function(rentalsale) {
		var latlng = this.markers[this.markers.length-1].getPoint();
		/*var old_rentalsale;
		if(this.markers[this.markers.length-1].getIcon().image.indexOf('rental')) {
			old_rentalsale = 'rental';
		} else {//if(this.markers[this.markers.length-1].getIcon().image.indexOf('sale')) {
			old_rentalsale = 'sale';
		}
		if(rentalsale != old_rentalsale){*/
			//alert("old_rentalsale="+old_rentalsale+" rentalsale="+rentalsale+" len="+this.markers.length)
			GEvent.removeListener(this.idokeido_listener);
			this.map.removeOverlay(this.markers[this.markers.length-1]);
			if(rentalsale=='sale') {
				this.add_marker_sale(latlng);
			} else {
				this.add_marker_rental(latlng);
			}
		//}
		if (this.map_mode == "edit") {
			map1.attach_click(map1.markers[this.markers.length-1], 0);
			var marker = map1.markers[this.markers.length-1];
		}
	};

	this.tabbed_info = function() {
		if (this.map_jusho.length != this.markers.length) {
			alert ("インフォウィンドーのデータは正しく読み込む事が出来ませんでした");
			return 1;
		}
		this.tabs = new Array();
		var i = 0;
		var logo_size;
		var bukken_info = "";
		var fudosan_info = "";
		if (this.map_search == 'fudosan') {
			for (i = 0; i < this.map_jusho.length; i+=1) {
				if (this.map_logos[i]) {
					logo_size = resize_image("http://www.fukuoka-chintai.com/pictures/" + this.map_logos[i], 80, 60);
				}
				fudosan_info  = "<div class=\"balloon\">";
				if (this.map_logos[i]) {
					fudosan_info += "<div class=\"balloon_img\"><img src=\"http://www.fukuoka-chintai.com/pictures/" + this.map_logos[i] + "\" alt=\"" + this.map_fudosan_name[i] + "ロゴ\" width=\"" + logo_size[0] + "\" height=\"" + logo_size[1] + "\" /></div>";
				}
				fudosan_info += "<div class=\"balloon_right\">";
				fudosan_info += "<h2>" + this.map_fudosan_name[i] + "</h2>";
				fudosan_info += "<h3>" + this.map_jusho[i] + "</h3>";
				fudosan_info += "<p class=\"balloon_tel\">TEL " + this.map_fudosan_phone[i] + "</p>";
				fudosan_info += "<p class=\"balloon_detail\"><a href=\"http://www.fukuoka-chintai.com/" + this.map_fudosan_user[i] + "\">会社の詳細</a></p>";
				fudosan_info += "<p class=\"balloon_contact\"><a href=\"http://www.fukuoka-chintai.com/contact/fudosan/" + this.map_id[i] + "\">お問合せ</a></p>";
				fudosan_info += "<br class=\"close\" /></div><br class=\"close\" /></div>";
				this.tabs.push(fudosan_info);
				this.add_window(i);
			}
		} else if (this.map_search == 'mixed') {
			for (i = 0; i < 1; i+=1) {
				if (this.map_logos[i]) {
					logo_size = resize_image("http://www.fukuoka-chintai.com/pictures/" + this.map_logos[i], 80, 60);
				}
				fudosan_info  = "<div class=\"balloon\">";
				if (this.map_logos[i]) {
					fudosan_info += "<div class=\"balloon_img\"><img src=\"http://www.fukuoka-chintai.com/pictures/" + this.map_logos[i] + "\" alt=\"" + this.map_fudosan_name[i] + "ロゴ\" width=\"" + logo_size[0] + "\" height=\"" + logo_size[1] + "\" /></div>";
				}
				fudosan_info += "<div class=\"balloon_right\">";
				fudosan_info += "<h2>" + this.map_fudosan_name[i] + "</h2>";
				fudosan_info += "<h3>" + this.map_jusho[i] + "</h3>";
				fudosan_info += "<p class=\"balloon_tel\">TEL " + this.map_fudosan_phone[i] + "</p>";
				fudosan_info += "<p class=\"balloon_detail\"><a href=\"http://www.fukuoka-chintai.com/" + this.map_fudosan_user[i] + "\">会社の詳細</a></p>";
				fudosan_info += "<p class=\"balloon_contact\"><a href=\"http://www.fukuoka-chintai.com/contact/fudosan/" + this.map_id[i] + "\">お問合せ</a></p>";
				fudosan_info += "<br class=\"close\" /></div><br class=\"close\" /></div>";
				this.tabs.push(fudosan_info);
				this.add_window(i);
			}
			for (i = 1; i < this.map_jusho.length; i+=1) {
				if (this.map_logos[i]) {
					logo_size = resize_image("http://www.fukuoka-chintai.com/pictures/" + this.map_logos[i], 80, 60);
				}
				bukken_info  = "<div class=\"balloon\">";
				if (this.map_pictures[i]) {
					bukken_info += "<div class=\"balloon_img\"><img src=\"http://www.fukuoka-chintai.com/thumbs/" + this.map_pictures[i] + "\" alt=\"" + this.map_name[i] + "\" width=\"80\" height=\"60\" /></div>";
				}
				bukken_info += "<div class=\"balloon_right\">";
				bukken_info += "<h2>" + this.map_name[i] + "</h2>";
				//bukken_info += "<h3>" + this.map_jusho[i] + "</h3>";
				if (this.map_chintaibaibai[i]=="賃貸") {
					bukken_info += "<p class=\"balloon_tel\">間取り：" + this.map_madori[i] + "｜賃料：￥" + this.map_chinryo[i] + "</p>";
					bukken_info += "<p class=\"balloon_bukken_detail\"><a href=\"www.fukuoka-chintai.com/" + this.map_id[i] + "\">物件の詳細</a></p>";
				} else if (this.map_chintaibaibai[i]=="売買") {
					bukken_info += "<p class=\"balloon_tel\">間取り：" + this.map_madori[i] + "｜価格：" + this.map_kakaku[i] + "</p>";
					bukken_info += "<p class=\"balloon_bukken_detail\"><a href=\"www.fukuoka-chintai.com/" + this.map_id[i] + "\">物件の詳細</a></p>";
				}
				/*bukken_info += "<p class=\"balloon_contact\"><a href=\"http://www.fukuoka-chintai.com/contact/bukken/" + this.map_id[i] + "\">お問合せ</a></p>";
				bukken_info += "<br class=\"close\" /></div><br class=\"close\" /></div>";*/
				fudosan_info  = "<div class=\"balloon\">";
				if (this.map_logos[i]) {
				fudosan_info += "<div class=\"balloon_img\"><img src=\"http://www.fukuoka-chintai.com/pictures/" + this.map_logos[i] + "\" alt=\"" + this.map_fudosan_name[i] + "ロゴ\" width=\"" + logo_size[0] + "\" height=\"" + logo_size[1] + "\" /></div>";
				}
				fudosan_info += "<div class=\"balloon_right\">";
				fudosan_info += "<h2>" + this.map_fudosan_name[i] + "</h2>";
				fudosan_info += "<h3>" + this.map_jusho[i] + "</h3>";
				fudosan_info += "<p class=\"balloon_tel\">TEL " + this.map_fudosan_phone[i] + "</p>";
				fudosan_info += "<p class=\"balloon_detail\"><a href=\"http://www.fukuoka-chintai.com/" + this.map_fudosan_user[i] + "\">会社の詳細</a></p>";
				fudosan_info += "<p class=\"balloon_contact\"><a href=\"http://www.fukuoka-chintai.com/contact/fudosan/" + this.map_fudosan_id[i] + "\">お問合せ</a></p>";
				fudosan_info += "<br class=\"close\" /></div><br class=\"close\" /></div>";
				this.tabs.push(new info_tabs("物件",	bukken_info, "不動産", fudosan_info ));
				this.add_tabs(i);
			}
		} else {
			for (i = 0; i < this.map_jusho.length; i+=1) {
				if (this.map_logos[i]) {
					logo_size = resize_image("http://www.fukuoka-chintai.com/pictures/" + this.map_logos[i], 80, 60);
				}
				bukken_info  = "<div class=\"balloon\">";
				/*if (this.map_pictures[i]) {
					bukken_info += "<div class=\"balloon_img\"><img src=\"http://www.fukuoka-chintai.com/thumbs/" + this.map_pictures[i] + "\" alt=\"" + this.map_name[i] + "\" width=\"80\" height=\"60\" /></div>";
				}
				*/
				//bukken_info += "<div class=\"balloon_right\">";
				bukken_info += "<h2>" + this.map_name[i] + "</h2>";
				bukken_info += "<p class=\"balloon_tel\">間取り：" + this.map_madori[i] + "｜賃料：￥" + this.map_chinryo[i] + "</p>";
				bukken_info += "<p class=\"balloon_bukken_detail\"><a href=\"http://www.fukuoka-chintai.com/" + this.map_id[i] + "\" target=\"_blank\">物件の詳細</a>";
				bukken_info += "</div>";
				/*
				this.tabs.push(new info_tabs2("物件",bukken_info));
				this.add_tabs(i);
				*/
				this.tabs.push(bukken_info);
				this.add_window(i);
			}
		}
	};

	this.add_tabs = function(index) {
		GEvent.addListener(this.markers[index], "click", function() {
			this.openInfoWindowTabsHtml(map1.tabs[index].tabs);
			for (i=0; i<results.length; i=i+1) {
				if (i != index){
					//results[i].className = 'results';
					//results[i].className = 'clickable_list_item';
				}
			}
			//return this.className = 'results_selected';
			//divから変更したので不具合
			//results[index].className = 'clickable_list_item_selected';
			//return results[index].className;
		});
	};

	this.add_window = function(index) {
		GEvent.addListener(this.markers[index], "click", function() {
			this.openInfoWindowHtml(map1.tabs[index]);
			return results[index].className;
		});
	};

	this.attach_click_to_result = function(element, counter) {
		element.style.cursor = 'pointer';
		GEvent.addDomListener(element, "mouseover", function() {
			map1.markers[counter].openInfoWindowHtml(map1.tabs[counter]);
		});
	};

	return true;
}

function info_tabs(label1, body1, label2, body2){
	this.label1 = label1;
	this.label2 = label2;
	this.body1 = body1;
	this.body2 = body2;
	this.tab1 = new GInfoWindowTab(this.label1,this.body1);
	this.tab2 = new GInfoWindowTab(this.label2,this.body2);
	this.tabs = [ this.tab1, this.tab2 ];

	return true;
}

function info_tabs2(label1, body1){
	this.label1 = label1;
	this.body1 = body1;
	this.tab1 = new GInfoWindowTab(this.label1,this.body1);
	this.tabs = [ this.tab1];

	return true;
}

function resize_image(src, max_width, max_height) {
	picture = new Image();
	picture.src = src;
	//alert("picture.src="+src+" picture.width="+picture.width+" picture.height="+picture.width);
	var width;
	var height;
	if (picture.width / picture.height >= max_width / max_height) {
		width = max_width;
		height = picture.height * (max_width / picture.width);
	} else {
		height = max_height;
		width = picture.width * (max_height / picture.height);
	}
	var size = new Array();
	size.push(width);
	size.push(height);
	//alert("picture.width="+picture.width+" picture.height="+picture.width+" width="+width+" height="+height);
	return size;
}

function start_slideshow2() {
	this.pictures = new Array();
	if (document.getElementById("slideshow_urls")) {
		this.slideshow_urls=document.getElementById("slideshow_urls").innerHTML.split("|");
		this.slideshow_urls.pop();
	}
	myShow = new Slideshow('slideshow', { type: 'pan', duration: [2000, 4000], width: 340, height: 255, images: this.slideshow_urls, hu: 'http://www.fukuoka-chintai.com/pictures/' });
	
}

function img_resize(){
	//width: 340, height: 255　にリサイズ。縦横比保持
	var width_size=340;
	var height_size=255;
	
	var picture_url = document.getElementById("picture_url").innerHTML;
	
	if(picture_url != ""){
		newPic = new Image();
		newPic.src = 'http://www.fukuoka-chintai.com/pictures/' + picture_url;
	
		var w = newPic.width;
		var h = newPic.height;

		if(w/4 > h/3){
			//横長の場合
			scale = width_size/newPic.width;
			newPic.width = width_size;
			newPic.height = h*scale;
		}else{
			//縦長の場合
			scale = height_size/newPic.height;
			newPic.width = w*scale;
			newPic.height = height_size;
		}
		document.getElementById("slideshow").innerHTML = '<img src="http://www.fukuoka-chintai.com/pictures/' + picture_url + '" width="'+ newPic.width + ' height="' + newPic.height +'">';
	}
}

function detailed_search_toggle() {
	var on = document.getElementById("detailed_search_on");
	var off = document.getElementById("detailed_search_off");
	on.style.cursor = 'pointer';
	on.onclick = function(){ 
		new Effect.toggle('detailed_search_box','appear');
		new Effect.toggle(this);
	};
	off.style.cursor = 'pointer';
	off.onclick = function(){ 
		new Effect.toggle('detailed_search_box','appear');
		new Effect.toggle('detailed_search_on');
	};
}

function bksearch() {
	//get data from xhtml
	var map_ido = new Array();
	var map_keido = new Array();
	var map_mode = "";
	if (document.getElementById("map_mode")) {
		map_mode=document.getElementById("map_mode").innerHTML;
	}
	if (document.getElementById("map_ido")) {
		map_ido=document.getElementById("map_ido").innerHTML.split("|");
		if (map_mode == "search") { map_ido.pop(); }
	}
	if (document.getElementById("map_keido")) {
		map_keido=document.getElementById("map_keido").innerHTML.split("|");
		if (map_mode == "search") { map_keido.pop(); }
	}
	//create map
	//if (GBrowserIsCompatible() && typeof map_ido!='undefined' && typeof map_keido!='undefined' && typeof map_mode!='undefined') {
	if ('function' == typeof GBrowserIsCompatible) {
		if (GBrowserIsCompatible() && map_ido && map_keido && map_mode) {
			map1 = new google_map(map_ido[0], map_keido[0], map_mode);
			if (map_mode == "search" || map_mode == "kakunin" || map_mode == "home" || map_mode == "edit" || document.getElementById("map_chintaibaibai")) {
				map1.get_results_data();
			}
			if (map_ido.length>0) {
				// 逆にする？まだ何かが足りない
				//for (var i = map_ido.length - 1; i >= 0; i-=1) {
				for (var i = 0; i < map_ido.length; i+=1) {
					var point = new GLatLng(map_ido[i],map_keido[i]);
					map1.add_marker(point,i);
				}
			}
			
			if (map_mode == "search") {
				map1.autozoom();
				map1.tabbed_info();
				
			}
			if (map_mode == "edit") {
				map1.attach_click(map1.markers[map1.markers.length-1], 0);
				var marker = map1.markers[map1.markers.length-1];
			}
		}
	}
	//validate form
	if(document.getElementById("form1")) {
		my_form = new form();
		if (my_form.jusho.id) {
			my_form.concat_jusho();
		}
		//my_form.rosen_option_add();
		if (my_form.chintaibaibai.id && map_mode) {
			my_form.switch_chintaibaibai();
			my_form.switch_chikunentype();
		}
		if (my_form.input_fields.length>0) {
			my_form.attach_events();
		}
		my_form.rosen_change();
		my_form.rosen2_change();
		//学校入力チェック　入力していれば入力フィールドオープン
		my_form.gakkou_open_check();
		
		my_form.dai2kotsu_change();
	}
	if(document.getElementById("embed_video")) {
		document.getElementById("embed_video").style.cursor = 'pointer';
		document.getElementById("embed_video").onclick = function(){ 
			return show_embed_video(this);
		};
	} else if (document.getElementById("movie") && document.getElementById("slideshow_urls")) {
		//start_slideshow();
		start_slideshow2();
	} else if (document.getElementById("picture_url")) {
		img_resize();
	}
	if (document.getElementById("detailed_search_box") 
		&& document.getElementById("detailed_search_on") 
		&& document.getElementById("detailed_search_off")) {
			detailed_search_toggle();
	}

	//map_showsに変更から未使用？
	divs = document.getElementsByTagName('div');
	if (divs) {
		results = new Array();
		for (i=0; i<divs.length; i=i+1) {
			//if (divs[i].className == 'results') {
			if (divs[i].className == 'clickable_list_item') {
				results.push(divs[i]);
			}
		}
		for (i=0; i<results.length; i=i+1) {
			map1.attach_click_to_result(results[i], i);
		}
	}

	if(document.getElementById('map_mode_sub')){
		//var mapsClass = new Array("ap","ma","ho","so")
		var mapsClass = "maps_mover";
		mapshows = getElementsByClassName(mapsClass);
		if (mapshows) {
			results = new Array();
			
			for (i=0; i<mapshows.length; i=i+1) {
				//if (divs[i].className == 'clickable_list_item') {
					results.push(mapshows[i]);
				//}
			}
			
			for (i=0; i<results.length; i=i+1) {
				map1.attach_click_to_result(results[i], i);
			}
		}
	}

	if(document.getElementById('ekibus')){
		ekibus_change();
	}
	
	if(document.getElementById('change_detail_view')){
		var change_detail_view = document.getElementById('change_detail_view');
		//var setphoto1 = document.getElementById('setphoto1');
		var setphoto2 = document.getElementById('setphoto2');

		change_detail_view.style.cursor = 'pointer';
		//setphoto1.style.display = 'block';
		//setphoto2.style.display = 'none';
		setphoto2.style.display = 'block';
		change_detail_view.onclick =  function(){
			//if(setphoto1.style.display == 'none'){
			if(setphoto2.style.display == 'block'){
				//setphoto1.style.display = 'block';
				setphoto2.style.display = 'none';
				
				change_detail_view.innerHTML = '<img src="../imgs/button_changemap2.gif" width="251" height="34" alt="マップ表示モードに切替え" />';
				
			}else{
				//setphoto1.style.display = 'none';
				setphoto2.style.display = 'block';

				change_detail_view.innerHTML = '<img src="../imgs/button_changeimage2.gif" width="251" height="34" alt="地図表示モードに切替え" />';

				//センターがずれる
				//map1.center_map2(new GLatLng(map_ido[0], map_keido[0]))
			}
		}
	}

	//グラフィカル検索
	if(document.getElementById('flashcontents')){
		var so = new SWFObject("./map.swf", "top", "830", "290", "8","#ffffff");
		so.addParam("wmode", "transparent");
		//so.write("flashcontents");
		if( ! so.write( "flashcontents" ) ){
			//document.getElementById( "flashcontents" ).innerHTML = "<br /><br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<福岡賃貸ドットコムをご利用するには、Flash Playerが必要になります。<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ahref='http://www.adobe.com/go/getflashplayer_jp'>&nbsp;こちらをクリック&nbsp;</a>して最新のFlashPlayerをインストールして下さい。";
			document.getElementById( "flashcontents" ).innerHTML = "<p>この部分を正しく表示するには、Flash Playerが必要になります。<br /><a href='http://www.adobe.com/go/getflashplayer_jp'>&nbsp;こちらをクリック</a>し、FlashPlayerをインストールしてお楽しみ下さい。</p>Flash Playerをご使用になられない場合は、下記で地域を選択することができます。<br />[ <a href='http://www.fukuoka-chintai.com/hakata'>福岡市博多区</a> ] [<a href='http://www.fukuoka-chintai.com/chuou'>福岡市中央区</a> ] [<a href='http://www.fukuoka-chintai.com/jounan'>福岡市城南区</a> ] [ <a href='http://www.fukuoka-chintai.com/sawara'>福岡市早良区</a> ]<br />[ <a href='http://www.fukuoka-chintai.com/nishi'>福岡市西区</a> ] [ <a href='http://www.fukuoka-chintai.com/higashi'>福岡市東区</a> ] [ <a href='http://www.fukuoka-chintai.com/minami'>福岡市南区</a> ]<br />[ <a href='http://www.fukuoka-chintai.com/kasuga'>春日市</a> ] [ <a href='http://www.fukuoka-chintai.com/onojou'>大野城市</a> ] [ <a href='http://www.fukuoka-chintai.com/chikushino'>筑紫野市</a> ] [ <a href='http://www.fukuoka-chintai.com/dazaifu'>太宰府市</a> ] [ <a href='http://www.fukuoka-chintai.com/kasuya'>糟屋郡</a> ]";
    	}
	}
	
    
	//top
	//if(document.getElementById('topflash')){
		//var so = new SWFObject("/topflash/base.swf", "top", "800", "327", "8","#ffffff");
		//so.addParam("wmode", "transparent");
		//so.write("topflash");
		//if( ! so.write( "topflash" ) ){
			//document.getElementById( "topflash" ).innerHTML = "<span>この部分を正しく表示するには、Flash Playerが必要になります。<br /><a href='http://www.adobe.com/go/getflashplayer_jp'>&nbsp;こちらをクリック</a>し、FlashPlayerをインストールしてお楽しみ下さい。<br />Flash Playerをご使用になられない場合は、下記からあらかじめ地域を選択してください。<br />[ <a href='http://www.fukuoka-chintai.com/hakata'>福岡市博多区</a> ] [<a href='http://www.fukuoka-chintai.com/chuou'>福岡市中央区</a> ] [<a href='http://www.fukuoka-chintai.com/jounan'>福岡市城南区</a> ] [ <a href='http://www.fukuoka-chintai.com/sawara'>福岡市早良区</a> ]<br />[ <a href='http://www.fukuoka-chintai.com/nishi'>福岡市西区</a> ] [ <a href='http://www.fukuoka-chintai.com/higashi'>福岡市東区</a> ] [ <a href='http://www.fukuoka-chintai.com/minami'>福岡市南区</a> ]<br />[ <a href='http://www.fukuoka-chintai.com/kasuga'>春日市</a> ] [ <a href='http://www.fukuoka-chintai.com/onojou'>大野城市</a> ] [ <a href='http://www.fukuoka-chintai.com/chikushino'>筑紫野市</a> ] [ <a href='http://www.fukuoka-chintai.com/dazaifu'>太宰府市</a> ] [ <a href='http://www.fukuoka-chintai.com/kasuya'>糟屋郡</a> ]</span>";
    	//}
	//}
	
	//imgタグで右クリック禁止
	var ImgObj = document.getElementsByTagName("img");
	for (i = 0; i < ImgObj.length; i++) {
		ImgObj[i].oncontextmenu = function(){
			return false;
		}
	}
	
	//オールチェック
	var all_check = document.getElementById("all_check");
	if(all_check){
		all_check.onclick = function(){
			var CheckObj = document.getElementsByTagName("input");
			for (i = 0; i < CheckObj.length; i++) {
				if(CheckObj[i].type=='checkbox'){
					CheckObj[i].checked = this.checked;
				}
			}
		}
	}
	
	//オールチェック(アンカーVer)
	var check_all = document.getElementById("check_all");
	if(check_all){
		check_all.onclick = function(){
			var CheckObj = document.getElementsByTagName("input");
			for (i = 0; i < CheckObj.length; i++) {
				if(CheckObj[i].type=='checkbox'){
					CheckObj[i].checked = true;
				}
			}
		}
	}
	//オールクリアー(アンカーVer)
	var check_clear = document.getElementById("check_clear");
	if(check_clear){
		check_clear.onclick = function(){
			var CheckObj = document.getElementsByTagName("input");
			for (i = 0; i < CheckObj.length; i++) {
				if(CheckObj[i].type=='checkbox'){
					CheckObj[i].checked = false;
				}
			}
		}
	}
	var contacts_bukken = document.getElementById("contacts_bukken");
	if(contacts_bukken){
		contacts_bukken.onclick =  function(){
			var all_check = document.getElementsByName("showmap[]");
			if(all_check){
				var show_form = document.getElementById("bk_form");
				var form_action = document.getElementById("form_action");
				var refresh = document.getElementById("refresh");
				form_action.value="contacts_bukken";
				refresh.value=document.URL;
				show_form.method="get";
				show_form.submit();
			}
		}
	}

	//お気に入りリストからジャンプ
	var bookmark_show = document.getElementById('bookmark_show');
	if(bookmark_show){
		bookmark_show.onclick = function(){
			var bookmark_list = document.getElementById("bookmark_list");
			if(bookmark_list.options[bookmark_list.selectedIndex].value != ''){
				//location.href = bookmark_list.options[bookmark_list.selectedIndex].value;
				window.open(bookmark_list.options[bookmark_list.selectedIndex].value);
			}
		}
		bookmark_show.onmouseover = function(){
			bookmark_show.style.backgroundPosition = "0px -23px";
		}
		bookmark_show.onmouseout = function(){
			bookmark_show.style.backgroundPosition = "0px 0px";
		}
	}
}

//クラス検索取得(配列)
function getElementsByClassName3(classNameArray) {
    var i, j, eltClass;
    var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
    var objCN = new Array();
    for (i = 0; i < objAll.length; i++) {
        eltClass = objAll[i].className.split(/\s+/);
        for (j = 0; j < eltClass.length; j++) {
        	for (k = 0; k < classNameArray.length; k++) {
				if(objAll[i].className == classNameArray[k]){
	                objCN.push(objAll[i]);
  		  	 	    break;
          		}
           	}
        }
    }
    return objCN;
}
//クラス曖昧検索取得
function getElementsByClassName2(className) {
    var i, j, eltClass;
    var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
    var objCN = new Array();
    for (i = 0; i < objAll.length; i++) {
        eltClass = objAll[i].className.split(/\s+/);
        for (j = 0; j < eltClass.length; j++) {
            if (eltClass[j] == className+"1" || eltClass[j] == className+"2") {
                objCN.push(objAll[i]);
                break;
            }
        }
    }
    return objCN;
}
function getElementsByClassName(className) {
    var i, j, eltClass;
    var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
    var objCN = new Array();
    for (i = 0; i < objAll.length; i++) {
        eltClass = objAll[i].className.split(/\s+/);
        for (j = 0; j < eltClass.length; j++) {
            if (eltClass[j] == className) {
                objCN.push(objAll[i]);
                break;
            }
        }
    }
    return objCN;
}

window.onload = function() {
	bksearch();
};

