﻿var CommID = ''

function SetColumnTwoContent(CityID, CommunityID) {
    CommID = CommunityID
    sUrl = '/Scripts/JSON/CityDataForListView.aspx?Type=OnlyData&City=' + CityID;
    var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, CommunityCallback);
}

var CommunityHandleSuccess = function(o) {
    if (o.responseText !== undefined) {
        var jsonObj = YAHOO.lang.JSON.parse(o.responseText);
        for (i = 0; i < jsonObj.length; i++) {
            if (jsonObj[i].CommunityID == CommID) {
                setContent(jsonObj[i]);
            }
        }

    }
}

function setContent(ds){
        var ndeImg = YAHOO.util.Selector.query('img', 'FormHighlight', true);
        var ndeConent = YAHOO.util.Selector.query('div', 'FormHighlight', true);
        
        var markup = '';

        ndeImg.src = ds.ImgURL
        ndeImg.alt = ds.PhotoTitle
        ndeImg.height = ds.PhotoHeight
        ndeImg.width = ds.PhotoWidth
        markup += "<h2>" + ds.CommunityName + "</h2>"

        var LowSqFt = ds.LowSquareFeet
        var HighSqFt = ds.HighSquareFeet
        var LowPrRange = ds.LowPriceRange
        var SquareFeet = "";
        SquareFeet = GetSQFTMarkup(LowSqFt, HighSqFt)

        var PriceRange = parsePriceRange(LowPrRange)

        markup += "<p>Price: " + PriceRange + "</p>"
        markup += SquareFeet       

        ndeConent.innerHTML = markup;
    
}

var CommunityHandleFailure = function(o) {
    if (o.responseText !== undefined) {

    }
}

var CommunityCallback =
{
    success: CommunityHandleSuccess,
    failure: CommunityHandleFailure,
    cache: false
};
