$(window).load(function(){
	if($.browser.msie)
	{
		var headerBar = {bl: {radius: 15}, br: {radius: 15}, antiAlias: true}
		var footerBlock = {tl: {radius: 15}, tr: {radius: 15}, bl: {radius: 15}, br: {radius: 15}, antiAlias: true}
		
	    curvyCorners(headerBar, "#headerBar");
	    curvyCorners(footerBlock, "#footerBlock");
    }
});

$(document).ready(function()
{
	loadTwitterInline('onemovement', 5);
	
	// Animate news items
	$('#news').cycle({ 
	    fx: 'scrollUp',
	    timeout: 7000
	});
	
	$('.slideshow').cycle({ 
	    fx: 'fade'
	});
});

function loadTwitterInline(username,count)
{
	var url = "http://twitter.com/status/user_timeline/" + username + ".json?count=" + count + "&callback=?"; 

	$.getJSON(url,function(data){
		$.each(data,function(i,item){
			$("#twitterFeed").append(
					item.text.linkify() + " "+
					relativeTime(item.created_at) + " "
			); 
		}); 
	});
}

String.prototype.linkify = function(){return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/,function(m){return m.link(m);});};


function relativeTime(time_value)
{
	var values = time_value.split(" ");
	
	var hour = values[3].substring(0,5);
	var hour_split = hour.split(":");
	
	if(hour_split[0] > 12)
	{
		hour = (hour_split[0] - 12 )+ ":" +  hour_split[1] + " " +  "PM";
	}
	else
	{
		hour = hour + " " +  "AM";
	}
	time_value = hour + " " + values[1] + " " + values[2] + "th" + " via Web";
	return "<b>" + time_value + "</b>";
}