$(document).ready(function() {
	if (typeof renderYMap == "function") renderYMap();
	if (typeof resetHeight == "function") resetHeight();
	if (typeof formGalery == "function") formGalery();
	if (typeof renderPrivate == "function") renderPrivate();
	if (typeof renderDatePicker == "function") renderDatePicker();
	if (typeof renderAttachment == "function") renderAttachment();

	try {
		var count = parseInt($("input#SectionsCount").val());
		for (var i = 1; i <= count; i++) {
			var selects = document.getElementsByTagName("select");
			for (var j in selects) if (selects[j].id == "Section" + i) {
				var select = selects[j];
				populateBoardSubsections(select.options[select.selectedIndex].value, i);
				break;
			}
		}
	} catch (ex) { }

	try { new AjaxUpload("upload_photo1", {
			action: "/utils/upload_photo.php",
			name: "photofile",
			onSubmit: function(file, extension) {
				if (!(extension && /^(jpg|jpeg)$/i.test(extension))) {
					alert("Недопустимый тип файла");
					return false;
				}
				$("img#photopreview1").attr("src", "/images/44.gif");
				$("img#photopreview1").attr("height", "32");
				$("img#photopreview1").attr("width", "32");
				$("img#photopreview1").css("display", "inline");
				this.disable();
			},
			onComplete: function(file, response) {
				if (response == "error") {
					$("img#photopreview1").attr("src", "");
					$("img#photopreview1").css("display", "none");
					alert("Недопустимый тип файла");
					return false;
				}
				$("input#Photo1").val(response + ".jpg");
				$("img#photopreview1").attr("src", "");
				$("img#photopreview1").attr("height", "120");
				$("img#photopreview1").attr("width", "160");
				$("img#photopreview1").attr("src", "http://i.glac.ru/image/photo/" + response + ".jpg");
				$("img#photopreview1").css("display", "inline");
				$("div#upload_photo1").html("Обновить");
				$("a#delete_photo1").css("display", "inline");
				$("a#add_photo1").css("display", "inline");
				this.enable();
			}
		}
	); } catch (ex) { }
});
