﻿//create the data object for passing data search data
//this allows us to pass the same object in all the time.
var searchdata = function(datatype, coords, title, summary, url, logouri, rating, startdate, enddate, telephonenumber,numoffers,numtestimonials) {

    this.datatype = datatype;
    this.title = title;
    this.summary = summary;
    this.url = url;
    this.featureurl = '';
    this.logouri = logouri;
    this.rating = rating;
    this.location = '';
    this.coords = coords;
    this.addtestimoniallink = url + '/review#write';
    this.startdate = startdate;
    this.enddate = enddate;
    this.telephonenumber = telephonenumber;
    this.numoffers  = numoffers;
    this.numtestimonials = numtestimonials
};
searchdata.prototype.display = function() {

    var output;
    
    switch (this.datatype) {
        case '1':
            //gets the data and displays presents it correctly.
            output = '<div style="width: 400px;">' +
            '<h2><a href="' + this.url + '">' + this.title + '</a></h2>' +
            '<p>' + this.summary + '</p>' +
            '<div class="extra">' +
            '<a href="' + this.url + '"><img class="map-logo" src="' + this.logouri + '" alt="' + this.title + '" /></a>' +
            '<div class="map-viewmore" id="Feature_Content_Summary">' +
            '<p><a class="tboaqua" href="' + this.url + '/offers" target="_blank" ><strong>Offers: </strong>' + this.numoffers + '</a><br />' +
            '<a class="tboaqua" href="' + this.url + '/review" target="_blank" ><strong>Testimonials: </strong>' + this.numtestimonials + '</a></p>' +
            '<p><a class="recommendlink tboaqua" href="' + this.addtestimoniallink + '" target="_blank" >Add a testimonial</a></p>' +
            '<p><span class="phone tboaqua" >' + this.telephonenumber + '</span></p>' +
            '<p><a class="website tboaqua" href="' + this.url + '" target="_blank" >Read more</a></p>' +
            this.displayrating() +
            '</div>' +
            '<div style="clear: both;"></div>' +
            '</div>' +
            '</div>';

            break;
        case '2':
            output = '<div style="width: 400px;">' +
            '<h2><a href="' + this.url + '">' + this.title + '</a></h2>' +
            '<p>' + this.summary + '</p>' +
            '<div class="extra">' +
            '<a href="' + this.url + '"><img class="map-logo" src="' + this.logouri + '" alt="' + this.title + '" /></a>' +
            '<div class="map-viewmore" id="Feature_Content_Summary">' +
            '<p><a class="website tboaqua" href="' + this.url + '" target="_blank" >Read more</a></p>' +
            '<p>Start Date: ' + this.startdate + '</p>' +
            '<p>End Date: ' + this.enddate + '</p>' +
            '</div>' +
            '<div style="clear: both;"></div>' +
            /*'</div>' +*/
            '</div>';

    }



    return output;



};
searchdata.prototype.displayrating = function() {

    var displayratingoutput = '<div style="clear: left;">';

    for (var ndx = 0; ndx < this.rating; ndx++) {
        displayratingoutput += '<img align="absMiddle" class="bubble" src="/_style/module/business-guide/i/company-profile/bubble.png" />';

    }

    displayratingoutput += '</div>';

    return displayratingoutput;

}
/*searchdata.prototype.abstract = function() { };
searchdata.prototype.startdata = function() { };
searchdata.prototype.enddate = function() { };
 */


function ShowContentType(cntrlid) {

    //alert(cntrlid);
    //document.getElementById(cntrlid).click();
    __doPostBack(cntrlid, '');

}

function PostBack(cntrlid) {

   // alert('hit');
    $('#ctl00_Content_CustomSearch1_updPleaseWait').css("display","block");   
    __doPostBack(cntrlid, '');
    //$('#ctl00_Content_CustomSearch1_updPleaseWait').css("display", "none");   
}

function DoPredictiveSearch(searchpatterncontainerid,band,place) {

    searchpatternelement = '#' + searchpatterncontainerid

    var curText = $(searchpatternelement).val();
    $.get("/_services/helper.ashx?function=predictivesearch&search=" + curText + "&container="+escape(searchpatternelement)+"&place="+place+"&band="+band, function(result) {
        //var oResultData = eval('(' + result + ')');
        //$(containerresultsid).addClass("containerselection");
        $("#predictivesearch").html(result.toString());
        
        
        
        
        
    });





}

function DoChooseKeyword(keyword,container) {
    
    if (keyword != null && container != null) {
        $(unescape(container)).val(unescape(keyword));
    
    }
    $("#predictivesearch").html("");
    
}
