document.bgColor='#B9FFBC';

done=0;

carry=0;

carryflag=0;

total_items=12;
screen_width=screen.width;
start=0;
nod=0;
swimx=-80;
duck_turn=screen_width-100;
old_sequence=-1;
this_sequence=old_sequence;
helpflag=0;
helpstatus=0;
resetflag=0;
hideflag=0;
hidehelpflag=0;
quitflag=0;
checkflag=0;
checkstatus=0;
levelflag=0;
changelevelflag=0;
yesnoflag=0;
hide=1;
duckx=70;ducky=140;
boardx=64;boardy=308;
level=1;
drag=-1;

this_number=-1;
cardwidth=36;

app="I";
if(navigator.appName=="Netscape") app="N";
if(app=="N" && parseInt(navigator.appVersion)>4) app="N6";
mac=1;if(navigator.appVersion.indexOf("Macintosh")==-1) mac=0;

if (app=="N")  {
doc_ref='document.layers["';
style_ref='"]';
}
else {
if (app=="N6") {
doc_ref='document.getElementById("';
style_ref='").style';
}
else {
doc_ref='document.all["';
style_ref='"].style';
}
}

function moveLayer(layerName,left,top){
eval(doc_ref+layerName+style_ref+'.top=top');
eval(doc_ref+layerName+style_ref+'.left=left');
return false;
}


function hideLayer(layerName){eval(doc_ref+layerName+style_ref+'.visibility="hidden"');}
function showLayer(layerName){eval(doc_ref+layerName+style_ref+'.visibility="visible"');}


// *****************


if (app=="I") {
document.ondragstart = drag_initIE;
document.onmousedown = start_dragIE;
document.onmousemove = dragIE;
document.onmouseup = end_dragIE;
}

if (app=="N") {
document.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN);
document.onmousedown=start_dragNS;
document.onmouseup=end_dragNS;
}

if (app=="N6") {
window.onmousedown=start_dragNS;
window.onmouseup=end_dragNS;
}

function drag_initIE() {
event.returnValue=false;
}

function dragIE() {
if(drag>-1) moveLayer(mapbit,window.event.x-offsetX,window.event.y-offsetY);
lx=window.event.x+20;ly=window.event.y;
if(mac==1) {lx+=document.body.scrollLeft;ly+=document.body.scrollTop;}
move_duck(lx,ly);
}

function dragNS(e) {
if(drag>-1) moveLayer(mapbit,e.pageX-offsetX,e.pageY-offsetY);
move_duck(e.pageX,e.pageY);
}

function end_dragNS(e) {
if (app=="N") {
document.onmousemove=0; 
document.releaseEvents(Event.MOUSEMOVE);
}
else window.onmousemove=0;
if(drag>-1) {
dragpointX=e.pageX;
dragpointY=e.pageY;
thisitem=drag;
drag=-1;
drop_check();
}
return false;
}

function start_dragIE() {
drag=click_check(window.event.x,window.event.y);
}

function start_dragNS(e) {
drag=click_check(e.pageX,e.pageY);
if (drag>-1){
if (app=="N") {
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=dragNS;
}
else window.onmousemove=dragNS;
return false;
}
return false;
}

function click_check(clickX,clickY) {
if(app=="N") {
if(checkflag==true) {do_check();return;}
if(resetflag==true) {do_reset();return;}
if(helpflag==true) {do_help();return;}
if(hideflag==true) {hidetext();return;}
if(quitflag==true) {do_quit();return;}
if(levelflag>0) {set_level(levelflag);return;}
if(changelevelflag>0) {change_level(changelevelflag);return;}
if(yesnoflag==1) {no();return;}
if(yesnoflag==2) {yes();return;}
if(hidehelpflag==true) {hidehelp();return;}
}
if(this_number>-1) {
drag=this_number;
if(number_status[this_number]>-1) {
board_in_use[number_status[this_number]]=-1;
}
number_status[this_number]=-1;
mapbit='block'+this_number;
eval(doc_ref+'block'+this_number+style_ref+'.zIndex=1000');
leftedge=parseInt(eval(doc_ref+mapbit+style_ref+'.left'));
topedge=parseInt(eval(doc_ref+mapbit+style_ref+'.top'));
offsetX=clickX-leftedge;
offsetY=clickY-topedge;
return i;
}
}

function end_dragNS(e) {
if (app=="N") {
document.onmousemove=0; 
document.releaseEvents(Event.MOUSEMOVE);
}
else window.onmousemove=0;
if(drag>-1) {
dragpointX=e.pageX;
dragpointY=e.pageY;
thisitem=drag;
drag=-1;
drop_check();
}
return false;
}

function end_dragIE() {
if(drag>-1) {
dragpointX=window.event.x;
dragpointY=window.event.y;
thisitem=drag;
drag=-1
drop_check();
}
}

function drop_check() {

eval(doc_ref+mapbit+style_ref+'.zIndex=110');

leftedge=parseInt(eval(doc_ref+mapbit+style_ref+'.left'));
topedge=parseInt(eval(doc_ref+mapbit+style_ref+'.top'));
midpoint=leftedge+cardwidth/2;

ok=-1;
for(i=0;i<total_items; i++) {

leftcheck=boardx+i*54+54-27+7;
rightcheck=leftcheck+55;

if((midpoint>leftcheck)&&(midpoint<rightcheck)&&(topedge>boardy-26))  {

nleft=leftcheck+41-8-27;
ok=i;
if(board_in_use[i]>0) ok=-2;
if(topedge>(boardy+40)) ok=-2;
}
}
if(ok==-2)  moveLayer(mapbit,nleft,boardy-40);
if(ok>-1) {
moveLayer(mapbit,nleft,boardy+7);
thisboard=ok;
board_in_use[ok]=this_number;
number_status[this_number]=ok;
checksofar();
}
}




//---------------------


function displayText(text) {
if(app!="I") {
str=messa+'<p id="helpstyle">'+text+messb+'</td></tr></table>';
write_to_layer("textitem");
}
else {
str='<p id="helpstyle">'+text+messb;
this_table=eval("messagetable");
this_row=this_table.rows(0);
this_row.cells(0).innerHTML = str;
}
showLayer("textitem");
}

function do_nod() {
document.duckpic.src="images/dukyes.gif";
setTimeout('do_nod2()',450);
}
function do_nod2() {
document.duckpic.src="images/duck1.gif";
nod++;
if(nod<4) setTimeout('do_nod()',450);
else nod=0;
}


function move_duck(mposx,mposy) {
mposx=mposx-duckx;
mposy=ducky-mposy;
mval=mposx/mposy;

if((mval>=-0.414)&&(mval<=0.414)) {
if(mposy>=0) seg=4;
if(mposy<0) seg=8;
}
if((mval>=0.414)&&(mval<=2.414)) {
if(mposx>=0) seg=3;
if(mposx<=0) seg=7;
}
if((mval<=-0.414)&&(mval>=-2.414)) {
if(mposx<0) seg=5;
if(mposx>0) seg=1;
}
if((mval>=2.414)||(mval<=-2.414)) {
if(mposx>=0) seg=2;
if(mposx<=0) seg=6;
}
eval('document.duckpic.src="images/duck'+seg+'.gif"');
}

// --------------------------------------------


sequence=new Array(total_items);
formula=new Array(4);
tempx=new Array(2);
tempy=new Array(2);
randpos=new Array(total_items);

board_in_use=new Array(total_items);
number_status=new Array(total_items);

startmessage="Laying eggs makes my brain hurt. Can you complete this number sequence for me?";
endmessage="Thank you.<br>Try another sequence.";
messa='<table ID="messagetable" width="300" border="1" cellpadding="6" cellspacing="0" bgcolor="#F2F2FF"><tr><td align="center">';

messb='<br><a href="javascript:hidetext()" onmouseover="hideflag=true" onmouseout="hideflag=false"><img src="images/ok.gif" width="24" height="20" border="0"></a>';


if(app=="N") w('<layer id="bg" position=absolute left=0 top=0 height=200 z-index=0><table border="0" cellpadding="0" cellspacing="0" bgcolor="#B9FFBC" height="'+innerHeight+'" width="'+innerWidth+'"><tr><td>&nbsp; </td></tr></table></layer>');

makelayer('back','visible',0,0,screen.width,363,0);
w('<table border="0" cellpadding="0" cellspacing="0" background="images/back.jpg" height="363" width="'+screen.width+'"><tr><td>&nbsp; </td></tr></table>');
endbit();

makelayer('reeds1','visible',270,188,57,109,10);
w('<img src="images/reeds1.gif" width="57" height="109">');
endbit();

makelayer('reeds2','visible',600,135,29,160,10);
w('<img src="images/reeds2.gif" width="29" height="160">');
endbit();

makelayer('duck','visible',duckx-70,ducky,132,160,100);
w('<img src="images/blank.gif" width="5" height="10"><img name="duckpic" src="images/duck1.gif" width="126" height="107"><br><img src="images/body.gif" width="110" height="150">');
endbit();

makelayer('swim','visible',swimx,240,69,55,20);
w('<img name="swimpic" src="images/swimr.gif" width="69" height="55">');
endbit();

makelayer('baby','visible',swimx-148,256,137,38,19);
w('<img name="babypic" src="images/babyr.gif" width="137" height="38">');
endbit();

makelayer('title','visible',250,6,229,54,10);
w('<img src="images/title.gif" width="229" height="54">');
endbit();

// **** boards ****

for(i=0;i<total_items; i++) {
makelayer('boardback'+i,'visible',boardx+i*54,boardy,86,50,5);
w('<img src="images/board.gif" width="86" height="50">');
endbit();
}


// **** blank cards ****

cardoffsetX=36;
cardoffsetY=3;
if(mac==1) {cardoffsetX=41;cardoffsetY=7;}


for(i=0;i<total_items; i++) {
makelayer('block'+i,'visible',-100,0,40,30,100);
w('<table border="1" ID="table'+i+'" cellpadding="4" cellspacing="0" bgcolor="#0000FF" width="'+cardwidth+'"><tr><td></td></tr></table>');
endbit();
}



//--------------------------------------------


makelayer('textitem','hidden',140,140,300,100,155);
w(messa+'<p id="helpstyle">'+startmessage+messb+'</td></tr></table>');
endbit();

egg0bit='<a href="javascript:do_help()" onMouseover="helpflag=true" onMouseout="helpflag=false"><img src="buttons/help';
egg1bit='<a href="javascript:do_check()" onMouseover="checkflag=true" onMouseout="checkflag=false"><img src="buttons/check';
egg2bit='<a href="javascript:do_reset()" onMouseover="resetflag=true" onMouseout="resetflag=false"><img src="buttons/new';
egg3bit='<a href="javascript:do_quit()" onMouseover="quitflag=true" onMouseout="quitflag=false"><img src="buttons/quit';

for(i=0;i<4;i++) {
makelayer('shad'+i,'hidden',180+i*100,390,76,32,149);
w('<img src="buttons/shadow.gif" width="76" height="32">');
endbit();

makelayer('butt'+i,'hidden',200+i*100,370,56,45,150);
w(eval('egg'+i+'bit')+'.gif" width="56" height="45" border="0"></a>');
endbit();
}

messagebit1='<table ID="yesnotable" border="1" cellpadding="6" cellspacing="0" bgcolor="#F2F2FF"><tr><td align="center">';

messagebit2='<a href="javascript:no()" onmouseover="yesnoflag=1" onmouseout="yesnoflag=0"><img src="images/no.gif" width="24" height="20" border="0"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:yes()" onmouseover="yesnoflag=2" onmouseout="yesnoflag=0"><img src="images/yes.gif" width="24" height="20" border="0"></a>';

makelayer('yesno','visible',-500,0,140,100,7000);
w(messagebit1+messagebit2+'</td></tr></table>');
endbit();


// *** start text ***

makelayer('start','visible',200,150,400,60,7000);
w('<table border="1" cellspacing="0" bgcolor="#F2F2FF"><tr><td><div align="center"><center>');
w('<table border="0" cellpadding="6" cellspacing="0" bgcolor="#F2F2FF"><tr><td align="center"><font face="Arial">Please choose a level.</font></td></tr><tr><td align="center">');
for(i=1;i<4; i++) {
w('<a href="javascript:set_level('+i+')" onMouseover="levelflag='+i+'" onMouseout="levelflag=0"><img src="images/level'+i+'.gif" width="40" height="20" border="0"></a>');
if(i<3) w('&nbsp;&nbsp;'); 
}
w('</td></tr><tr><td align="center"><small><font face="Arial">You can change it later.</font></small></td>');
w('</tr></table></center></div></td></tr></table>');
endbit();

// *** set level ***

makelayer('levels','hidden',4,48,62,60,10);
for(i=1;i<4; i++) {
w('<a href="javascript:change_level('+i+')" onMouseover="changelevelflag='+i+'" onMouseout="changelevelflag=0"><img name="lev'+i+'" src="buttons/lev'+i+'a.gif" width="58" height="23" border="0"></a><br><img src="images/blank.gif" width="10" height="4" border="0">');
}
endbit();

// *** help notes ***

helpbit='</p><div align="center"><center><table border="0" cellpadding="7" cellspacing="0" bgcolor="#F2F2FF"><tr><td>';
ap="'";

for(i=1;i<4; i++) {
makelayer('helpnotes'+i,'hidden',130,20,600,200,7000);

w('<table border="1" cellpadding="4" cellspacing="0" bgcolor="#F2F2FF"><tr><td><h1 align="center">Level '+i+' example</h1><p id="helpstyle">This sequence is made by ');

if(i==1) {
w('adding 3 each time.');
w(helpbit);
bnbit("&nbsp;&nbsp;2");nbit("+ 3 =");bnbit("&nbsp;&nbsp;5");nbit("+ 3 =");bnbit("&nbsp;&nbsp;8");nbit("+ 3 =");bnbit("11");
hend();
}
if(i==2) {
w('multiplying by 3 and adding 2.');
w(helpbit);
bnbit("&nbsp;&nbsp;2");nbit("x 3 =");bnbit("&nbsp;&nbsp;6");nbit("+ 2 =");bnbit("&nbsp;&nbsp;8");nbit("x 3 =");bnbit("24");nbit("+ 2 =");bnbit("26");
hend();
}
if(i==3) {
w(':<br>multiplying by 3, adding 5, and subtracting 8.');
w(helpbit);
bnbit("&nbsp;&nbsp;2");nbit("x 3 =");bnbit("&nbsp;&nbsp;6");nbit("+ 5 =");bnbit("11");nbit("- 8 =");bnbit("&nbsp;&nbsp;3");
hend();
}

endbit();
}

window.focus();

// -----------------------------------------


function set_level(L) {
moveLayer("start",-500,0);
eval('document.lev'+L+'.src="buttons/lev'+L+'b.gif"');
showLayer("levels");
level=L;
for(i=0;i<4;i++) {eval('showLayer("shad'+i+'")');eval('showLayer("butt'+i+'")');}
make_cards();
do_swimright();
}

function change_level(L) {
for(i=1;i<4; i++) {
gif="a";if(i==L) gif="b";
eval('document.lev'+i+'.src="buttons/lev'+i+gif+'.gif"');
}
level=L;
if(done==0) {done=1;displayText("The level will change when you do the next sequence.");}
}

function make_cards() {

zdata='adata';seqtotz=seqtota;
if(level==2) {zdata='bdata';seqtotz=seqtotb;}
if(level==3) {zdata='cdata';seqtotz=seqtotc;}

hide=1;
while(this_sequence==old_sequence) {this_sequence=get_random(seqtotz);}
old_sequence=this_sequence;

num1=parseInt(eval(zdata+this_sequence+'[0]'));
num2=parseInt(eval(zdata+this_sequence+'[1]'));
sequence[0]=get_random(num2-num1+1)+num1;

formula[0]=eval(zdata+this_sequence+'[2]');
if(level>1) formula[1]=eval(zdata+this_sequence+'[3]');
if(level==3) formula[2]=eval(zdata+this_sequence+'[4]');
a=0;
for(i=1;i<total_items; i++) {
sequence[i]=eval(sequence[i-1]+formula[a]);
a++;
if(a==level) a=0;
}
randomise();

for(i=0;i<total_items; i++) {

thisnum=sequence[i];
if(thisnum<10) thisnum="&nbsp;&nbsp;&nbsp;&nbsp;"+thisnum;
else if(thisnum<100) thisnum="&nbsp;&nbsp;"+thisnum;

if(app=="I") {
str='<a href="javascript:void()" onMouseover="this_number='+i+'" onMouseout="this_number=-1"><SPAN Class="numstyle">'+thisnum+'</SPAN></a>';
this_table=eval("table"+i);
this_row=this_table.rows(0);
this_row.cells(0).innerHTML = str;
}
else {
str='<table border="1" cellpadding="4" cellspacing="0" bgcolor="#0000FF"><tr><td><a href="javascript:void()" onMouseover="this_number='+i+'" onMouseout="this_number=-1"><SPAN Class="numstyle">'+thisnum+'</SPAN></a></td></tr></table>';

write_to_layer('block'+i);
}
board_in_use[i]=-1;
number_status[i]=-1;

j=randpos[i];
ttop=70+(j%2)*40;
tleft=100+(j+(j+1)%2)*40;
if(i<4) {tempx[i]=tleft;tempy[i]=ttop;}

eval('moveLayer("block'+i+'",tleft,ttop)');
}
c=0;setTimeout("do_cards()",500);
}

function do_cards() {
endflag=0;
distx=tempx[c]-(boardx+c*54+cardoffsetX);
disty=tempy[c]-(boardy+cardoffsetY);
stepx=distx/12;
stepy=disty/12;

v=1;do_cards2();
}
function do_cards2() {
eval('moveLayer("block'+c+'",tempx[c]-stepx*v,tempy[c]-stepy*v)');

v++;
if(v<13) setTimeout("do_cards2()",50);
else {

board_in_use[c]=c;
number_status[c]=c;

c++;
if(c<(level+1)) setTimeout("do_cards()",50);
else {
hide=0;
if(start==0)showLayer("textitem");
start=1;
}
}
}


function set_flag(fl) {
if(carry==1) flag=fl;
}

function unset_flag() {
flag=-1;
}

function set_carryflag(fl) {
carryflag=1;
}

function unset_carryflag() {
carryflag=0;
}



function getnum(tn) {
if((carry==1)&&(carryflag==1)) return;
carry=1;
this_number=tn;
if(number_status[this_number]>-1) {
board_in_use[number_status[this_number]]=-1;
}
number_status[this_number]=-1;
setZ(100);
for(i=0;i<total_items; i++) {if(board_in_use[i]==-1)showLayer('board'+i);}
duckling();
}

function dropnum(tb) {
if(flag==-1) return;
flag=-1;
carry=0;
thisboard=tb;
moveLayer('block'+this_number,boardx+tb*54+cardoffsetX,boardy+cardoffsetY);
board_in_use[tb]=this_number;
number_status[this_number]=tb;
duckling();
checksofar();
}


function checksofar() {
finished=0;
for(i=0;i<total_items; i++) {
if(board_in_use[i]==i) finished++;
}
if(finished==total_items) {
setTimeout('do_nod()',450);
endflag=1;
displayText(endmessage);
}
}

function do_check() {
if(checkstatus==1) {hideLayer('textitem');checkstatus=0;return;}
checkstatus=1;
if(hide==0) {
moveLayer("butt1",300,360);
moveLayer("shad1",270,395);
hidehelp();
setTimeout("do_check2()",200);
}
}
function do_check2() {
duckling();
moveLayer("butt1",300,370);
moveLayer("shad1",280,390);
finished=0;
for(i=0;i<total_items; i++) {
nn=board_in_use[i];
if(nn==i) finished++;
else if(nn>-1){
moveLayer('block'+nn,boardx+i*54+cardoffsetX,boardy-40);
board_in_use[i]=-1;
number_status[nn]=-1;
}
}
finitem=" numbers";
if(finished==1) finitem=" number";
displayText("The sequence has "+finished+" correct "+finitem+".");
}


function do_swimleft() {
swimdir=1;
swimx-=2;
moveLayer("swim",swimx,240);
moveLayer("baby",swimx+80,256);
if(swimx>-220)setTimeout('do_swimleft()',50);
else {
document.swimpic.src="images/swimr.gif";
document.babypic.src="images/babyr.gif";
swimx=-80;
setTimeout('do_swimright()',50);
}
}

function do_swimright() {
swimdir=0;
swimx+=2;
moveLayer("swim",swimx,240);
moveLayer("baby",swimx-148,256);
if(swimx<duck_turn)setTimeout('do_swimright()',50);
else {
document.swimpic.src="images/swiml.gif";
do_turn();
}
}

function do_turn() {
swimx-=2;
moveLayer("swim",swimx,240);
if(swimx>(duck_turn-228))setTimeout('do_turn()',50);
else {
document.babypic.src="images/babyl.gif";
setTimeout('do_swimleft()',50);
}
}

function duckling() {
if(swimdir==0)document.babypic.src="images/babyr.gif";
else document.babypic.src="images/babyl.gif";
}

function hidetext() {
if(helpstatus==1) helpstatus=0;
if(checkstatus==1) checkstatus=0;
hideLayer('textitem');
if(endflag==1) make_cards();
}


function do_help() {
if(helpstatus==1) {hideLayer('helpnotes1');hideLayer('helpnotes2');hideLayer('helpnotes3');helpstatus=0;return;}
hidetext();
helpstatus=1;
if(hide==0) {
moveLayer("butt0",200,360);
moveLayer("shad0",170,395);
setTimeout("do_help2()",200);
}
}
function do_help2() {
duckling();
moveLayer("butt0",200,370);
moveLayer("shad0",180,390);

showLayer("helpnotes"+level);
}

function hend() {

w('</td></tr></table></center></div><div align="center"><center><table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#FFFFFF">');

w('<tr><td><hr></td></tr><tr><td><P id="test">You have to complete Duck\'s number sequence.<br>Click on a number to pick it up, and then click on a board to drop it.<br>');
w('Use the <b>check</b> button to see how well you are doing.<br>');

w('<center><div><a href="javascript:hidehelp()" onmouseover="hidehelpflag=true" onmouseout="hidehelpflag=false"><img src="images/ok.gif" width="24" height="20" border="0"></a></center></div></td></tr></table></center></div></td></tr></table>');

}
function bnbit(nbit) {w('<table border="1" cellpadding="4" cellspacing="0" bgcolor="#0000FF"><tr><td><SPAN Class="numstyle">&nbsp;'+nbit+'&nbsp;</SPAN></td></tr></table>');}

function nbit(nbit) {w('</td><td><font color="#FF0000" face="Arial"><strong>'+nbit+'</strong></font></td><td>');}


function hidehelp() {
if(helpstatus==1) helpstatus=0;
hideLayer("helpnotes"+level);
}

function do_reset(){
if(hide==0) {
moveLayer("butt2",400,360);
moveLayer("shad2",370,395);
hidetext();
hidehelp();
setTimeout("do_reset2()",200);
}
}
function do_reset2(){
duckling();
moveLayer("butt2",400,370);
moveLayer("shad2",380,390);
yesno('You will lose this sequence.<br>Is that all right?<br>',300,280,"make_cards");
}


function do_quit() {
if(hide==0) {
moveLayer("butt3",500,360);
moveLayer("shad3",470,395);
hidetext();
hidehelp();
setTimeout("do_quit2()",200);
}
}
function do_quit2() {
duckling();
moveLayer("butt3",500,370);
moveLayer("shad3",480,390);
yesno('Are you sure you want to quit?<br>',400,300,"close_window");
}

function close_window() {
window.close();
}

function randomise() {
randpos[0]=get_random(total_items);
for(i=1;i<total_items; i++) {
ok=false;
while(ok==false) {
randpos[i]=get_random(total_items);
ok2=true;
for(j=0;j<i; j++) {
if(randpos[i]==randpos[j]) ok2=false;
}
if(ok2==true) ok=true;
}
}
}

function get_random(R) {return parseInt(Math.random()*1000)%R;}



//**** yes/no ****

function yesno(message,ynx,yny,thisfunc) {
func=thisfunc;
hide=1;
if(app!="I") {
str=messagebit1+'<p id="helpstyle">'+message+messagebit2+'</td></tr></table>';
write_to_layer("yesno");
}
else {
str='<p id="helpstyle">'+message+messagebit2;
this_table=eval("yesnotable");
this_row=this_table.rows(0);
this_row.cells(0).innerHTML = str;
}
moveLayer("yesno",ynx,yny);
showLayer("yesno");
}

function no(){
hide=0;
moveLayer("yesno",-500,-500);
hideLayer("yesno");
}

function yes(){
hide=0;
moveLayer("yesno",-500,-500);
hideLayer("yesno");
eval(func+"()");
}


// ---------------

function write_to_layer(layer) {
if (app=="N") {with (document.layers[layer].document) {open();write(str);close();}}
else
if (app=="N6") {
eval(doc_ref+layer+'").innerHTML=str');
}
else document.all[layer].innerHTML=str;
}

function makelayer(name,vis,left,top,width,height,z) {
if(app=="N") w('<layer id="'+name+'" position=absolute visibility='+vis+' left='+left+' top='+top+' width='+width+' height='+height+' z-index='+z+';>');
else w('<div id="'+name+'" STYLE="position:absolute;visibility:'+vis+';left:'+left+';top:'+top+';width:'+width+';height:'+height+';z-index:'+z+';">');
}

function w(cont) {
document.write(cont);
}

function endbit() {
if (app=="N") w('</layer>');
else w('</div>');
}

function setZ(z) {
eval(doc_ref+'["block'+this_number+'"]'+style_ref+'.zIndex+=z');
}
