/*
+----------------------------------------------------------------------+
| Authors: Matthew Kirkpatrick <webmaster@immergetech.com>                |
+----------------------------------------------------------------------+
 Last Updated: June 21, 2011
*/
entrySearch = function (searchGroup, currentPage) {
	$('.search_results_count').html('<img src="/files_images/base/ajax-loader.gif" width="21" height="21" border="0" />');
	$('#searchGroup').val(searchGroup);
	if (!currentPage) { $('#currentPage').val(1); } else { $('#currentPage').val(currentPage); }
	$('#search_result_block').load('/files_search/index.php?show=search', $('#searchDetails').serializeArray());
};

postwith = function (to, p) {
	var myForm = document.createElement('form');
	myForm.method = 'post';
	myForm.action = to;
	var a = 0;
	var myInput = new Array ();
	for (var k in p) {
		myInput[a] = document.createElement('input');
		myInput[a].setAttribute('name', k);
		myInput[a].setAttribute('value', p[k]);
		a++;
	}
	for (b = 0; myInput[b]; b++) {
		myForm.appendChild(myInput[b]);
	}
	document.body.appendChild(myForm);
	myForm.submit();
	document.body.removeChild(myForm);
}

formSubmit = function (page_form, formData) {
	$.ajax({
		type:		'POST',
		url:		'/files_form_processors/' + page_form + '.php',
		data:		formData,
		success:	function (data, textStatus, jqXHR) {
			$('.form_container').fadeOut();
			$('#submit').fadeOut();
			$('.form_feedback').html(jqXHR.responseText);
			$('.form_feedback').css({'background-color':'#b5d9a3', 'font-size':'14px'});
			$('.form_feedback').fadeIn('slow');
		},
		error:	function (jqXHR, textStatus, errorThrown) {
			var error_feedback	= errorThrown.split("|");
			var error_msg		= error_feedback[0];
			var error_field		= error_feedback[1];
			$('.form_feedback').html(error_msg);
			$('.required_field').removeClass('error');
			$(error_field).addClass('error').focus();
			$('.form_feedback').fadeIn('slow').delay(3500).fadeOut(2500);
			$('#submit').removeAttr('disabled');
		}
	});
};

