// JavaScript functions for Darkness and Light Photo Galleries

var prevBwSepVal;

function initialise_gallery() {
//	lowResScreenRedirector();  NO LONGER NEEDED 16/10/06
	var selOption = document.options_bar_form.bw_sepia.selectedIndex;
	prevBwSepVal = document.options_bar_form.bw_sepia.options[selOption].text;
}

function gallery_options_form() {
	// Process the submission of the options bar form on gallery pages
	var pgVal = document.options_bar_form.pg.value;
	var selOption = document.options_bar_form.bw_sepia.selectedIndex;
	var bwSepVal = document.options_bar_form.bw_sepia.options[selOption].text;
	if ( bwSepVal == "both" && prevBwSepVal != "both" ) {
		// Toning option changed to "both" from something else
		document.options_bar_form.pg.value = 2*pgVal-1;

	}
	else if ( bwSepVal != "both" && prevBwSepVal == "both" ) {
		// Toning option changed from "both" to something else
		var newPg = Math.floor( 0.5*( parseFloat(pgVal)+1.0 ) );
		document.options_bar_form.pg.value = newPg;

	}
	else if ( bwSepVal != prevBwSepVal  ) {
		// Toning option changed, but no affect on paging

	}
	else {
		// non-toning change, so reset the pager
		document.options_bar_form.pg.value = 1;
	}
	document.options_bar_form.submit();
}

function nofollow(n)
{ document.location.href=n; } 

