// hello!
// (c) David Barton. 2002 / 2007
// http://www.limpfish.com/
// little duck bobs in NS4, IE4/5/6, Opera 5, NS6 / Mozilla 0.9.8
// yikes, 5 years later (old browser stuff probably useless now), lots of new stuff added, 2007
var layerRef="null",layerStyleRef="null",styleSwitch="null";
var down=0;
function init()
{
isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
if (isNS4)
{
layerStyleRef="layer.";
layerRef="document.layers";
bracketOpen='["';
bracketClose='"]';
styleSwitch="";
winW = window.innerWidth;
}
else
{
layerStyleRef="layer.style.";
styleSwitch=".style";
winW = document.body.offsetWidth;
if (isIE4)
{
bracketOpen='["';
bracketClose='"]';
layerRef="document.all";
}
else
{
// IE5, 6 and NS6, moz
bracketOpen='("';
bracketClose='")';
layerRef="document.getElementById";
}
}
}
function doStyleStuff(layerName,action) // do any style action for any browser
{
eval(layerRef+bracketOpen+layerName+bracketClose+styleSwitch+'.'+action);
}
function showLayer(layerName)
{
doStyleStuff(layerName,'visibility="visible"');
}
function hideLayer(layerName)
{
doStyleStuff(layerName,'visibility="hidden"');
}
function moveLayerTo(layerName,left,top)
{
doStyleStuff(layerName,'top='+top);
doStyleStuff(layerName,'left='+left);
}
function inner(layerName,c)
{
eval(layerRef+bracketOpen+layerName+bracketClose+'.innerHTML="'+c+'"');
}
var y = 50;
var x = 30;
var newanim=999;
var state;
var splash_down_totalTime=14;
var bob_totalTime=7;
var currTime=0;
var hideit=0;
var slide_bounce=new Array (2,4,6,10,14,19,24,30,36,43,53,67,85,108,135,165,185);
var splash_down_y=new Array (-75,-70,-60,-50,-35,-20,-5,15, 9,7,5, 6,7,9);
var bob_y=new Array (9,7,6,6,6,7,8);
var bob_alt_y=new Array (9,8,7,7,8,9,10);
function hidecuppa()
{
hideLayer('nice-cuppa');
thisMovie("cupsb").fadeout(9);
}
function showcuppa()
{
inner("flashy"," ");
showLayer('nice-cuppa');
}
function showform()
{
showLayer('contact');
}
function thisMovie(movieName)
{
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
function resetform()
{
inner("contact","
");
inner("pencil","
");
doStyleStuff('nice-cuppa','left=625');
inner("nice-cuppa","
");
showLayer('nice-cuppa');
document.body.style.backgroundImage = 'url(/lovely_ceramic_finish.jpg)';
document.body.style.backgroundRepeat = 'repeat-x';
currTime=0;
state = 1;
newanim=1;
x = 15+(Math.random()*104);
if (duck!='1')
{
timelineController();
}
}
function timelineController()
{
// splash down
if (state == 0)
{
if (currTime <= splash_down_totalTime)
{
currTime++;
if (splash_down_y[currTime] != null)
{
moveLayerTo('duck',x,splash_down_y[currTime])
}
}
else
{
state = 1;
}
}
// general idle state, animation logic.
if (state == 1)
{
currTime=0;
r = Math.random() * 29700;
if (newanim==0) { state = 2; } // bob
//hideLayer('quack');
if ((r < 100) && (newanim==0)) { state = 3; } // alternate bob
//if ((r < 40) && (newanim==0) && (hideit == 0)){ showLayer('quack'); } // perform a random quack
if ((r < 14) && (newanim==1)) { state = 0; x = 12; moveLayerTo('duck',x,-80); showLayer('duck'); newanim=0; } //begin?
if ((r < 150) && (newanim==0) && (state!=0)) { hideLayer('duck'); hideit=1; state = 1; newanim=1; //hideLayer('quack');
} // end anim
}
// bob up and down anim
if ((state == 2) || (state == 3))
{
if (currTime <= bob_totalTime)
{
currTime++;
if (bob_y[currTime] != null)
{
if (state == 2) { moveLayerTo('duck',x,bob_y[currTime]); }
if (state == 3) { moveLayerTo('duck',x,bob_alt_y[currTime]);}
//moveLayerTo('quack',x+40 ,5);
}
}
else
{
state = 1;
}
}
setTimeout("timelineController()",50);
}
function slidedown()
{
y= 55;
yy= 0;
slideindex = 0;
slideController();
}
function slideController()
{
yy = (y + slide_bounce[slideindex]);
doStyleStuff('nwstuff','clip="rect(0 auto '+yy+'px 0)"');
if (slideindex < 16)
{
slideindex++;
setTimeout("slideController()",20);
}
else
{
showLayer('nomore');
}
}