if (alt) {

 document.write('</tr>');
 document.write('<tr>');
 
 alt=0;
 
} else {

 alt++;

}