﻿function buildDiv(info) {
    var drvLink = drivingLink(homePoint, info.address + ' ' + info.city + ' ' + info.state + ' ' + info.zip);
    var gaStuff = 'pageTracker._trackPageview(\'/locationSearch/' + encodeURI(homeAddress) + '/' + getFilter() + '/info/drivingDirections/' + info.id + '\')';

    /*if (Browser.Engine.trident && (Browser.Engine.version < 5)) {
        var temp = info.image.split('.');
        temp.pop();
        info.image = temp.join('.') + '.gif';
    }*/
    
    var html = '<a href="#" class="icon"><img src="' + info.image + '"/></a>';
    html += '<a href="#" class="title">' + info.title + '</a><br />';
    html += info.address + '<br/>';
    if (info.city != null) {
        html += info.city + ', ';
    }
    if (info.state != null) {
        html += info.state + ' ';
    }
    if (info.zip != null) {
        html += info.zip;
    }
    html += '<br />';
    if ((info.phone != null) && (info.phone != '')) {
        html += '<span class="phone">' + info.phone + '</span><br />';
    }

    html += '<a href="javascript:void(window.open(\'' + drvLink + '\', \'Directions\', \'menubar=no,width=800,height=600,toolbar=no,titlebar=no,location=no,status=no,scrollbars=yes\'));void(' + gaStuff + ');" class="directions">Driving Directions</a>';

    if ((info.link != null) && (info.link != '')) {
        html += ' | <a href="'+info.link+'">Visit Store Site</a><br />';
    }
    
    var thisDiv = new Element('div', {
        'class':'location',
        'html':html
    });
    
    return thisDiv;
}
function buildInfo(info) {
    var drvLink = drivingLink(homePoint, info.address + ' ' + info.city + ' ' + info.state + ' ' + info.zip);
    var gaStuff = 'pageTracker._trackPageview(\'/locationSearch/' + encodeURI(homeAddress) + '/' + getFilter() + '/bubble/drivingDirections/' + info.id + '\')';
    var gaLink = 'pageTracker._trackPageview(\'/locationSearch/' + encodeURI(homeAddress) + '/' + getFilter() + '/bubble/storeWebsite/' + info.id + '\')';

    var html = '<h3>' + info.title + '</h3><br />';

    html += info.address + '<br/>';
    if (info.city != null) {
        html += info.city + ', ';
    }
    if (info.state != null) {
        html += info.state + ' ';
    }
    if (info.zip != null) {
        html += info.zip;
    }
    html += '<br />';
    
    if (info.phone && (info.phone != null) && (info.phone != '')) {
        html += '<span class="phone">' + info.phone + '</span><br />';
    }
    if (info.mon && (info.mon != null)) {
        if (!info.tues || (info.tues == null)) {
            info.tues = '';
        }
        if (!info.wed || (info.wed == null)) {
            info.wed = '';
        }
        if (!info.thur || (info.thur == null)) {
            info.thur = '';
        }
        if (!info.fri || (info.fri == null)) {
            info.fri = '';
        }
        if (!info.sat || (info.sat == null)) {
            info.sat = '';
        }
        if (!info.sun || (info.sun == null)) {
            info.sun = '';
        }
        html += '<table cellspacing="0" cellpadding="3" bgcolor="#eae9e7" width="100%" class="hours">';
        html += '<tr><th>Mon</th><th>Tues</th><th>Wed</th><th>Thur</th><th>Fri</th><th>Sat</th><th>Sun</th></tr>';
        html += '<tr>';
        html += '<td align="center">' + info.mon + '</td>';
        html += '<td align="center">' + info.tues + '</td>';
        html += '<td align="center">' + info.wed + '</td>';
        html += '<td align="center">' + info.thur + '</td>';
        html += '<td align="center">' + info.fri + '</td>';
        html += '<td align="center">' + info.sat + '</td>';
        html += '<td align="center">' + info.sun + '</td>';
        html += '</tr></table>';
    }

    html += '<a href="javascript:void(window.open(\'' + drvLink + '\', \'Directions\', \'menubar=no,width=800,height=600,toolbar=no,titlebar=no,location=no,status=no,scrollbars=yes\'));void(' + gaStuff + ');" class="directions">Driving Directions</a>';

    if (info.link && (info.link != null) && (info.link != '')) {
        html += ' | <a href="' + info.link + '" onclick="' + gaLink + '">Visit Store Website</a>';
    }
    
    var thisDiv = new Element('div', {
        'html':html
    });
    
    return thisDiv;
}