$(document).ready(function() {	
	 
	$.fn.equalizeCols = function(){
		var height = 0,
			reset = $.browser.msie ? "1%" : "auto";
  
		return this
			.css("height", reset)
			.each(function() {
				height = Math.max(height, this.offsetHeight);
			})
			.css("height", height)
			.each(function() {
				var h = this.offsetHeight;
				if (h > height) {
					$(this).css("height", height - (h - height));
				};
			});			
	};
	
	
	/* my stuff */
	function fixStuff() {
		//var $els = $("#contentcolumn, #rightcolumn").equalizeCols();	
		var ww = $("#wrapper").width() - 5;
		$("#leftcolumn").css("margin-left", -ww);
	}
	
	$(window).bind('resize', function() {
		fixStuff();   
	});
	
	
	/* changing background */
	function getBackground() {
		var color;
		var img;
		
		var num_bgs = 13;
		var ran_number=Math.floor(Math.random()*num_bgs);
		
		switch(ran_number) {
			case 0:
				color = "#ff9999";
				img = "wolf.jpg";
				setBG(color, img, "50% 0px", "no-repeat");
			break;
			case 1:
				color = "#9a9287";
				img = "hk.jpg";
				setBG(color, img, "50% 0px", "no-repeat");
			break;
			case 2:
				color = "#00FFFF";
				img = "aqua.jpg";
				setBG(color, img, "50% 0px", "no-repeat");
			break;
			case 3:
				color = "#999999";
				img = "interfere.jpg";
				setBG(color, img, "50% 0px", "repeat-x");
			break;
			case 4:
				color = "#353535";
				img = "cone.jpg";
				setBG(color, img, "50% 0px", "no-repeat");
			break;
			case 5:
				color = "#0055fe";
				img = "jelly.jpg";
				setBG(color, img, "50% 0px", "no-repeat");
			break;
			case 6:
				color = "#ffffff";
				img = "fridge.jpg";
				setBG(color, img, "", "repeat");
			break;
			case 7:
				color = "#f0e0cd";
				img = "beer.jpg";
				setBG(color, img, "50% 0px", "no-repeat");
			break;
			case 8:
				color = "#a3b2c5";
				img = "liberty.jpg";
				setBG(color, img, "", "repeat-x");
			break;
			case 9:
				color = "#000000";
				img = "red.jpg";
				setBG(color, img, "", "repeat");
			break;
			case 10:
				color = "#000000";
				img = "aok.jpg";
				setBG(color, img, "", "repeat");
			break;
			case 11:
				color = "#000000";
				img = "blue.jpg";
				setBG(color, img, "", "repeat");
			break;
			case 12:
				color = "#000000";
				img = "colorado.jpg";
				setBG(color, img, "", "repeat");
			break;
		
		}
			
		
	}
	
	function setBG(color, image, position, repeat) {
		var root = "http://deleteyourself.com/blog/bg/";
		
		$("body").css('background-color', color);
		$("body").css('background-image', 'url('+ root + image+')');
		$("body").css('background-position', position);
		$("body").css('background-repeat', repeat);	
	}
	
	/* banner crap */

	function getBanner() {
		var url;
		var img;
		var num_banners = 5;
		var ran_number=Math.floor(Math.random()*num_banners);
		
		
		switch(ran_number) {
			case 0:
				url = "http://hasthebest.com";
				img = "http://deleteyourself.com/blog/banners/hasthebest.jpg";
			break;
			case 1:
				url = "http://whatsideoftheroad.com";
				img = "http://deleteyourself.com/blog/banners/whatsideoftheroad.jpg";
			break;
			case 2:
				url = "http://photololz.com";
				img = "http://deleteyourself.com/blog/banners/photololz.jpg";
			break;
			case 3:
				url = "http://madisonmcnugget.com";
				img = "http://deleteyourself.com/blog/banners/madison.jpg";
			break;
			case 4:
				url = "http://williamsburgeats.com";
				img = "http://deleteyourself.com/blog/banners/wburgeats.jpg";
			break;
			
		}
		
		$("#the-ad").html('<a href="' + url + '"><img src="' + img + '" border="0" width="160" height="600" /></a>');
	}
	
	fixStuff();
	getBackground();
	getBanner();
	
	$("#change-it").click(function(){
		getBackground();
	});
	
	$("#change-bg img").hover(
		 function()
		 {
		  this.src = this.src.replace("_off","_on");
		 },
		 function()
		 {
		  this.src = this.src.replace("_on","_off");
		 }
	);
	
	
});

