$(document).ready(function(){
	
	// Facebook like integration
	// -----------------------------------------------------------------------------

		if ( (!$.browser.msie) || ($.browser.msie && $.browser.version.substr(0,1) > 6) ) {
			$('head').append('<meta property="og:image" content="'+js_theme_url+'/nav/logo_fb.png" />');

			$('.facebook-like').each( function(i) {
				$(this).html(
					 '<iframe src="http://www.facebook.com/plugins/like.php?href='+$(this).attr('title')
					+'&amp;layout=button_count&amp;show_faces=false&amp;width=200&amp;action=like&amp;font=arial'
					+'&amp;colorscheme=light&amp;height=35" scrolling="no" frameborder="0" style="border:none; '
					+'overflow:hidden; width:150px; height:35px;" allowTransparency="true"></iframe>'
				);
			});

			$('.facebook-like').css('display', 'block');
		}

	// -----------------------------------------------------------------------------
	
	

	// Selected menu items.
	// -----------------------------------------------------------------------------
	$('#submenu').children('.current_page_ancestor').children('a:eq(0)').attr('class', 'selected');
	
	
	
	

	// Set the height of the sidebar if less than 193px high.
	// -----------------------------------------------------------------------------
	// if ( $('#blob2').height() < 193 ) {
	// 	$('#blob2').css('padding-bottom', 193-$('#blob2').height()+'px')
	// }
	
	
	
	
	
	// Image formatting.
	// Adjust formatting if there is more than 1 image.
	// -----------------------------------------------------------------------------
	function image_reformat() {
		var image_count = $('.page-images > .page-image').size();
		if (image_count > 1) {
			$('.page-images').attr('class', 'page-images-wide');
			setHeight(".page-images-wide", 2, 0);
		}
	}
	
	function setHeight(theClass, cols, item_height) {
		
		$('body').append('<div id="debug"></div>');
		
		$(theClass).wrapInner('<div class="inner"></div>');			// Wrap div around content of outer div.
		var block_count = $(theClass+' .inner').children().size();	// Count number of blocks.
		var block_item = '.'+$(theClass+' .inner').children('div:eq(0)').attr("class");	// Get the class name of repeating blocks.
		
		var looper = 0;												// Initialise variable.
		while (looper < block_count) {								// Loop for number of blocks...
			$(theClass).children('.inner').children(block_item).slice(0,cols).wrapAll('<div class="block-row"></div>');
			looper = looper+cols;	// Set for next row group.
		}
		
		if (item_height == 1) {											// Use if each block has background.
			var largestHeight = 1;										// Initialise variable.
			$(theClass+' .inner .block-row>div').each(function (i) {	// Loop through each block...
				if (parseInt($(this).height()) > largestHeight) {		// If current block is the tallest block yet...
					largestHeight = parseInt($(this).height());			// Set height placeholder to current block height.
				}
			});
			$(theClass+' .inner .block-row>div').css("height", largestHeight);	// Set all blocks to tallest value.
		}
	}
	
	image_reformat();
	
	
	
	
	
	// Fix PNGs for IE6.
	// -----------------------------------------------------------------------------
	$(document).pngFix();
	
});





// Fix blog button highlight when on search page.
// -----------------------------------------------------------------------------
function fix_blog_button() {
	$('.current_page_parent').removeAttr('class');
}



$(document).ready(function() {
	$("#twitter").getTwitter({
		userName: "alittlesquare",
		numTweets: 1,
		loaderText: "Loading tweets...",
		slideIn: false,
		showHeading: false,
		headingText: "Latest Tweets",
		showProfileLink: false
	});
	$('#twitter-feed').css('display', 'none');
});
