/*
 * toggles the citation div tag containing the citation form
 */
$(document).ready(function() {
	$('div.citation').hide();
	$('#toggle').click( function() {
		$('div.citation').toggle('slow');
		$('div.result').fadeOut('100');
		return false;
	});
});

/*
 * submits the citation form, displays citation in result div tag
 */
$(document).ready(function() {
	$('#submit').click(function() {
		var maker = $('select[name=maker]');
		var title = $('select[name=title]');
		var date = $('select[name=date]');
		var from = $('input[name=from]');
		var url = $('input[name=url]');
		var currentdate = $('input[name=currentdate]');
		
		var data = 'maker=' + maker.val() + '&title=' + title.val() + '&date=' + date.val()
		+ '&from=' + from.val() + '&url=' + url.val() + '&currentdate=' + currentdate.val(); 
		
		$.ajax({
			url: "citation.php",
			type: "GET",
			data: data,
			cache: false,
			success: function (html) {
					$('div.result').html(html);
					$('div.citation').toggle('slow');
					$('div.result').toggle('slow');
				}
		});
		return false;
	});
});
