/*
 * Google Analytics
 */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-19530028-1'], ['_setAllowAnchor', true]);

//cross-domain
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowHash'  , false]);
_gaq.push(['_setAllowLinker', true]);

//additional search engines
_gaq.push(['_addOrganic','excite.co.jp','search']);
_gaq.push(['_addOrganic','s.luna.tv','q']);
_gaq.push(['_addOrganic','search.goo.ne.jp','MT']);
_gaq.push(['_addOrganic','search.nifty.co','q']);
_gaq.push(['_addOrganic','search.rakuten.co.','qt']);

if(document.location.hostname=='sweetsbeer.cocolog-nifty.com'){
	_gaq.push(['_trackPageview']);
}
//URLからhashを削除する関数
var removeHash = function(){
	if ('replaceState' in history)
		history.replaceState('', document.title, window.location.pathname);
	else
		window.location.hash = '';
};
//計測後に実行する関数
var doAfterTrack = function(){
	//Cross-DomainまたはCampaign用Hashがあれば削除
	if (location.hash && location.hash.match(/(#|&)(utm_source|__utma)=.+/))
		removeHash();
};
_gaq.push(function(){doAfterTrack();});

(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);
})();

//onClick
$(document).ready(function(){
	//cross-domain link
	jQuery('a').filter(function() {
		return this.hostname && this.hostname !== location.hostname && "www.sanktgallenbrewery.com sanktgallen.shop-pro.jp beer.secure-asp.com".indexOf(this.hostname)!=-1
	}).click(function(){
		_gaq.push(['_link', this.href, true]);
		return false;
	});
});

