$(document).ready(function() {

});

function contentSwitch(event, section) {
	$('#splash').slideUp('fast');
	$('.category').removeClass('active-cat');
	$(event.target).closest('.category').addClass('active-cat');
	$('.stuff').hide();
	$('#' + section).show();
}

function restoreSplash() {
	$('#splash').slideDown('fast');
}

function toggleSupportPanel() {
	$.fn.colorbox({ href: "/support/form.php", iframe: true, transition: "fade", scrolling: true, width: 695, height: 640 });
	return false;
}

function triggerMapLoad() {
	// Load embedded map after the fact. Saves us a lot of bandwidth.
	setFormFocus();
}

function setFormFocus() {
	$("#realname").focus();
}

function toggleContactPanel() {
	$.fn.colorbox({ href: "/contactForm.php", iframe: true, transition: "fade", scrolling: false, width: 850, height: 500 });
	return false;
}

function contactValidate() {
	if (document.form1.realname.value.length < 1) {
	  document.form1.realname.focus();
	  window.alert("Missing your name. Please correct");
	  return false;
	}
	if (document.form1.email.value.length < 1) {
	  document.form1.email.focus();
	  window.alert("Please enter your email address");
	  return false;
	}
	if (document.form1.phone_no.value.length < 1) {
	  document.form1.phone_no.focus();
	  window.alert("Please enter your phone number.");
	  return false;
	}     
	if (document.form1.message.value.length < 1) {
	  document.form1.message.focus();
	  window.alert("Please describe your issue in detail.");
	  return false;
	}        
	return true;
}

function supportValidate() {
	if (document.form1.realname.value.length < 1) {
	  document.form1.realname.focus();
	  window.alert("Missing your name. Please correct");
	  return false;
	}
	if (document.form1.email.value.length < 1) {
	  document.form1.email.focus();
	  window.alert("Please enter your email address");
	  return false;
	}
	if (document.form1.email2.value !== document.form1.email.value) {
	  document.form1.email2.focus();
	  window.alert("Email addresses do not match");
	  return false;
	}
	if (document.form1.phone_no.value.length < 1) {
	  document.form1.phone_no.focus();
	  window.alert("Please enter your phone number.");
	  return false;
	}
	if (document.form1.request_type.value == "select") {
	  document.form1.request_type.focus();
	  window.alert("Please select what this issue pertains to");
	  return false;
	}
	if (document.form1.subject.value.length < 1) {
	  document.form1.subject.focus();
	  window.alert("Please enter a brief summary of your issue.");
	  return false;
	}        
	if (document.form1.message.value.length < 1) {
	  document.form1.message.focus();
	  window.alert("Please describe your issue in detail.");
	  return false;
	}        
	return true;
}

