
for(var i=0;i<15;i++)
{
  if (firstRow)
  {
    document.writeln("<tr id='firstRow'>");
    firstRow = false;
  }
  else
    document.writeln("<tr>");

  for(var j=0;j<15;j++)
  {
    var t = tiles.charAt(i*15+j);
    var h = hs.charAt(i*15+j);

    var y = "a";
    var x = String.fromCharCode(j+y.charCodeAt(0));
    var cell = "row" + x + i;

    var s = "";
    
    if( t == '!')
      s += '<td id="vacant" ';
    else
      s += '<td ';


    // Juraj Changed this line

    // if( h == '1')    s +=  'bgcolor="'+dls_color+'" background="' + dls_image + '">'



    // Add this line once at the top

    alt = "";

    // Change each of the single line 'if' statements to the following 5 lines:

    if( h == '1' )

    {

        s +=  'bgcolor="'+dls_color+'" background="' + dls_image + '">'

        alt = "Double Letter Score";

    }
    if( h == '2' ) 

    {

        s +=  'bgcolor="'+tls_color+'" background="' + tls_image + '">';

        alt = "Triple Letter Score";

    }

    if( h == '3' ) 

    {

        s +=  'bgcolor="'+dws_color+'" background="' + dws_image + '">';

        alt = "Double WORD Score";

    }

    if( h == '4' )

    {

        s +=  'bgcolor="'+tws_color+'" background="' + tws_image + '">';

        alt = "Triple WORD Score";

    }

    if( h == '5' ) 

    {
        
        s +=  'bgcolor="'+center_color+'" background="' + center_image + '">';

        alt = "Double WORD Score, and Centre Square";

    }


    if( h == '-' )
    {
     s +=  '>'; 

    alt = "Vacant Square";
    }


    if( t == '_') s += '<img src="' + grpath + grprefix + t + '.gif" alt="'+alt+'" ' + image_properties + '>';


if( t == '!')
{
altmsg = 'title="' + alt + '"';

    if(h == '1')
    {
    bgcolor = '#99CCFF';
    }

    if(h == '2')
    {
    bgcolor = '#0188FF';
    }

    if(h == '3')
    {
    bgcolor = '#FB80FC';
    }

    if(h == '4')
    {
    bgcolor = '#FF0000';
    }

    if(h == '5')
    {
    bgcolor = '#FB80FC';
    }

    if(h == '-')
    {
    bgcolor = '#FFFFFF';
    }


s += '<center><font size="-2"><input '+altmsg+' type="text" size="2"  maxlength="1" onkeydown="return handleKey(this, event)" onkeyup="handleKey(this, event)" onblur=this.style.backgroundColor="'+bgcolor+'" onfocus=this.style.backgroundColor="#D0D0A0"  name="' + cell + '" class=' + style_class + '></font></center>';
}

    if( 'a' <= t && t <= 'z' ) s += '<img src="' + grpath + grprefix + t + '.gif" alt="'+t+'" ' + image_properties + '>';
    if( 'A' <= t && t <= 'Z' ) s += '<img src="' + grpath + grprefix + t.toLowerCase() + '_blk.gif" alt="'+t+'" ' + image_properties + '>';
    if( t == '-' ) s += '<img src="' + grpath + grprefix + t + '_blk.gif" alt="'+t+'" ' + image_properties + '>';
    if( t == '1' ) s += '<img src="' + grpath + grprefix + t + '.gif" alt="'+t+'" ' + image_properties + '>';
    if( t == '2' ) s += '<img src="' + grpath + grprefix + t + '.gif" alt="'+t+'" ' + image_properties + '>';
    if( t == '3' ) s += '<img src="' + grpath + grprefix + t + '.gif" alt="'+t+'" ' + image_properties + '>';


    s += "</td>"

    document.writeln(s);
  }
  document.writeln("</tr>");
}
