﻿///<reference path="jquery-1.3.2-vsdoc2.js">
///<reference path="pagelister.js">
///<reference path="productsFilter.js">

function getProductShops(groupId, classId, vendorId) {

    Products.GetShops(groupId, classId, vendorId, function(data) { DrawShopsList(data); });

}


function DrawShopsList(data)
{
    var header =
    '<td nowrap class="tdhead">Название компании</td>' +
    '<td align="center" nowrap class="tdhead">Телефон</td>' +
    '<td align="center" nowrap class="tdhead">Сайт</td>' +
  '</tr>';

    var res = '<table id="slTab"  border="0" cellspacing="0" cellpadding="8" class="e4 content" width="530">';

    var currCity = '';

    var identity = 0;

    if (data.length == 0) {
        $("#shopsListContainer").html("Нет информации...");
    }
    else {
        $.each(data, function() {
            if (this.City != currCity) {
                identity++;
                res += '<tr><td colspan="3" class="rowcol"><img id="gimage' + identity + '" src="' + image_path + 'arrow01.gif" class="slImg">&nbsp;&nbsp;<a class="pointer" onclick="CollapseList(' + identity + ');">' + this.City + '</a></td></tr>';
                res += '<tr class="sl' + identity + ' slAll" style="display: none;">' + header;
                currCity = this.City;
            }

            res +=
              '<tr class="row1 sl' + identity + ' slAll" style="display: none;">' +
                '<td>' + ((this.CompanyName == null) ? "" : this.CompanyName) + '&nbsp</td>' +
                '<td>' + ((this.Phone == null) ? "" : this.Phone) + '&nbsp</td>' +
                '<td>' + ((this.WebSite == null) ? "" : '<a href="http://' + this.WebSite + '">' + this.WebSite + '</a>') + '&nbsp</td>' +
              '</tr>';
        });

        $("#shopsListContainer").html(res + '</table>');
    }
    
    SetshopsListTablePos();
    
    $("#shopsListTable").show();
}

function CollapseList(id) {
    if ($("#slTab .sl" + id +":first").css("display")=="none") {
        $("#slTab .slImg").attr("src", image_path + "arrow01.gif");
        $("#slTab #gimage" + id).attr("src", image_path + "arrow03.gif");
        $("#slTab .slAll").hide();
        $("#slTab .sl" + id).show();
    }
    else {
        $("#slTab .slAll").hide();
        $("#slTab .slImg").attr("src", image_path + "arrow01.gif");
    }
}