function randomEyes()
{
	var imgEyes = document.getElementById('imgEyes');
	imgEyes.src = imgEyes.src;
	setTimeout("randomEyes()", 5000 + Math.floor(Math.random()*10000)); /* Every 5 to 15 seconds */
}
var spiderMoveTo, moveDown, spiderSpeed = 10, interations = 0, maxIterations = 35;
var imgSpider, imgString;
function spiderMove()
{
	var thirdHeight = Math.round($(document).height() / 3);
	imgSpider = document.getElementById("imgSpider");
	imgString = document.getElementById("imgString");
	moveDown = true;
	spiderMoveTo = Math.floor(Math.random() * (thirdHeight * 2));
	makeSpiderMove();
}
function makeSpiderMove()
{
	if (++interations > maxIterations)
	{
		interations = 0;
		maxIterations = 25 + Math.floor(Math.random() * 25);
		spiderSpeed = 10 + Math.floor(Math.random() * 25);
	}
	var pos = parseInt(imgSpider.style.top.replace("px", ""));
	if (moveDown)
	{
		if (pos < spiderMoveTo)
		{
			imgSpider.style.top = (++pos) + "px";
		}
		else
		{
			moveDown = false;
			interations = maxIterations; /* Make sure it gets a new (much faster) spiderSpeed on return */
			spiderSpeed = 5000 + Math.floor(Math.random() * 10000); /* Wait 5 to 15 seconds */
		}
		setTimeout("makeSpiderMove()", spiderSpeed);
	}
	else
	{
		if (pos > -10)
		{
			imgSpider.style.top = (--pos) + "px";
			setTimeout("makeSpiderMove()", spiderSpeed);
		}
		else
		{
			setTimeout("spiderMove()", 5000 + Math.floor(Math.random()*10000)); /* Every 5 to 15 seconds */
		}
	}
	imgString.style.height = Math.max(pos, 0) + "px";
}
$(document).ready(function() {

	$.fn.nyroModal.settings.minWidth = 750;
	$.fn.nyroModal.settings.minHeight = 500;
	$.fn.nyroModal.settings.autoSizable = false;

});


/* Portfolio */

var SWATCH_WIDTH = 164;
var SWATCH_PER_PAGE = 3;

var currentMargin = 0;
var currentIndex = 0;
function moveLeft()
{
	if (currentIndex <=  0)
	{
		currentIndex = swatches.length - SWATCH_PER_PAGE;
		movePhoto(-(SWATCH_WIDTH * (currentIndex)));
	}
	else
	{
		movePhoto(SWATCH_WIDTH);
		currentIndex--;
	}
}

function moveRight()
{
	if (currentIndex >= (swatches.length - SWATCH_PER_PAGE))
	{
		currentIndex = 0;
		movePhoto(SWATCH_WIDTH * (swatches.length - SWATCH_PER_PAGE));
	}
	else
	{
		movePhoto(-SWATCH_WIDTH);
		currentIndex++;
	}
}

function movePhoto(offset)
{
	currentMargin += offset;
	var val = currentMargin + "px";
	var duration = 1000;
	if ((offset != SWATCH_WIDTH) && (offset != -SWATCH_WIDTH))
	{
		duration = 2500;
	}
	$("#divPortfolioSlide").animate({marginLeft: val}, duration, "swing");
}

