/*
 * 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://baibai.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;
	})
	
	//マウスオーバー追加用
	$('input,label,textarea')
		.removeClass('hover').hover(function(){$(this).addClass('hover');},function(){$(this).removeClass('hover')});

	//するするアニメーション ※要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');

	//googlemapをiframeで表示
	$('#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 #subContent .news dd').load('shop/indexlist_news.html');
$('#home #subContent .staff dd').load('shop/indexlist.html');*/

	if($('body#home').length){
		$('body#home #recSukaguchi li,body#home #recIchinomiya li').flatHeights();
	}
	
/*$('#home dd#recSukaguchi').load('shop/sukaguchi/recommend/rec_sukaguchi.html',function(){;
//ブロック要素の高さを調節
$('.heightLine').add('body#home .push dd ul li').flatHeights();
});	
$('#home dd#recIchinomiya').load('shop/ichinomiya/recommend/rec_ichinomiya.html',function(){;
//ブロック要素の高さを調節
$('.heightLine').add('body#home .push dd ul li').flatHeights();
});*/	
	
	
//店舗紹介 新着情報一覧
	if($('body.shop').length){
$('.shop #indexNews').load('sukaguchi/news/news_pagelist.html');
$('.shop #ichinomiyaNews').load('ichinomiya/news/news_pagelist.html');
//店舗紹介 店舗ブログ一覧
$('.shop #indexBlog').load('sukaguchi/blog/blog_pagelist.html');
$('.shop #ichinomiyaBlog').load('ichinomiya/blog/blog_pagelist.html');
//店舗紹介 オススメ物件一覧
$('.shop #indexPush').load('sukaguchi/recommend/push_pagelist.html',function(){
	//ブロック要素の高さを調節
    $('.heightLine').add('body#shoIndex .push dd ul li').add('body.shopRecommend .push ul li').flatHeights();
});
$('.shop #ichinomiyaPush').load('ichinomiya/recommend/push_pagelist.html',function(){
	//ブロック要素の高さを調節
    $('.heightLine').add('body#shoIndex .push dd ul li').add('body.shopRecommend .push ul li').flatHeights();
});
//店舗紹介 スタッフ紹介一覧
$('.shop #indexStaff').load('../staff/sukaguchi_list.html',function(){
	//ブロック要素の高さを調節
    $('.heightLine').add('body#shoIndex .staffList dd ul li').add('body.shopRecommend .push ul li').flatHeights();
});
$('.shop #ichinomiyaStaff').load('../staff/ichinomiya_list.html',function(){
	//ブロック要素の高さを調節
    $('.heightLine').add('body#shoIndex .staffList dd ul li').add('body.shopRecommend .push ul li').flatHeights();
});
	}

$('#indexPush ul li:nth-child(3n-2),#ichinomiyaPush ul li:nth-child(3n-2)','.shop').addClass('clearB');



});


