function sendMainContact(category,name,email,comments,captcha) {
	var ob='hsContactResult';
	setDivText(ob,'');

	var strV="";
	if (comments.length==0) strV+="The comments field cannot be blank.\n";
	if (captcha.length==0) strV+="The CAPTCHA field cannot be blank.\n";

	if (strV=="") {
		var path = rootpath + '/ajax/ajx_sendContact.php';
		var qstring='category=' + encodeURIComponent(category) + '&name=' + encodeURIComponent(name) + '&email=' + encodeURIComponent(email) + '&comments=' + encodeURIComponent(comments) + '&captcha=' + encodeURIComponent(captcha);
		ajaxQ.setLoadOb(ob,'<img src="images/wait.gif">','overwrite');
		ajaxQ.setResultsFunction('callfunction','contactMessageSent(ajaxResponseText,"'+ob+'");','json');
		ajaxQ.addRequest('post',path,qstring);
	}
	else {
		window.alert(strV);
	}
}

function contactMessageSent(json,obID) {
	var ob=getElem(obID);
	ob.innerHTML=json['msg'];
	if (json['status']=='success') {
		setTimeout("closeContactForm();",2000);
	}
}

$(document).ready (function() {
	$(function(){
		$("#mainContactBox").dialog({
			bgiframe: true, 
			autoOpen: false, 
			modal: true,
			closeOnEscape: true,
			resizable: false,
			title: 'Contact BeerMagnet.com via Email',
			width: '600'
		});
	});
});

function closeContactForm() {
	$('#mainContactBox').fadeOut("slow").dialog('close');
}

function openContactForm() {
	$('#mainContactBox').fadeIn("slow").dialog('open');
	setDiv('hsContactResult',null,null,'block');
	document.frmMainContact.name.focus();
}
