/* ! Forms *//*
================================================================================================================================ */

/* Empty Form Element
-------------------------------------------------------------------------------------------------------------------------------- */
function JL_empty_form(my_object_name) {
	var my_object = new JL_get_object(my_object_name);
	if (my_object.object.defaultValue) {
		if (my_object.object.value === my_object.object.defaultValue) {
			JL_set_object_property(my_object_name, 'value', '');
		}
	}
}

/* Fill Form Element
-------------------------------------------------------------------------------------------------------------------------------- */
function JL_fill_form(my_object_name) {
	var my_object = new JL_get_object(my_object_name);
	if (my_object.object.defaultValue) {
		if (my_object.object.value === '') {
			JL_set_object_property(my_object_name, 'value', my_object.object.defaultValue);
		}
	}
}

/* Set Maximum Length for Form Element Input
-------------------------------------------------------------------------------------------------------------------------------- */
function JL_textfield_maximum_length(my_form_element, my_maximum) {
	var my_object = new JL_get_object(my_form_element);
	if (my_object.object.value.length && my_object.object.value.length > my_maximum) {
		JL_set_object_property(my_form_element, 'value', my_object.object.value.substring(0, my_maximum));
	}
}


/* ! Submit Forms *//*
================================================================================================================================ */
function JL_submit_email_me(my_form) {
	if (document.forms[my_form].name.defaultValue && document.forms[my_form].mail.defaultValue && document.forms[my_form].number.defaultValue && document.forms[my_form].message.defaultValue) {
		var my_focus = 0;
		if (document.forms[my_form].name.value === document.forms[my_form].name.defaultValue || document.forms[my_form].name.value === '') {
			my_focus = 1;
		} else if (document.forms[my_form].mail.value === document.forms[my_form].mail.defaultValue || document.forms[my_form].mail.value === '') {
			my_focus = 2;
		} else if (document.forms[my_form].message.value === document.forms[my_form].message.defaultValue || document.forms[my_form].message.value === '') {
			my_focus = 3;
		}
		if (my_focus === 1) {
			document.forms[my_form].name.focus();
			var my_object = new JL_get_object('name');
			JL_set_object_property('name', 'className', my_object.object.className + ' notice-negative');
			JL_set_object_property('figure-img-1', 'src', '/contact/images/return-to-sender-name.gif');
		} else if (my_focus === 2) {
			document.forms[my_form].mail.focus();
			var my_object = new JL_get_object('mail');
			JL_set_object_property('mail', 'className', my_object.object.className + ' notice-negative');
			JL_set_object_property('figure-img-1', 'src', '/contact/images/return-to-sender-mail.gif');
		} else if (my_focus === 3) {
			document.forms[my_form].message.focus();
			var my_object = new JL_get_object('message');
			JL_set_object_property('message', 'className', my_object.object.className + ' notice-negative');
			JL_set_object_property('figure-img-1', 'src', '/contact/images/return-to-sender-message.gif');
		}
		if (!my_focus) {
			document.forms[my_form].submit();
			return false;
		}
	} else {
		document.forms[my_form].submit();
		return false;
	}
}

function JL_submit_contact_you(my_form) {
	if (document.forms[my_form].contactinfo.defaultValue) {
		var my_focus = 0;
		if (document.forms[my_form].contactinfo.value === document.forms[my_form].contactinfo.defaultValue || document.forms[my_form].contactinfo.value === '') {
			my_focus = 1;
		}
		if (my_focus === 1) {
			document.forms[my_form].contactinfo.focus();
			var my_object = new JL_get_object('contactinfo');
			JL_set_object_property('contactinfo', 'className', my_object.object.className + ' notice-negative');
			JL_set_object_property('figure-img-2', 'src', '/contact/images/return-to-sender-contactinfo.gif');
		}
		if (!my_focus) {
			document.forms[my_form].submit();
			return false;
		}
	} else {
		document.forms[my_form].submit();
		return false;
	}
}

function JL_submit_email_you(my_form) {
	if (document.forms[my_form].fullname.defaultValue && document.forms[my_form].email.defaultValue) {
		var my_focus = 0;
		if (document.forms[my_form].fullname.value === document.forms[my_form].fullname.defaultValue || document.forms[my_form].fullname.value === '') {
			my_focus = 1;
		} else if (document.forms[my_form].email.value === document.forms[my_form].email.defaultValue || document.forms[my_form].email.value === '') {
			my_focus = 2;
		}
		if (my_focus === 1) {
			document.forms[my_form].fullname.focus();
			var my_object = new JL_get_object('fullname');
			JL_set_object_property('fullname', 'className', my_object.object.className + ' notice-negative');
			JL_set_object_property('figure-img-3', 'src', '/contact/images/return-to-sender-fullname.gif');
		} else if (my_focus === 2) {
			document.forms[my_form].email.focus();
			var my_object = new JL_get_object('email');
			JL_set_object_property('email', 'className', my_object.object.className + ' notice-negative');
			JL_set_object_property('figure-img-3', 'src', '/contact/images/return-to-sender-email.gif');
		}
		if (!my_focus) {
			document.forms[my_form].submit();
			return false;
		}
	} else {
		document.forms[my_form].submit();
		return false;
	}
}
