﻿/// <reference path="scripts/jquery-1.2.3-intellisense.js" />

var page={
    init: function(){
        $('.leftnav').height($('#bd').height());

    }
}


var houseValue = {
    sendRequest : function()
    {
        var data = {};
        $("input:text").each(function(){
            var i = $(this)
            data[i.attr("id")] = i.val();
        });
        $.jmsajax({
              type: "POST",
              url: "WhatsMyHouseWorth.aspx",
              method: "RequestInfo",
              data: data,   
              success: function(message) {
                $('#response').html(message);
              }
        });
    
    }
}

var requestInfo = {
    id: undefined,
    div: undefined,
    divErrors: undefined,
    buyingGuideName: undefined,
    show : function(id, name){
        requestInfo.id = id;
        requestInfo.buyingGuideName.html(name);
            requestInfo.div.dialog({ 
                modal: true, 
                height: 300,
                title: 'Buying Guide Request',
                width: 450,
                overlay: { 
                    opacity: 0.5, 
                    background: "black" 
                } 
            }); 
    },
    validate : function()
    {
        $('#feedback').html('');
        var valid = true;
        if(valid)
            requestInfo.sendRequest();
    },
    sendRequest : function()
    {
        $.jmsajax({
              type: "POST",
              url: "HomeBuyingTips.aspx",
              method: "RequestInfo",
              data: { desc: $('#txtDescription').val(), buyingGuideId : requestInfo.id , name: $('#txtName').val(), email: $('#txtEmail').val(), phone: $('#txtPhone').val() },   
              success: function(message) {
                $('#feedback').html(message);
              }
        });
    
    },
    init: function(){
        requestInfo.div = $("#rInfo");
        requestInfo.buyingGuideName = $("#buyingGuideName");
    }
}

var requestInfo2 = {
    id: undefined,
    div: undefined,
    divErrors: undefined,
    show : function(id, name){
        requestInfo2.id = id;
        $("#buyingGuideName").html(name);
            requestInfo.div.dialog({ 
                modal: true, 
                height: 300,
                title: 'Selling Guide Request',
                width: 450,
                overlay: { 
                    opacity: 0.5, 
                    background: "black" 
                } 
            }); 
    },
    validate : function()
    {
        $('#feedback').html('');
        var valid = true;
        if(valid)
            requestInfo2.sendRequest();
    },
    sendRequest : function()
    {
        $.jmsajax({
              type: "POST",
              url: "HomeSellingTips.aspx",
              method: "RequestInfo",
              data: { desc: $('#txtDescription').val(), sellingGuideId : requestInfo2.id , name: $('#txtName').val(), email: $('#txtEmail').val(), phone: $('#txtPhone').val() },   
              success: function(message) {
                $('#feedback').html(message);
              }
        });
    
    }

}

$(document).ready(page.init);
$(document).ready(requestInfo.init);