$(function() {

/*-----------------------------------------------------------------------
■ページ上部へ移動■
------------------------------------------------------------------------*/
/*	if (! $.browser.safari) {
		$('#pagetop').click(function () {
			$(this).blur();
			$('html,body').animate({ scrollTop: 0 }, 'fast');
			return false;
		});
	}*/
	$('#pagetop').click(function(){
		$('html,body').animate({ scrollTop: 0 }, 'fast');
		return false;
	});

/*-----------------------------------------------------------------------
■画像ロールオーバー■
------------------------------------------------------------------------*/
	function smartRollover() {
		if($()) {
			var images = $("img,:image");
//2011/05/13 YU-001 ↓
//			for(var i=0; i < images.length; i++) {
			var nlen = images.length||0;
			for(var i=0; i < nlen; i++) {
				if(images[i].getAttribute("src")){
//2011/05/13 YU-001 ↑
					if(images[i].getAttribute("src").match("_off."))
					{
						images[i].onmouseover = function() {
							this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
						}
						images[i].onmouseout = function() {
							this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
						}
					}
				}
			}
		}
	}
	if(window.addEventListener) {
		window.addEventListener("load", smartRollover, false);
	}
	else if(window.attachEvent) {
		window.attachEvent("onload", smartRollover);
	}

/*-----------------------------------------------------------------------
■検索ボタンロールオーバー（トップ、物件検索）■
------------------------------------------------------------------------*/
	$("#search_rent li a,#search_sale li a,.search_left,.search_right").mouseover(function() {
		$(this).css('background-position',' bottom left');
		$(this).children("span").css('background-position','bottom right');
		$(this).children("a").children(".wrap_search").css('background-position','bottom right');
	});
	$("#search_rent li a,#search_sale li a,.search_left,.search_right").mouseout(function() {
		$(this).css('background-position',' top left');
		$(this).children("span").css('background-position','top right');
		$(this).children("a").children(".wrap_search").css('background-position','top right');
	});
	$("#search_rent li span,#search_sale li span,.wrap_search").mouseover(function() {
		$(this).css('background-position','bottom right');
	});
	$("#search_rent li span,#search_sale li span,.wrap_search").mouseout(function() {
		$(this).css('background-position','top right');
	});

/*-----------------------------------------------------------------------
■サイドボックス　※最後のli要素から破線削除■
------------------------------------------------------------------------*/
	$("#right_box div li:last").css('border', 'none');

/*-----------------------------------------------------------------------
■サイドボックス　※検索の最後のli要素のバックグラウンド変更■
------------------------------------------------------------------------*/
	$("#left_box #search_rent li:last,#left_box #search_sale li:last").css('background-image', 'url(images/3column/bg_btn_side_last.gif)');


/*-----------------------------------------------------------------------
■物件紹介高さ計算■
------------------------------------------------------------------------*/
	var special = $(".top_bkn").height();
	$("top_line").height(special);


/*-----------------------------------------------------------------------
■Googlemap別ウィンドウ表示■
------------------------------------------------------------------------*/
	$("small a").click(function() {
		window.open(this.href, '_blank');
		return false;
	});

/*-----------------------------------------------------------------------
■物件紹介一覧サイズ調整■
------------------------------------------------------------------------*/
	var speciallist = $("#main").width();
	$(".special_list_left,.special_list_right").width((speciallist / 2) - 10);
	$(".special_list_left a,.special_list_right a").width((speciallist / 2) - 10);

/*-----------------------------------------------------------------------
■物件紹介一覧ロールオーバー■
------------------------------------------------------------------------*/
	$(".special_list_left,.special_list_right").mouseover(function() {
		$(this).css('border-color', '#ccc');
	});
	$(".special_list_left,.special_list_right").mouseleave(function() {
		$(this).css('border-color', '#eee');
	});

/*-----------------------------------------------------------------------
■店舗一覧サイズ調整■
------------------------------------------------------------------------*/
/*
2011/03/14 YH-001 ↓
	var shoplist = $("#main").width();
	$(".shop_list_left,.shop_list_right").width((shoplist / 2) - 104);
	$(".shop_list_left a,.shop_list_right a").width((shoplist / 2) - 104);
2011/03/14 YH-001 ↑
*/
	var shoplist = $("#main").width();
	$(".shop_list_left,.shop_list_right").width((shoplist / 2) - 10);
	$(".shop_list_left a,.shop_list_right a").width((shoplist / 2) - 10);
/*-----------------------------------------------------------------------
■店舗一覧ロールオーバー■
------------------------------------------------------------------------*/
/*
2011/03/14 YH-001 ↓
	$(".shop_list_left,.shop_list_right").mouseover(function() {
		$(this).css('background', 'url(../../images/template/bg_shop_list_left_on.gif) no-repeat top left');
		$(this).children("a").css('background', 'url(../../atconfig/images/template/bg_shop_list_right_on.gif) no-repeat top right');
	});
	$(".shop_list_left,.shop_list_right").mouseleave(function() {
		$(this).css('background', 'url(../../images/template/bg_shop_list_left.gif) no-repeat top left');
		$(this).children("a").css('background', 'url(../../images/template/bg_shop_list_right.gif) no-repeat top right');
	});
2011/03/14 YH-001 ↑
*/
	$(".shop_list_left,.shop_list_right").mouseover(function() {
		$(this).css('border-color', '#ccc');
	});
	$(".shop_list_left,.shop_list_right").mouseleave(function() {
		$(this).css('border-color', '#eee');
	});
/*-----------------------------------------------------------------------
■店舗一覧:IE6用リンクカラー■
------------------------------------------------------------------------*/
	if (typeof document.body.style.maxHeight == "undefined") {
		$(".shop_list_left a,.shop_list_right a").mouseover(function() {
			$(this).css('color', '#333');
			$(this).css('text-decoration', 'underline');
		});
		$(".shop_list_left a,.shop_list_right a").mouseleave(function() {
			$(this).css('text-decoration', 'none');
		});
	}

/*-----------------------------------------------------------------------
■会社・店舗写真サイズ調整■
------------------------------------------------------------------------*/
	var commaphalf = $("#company_pic,#shop_pic").parent().width();
	$(".half img").width((commaphalf / 2) - 30);

/*-----------------------------------------------------------------------
■店舗地図別ウィンドウ■
------------------------------------------------------------------------
	$('a[href="shop_map.html"]').click(function() {
		window.open(this.href, "shop","width=700,height=500");
		return false;
	});
	$(".map_close img").click(function() {
		window.close();
	});*/
	

	//IE7以前だと検索エンジンの画像リンクが反応しないためイベント追加
	if(navigator.userAgent.indexOf("MSIE 7") >= 0 || navigator.userAgent.indexOf("MSIE 6") >= 0){
		$('.img_feat').click(function(){
			var strHref = $(this).closest('a').attr('href')||'';
			var strTarget = $(this).closest('a').attr('target')||'';

			window.open(strHref, strTarget);
		});
	}


});

/*-----------------------------------------------------------------------
■メニュー縦型の高さ調整■　※129はヘッダーとフッターの高さ
------------------------------------------------------------------------*/
function menuheight() {
	var h = $("#wrapper").height();
	var i = h - 129;
	$("#menu").height(i);
}

/*-----------------------------------------------------------------------
■ブックマーク登録（firefox対応済み）■
------------------------------------------------------------------------*/
function addBookmark(title,url) {
	if(jQuery.browser.safari) {
		alert("Ctrl+Dを押してブックマークに追加して下さい。");
	} else 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;
	}
}
