document.write('<div style="z-index: 3000;" style="hidden" class="jqmWindow jqmID1" id="dialog"></div>');
document.write('<div style="z-index: 3000;" style="hidden" class="jqmWindowReg jqmID1" id="soapModal"></div>');

var regExpExt = /_[0-9]{1,4}x[0-9]{1,4}\.(jpg|php)$/;

$(document).ready(function () {
	$('#dialog').jqm();
	$('#soapModal').jqm();

	$(".registrationBtn").click(function() {
		ajaxGetUpdate("soapModal", "/regisztracio", false);
		return false;
	});

	$("#modificationBtn").click(function() {
		ajaxGetUpdate("soapModal", "/adatmodositas", false);
		return false;
	});
	
	$("#legalDeclarationBtn").click(function() {
		ajaxGetUpdate("soapModal", "/jogi-nyilatkozat", false);
		return false;
	});

	$("#sendNewPasswordBtn").click(function() {
		$("#dialog").html($("#sendNewPasswordModal").html());
		$("#dialog").jqmShow();

		$("#sendNewPasswordForm").submit(function () {
			ajaxPostUpdate (this.id, this.action + (this.action.indexOf("?") == -1 ? "?" : "&") + "ajax=true", "sendNewPasswordDiv", false);
			return false;
		});

		return false;
	});

	$("div#menucol li").each(function(i, li) {
		if (!$(this).hasClass("active")) {
				$("ul", this).css({'display': 'none'});
			}
	});
	$("a").each(function(i, a) {
		$(this).click(function(){
			this.blur(); // most browsers
			this.hideFocus = false; // ie
		});
	});

	$("div#menucol li.level1").each(function(i, li) {
		$("a:first", this).click(function(){

			/*$("div#menucol li.level1 ul").css({'display': 'none'});*/
			$(this).next().slideToggle("fast");
			this.blur(); // most browsers
			this.hideFocus = false; // ie
			this.style.outline = null; // mozilla
		});
	});

	$(".ajaxForm").submit(function () {
		ajaxPostUpdate (this.id, this.action + (this.action.indexOf("?") == -1 ? "?" : "&") + "ajax=true", "dialog", false);
		return false;
	});

	$(".delBtn").click(function() {
		if (confirm("Valóban törli a kijelölt tételt?\n A törlés nem visszavonható!")) {
			return true;
		} else {
			return false;
		}
		this.blur(); // most browsers
		this.hideFocus = false; // ie
		this.style.outline = null; // mozilla
	});

	$(".imageDiv img").click(function() {
		$("#galleryDialog").html("<table class='showpic'><tbody><tr><td colspan='2'><img src='" + this.src.replace(regExpExt, "_800x600.php") + "' alt='" + this.alt + "' onclick='$(\"#galleryDialog\").jqmHide(); return false;'/></td></tr><tr><td class='details'>" + this.alt + "</td><td class='close'><img src='/images/closelabel.gif' onclick='$(\"#galleryDialog\").jqmHide(); return false;'/></td></tr></tbody></table>");
		$("#galleryDialog").jqmShow();
		this.blur(); // most browsers
		this.hideFocus = false; // ie
		this.style.outline = null; // mozilla
	})
	validate();
});
function validate() {
	$('div.content #menucol').css({'overflow-x':'hidden'});
}
