function show_subnav(id) {
	// Open up the right menu based on the ID. These submenus
	// are defined in the inc/nav.html file and are all 
	// hidden by default
	
	// First handle special case of job system by checking 
	// edition id (ed_id) url param
	var edition_id = url_param('ed_id');
	if (edition_id) {
		var mapping = new Array( "-", "jobssum", "jobs", "jobsuk", "jobsgap" );
		if (edition_id < mapping.length) {
			id = mapping[edition_id];
		}
	}
	
	// Now open up the right block
	span = document.getElementById('subnav_' + id);
	
	if (span) {
		span.style.display = 'block';
	}
	
	// Do any other common page tasks
	randomise_masthead_image(id);
	check_voted();
}


function randomise_masthead_image(id) {
// Randomly pick an image from choices and display in masthead
//
// Images are assumed to be in /images/masthead/ and be named
// 0.jpg 1.jpg 2.jpg etc.
// Presently id is ignored

	// How many images are there?
	var choices = 70; // images are numbered 0 through choices-1
	
	// Now pick one at random
	var i = document.getElementById("mastheadImage");
	
	// Just check that the image is there!
	if (i) {
		var choice = Math.floor(Math.random()*choices);
		i.src = "/images/masthead/" + choice + ".jpg";
	}
}


function url_param(p) {
	// Retrieve an url param specified by p=value
	var re = new RegExp( p + "=([^&]+)" );
	var matches = document.location.href.match(re);
	if (matches) {
		return matches[1];
	}
	else {
		return '';
	}
}
