var tr=0;
function	genEpisode(nr, title, trailer, info)
{
  ext = browser=='MSIE' ? 'gif':'png';
  info = info.split(',');
  smsiframe = "<iframe src='http://www.polisz-kicz.pl/members/?ref=pawel71&c:ffffff;b:000000;&F' width=200 height=60 scrollbars=no frameborder=0></iframe>";
  smsprompt = "<span style='font-weight:bold;color:yellow;font-size:12px;padding:4px;'>!!! MEGA PROMOCJA !!!</span><br><b>50 filmów do ściągnięcia</b> za <b>1 SMS</b><br>Wyślij SMS o treści <span style='font-weight:bold;color:yellow;font-size:12px;'>DM</span> pod numer <span style='font-weight:bold;color:yellow;font-size:12px;'>91985</span>.<div onclick='this.innerHTML=smsiframe;' id=sms_"+nr+">Otrzymany kod wpisz <span style='cursor:pointer;text-decoration:underline;'>TUTAJ</span></div>";
  trpath = tr<40 ? dpath+"trailers/"+nr+"/polisz-kicz--"+trailer : 'http://www.poliszkicz.net/members.html';
  var o  = "";

  if(parseInt(nr.substr(1)) >= 27)
  {
    o += "<table><tr><td colspan=3><table width=100% bgcolor=black><tr><td align=center><font style='font-family:impact;color:#ffccff;font-size:32px;'>"+title+"</font><br>"+smsprompt+"</td></tr></table></td></tr>";
    o += "<tr><td colspan=3><img src='"+dpath+"epizod/"+nr+"/big.jpg' width=640 height=360 class=brd style='cursor:pointer;' onclick=\"episode('"+nr+"');\"></td></tr>";
    o += "<tr>";
     o += "<td><img src='"+dpath+"epizod/"+nr+"/thumb_01.jpg' width=208 height=117 class=brd style='cursor:pointer;' onclick=\"episode('"+nr+"');\"></td>";
     o += "<td align=center><img src='"+dpath+"epizod/"+nr+"/thumb_02.jpg' width=208 height=117 class=brd style='cursor:pointer;' onclick=\"episode('"+nr+"');\"></td>";
     o += "<td align=right><img src='"+dpath+"epizod/"+nr+"/thumb_03.jpg' width=208 height=117 class=brd style='cursor:pointer;' onclick=\"episode('"+nr+"');\"></td>";
    o += "</tr>";
    o += "<tr><td colspan=3><table width=100% bgcolor=black cellpadding=8><tr align=center><td width=33%>Czas trwania : <span style='font-weight:bold;color:yellow;'>"+info[0]+"</span></td><td width=33%>Film DivX : <span style='font-weight:bold;color:yellow;'>"+info[2]+" MB</span></td><td width=33%>Fotek : <span style='font-weight:bold;color:yellow;'>"+info[4]+"</span></td></tr></table></td></tr>";
    o += "<tr><td colspan=3><table width=100% cellspacing=0 cellpadding=0><tr align=center><td width=50%><a href='"+trpath+"'><img src='"+dpath+"images/trailer."+ext+"' width=167 height=32 border=0></a></td>";
    o += "<td width=50%><img src='"+dpath+"images/movie."+ext+"' width=167 height=32 style='cursor:pointer;' onclick=\"episode('"+nr+"');\"></td>";
    o += "</tr></table></td></tr>";
    o += "</table><br><br><br><br>";
  }
  else
  {
    o += "<table><tr><td colspan=2><table width=100% bgcolor=black><tr><td align=center><font style='font-family:impact;color:#ffccff;font-size:32px;'>"+title+"</font><br>"+smsprompt+"</td></tr></table></td></tr>";
    o += "<tr><td rowspan=3><img src='"+dpath+"epizod/"+nr+"/big.jpg' width=417 height=313 class=brd style='cursor:pointer;' onclick=\"episode('"+nr+"');\"></td>";
    o += "<td><img src='"+dpath+"epizod/"+nr+"/thumb_01.jpg' width=132 height=99 class=brd style='cursor:pointer;' onclick=\"episode('"+nr+"');\"></td></tr>";
    o += "<tr><td><img src='"+dpath+"epizod/"+nr+"/thumb_02.jpg' width=132 height=99 class=brd style='cursor:pointer;' onclick=\"episode('"+nr+"');\"></td></tr>";
    o += "<tr><td><img src='"+dpath+"epizod/"+nr+"/thumb_03.jpg' width=132 height=99 class=brd style='cursor:pointer;' onclick=\"episode('"+nr+"');\"></td></tr>";
    o += "<tr><td colspan=2><table width=100% bgcolor=black><tr align=center><td>Czas trwania : <span style='font-weight:bold;color:yellow;'>"+info[0]+"</span></td><td>Film DivX : <span style='font-weight:bold;color:yellow;'>"+info[2]+" MB</span></td><td>Film WMV : <span style='font-weight:bold;color:yellow;'>"+info[3]+" MB</span></td><td>Fotek : <span style='font-weight:bold;color:yellow;'>"+info[4]+"</span></td><td width=132 style='font-weight:normal;color:red;'>"+info[5]+"</td></tr></table></td></tr>";
    o += "<tr><td colspan=2><table width=100% cellspacing=0 cellpadding=0><tr align=center><td width=50%><a href='"+trpath+"'><img src='"+dpath+"images/trailer."+ext+"' width=167 height=32 border=0></a></td>";
    o += "<td width=50%><img src='"+dpath+"images/movie."+ext+"' width=167 height=32 style='cursor:pointer;' onclick=\"episode('"+nr+"');\"></td>";
    o += "</tr></table></td></tr>";
    o += "</table><br><br><br><br>";
  }

  tr++;
  return o;
}
function	exEpisode(ti)
{
  used[ti]=1;
  iout = document.getElementById('erest');
  iout.innerHTML += genEpisode(ids[ti], titles[ids[ti]], trailers[ids[ti]], infos[ids[ti]]);
  iout = document.getElementById('eindex');
  iout.innerHTML = genIndex();
}
function	genIndex()
{
  o  = "";
  o += "<table><tr>"; l=0;
  for(i=0; i<ids.length; i++)
  {
    if(used[i]==undefined && parseInt(ids[i].substr(1))>=27)
    {
      o += "<td><img src='"+dpath+"epizod/"+ids[i]+"/thumb_00.jpg' width=208 height=117 class=brd onClick='exEpisode("+i+");' style='cursor:pointer;' alt=\""+titles[ids[i]]+"\"></td>";
      if((l%3)==2) o+="</tr><tr>";
      l++;
    }
  }
  o += "</tr></table><br>";
  if(l) o = "<table width=644 bgcolor=black><tr><td align=center><font style='font-family:impact;color:#ffccff;font-size:32px;'>ARCHIWUM HDV</font></td></tr></table>"+o;
  var oo = "<table><tr>"; l=0;
  for(i=0; i<ids.length; i++)
  {
    if(used[i]==undefined && parseInt(ids[i].substr(1))<27)
    {
      oo += "<td><img src='"+dpath+"epizod/"+ids[i]+"/thumb_00.jpg' width=132 height=99 class=brd onClick='exEpisode("+i+");' style='cursor:pointer;' alt=\""+titles[ids[i]]+"\"></td>";
      if((l%5)==4) oo+="</tr><tr>";
      l++;
    }
  }
  oo += "</tr></table>";
  if(l) oo = "<table width=696 bgcolor=black><tr><td align=center><font style='font-family:impact;color:#ffccff;font-size:32px;'>ARCHIWUM DV</font></td></tr></table>"+oo;

  return o+oo;
}
function	episode(nr)
{
  location.href='http://www.poliszkicz.net/members.html';
/*
  if(le!=null) {le.innerHTML = ''; le.bgColor='#c01b93';}
  po = document.getElementById('po_'+nr);
  po.innerHTML = tsh(payopt(nr));
  po.bgColor = '#980B71';
  le = po;
  location.href='#epizod_'+nr;
*/
}
function	tsh(inner)
{
  return "<table cellspacing=0 cellpadding=0><tr height=5><td width=5><img src='images/table_tl.gif' width=10 height=5></td><td background='images/table_bg_t.gif' width=99%><img src='images/table_bg_t.gif' width=1 height=5></td><td width=5><img src='images/table_tr.gif' width=10 height=5></td></tr><tr><td colspan=3><table width=100% cellspacing=0 cellpadding=0><tr valign=top><td width=5 background='images/table_bg_l.gif'><img src='images/table_lt.gif' width=5 height=5></td><td width=99% rowspan=3 style='padding:4px;'>"+inner+"</td><td width=5 background='images/table_bg_r.gif'><img src='images/table_rt.gif' width=5 height=5></td></tr><tr><td width=5 background='images/table_bg_l.gif'><img src='images/table_bg_l.gif' width=5 height=5></td><td width=5 background='images/table_bg_r.gif'><img src='images/table_bg_r.gif' width=5 height=5></td></tr><tr valign=bottom><td width=5 background='images/table_bg_l.gif'><img src='images/table_lb.gif' width=5 height=5></td><td width=5 background='images/table_bg_r.gif'><img src='images/table_rb.gif' width=5 height=5></td></tr></table></td></tr><tr height=5><td width=5><img src='images/table_bl.gif' width=10 height=5></td><td background='images/table_bg_b.gif' width=99%><img src='images/table_bg_b.gif' width=1 height=5></td><td width=5><img src='images/table_br.gif' width=10 height=5></td></tr></table>";
}
