var gDirection = 1;
var gCurrentDirection = true;
var	gPreviousDirection = true;

// define class to load store data into xml via ajax
function artwork() 
{
	this.windowWidth = document.body.clientWidth;
	this.windowHeight = document.body.clientHeight;	
	this.maxOutfitImageWidth=500;// max width of image in center
	this.maxButterflyImageWidth = 70;
	this.iFliesCounter = 0;
	this.iMaxFlies = 50;
	this.iNumButterflies = 7;
}

/*
// load the data from the server into a hashtable with key being counter (0,1,.. numOutfits-1)
artwork.prototype.addButterflies = function()
{
	var artworkLayer = document.getElementById('artworkLayer');
	artworkLayer.innerHTML = "";
		
	var ii,iLeftLoc,iTopLoc,tmpImage;
	var imageMaxWidth=70;
	var imageMaxHeight=50;
	var iRandom = Math.round(Math.random());
	for (ii=0;ii<this.iNumButterflies;ii++)
	{
		tmpImage = new Image();
		tmpImage.src = 'artwork/butterfly' + (ii+1) + '.gif';
		tmpImage.style.position="absolute";
		iLeftLoc = Math.floor(this.windowWidth*Math.random());
		var remainingWidth = (this.windowWidth-this.maxOutfitImageWidth)/2;
		
		if (ii%2 == 0)
		{
			iLeftLoc = Math.floor( ((remainingWidth)*Math.random()) );
		}
		else
			iLeftLoc = Math.floor(remainingWidth + this.maxOutfitImageWidth) + (remainingWidth*Math.random()) - this.maxButterflyImageWidth;
		
		iRandom = Math.random();
		iTopLoc  = 28 + Math.floor((367-28)*Math.random());
	
		tmpImage.style.left = iLeftLoc;
		tmpImage.style.top= iTopLoc;
		artworkLayer.appendChild(tmpImage);
	}
	
	this.addLadyBug();
	//moveLadyBug();
};
*/

/*
// load the data from the server into a hashtable with key being counter (0,1,.. numOutfits-1)
artwork.prototype.addLadyBug = function()
{
	var artworkLayer = document.getElementById('artworkLayer');
	artworkLayer.innerHTML = "";
	var tmpImage = new Image();
	tmpImage.src = 'images/ladybug2.gif';
	tmpImage.style.position = "absolute";
	tmpImage.style.left = 100 + Math.floor((this.windowWidth-100)*Math.random() - 34); // min 100 pixels from left and offset width so not too far right
	tmpImage.style.top = this.windowHeight - 0;
	tmpImage.id = 'ladybug';
	tmpImage.style.cursor = "pointer";
	tmpImage.onclick = function()
	{
		alert("hi");
	}
	artworkLayer.appendChild(tmpImage);
}
*/

/*
// load the data from the server into a hashtable with key being counter (0,1,.. numOutfits-1)
function flyButterflies()
{
	if (myArtwork.iFliesCounter < myArtwork.iMaxFlies)
	{
		self.setTimeout("flyButterflies()", 200);
		myArtwork.addButterflies();
		myArtwork.iFliesCounter++;
	}
}
*/



// load the data from the server into a hashtable with key being counter (0,1,.. numOutfits-1)
function moveLadyBug()
{
	//alert("in moveLadyBug");
	var ladybug = document.getElementById('ladybug');
	var iLeftLoc = ladybug.style.left;
	var iLeftLocNum = parseInt(iLeftLoc.substring(0, iLeftLoc.length - 2));

	iLeftLocNum = iLeftLocNum + (2*gDirection);
	ladybug.style.left = iLeftLocNum;
	//alert("iLeftLocNum"+iLeftLocNum);
	
	self.setTimeout("moveLadyBug()", 200 + Math.random()*1000);
	if (iLeftLocNum < 900 && (iLeftLocNum > 100))
	{
		gCurrentDirection = true;
	}
	else
	{
		gCurrentDirection = false;
	}	
	
	if (gCurrentDirection == false && gPreviousDirection == true)
	{
		gDirection = -1;
		document.getElementById('ladybug').src = "images/ladybugleft.gif";
	}
	
	gPreviousDirection = gCurrentDirection;	
}

function showLadyBugDetails()
{
document.getElementById('actorimage').src = "images/hannah.jpg";
myLoadStoreEO.stopAutoPlay();
}

function showOwlDetails()
{
document.getElementById('owl').src = "images/owlfront.jpg";
document.getElementById('actorimage').src = "images/dave.jpg";
myLoadStoreEO.stopAutoPlay();
}

