$(document).ready(function(){

	//colours.today($('#logo'));
	//colours.postdates();
});

var colours = {
	
	init: function(){
		
	},

	today : function(element){ 
		
		$.ajax({
        url: 'http://thelastline.com/new/api/' ,
        dataType: "jsonp",
        data:{},
        timeout: 5000,
        success: function(data, status){
            element.css('background-color', '#' + data.todays_colour);
            
        },
        error: function(XHR, textStatus, errorThrown){
            alert("ERROR: " + textStatus);
            alert("ERROR: " + errorThrown);
        }
    });
     
	},
	
	postdates : function(){
	
		$('.datetime').each(function(index) {
    			var date_of_post=$(this).find('li.datevalue').text();
    			var element=$(this);
    			$.ajax({
		        url: 'http://thelastline.com/new/api/find/date/' + date_of_post ,
		        dataType: "jsonp",
		        data:{},
		        timeout: 5000,
		        success: function(data, status){
		            element.css({'border-color': '#' + data.background_colour});
		            
		        },
		        error: function(XHR, textStatus, errorThrown){
		            alert("ERROR: " + textStatus);
		            alert("ERROR: " + errorThrown);
		        }
		     });	
  		});
		
	}
};

