File size: 9,925 Bytes
e9a2e31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312

// Global Functions for DreamKey Estates

// Property Data (Mock API)
const properties = [
    {
        id: 1,
        title: "Modern Lakeside Villa",
        location: "234 Lakeview Dr, Seattle, WA",
        price: 875000,
        bedrooms: 4,
        bathrooms: 3,
        sqft: 3200,
        image: "http://static.photos/real-estate/640x360/101",
        virtualTour: true,
        featured: true
    },
    {
        id: 2,
        title: "Downtown Penthouse",
        location: "501 Skyline Ave, New York, NY",
        price: 2450000,
        bedrooms: 3,
        bathrooms: 3.5,
        sqft: 2800,
        image: "http://static.photos/real-estate/640x360/102",
        virtualTour: true,
        featured: true
    },
    {
        id: 3,
        title: "Suburban Family Home",
        location: "789 Maple St, Austin, TX",
        price: 625000,
        bedrooms: 5,
        bathrooms: 4,
        sqft: 3800,
        image: "http://static.photos/real-estate/640x360/103",
        virtualTour: false,
        featured: true
    },
    {
        id: 4,
        title: "Mountain Retreat Cabin",
        location: "123 Alpine Way, Denver, CO",
        price: 425000,
        bedrooms: 3,
        bathrooms: 2,
        sqft: 1800,
        image: "http://static.photos/real-estate/640x360/104",
        virtualTour: true,
        featured: true
    },
    {
        id: 5,
        title: "Urban Loft Studio",
        location: "456 Art District, Chicago, IL",
        price: 350000,
        bedrooms: 1,
        bathrooms: 1,
        sqft: 1200,
        image: "http://static.photos/real-estate/640x360/105",
        virtualTour: false,
        featured: true
    },
    {
        id: 6,
        title: "Beachfront Condo",
        location: "789 Ocean Blvd, Miami, FL",
        price: 950000,
        bedrooms: 2,
        bathrooms: 2,
        sqft: 1600,
        image: "http://static.photos/real-estate/640x360/106",
        virtualTour: true,
        featured: true
    }
];
// Agent Data
const agents = [
    {
        id: 1,
        name: "Sarah Chen",
        title: "Senior Real Estate Specialist",
        experience: "12 years",
        specialties: ["Luxury Homes", "Investment Properties"],
        image: "http://static.photos/people/200x200/201",
        phone: "(555) 123-4567",
        email: "sarah@dreamkeyestates.com"
    },
    {
        id: 2,
        name: "Marcus Johnson",
        title: "Commercial Property Expert",
        experience: "8 years",
        specialties: ["Commercial", "Development"],
        image: "http://static.photos/people/200x200/202",
        phone: "(555) 234-5678",
        email: "marcus@dreamkeyestates.com"
    },
    {
        id: 3,
        name: "Elena Rodriguez",
        title: "First-Time Homebuyer Advisor",
        experience: "6 years",
        specialties: ["First-Time Buyers", "Condos"],
        image: "http://static.photos/people/200x200/203",
        phone: "(555) 345-6789",
        email: "elena@dreamkeyestates.com"
    }
];
// Neighborhood Data
const neighborhoods = [
    {
        id: 1,
        name: "Westside Heights",
        city: "Los Angeles, CA",
        rating: 4.8,
        highlights: ["Top Schools", "Parks", "Low Crime"],
        image: "http://static.photos/cityscape/320x240/301"
    },
    {
        id: 2,
        name: "Riverfront District",
        city: "Portland, OR",
        rating: 4.6,
        highlights: ["Walkable", "Art Scene", "Restaurants"],
        image: "http://static.photos/cityscape/320x240/302"
    },
    {
        id: 3,
        name: "Historic Old Town",
        city: "Charleston, SC",
        rating: 4.9,
        highlights: ["Historic", "Community", "Waterfront"],
        image: "http://static.photos/cityscape/320x240/303"
    }
];
// Load Featured Listings
function loadFeaturedListings() {
    const container = document.getElementById('featuredListings');
    if (!container) return;
    
    container.innerHTML = '';
    
    const featured = properties.filter(p => p.featured).slice(0, 3);
    
    featured.forEach(property => {
        const card = document.createElement('property-card');
        card.setAttribute('data-property', JSON.stringify(property));
        card.classList.add('fade-in');
        container.appendChild(card);
    });
}

// Load Agent Profiles
function loadAgentProfiles() {
    const container = document.getElementById('agentProfiles');
    if (!container) return;
    
    container.innerHTML = '';
    
    agents.forEach(agent => {
        const card = document.createElement('agent-card');
        card.setAttribute('data-agent', JSON.stringify(agent));
        card.classList.add('fade-in');
        container.appendChild(card);
    });
}

// Load Neighborhood Guides
function loadNeighborhoodGuides() {
    const container = document.getElementById('neighborhoodGuides');
    if (!container) return;
    
    container.innerHTML = '';
    
    neighborhoods.forEach(neighborhood => {
        const card = document.createElement('neighborhood-card');
        card.setAttribute('data-neighborhood', JSON.stringify(neighborhood));
        card.classList.add('fade-in');
        container.appendChild(card);
    });
}

// Initialize Mortgage Calculator
function initMortgageCalculator() {
    const priceSlider = document.getElementById('priceSlider');
    const downSlider = document.getElementById('downSlider');
    const rateSlider = document.getElementById('rateSlider');
    const termButtons = document.querySelectorAll('.term-btn');
    const priceValue = document.getElementById('priceValue');
    const downValue = document.getElementById('downValue');
    const rateValue = document.getElementById('rateValue');
    const monthlyPayment = document.getElementById('monthlyPayment');
    const totalLoan = document.getElementById('totalLoan');
    const totalDown = document.getElementById('totalDown');
    
    if (!priceSlider) return;
    
    let termYears = 15;
    
    // Update display values
    function updateDisplay() {
        const price = parseInt(priceSlider.value);
        const downPercent = parseInt(downSlider.value);
        const rate = parseFloat(rateSlider.value);
        
        const downAmount = price * (downPercent / 100);
        const loanAmount = price - downAmount;
        const monthlyRate = rate / 100 / 12;
        const payments = termYears * 12;
        
        // Calculate monthly payment
        let monthly;
        if (monthlyRate === 0) {
            monthly = loanAmount / payments;
        } else {
            monthly = loanAmount * monthlyRate * Math.pow(1 + monthlyRate, payments) / 
                     (Math.pow(1 + monthlyRate, payments) - 1);
        }
        
        // Update display
        priceValue.textContent = `$${price.toLocaleString()}`;
        downValue.textContent = `${downPercent}%`;
        rateValue.textContent = `${rate}%`;
        monthlyPayment.textContent = `$${monthly.toFixed(0)}`;
        totalLoan.textContent = `$${loanAmount.toLocaleString()}`;
        totalDown.textContent = `$${downAmount.toLocaleString()}`;
    }
    
    // Event Listeners
    priceSlider.addEventListener('input', updateDisplay);
    downSlider.addEventListener('input', updateDisplay);
    rateSlider.addEventListener('input', updateDisplay);
    
    termButtons.forEach(button => {
        button.addEventListener('click', function() {
            termButtons.forEach(btn => btn.classList.remove('active'));
            this.classList.add('active');
            termYears = parseInt(this.textContent);
            updateDisplay();
        });
    });
    
    // Initial calculation
    updateDisplay();
}

// Initialize Contact Form
function initContactForm() {
    const form = document.getElementById('contactForm');
    if (!form) return;
    
    form.addEventListener('submit', function(e) {
        e.preventDefault();
        
        // Get form data
        const formData = new FormData(form);
        const data = Object.fromEntries(formData);
        
        // In a real app, you would send this to a server
        console.log('Form submitted:', data);
        
        // Show success message
        alert('Thank you for your message! We\'ll get back to you within 24 hours.');
        form.reset();
        
        // Reset consent checkbox
        const consent = document.getElementById('consent');
        if (consent) consent.checked = false;
    });
}

// Initialize Search Functionality
function initSearch() {
    const searchBtn = document.getElementById('searchBtn');
    if (!searchBtn) return;
    
    searchBtn.addEventListener('click', function() {
        // Get filter values
        const location = document.querySelector('input[placeholder*="City"]').value;
        const minPrice = document.querySelector('input[placeholder="Min"]').value;
        const maxPrice = document.querySelector('input[placeholder="Max"]').value;
        const bedrooms = document.querySelector('select').value;
        
        // In a real app, this would filter properties and update display
        console.log('Search filters:', { location, minPrice, maxPrice, bedrooms });
        
        alert('Search functionality would filter properties here. In a real application, this would connect to a backend API.');
    });
}

// Initialize on page load
document.addEventListener('DOMContentLoaded', function() {
    initSearch();
    
    // Add loading animation to buttons
    const buttons = document.querySelectorAll('button, a[href]');
    buttons.forEach(button => {
        button.addEventListener('click', function(e) {
            if (this.tagName === 'A' && this.getAttribute('href').startsWith('#')) {
                return; // Don't animate anchor links
            }
            
            this.classList.add('opacity-75');
            setTimeout(() => {
                this.classList.remove('opacity-75');
            }, 300);
        });
    });
});