﻿$(document).ready(function() {
	$('.btnEmailSubmit').click(function() {
		var postForm = document.createElement("form");
		postForm.method = "post";
		postForm.action = "/Email-Signup.aspx";
		addFormField(postForm, "email", $('#email').val());
		document.body.appendChild(postForm);
		postForm.submit();
	});
	$('.btnSiteSearch').click(function() {
		var postForm = document.createElement("form");
		postForm.method = "get";
		postForm.action = "/search-results.aspx";
		addFormField(postForm, "q", $('#search-field').val());
		document.body.appendChild(postForm);
		postForm.submit();
	});
	$('#search-field').keypress(function(e) {
		if (window.event) {
			key = window.event.keyCode;
		}
		else {
			key = e.which;
		}
		if (key == 13) {
			e.preventDefault();
			$('#btnSiteSearch').click();
		}  
	});
	$('#btnSiteSearch2').click(function() {
		var postForm = document.createElement("form");
		postForm.method = "get";
		postForm.action = "/search-results.aspx";
		addFormField(postForm, "q", $('#search-field2').val());
		document.body.appendChild(postForm);
		postForm.submit();
	});
	$('#search-field2').keypress(function(e) {
		if (window.event) {
			key = window.event.keyCode;
		}
		else {
			key = e.which;
		}
		if (key == 13) {
			e.preventDefault();
			$('#btnSiteSearch2').click();
		}
	});

	$('#fontsizer').jfontsizer({
		applyTo: '#boxContent'
	});
});



function addFormField(form, fieldName, fieldValue) {
    var inputField = document.createElement("input");
    inputField.setAttribute("name", fieldName);
    inputField.setAttribute("id", fieldName);
    inputField.setAttribute("type", "hidden");
    inputField.setAttribute("value", fieldValue);
    form.appendChild(inputField);
}


