//**Start Encode**
function movenext(xml_id)
{
  x=xml_id.recordset;
  if (x.absoluteposition < x.recordcount)
  {
  	x.movenext();
  }
}

function moveprevious(xml_id)
{
  x=xml_id.recordset;
  if (x.absoluteposition > 1)
  {
  	x.moveprevious();
  }
}

function testclick(field)
{
  var row=field.rowIndex;
  offers.recordset.absoluteposition=row;
  off_name.innerHTML=offers.recordset("offer_name");
  off_desc.innerHTML=offers.recordset("offer_desc");
  off_price_eu.innerHTML=offers.recordset("offer_price")+" &euro;";
  off_price.innerHTML="&nbsp;&nbsp;("+convertEurosToLire(offers.recordset("offer_price"))+" Lire)";
  off_date_start.innerHTML=offers.recordset("offer_date_start");
  off_date_end.innerHTML=offers.recordset("offer_date_end");
  window.location.hash = "detail";
}

function load_photos()
{
  var photo_length = photos.recordset.recordcount;
  photo_length++;
  var photo_x = 0;
  var photo_y = 0;
  var counter = 1;
  
  for(var i=1; i<photo_length; i++)
  {
    photos.recordset.absoluteposition = i;
    photo_x = photos.recordset("photo_xsize");
    photo_y = photos.recordset("photo_ysize");
    
    if(photo_x == "")
      photo_x = 0;
  
    if(photo_y == "")
      photo_y = 0;
  
    if(i%3==1)
    {
      counter = 1;
      if(i>1)
      {
        document.write('<tr height="20" valign="top">');
        document.write('  <td align="left" valign="top" colspan="3"><img src="images/trasp.gif" width="1" height="20" border="0"></td>');
        document.write('</tr>');
      }
      document.write('<tr valign="top">');
    }
  
    document.write('  <td width="33%" align="center" valign="middle">');
    document.write('    <a href="javascript:openImage(\'images/'+photos.recordset("photo_name")+'\', '+photo_x+', '+photo_y+');"><img src="images/'+photos.recordset("photo_preview")+'" border="0"></a>');
    document.write('    <br>');
    document.write('    <span class="footerbold">'+photos.recordset("photo_author")+'</span>');
    document.write('  </td>');
    
    counter++;
    
    if(i%3 == 0)
      document.write('</tr>');
  }
  
  if(counter > 1 && counter < 4)
  {
    for(var j=counter; j<4; j++)
      document.write('<td><img src="images/trasp.gif" border="0"></td>');
  
    document.write('</tr>');
  }
}

function photoInnerHTML(pag)
{
  var page_num = pag;
  var photo_length = photos.recordset.recordcount;
  photo_length++;
  var photo_x = 0;
  var photo_y = 0;
  var counter = 1;
  var stringa = '<table border="0" cellpadding="0" cellspacing="0" width="630">';
  var stringa2 = "";
  var start = (page_num * 6) + 1;
  var stop = ((page_num + 1) * 6) + 1;
  var author = "";

  if(stop > photo_length)
    stop = photo_length;

  if(start > stop)
  {
    page_num = Math.ceil(((stop - 1) / 6) - 1);
    page = page_num;
    next_page = page + 1;
    next_page_text = next_page.toString();
    if(page>0)
      prev_page = page - 1;
    else
      prev_page = 0;
    prev_page_text = prev_page.toString();
    start = (page_num * 6) + 1;
  }

  for(var i=start; i<stop; i++)
  {
    photos.recordset.absoluteposition = i;
    photo_x = photos.recordset("photo_xsize");
    photo_y = photos.recordset("photo_ysize");
    
    if(photo_x == "")
      photo_x = 0;
  
    if(photo_y == "")
      photo_y = 0;
  
    if(i%3==1)
    {
      counter = 1;
      if(i>1)
      {
        stringa += '<tr height="20" valign="top">';
        stringa += '  <td align="left" valign="top" colspan="3"><img src="images/trasp.gif" width="1" height="20" border="0"></td>';
        stringa += '</tr>';
      }
      stringa += '<tr valign="top">';
    }
  
    author = new String(photos.recordset("photo_author"));
    if(author.length > 26)
      author = author.substring(0, 23) + "...";
    
    stringa += '  <td width="180">';
    stringa += '    <table border="0" cellpadding="0" cellspacing="0" width="180">';
    stringa += '      <tr height="25">';
    stringa += '        <td align="center" background="images/frame_foto_piccolo.jpg" colspan="3"><span class="footerbold">'+author+'</span></td>';
    stringa += '      </tr>';
    stringa += '      <tr height="120">';
    stringa += '        <td background="images/pixel_celeste.gif" height="120" width="3"><img src="images/trasp.gif" height="120" width="3" border="0"></td>';
    stringa += '        <td height="120" width="174" align="center" valign="middle">';
    stringa += '          <a href="javascript:openImage(\'images/'+photos.recordset("photo_name")+'\', '+photo_x+', '+photo_y+');"><img src="images/'+photos.recordset("photo_preview")+'" border="0"></a>';
    stringa += '        </td>';
    stringa += '        <td background="images/pixel_celeste.gif" height="120" width="3"><img src="images/trasp.gif" height="120" width="3" border="0"></td>';
    stringa += '      </tr>';
    stringa += '      <tr height="3">';
    stringa += '        <td background="images/pixel_celeste.gif" height="3" width="180" colspan="3"><img src="images/trasp.gif" height="3" width="180" border="0"></td>';
    stringa += '      </tr>';
    stringa += '    </table>';
    stringa += '  </td>';
    
    counter++;
    
    if(i%3 == 0)
      stringa += '</tr>';
  }
  
  if(counter > 1 && counter < 4)
  {
    for(var j=counter; j<4; j++)
      stringa += '<td><img src="images/trasp.gif" border="0"></td>';
  
    stringa += '</tr>';
  }

  photo_space.innerHTML = stringa + '</table>';
  
  stringa2 = "<br>";
  
  if(page_num > 0)
    stringa2 += '<span class="prevAndNext"><a href="javascript:setPage(\'prev\')" class="prevAndNext"><< Pag. precedente</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>';
  else
    stringa2 += '<span class="prevAndNext"><< Pag. precedente&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>';
  
  if(stop < photo_length)
    stringa2 += '<span class="prevAndNext"><a href="javascript:setPage(\'next\')" class="prevAndNext">Pag. successiva >></a></span>';
  else
    stringa2 += '<span class="prevAndNext">Pag. successiva >></span>';
  
  form_space.innerHTML = stringa2;
}

