$(function(){
	
	o = {
		$win:$(window),
		$doc:$(document),
		$body:$('body')
	};
	
	
	//[common]

	//browser check -------------------------------------------- */
	if (navigator.platform.indexOf("Win") != -1) { //Windows
		$('body').addClass("win");
			if(!jQuery.support.opacity) { //IE6〜IE8
				if(!jQuery.support.style) { //IE6〜IE7
					$('body').addClass("win-ie").addClass("win-ieL");
				} else { //IE8
					$('body').addClass("win-ie");
				}
			} else { // Windows
		}
	} else { // Mac
	}
	
	$('a img, #sidebar li').not('.none').hover(function(){$(this).fadeTo(200, 0.6)}, function(){$(this).fadeTo(0, 1)})
	
	//resizing thumbnail
	$('.archive .post a img.attachment-thumbnail').width(64).height(64);
	$('#top-update ul li a img.attachment-thumbnail').width(64).height(64);
	$('#top-items ul li a img.attachment-thumbnail').width(147).height(147);


	//[top]
	//add class to items column
	$('#top-items ul li .detail p').addClass('description');
	$('#top-items ul li .detail p').addClass('description');

	//[works] add the caption of past works
	$('.archive .single .entry-works div').each(function(i){
		if($(this).children('a').children('img').length){
			$(this).append('<span>' + $(this).children('a').children('img').attr('title') + '</span>');
			$(this).children('a').attr('title', $(this).children('p.entry-works-caption').text());
		}
	});
	$('#banners-provide p').addClass('left');

	$('.a-pagetop').click( function() { 
		$('html,body').animate({ scrollTop: 0 }, 800);
		return false;
	});
	$('.a-anchor').click( function() { 
		var target = $(this).attr('href');
		var scroll = $(target).offset();
		$('html,body').animate({ scrollTop: scroll.top }, 800);
		return false;
	});

	//[items]
	//add zoom button for images	
	$('.single-items .items-imgs a img.size-medium').each(function(){
		$(this).parent().wrap('<p class="items-img"></p>');
		$(this).parent().append('<img src="http://fujikizuna.com/wp-content/themes/fujikizuna/_img/bt-items-zoom.gif" width="101" style="padding-top:5px;"/>');
	});
	//make list
	$('.single-items .items-description ul a').each(function(){
		$(this).wrap('<li></li>')
	});
	
	//colorbox
	$('.single-items div.items-imgs p.items-img a, ul.gallery dl dt a, .entry-works a, p a#areamap.').colorbox();


	//twitter part
	$('#tweets').jTweetsAnywhere({
    username: 'fujikizuna',
    count: 5,
    showInReplyTo: false,
    tweetTimestampDecorator: function(tweet, options){
			var screenName = tweet.user ? tweet.user.screen_name : false || tweet.from_user;
			var date = new Date(formatDate(tweet.created_at));
			
			var h;
			var ampm;
			if(date.getHours() >= 13) {
				h = date.getHours() - 12;
				ampm = "PM";
			}
			else if(date.getHours() <= 12) {
				h = date.getHours();
				ampm = "AM";
			}
      var dateString =
          h + ':' +
          (date.getMinutes() < 10 ? '0' : '') + 
          date.getMinutes() + ' ' + ampm + ' ' +
          (date.getMonth() + 1) + '/' +
          date.getDate() + '/' +
          date.getFullYear();

			var html =
				'<p class="jta-tweet-timestamp">' +
				'<a class="date" href="http://twitter.com/' +
				screenName + '/status/' + tweet.id + '">' +
				dateString + '</a></p>';
				
			return html;
    }
	});
	
	var fitHeightTimer = setInterval(function(){
		var sideHeight = parseInt($('#side_content').height());
		var contentHeight = parseInt($('.content').height());
		if(contentHeight < sideHeight) $('.content').height(1900);
		else if(contentHeight > sideHeight) $('#side_content').height(contentHeight - 40);
	}, 100);

});

$(window).load(function(){
	$('#top-banner img').fadeTo(1000, 1);		
});
