jQuery(function ($) {
	$('.makeof a').click(function (e) {
		$('.makeofdialog').modal({overlayClose:true});

		return false;
	});
	$('.contact a').click(function (e) {
		$('.contactdialog').modal({overlayClose:true});

		return false;
	});
	$('#sendContact').ajaxForm({
        url: '/ajax/sendContact.php',
        dataType: 'json',
        cache: false,
        type: 'post',
        beforeSubmit: function () {
            $("#sendContact").hide();
            $("#waitContact").show();
        },
        success: function (data) {
            if (data.status == "ERROR") {
                alert(data.dataError);
                $("#waitContact").hide();
                $("#sendContact").show();
            } else if (data.status == "OK") {
				alert(data.message);
				$.modal.close();
            }
        }
    });
	$('#sendOffer').ajaxForm({
        url: '/ajax/sendOffer.php',
        dataType: 'json',
        cache: false,
        type: 'post',
        beforeSubmit: function () {
            $("#sendOffer").hide();
            $("#waitOffer").show();
        },
        success: function (data) {
            if (data.status == "ERROR") {
                alert(data.dataError);
                $("#waitOffer").hide();
                $("#sendOffer").show();
            } else if (data.status == "OK") {
				alert(data.message);
				$.modal.close();
            }
        }
    });
	var windowHeight = $(document).height();
	var windowWidth = $(document).width();
	$('body').attr('style','background:url("pictures.php?p='+pictureKey+'&h='+windowHeight+'&w='+windowWidth+'") no-repeat scroll center top #FFFFFF;');
	$(window).bind("resize", function () {
		var windowHeight = $(document).height();
		var windowWidth = $(document).width();
		$('body').attr('style','background:url("pictures.php?p='+pictureKey+'&h='+windowHeight+'&w='+windowWidth+'") no-repeat scroll center top #FFFFFF;');
	});
});
