var acti=0
var timerID = null
var timerINT = 500                              //interval (ms)
var scrn = new Array(220)                       //screen fill flag
var icons = new Array(8)                        //block image
        icons[0]=new Image();icons[0].src="img/tetris_bs0.gif"
        icons[1]=new Image();icons[1].src="img/tetris_bs1.gif"
        icons[2]=new Image();icons[2].src="img/tetris_bs2.gif"
        icons[3]=new Image();icons[3].src="img/tetris_bs3.gif"
        icons[4]=new Image();icons[4].src="img/tetris_bs4.gif"
        icons[5]=new Image();icons[5].src="img/tetris_bs5.gif"
        icons[6]=new Image();icons[6].src="img/tetris_bs6.gif"
        icons[7]=new Image();icons[7].src="img/tetris_bs7.gif"
        icons[8]=new Image();icons[8].src="img/tetris_bs8.gif"
var styl = new Array(280)                       //block style
var tmps = new Array(10)                        //temp array
var lv = 1                                      //level
var rst = 1                                     //reset flag

var bb1 = 0                                     //old block buffer
var bb2 = 0
var bb3 = 0
var bb4 = 0
var bbo = 0

var hcp = 0                                     //Hit Check parameter
var hcr = 0
var hcx = 0
var hcy = 0
var hcf = 0

var nowp = 5
var nowr = 0
var nowx = 3
var nowy = 0
var movf = 0                                    //move flag
var chkf = 0

var total = 0                                   //total clear line
var score = 0                                   //score

tetris_s0=new Image(100,10); tetris_s0.src='img/tetris_s0.gif';
tetris_s1=new Image(111,11); tetris_s1.src='img/tetris_s1.gif';
tetris_s2=new Image(122,12); tetris_s2.src='img/tetris_s2.gif';
tetris_s3=new Image(133,13); tetris_s3.src='img/tetris_s3.gif';
tetris_s4=new Image(144,14); tetris_s4.src='img/tetris_s4.gif';
tetris_s5=new Image(155,15); tetris_s5.src='img/tetris_s5.gif';
tetris_s6=new Image(166,16); tetris_s6.src='img/tetris_s6.gif';
tetris_s7=new Image(177,17); tetris_s7.src='img/tetris_s7.gif';
tetris_s8=new Image(188,18); tetris_s8.src='img/tetris_s8.gif';
tetris_s9=new Image(199,19); tetris_s9.src='img/tetris_s9.gif';

tetris_z1=new Image(40,10); tetris_z1.src='img/tetris_z1.gif';
tetris_z2=new Image(40,10); tetris_z2.src='img/tetris_z2.gif';
tetris_z3=new Image(40,10); tetris_z3.src='img/tetris_z3.gif';
tetris_z4=new Image(40,10); tetris_z4.src='img/tetris_z4.gif';
tetris_z5=new Image(40,10); tetris_z5.src='img/tetris_z5.gif';

function change(no,picture) {
        window.document.images[no].src = picture.src;
}

function interval1(){
        clearTimeout(timerID)
        DownCheck()
        timerID = setTimeout("interval1()",timerINT)
}

function start(){
        for (ia=0; ia<220; ia++){
                scrn[ia]=0
        }

        lv = 1
        bb1 = 0
        bb2 = 0
        bb3 = 0
        bb4 = 0
        bbo = 0
        nowp = 5
        nowr = 0
        nowx = 3
        nowy = 0
        total = 0
        score = 0

        if (rst == 1){
                document.TetriScript.LINE.value = "0 LINE CLEAR"
                document.TetriScript.PTS.value = "0 pts"
        }else{
                document.TetriScript.LINE.value = "SELECT LEVEL"
                if (systm != "C"){if (Nv >= 4){
                        document.TetriScript.PTS.value = "LEVEL L KEY!"
                }else{ document.TetriScript.PTS.value = "CLICK ROTATE" }
                }else{ document.TetriScript.PTS.value = "CLICK ROTATE" }
        }

        for (ia=0; ia<22; ia++){
                for (ib=0; ib<10; ib++){
                        iaa=ia*10+ib+16
                        SetIcon(0,iaa)
                }
        }

        if (rst == 1){
                WriNxt()
                nowp = patn
                nowr = rotat
                WriScr()
                WriNxt()
                acti=1
                rst =0
                timerID = setTimeout("interval1()",10)
        }else{
                for (iaa=0; iaa<16; iaa++){
                        SetIcon (0,iaa)
                        rst=1
                        acti=0
                        clearTimeout(timerID)
                }
        }
}

function SetIcon(flag, position){
        document.images[position].src=icons[flag].src
}

function WriNxt(){
        with (Math) {
                patn = floor(random()*7)+1
                rotat = floor(random()*4)
        }

        for (iaa=0; iaa<16; iaa++){
                SetIcon (0,iaa)
        }

        offset=patn*40 + rotat*10 - 40

        outpos=styl[offset]*4+styl[offset+1]-5
        SetIcon (patn,outpos)

        outpos=styl[offset+2]*4+styl[offset+3]-5
        SetIcon (patn,outpos)

        outpos=styl[offset+4]*4+styl[offset+5]-5
        SetIcon (patn,outpos)

        outpos=styl[offset+6]*4+styl[offset+7]-5
        SetIcon (patn,outpos)
}

function WriScr(){
        if (movf == 0){
                SetIcon (0,bb1)
                SetIcon (0,bb2)
                SetIcon (0,bb3)
                SetIcon (0,bb4)
        }
        movf=0
        offset=nowp*40+nowr*10-40
        bbo = offset

        outpos=(styl[offset]+nowy)*10+styl[offset+1]+nowx+5
        SetIcon (nowp,outpos)
        bb1=outpos

        outpos=(styl[offset+2]+nowy)*10+styl[offset+3]+nowx+5
        SetIcon (nowp,outpos)
        bb2=outpos

        outpos=(styl[offset+4]+nowy)*10+styl[offset+5]+nowx+5
        SetIcon (nowp,outpos)
        bb3=outpos

        outpos=(styl[offset+6]+nowy)*10+styl[offset+7]+nowx+5
        SetIcon (nowp,outpos)
        bb4=outpos
}

function LeftClick(){
        if (acti == 1){
                iab=styl[bbo+1]+nowx
                if (iab >= 2){
                        iab=styl[bbo+3]+nowx
                        if (iab >= 2){
                                iab=styl[bbo+5]+nowx
                                if (iab >= 2){
                                        iab=styl[bbo+7]+nowx
                                        if (iab >= 2){
                                                hcp=nowp
                                                hcr=nowr
                                                hcx=nowx-1
                                                hcy=nowy
                                                HitChk(hcp,hcr,hcx,hcy)
                                                if (hcf == 0){
                                                        nowx=nowx-1
                                                        WriScr()
                                                }
                                        }
                                }
                        }
                }
        }
}

function RightClick(){
        if (acti == 1){
                iab=styl[bbo+1]+nowx
                if (iab <= 9){
                        iab=styl[bbo+3]+nowx
                        if (iab <= 9){
                                iab=styl[bbo+5]+nowx
                                if (iab <= 9){
                                        iab=styl[bbo+7]+nowx
                                        if (iab <= 9){
                                                hcp=nowp
                                                hcr=nowr
                                                hcx=nowx+1
                                                hcy=nowy
                                                HitChk(hcp,hcr,hcx,hcy)
                                                if (hcf == 0){
                                                        nowx=nowx+1
                                                        WriScr()
                                                }
                                        }
                                }
                        }
                }
        }
}

function RotateClick(){
        if (acti == 1){
                hcp=nowp
                hcr=nowr+1
                if (hcr == 4){hcr=0}
                hcx=nowx
                hcy=nowy
                iaoff=hcp*40 + hcr*10 - 40
                iab=styl[iaoff+1]+hcx
                if (iab <= 10){
                        if (iab >= 1 ){
                                iab=styl[iaoff+0]+hcy
                                if (iab <= 22){
                                        if (iab >= 1 ){
                                                iab=styl[iaoff+3]+hcx
                                                if (iab <= 10){
                                                        if (iab >= 1 ){
                                                                iab=styl[iaoff+2]+hcy
                                                                if (iab <= 22){
                                                                        if (iab >= 1 ){
                                                                                iab=styl[iaoff+5]+hcx
                                                                                if (iab <= 10){
                                                                                        if (iab >= 1 ){
                                                                                                iab=styl[iaoff+4]+hcy
                                                                                                if (iab <= 22){
                                                                                                        if (iab >= 1 ){
                                                                                                                iab=styl[iaoff+7]+hcx
                                                                                                                if (iab <= 10){
                                                                                                                        if (iab >= 1 ){
                                                                                                                                iab=styl[iaoff+6]+hcy
                                                                                                                                if (iab <= 22){
                                                                                                                                        if (iab >= 1 ){
                                                                                                                                                HitChk(hcp,hcr,hcx,hcy)
                                                                                                                                                if (hcf == 0){
                                                                                                                                                        nowr=hcr
                                                                                                                                                        WriScr()
                                                                                                                                                }
                                                                                                                                        }
                                                                                                                                }
                                                                                                                        }
                                                                                                                }
                                                                                                        }
                                                                                                }
                                                                                        }
                                                                                }
                                                                        }
                                                                }
                                                        }
                                                }
                                        }
                                }
                        }
                }
        }else{
                if (rst == 1){
                        lv=lv+1
                        if (lv == 6){lv=1}
                        timerINT = 600-(lv * 100)
                        if (lv == 1) { change(252,tetris_z1) }
                        if (lv == 2) { change(252,tetris_z2) }
                        if (lv == 3) { change(252,tetris_z3) }
                        if (lv == 4) { change(252,tetris_z4) }
                        if (lv == 5) { change(252,tetris_z5) }
                }
        }
}

function DownCheck(){
        if (acti == 1){
                chkf=0
                iab=styl[bbo+0]+nowy
                if (iab <= 21){
                        iab=styl[bbo+2]+nowy
                        if (iab <= 21){
                                iab=styl[bbo+4]+nowy
                                if (iab <= 21){
                                        iab=styl[bbo+6]+nowy
                                        if (iab <= 21){
                                                hcp=nowp
                                                hcr=nowr
                                                hcx=nowx
                                                hcy=nowy+1
                                                HitChk(hcp,hcr,hcx,hcy)
                                                if (hcf == 0){
                                                        nowy=nowy+1
                                                        WriScr()
                                                        chkf=1
                                                }
                                        }
                                }
                        }
                }
                if (chkf == 0){
                        tmps[0]=(styl[bbo+0]+nowy-1)*10
                        iab=tmps[0]+styl[bbo+1]+nowx-1
                        scrn[iab]=nowp
                        tmps[1]=(styl[bbo+2]+nowy-1)*10
                        iab=tmps[1]+styl[bbo+3]+nowx-1
                        scrn[iab]=nowp
                        tmps[2]=(styl[bbo+4]+nowy-1)*10
                        iab=tmps[2]+styl[bbo+5]+nowx-1
                        scrn[iab]=nowp
                        tmps[3]=(styl[bbo+6]+nowy-1)*10
                        iab=tmps[3]+styl[bbo+7]+nowx-1
                        scrn[iab]=nowp

                        tmps[4]=-1
                        tmps[5]=-1
                        tmps[6]=-1
                        tmps[7]=-1
                        tmps[8]=0

                        for (iae=0; iae<4; iae++){
                                iag=tmps[iae]
                                iah=1
                                if (tmps[4] == iag){iah=0}
                                if (tmps[5] == iag){iah=0}
                                if (tmps[6] == iag){iah=0}
                                if (tmps[7] == iag){iah=0}
                                for (iaf=0; iaf<10; iaf++){
                                        if (scrn[iag+iaf] == 0){iah=0}
                                }
                                if (iah == 1){
                                        tmps[8]=tmps[8]+1             //clear line count up
                                        total=total+1
                                        tmps[iae+4]=iag               //clear line hight tmp save
                                        for (iaf=0; iaf<10; iaf++){
                                                SetIcon(8,iag+iaf+16)
                                        }
                                }
                        }
                        if (tmps[8] == 1){score=score+20}
                        if (tmps[8] == 2){score=score+40}
                        if (tmps[8] == 3){score=score+80}
                        if (tmps[8] == 4){score=score+160}

                        document.TetriScript.LINE.value = total+" LINE CLEAR"
                        document.TetriScript.PTS.value = score+" pts"

                        zahl = total
                        test_t = parseInt(zahl / 1000)
                        if (test_t == 0) { change(254,tetris_s0) }
                        if (test_t == 1) { change(254,tetris_s1) }
                        if (test_t == 2) { change(254,tetris_s2) }
                        if (test_t == 3) { change(254,tetris_s3) }
                        if (test_t == 4) { change(254,tetris_s4) }
                        if (test_t == 5) { change(254,tetris_s5) }
                        if (test_t == 6) { change(254,tetris_s6) }
                        if (test_t == 7) { change(254,tetris_s7) }
                        if (test_t == 8) { change(254,tetris_s8) }
                        if (test_t == 9) { change(254,tetris_s9) }
                        rest = zahl - test_t * 1000

                        zahl = rest
                        test_h = parseInt(zahl / 100)
                        if (test_h == 0) { change(255,tetris_s0) }
                        if (test_h == 1) { change(255,tetris_s1) }
                        if (test_h == 2) { change(255,tetris_s2) }
                        if (test_h == 3) { change(255,tetris_s3) }
                        if (test_h == 4) { change(255,tetris_s4) }
                        if (test_h == 5) { change(255,tetris_s5) }
                        if (test_h == 6) { change(255,tetris_s6) }
                        if (test_h == 7) { change(255,tetris_s7) }
                        if (test_h == 8) { change(255,tetris_s8) }
                        if (test_h == 9) { change(255,tetris_s9) }
                        rest = zahl - test_h * 100

                        zahl = rest
                        test_z = parseInt(zahl / 10)
                        if (test_z == 0) { change(256,tetris_s0) }
                        if (test_z == 1) { change(256,tetris_s1) }
                        if (test_z == 2) { change(256,tetris_s2) }
                        if (test_z == 3) { change(256,tetris_s3) }
                        if (test_z == 4) { change(256,tetris_s4) }
                        if (test_z == 5) { change(256,tetris_s5) }
                        if (test_z == 6) { change(256,tetris_s6) }
                        if (test_z == 7) { change(256,tetris_s7) }
                        if (test_z == 8) { change(256,tetris_s8) }
                        if (test_z == 9) { change(256,tetris_s9) }
                        rest = zahl - test_z * 10

                        zahl = rest
                        test_e = parseInt(zahl / 1)
                        if (test_e == 0) { change(257,tetris_s0) }
                        if (test_e == 1) { change(257,tetris_s1) }
                        if (test_e == 2) { change(257,tetris_s2) }
                        if (test_e == 3) { change(257,tetris_s3) }
                        if (test_e == 4) { change(257,tetris_s4) }
                        if (test_e == 5) { change(257,tetris_s5) }
                        if (test_e == 6) { change(257,tetris_s6) }
                        if (test_e == 7) { change(257,tetris_s7) }
                        if (test_e == 8) { change(257,tetris_s8) }
                        if (test_e == 9) { change(257,tetris_s9) }
                        rest = zahl - test_e * 1

                        zahl = score
                        test_t = parseInt(zahl / 1000)
                        if (test_t == 0) { change(258,tetris_s0) }
                        if (test_t == 1) { change(258,tetris_s1) }
                        if (test_t == 2) { change(258,tetris_s2) }
                        if (test_t == 3) { change(258,tetris_s3) }
                        if (test_t == 4) { change(258,tetris_s4) }
                        if (test_t == 5) { change(258,tetris_s5) }
                        if (test_t == 6) { change(258,tetris_s6) }
                        if (test_t == 7) { change(258,tetris_s7) }
                        if (test_t == 8) { change(258,tetris_s8) }
                        if (test_t == 9) { change(258,tetris_s9) }
                        rest = zahl - test_t * 1000

                        zahl = rest
                        test_h = parseInt(zahl / 100)
                        if (test_h == 0) { change(259,tetris_s0) }
                        if (test_h == 1) { change(259,tetris_s1) }
                        if (test_h == 2) { change(259,tetris_s2) }
                        if (test_h == 3) { change(259,tetris_s3) }
                        if (test_h == 4) { change(259,tetris_s4) }
                        if (test_h == 5) { change(259,tetris_s5) }
                        if (test_h == 6) { change(259,tetris_s6) }
                        if (test_h == 7) { change(259,tetris_s7) }
                        if (test_h == 8) { change(259,tetris_s8) }
                        if (test_h == 9) { change(259,tetris_s9) }
                        rest = zahl - test_h * 100

                        zahl = rest
                        test_z = parseInt(zahl / 10)
                        if (test_z == 0) { change(260,tetris_s0) }
                        if (test_z == 1) { change(260,tetris_s1) }
                        if (test_z == 2) { change(260,tetris_s2) }
                        if (test_z == 3) { change(260,tetris_s3) }
                        if (test_z == 4) { change(260,tetris_s4) }
                        if (test_z == 5) { change(260,tetris_s5) }
                        if (test_z == 6) { change(260,tetris_s6) }
                        if (test_z == 7) { change(260,tetris_s7) }
                        if (test_z == 8) { change(260,tetris_s8) }
                        if (test_z == 9) { change(260,tetris_s9) }
                        rest = zahl - test_z * 10

                        zahl = rest
                        test_e = parseInt(zahl / 1)
                        if (test_e == 0) { change(261,tetris_s0) }
                        if (test_e == 1) { change(261,tetris_s1) }
                        if (test_e == 2) { change(261,tetris_s2) }
                        if (test_e == 3) { change(261,tetris_s3) }
                        if (test_e == 4) { change(261,tetris_s4) }
                        if (test_e == 5) { change(261,tetris_s5) }
                        if (test_e == 6) { change(261,tetris_s6) }
                        if (test_e == 7) { change(261,tetris_s7) }
                        if (test_e == 8) { change(261,tetris_s8) }
                        if (test_e == 9) { change(261,tetris_s9) }
                        rest = zahl - test_e * 1

                        if (tmps[4] >= tmps[5]){
                                tmps[9]=tmps[4]
                                tmps[4]=tmps[5]
                                tmps[5]=tmps[9]
                        }
                        if (tmps[4] >= tmps[6]){
                                tmps[9]=tmps[4]
                                tmps[4]=tmps[6]
                                tmps[6]=tmps[9]
                        }
                        if (tmps[4] >= tmps[7]){
                                tmps[9]=tmps[4]
                                tmps[4]=tmps[7]
                                tmps[7]=tmps[9]
                        }
                        if (tmps[5] >= tmps[6]){
                                tmps[9]=tmps[5]
                                tmps[5]=tmps[6]
                                tmps[6]=tmps[9]
                        }
                        if (tmps[5] >= tmps[7]){
                                tmps[9]=tmps[5]
                                tmps[5]=tmps[7]
                                tmps[7]=tmps[9]
                        }
                        if (tmps[6] >= tmps[7]){
                                tmps[9]=tmps[6]
                                tmps[6]=tmps[7]
                                tmps[7]=tmps[9]
                        }
                        for (ial=0; ial<4; ial++){
                                if (tmps[4+ial] != -1){
                                        for (iam=0; iam<(tmps[4+ial]-10); iam++){
                                                ian=tmps[4+ial]-1-iam
                                                scrn[ian+10]=scrn[ian]
                                        }
                                        for (iam=0; iam<10; iam++){scrn[iam]=0}
                                }
                        }

                        for (iam=0; iam<220; iam++){SetIcon(scrn[iam],iam+16)}

                        nowx=3
                        nowy=0
                        nowp=patn
                        nowr=rotat
                        movf=1
                        WriScr()
                        hcp=nowp
                        hcr=nowr
                        hcx=nowx
                        hcy=nowy
                        HitChk(hcp,hcr,hcx,hcy)

                        if (hcf == 1){acti=0
                                document.TetriScript.LINE.value = "GAME OVER!!"
                                clearTimeout(timerID)
                        }

                        WriNxt()
                }
        }
}

function HitChk(hcp,hcr,hcx,hcy){
        hcf=0                                      //Hit = 1  No Hit = 0
        iaoff=hcp*40 + hcr*10 - 40
        iad=(styl[iaoff+0]+hcy)*10+styl[iaoff+1]+hcx-11
    if (scrn[iad] >= 1){hcf=1}
    iad=(styl[iaoff+2]+hcy)*10+styl[iaoff+3]+hcx-11
    if (scrn[iad] >= 1){hcf=1}
    iad=(styl[iaoff+4]+hcy)*10+styl[iaoff+5]+hcx-11
    if (scrn[iad] >= 1){hcf=1}
    iad=(styl[iaoff+6]+hcy)*10+styl[iaoff+7]+hcx-11
    if (scrn[iad] >= 1){hcf=1}
}

function keyDown(DnEvents){
 if (systm != "C"){
  k=DnEvents.which
 }else{
  k=window.event.keyCode
 }
 
 	if (k == 40){DownCheck()}                    // Arrow down
  else if (k == 50){DownCheck()}                    //2
  else if (k == 98){DownCheck()}                    //2

	if (k == 38){RotateClick()}                  // Arrow up
  else if (k == 53){RotateClick()}                  //5
  else if (k == 101){RotateClick()}                 //5
  
  if (k == 39){RightClick()} 
  else if (k == 54){RightClick()}                   // Arrow right
  else if (k == 102){RightClick()}                  //6

	if (k == 37){LeftClick()}                    // Arrow left
  else if (k == 52){LeftClick()}                    //4
  else if (k == 100){LeftClick()}                   //4

  if (k ==  83){start()}                       //S
  if (k == 115){start()}                       //s

}


for (ia=0; ia<220; ia++){ scrn[ia]=0 }

//if((navigator.appName == 'MSIE') || (navigator.appName == 'Microsoft Internet Explorer')){
        document.write('<div style="position:absolute; left:50px; top:221px">');

        for (ia=0; ia<4; ia++){
                document.write('<img border="0" width="10" height="10" src="img/tetris_bs0.gif">');
                document.write('<img border="0" width="10" height="10" src="img/tetris_bs0.gif">');
                document.write('<img border="0" width="10" height="10v src="img/tetris_bs0.gif">');
                document.write('<img border="0" width="10" height="10" src="img/tetris_bs0.gif"><br>');
        }
        document.write('</div>');

        document.write('<div style="position:absolute; left:160px; top:230px">');
        for (ia=0; ia<22; ia++){
                document.write('<img border="0" width="10" height="10" src="img/tetris_bs0.gif">');
                document.write('<img border="0" width="10" height="10" src="img/tetris_bs0.gif">');
                document.write('<img border="0" width="10" height="10" src="img/tetris_bs0.gif">');
                document.write('<img border="0" width="10" height="10" src="img/tetris_bs0.gif">');
                document.write('<img border="0" width="10" height="10" src="img/tetris_bs0.gif">');
                document.write('<img border="0" width="10" height="10" src="img/tetris_bs0.gif">');
                document.write('<img border="0" width="10" height="10" src="img/tetris_bs0.gif">');
                document.write('<img border="0" width="10" height="10" src="img/tetris_bs0.gif">');
                document.write('<img border="0" width="10" height="10" src="img/tetris_bs0.gif">');
                document.write('<img border="0" width="10" height="10" src="img/tetris_bs0.gif"><br>');
        }
        document.write('</div>');
//}

//if((navigator.appName == "MSIE") || (navigator.appName == "Microsoft Internet Explorer")){
        document.write('<div style="position:absolute; left:10px; top:200px">');
        document.write('<table border="0" cellpadding="0" cellspacing="0">');
                document.write('<tr valign=top>');
                        document.write('<td>');
                        document.write('<table border="0" cellpadding="0" cellspacing="0">');
                                document.write('<tr valign="top"><td colspan="3"><img src="img/tetris_pic_01.gif" width=130 height=21></td></tr>');

                                document.write('<tr valign="top">');
                                        document.write('<td><img src="img/tetris_pic_02.gif" width="40" height="40"></td>');
                                        document.write('<td><img src="img/dummy.gif" width="40" height="40"></td>');
                                        document.write('<td><img src="img/tetris_pic_03.gif" width="50" height="40"></td>');
                                document.write('</tr>');

                                document.write('<tr valign="top"><td colspan="3"><img src="img/tetris_pic_04.gif" width="130" height="49"></td></tr>');
                                document.write('<tr valign="top"><td colspan="3"><img src="img/tetris_pic_05.gif" width="130" height="91"></td></tr>');
                                document.write('<tr valign="top"><td colspan="3"><img src="img/tetris_pic_06.gif" width="130" height="59"></td></tr>');
                        document.write('</table>');
                        document.write('</td>');

                        document.write('<td><img src="img/tetris_pic_07.gif" width="20" height="270"></td>');
                        document.write('<td><img src="img/tetris_bs0.gif" width="100" height="10"><br><img src="img/tetris_bs0.gif" width="100" height="10"><br><img src="img/tetris_bs0.gif" width="100" height="10"><br><img src="img/dummy.gif" width="100" height="220"><br><img src="img/tetris_pic_08.gif" width="100" height="20"></td>');
                        document.write('<td><img src="img/tetris_pic_09.gif" width="20" height="270"></td>');

                        document.write('<td>');
                        document.write('<table border="0" cellpadding="0" cellspacing="0">');
                                document.write('<tr valign=top><td colspan=3><img src="img/tetris_pic_10.gif" width="131" height="21"></td></tr>');

                                document.write('<tr valign="top">');
                                        document.write('<td><img src="img/tetris_pic_11.gif" width="49" height="40"></td>');
                                        document.write('<td><img src="img/tetris_z1.gif" width="40" height="10"><br><img src="img/tetris_bs0.gif" width="40" height="10"><br><img src="img/tetris_bs0.gif" width="10" height="10"><img src="img/tetris_bs0.gif" width="10" height="10"><img src="img/tetris_bs0.gif" width="10" height="10"><img src="img/tetris_bs0.gif" width="10" height="10"><br><img src="img/tetris_bs0.gif" width="10" height="10"><img src="img/tetris_bs0.gif" width="10" height="10"><img src="img/tetris_bs0.gif" width="10" height="10"><img src="img/tetris_bs0.gif" width="10" height="10"></td>');
                                        document.write('<td><img src="img/tetris_pic_12.gif" width="42" height="40"></td>');
                                document.write('</tr>');

                                document.write('<tr valign="top"><td colspan="3"><img src="img/tetris_pic_13.gif" width="131" height="49"></td></tr>');
                                document.write('<tr valign="top"><td colspan="3"><img src="img/tetris_pic_14.gif" width="131" height="91"></td></tr>');
                                document.write('<tr valign="top"><td colspan="3"><img src="img/tetris_pic_15.gif" width="131" height="59"></td></tr>');
                        document.write('</table>');
                        document.write('</td>');
                document.write('</tr>');
        document.write('</table>');
        document.write('</div>');
//}

tmps[1]="22233233--22233233--22233233--22233233--"
tmps[2]="12212223--12212232--21222332--12222332--"
tmps[3]="13222332--21223233--13222332--21223233--"
tmps[4]="12222333--22233132--12222333--22233132--"
tmps[5]="12223233--23313233--22233343--22232432--"
tmps[6]="13233233--21222333--22233242--22323334--"
tmps[7]="13233343--21222324--13233343--21222324--"

for (ib=1; ib<8; ib++){
        for (ia=0; ia<40; ia++){
                ic = tmps[ib].charAt(ia)
                iz = ib * 40 + ia - 40
                styl[iz] = 4
                if (ic == "1"){styl[iz] = 1}
                if (ic == "2"){styl[iz] = 2}
                if (ic == "3"){styl[iz] = 3}
                if (ic == "4"){styl[iz] = 4}
        }
}


 systm=""
 ver=navigator.appVersion
 Nv=ver.charAt(0)
 len=ver.length
 for(iln=0;iln<len;iln++) if(ver.charAt(iln)=="(") break
 systm = ver.charAt(iln+1).toUpperCase()
 
var ie = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
if(!ie)
{
	document.addEventListener("keydown", keyDown, true);
}
else
{
	document.attachEvent("onkeydown", keyDown);
}



//if ( (Nv >= 4) && ((navigator.appName == 'MSIE') || (navigator.appName == 'Microsoft Internet Explorer')) ) {
        document.write("<div style='position:absolute; left:0; top:0'>");
        document.write("<form name='TetriScript'>");
        document.write("<input type='hidden' name='LINE' size=20 value='SELECT LEVEL'>");
        document.write("<input type='hidden' name='PTS' size=20 value='LEVEL'>");
        document.write("</form>");
        document.write("</div>");
//}
