/*

Template Library

*/

AtexDNA.templates = {
    SearchResultRow: new Ext.XTemplate( // FIXME
    '<tpl for=".">',
    '<div id="r_{id}" class="search-result-row span-44 append-1 {exact:this.ShowFuzzy}">',
    '<div class="span-2 prepend-1 search-result-num">{num}</div>',
    '<div class="span-11 search-result-img">',
    '<a href="/demo/{category_slug}/{id}">',
    '<img src="{id:this.GetPropertyThumbnail}" alt="{title}" width="110" height="84" /></a>',
    '</div>',
    '<div class="span-20 prepend-1 append-1"><a href="/demo/{category_slug}/{id}">{title}</a><b class="type">{housing_sale_type:this.HousingSaleType}</b></div>',
    '<div class="span-6"><b class="price">{price:this.FormatCurrency}</b></div>',
    '<div class="item-description span-20 prepend-1 append-1"><p>{description:this.Truncate}</p></div>',
    '<div class="span-6 last"><b>{housing_bedrooms}br / {housing_bathrooms}ba</b></div>',
    '</div>',
    '</tpl>'
    ),
    init: function() {
        AtexDNA.templates.SearchResultRow.FormatCurrency = AtexDNA.util.FormatCurrency;
        AtexDNA.templates.SearchResultRow.GetPropertyThumbnail = AtexDNA.util.GetPropertyThumbnail;
        AtexDNA.templates.SearchResultRow.Truncate = AtexDNA.util.TruncateHighlighting;
        AtexDNA.templates.SearchResultRow.HousingSaleType = function (id) {
            var map = [
                'Residential',
                'Mobile Home',	
                'Single-Family House',
                'Multi-Family',
                'Other',
                'Condo / Townhouse / Apartment',
                'Commercial',
                'Office Space',
                'Farms / Ranch',
                'Land',
                'Vacation Property'
            ];
            return map[id];
        }
        AtexDNA.templates.SearchResultRow.ShowFuzzy = function(match) {
            return match ? '': 'fuzzy';
        }

        YAHOO.log("INIT", "info", ".templates");
    }
};
