// --------------------------------------------------------------------------
// Playbill operations for artists' sites
// Copyright (c) 2007 by Yury Ermolaev
// (Requires library comlib.js)
// --------------------------------------------------------------------------

function PlaybillRecord(hall_id, style_num, c_date, c_tyme, titul, 
                        programme, aux, img, flag, pop_text)
{
  this.HallID = hall_id;
  this.Style = style_num;
  this.CDate = c_date;
  this.CTime = c_tyme;
  this.Titul = titul;
  this.Programme = programme;
  this.Aux = aux;
  this.Img = img;
  this.Flag = flag;
  this.PopText = pop_text;
}

// --------------------------------------------------------------------------
function HallRecord(ID, name, city, address, logo)
{
  this.ID = ID;
  this.Name = name;
  this.City = city;
  this.Address = address;
  this.Logo = logo;
}

// --------------------------------------------------------------------------
function ShowPlaybill(parr, default_img)
{   
///alert("ShowPlaybill()");
}

// --------------------------------------------------------------------------
function ConcertList(parr, style_num, first, last, num)
{
///alert("ConcertList() - 1");

  cur_date = new Date();                    // Current date
  date1 = CreateDate(first);
  date2 = CreateDate(last);
  m = cur_date.getTime();
  m1 = date1.getTime();
  m2 = date2.getTime();

  max_num = num;
  if (num < 0) max_num = -num;
  n = 0;

  for (i=0; i < parr.length; i++)
  {
    cdate = CreateDate(parr[i].CDate);      // Date of the i-th concert
    cdate.setHours(19);                     // Look after 19:00 (beginning of the concert)
    mc = cdate.getTime();
    s = style_num;

    if (first != "" && mc < m1) continue;   // Earlier then first
    if (last  != "" && mc > m2) continue;   // Later then last

    if (mc < m)                             // The concert date is past:
    {  
       if (num <= 0 || max_num == 0)
         s = style_num + 1;                 // Show the concert, but using the next style
       else
         continue;                          // Miss the concert
    }

    full_date = FullDate(cdate);
    WriteRecord(s, full_date, parr[i].CTime, parr[i].Titul, 
                parr[i].Programme, parr[i].Aux, parr[i].HallID);
    n++;
    if (max_num != 0 && n == max_num) return;
  }  
}










