|
Try the magic 8 ball
To place the shaking 8 ball on your site you need
to copy two pieces of code. The first goes just under
the body tags while the second goes where you want the
8ball to appear. Remeber to save as a php file. Credit
for the shaking bit goes to dynamicdrive while the 8ball
script was an edited version from hotscripts.
Place the following just under the <body> tags:
<layer
id="quakenotice_ns" width=300 height=55 bgcolor=lightyellow
visibility=hide></layer>
<script>
/*
EarthQuake script- © Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions, 100's
more DHTML scripts, and Terms Of Use,
Visit http://dynamicdrive.com
*/
//configure the likelihood
that an earthquake will occur (100% means always)
var chance_of_occurence="100%"
/////do NOT edit below
this line/////////////
//variable used to
store the equivalency of the 10 rector scales (in the
form of 1, 3, 6...etc)
var rectorscale=new Array(1,3,6,9,12,15,18,21,24,27)
chance_of_occurence=parseInt(chance_of_occurence)
function earthquake(){
//randomly assign a number from 1 to 10 to variable
rectorindex
rectorindex=Math.floor(Math.random()*10)
//randomly assign one of element rectorscale into variable
rector
rector=rectorscale[rectorindex]
if ((document.all||document.layers)&&Math.floor(Math.random()*100)<=chance_of_occurence)
{
//shake the browser's screen according to the random
rector scale!
for (i=0;i,i<20;i++){
window.moveBy(0,rector)
window.moveBy(rector,0)
window.moveBy(0,-rector)
window.moveBy(-rector,0)
}
}
}
if (document.all)
document.write('<div id="quakenotice_ie"></div>')
function quakealert(){
var quakemessage='An earthquake of magnitude <b>'+eval(rectorindex+1)+'</b>
has just occured! Please stay calm...everything\'s fine
now.'
if (document.all){
quakemsg_ie=document.all.quakenotice_ie
quakemsg_ie.innerHTML=quakemessage
//position quake message in center of screen
quakemsg_ie.style.left=document.body.scrollLeft+document.body.clientWidth/2-quakemsg_ie.offsetWidth/2
quakemsg_ie.style.top=document.body.scrollTop+document.body.clientHeight/2-quakemsg_ie.offsetHeight/2
quakemsg_ie.style.visibility="visible"
setTimeout("quakemsg_ie.style.visibility='hidden'",5000)
}
else if (document.layers){
quakemsg_ns=document.quakenotice_ns
quakemsg_ns.document.write(quakemessage)
quakemsg_ns.document.close()
quakemsg_ns.left=pageXOffset+window.innerWidth/2-quakemsg_ns.document.width/2
quakemsg_ns.top=pageYOffset+window.innerHeight/2-quakemsg_ns.document.height/2
quakemsg_ns.visibility="show"
setTimeout("quakemsg_ns.visibility='hide'",5000)
}
}
</script>
Place whereever you
want the 8ball:
<table width="95%" border="0"
cellspacing="0" cellpadding="0"
align="center" bgcolor="#FFFFFF">
<tr>
<td bgcolor="#000000" width="1"><img
src="../pics/spacer.gif" width="1"
height="1"></td>
<td valign="top">
<table width="100%" border="0"
cellspacing="5">
<tr>
<td>
<div align="center"><b>Let the
Magic 8 ball answer all
your questions:</b></div>
</td>
</tr>
<tr>
<td>
<div align="center"><img src="pics/8ball.gif"
width="160" height="150"></div>
</td>
</tr>
<tr>
<td height="53">
<center>
<?php echo "<form action='$PHP_SELF?action=answer'
method='post'>"?>
<BR>Ask a question:
<BR>
<BR>
<input type="text" name="question">
<input type="submit" value="Ask.."
onClick="earthquake()">
</center>
<?
if($action == "answer")
{
?> <br>
<br>
<center>
<b><font size=+2>The answer is:</font></b><br>
<br>
</center>
<?
echo "<center>";
srand((double)microtime()*1000000);
$shake = rand(0,10);
if($shake == "0"){
echo "Without a shadow of a doubt";
} elseif($shake == "1"){
echo "Definitely yes.";
} elseif($shake == "2"){
echo "Its more than likely.";
} elseif($shake == "3"){
echo "Maybe, Maybe not.";
} elseif($shake == "4"){
echo "Possibly.";
} elseif($shake == "5"){
echo "Probably";
} elseif($shake == "6"){
echo "Who knows.";
} elseif($shake == "7"){
echo "No chance.";
} elseif($shake == "8"){
echo "DEfinitely not.";
} elseif($shake == "9"){
echo "Possibly, if you stand on your hands for
10 seconds you'll have a better chance.";
} elseif($shake == "10"){
echo "Not a f*!@*$! chance.";
}
echo "</center>";
}
?> </td>
</tr>
</table>
|