// JS Library

var d=document;
var tid=0; /* body onload timer */

function obj(id) {return d.getElementById(id)}
function gURL() {return d.URL}

// Preload

var o_images=new Array("buttons/bcctv.gif","buttons/bcagd.gif","buttons/bcaaw.gif","buttons/bcotl.gif","buttons/bccnw.gif","buttons/bcogw.gif","buttons/bcbws.gif")
var d_images=new Array("buttons/cctv.gif","buttons/cagd.gif","buttons/caaw.gif","buttons/cotl.gif","buttons/ccnw.gif","buttons/cogw.gif","buttons/cbws.gif","buttons/q-down.gif","buttons/v-down.gif","buttons/w-down.gif","buttons/x-down.gif","buttons/y-down.gif","buttons/z-down.gif")
var p_images=new Array("aforest/x.jpg","aforest/bg-about-b.png")
var pre_images=o_images.concat(d_images)

var preloads=new Array()
function preloadimages(arr) {
if (d.images){
for (i=0;i<arr.length;i++){
preloads[i]=new Image()
preloads[i].src=arr[i]
}}}
preloadimages(pre_images)

var aniloads=new Array(),currCount=0,loaded=new Array(),i,timerID;

function loadImages(){
if (d.images&&d.getElementById){
obj('cbuttons').style.visibility="visible";obj('zbuttons').style.visibility="visible"
for (i=0;i<=1;i++){
aniloads[i]=new Image()
aniloads[i].src=p_images[i]}
for (i=0;i<=1;i++){
loaded[i]=false}
checkLoad()}}

function checkLoad(){
for (i=0;i<=2;i++){
if (loaded[i]==false&&aniloads[i].complete){
loaded[i]=true;currCount++}
if (currCount==2) {
externalLinks()
initMess()
return}}
timerID=setTimeout("checkLoad()",100)}

// CSS Swap Buttons

function changeImages() {
var cI=changeImages.arguments, path='buttons\/', ext='.gif'; for (var i=2; i<cI.length; i+=1) {
with (d.getElementById(cI[i]).style) {backgroundImage="url("+path+cI[0]+cI[i]+cI[1]+ext+")"}}}

// Event Handlers, Functions

function clearMess() {mbar('void'); mess('void')}
function message(string) {d.forms[0].helpmsg.value=string}
function mbarstat(string) {obj('mbardiv').innerHTML='<div>'+string+'<\/div>'}
function mess(button) {message(msg[button])}
function mbar(button) {mbarstat(stb[button])}
function mouseOver(id) {mess(id); mbar(id)}
function pageId() {
var htm=(gURL().indexOf('/?')==-1)?(gURL().indexOf('.htm')):-1;
var param=(gURL().indexOf('/?')!=-1)?(gURL().indexOf('=')):-1;
var page=(param!=-1)?parseInt(gURL().split('=')[gURL().split('=').length-1]):
(htm!=-1)?gURL().substring(gURL().indexOf('pid')+3,htm):1; if (htm!=-1) return page;
page=((gURL().indexOf('/?page_id=')!=-1 && wpdb)||(gURL().indexOf('/?tigp_id=')!=-1 && !wpdb)||(gURL().indexOf('/?p=1')!=-1))?page:0;
page=(page == page && (page < 8 && page != 6 || (page > 100 && page < 122)))?page:0; return page}
function piclink(n) {var titlestr='Shop | '+(eval(pageId())-n)+' - '+msg[eval(pageId())+100-n]; return titlestr}

function externalLinks() {
if (!d.getElementById) return
for (var i = 1; i <= 14; i++) {
if (i<9) {
if (i!=1) {
obj(iC[i]+'_a').href=iU[iC[i]]+'.htm';
obj(iC[i]+'_a').onfocus=function() {this.blur()}
obj(iC[i]).onmouseover=function() {clearTimeout(tid); changeImages('b','',this.id); mouseOver(this.id)}
obj(iC[i]).onmouseout=function() {changeImages('d','',this.id); clearMess()}
obj(iC[i]).onmousedown=function() {changeImages('','',this.id)}
obj(iC[i]).onmouseup=function() {changeImages('d','',this.id); mess('void')}
if (i!=5) {
obj(iCb[i]+'_a').href="javascript:void(0)";
obj(iCb[i]+'_a').onfocus=function() {this.blur()}
obj(iCb[i]+'_a').onclick=function() {eval(iFb[this.id.split('_a')[0]]); return false}
obj(iCb[i]).onmouseover=function() {clearTimeout(tid); mouseOver(this.id)}
obj(iCb[i]).onmousemove=function() {clearTimeout(tid)}
obj(iCb[i]).onmouseout=function() {changeImages('','-out',this.id); clearMess()}
obj(iCb[i]).onmousedown=function() {changeImages('','-down',this.id)}
obj(iCb[i]).onmouseup=function() {changeImages('','-out',this.id)}}
}
obj(iNav[i]).title=msg[iNav[i]];
obj(iNav[i]).onmouseout=function() {clearMess()}
//obj(iNav[i]).onfocus=function() {this.blur()}
} else {
obj(iNav[i]).onmouseover=function() {clearTimeout(tid);mess(this.id.split('_s')[0]);mbarstat(stb[this.id])}
obj(iNav[i]).onmouseout=function() {clearMess()}
//obj(iNav[i]).onfocus=function() {this.blur()}
}
}
obj('blog').onmousemove=function() {tid=setTimeout("if(obj('helpmsg').value==msg['v']||obj('helpmsg').value==msg['Con']||obj('helpmsg').value==msg['HTA']||obj('helpmsg').value==msg['Tru']||obj('helpmsg').value==msg['Tom']||obj('helpmsg').value==msg['Sho']||obj('helpmsg').value==msg['Fre']) clearMess()",7000); obj('blog').onmousemove=function() {}}
if (d.getElementById('ext01')) {obj('ext01').target='_blank';}
if (d.getElementById('ext02')) {obj('ext02').target='_blank';}
if (d.getElementById('ext03')) {obj('ext03').target='_blank';}
if (d.getElementById('paypal')) {obj('paypal').target='paypal';
if (d.getElementById('previous')) {
obj('previous').title=piclink(101);
obj('previous').onmouseout=function() {clearMess()}
}
if (d.getElementById('next')) {
obj('next').title=piclink(99);
obj('next').onmouseout=function() {clearMess()}
}
obj('preview').title='Click to preview';
obj('preview').onfocus=function() {this.blur()}
obj('image').title='Add to Shopping Cart';
obj('sidephoto').src='aforest/'+iI[pageId()]+'.jpg';
} else {
obj('sidephoto').src='aforest/sidephoto-'+pageId()+'.jpg';
}
if (d.getElementById('theend')) {
obj('theend').onmouseover=function() {clearTimeout(tid);mouseOver(this.id)}
obj('theend').onmouseout=function() {clearMess()}
obj('theend').onfocus=function() {this.blur()}
obj('ccclock').onmouseover=function() {clearTimeout(tid);mouseOver(this.id)}
obj('ccclock').onmouseout=function() {clearMess()}
obj('ccclock').onfocus=function() {this.blur()}
}
}

// Midi Music Player

function MMP(theURL,winName,winOpts) {
winOpts = 'left=50,top=50,width=600,height=550,status=0,scrollbars=0,menubar=0,resizable=yes';
window.open('midiload.htm','PlayerWindow',winOpts)
}

// JS Links

function GO() {var arg=GO.arguments;
if (arg.length>1) {location.href=(arg[2])?arg[0]:arg[1]} else {location.href=arg[0]}}
function SH() {GO("/")}
function GS() {GO("pid101.htm","?tigp_id=101",pid)}
function MP() {GO("fguide.htm")}
function TSS() {GO("ftssp.htm")}
function CMM() {GO("ftext000.htm")}

// Messages

msg = new Array();
msg['void'] = '';
msg['cctv'] = 'Tom\'s Image Gallery Page - home';
msg['cagd'] = 'Persistence Of Vision Ray Images - page 1';
msg['caaw'] = 'Persistence Of Vision Ray Images - page 2';
msg['cotl'] = 'TrueSpace Ray Images';
msg['ccnw'] = 'RDSGEN: Random Dot Stereograms';
msg['cogw'] = 'Animated GIF Icons';
msg['cbws'] = 'loose ends ...';
msg['v'] = 'Start Here';
msg['z'] = 'Tom\'s Slide Show';
msg['x'] = 'High-quality Pictures';
msg['q'] = 'The MIDI Music Player';
msg['w'] = 'Magic Fiction (o-book)';
msg['y'] = 'Computer Fiction (o-mail)';
msg['TIG'] = 'Where Art is sold ...';
msg['Sta'] = msg['v'];
msg['Con'] = 'About TIG';
msg['HTA'] = 'HTA Browser Object';
msg['Tru'] = '13';
msg['Tom'] = 'Install Tom offline';
msg['Sho'] = msg['x'];
msg['Fre'] = 'Promotional Giveaways';
msg['theend'] = 'A hidden meaning';
msg['ccclock'] = 'An analog clock';
msg['101'] = 'The Starcross';
msg['102'] = 'The Watergate';
msg['103'] = 'The Trumpet';
msg['104'] = 'Channel 11';
msg['105'] = '5 Ballz';
msg['106'] = 'The Ballroom';
msg['107'] = 'Plinth Park';
msg['108'] = 'Reflections';
msg['109'] = 'Vertigo';
msg['110'] = 'Rainbirds';
msg['111'] = 'Blind';
msg['112'] = 'POV-Ray';
msg['113'] = 'Help Desk';
msg['114'] = 'The Card Game';
msg['115'] = 'Money';
msg['116'] = 'C Of E';
msg['117'] = 'TrueSpace';
msg['118'] = '3-D Trumpet (stereogram)';
msg['119'] = '3-D Ballz (stereogram)';
msg['120'] = 'Ship Of Souls (stereogram)';
msg['121'] = '2C 3D (stereogram)';

stb = new Array();
stb['void'] = '';
stb['cctv'] = 'CCTV = Closed Circuit Television';
stb['cagd'] = 'CAGD = Computer Aided Graphic Design';
stb['caaw'] = 'CAAW = Comments Are Always Welcome';
stb['cotl'] = 'COTL = Click On This Link';
stb['ccnw'] = 'CCNW = Crap Comments Not Welcome';
stb['cogw'] = 'COGW = Can Only Get Worse';
stb['cbws'] = 'CBWS = Coolest Best Website';
stb['v'] = 'Hello, world!';
stb['z'] = 'javascript \/ java image transitions';
stb['x'] = '&#64; TIG Shop: e-commerce via PayPal (or credit card) &#8226; www.teanow4pm.co.uk';
stb['q'] = 'listen to MIDI arrangements';
stb['w'] = 'play cycle';
stb['y'] = 'html fiction';
stb['Sta'] = stb['v'];
stb['Con'] = '&gt;&gt; history &gt;&gt; evolution &gt;&gt; now &gt;&gt; comments &gt;&gt; hmm, interesting';
stb['HTA'] = 'how to make navigation buttons in hta';
stb['Tru'] = 'the triskaidekachronicity of light = c';
stb['Tom'] = 'download TIG installer';
stb['Sho'] = (document.title.indexOf("Shop")!=-1)?stb['x']+' &#8226; item no. img'+((eval(pageId())+9990900).toString().split('9991')[1]):stb['x'];
stb['Fre'] = 'freebies, freebies, ...';
stb['w_s'] = '-&gt; the drama';
stb['y_s'] = '-&gt; the prose';
stb['cagd_s'] = '-&gt; the first batch of images';
stb['caaw_s'] = '-&gt; the second batch';
stb['cotl_s'] = '-&gt; the third batch';
stb['ccnw_s'] = '-&gt; and Magic Eye';
stb['theend'] = 'read between the lines';
stb['ccclock'] = 'turn back the hands of time';

function getRandom(output) {var rand=Math.floor(Math.random()*output);return rand+1}
var newnum=getRandom(10)

function showAny()
{
 var num=newnum;
 textArray = new Array();
 textArray[1] = "Raytracing is Fun!";
 textArray[2] = "And now ... something completely different.";
 textArray[3] = "Hold down your mouse key.";
 textArray[4] = "Ok ... now what?";
 textArray[5] = "A nice choice, if I do say so myself.";
 textArray[6] = "Only one more to go ...";
 textArray[7] = "That's it!";
 textArray[8] = "Keep on trying.";
 textArray[9] = "Oh no ... not again.";
 textArray[10] = "Keep me posted.";
 while (num==newnum) {newnum=getRandom(10)}
 d.forms[0].helpmsg.value=textArray[newnum];
}

// IDs, Links, Functions, Images

iC = new Array();
iC[2] = 'cctv';
iC[3] = 'cagd';
iC[4] = 'caaw';
iC[5] = 'cotl';
iC[6] = 'ccnw';
iC[7] = 'cogw';
iC[8] = 'cbws';

iCb = new Array();
iCb[2] = 'v';
iCb[3] = 'z';
iCb[4] = 'x';
iCb[6] = 'q';
iCb[7] = 'w';
iCb[8] = 'y';

iNav = new Array();
iNav[1] = 'TIG';
iNav[2] = 'Sta';
iNav[3] = 'Con';
iNav[4] = 'HTA';
iNav[5] = 'Tru';
iNav[6] = 'Tom';
iNav[7] = 'Sho';
iNav[8] = 'Fre';
iNav[9] = 'y_s';
iNav[10] = 'w_s';
iNav[11] = 'cagd_s';
iNav[12] = 'caaw_s';
iNav[13] = 'cotl_s';
iNav[14] = 'ccnw_s';

var iFb = new Array()
iFb['v'] = 'SH()';
iFb['z'] = 'TSS()';
iFb['x'] = 'GS()';
iFb['q'] = 'MMP()';
iFb['w'] = 'MP()';
iFb['y'] = 'CMM()';

var iU = new Array()
iU['cctv'] = 'tigp2';
iU['cagd'] = 'tigp3';
iU['caaw'] = 'tigp4';
iU['cotl'] = 'tigp5';
iU['ccnw'] = 'tigp6';
iU['cogw'] = 'tigp7';
iU['cbws'] = 'tigp8';

var iI = new Array()
iI['101'] = 'starcro';
iI['102'] = 'watgate';
iI['103'] = 'trumpet';
iI['104'] = 'c11';
iI['105'] = '5balz';
iI['106'] = 'balrom';
iI['107'] = 'plinth';
iI['108'] = 'reflect';
iI['109'] = 'vertigo';
iI['110'] = 'botbatbt';
iI['111'] = 'blind';
iI['112'] = 'povlogo';
iI['113'] = 'helpdsk';
iI['114'] = 'card';
iI['115'] = 'money';
iI['116'] = 'coe';
iI['117'] = 'trulogo';
iI['118'] = 'trufog';
iI['119'] = 'ballzfog';
iI['120'] = 'shipfog';
iI['121'] = '2c3dfog2';

function initMess() {
if (document.title=="TIG") mouseOver('v')
if (document.title.indexOf("Concept")!=-1) mouseOver('Con')
if (document.title.indexOf("HTA")!=-1) mouseOver('HTA')
if (document.title.indexOf("Trust")!=-1) mouseOver('Tru')
if (document.title.indexOf("Tom")!=-1) mouseOver('Tom')
if (document.title.indexOf("Shop")!=-1) mouseOver('Sho')
if (document.title.indexOf("Free")!=-1) mouseOver('Fre')
}

