var FileCounter=1;
var FilePos=1;


// ********************************************
function NowyPlik(attachment)
{

FilePos ++;
FileCounter ++;

body = document.getElementById('dhtmlattach').tBodies[0];
len = body.rows.length;
body.insertRow(len);
row = body.rows[len];
row.id = "file_row_"+FileCounter;

len ++;
body.insertRow(len);
row = body.rows[len];
cell = row.insertCell(0);
cell.innerHTML = "<span id='file_pos_"+FileCounter+"'>Zdjęcie "+FilePos+":&nbsp;</span>";
cell = row.insertCell(1);
cell.innerHTML = "<input type='file' id='n_ac_file_"+FileCounter+"' name='n_ac_file_"+FileCounter+"' class='ac_file' />";
cell.innerHTML = cell.innerHTML + "&nbsp;&nbsp;<input type='button' id='n_ac_delete_"+FileCounter+"' class='Button2' value=' Usuń ' title='usuń plik' onclick='return UsunPlik("+FileCounter+");' />";

len ++;
body.insertRow(len);
row = body.rows[len];
cell = row.insertCell(0);
cell.innerHTML = "<span>Opis&nbsp;zdjęcia:&nbsp;</span>";
cell = row.insertCell(1);
cell.innerHTML = "<input type='text' id='n_ac_opis_"+FileCounter+"' name='n_ac_opis_"+FileCounter+"' value='' maxlength='200' class='ac_file_description' />";


document.getElementById('n_ac_ilosc_plikow').value = FileCounter;
 
return false;
} // koniec NowyPlik()




// ********************************************
function UsunPlik(Nr_)
{
body = document.getElementById('dhtmlattach').tBodies[0];

for ( i=0 ; i < body.rows.length ; i ++ )
  {
  row = body.rows[i];
  if ( row.id == "file_row_"+Nr_ )
    {
    body.deleteRow(i);
    body.deleteRow(i);
    body.deleteRow(i);    
    break;
  }
}    

PrzenumerujPliki();

return false;
} // koniec UsunPlik()




// ********************************************
function PrzenumerujPliki()
{

FilePos = 1;

for ( i=1 ; i<=FileCounter ; i++ )
  {
  Obj_ = document.getElementById('file_pos_'+i); 
  if ( Obj_ )
    {
    FilePos++;
    Obj_.innerHTML = "zdjęcie "+FilePos+"";
  }
}      

return false;
} // koniec PrzenumerujPliki()





// ************************************************
function FileItem(file, surname)
{
this.name = name;
this.surname = surname;
  
} // koniec FileItem()






// *********************************
function SprFormAddComment()
{
JestOK_ = true;

JestOK_ = ( JestOK_ && CiagPusty('n_ac_author',0,'Prosimy o podanie imienia.') );
JestOK_ = ( JestOK_ && CiagPusty('n_ac_description',0,'Wprowadź swój komentarz.') );

if ( JestOK_ && KillAllSpace(document.getElementById('n_ac_email').value).length > 0 && !MailTest( document.getElementById('n_ac_email').value ) )
  {
  alert( 'Podany adres e-mail nie jest poprawny.' );
  document.getElementById('n_ac_email').focus();
  JestOK_ = false;  
}  


if ( JestOK_ )
  {
  j=1;
  for ( i=1 ; i<=FileCounter ; i++ )
    {
    if ( document.getElementById('n_ac_file_'+i) )
      {
      ObjFile_ = document.getElementById('n_ac_file_'+i); 
      File_ = ObjFile_.value.toLowerCase();
    
      if ( JestOK_ && File_ != "" && File_.substring(File_.length-4,File_.length) != '.jpg' )
        {
        alert( 'zdjęcie '+j+' to nie jest plik graficzny JPG' );
        ObjFile_.focus();
        JestOK_ = false;
      }
/*      
//      if ( JestOK_ && File_ != "" && File_.substring(1,3) != ":\\" )
      if ( JestOK_ && G__Navigator.indexOf('OPERA') == -1 && File_ != "" && File_.indexOf(':\\') < 1 && File_.indexOf(':/') < 1 )
        {
        alert( 'ścieżka do pliku '+j+' na Twoim komputerze nie wygląda poprawnie\n\nnależy podać plik korzystając z przycisku "Przeglądaj..."' );
        ObjFile_.focus();
        JestOK_ = false;
      }
*/       
      j++;   
    }
  }     
}  

if ( JestOK_ && confirm( 'Czy chcesz dodać swój komentarz?' ) )
  {
  document.getElementById('commentFormAction').value = 'send';  
  document.getElementById('formAddComment').submit();  
}  

return false;
} // koniec SprFormAddComment()











// *********************************************
function RatingResigne(Url_)
{
window.location.href=Url_;

return false;
} // koniec RatingResigne()



// *********************************************
function RatingSend()
{
JestOK_ = true;

for ( i=1 ; i <= 100 ; i++ )
  {
  if ( document.getElementById('n_av_rate_'+i) && document.getElementById('n_av_rate_'+i).value == -1 )
    {
    alert("proszę wybrać");
    document.getElementById('n_av_rate_'+i).focus();
    JestOK_ = false;    
    break;    
  }
}

if ( JestOK_ && confirm("Chcesz wysłać swój głos?") )
  {
  document.getElementById('rateFormAction').value = "send";
  document.getElementById('formRating').submit();    
}    

return false;
} // koniec RatingSend()


