//JavaScript for 高野商事
//by GhettoDesign

function copyright(){
	myD = new Date();
	myYear = myD.getFullYear();
	document.write('<p>Copyright(C)'+myYear+' Takano Shoji Corporation. All Rights Reserved.</p>\n');
}
//エントリーのnewマーク
//30日以内の物件にnewマークをつける

function newmark(EntryYear,EntryDate){//MTEntryDate format="%Y",MTEntryDate format=%j"
	EntryMsec=((EntryYear-1970)*365*24*60*60*1000) + (EntryDate*24*60*60*1000);
	Today=new Date();
	TodayMsec=Today.getTime();
	differenceDays=(TodayMsec-EntryMsec)/(1000*60*60*24);
	if(differenceDays<=30){
		document.write('<img src="http://www.takanoshoji.co.jp/img/mark_new.gif" alt="1ヶ月以内に掲載された物件です" width="35" height="13" class="new" />\n');
	}
}
//アパートまたはマンション 
function apaorman(MTEntryMore){
	if(MTEntryMore.indexOf("bw_002001")!= -1){
		document.write('<img src="http://www.takanoshoji.co.jp/img/mark_apart.gif" alt="アパート" width="70" height="15" class="apaorman" />\n');
	}else if(MTEntryMore.indexOf("bw_002002")!= -1){
		document.write('<img src="http://www.takanoshoji.co.jp/img/mark_mantion.gif" alt="マンション" width="70" height="15" class="apaorman" />\n');
	}else if(MTEntryMore.indexOf("bw_002003")!= -1){
		document.write('<img src="http://www.takanoshoji.co.jp/img/mark_house.gif" alt="一戸建て" width="70" height="15" class="apaorman" />\n');
	}else if(MTEntryMore.indexOf("bw_002004")!= -1){
		document.write('<img src="http://www.takanoshoji.co.jp/img/mark_other.gif" alt="土地 その他" width="70" height="15" class="apaorman" />\n');
	}
}
//トップのFLASH
function topNavi(){
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="762" height="282" id="topNavi" align="middle">');
document.write('<param name="allowScriptAccess" value="sameDomain" />');
document.write('<param name="movie" value="img/topNavi2.swf" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="bgcolor" value="#ffffff" />');
document.write('<embed src="img/topNavi2.swf" quality="high" bgcolor="#ffffff" width="762" height="282" name="topNavi" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');
}


//地図のFLASH
function mapindex(){
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="720" height="600" id="mapindex" align="middle">');
document.write('<param name="allowScriptAccess" value="sameDomain" />');
document.write('<param name="movie" value="img/mapindex.swf" />');
document.write('<param name="quality" value="high" />');
document.write('<param name="bgcolor" value="#ffffff" />');
document.write('<embed src="img/mapindex.swf" quality="high" bgcolor="#ffffff" width="720" height="600" name="mapindex" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');
}



//アクセスカウンター
function rebuild_access_counter(param)
{
    var ajax_obj = new Ajax.Request('http://www.takanoshoji.co.jp/cgi-bin/mt/plugins/RealtimeRebuild/mt-realtime-rebuild.cgi',
                                    { method : 'get',
                                      parameters : param,
                                      onSuccess : access_counter_success,
                                      onFailure : access_counter_failure });
}

function access_counter_success(obj)
{
    $("access_counter").innerHTML = obj.responseText;
}

function access_counter_failure(obj)
{
    $("access_counter").innerHTML = '読み込みに失敗しました';
}




function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//検索用スクリプト

function searchWords(form){
	var sale0 =new Array();
	var type0 =new Array();
	var area0 =new Array();
	var railroad0 =new Array();
	var time0 =new Array();
	var price0 =new Array();
	var numbert0 =new Array();
	var space0 =new Array();
	var numberm0 =new Array();
	var stair0 =new Array();
	var numberi0 =new Array();
	var car0 =new Array();
	var real0 =new Array();
	
	//sale
	isale=0
	for (i=0 ; i < document.ghetto.sale.length ; i++){ //saleのチェックボタンの数
		if (document.ghetto.sale[i].checked){
			sale0[isale] = document.ghetto.sale[i].value; //チェックされている値を配列に入れる
			isale++;
		}
	}
	sale=sale0.join(" OR "); //チェックされた値をORで結ぶ

	//type
	itype=0
	for (i=0 ; i < document.ghetto.type.length ; i++){
		if (document.ghetto.type[i].checked){
			type0[itype] = document.ghetto.type[i].value;
			itype++;
		}
	}
	type=type0.join(" OR ");

	//area
	iarea=0
	for (i=0 ; i < document.ghetto.area.length ; i++){
		if (document.ghetto.area[i].checked){
			area0[iarea] = document.ghetto.area[i].value;
			iarea++;
		}
	}
	area=area0.join(" OR ");
	

	//railroad
	var num = document.ghetto.railroad.selectedIndex;
	railroad = document.ghetto.railroad.options[num].value;
	
	//time
	itime=0
	for (i=0 ; i < document.ghetto.time.length ; i++){
		if (document.ghetto.time[i].checked){
			time0[itime] = document.ghetto.time[i].value;
			itime++;
		}
	}
	time=time0.join(" OR ");

	//price
	iprice=0
	for (i=0 ; i < document.ghetto.price.length ; i++){
		if (document.ghetto.price[i].checked){
			price0[iprice] = document.ghetto.price[i].value;
			iprice++;
		}
	}
	price=price0.join(" OR ");

	//numbert
	inumbert=0
	for (i=0 ; i < document.ghetto.numbert.length ; i++){
		if (document.ghetto.numbert[i].checked){
			numbert0[inumbert] = document.ghetto.numbert[i].value;
			inumbert++;
		}
	}
	numbert=numbert0.join(" OR ");

	//space
	ispace=0
	for (i=0 ; i < document.ghetto.space.length ; i++){
		if (document.ghetto.space[i].checked){
			space0[ispace] = document.ghetto.space[i].value;
			ispace++;
		}
	}
	space=space0.join(" OR ");

	//numberm
	inumberm=0
	for (i=0 ; i < document.ghetto.numberm.length ; i++){
		if (document.ghetto.numberm[i].checked){
			numberm0[inumberm] = document.ghetto.numberm[i].value;
			inumberm++;
		}
	}
	numberm=numberm0.join(" OR ");

	//stair
	istair=0
	for (i=0 ; i < document.ghetto.stair.length ; i++){
		if (document.ghetto.stair[i].checked){
			stair0[istair] = document.ghetto.stair[i].value;
			istair++;
		}
	}
	stair=stair0.join(" OR ");

	//numberi
	inumberi=0
	for (i=0 ; i < document.ghetto.numberi.length ; i++){
		if (document.ghetto.numberi[i].checked){
			numberi0[inumberi] = document.ghetto.numberi[i].value;
			inumberi++;
		}
	}
	numberi=numberi0.join(" OR ");

	//car
	icar=0
	for (i=0 ; i < document.ghetto.car.length ; i++){
		if (document.ghetto.car[i].checked){
			car0[icar] = document.ghetto.car[i].value;
			icar++;
		}
	}
	car=car0.join(" OR ");

	//real
	ireal=0
	for (i=0 ; i < document.ghetto.real.length ; i++){
		if (document.ghetto.real[i].checked){
			real0[ireal] = document.ghetto.real[i].value;
			ireal++;
		}
	}
	real=real0.join(" OR ");


	words = new Array(13); //各グループの値を配列に入れる
	words[0]=sale;
	words[1]=type;
	words[2]=area;
	words[3]=railroad;
	words[4]=time;
	words[5]=price;
	words[6]=numbert;
	words[7]=space;
	words[8]=numberm;
	words[9]=stair;
	words[10]=numberi;
	words[11]=car;
	words[12]=real;
	searchString=new Array();
	

var icount = 0; //空要素を除いたグループをカウント
	for(i=0;i<13;i++){
		if(words[i]!=""){
			icount++;
		}
	}

var searchString0 = new Array(icount); //空要素をのぞいたグループを配列に入れる
var istr=0;
for (i=0;i<13;i++){ 
	if (words[i]!=""){
		searchString0[istr]=words[i];
		istr++;
	}else if(words[i]==""){
		void(0);
	}

}
	var sss = searchString0.length;
	searchString=searchString0.join(" AND "); //各グループをANDで結ぶ
	
	//alert('グループ数：'+icount+'/サーチストリング：'+searchString0);
	form.elements['search'].value = searchString;

}
