//================================================

//■ロールオーバー・プリロードイメージ

//================================================

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_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_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 subWindow(url,w,h,Winname){

	var subWin = window.open(''+url, ''+Winname,'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width='+w+',height='+h+''); 

subWin.focus();

}

//================================================

//■サブウインドウ　スクロールバーなし（固定）

//================================================

function subWindow2(url,w,h,Winname){

	var subWin = window.open(''+url, ''+Winname,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+w+',height='+h+''); 

subWin.focus();

}



//================================================

//■ページトップへ戻るスクロール

//================================================

var timerScroll;

var posX;

var posY;

var Ver = parseFloat(navigator.appVersion);

var frm = 10;

if(navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1) { fIE = true; } else { fIE = false; }

if(navigator.appVersion.indexOf('Mac',0) != -1) { fMac = true; } else { fMac = false; }

if(navigator.appName.indexOf("Netscape",0) != -1) { fNN = true; } else { fNN = false; }

if((fMac && navigator.appVersion.indexOf('MSIE 4.',0) != -1)) { fMacIE4 = true; } else { fMacIE4 = false; }

if((fMac && navigator.appVersion.indexOf('MSIE 3.',0) != -1)) { fMacIE3 = true; } else { fMacIE3 = false; }



function getPosY() {

	if (fIE) { return document.body.scrollLeft; }

	else if (window.pageXOffset) { return window.pageXOffset; }

	else { return 0; }

}



function getPosX() {

	if (fIE) { return document.body.scrollTop; }

	else if (window.pageYOffset) { return window.pageYOffset; }

	else { return 0; }

}



function scroll2Top(pos2X,pos2Y,pos3X,pos3Y) {

	if (timerScroll) { clearTimeout(timerScroll); }

	if (!pos2X || (pos2X < 0)) { pos2X = 0; }

	if (!pos2Y || (pos2Y < 0)) { pos2Y = 0; }

	if (!pos3X) { pos3X = 0 + getPosY() };

	if (!pos3Y) { pos3Y = 0 + getPosX() };



	if (pos2Y > pos3Y && pos2Y > (getAnchorPosObj2('end','enddiv').y) - getInnerSize().height) pos2Y = (getAnchorPosObj2('end','enddiv').y - getInnerSize().height) + 1;

	pos3X += (pos2X - getPosY()) / frm;

	if (pos3X < 0) pos3X = 0;

	pos3Y += (pos2Y - getPosX()) / frm;

	if (pos3Y < 0) pos3Y = 0;

	posX = Math.floor(pos3X);

	posY = Math.floor(pos3Y);

	window.scrollTo(posX, posY);



	if (posX != pos2X || posY != pos2Y) {

		timerScroll = setTimeout("scroll2Top("+pos2X+","+pos2Y+","+pos3X+","+pos3Y+")",10);

	}

}



function jumpToPageTop() {

	scroll2Top(0,0);

}



//================================================

//■店舗検索用JS

//================================================

function search_realtor() {

	document.form_pref.action = "/shop/list.jsp";

	if( !document.form_pref.prefecture_id[0].selected ) {

		document.form_pref.submit();

	}

}



// セレクトボックスを書き出す

function search_realtor_prefecture_write() {



	document.write( "<table width='100%'  border='0' cellspacing='0' cellpadding='0'>" );

	document.write( "<form action='#' method='post' name='form_pref'>" );

	document.write( "<tr>" );

	document.write( "<td align='left'><img src='/image/shop_01.gif' alt='掲載不動産会社' width='107' height='22'></td>" );

	document.write( "<td>" );

	document.write( "<select name='prefecture_id'>" );

	document.write( "<option selected>選択！</option>" )

	document.write( "<option value='1'>北海道</option><option value='2'>青森</option><option value='3'>岩手</option><option value='4'>宮城</option>" );

	document.write( "<option value='5'>秋田</option><option value='6'>山形</option><option value='7'>福島</option><option value='8'>茨城</option>" );

	document.write( "<option value='9'>栃木</option><option value='10'>群馬</option><option value='11'>埼玉</option><option value='12'>千葉</option>" );

	document.write( "<option value='13'>東京</option><option value='14'>神奈川</option><option value='15'>新潟</option><option value='16'>富山</option>" );

	document.write( "<option value='17'>石川</option><option value='18'>福井</option><option value='19'>山梨</option><option value='20'>長野</option>" );

	document.write( "<option value='21'>岐阜</option><option value='22'>静岡</option><option value='23'>愛知</option><option value='24'>三重</option>" );

	document.write( "<option value='25'>滋賀</option><option value='26'>京都</option><option value='27'>大阪</option><option value='28'>兵庫</option>" );

	document.write( "<option value='29'>奈良</option><option value='30'>和歌山</option><option value='31'>鳥取</option><option value='32'>島根</option>" );

	document.write( "<option value='33'>岡山</option><option value='34'>広島</option><option value='35'>山口</option><option value='36'>徳島</option>" );

	document.write( "<option value='37'>香川</option><option value='38'>愛媛</option><option value='39'>高知</option><option value='40'>福岡</option>" );

	document.write( "<option value='41'>佐賀</option><option value='42'>長崎</option><option value='43'>熊本</option><option value='44'>大分</option>" );

	document.write( "<option value='45'>宮崎</option><option value='46'>鹿児島</option><option value='47'>沖縄</option>" );

	document.write( "</select>" );

	document.write( "<input type='hidden' name='search_id' value='area'>" );

	document.write( "</td>" );

	document.write( "<td align='right'><a href='javascript:search_realtor();' onMouseOut='MM_swapImgRestore()' onMouseOver=\"MM_swapImage('eheyaImage01','','/image/btn_search_on.gif',1)\"><img src='/image/btn_search.gif' alt='不動産会社検索' name='eheyaImage01' width='85' height='21' border='0'></a></td>" );

	document.write( "</tr>" );

	document.write( "</form>" );

	document.write( "</table>" );

}



//================================================

//■ロールオーバー・プリロードイメージ

//================================================

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_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_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 subWindow(url,w,h,Winname){

	var subWin = window.open(''+url, ''+Winname,'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width='+w+',height='+h+''); 

subWin.focus();

}

//================================================

//■サブウインドウ　スクロールバーなし（固定）

//================================================

function subWindow2(url,w,h,Winname){

	var subWin = window.open(''+url, ''+Winname,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+w+',height='+h+''); 

subWin.focus();

}



//================================================

//■ページトップへ戻るスクロール

//================================================

var timerScroll;

var posX;

var posY;

var Ver = parseFloat(navigator.appVersion);

var frm = 10;

if(navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1) { fIE = true; } else { fIE = false; }

if(navigator.appVersion.indexOf('Mac',0) != -1) { fMac = true; } else { fMac = false; }

if(navigator.appName.indexOf("Netscape",0) != -1) { fNN = true; } else { fNN = false; }

if((fMac && navigator.appVersion.indexOf('MSIE 4.',0) != -1)) { fMacIE4 = true; } else { fMacIE4 = false; }

if((fMac && navigator.appVersion.indexOf('MSIE 3.',0) != -1)) { fMacIE3 = true; } else { fMacIE3 = false; }



function getPosY() {

	if (fIE) { return document.body.scrollLeft; }

	else if (window.pageXOffset) { return window.pageXOffset; }

	else { return 0; }

}



function getPosX() {

	if (fIE) { return document.body.scrollTop; }

	else if (window.pageYOffset) { return window.pageYOffset; }

	else { return 0; }

}



function scroll2Top(pos2X,pos2Y,pos3X,pos3Y) {

	if (timerScroll) { clearTimeout(timerScroll); }

	if (!pos2X || (pos2X < 0)) { pos2X = 0; }

	if (!pos2Y || (pos2Y < 0)) { pos2Y = 0; }

	if (!pos3X) { pos3X = 0 + getPosY() };

	if (!pos3Y) { pos3Y = 0 + getPosX() };



	if (pos2Y > pos3Y && pos2Y > (getAnchorPosObj2('end','enddiv').y) - getInnerSize().height) pos2Y = (getAnchorPosObj2('end','enddiv').y - getInnerSize().height) + 1;

	pos3X += (pos2X - getPosY()) / frm;

	if (pos3X < 0) pos3X = 0;

	pos3Y += (pos2Y - getPosX()) / frm;

	if (pos3Y < 0) pos3Y = 0;

	posX = Math.floor(pos3X);

	posY = Math.floor(pos3Y);

	window.scrollTo(posX, posY);



	if (posX != pos2X || posY != pos2Y) {

		timerScroll = setTimeout("scroll2Top("+pos2X+","+pos2Y+","+pos3X+","+pos3Y+")",10);

	}

}



function jumpToPageTop() {

	scroll2Top(0,0);

}



//================================================

//■店舗検索用JS

//================================================

function search_realtor() {

	document.form_pref.action = "/shop/list.jsp";

	if( !document.form_pref.prefecture_id[0].selected ) {

		document.form_pref.submit();

	}

}



// セレクトボックスを書き出す

function search_realtor_prefecture_write1() {



	document.write( "<table width='100%'  border='0' cellspacing='0' cellpadding='0'>" );

	document.write( "<form action='#' method='post' name='form_pref'>" );

	document.write( "<tr>" );

	document.write( "<td align='left'><img src='/image/shop_01.gif' alt='掲載不動産会社' width='107' height='22'></td>" );

	document.write( "<td>" );

	document.write( "<select name='prefecture_id'>" );

	document.write( "<option selected>選択！</option>" )

	document.write( "<option value='1'>北海道</option><option value='2'>青森</option><option value='3'>岩手</option><option value='4'>宮城</option>" );

	document.write( "<option value='5'>秋田</option><option value='6'>山形</option><option value='7'>福島</option><option value='8'>茨城</option>" );

	document.write( "<option value='9'>栃木</option><option value='10'>群馬</option><option value='11'>埼玉</option><option value='12'>千葉</option>" );

	document.write( "<option value='13'>東京</option><option value='14'>神奈川</option><option value='15'>新潟</option><option value='16'>富山</option>" );

	document.write( "<option value='17'>石川</option><option value='18'>福井</option><option value='19'>山梨</option><option value='20'>長野</option>" );

	document.write( "<option value='21'>岐阜</option><option value='22'>静岡</option><option value='23'>愛知</option><option value='24'>三重</option>" );

	document.write( "<option value='25'>滋賀</option><option value='26'>京都</option><option value='27'>大阪</option><option value='28'>兵庫</option>" );

	document.write( "<option value='29'>奈良</option><option value='30'>和歌山</option><option value='31'>鳥取</option><option value='32'>島根</option>" );

	document.write( "<option value='33'>岡山</option><option value='34'>広島</option><option value='35'>山口</option><option value='36'>徳島</option>" );

	document.write( "<option value='37'>香川</option><option value='38'>愛媛</option><option value='39'>高知</option><option value='40'>福岡</option>" );

	document.write( "<option value='41'>佐賀</option><option value='42'>長崎</option><option value='43'>熊本</option><option value='44'>大分</option>" );

	document.write( "<option value='45'>宮崎</option><option value='46'>鹿児島</option><option value='47'>沖縄</option>" );

	document.write( "</select>" );

	document.write( "<input type='hidden' name='search_id' value='area'>" );

	document.write( "</td>" );

	document.write( "<td align='right'><a href='javascript:search_realtor();' onMouseOut='MM_swapImgRestore()' onMouseOver=\"MM_swapImage('eheyaImage01','','/image/btn_search_on.gif',1)\"><img src='/image/btn_search.gif' alt='不動産会社検索' name='eheyaImage01' width='85' height='21' border='0'></a></td>" );

	document.write( "</tr>" );

	document.write( "</form>" );

	document.write( "</table>" );



}





//================================================

//■お気に入り一覧に遷移用JS

//================================================

function gotoFavoriteList(){

	search_id = 'rent_area';

	url = '/search/favorite/favorite.jsp?search_id=' + search_id;

	subWindow(url,810,550,'favorite');
}

function gotoFavoriteList( search_id ){

	if( search_id == null || search_id == '' ) {

		search_id = 'rent_area';

	}

	url = '/search/favorite/favorite.jsp?search_id=' + search_id;

	subWindow(url,810,550,'favorite');
}


//お問い合わせ画面から用 2010/9/30作成 鶴田
function gotoFavoriteListNew( serverName )
{
	search_id = 'rent_area';
	
	url = 'http://' + serverName + '/search/favorite/favorite.jsp?search_id=' + search_id;

	subWindow(url,810,550,'favorite');
}


//================================================

//■コピーライト書出し

//================================================

function setCopyright(){

var nowMonth = new Date();

document.write("<address>");

//[36-0246]コピーライトの設定変更(2009/09/30)
//document.write('Copyright(c) 2005 - ' + nowMonth.getFullYear() + ' eheyanet All Rights Reserved.');
document.write('Copyright(c) eheyanet All Rights Reserved.');

document.write("<\/address>");

}



//================================================

//■SEOページ用のセレクトボックス作成

//================================================

function init_area( select , prefecture ){

	for( var i=0; i < array_area[prefecture].length ; i++ ) {

		select.options[i] = new Option(array_area[prefecture][i]["name"]);

		select.options[i].value = array_area[prefecture][i]["value"];

	}

	return;

}

function init_line( select ){

	for( var i=0; i < array_line.length ; i++ ) {

		select.options[i] = new Option(array_line[i]["name"]);

		select.options[i].value = array_line[i]["value"];

	}

	return;

}


//================================================

//■旧仕様の画像ポップアップ処理　物件複数表示未対応

//================================================
// 物件画像をポップアップ表示する
function subImageWindow(url,w,h,Winname,comment){

	var subWin = window.open(''+url,''+Winname,'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width='+w+',height='+h+''); 

subWin.focus();

}

//================================================

//■新仕様の画像ポップアップ処理　物件複数表示　対応

//================================================
function subImageWindowForIndex(url,w,h,Winname,index,num){

	var comment = document.form_detail.elements['comment['+index+']['+num+']'].value;

	var subWin = window.open(''+url+'&comment='+comment, ''+Winname,'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width='+w+',height='+h+''); 

subWin.focus();

}


//================================================

//■ブックマーク

//================================================






function bookmark(){



if(navigator.userAgent.indexOf("MSIE") > -1){ // IE の場合

document.writeln('<!-'+'-[if IE]>'); //スクリプトが使えない環境を完全にはじく

document.writeln('<li>');

document.writeln('<a href="javascript:window.external.AddFavorite(\'http://www.eheya.net/\',\'お部屋探しはいい部屋ネット\')">');

document.writeln('ブックマーク登録');

document.writeln('<'+'/a>');

document.writeln('<'+'/li>');

document.writeln('<![endif]-'+'->');

}



else if(navigator.userAgent.indexOf("Firefox") > -1){ // Firefox の場合

document.writeln('<li>');

document.writeln('<a href="javascript:window.sidebar.addPanel(\'お部屋探しはいい部屋ネット\',\'http://www.eheya.net/\',\'\');">');

document.writeln('ブックマーク登録');

document.writeln('<'+'/a>');

document.writeln('<'+'/li>');

}



else { //該当なし

void(0); //何もしない

}

}


//================================================

//■ブックマーク　ボタンのパスを引数に

//================================================
function bookmark(imagePath){
if(navigator.userAgent.indexOf("MSIE") > -1){ // IE の場合
document.writeln('<!-'+'-[if IE]>'); //スクリプトが使えない環境を完全にはじく
document.writeln('<a class="book" href="javascript:window.external.AddFavorite(\'http://www.eheya.net/\',\'お部屋探しはいい部屋ネット\')">');
if(imagePath == null || imagePath == ''){
document.writeln('ブックマーク登録');
}else{
document.writeln('<img src="' + imagePath + '" alt="ブックマーク登録" id="Image502" onmouseover="MM_swapImage(\'Image502\',\'\',\'/img/bt_bookmark_on.gif\',1)" onmouseout="MM_swapImgRestore()" />');
}
document.writeln('<'+'/a>');
document.writeln('<![endif]-'+'->');
}
else if(navigator.userAgent.indexOf("Firefox") > -1){ // Firefox の場合
document.writeln('<a class="book" href="javascript:window.sidebar.addPanel(\'お部屋探しはいい部屋ネット\',\'http://www.eheya.net/\',\'\');">');
if(imagePath == null || imagePath == ''){
document.writeln('ブックマーク登録');
}else{
document.writeln('<img src="' + imagePath + '" alt="ブックマーク登録" id="Image502" onmouseover="MM_swapImage(\'Image502\',\'\',\'/img/bt_bookmark_on.gif\',1)" onmouseout="MM_swapImgRestore()" />');
}
document.writeln('<'+'/a>');
}
else { //該当なし
void(0); //何もしない
}
}



//========================================
//クロスサイトスクリプティング対応
//========================================

	// 34-0260 クロスサイトスクリプティング対応
	function htmlFilter(str){
		
		cnt = str.length;
		var result="";
		
		for (i=0; i<cnt; ++i) {
			switch (str.charAt(i)) {
			case '<':
				result += "&lt;";
				break;
			case '>': 
				result += "&gt;";
				break;
			case '"': 
				result += "&quot;";
				break;
			case '\'': 
				result += "&#39;";
				break;
			case '%': 
				result += "&#37;";
				break;
			case ';': 
				result += "&#59;";
				break;
			case '(': 
				result += "&#40;";
				break;
			case ')': 
				result += "&#41;";
				break;
			case '&': 
				result += "&amp;";
				break;
			case '+':
				result += "&#43;";
				break;
			default:
				result += str.charAt(i);
				break;
			}
		}		
		return result;
	}





