/*
 * jcommon.js 1.12
 * Copyright (c) 2007 C.M.A. Co.,Ltd.
 *
 * Last Added: 2008-09-09
 *
 */



var ary = location.pathname.split('/');


var l=0;var isLinkAry=new Array;for(i=0;i<=ary.length-1;i++){isLinkAry[i]=ary.slice(i,i+1);isLinkAry[i]=isLinkAry[i].join('/');isLinkAry[i]=isLinkAry[i].replace(/index.*$/,"")}for(k=i+1;k<=i+ary.length;k++){isLinkAry[k]=ary.slice(0,ary.length-l);isLinkAry[k]=isLinkAry[k].join('/');isLinkAry[k]=isLinkAry[k].replace(/^\//,"");isLinkAry[k]=isLinkAry[k].replace(/index.*$/,"");l++}isLinkAry[0]=isLinkAry[0].replace(/\#.*$/,"");var jcommon={preloader:{loadedImages:[],load:function(url){var img=this.loadedImages;var l=img.length;img[l]=new Image();img[l].src=url}},URI:function(path){path=path.replace(/^https[^a-z]*/,"");path=path.replace(/^http[^a-z]*/,"");path=path.replace(document.domain,"");path=path.replace(/^[^a-z]*/,"");path=path.replace(/index.*$/,"");path=path.replace(/\/$/,"");this.absolutePath=path;this.len=isLinkAry.length;this.isSelfLink=false;while(this.len--){this.isSelfLink=this.isSelfLink||(this.absolutePath==isLinkAry[this.len])}}};

/*ロールオーバー*/			$.fn.addRollOver=function(add){$(this).filter('img').each(function(){$(this).runRollOver(add,$(this));}).end().not('img').each(function(){$(this).runRollOver(add,$(this).find('img'));});};
							$.fn.runRollOver=function(add,target){$(this).each(function(num){this.originalSrc=String(target.attr('src'));this.rolloverSrc=this.originalSrc.replace(/(\.gif|\.jpg|\.png)/,add+"$1");}).hover(function(){target.attr('src',this.rolloverSrc);},function(){target.attr('src',this.originalSrc);});};
/*現在のページへのリンク*/	$.fn.addCurrentImages=function(add){$(this).each(function(){var href=new jcommon.URI($(this).attr('href'));if(href.isSelfLink){$(this).addClass('current');$(this).unbind('mouseenter');$(this).unbind('mouseleave');$(this).find('img').each(function(){$(this).unbind('mouseenter');$(this).unbind('mouseleave');this.currentSrc=this.getAttribute('src').replace(/(\.gif|\.jpg|\.png)/,add+"$1");$(this).attr('src',this.currentSrc)});}});};

$(function(){


	//ロールオーバー
	$('a img.btn,a.btn,#globalNav li a').addRollOver('_on');

	//現在のページへのリンク
	$('#globalNav li a,#localNav li a').addCurrentImages('_on');	

	//外部リンクは別ウインドウを設定
	$('a[href^="http://"]:not([href^="http://chintai.wiz-with.jp/"])').not('[@href^="http://maps.google.co.jp/maps?"]').click(function(){
		window.open(this.href, '_blank');
		return false;
	}).addClass('externalLink');


	//別ウィンドウを設定
	$('a[href$=".pdf"],a[href$=".asx"]').click(function(){
		window.open(this.href, '_blank');
		return false;
	})

	//#itemNameに?以降の文字列を入力しておく
	$('a[href*="?"]').each(function(){
		$(this).attr('href',encodeURI($(this).attr('href')));//URLエンコード
	});
	$('input#itemName').each(function(){
		$(this).val(decodeURI(location.search.slice(1)));//URLデコード
	});
	
		//マウスオーバー追加用
	$('input,label,textarea')
		.removeClass('hover').hover(function(){$(this).addClass('hover');},function(){$(this).removeClass('hover')});

	//n段組み
	$('.col3 li:nth-child(3n)').add('.col4 li:nth-child(4n)').addClass('clearMargin');
	
	//するするアニメーション ※要scrollTo.js
	$('a[href^="#top"]').each(function(){
		this.target = $(this).attr('href');
	}).click(function(){
		$.scrollTo( this.target, {speed:800} );
		return false;
	});



	//oddとevenを追加
	$('tr').filter(':odd').addClass('even').end().filter(':even').addClass('odd');

	//:first-child, :last-childをクラスとして追加
	$('tr,th').filter(':first-child').addClass('firstChild');
	$('dd,li,tr,th').filter(':last-child').addClass('lastChild');



	//dd要素の非表示 ver1.0
	$('#comIndex #mainContent table tr td dl dd').each(function(){
		$(this).children('div').hide();
		//$(this).before('<p class="faq alignR" href=""><a>すべて表示</a></p>');
	});

$('#comIndex #mainContent table a.map').each(function(){
		this.gmapURI = $(this).attr('href');
		$(this).removeAttr('href');
	}).click(function(){
		if($(this).hasClass('show')){
			$(this).next().remove();
			$(this).text('地図を表示');
			$(this).removeClass('show')
		}else{
			$(this).after('<iframe frameborder="0" src="'+this.gmapURI+'"></iframe>');
			$(this).text('地図を非表示');
			$(this).addClass('show')
		}
		return false;
	});

//トップページおすすめ物件一覧
$('#home #areaRecommend').load('recommend/indexlist_recommend.html');


$('#comIndex #mainContent table a#mapbtn001').click(function(){
$('#comIndex #mainContent table div#map001').load('map001.html');
});
$('#home #subContent .news dd').load('shop/indexlist_news.html');
$('#home #subContent .staff dd').load('shop/indexlist.html');

//店舗紹介 新着情報一覧
$('.shop #indexNews').load('sukaguchi/news/news_pagelist.html');
$('.shop #nakamuraNews').load('nakamura/news/news_pagelist.html');
$('.shop #inazawaNews').load('inazawa/news/news_pagelist.html');
$('.shop #ichinomiyaNews').load('ichinomiya/news/news_pagelist.html');
//店舗紹介 店舗ブログ一覧
$('.shop #indexBlog').load('sukaguchi/blog/blog_pagelist.html');
$('.shop #nakamuraBlog').load('nakamura/blog/blog_pagelist.html');
$('.shop #inazawaBlog').load('inazawa/blog/blog_pagelist.html');
$('.shop #ichinomiyaBlog').load('ichinomiya/blog/blog_pagelist.html');
//店舗紹介 スタッフ紹介一覧
$('.shop #indexStaff').load('../staff/sukaguchi_list.html');
$('.shop #nakamuraStaff').load('../staff/nakamura_list.html');
$('.shop #inazawaStaff').load('../staff/inazawa_list.html');
$('.shop #ichinomiyaStaff').load('../staff/ichinomiya_elist.html');


$("ul.fooBnr").append("<li><a href='http://wizco-chintai.com/' target='_blank'><img src='/shared/img/bnr_f_nagoya.gif' alt='名古屋に通える賃貸'>名古屋に通える賃貸、お部屋探しはアパマンショップ加盟のウィズコ賃貸にお任せくだサイ！ </a></li><li><a href='http://baikyaku.wiz-with.jp/' target='_blank'><img src='/shared/img/bnr_baikyaku.gif' alt='中古住宅売却査定相談'>中古住宅・中古戸建の売却・査定はお任せください! </a></li>");

$("ul.fooBnr").after("<p class='addWiz'><strong>ウィズコーポレーション</strong><br />〒452-0914 愛知県清須市土器野145 スカイフォーラム1<br />[電話] 052-400-2821  [FAX] 052-400-4031 [E-mail] <a href='mailto:info@wizco.jp'>info&#064;wizco.jp</a><br />[宅地建物取引業] 愛知県知事(5)第16765号 <br />[営業エリア] <a href='http://chintai.wiz-with.jp/'>名古屋市中村区</a>  <a href='http://chintai.wiz-with.jp/'>一宮市</a>  <a href='http://chintai.wiz-with.jp/'>稲沢市</a>  <a href='http://chintai.wiz-with.jp/'>清須市</a>  <a href='http://chintai.wiz-with.jp/'>あま市</a><br />[取扱い不動産]																																																																																																																																																																																																																																																																																												<a href='http://chintai.wiz-with.jp/'>マンション</a>  																																																																																																																																																																																																																																																																																																				<a href='http://chintai.wiz-with.jp/'>アパート</a>  																																																																																																																																																																																																																																																																																																				<a href='http://chintai.wiz-with.jp/'>ハイツ</a>  																																																																																																																																																																																																																																																																																																				<a href='http://chintai.wiz-with.jp/'>コーポ</a>  																																																																																																																																																																																																																																																																																																					<a href='http://chintai.wiz-with.jp/'>戸建賃貸</a>  																																																																																																																																																																																																																																																																																																					<a href='http://chintai.wiz-with.jp/'>借家</a>  																																																																																																																																																																																																																																																																																																					<a href='http://chintai.wiz-with.jp/'>テラスハウス</a>  																																																																																																																																																																																																																																																																																																					<a href='http://chintai.wiz-with.jp/'>メゾネット</a>  																																																																																																																																																																																																																																																																																																					<a href='http://chintai.wiz-with.jp/'>デザイナーズ賃貸</a>  																																																																																																																					</p>");
});
