I have a drag and drop game. Images are dragged onto a table with divisions. If the correct image is dragged over the correct div then a message saying well done is alerted and the background color of the div is changed to the background color of the page so that the text in the div can no longer be seen. if another image is dragged over the div then the color is changed to the color set when an image is dragged over a div. Is there any way to disable the div so that when the correct image is placed on the correct div then the div no longer is active and other images cannot be dragged over it? here is the code:
<html>
<head>
<title>Animal Drag and Drop Game</title>
<style type = "text/css">
<!--
table, th, td, tr
{font-family: cursive , arial, helvetica, sans-serif;
color: #CC3300;
font-size: 10pt;
border-color: #CC3300;
}
p {font-family: cursive, , arial, helvetica, sans-serif;
font-size: 12pt;
color: red;
}
h1 {font-family: cursive, , arial, helvetica, sans-serif;
font-weight: bold;
font-size: 24pt;
color: red;
}
-->
</style>
<body bgcolor = "#CC3300">
<script language = "JavaScript">
//time functions start, stop and update timer for the game
var timerID = 0;
var tStart = null;
function UpdateTimer() {
if(timerID) {
clearTimeout(timerID);
clockid = 0;
}
if(!tStart)
tStart = new Date();
var tDate = new Date();
var tDiff = tDate.getTime() - tStart.getTime();
tDate.setTime(tDiff);
document.theTimer.theTime.value = ""
+ tDate.getMinutes() + ":"
+ tDate.getSeconds();
timerID = setTimeout("UpdateTimer()", 1000);
}
function Start() {
tStart = new Date();
document.theTimer.theTime.value = "00:00";
timerID = setTimeout("UpdateTimer()", 1000);
}
function Stop() {
if(timerID) {
rawtime = document.theTimer.theTime.value;
calculatemins = document.theTimer.theTime.value.substring(0,2);
calculatesecs = document.theTimer.theTime.value.substring(2,5);
var actualmins = calculatemins.substring(0,1)
alert('Congradulations!! It took you '+actualmins+ ' minutes and '+calculatesecs+' seconds to finish the game.Your score is: '+counter);
clearTimeout(timerID);
timerID = 0;
}
tStart = null;
document.theTimer.theTime.value = "00:00"
counter = 0;
window.location.reload();
}
//change the background colour of the division in the table to cream when an image is
//dragged over it
function doOverTarget() {
elDragged.overTarget.style.background="#FBEADC"
}
//when an image is dragged over a division and then dragged to a new dvision in
//the table or outside the table then change the colour of the division back to white
function doOutTarget() {
elDragged.overTarget.style.background="white"
}
var counter = 0;
//check to see if the correct image is on the correct division in the table
function TestNumber(l)
{
var imageText= elDragged.innerHTML;
var num = imageText.indexOf(".gif"
;
var tempId = imageText.substring(num-5, num);
if (tempId == (l))
{ alert('Well Done!!')
elDragged.overTarget.style.background="#CC3300";
counter++;
}
else
{ alert('Try again!!')
counter--;
}
}
//image that is currently being dragged
var elDragged = null
function testOver(iLeft, iTop) {
// Test if the image is over a valid drop-area
var hit = false
if (elDragged.getAttribute("dropTarget"
!=null) {
for (var intLoop=0; intLoop<elDragged._targets.length; intLoop++) {
// Check all drop-areas
var el = elDragged._elTargets[intLoop]
if (null!=el) {
if ((iTop > el._top) && (iLeft > el._left) && (iLeft+elDragged.offsetWidth < el.offsetWidth+el._left) && (elDragged.offsetHeight+iTop < el.offsetHeight+el._top)) {
elDragged.overTarget= el
var hit=true
elDragged._over[intLoop] = true
if (event.type=="mouseup"
{
if (el.getAttribute("onDropTarget"
!=null)
eval(el.getAttribute("onDropTarget"
);
} else
{
if (el.getAttribute("onOverTarget"
!=null)
eval(el.getAttribute("onOverTarget"
)
}
}
else {
if ((el.getAttribute("onOutTarget"
!=null) && (elDragged._over[intLoop])) {
elDragged.overTarget= el
eval(el.getAttribute("onOutTarget"
)
}
elDragged._over[intLoop] = false
}
}
}
}
return hit;
}
//function performed on mouse up
function doMouseUp() {
if (elDragged!=null)
if (testOver(elDragged._left, elDragged._top)) {
if (elDragged.getAttribute("onTarget"
)
eval(elDragged.getAttribute("onTarget"
)
}
else
if (elDragged.getAttribute("onNoTarget"
)
eval(elDragged.getAttribute("onNoTarget"
)
elDragged=null
}
//function performed when mouse button is down and an element is being dragged
function doMouseMove() {
if ((1 == event.button) && (elDragged != null)) {
// Set new position
var intTop = event.clientY+document.body.scrollTop;
var intLeft = event.clientX + document.body.scrollLeft;
elDragged.style.pixelTop = intTop - elDragged._lessTop - elDragged.y;
elDragged.style.pixelLeft = intLeft - elDragged._lessLeft - elDragged.x;
// Cache updated info
elDragged._left = elDragged._lessLeft + elDragged.offsetLeft + document.body.scrollLeft
elDragged._top = elDragged.offsetTop+ elDragged._lessTop +document.body.scrollTop
// Test if over target
testOver(elDragged._left, elDragged._top)
event.returnValue = false;
};
};
//make sure that the element clicked on supports dragging
function checkDrag(elCheck) {
while (elCheck!=null) {
if (null!=elCheck.getAttribute("dragEnabled"
)
return elCheck
elCheck = elCheck.parentElement
}
return null
}
// On the mouse down, test if element can be dragged
function doMouseDown() {
var elCurrent = checkDrag(event.srcElement)
// For draggable elements, cache all calculations up front. This is for performance.
if (null!=elCurrent) {
elDragged = elCurrent;
// Determine where the mouse is in the element
elDragged.x = event.offsetX
elDragged.y = event.offsetY
// Make sure we are using pixel units everywhere
elDragged.style.top = elDragged.offsetTop + "px"
elDragged.style.left = elDragged.offsetLeft + "px"
var op = event.srcElement
// Find real location in respect to element being dragged.
if ((elDragged!=op.offsetParent) && (elDragged!=event.srcElement)) {
while (op!=elDragged) {
elDragged.x+=op.offsetLeft
elDragged.y+=op.offsetTop
op=op.offsetParent
}
}
// Move the element
// Where the mouse is in the document
// Calculate what element the mouse is really in
var intLessTop = 0; var intLessLeft = 0;
var elCurrent = elDragged.offsetParent;
while (elCurrent.offsetParent!=null) {
intLessTop+=elCurrent.offsetTop;
intLessLeft+=elCurrent.offsetLeft;
elCurrent = elCurrent.offsetParent;
}
elDragged._lessTop = intLessTop
elDragged._lessLeft = intLessLeft
// Calculate and cache target information
if (null!=elDragged.getAttribute("dropTarget"
) {
elDragged._targets = elDragged.getAttribute("dropTarget"
.split(","
elDragged._over = new Array
elDragged._elTargets = new Array
for (var intLoop=0; intLoop < elDragged._targets.length; intLoop++) {
var el = document.all[elDragged._targets[intLoop]]
if (null!=el) {
elDragged._elTargets[intLoop]= el;
var intLessTop = el.offsetTop; var intLessLeft = el.offsetLeft;
var elCurrent = el.offsetParent;
var intTop = document.body.scrollTop;
var intLeft = document.body.scrollLeft;
while (elCurrent.offsetParent!=null) {
intLessTop+=elCurrent.offsetTop;
intLessLeft+=elCurrent.offsetLeft;
elCurrent = elCurrent.offsetParent;
}
el._top = intLessTop + intTop
el._left = intLessLeft + intLeft
}
}
}
}
}
// Process all mouse events.
document.onmousedown = doMouseDown;
document.onmousemove = doMouseMove;
document.onmouseup = doMouseUp;
//array of all the images in the game
var Pictures = new Array;
Pictures[0] = '00001.gif';
Pictures[1] = '00002.gif';
Pictures[2] = '00003.gif';
Pictures[3] = '00004.gif';
Pictures[4] = '00005.gif';
Pictures[5] = '00006.gif';
Pictures[6] = '00007.gif';
Pictures[7] = '00008.gif';
Pictures[8] = '00009.gif';
Pictures[9] = '00010.gif';
//shuffle the images using a random number so that a new combination
//occurs each time the shuffle button is pressed
function shuffle()
{
for(i = 0;i<10;i++)
{
Pictures = Pictures.sort(getRandomNumber);
for(x = 0; x<10; x++)
{
document.images[x].src = Pictures[x];
document.images[x].style.top = 500;
document.images[x].style.pixelLeft = 5;
}
document.images[5].style.top = 500;
document.images[5].style.pixelLeft = 5;
}
}
function getRandomNumber()
{
return Math.floor(Math.random() * 10)-1;
}
</script>
<!--divisions for the images -->
<div id = "00001" style =" position:absolute;left:50;top:150;" dragEnabled dropTarget = "dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00001.gif" width = 250em height = 75em align = "center">
</div>
<div id = "00002" style = "position:absolute;left:50;top:150; position: absolute" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00002.gif" width = 250em height = 75em align = "center">
</div>
<div id="00003" style="position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00003.gif" width = 250em height = 75em align = "center">
</div>
<div id="00004" style ="position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00004.gif" width = 250em height = 75em align = "center">
</div>
<div id = "00005" style = "position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00005.gif" width = 250em height = 75em align = "center">
</div>
<div id = "00006" style = "position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00006.gif" width = 250em height = 75em align = "center">
</div>
<div id="00007" style = "position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00007.gif" width = 250em height = 75em align = "center">
</div>
<div id = "00008" style = "position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00008.gif" width = 250em height = 75em align = "center">
</div>
<div id = "00009" style = "position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00009.gif" width = 250em height = 75em align = "center">
</div>
<div id = "00010" style = "position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00010.gif" width = 250em height = 75em align = "center">
</div>
<!--<div id = "00011" style = "position:absolute;left:200;top:450;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00011.gif" width = 75em height = 75em align = "center">
</div>
<div id = "00012" style = "position:absolute;left:320;top:450;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00012.gif" width = 75em height = 75em align = "center">
</div>
<form align = "left" name="theTimer"><table>
<tr>
<td>
</td>
<td >
<input type=text name="theTime" size=5 align = "center">
</td>
<td>
</td>
</tr>
<tr>
<td width = "33%">
<input type = button name = "start" value = "Start" onclick = "Start()">
</td>
<td width = "33%">
<input type = button name = "stop" value = "Stop" onclick = "Stop()">
</td>
<td width = "33%">
<input type = "button" name = "button1" value = "Shuffle" onClick = "shuffle()">
</td>
</tr>
</table></form>
-->
<input type = "button" name = "button1" value = "Shuffle" onClick = "shuffle()">
<!--divisions for the drop areas in the table -->
<div id = dropAnimal style = "position: absolute; top: 50;left: 405; width: 290; height: 7em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00006')">
</div>
<div id = dropAnimal2 style = "position: absolute; top: 50;left: 695; width: 290; height: 7em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00001')">
</div>
<div id = dropAnimal3 style = "position: absolute; top: 160;left: 405; width: 290; height: 5.5em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00005')">
</div>
<div id = dropAnimal4 style = "position: absolute; top: 160;left: 695; width: 290; height: 5.5em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00003')">
</div>
<div id = dropAnimal5 style = "position: absolute; top: 248;left: 405; width: 290; height: 5em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00007')">
</div>
<div id = dropAnimal6 style = "position: absolute; top: 248;left: 695; width: 290; height: 5em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00004')">
</div>
<div id = dropAnimal7 style = "position: absolute; top: 328;left: 405; width: 290; height: 12em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00010')">
</div>
<div id = dropAnimal8 style = "position: absolute; top: 328;left: 695; width: 290; height: 12em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00009')">
</div>
<div id = dropAnimal9 style = "position: absolute; top: 515;left: 405; width: 290; height: 6.2em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00008')">
</div>
<div id = dropAnimal10 style = "position: absolute; top: 515;left: 695; width: 290; height: 6.2em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00002')">
</div>
<!--divisions for text
<div id = title style = "position: absolute; top: 0;left: 300; width: 200; height: 3.5em; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00006')">
<h1>Animal Game</h1>
</div>
<div id = instructions style = "position: absolute; top: 15;left: 500; width: 470; height: 2em; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00006')">
<br>
<p>Press Play to Start. When you are finished playing press Stop for your time and score.
Press Shuffle and then Start to begin a new game.</p>
</div>
-->
<table border = 5 align = right width = 60% cellpadding = 12 cellspacing = 2.5 >
<tbody>
<tr>
<td width = 50%>This theory stresses initial disparities and the rigidity of the system, pointing out that under such conditions the free play of market forces is bound to lead to an unbalanced regional growth.</td>
<td width = 50%>This policy is a policy that tries to address regional imbalances that have occurred over time.</td>
<tr>
<td width = 50% >This theory suggests that similar economic activities regularly tend to concentrate in the same locations.</td>
<td width = 50% >This theory views development as a succession of stages through which all economies must pass to become ‘developed’.</td>
</tr>
<tr>
<td width = 50% >This theory is based on the idea that demand in a given region is the summation of domestic, export and import demand.</td>
<td width = 50%>This theory is interested in the workings of the political economy.</td>
</tr>
<tr>
<td width = 50%>This theory suggests that regions go through stages of structural change - from an economy initially dominated by primary sector, to one characterised by secondary sector dominance, to the prevalence of tertiary sector production.</td>
<td width = 50%>This theory believes that if the market is able to operate freely, it will automatically bring about economic development and is based on four major assumptions - free competition and market entry, full employment of factors of production (labour and capital), full mobility of labour and capital, and common level of technology.</td>
</tr>
<tr>
<td width = 50%> This theory is used to explain regional specialisation in the production of certain goods, and inter-regional and international trade.</td>
<td width = 50%>This policy can be defined as all aspects of State action that, directly or indirectly, influences the nature of economic and social development in rural areas.</td>
</tr>
</tbody>
</table>
</body>
</html>
<html>
<head>
<title>Animal Drag and Drop Game</title>
<style type = "text/css">
<!--
table, th, td, tr
{font-family: cursive , arial, helvetica, sans-serif;
color: #CC3300;
font-size: 10pt;
border-color: #CC3300;
}
p {font-family: cursive, , arial, helvetica, sans-serif;
font-size: 12pt;
color: red;
}
h1 {font-family: cursive, , arial, helvetica, sans-serif;
font-weight: bold;
font-size: 24pt;
color: red;
}
-->
</style>
<body bgcolor = "#CC3300">
<script language = "JavaScript">
//time functions start, stop and update timer for the game
var timerID = 0;
var tStart = null;
function UpdateTimer() {
if(timerID) {
clearTimeout(timerID);
clockid = 0;
}
if(!tStart)
tStart = new Date();
var tDate = new Date();
var tDiff = tDate.getTime() - tStart.getTime();
tDate.setTime(tDiff);
document.theTimer.theTime.value = ""
+ tDate.getMinutes() + ":"
+ tDate.getSeconds();
timerID = setTimeout("UpdateTimer()", 1000);
}
function Start() {
tStart = new Date();
document.theTimer.theTime.value = "00:00";
timerID = setTimeout("UpdateTimer()", 1000);
}
function Stop() {
if(timerID) {
rawtime = document.theTimer.theTime.value;
calculatemins = document.theTimer.theTime.value.substring(0,2);
calculatesecs = document.theTimer.theTime.value.substring(2,5);
var actualmins = calculatemins.substring(0,1)
alert('Congradulations!! It took you '+actualmins+ ' minutes and '+calculatesecs+' seconds to finish the game.Your score is: '+counter);
clearTimeout(timerID);
timerID = 0;
}
tStart = null;
document.theTimer.theTime.value = "00:00"
counter = 0;
window.location.reload();
}
//change the background colour of the division in the table to cream when an image is
//dragged over it
function doOverTarget() {
elDragged.overTarget.style.background="#FBEADC"
}
//when an image is dragged over a division and then dragged to a new dvision in
//the table or outside the table then change the colour of the division back to white
function doOutTarget() {
elDragged.overTarget.style.background="white"
}
var counter = 0;
//check to see if the correct image is on the correct division in the table
function TestNumber(l)
{
var imageText= elDragged.innerHTML;
var num = imageText.indexOf(".gif"
var tempId = imageText.substring(num-5, num);
if (tempId == (l))
{ alert('Well Done!!')
elDragged.overTarget.style.background="#CC3300";
counter++;
}
else
{ alert('Try again!!')
counter--;
}
}
//image that is currently being dragged
var elDragged = null
function testOver(iLeft, iTop) {
// Test if the image is over a valid drop-area
var hit = false
if (elDragged.getAttribute("dropTarget"
for (var intLoop=0; intLoop<elDragged._targets.length; intLoop++) {
// Check all drop-areas
var el = elDragged._elTargets[intLoop]
if (null!=el) {
if ((iTop > el._top) && (iLeft > el._left) && (iLeft+elDragged.offsetWidth < el.offsetWidth+el._left) && (elDragged.offsetHeight+iTop < el.offsetHeight+el._top)) {
elDragged.overTarget= el
var hit=true
elDragged._over[intLoop] = true
if (event.type=="mouseup"
if (el.getAttribute("onDropTarget"
eval(el.getAttribute("onDropTarget"
} else
{
if (el.getAttribute("onOverTarget"
eval(el.getAttribute("onOverTarget"
}
}
else {
if ((el.getAttribute("onOutTarget"
elDragged.overTarget= el
eval(el.getAttribute("onOutTarget"
}
elDragged._over[intLoop] = false
}
}
}
}
return hit;
}
//function performed on mouse up
function doMouseUp() {
if (elDragged!=null)
if (testOver(elDragged._left, elDragged._top)) {
if (elDragged.getAttribute("onTarget"
eval(elDragged.getAttribute("onTarget"
}
else
if (elDragged.getAttribute("onNoTarget"
eval(elDragged.getAttribute("onNoTarget"
elDragged=null
}
//function performed when mouse button is down and an element is being dragged
function doMouseMove() {
if ((1 == event.button) && (elDragged != null)) {
// Set new position
var intTop = event.clientY+document.body.scrollTop;
var intLeft = event.clientX + document.body.scrollLeft;
elDragged.style.pixelTop = intTop - elDragged._lessTop - elDragged.y;
elDragged.style.pixelLeft = intLeft - elDragged._lessLeft - elDragged.x;
// Cache updated info
elDragged._left = elDragged._lessLeft + elDragged.offsetLeft + document.body.scrollLeft
elDragged._top = elDragged.offsetTop+ elDragged._lessTop +document.body.scrollTop
// Test if over target
testOver(elDragged._left, elDragged._top)
event.returnValue = false;
};
};
//make sure that the element clicked on supports dragging
function checkDrag(elCheck) {
while (elCheck!=null) {
if (null!=elCheck.getAttribute("dragEnabled"
return elCheck
elCheck = elCheck.parentElement
}
return null
}
// On the mouse down, test if element can be dragged
function doMouseDown() {
var elCurrent = checkDrag(event.srcElement)
// For draggable elements, cache all calculations up front. This is for performance.
if (null!=elCurrent) {
elDragged = elCurrent;
// Determine where the mouse is in the element
elDragged.x = event.offsetX
elDragged.y = event.offsetY
// Make sure we are using pixel units everywhere
elDragged.style.top = elDragged.offsetTop + "px"
elDragged.style.left = elDragged.offsetLeft + "px"
var op = event.srcElement
// Find real location in respect to element being dragged.
if ((elDragged!=op.offsetParent) && (elDragged!=event.srcElement)) {
while (op!=elDragged) {
elDragged.x+=op.offsetLeft
elDragged.y+=op.offsetTop
op=op.offsetParent
}
}
// Move the element
// Where the mouse is in the document
// Calculate what element the mouse is really in
var intLessTop = 0; var intLessLeft = 0;
var elCurrent = elDragged.offsetParent;
while (elCurrent.offsetParent!=null) {
intLessTop+=elCurrent.offsetTop;
intLessLeft+=elCurrent.offsetLeft;
elCurrent = elCurrent.offsetParent;
}
elDragged._lessTop = intLessTop
elDragged._lessLeft = intLessLeft
// Calculate and cache target information
if (null!=elDragged.getAttribute("dropTarget"
elDragged._targets = elDragged.getAttribute("dropTarget"
elDragged._over = new Array
elDragged._elTargets = new Array
for (var intLoop=0; intLoop < elDragged._targets.length; intLoop++) {
var el = document.all[elDragged._targets[intLoop]]
if (null!=el) {
elDragged._elTargets[intLoop]= el;
var intLessTop = el.offsetTop; var intLessLeft = el.offsetLeft;
var elCurrent = el.offsetParent;
var intTop = document.body.scrollTop;
var intLeft = document.body.scrollLeft;
while (elCurrent.offsetParent!=null) {
intLessTop+=elCurrent.offsetTop;
intLessLeft+=elCurrent.offsetLeft;
elCurrent = elCurrent.offsetParent;
}
el._top = intLessTop + intTop
el._left = intLessLeft + intLeft
}
}
}
}
}
// Process all mouse events.
document.onmousedown = doMouseDown;
document.onmousemove = doMouseMove;
document.onmouseup = doMouseUp;
//array of all the images in the game
var Pictures = new Array;
Pictures[0] = '00001.gif';
Pictures[1] = '00002.gif';
Pictures[2] = '00003.gif';
Pictures[3] = '00004.gif';
Pictures[4] = '00005.gif';
Pictures[5] = '00006.gif';
Pictures[6] = '00007.gif';
Pictures[7] = '00008.gif';
Pictures[8] = '00009.gif';
Pictures[9] = '00010.gif';
//shuffle the images using a random number so that a new combination
//occurs each time the shuffle button is pressed
function shuffle()
{
for(i = 0;i<10;i++)
{
Pictures = Pictures.sort(getRandomNumber);
for(x = 0; x<10; x++)
{
document.images[x].src = Pictures[x];
document.images[x].style.top = 500;
document.images[x].style.pixelLeft = 5;
}
document.images[5].style.top = 500;
document.images[5].style.pixelLeft = 5;
}
}
function getRandomNumber()
{
return Math.floor(Math.random() * 10)-1;
}
</script>
<!--divisions for the images -->
<div id = "00001" style =" position:absolute;left:50;top:150;" dragEnabled dropTarget = "dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00001.gif" width = 250em height = 75em align = "center">
</div>
<div id = "00002" style = "position:absolute;left:50;top:150; position: absolute" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00002.gif" width = 250em height = 75em align = "center">
</div>
<div id="00003" style="position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00003.gif" width = 250em height = 75em align = "center">
</div>
<div id="00004" style ="position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00004.gif" width = 250em height = 75em align = "center">
</div>
<div id = "00005" style = "position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00005.gif" width = 250em height = 75em align = "center">
</div>
<div id = "00006" style = "position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00006.gif" width = 250em height = 75em align = "center">
</div>
<div id="00007" style = "position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00007.gif" width = 250em height = 75em align = "center">
</div>
<div id = "00008" style = "position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00008.gif" width = 250em height = 75em align = "center">
</div>
<div id = "00009" style = "position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00009.gif" width = 250em height = 75em align = "center">
</div>
<div id = "00010" style = "position:absolute;left:50;top:150;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00010.gif" width = 250em height = 75em align = "center">
</div>
<!--<div id = "00011" style = "position:absolute;left:200;top:450;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00011.gif" width = 75em height = 75em align = "center">
</div>
<div id = "00012" style = "position:absolute;left:320;top:450;" dragEnabled dropTarget="dropAnimal,dropAnimal2,dropAnimal3,dropAnimal4,dropAnimal5,dropAnimal6,dropAnimal7,dropAnimal8,dropAnimal9,dropAnimal10,dropAnimal11,dropAnimal12">
<img src = "00012.gif" width = 75em height = 75em align = "center">
</div>
<form align = "left" name="theTimer"><table>
<tr>
<td>
</td>
<td >
<input type=text name="theTime" size=5 align = "center">
</td>
<td>
</td>
</tr>
<tr>
<td width = "33%">
<input type = button name = "start" value = "Start" onclick = "Start()">
</td>
<td width = "33%">
<input type = button name = "stop" value = "Stop" onclick = "Stop()">
</td>
<td width = "33%">
<input type = "button" name = "button1" value = "Shuffle" onClick = "shuffle()">
</td>
</tr>
</table></form>
-->
<input type = "button" name = "button1" value = "Shuffle" onClick = "shuffle()">
<!--divisions for the drop areas in the table -->
<div id = dropAnimal style = "position: absolute; top: 50;left: 405; width: 290; height: 7em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00006')">
</div>
<div id = dropAnimal2 style = "position: absolute; top: 50;left: 695; width: 290; height: 7em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00001')">
</div>
<div id = dropAnimal3 style = "position: absolute; top: 160;left: 405; width: 290; height: 5.5em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00005')">
</div>
<div id = dropAnimal4 style = "position: absolute; top: 160;left: 695; width: 290; height: 5.5em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00003')">
</div>
<div id = dropAnimal5 style = "position: absolute; top: 248;left: 405; width: 290; height: 5em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00007')">
</div>
<div id = dropAnimal6 style = "position: absolute; top: 248;left: 695; width: 290; height: 5em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00004')">
</div>
<div id = dropAnimal7 style = "position: absolute; top: 328;left: 405; width: 290; height: 12em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00010')">
</div>
<div id = dropAnimal8 style = "position: absolute; top: 328;left: 695; width: 290; height: 12em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00009')">
</div>
<div id = dropAnimal9 style = "position: absolute; top: 515;left: 405; width: 290; height: 6.2em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00008')">
</div>
<div id = dropAnimal10 style = "position: absolute; top: 515;left: 695; width: 290; height: 6.2em; border: 1pt black solid; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00002')">
</div>
<!--divisions for text
<div id = title style = "position: absolute; top: 0;left: 300; width: 200; height: 3.5em; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00006')">
<h1>Animal Game</h1>
</div>
<div id = instructions style = "position: absolute; top: 15;left: 500; width: 470; height: 2em; z-index: -1; background: white" onOverTarget="doOverTarget()" onOutTarget="doOutTarget()" onDropTarget= "TestNumber('00006')">
<br>
<p>Press Play to Start. When you are finished playing press Stop for your time and score.
Press Shuffle and then Start to begin a new game.</p>
</div>
-->
<table border = 5 align = right width = 60% cellpadding = 12 cellspacing = 2.5 >
<tbody>
<tr>
<td width = 50%>This theory stresses initial disparities and the rigidity of the system, pointing out that under such conditions the free play of market forces is bound to lead to an unbalanced regional growth.</td>
<td width = 50%>This policy is a policy that tries to address regional imbalances that have occurred over time.</td>
<tr>
<td width = 50% >This theory suggests that similar economic activities regularly tend to concentrate in the same locations.</td>
<td width = 50% >This theory views development as a succession of stages through which all economies must pass to become ‘developed’.</td>
</tr>
<tr>
<td width = 50% >This theory is based on the idea that demand in a given region is the summation of domestic, export and import demand.</td>
<td width = 50%>This theory is interested in the workings of the political economy.</td>
</tr>
<tr>
<td width = 50%>This theory suggests that regions go through stages of structural change - from an economy initially dominated by primary sector, to one characterised by secondary sector dominance, to the prevalence of tertiary sector production.</td>
<td width = 50%>This theory believes that if the market is able to operate freely, it will automatically bring about economic development and is based on four major assumptions - free competition and market entry, full employment of factors of production (labour and capital), full mobility of labour and capital, and common level of technology.</td>
</tr>
<tr>
<td width = 50%> This theory is used to explain regional specialisation in the production of certain goods, and inter-regional and international trade.</td>
<td width = 50%>This policy can be defined as all aspects of State action that, directly or indirectly, influences the nature of economic and social development in rural areas.</td>
</tr>
</tbody>
</table>
</body>
</html>