﻿$(document).ready(function() {
    var y = $('#notifyForm').height() + 70;
    parent.$.colorbox.resize({width:"470px",height:y})
    
    $("#notifySend").live("click", function() {
        $("#notifyForm div").removeClass("warningHighlight");
        $("#warningMessageGN").hide();
        $.post('/services/notify.ashx',
            {
                txtFirstNameGN: $("#txtFirstNameGN").val(),
                txtLastNameGN: $("#txtLastNameGN").val(),
                txtCompanyGN: $("#txtCompanyGN").val(),
                txtZipGN: $("#txtZipGN").val(),
                txtEmailGN: $("#txtEmailGN").val()
            },
            function(response) {
                if (response == "")
                {
                    //$("#notifyForm").html('<h1 style="margin-top: 20px;">Thank You </h1><p>We\'ll let you know when Sunesys is available near you.</p><p>Call us at (888) 35-FIBER if you have any questions or would like more information about Sunesys.</p>');
                    //$.colorbox.resize();
                    var redirectUrl = "/forms/GetNotifiedThankYou.aspx?txtFirstNameGN=" + $("#txtFirstNameGN").val();
                    redirectUrl += "&txtLastNameGN=" + $("#txtLastNameGN").val();
                    redirectUrl += "&txtCompanyGN=" + $("#txtCompanyGN").val();
                    redirectUrl += "&txtZipGN=" + $("#txtZipGN").val();
                    redirectUrl += "&txtEmailGN=" + $("#txtEmailGN").val();
                    window.location = redirectUrl;
                }
                else
                {
                    var resArray = response.split("\r\n");
                    for (var x = 0; x < resArray.length; x++) {
                        var err = resArray[x];
                        if (err.length == 0) continue;
                        $("#" + err.split(":")[0]).parent().parent().addClass("warningHighlight");
                    }
                    $("#warningMessageGN").show();
                    //$.colorbox.resize();
                    var y = $('#notifyForm').height() + 70;
                    parent.$.colorbox.resize({width:"470px",height:y})
                }
            }
        );
    });
});
