$(document).ready(function() {
	$('.cycle').find('.killfloat').remove();
	$('.cycle').find('.news_all').remove();
	if ($('#featured_advert img').length != 0) {		$('<div class="news_item"><div class="news_item_inner"><div class="news_item_hook"></div><h5><a href="'+$('#featured_advert a').attr('href')+'">'+$('#featured_advert img').attr('alt')+'</a></h5><span class="news_image"><a href="'+$('#featured_advert a').attr('href')+'"><img src="'+$('#featured_advert img').attr('src')+'" /></a></span></div></div>').insertAfter(".defaultnews.cycle .item1");	}	$('#featured_advert').remove();	$('.defaultnews.cycle').cycle({fx: 'scrollHorz', pause: 'true', next: '.cyclewrapper #next', prev: '.cyclewrapper #prev', timeout:12000, delay:-4000});
	$('.defaultents.cycle .msl_eventlist > div').cycle({pause: 'true', timeout:8000, delay:2000});

	var today = new Date();
	var dayofweek = today.getDay()+1;
	$('#opening_reception').before('<p>'+$('#opening_reception div table tr:nth-child('+dayofweek+') td').html()+'</p>');
	$('#opening_reception').remove();
	$('#opening_advice').before('<p>'+$('#opening_advice div table tr:nth-child('+dayofweek+') td').html()+'</p>');
	$('#opening_advice').remove();

	if ($('#ctl00_boarrss_ErrorMessage_NotificationLabel').length != 0){
		$('#ctl00_boarrss_ErrorMessage_NotificationLabel').parent().replaceWith('<p>The University of Warwick students\' newspaper, published every Tuesday, and circulated amongst most of the students on campus. Find out more at <a href="http://theboar.org">theBoar.org</a>.</p>');
	}

	$('#today .event').each(function() { if ( $(this).find('.msl_event_time').text().trim().substr(0,2).replace(/[a-z]/,'') != today.getDate()){ $(this).remove(); } else { $(this).find('.msl_event_time').html($(this).find('.msl_event_time').html().replace(/\d{1,2}[a-z]{2}\s[a-zA-Z]*?\s/,''));} });
	
	var weekday=new Array(7);
	weekday[0]="Sunday";
	weekday[1]="Monday";
	weekday[2]="Tuesday";
	weekday[3]="Wednesday";
	weekday[4]="Thursday";
	weekday[5]="Friday";
	weekday[6]="Saturday";
	
	var month = new Array(12);
	month[0]="January";
	month[1]="February";
	month[2]="March";
	month[3]="April";
	month[4]="May";
	month[5]="June";
	month[6]="July";
	month[7]="August";
	month[8]="September";
	month[9]="October";
	month[10]="November";
	month[11]="December";

	$('#today h1').prepend('<span>'+weekday[today.getDay()]+', '+today.getDate()+' '+month[today.getMonth()]+'</span>');
	
	$('#news #ctl00_newsall_lnkAllNews').html('More News&hellip;');
	$('#news .news_item_inner').hover(function() { $(this).find('.leader').slideDown(); },function() { $(this).find('.leader').slideUp(); });
	$('#news .leader').each(function() { $(this).html('<a href="'+$(this).parent().find('.news_image a').attr("href")+'">'+$(this).html()+'</a>'); });

	$('#studentmedia .rss_description').each(function() { $(this).parent().find('.rss_title a').prepend($(this).find('img:first')); $(this).remove(); });
	$('#studentmedia .rss_title img').each(function() { $(this).attr('src','http://theboar.org'+$(this).attr('src')); });
	$('p.raw_onair').html('On air: '+$('div.raw_onair').find('.rss_title').html()+'. <a href="http://www.radio.warwick.ac.uk/listen/?utm_source=warwicksu&utm_medium=web&utm_content=su_homepage" target="player" class="raw_listenpop">Listen Live!</a>');
	$('div.raw_onair').remove();
	$('.raw_listenpop').click(function() { window.open('http://player.radio.warwick.ac.uk/?utm_source=warwicksu&utm_medium=web&utm_content=su_homepage', 'radioplayer', 'height=665,width=380'); return false; });
	if ($('#jobs div').length == 0) {
		$('#jobs').hide();
	}
	$('.msl-recentblogpostdate').each(function(){
		$(this).html($(this).text().substr(0,10));
	});
	$("<dd class=\"eventtype soc\">Society Event</dd>").insertAfter('#eventcalendar .msltypesocieties dt');
	$("<dd class=\"eventtype bss\">Big-Screen Sport</dd>").insertAfter('#eventcalendar .msltypebigscreensports dt');
	$("<dd class=\"eventtype club\">Clubnight</dd>").insertAfter('#eventcalendar .msltypeclub dt');
	$("<dd class=\"eventtype gig\">Live Music</dd>").insertAfter('#eventcalendar .msltypegig dt');
});
