Randomly Tiled Image HTML Backgrounds


I had previously described an app for painting with images. This app permits the creation of randomly tiled images for web page backgrounds.

This is an example:

If the tiled background is too distracting, it can be given some transparency:

To try the app click here

to download the app, including images with transparent backgrounds click here

Here is the code:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head profile=”http://gmpg.org/xfn/11″&gt;
<title>Tile BK</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal 800 24px Arial; color: white}
a{ text-decoration: }:link { color: rgb(0, 0, 255) }:visited {color :rgb(100, 0,100) }:hover { }:active { }

</style>
</head>
<body>
<di id=”canvas” style=”position: absolute; width:900px; height: 600px; left: 50%; margin-left: -450px; top: 50px; overflow: hidden; opacity:0.90;filter:alpha(opacity=90)”></di>
<di id=”div1″ style=”position: absolute; width:900px; height: 600px; left: 50%; margin-left: -450px; top: 50px; text-align: center”><br /><br /><br />
This is a test</di>

var lft = -40; var tp = 10; var ht = 150; var wd = 150; var bkc = “”;

var val = prompt(“Choose Image: leaf – 1 leaf2 – 2 daisy – 3 butterfly – 4 bow – 5 ring – 6 flower – 7 flower2 – 8 flower3 – 9 egg – 10 Opacity: 0 – 100”, “1, 90”);

if (val.indexOf(“,”) > 1) {
var im = val.substr(0,2);
} else {
im = val.substr(0,1);
}

var im1 =””;
if (im == “1”) {
im1 = “images/leaf.gif”; bkc = “#77aa77”;
}
if (im == “2”) {
im1 = “images/leaf2.gif”; bkc = “#668866”;
}
if (im == “3”) {
im1 = “images/daisy.gif”; bkc = “#ee8800”;
}
if (im == “4”) {
im1 = “images/butterfly.gif”; bkc = “#dd8800”;
}
if (im == “5”) {
im1 = “images/bow.gif”; bkc = “#cc0000”;
}
if (im == “6”) {
im1 = “images/ring.gif”; bkc = “#33bb33”;
}
if (im == “7”) {
im1 = “images/flower.gif”; bkc = “#ee7700”;
}
if (im == “8”) {
im1 = “images/flower2.gif”; bkc = “#ddddee”;
}
if (im == “9”) {
im1 = “images/flower3.gif”; bkc = “#9900bb”;
}
if (im == “10”) {
im1 = “images/egg.gif”; bkc = “#bb0000”;
}
if (val.indexOf(“,”) > 1) {
var opc = val.substr(3);
} else {
opc = val.substr(2);
}

for (var i=1; i ‘;
document.getElementById(“d” + i).style.left = lft + “px”;
document.getElementById(“d” + i).style.top = tp + “px”;
document.getElementById(“d” + i).style.width = wd + “px”;
document.getElementById(“d” + i).style.height = ht + “px”;
}
document.getElementById(“canvas”).style = “position: absolute; width:900px; height: 600px; left: 50%; margin-left: -450px; top: 50px; background:” + bkc + “; overflow:hidden; opacity:” + opc/100 + “;filter:alpha(opacity=” + opc + “) “;

</body></html>


The background is placed in a division called canvas:
<di id=”canvas” style=”position: absolute; width:900px; height: 600px; left: 50%; margin-left: -450px; top: 50px; overflow: hidden; opacity:0.90;filter:alpha(opacity=90)”></di>

Superimposed is a division in which the bulk of the page is created. In this case I just added some text, but anything can be placed there:
<di id=”div1″ style=”position: absolute; width:900px; height: 600px; left: 50%; margin-left: -450px; top: 50px; text-align: center”><br /><br /><br />
This is a test</di>

I could have placed a control panel that could be hidden, but for simplicity’s sake I just used a prompt for input of image and transparency:
var val = prompt(“Choose Image: leaf – 1 leaf2 – 2 daisy – 3 butterfly – 4 bow – 5 ring – 6 flower – 7 flower2 – 8 flower3 – 9 egg – 10 Opacity: 0 – 100”, “1, 90”);

The prompt is parsed to get the image and opacity:
if (val.indexOf(“,”) > 1) {
var im = val.substr(0,2);
} else {
im = val.substr(0,1);
}

if (val.indexOf(“,”) > 1) {
var opc = val.substr(3);
} else {
opc = val.substr(2);
}

The images are randomly tiled:
for (var i=1; i <= 500; i ++) {
lft = 900*Math.random() – 50;
tp = 600*Math.random() – 50;

document.getElementById(“canvas”).innerHTML += ‘<img id = “d’ + i + ‘” src=”‘ + im1 + ‘” style = “position:absolute;” />’;
document.getElementById(“d” + i).style.left = lft + “px”;
document.getElementById(“d” + i).style.top = tp + “px”;
document.getElementById(“d” + i).style.width = wd + “px”;
document.getElementById(“d” + i).style.height = ht + “px”;
}

Since there is no guarantee that every part of canvas will be covered by a tile, its background is changed to blend with the image being applied:
if (im == “1”) {
im1 = “images/leaf.gif”; bkc = “#77aa77”;
}
if (im == “2”) {
im1 = “images/leaf2.gif”; bkc = “#668866”;
}
if (im == “3”) {
im1 = “images/daisy.gif”; bkc = “#ee8800”;
}
if (im == “4”) {
im1 = “images/butterfly.gif”; bkc = “#dd8800”;
}
if (im == “5”) {
im1 = “images/bow.gif”; bkc = “#cc0000”;
}
if (im == “6”) {
im1 = “images/ring.gif”; bkc = “#33bb33”;
}
if (im == “7”) {
im1 = “images/flower.gif”; bkc = “#ee7700”;
}
if (im == “8”) {
im1 = “images/flower2.gif”; bkc = “#ddddee”;
}
if (im == “9”) {
im1 = “images/flower3.gif”; bkc = “#9900bb”;
}
if (im == “10”) {
im1 = “images/egg.gif”; bkc = “#bb0000”;
}

The choice that selects the image also selects the background color, which is applied to the canvas, and applies the opacity:
document.getElementById(“canvas”).style = “position: absolute; width:900px; height: 600px; left: 50%; margin-left: -450px; top: 50px; background:” + bkc + “; overflow:hidden; opacity:” + opc/100 + “;filter:alpha(opacity=” + opc + “) “;

Curtain Falling for Slide Show Transition


This post simulates a curtain fall for a slide change.

To view Click Here

Here is the code:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head profile=”http://gmpg.org/xfn/11″&gt;
<title>Fade</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal normal 15px Arial;}
a{ text-decoration: }:link { color: rgb(0, 0, 255) }:visited {color :rgb(100, 0,100) }:hover { }:active { }
td{position:relative ; width:100% ;left: 0; top: 0 }
</style>
</head>
<body onload=’init();’>
<table style= “position:absolute ; width:100% ; height:100% ; left:0 ; top:0 ; “>
<tr><td valign=”center”>
<center><di id=”frame” style= “position: relative ; width:400px ; height: 400px ; overflow: hidden “>
<img src= “file://D:/My Pictures/A-E/aloe.png” style=”position: absolute; width: 400px; left: 0; top: 0″ />
<img id=”frame2″ src=”images/curtain.png” style= “position: absolute ; width:400px ; height: 600px; top: -600px; left: 0 ” />
</di></center>
</td></tr></table>

var si; var vpos = -400; var drp = true; var cnt = 0;

function init() {
setInterval(“control()”,7000);
}

function control() {
cnt ++;
si = setInterval(“drop()”,7);
}

function drop() {
if (vpos -4) {
if (cnt % 2 == 1) {
document.getElementById(“frame”).innerHTML = ‘‘;
} else {
document.getElementById(“frame”).innerHTML = ‘‘;
}
drp = false;
}

if (vpos > -600 && ! drp ) {
vpos -= 3;
}
if (vpos
</body></html>


The general concept is the same as before, using two timers.

An image of a curtain is placed inside the division that displays the slides.

It is positioned to be above the top of the division and overflow: hidden prevents it from being seen until it starts to fall:
<center><di id=”frame” style= “position: relative ; width:400px ; height: 400px ; overflow: hidden “>
<img src= “file://D:/My Pictures/A-E/aloe.png” style=”position: absolute; width: 400px; left: 0; top: 0″ />
<img id=”frame2″ src=”images/curtain.png” style= “position: absolute ; width:400px ; height: 600px; top: -600px; left: 0 ” />
</di></center>

A boolean variable, drp, originally true, determines whether the curtain falls or rises.

When the curtain is down and the image is covered, it is replaced with a new one so the curtain rises with a new image exposed:
if (vpos > -4) {
if (cnt % 2 == 1) {
document.getElementById(“frame”).innerHTML = ‘<img src= “file://D:/My Pictures/A-E/aloe.png” style=”position: absolute; width: 400px; left: 0; top: 0″ /><img id=”frame2″ src=”images/curtain.png” style= “position: absolute ; width:400px ; height: 600px; top: -400px; left: 0 ” />’;
} else {
document.getElementById(“frame”).innerHTML = ‘<img src= “file://D:/My Pictures/A-E/Daffodil.jpg” style=”position: absolute; width: 400px; left: 0; top: 0″ /><img id=”frame2″ src=”images/curtain.png” style= “position: absolute ; width:400px ; height: 600px; top: -400px; left: 0 ” />’;
}
drp = false;
}

As before I am alternating two images, but it could be written to sequentially display multiple images.

When the curtain is fully up, the second timer is stopped, allowing the image to be viewed until the first timer restarts it:
if (vpos < -596) {
clearInterval(si);
drp = true;
}

HTML – Painting With Images


This app allows painting with an image.
It works best with an image that has a transparent background.

Here is an example of how it could look:

To try it click here

Here is the code:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head profile=”http://gmpg.org/xfn/11″&gt;
<title>Image Painter</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal normal 15px Arial; white-space: pre-wrap}
a{ text-decoration: }:link { color: rgb(0, 0, 255) }:visited {color :rgb(100, 0,100) }:hover { }:active { }
input{ width: 70px}
</style>
</head>
<body>
<di id=”canvas” style=”position: absolute; width:100%; height: 100%; left: 0; top: 0; background: #eeeeee” onclick=’go();’></di>
<table id=”table1″ style=”position: absolute; left: 0; top: 0;” >
<tr><td><input type=”text” id=”t1″ name=”t1″ value=”width(px)” /> <input type=”text” id=”t2″ name=”t2″ value=”height(px)” /> <input type=”text” id=”t3″ name=”t3″ value=”hspace(px)” /> <input type=”text” id=”t4″ name=”t4″ value=”vspace(px)” />
</td></tr>
</table>

var posX; var posY; var cnt = 0; var wd = 80; var ht = 80; var lft = 0; var tp = 0; var drw = false; hspace = 64; vspace=64;

document.getElementById(“t1”).focus();
document.getElementById(“t1”).select();

var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE);
document.onkeyup = getMouse2;
document.onmousemove = getMouseXY;

function go() {
if (drw) {
drw = false;
} else {
drw = true;
}
wd = parseInt(document.getElementById(“t1”).value);
ht = parseInt(document.getElementById(“t2”).value);
hspace = parseInt(document.getElementById(“t3”).value);
vspace = parseInt(document.getElementById(“t4”).value);
}

function getMouse2(e) {
if (e.keyCode == 13) {
if (drw) {
drw = false;
} else {
drw = true;
}
}

wd = parseInt(document.getElementById(“t1”).value);
ht = parseInt(document.getElementById(“t2”).value);
hspace = parseInt(document.getElementById(“t3”).value);
vspace = parseInt(document.getElementById(“t4”).value);
}

function getMouseXY(e) {
if (drw) {
if (IE ) {
posX = event.clientX + document.body.scrollLeft;
posY = event.clientY + document.body.scrollTop;
}
else {
posX = e.pageX ;
posY = e.pageY ;
}

if ((Math.abs(posX – lft) > hspace || Math.abs(posY – tp) > vspace) && posY > 40) {
cnt ++;
document.getElementById(“canvas”).innerHTML += ‘‘;
// document.getElementById(“d” + cnt).style.borderRadius = wd + “px”;
document.getElementById(“d” + cnt).style.left = posX-5 + “px”;
document.getElementById(“d” + cnt).style.top = posY-5 + “px”;
document.getElementById(“d” + cnt).style.width = wd + “px”;
document.getElementById(“d” + cnt).style.height = ht + “px”;
lft = posX;
tp = posY;
}
}
}

</body></html>


There are two ways to start and stop drawing: move the pointer to the starting point and either hit Enter or click.
Then draw and hit Enter or click to stop.

the first uses document.onkeyup = getMouse2:
function getMouse2(e) {
if (e.keyCode == 13) {
if (drw) {
drw = false;
} else {
drw = true;
}
}

wd = parseInt(document.getElementById(“t1”).value);
ht = parseInt(document.getElementById(“t2”).value);
hspace = parseInt(document.getElementById(“t3”).value);
vspace = parseInt(document.getElementById(“t4”).value);
}

The second uses go():
function go() {
if (drw) {
drw = false;
} else {
drw = true;
}
wd = parseInt(document.getElementById(“t1”).value);
ht = parseInt(document.getElementById(“t2”).value);
hspace = parseInt(document.getElementById(“t3”).value);
vspace = parseInt(document.getElementById(“t4”).value);
}

The drawing is done by getMouseXY
function getMouseXY(e) {
if (drw) {
if (IE ) {
posX = event.clientX + document.body.scrollLeft;
posY = event.clientY + document.body.scrollTop;
}
else {
posX = e.pageX ;
posY = e.pageY ;
}

if ((Math.abs(posX – lft) > hspace || Math.abs(posY – tp) > vspace) && posY > 40) {
cnt ++;
document.getElementById(“canvas”).innerHTML += ‘<img id = “d’ + cnt + ‘” src=”images/leaf.gif” style = “position:absolute;” />’;
// document.getElementById(“d” + cnt).style.borderRadius = wd + “px”;
document.getElementById(“d” + cnt).style.left = posX-5 + “px”;
document.getElementById(“d” + cnt).style.top = posY-5 + “px”;
document.getElementById(“d” + cnt).style.width = wd + “px”;
document.getElementById(“d” + cnt).style.height = ht + “px”;
lft = posX;
tp = posY;
}
}
}

The width and height of the image as well as the spacing between image repeats is set by values in the text boxes at the top.
wd = parseInt(document.getElementById(“t1”).value);
ht = parseInt(document.getElementById(“t2”).value);
hspace = parseInt(document.getElementById(“t3”).value);
vspace = parseInt(document.getElementById(“t4”).value);

A Practical Application of Click()


This expansion of the custom pace band calculator incorporates the click() simulator to make multiple clicks with a single one. It also opens a print dialog to allow printing the list.

To try click here

Here is the code:

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'&gt;
<html xmlns='http://www.w3.org/1999/xhtml'&gt;
<head profile='http://gmpg.org/xfn/11'&gt;
<title>Pace</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal normal 15pt Arial;}a{ text-decoration: }:link { color: rgb(0, 0, 255) }:visited {color :rgb(100, 0,100) }:hover { }:active { }
#t1, #t2{position: relative}
td{position: relative; padding: 5px}
#r1, #r2, #c1 {width: 15px}
#hours, #minutes, #seconds, #remain{width: 55px}
#dist{width: 100px}
#split{width: 250px; font:normal normal 800 18pt Arial; text-align: left}
#remain2{width: 64px}
</style>
</head>
<body>
<table id = “t1″ align=”center”>
<tr>
<td valign = “top”><select id=”dist” name=”dist” onchange=’document.getElementById(“hours”).focus();document.getElementById(“hours”).select();’>
<option >Distance</option>
<option >5K</option>
<option >8K</option>
<option >5Mi</option>
<option >10K</option>
<option >12K</option>
<option >15K</option>
<option >10Mi</option>
<option >20K</option>
<option >Half Marathon</option>
<option >25K</option>
<option >30K</option>
<option >20Mi</option>
<option >Marathon</option>
<option >50K</option>
<option >50Mi</option>
<option >100K</option>
<option >100Mi</option>
</select> </td>
<td valign = “top”><input type=”text” id=”hours” name=”hours” value=”Hours” /></td><td valign = “top”><input type=”text” id=”minutes” name=”minutes” value=”Minutes” /></td><td valign = “top”><input type=”text” id=”seconds” name=”seconds” value=”Seconds” /></td><td valign = “top”>&nbsp&nbsp&nbspsplits (miles or km) <input type=”radio” id=”r1″ name=”r1″ value=”Mi” checked />Miles<input type=”radio” id=”r1″ name=”r1″ value=”Km” />Km&nbsp&nbsp&nbsp</td>
<td valign = “top”><input type=”checkbox” id=”c1″ name=”c1″ value=”custom” />Custom</td><td valign = “top”><textarea id=”split” name=”split” rows=” ” cols=” ” onclick=’viw();’ ></textarea></td><td valign = “top”><input type=”text” id=”remain” name = “remain” Value=”Remain” /> <input type=”text” id=”remain2″ name = “remain2″ Value=”Av Rem” /></td><td valign = “top”><input type=”button” id=”calc” name=”calc” value=”Calculate” onclick=’calc();’ /> <!– <input type=”button” id=”fs” name=”fs” value=”Reduce Font” onclick=’fsize();’ />–></td></tr>
</table>
<table id=”t1″>
<tr><td><input type=”radio” id=”r2″ name=”r2″ value=”Ti” checked />Time<input type=”radio” id=”r2″ name=”r2″ value=”Pa” />Pace<input type=”radio” id=”r2″ name=”r2″ value=”Bo” />Both<input type=”radio” id=”r2″ name=”r2″ value=”2Pa” />2Pace</td> <td><input type=”text” id=”el” style= “position: ; width:900px ; height: ; left: ; top: ; ” name=”el” value=”0,0,0,0,0,0,0,0,0,0,0,0,0,0,” /></td>
</tr>
<table>

var ht = 0; var tm; var dst; var dst2; var splt; var pace1 = 0; var pace2 = 0; var secs = 0; var hrs = 0; var kms = false; var custsplt; var j = 0; var str = “”; var secs2; var hrs1; var mins1; var secs1; var fsze = 18; var remsplit; var remsecs; var remmins; var remsplit2; var str2 = “”; var tim = false; var pce = false; var bth = false; var pces = false; var a = 0; var b = -1; echange2 = new Array(); var a1; var a2; var arno = 0;

document.onkeyup = keyaction;

alert(“Instructions:\nChoose Distance\nEnter Overall Time\nLeaving Text Equivalent to Entering 0\nHit Enter or Click Calculate to Get Even Splits\n\nCustomized Splits:\nCheck Custom\nHit Calculate or Enter again\nIf there is a significant elevation change in the fraction after the last split, compensate by adjusting the overall time, eg: if the last near mile in an 8K has a significant uphill, lower the overall time to allow for the slowing.\n\nWhen all splits hace been displayed, the page can be printed.\nTo do another time, click the pace list\n\nFor KM Splits Check Km box before Entering Anything\n\nListing Choice:\nCheck Box with Listing Choice Before Entries\nTimes Only\nAverage Pace Only\nBoth\nAverage Pace and Average Pace for Remaining Splits to Get Desired Time”);

function keyaction(e) {
if (e.keyCode == 13) calc();
if (e.keyCode == 16) fsize();
if (e.keyCode == 18) chck();
}

document.getElementById(“dist”).focus();

function viw() {
document.getElementById(“t1”).style.visibility = “visible”;
//document.getElementById(“fs”).style.visibility = “visible”;
}

function chck() {
document.getElementById(“c1”).checked = true;
document.getElementById(“minutes”).value = “”;
}

/*function fsize() {
fsze -= 1;
document.getElementById(“split”).style.fontSize = fsze + “pt”;
}*/

function calc() {

var doc = document.getElementById(“el”).value;

for (var i = 0; i -1){
dst = dst.substr(0, dst.length – 1) + “.0”;
if (kms) dst2 = parseFloat(dst);
if (! kms) dst2 = .621*parseFloat(dst);
}

else if (dst.indexOf(“Mi”) > -1){
dst2 = parseFloat(dst.substr(0, dst.length – 2) + “.0”);
if (kms) dst2 = parseFloat(dst.substr(0, dst.length – 2) + “.0”) / .621;
}

else if (dst.indexOf(“alf”) > -1){
if (! kms) dst2 = 13.105;
if (kms) dst2 = 21.05;
}

else {
if (! kms) dst2 = 26.21;
if (kms) dst2 = 42.1;
}

if (document.getElementById(“c1”).checked) {
document.getElementById(“hours”).value = “0”;
for (var i = 1; i secs) secs1 = secs2 – secs;

if (remsplit2 >= j) {
remsecs = Math.floor(secs1/remsplit);
remmins = Math.floor(remsecs/60);
remsecs -= 60*remmins;

if (remsecs.toString().length == 1) {
document.getElementById(“remain2”).value = remmins.toString() + “:0” + remsecs.toString();
} else {
document.getElementById(“remain2”).value = remmins.toString() + “:” + remsecs.toString();
}

// }
hrs1 = Math.floor(secs1/3600);
hrs1 = hrs1.toString();
secs1 -= 3600 * hrs1;
mins1 = Math.floor(secs1/60);
mins1 = mins1.toString();
if(mins1.length == 1) mins1 = “0” + mins1;
secs1 -= 60 * mins1;
secs1 = secs1.toString();
if(secs1.length == 1) secs1 = “0” + secs1;
document.getElementById(“remain”).value = hrs1 + “:” + mins1 + “:” + secs1;
pace1 = Math.floor(secs/60);
pace2 = Math.floor((secs – pace1 * 60) );
pace2 = pace2.toString();
if (pace2 == “0” || pace2 == “1” || pace2 == “2” || pace2 == “3” ||pace2 == “4” || pace2 == “5” || pace2 == “6” ||pace2 == “7” || pace2 == “8” || pace2 == “9”) pace2 = “0” + pace2;

if (pace1 > 59) {
hrs = Math.floor(pace1 /60);
if (secs2 > secs) secs1 = secs2 – secs;

if (remsplit2 >= j) {
remsecs = Math.floor(secs1/remsplit);
remmins = Math.floor(remsecs/60);
remsecs -= 60*remmins;

if (remsecs.toString().length == 1) {
document.getElementById(“remain2”).value = remmins.toString() + “:0” + remsecs.toString();
} else {
document.getElementById(“remain2”).value = remmins.toString() + “:” + remsecs.toString();
}

}
hrs1 = Math.floor(secs1/3600);
hrs1 = hrs1.toString();
secs1 -= 3600 * hrs1;
mins1 = Math.floor(secs1/60);
mins1 = mins1.toString();
if(mins1.length == 1) mins1 = “0” + mins1;
secs1 -= 60 * mins1;
secs1 = secs1.toString();
if(secs1.length == 1) secs1 = “0” + secs1;
document.getElementById(“remain”).value = hrs1 + “:” + mins1 + “:” + secs1;
sb = parseInt(document.getElementById(“minutes”).value);
var pace5 = ((60*pace1 + parseInt(pace2)) / j – 60 * sb).toString();
pace1 -= hrs * 60;
pace5 = Math.floor(pace5);
if (pace5 > 59) pace5 = Math.floor(pace5 – 60);
if (pace5 59) pace5 = Math.floor(pace5 – 60);
if (pace5 0) {
pace1 = parseInt(pace1) + (60 * hrs);
}
var pace4 = Math.floor((pace1/j)).toString() + “:” + pace5;
if (bth) str += splt + ” ” + pace4 + “\n”;
if (tim) str += splt + “\n”;
if (pce) str += j.toString() + ” ” + pace4 + “\n”;

if(document.getElementById(“remain2”).value.indexOf(“NaN”) > 0) document.getElementById(“remain2″).value = pace4;
if (pces) str += j.toString() + ” ” + pace4 + ” ” + document.getElementById(“remain2”).value + “\n”;
document.getElementById(“split”).value = str;
//document.getElementById(“split”).style.height = ht.toString() + “pt”;
document.getElementById(“split”).style.height = “2000px”;
if (kms) {
var meas = “km”;
} else {
meas = “miles”;
}
if (remsplit2 == j) str2 = “Done\n” + (dst2 – j).toFixed(3) + ” ” + meas + ” to go at ” + pace4 + ” pace”;
}
if (remsplit2 59) {
hrs = Math.floor(pace1 /60);
pace1 -= hrs * 60;
pace1 = pace1.toString();
if (pace1 == “0” || pace1 == “1” || pace1 == “2” || pace1 == “3” ||pace1 == “4” || pace1 == “5” || pace1 == “6” ||pace1 == “7” || pace1 == “8” || pace1 == “9”) pace1 = “0” + pace1;
splt = i.toString() + ” ” + hrs.toString() + “:” + pace1 + “:” + pace2;
} else {
pace1 = pace1.toString();
if (pace1 == “0” || pace1 == “1” || pace1 == “2” || pace1 == “3” ||pace1 == “4” || pace1 == “5” || pace1 == “6” ||pace1 == “7” || pace1 == “8” || pace1 == “9”) pace1 = “0” + pace1;
splt = i.toString() + ” ” + pace1 + “:” + pace2;
if (i == 1) {
document.getElementById(“minutes”).value = pace1;
document.getElementById(“seconds”).value = pace2;
}
}
ht += 25;
//document.getElementById(“remain”).value = hrs.toString() + “:” + pace1 + “:” + pace2;
document.getElementById(“split”).value += splt.toString() + “\n”;
//document.getElementById(“split”).style.height = ht.toString() + “pt”;
document.getElementById(“split”).style.height = “2000px”;
}
secs2 = hrs * 3600 + parseInt(pace1) * 60 + parseInt(pace2);
}

if (! document.getElementById(“c1”).checked) {
ht = 0;
tm = 0;
secs = 0;
hrs = 0;
rem = “”;
j = 0;
str=””;
str2 = “”;
}
document.getElementById(“split”).style.borderWidth = “0”;
}

</body></html>


The multiple click simulations are done with the following code:
for (var i = 1; i <= dst2; i ++) {
document.getElementById(“calc”).click();
}

The print dialog is called with the following:
if (remsplit2 <= j) {
document.getElementById(“remain2”).value = “Av Rem”;
document.getElementById(“remain”).value = “Remain”;
document.getElementById(“c1”).checked = false;
alert(str2);
document.getElementById(“t1″).style.visibility=”hidden”;
document.getElementById(“split”).style.visibility=”visible”;
window.print();
}