/*
pixels.js
JavaScript functions for Pixel stuff
vers 1.1 ajm 06/02/2006
*/
var irefs = new Array();
var height=width=boxsize=x2=y2=pcost=curr=-1;
var eid1=eid2=ict=selo=cbutt=clbutt='';
var isIE=(document.all) ? 1 : 0;
function initJS() {
if (document.location.protocol=='https:') document.writeln('');
else document.writeln('');
}
initJS();
function zoomIn() {
if (document.body && document.body.style && typeof document.body.style.zoom != "undefined") {
if (document.body.style.zoom == "200%") document.body.style.zoom = "100%";
else document.body.style.zoom = "200%";
}
}
function writeZoomIn() {
if (isIE) {
document.writeln('');
document.writeln('Double click to zoom in/out.');
}
}
function setVars(h, w, b, e1, e2, ic, so, cb, clb, pc, scS, cd) {
height=h; // Image Height
width=w; // Image Width
boxsize=b; // Square size
eid1=e1; // First Square location
eid2=e2; // Second Square location
ict=ic; // Div that contains the image
selo=so; // Div that contains the selection info
cbutt=cb; // Continue Button
clbutt=clb; // Clear Button
pcost=pc; // Pixel Cost
curr=cd; // Currency Dollars
if (scS) {
window.onload=function () {
clearSelection();
}
}
}
function clearSelection() {
while (irefs.length > 0) {
ir=irefs.pop();
ir.clear();
}
if (document.getElementById(eid1)) document.getElementById(eid1).value='';
if (document.getElementById(eid2)) document.getElementById(eid2).value='';
if (document.getElementById(selo)) {
document.getElementById(selo).style.background='#ffffff';
document.getElementById(selo).innerHTML='';
}
if (document.getElementById(cbutt)) document.getElementById(cbutt).disabled=true;
if (document.getElementById(clbutt)) document.getElementById(clbutt).disabled=true;
}
function purchaseSQ(x , y) {
x1=(x * boxsize) - (boxsize - 1);
y1=(y * boxsize) - (boxsize - 1);
if (document.getElementById(eid1).value == '') {
document.getElementById(eid1).value=x + '|' + y;
x2=x1;
y2=y1;
ir = new jsGraphics(ict);
ir.setColor("#0000ff");
ir.fillRect(x1, y1, boxsize, boxsize);
ir.paint();
irefs.push(ir);
document.getElementById(clbutt).disabled=false;
document.getElementById(cbutt).disabled=false;
document.getElementById(selo).style.background='#646464';
document.getElementById(selo).innerHTML='You selected square ' + (((y - 1) * (height / boxsize)) + x) + '.';
}else{
if (document.getElementById(eid2).value == '') {
document.getElementById(eid2).value=x + '|' + y;
if (x2>x1) {
x=x1;
ww=x2 - x1;
}else{
x=x2;
ww=x1 - x2;
}
if (y2>y1) {
y=y1;
hh=y2 - y1;
}else{
y=y2;
hh=y1 - y2;
}
ir = new jsGraphics(ict);
ir.setColor("#0000ff");
ir.fillRect(x, y, ww + boxsize, hh + boxsize);
ir.paint();
irefs.push(ir);
www=((ww / boxsize)+1);
hhh=((hh / boxsize)+1);
document.getElementById(selo).style.background='#646464';
document.getElementById(selo).innerHTML='You selected ' + www + ' x ' + hhh + ' = ' + (www * hhh) + ' squares.
At a cost of £' + ((www * hhh) * pcost).toFixed(2) + '.' + ((curr) ? '
(Approx $' + (((www * hhh) * pcost) * curr).toFixed(2) + ')' : '');
}
}
}