$(window).load(function() {
    // Make columns equal height.
    // Give me a decent layout language
    // and I won't have to resort to this nonsense.
    var header = $("div#header").outerHeight()
    var content = $("div#content").outerHeight()
    var gratitude = $("div#gratitude").outerHeight()
    var highest = Math.max(header,content,gratitude);
    //var highest = header;
    //if (content > highest) { highest = content; }
    //if (gratitude > highest) { highest = gratitude; }
    $("div#header").add("div#content").add("div#gratitude").height(highest);

    var Color = function () {

	var randomColor = function () {
	    var baseline = 100;
	    var range = 140;
	    return baseline + Math.floor(Math.random()*range);
	}
	var normal = function (x) { return x; }
	var lighten =  function (x) { return Math.floor((255+x)/2); }

	var r = randomColor();
	var g = randomColor();
	var b = randomColor();
	var rgbString = function (f) { return "rgb(" + f(r) + "," + f(g) + "," + f(b) + ")";}

	this.rgb = rgbString(normal);
	this.light = rgbString(lighten);
    }

    var color = new Color();
    //console.log(color.rgb, color.light);
    $("div#header").add("div.item img").css("background-color",color.rgb);
    $("div#gratitude").css("background-color",color.light);
    $("div.item").hover(
	function () {
	    $(this).css("background-color",color.light);
	    $(this).css("cursor","pointer");
	}, 
	function () {
	    $(this).css("background-color","transparent");
	}
    );

    // Extract URL from title of item,
    // and apply it to the whole div.
    $("div.item").click(function(e){
	e.preventDefault();
	window.location=$(this).find("a").attr("href");
    });
});

