$(document).ready(function(){
	if(page_title == ''){
		$("#homefeed-loading").html('<img style="width:16px;margin-bottom:4px;" src="../wp-content/themes/barnesdmd/images/loadingball.gif" />');
		$.getJSON("http://barnesdmd.co.uk/wp-content/themes/barnesdmd/homefetch.php", function(data){
			$.each(data.entries,function(i,item){
				if($('#'+i).length<1){
					$(item).hide().prependTo('#homefeed').slideDown();
				}
			});
			//$("#homefeed").empty().append(data.html);
			//$.each(data, function(i,item){
				//$("#homefeed").append('<li><span style="background-image:url(../wp-content/themes/barnesdmd/icons/'+item.icon+'.ico);">&nbsp;</span><span class="homefeed_title">'+item.title+'</span></li>');
			//});
			//$("#homefeed").slideDown();
			$("#homefeed-loading").fadeOut();
		});
	}
	$("a[rel='gallery']").colorbox();
	$(".toggleable").hide();
	$("#togglemessage").html('<p>Clicking on the <span class="faketoggle" title="Show more information"><span>[</span>Show<span>]</span></span> links will give you additional information on certain entries without you having to leave the page.</p>');
	$(".hs li").each(function(){
		if($(this).children('.toggleable').length > 0){
			$(this).children('h4').append(' <a class="toggle" title="Show more information" href="#" alt="#'+$(this).children('.toggleable').attr('id')+'"><span>[</span>Show<span>]</span></a>');
		}
     });
	$('.toggle').live('click',function(){
		//alert($(this).attr('alt'));
		$($(this).attr('alt')).toggle("slow");
		//The to lower case bit here is beacuse opera seems to convert the tags in the $(this).html() bit to upper case whether it should be or not
		if($(this).html().toLowerCase() == "<span>[</span>show<span>]</span>"){
			$(this).html('<span>[</span>Hide<span>]</span>').attr('title','Hide extra information');
		}else{
			$(this).html('<span>[</span>Show<span>]</span>').attr('title','Show more information');
		}
		return false;
	});
	$(".delicious").text('');
	$("#s").val('Search...').click(function(){if($(this).val() == 'Search...'){$(this).val('');}});
	if($.browser.msie || $.browser.opera){
		var settings = {tl: { radius: 10 },tr: { radius: 10 },bl: { radius: 10 },br: { radius: 10 },antiAlias: true}	
		curvyCorners(settings, "#content");
	}
});
