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

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

	
	$('.ajaxForm').submit(function () {
		var year = $("#birthdate-year").attr("value");
		var month = $("#birthdate-month").attr("value");
		var day = $("#birthdate-day").attr("value");
		$("#birthdate").attr("value", year+"-"+month+"-"+day);
		var birthdate = year+"-"+month+"-"+day;

		if (birthdate.indexOf("h") != -1) {
			$("#birthdate").attr("value", "");
		}
		
		var target = this.target == false ? "dialog" : this.target;
		ajaxPostUpdate (this.id, this.action + (this.action.indexOf("?") == -1 ? "?" : "&") + "ajax=true", target, true);
		
		return false;
	});

	$('.ajaxLink').click(function () {
		var target = this.rel == false ? "dialog" : this.rel;
		ajaxGetUpdate (target, this.href + (this.href.indexOf("?") == -1 ? "?" : "&") + "ajax=true", true);

		return false;
	});

	$('.delBtn').click(function () {
		return confirm($("#realyDelete").html()) ? true : false;
	});

	$(".ajaxDel").click(function() {
		if (confirm($("#realyDelete").html())) {
			var target = this.rel == false ? "dialog" : this.rel;
			ajaxGetUpdate (target, this.href + (this.href.indexOf("?") == -1 ? "?" : "&") + "ajax=true", true);
		}

		return false;
	});

	$("#postalcode").keyup(function() {
		var postalCodeValue = parseInt(this.value, 10);

		if (postalCodeValue == this.value && this.value.length == 4) {
			var myAjax = $.ajax({
				type: "GET",
				url: "/ajax?function=getSettlement&code=" + postalCodeValue,
				success: function(msg) {
					$("#city").attr("value", msg);
				}
			 });
		} else if (this.value.length == 0) {
			$("#city").attr("value", "");
		}
	});

	if ($('#country') != null) {
		ajaxGetUpdate ("country", "/ajax?function=getContries&ajax=true", false);
	}

	$(".thermsBtn").click(function() {
		ajaxGetUpdate ("dialog", "/ajax?function=getTherms&ajax=true", false);
		return false;
	});
	validate();
});
function validate() {
	//$('.rounded').css({'-moz-border-radius':'5px','-webkit-border-radius':'5px'});
	if (!jQuery.browser.msie) {
		$(".preview a.termekek").mouseover(function(e){
			$(this).css('opacity','.75');
		}).mouseout(function(){
			$(this).css('opacity','1');
		});
	}
}
