// JavaScript Document
var historicalMap={};
historicalMap.init=function()
	{
		$("div#SearchForm").append($("<form name='find' id='find' method='get'></form>"));
		$("form#find").append("<span class='right80'>Search for records (e.g. Belfast or coal), then click one of the images below to select the type of documents you are interested in. Alternatively click an icon to go to a full listing.</span>");
		$("form#find").append("<input type='hidden' name='method' value='list' />");
		$("form#find").append("<p><input type='text' name='findtext' /></p>");
		
		var action = '';
		var	series = '';
		//When the observatory select box is clicked...
		$("#63_360GeologicalIcon").click(function (event){
			historicalMap.buildForm(event, 'map.cfc', 'I1inch');						 
		});
		$("#63_360_driftIcon").click(function (event) {
			historicalMap.buildForm(event, 'map.cfc', 'Drift');
		});
		$("#10_560GeologicalIcon").click(function (event) {
			historicalMap.buildForm(event, 'map.cfc', 'I6inch');									   
		});
		$("#memoirsIcon").click(function (event) {
			historicalMap.buildForm(event, 'memoir.cfc', '');
		});
		$("#sheetsIcon").click(function (event) {
			historicalMap.buildForm(event, 'miscellSheet.cfc', '');
		});
		$("#oldSectionsIcon").click(function (event) {
			historicalMap.buildForm(event, 'section.cfc', 'Old');
		});
		$("#newSectionsIcon").click(function (event) {
			historicalMap.buildForm(event, 'section.cfc', 'New');
		});
}

historicalMap.buildForm = function (event, theAction, theSeries) {
		event.preventDefault();
		action = theAction;
		series = theSeries;
		historicalMap.submitForm(action, series);
}

historicalMap.submitForm = function(action, series)
{
		$("form#find").attr("action",action);
		if(series != '') {$("form#find").append("<input type='hidden' name='series' value='"+ series + "' />");}
		$("form#find").submit();
}

$(document).ready(historicalMap.init);
