(function(){
	
	// settings
	var banner_height = 60,
		banner_width = 468,
		base_url = "http://www.torensma.net/banners/";

	// banner object
	function banner(url, src, title) {
		this.url = url;
		this.src = src;
		this.title = title;
	}

	// push banner into collection,
	// but only if it does not link to current website
	function push(coll, banner) {
		if (banner.url.match(window.location.hostname) == null) {
			coll.push(banner);
		}
	}

	// create an array to hold the banners
	var b = new Array();

	// push banners into collection
	push(b, new banner("http://calculators.torensma.net", base_url+"banner_calc_70s.jpg",  "Pocket Computing Devices"));
	push(b, new banner("http://tanks.torensma.net",       base_url+"banner_tanks.jpg",     "Tanks & armour"));
	push(b, new banner("http://tanks.torensma.net",       base_url+"banner_tanks_fun.jpg", "Funny & strange tanks"));
	push(b, new banner("http://programming.torensma.net", base_url+"banner_prog.jpg",      "c#, vb, php, sql snippets"));
	push(b, new banner("http://dx.torensma.net", base_url+"banner_dx.jpg",      "UnidenCommander, remote control software for Uniden scanners"));
	
	// determine which banner to show
	var i = Math.round(Math.random()*(b.length-1));

	// create an iframe; make sure id and name are unique in the page
	document.write("<iframe frameborder='0' width='"+banner_width+"' height='"+(banner_height+20)+"' name='torensma_banner_frame' id='torensma_banner_frame' scrolling='no'></iframe>");

	// get reference to document in inframe
	var fr = window.frames["torensma_banner_frame"].document;

	// write html header
	fr.write("<html><head><style>*{margin:0;padding:0;font:9px arial;}</style></head><body>");

	// write banner (image and href)
	fr.write("<p style='text-align:center'>Also visit my other site:");
	fr.write("<a href='"+b[i].url+"' title='"+b[i].title+"' target='_blank'><img src='"+b[i].src+"' width='"+banner_width+"' height='"+banner_height+"' alt='"+b[i].title+"' border='0' /></a>");
	fr.write("</p>");

	// close html document
	fr.write("</body></html>");
})()