﻿function chamaModal(idBox) {
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

    $('#mask').css({ 'width': maskWidth, 'height': maskHeight });
    $('#mask').fadeIn(1000);
    $('#mask').fadeTo("slow", 0.8);

    var winH = $(window).height();
    var winW = $(window).width();
    var id = idBox;

    $(id).css('top', winH / 2 - $(id).height() / 2);
    $(id).css('left', (winW / 2 - $(id).width() / 2));
    $(id).fadeIn(2000);
}

function closeBox() {
    $(".boxmodal").hide();
    $("#mask").hide();
    return false;
}

$(document).ready(function() {
    $("#btNews").click(function() {
        var email = $("#txtNews").val();
        $.post("code/newsletter.ashx", { email: email }, function(response) {
            $("#boxMsgNews span p").html(response);
            chamaModal("#boxMsgNews");
        });
        $("#txtNews").val("");
        return false;
    });

    $("#txtNews").focus(function() { $("#txtNews").val(""); });

    $("#btMap").click(function() {
        $("#boxMap").html("<iframe width='650' height='450' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.com.br/maps?f=q&amp;source=s_q&amp;hl=pt-BR&amp;geocode=&amp;q=casa+forte+im%C3%B3veis&amp;ie=UTF8&amp;hq=casa+forte+im%C3%B3veis&amp;hnear=Belo+Horizonte+-+MG&amp;radius=15000&amp;ll=-19.807045,-43.168759&amp;spn=0.018169,0.027852&amp;z=15&amp;iwloc=D&amp;output=embed'></iframe><br /><small><a href='http://maps.google.com.br/maps?f=q&amp;source=embed&amp;hl=pt-BR&amp;geocode=&amp;q=casa+forte+im%C3%B3veis&amp;ie=UTF8&amp;hq=casa+forte+im%C3%B3veis&amp;hnear=Belo+Horizonte+-+MG&amp;radius=15000&amp;ll=-19.807045,-43.168759&amp;spn=0.018169,0.027852&amp;z=15&amp;iwloc=D' style='color:#0000FF;text-align:left'>Exibir mapa ampliado</a></small><div class='options'><a href='#' onClick='closeBox();'>Fechar janela com mapa</a></div>");
        chamaModal("#boxMap");
        return false;
    });

    $(".btClose").click(function() {
        $(".boxmodal").hide();
        $("#mask").hide();
        return false;
    });

    $("#btEnquete").click(function() {
        $("#frameEnquete").attr("src", "code/enquete.aspx");
        chamaModal("#boxEnqueteModal");
        //return false;
    });
});
