function toggleArchives(state) {
	if(state == 1) {
		document.getElementById('archive').style.background = 'transparent url(images/openarrow.jpg) no-repeat center left';
		document.getElementById('archives').style.display = '';
	}
	else {
		document.getElementById('archive').style.background = 'transparent url(images/closedarrow.jpg) no-repeat center left';
		document.getElementById('archives').style.display = 'none';
	}
}

// photo section
function photoInit () {
	// image box
	$.ImageBox.init(
		{
			loaderSRC: 'images/imagebox/loading.gif',
			closeHTML: '<img style="border: 0; margin-top: 15px;" src="images/imagebox/close.png" />'
		}
	);
}


// ajax email
function submitEmail(obj) {
	if ((obj.name.value).length < 1 || (obj.email.value).length < 1 || (obj.comments.value).length < 1) {
		$("#contactbox").html('<p class="error">Please fill out all fields</p>');
	} else {
		var str = $('#contactForm').formSerialize();
		$.post('email.php', str , submitEmailResponse);
	}
}

var submitEmailResponse = function(x, y) {
	if (x.length > 0) { // errors
		$("#contactbox").html('<p class="error">' + x + '</p>');
	}
	else {
		$("#contactbox").html('<p><em>Thank you! Your message has been sent to Hope Harvest International.</em></p>');	
		$('#contactForm').clearForm();
	}
};

// homepage old news
function toggleOldNews() {
	$("#eventArchiveToggle").hide();
	$("#eventArchives").toggle();
}