﻿var homeList = new Array();

function homeListItem(id, name, imgSrc, lat, lng, price, href, city, address, zipcode) {
    this.id = id;
    this.name = name;
    this.imgSrc = imgSrc;
    this.lat = parseToFloat(lat);
    this.lng = parseToFloat(lng);
    this.price = price;
    this.href = href;
    this.city = city;
    this.address = address;
    this.zipcode = zipcode;
    this.marker = null;
}

function getHomeListItemById(homeId) {
    for (var i in homeList) {
        if (homeList[i].id == homeId)
            return homeList[i];
    }
}

function addHomeList(id, name, imageUrl, lat, lng, price, href, city, address, zipcode) {
    price = parseToFloat(price);
    homeList.push(new homeListItem(id, name, imageUrl, lat, lng, price, href, city, address, zipcode));
}

function parseToFloat(val) {
    if (isNaN(parseFloat(val)))
        val = 0;
    else
        val = parseFloat(val);
    return val;
}