function tabBlogRanking(content) {
	if (content == 'normal') {
		$('switchRankingNormal').addClassName('on');
		$('switchRankingAdult').removeClassName('on');
		$('blogRankingNormal').style.display  = 'block';
		$('blogRankingAdult').style.display  = 'none';
	} else if (content == 'adult') {
		$('switchRankingNormal').removeClassName('on');
		$('switchRankingAdult').addClassName('on');
		$('blogRankingNormal').style.display  = 'none';
		$('blogRankingAdult').style.display  = 'block';
	} else {
		$('switchRankingNormal').addClassName('on');
		$('switchRankingAdult').removeClassName('on');
		$('blogRankingNormal').style.display  = 'block';
		$('blogRankingAdult').style.display  = 'none';
	}
}

function tabPopularEntries(period) {
	if (period == 'latest') {
		$('switchPopularEntriesLatest').addClassName('on');
		$('switchPopularEntriesYesterday').removeClassName('on');
		$('popularEntriesLatest').style.display  = 'block';
		$('popularEntriesYesterday').style.display  = 'none';
	} else if (period == 'yesterday') {
		$('switchPopularEntriesLatest').removeClassName('on');
		$('switchPopularEntriesYesterday').addClassName('on');
		$('popularEntriesLatest').style.display  = 'none';
		$('popularEntriesYesterday').style.display  = 'block';
	} else {
		$('switchPopularEntriesLatest').addClassName('on');
		$('switchPopularEntriesYesterday').removeClassName('on');
		$('popularEntriesLatest').style.display  = 'block';
		$('popularEntriesYesterday').style.display  = 'none';
	}
}

function saveContentsFilter(content, value){
	//Save cookie
	expiration = new Date();
	expiration.setTime(expiration.getTime() + (365 * 1000 * 60 * 60 * 24));
	expirationGMT = expiration.toGMTString();
	document.cookie = encodeURIComponent(content) + '=' + encodeURIComponent(value) + '; expires=' + expirationGMT + '; domain=.gaylog.jp; path=/';
	location.reload(true);
}

function entryClicked(entryId, entryUrl){
	cookieName = 'ep' + encodeURIComponent(entryId);
	//Check if the cookie exists
	theCookie = document.cookie + ';';
	checkCookie = theCookie.indexOf(cookieName);
	if (checkCookie != -1) {
		location.href = entryUrl;
	} else {
		//Save cookie
		expiration = new Date();
		expiration.setTime(expiration.getTime() + (60 * 60 * 1000));
		expirationGMT = expiration.toGMTString();
		document.cookie = cookieName + '=1; expires=' + expirationGMT + '; domain=.gaylog.jp; path=/';
		//Send Entrypoint
		var parameter = 'entryId=' + encodeURIComponent(entryId);
		new Ajax.Request('/ajax/add.entrypoint', {
			method: 'post',
			parameters: parameter,
			onSuccess: function(response) {
				location.href = entryUrl;
			}, 
			onFailure: function(response) {
				location.href = entryUrl;
			}
		});
	}
}
