function people() {
	$('#people').load("/scripts/people/?num=20&rnd=1");
}

dialog_html = '<form id=add onSubmit="return false"><p>Ваше имя:<input type=text name=fio class=t><p>Организация:<input type=text name=organization class=t><p>Должность:<input type=text name=position class=t><p>Текст поздравления:<textarea name=compliment rows=8 class=t></textarea><p><input id=form_submit type=button value="Отправить"></form>';

$(function(){
	$('body').append('<div id=dialog><div class=overwin><div class="cn tl"></div><div class="cn tr"></div><a class=close href="javascript:void(0)"></a><table class=content><tr><td class="l png"></td><td class=m></td><td class="r png"></td></tr></table><div class="cn bl"></div> <div class="cn br"></div></div></div>');
	$("#form_submit").live("click", function () {
		var e, o = $("#add")[0], f=o.fio.value, r=o.organization.value, p=o.position.value, c=o.compliment.value;
		if (!f) {e='Поле Ваше имя должно быть корректно заполнено'}
		if (!r) {e='Поле Организация должно быть корректно заполнено'}
		if (!p) {e='Поле Должность должно быть корректно заполнено'}
		if (!c) {e='Поле Поздравление должно быть корректно заполнено'}
		if (e) {
			alert(e);
		} else {
			$("#dialog td.m").html('<img src="/i/p.gif"');
			center();
			$("#dialog td.m").load("/scripts/compliments/", { fio: f, organization: r, position: p, compliment: c }, center);
		}
	});
	$(".close").live("click", function() {
		$('#dialog').expose().close();
	});
	$("#form_close").live("click", function() {
		$('#dialog').expose().close();
	});
});

function center() {
	var d=Math.floor(($(window).height()-$('#dialog').height())/2);
	$('#dialog').css({top: $(window).scrollTop()+(d>0?d:0), display: 'block'});
}

function expose() {
	$("#dialog").expose({
		onBeforeLoad: function () {
			$("#dialog td.m").html(dialog_html);
			center();
		},
		onBeforeClose: function () {
			$("#dialog").css({display: 'none'});
		},
		color: '#333',
		opacity: 0.5,
		loadSpeed: 'fast',
		closeSpeed: 'fast',
		api: true
	}).load();
	return false;
}
