$(function(){
	$.i81.setScrolls();
	$.i81.rollOver();
	$.i81.setClass();
	$.i81.shopDetailLink();
	
	$("#choose_language > .nav2 > *").click(function () {
  		location.href="http://www.qbhouse.com/en/";
  		return false;
	});

});
	
$.i81 = {
	setScrolls: function(){
		$('a[href^=#]').click(function(){
			var top = 0; 
			top = $(this.hash).offset().top; 
   			$($.browser.safari ? 'body' : 'html').animate({scrollTop:top}, 700, 'swing');
			return false;
		});
	},
	rollOver: function(){
		$('img.btn').each(function(){
			this.oSrc = $(this).attr("src");
			this.hSrc = this.oSrc.replace(/(\.gif|\.jpg|\.png)$/, "_over$1");
			this.cache = new Image();
			this.cache.src = this.hSrc;
		}).hover(function(){
			$(this).attr('src',this.hSrc);
		},function(){
			$(this).attr('src',this.oSrc);
		});
	},
	setClass: function() {
		$('#table_layoutA01 tr :last-child').addClass('last-child');
		$('#table_layoutA02 tr :last-child').addClass('last-child');
		$('#result_city ul :last-child').addClass('last-child');
		$('#result_city2 ul :last-child').addClass('last-child');
		$('#yearmonth ol :last-child').addClass('last-child');
		$('#kyubo #table_layoutA01 tr :nth-child(2)').addClass('second-child');
		$('#sitemap_body ul :last-child').addClass('last-child');
	},
	shopDetailLink: function() {
		var href;
		$('#table_layoutA01 tr').hover(function() {
			href = $(this).find("a").attr("href");
			$(this).css("background-color","#ffe3d7");
		},function(){
			$(this).css("background-color","#ffffff");
		});
		$('#table_layoutA01 tr').click(function(){
			if (href)
				location.href = href;
		});
		$('#table_layoutA02 tr').hover(function() {
			href = $(this).find("a").attr("href");
			$(this).css("background-color","#ffe3d7");
		},function(){
			$(this).css("background-color","#ffffff");
		});
		$('#table_layoutA02 tr').click(function(){
			if (href)
				location.href = href;
		});
	}
}



//Google analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17126860-1']);
_gaq.push(['_trackPageview']);

(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

