
var tpl_container = '\
<table class="ctbl">\
	<tr>\
		<td class="msgbox_tl"><div class="msgbox_tl"></div></td>\
		<td class="msgbox_tc"><div class="msgbox_tc"></div></td>\
		<td class="msgbox_tr"><div class="msgbox_tr"></div></td>\
	</tr>\
	<tr>\
		<td class="msgbox_ml"></td>\
		<td class="msgbox_mc">DATA</td>\
		<td class="msgbox_mr"></td>\
	</tr>\
	<tr>\
		<td class="msgbox_bl"><div class="msgbox_bl"></div></td>\
		<td class="msgbox_bc"><div class="msgbox_bc"></div></td>\
		<td class="msgbox_br"><div class="msgbox_br"></div></td>\
	</tr>\
</table>\
';

var tpl_question = '\
<form name="frm_question" method="post" action="">\
	<p>\
		Email:\
		<br/><input type="text" name="email" value="" class="msgbox_text" />\
		<br/>\
		<br/>Subject:\
		<br/><input type="text" name="subject" value="" class="msgbox_text" />\
		<br/>\
		<br/>Message:\
		<br/><textarea name="msg" class="msgbox_text" rows="5"></textarea>\
		<br/>\
	</p>\
	<p style="text-align:right;">\
		<input type="button" class="button" name="close" value="Close" onclick="ask_a_question_close()" />\
		&nbsp; &nbsp; <input type="button" class="button" name="send" value="Send" onclick="ask_a_question_send()" />\
	</p>\
</form>\
';

var dfrm_question = null;

function ask_a_question(msg) {
	if (dfrm_question == null) {
		dfrm_question = document.createElement("div");
		$(dfrm_question).html(tpl_container.replace(/DATA/, tpl_question)).css({position: "absolute"});
		$("body").append(dfrm_question);
	}
	else {
		document.forms.frm_question.email.value = "";
		document.forms.frm_question.subject.value = "";
		document.forms.frm_question.msg.value = "";
	}
	
	var x = Math.round(($(window).width() - $(dfrm_question).width()) / 2);
	$(dfrm_question).css({opacity: 0, left: x, top: 100}).animate({opacity: 1, left: x - 20, top: 80});
}

function ask_a_question_close() {
	$(dfrm_question).animate({opacity: 0, left: $(dfrm_question).offset().left + 20, top: 100});
}

function ask_a_question_send() {
	$.ajax({
		url: document.u0 + "/ajax_cmd.php",
		type: "post",
		data: {
			cmd: "contact_form",
			url: location.href,
			email: document.forms.frm_question.email.value,
			subject: document.forms.frm_question.subject.value,
			msg: document.forms.frm_question.msg.value,
			fhk: document.fhk
		}
	});

	ask_a_question_close();
}

