
//共通関数、n秒後にtargetページ移動
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
var nextPage = "";
function autoMove(target,n) {
	nextPage = target;
	setTimeout(movePage,1000 * n);
}
function movePage() {
	if(nextPage == 'close')
		window.close();
	else
		window.location.href=nextPage;
}

//お気に入りに追加
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
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;
	}
}

//物件詳細サムネイル表示
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
pageNum = 0;
function thumbPage(n) {
	nowId ="thumb_list-" + String(pageNum);
	revId ="thumb_list-" + String(pageNum-1);
	fwdId ="thumb_list-" + String(pageNum+1);
	if (n == 'fwd'){
		if ( document.getElementById(fwdId) ){
			document.getElementById(nowId).style.display = "none";
			document.getElementById(fwdId).style.display = "block";
			pageNum++;
		}
	}else if (n == 'rev'){
		if ( document.getElementById(revId) ){
			document.getElementById(nowId).style.display = "none";
			document.getElementById(revId).style.display = "block";
			pageNum--;
		}
	}
}

//　ドロップダウンメニュー
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

function mopen(id) {	
	mcancelclosetime();
	if (ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}

function mclose() {
	if (ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

function mclosetime() {
	closetimer = window.setTimeout(mclose, timeout);
}

function mcancelclosetime() {
	if (closetimer) {
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}
document.onclick = mclose;

/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
	jQuery 
	++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
jQuery(document).ready(function(){
	
	//ライトボックスもどき
	/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
	jQuery(".frame-area").colorbox({width:"1000px", height:"650px", iframe:true});
	jQuery(".photo-box").colorbox();


	//登録内容変更のアクション
	/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
    jQuery(".custom-btn").click(function () {
    	jQuery(this).next().toggle();
    });

	//物件検索切り替え
	/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
	jQuery(".line-table select,.line-table input").attr("disabled", "disabled");
    jQuery(".switch-line").click(function () {
    	jQuery(".select-area").hide();
		jQuery(".select-line").show();
		jQuery(".area-table").hide();
		jQuery(".area-table select,.area-table input").attr("disabled", "disabled");
		jQuery("#f-estate_type2 input").attr('checked', false);
		hihyoji();
    	jQuery(".line-table").show();
		jQuery(".line-table select,.line-table input").removeAttr("disabled");
		jQuery("#f-gakku select").attr("disabled", "disabled");
		jQuery("#f-gakku").hide();
    });
    jQuery(".switch-area").click(function () {
        jQuery(".select-area").show();
    	jQuery(".select-line").hide();
    	jQuery(".area-table").show();
		jQuery(".area-table select,.area-table input").removeAttr("disabled");
		jQuery("#f-estate_type1 input").attr('checked', false);
		hihyoji();
    	jQuery(".line-table").hide();
		jQuery(".line-table select,.line-table input").attr("disabled", "disabled");
		jQuery("#f-gakku select").removeAttr("disabled");
		jQuery("#f-gakku").show();
    });

	function hihyoji(){
		jQuery(function(){
			jQuery("#f-kodate_price,#f-kodate_madori_search,#f-kodate_chikunen,#f-kodate_tochi_menseki,#f-nobeyuka_menseki,#f-mansion_price,#f-mansion_madori_search,#f-mansion_chikunen,#f-senyu_menseki,#f-tochi_price,#f-tochi_menseki,#f-madori_search1,#f-chikunen").css("display","none");
		})
	}

    jQuery(".switch-btn-area").click(function () {
	    jQuery("#switch-block-area").toggle();
	    jQuery(".btn2").toggle();
    });

	//検索変更テーブル
	/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
  jQuery(document).ready(function(){
      jQuery(".change-btn1").click(function () {
      jQuery(".change-btn1").toggle();
  		jQuery(".close-btn1").toggle();
  		jQuery(".change-area1").toggle();
  		jQuery(".enter-btn").css("display","block");
      });
  });
  jQuery(document).ready(function(){
      jQuery(".close-btn1").click(function () {
      jQuery(".change-btn1").toggle();
  		jQuery(".close-btn1").toggle();
  		jQuery(".change-area1").toggle();
      });
  });

  jQuery(document).ready(function(){
      jQuery(".change-btn2").click(function () {
      jQuery(".change-btn2").toggle();
  		jQuery(".close-btn2").toggle();
  		jQuery(".change-area2").toggle();
  		jQuery(".enter-btn").css("display","block");
      });
  });
  jQuery(document).ready(function(){
      jQuery(".close-btn2").click(function () {
      jQuery(".change-btn2").toggle();
  		jQuery(".close-btn2").toggle();
  		jQuery(".change-area2").toggle();
      });
  });

  jQuery(document).ready(function(){
      jQuery(".change-btn3").click(function () {
      jQuery(".change-btn3").toggle();
  		jQuery(".close-btn3").toggle();
  		jQuery(".change-area3").toggle();
  		jQuery(".enter-btn").css("display","block");
      });
  });
  jQuery(document).ready(function(){
      jQuery(".close-btn3").click(function () {
      jQuery(".change-btn3").toggle();
  		jQuery(".close-btn3").toggle();
  		jQuery(".change-area3").toggle();
      });
  });

  jQuery(document).ready(function(){
      jQuery(".change-btn4").click(function () {
      jQuery(".change-btn4").toggle();
  		jQuery(".close-btn4").toggle();
  		jQuery(".change-area4").toggle();
  		jQuery(".enter-btn").css("display","block");
      });
  });
  jQuery(document).ready(function(){
      jQuery(".close-btn4").click(function () {
      jQuery(".change-btn4").toggle();
  		jQuery(".close-btn4").toggle();
  		jQuery(".change-area4").toggle();
      });
  });

  jQuery(document).ready(function(){
      jQuery(".change-btn5").click(function () {
      jQuery(".change-btn5").toggle();
  		jQuery(".close-btn5").toggle();
  		jQuery(".change-area5").toggle();
  		jQuery(".enter-btn").css("display","block");
      });
  });
  jQuery(document).ready(function(){
      jQuery(".close-btn5").click(function () {
      jQuery(".change-btn5").toggle();
  		jQuery(".close-btn5").toggle();
  		jQuery(".change-area5").toggle();
      });
  });
    //jQuery("[class^='change-btn']").click(function () {
    //	jQuery("[class^='change-btn']").toggle();
		//jQuery("[class^='close-btn']").toggle();
		//jQuery("[class^='change-area']").toggle();
		//jQuery(".enter-btn").css("display","block");
    //});

    //jQuery("[class^='close-btn']").click(function () {
    //	jQuery("[class^='change-btn']").toggle();
		//jQuery("[class^='close-btn']").toggle();
		//jQuery("[class^='change-area']").toggle();
    //});

	//ローンシミュレーション　リセット
	/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
	jQuery("#loansim-fmreset").click(function () {
		jQuery("#fm input").each(function() {
			jQuery(this).val("");
		});
	});
	
	
});




//** jQuery Scroll to Top Control script- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com.
//** Available/ usage terms at http://www.dynamicdrive.com (March 30th, 09')
//** v1.1 (April 7th, 09'):
//** 1) Adds ability to scroll to an absolute position (from top of page) or specific element on the page instead.
//** 2) Fixes scroll animation not working in Opera. 


var scrolltotop={
	//startline: Integer. Number of pixels from top of doc scrollbar is scrolled before showing control
	//scrollto: Keyword (Integer, or "Scroll_to_Element_ID"). How far to scroll document up when control is clicked on (0=top).
	setting: {startline:200, scrollto: 0, scrollduration:500, fadeduration:[500, 500]},
	controlattrs: {offsetx:10, offsety:5}, //offset of control relative to right/ bottom of window corner
	anchorkeyword: '#top-page', //Enter href value of HTML anchors on the page that should also act as "Scroll Up" links

	state: {isvisible:false, shouldvisible:false},

	scrollup:function(){
		if (!this.cssfixedsupport) //if control is positioned using JavaScript
			this.$control.css({opacity:0}) //hide control immediately after clicking it
		var dest=isNaN(this.setting.scrollto)? this.setting.scrollto : parseInt(this.setting.scrollto)
		if (typeof dest=="string" && jQuery('#'+dest).length==1) //check element set by string exists
			dest=jQuery('#'+dest).offset().top
		else
			dest=0
		this.$body.animate({scrollTop: dest}, this.setting.scrollduration);
	},

	keepfixed:function(){
		var $window=jQuery(window)
		var controlx=$window.scrollLeft() + $window.width() - this.$control.width() - this.controlattrs.offsetx
		var controly=$window.scrollTop() + $window.height() - this.$control.height() - this.controlattrs.offsety
		this.$control.css({left:controlx+'px', top:controly+'px'})
	},

	togglecontrol:function(){
		var scrolltop=jQuery(window).scrollTop()
		if (!this.cssfixedsupport)
			this.keepfixed()
		this.state.shouldvisible=(scrolltop>=this.setting.startline)? true : false
		if (this.state.shouldvisible && !this.state.isvisible){
			this.$control.stop().animate({opacity:1}, this.setting.fadeduration[0])
			this.state.isvisible=true
		}
		else if (this.state.shouldvisible==false && this.state.isvisible){
			this.$control.stop().animate({opacity:0}, this.setting.fadeduration[1])
			this.state.isvisible=false
		}
	},
	
	init:function(){
		jQuery(document).ready(function($){
			var mainobj=scrolltotop
			var iebrws=document.all
			mainobj.cssfixedsupport=!iebrws || iebrws && document.compatMode=="CSS1Compat" && window.XMLHttpRequest //not IE or IE7+ browsers in standards mode
			mainobj.$body=(window.opera)? (document.compatMode=="CSS1Compat"? $('html') : $('body')) : $('html,body')
			mainobj.$control=$('<div id="topcontrol"></div>')
				.css({position:mainobj.cssfixedsupport? 'fixed' : 'absolute', bottom:mainobj.controlattrs.offsety, right:mainobj.controlattrs.offsetx, opacity:0, cursor:'pointer'})
				.attr({title:'Scroll Back to Top'})
				.click(function(){mainobj.scrollup(); return false})
				.appendTo('body')
			if (document.all && !window.XMLHttpRequest && mainobj.$control.text()!='') //loose check for IE6 and below, plus whether control contains any text
				mainobj.$control.css({width:mainobj.$control.width()}) //IE6- seems to require an explicit width on a DIV containing text
			mainobj.togglecontrol()
			$('a[href="' + mainobj.anchorkeyword +'"]').click(function(){
				mainobj.scrollup()
				return false
			})
			$(window).bind('scroll resize', function(e){
				mainobj.togglecontrol()
			})
		})
	}
}

scrolltotop.init()

//２重送信防止
var a_sent = false
function send_check(){
	if(a_sent){
		return false
	}else{
		a_sent = true
		return true
	}
}

