﻿var newCount;
var oImg = document.getElementById("qimg");

function updnav(thisnav)
{
	for(var i=1;i<=5;i++)
	{
		var currRow = document.getElementById("col" + i);
				
		if(i==thisnav)
		{
			currRow.style.background = "url(../../Images/site/col" + i + "-on.jpg) top left no-repeat";
		}
		else
		{
			currRow.style.background = "url(../../Images/site/col" + i + "-off.jpg) top left no-repeat";
		}
	}
}

function outnav()
{
	for(var i=1;i<=5;i++)
	{
		var currRow = document.getElementById("col" + i);
		currRow.style.background = "url(../../Images/site/col" + i + ".jpg) top left no-repeat";
	}
	
}

function moveQ()
{
	moveit('766');
	
	
}

function moveit(oCount)
{
	var oImg = document.getElementById("qimg");
	if(oCount!=0)
	{
		newCount = eval(oCount - 1);
		//alert(oCount);
		oImg.style.marginLeft =  "-" + oCount + "px";
		setTimeout("moveit('" + newCount + "')",1);
		
	}
	
}	

var fullWidth = 336;
var smallWidth = 83;
var smallWidthX = 75;
var pixSpeed = 14

function loadFirst()
{
	var bx1Src = document.getElementById("box1");
	bx1Src.style.width = fullWidth + "px";
}

	
function slideIt(newbox, oldbox, currcount)
{
	var runSrc = document.getElementById("isrunning");
	runSrc.value = "true";
	
	if(currcount<=fullWidth)
	{
		currcount = currcount + pixSpeed;
		newbox.style.width = currcount + "px";
		
		oldbox.style.width = fullWidth - (currcount - smallWidth) + "px";
		
		if(currcount>=200&&currcount<210)
		{
			var offImg = document.getElementById(oldbox.id + "on");
			offImg.style.display = "none";
			
			var offImg2 = document.getElementById(oldbox.id + "off");
			offImg2.style.display = "block";
			
			var onImg = document.getElementById(newbox.id + "on");
			onImg.style.display = "block";
			
			var onImg2 = document.getElementById(newbox.id + "off");
			onImg2.style.display = "none";
		}
		
		if(currcount>=fullWidth)
		{
			oldBox = document.getElementById("thisOldBox");
			oldBox.value = newbox.id;
			runSrc.value = "false";
		}
		else
		{
			setTimeout(function() {slideIt(newbox, oldbox, currcount)}, 1)
		}
	}
}

	
function slideBox(thisBox)
{	

	var bx1Src = document.getElementById("box" + thisBox);
	var runSrc = document.getElementById("isrunning");
							
	oldBox = document.getElementById("thisOldBox");
	var oSrc = document.getElementById(oldBox.value);
	currBox = "box" + thisBox;
	
	if(runSrc.value=="false"&&oldBox.value!=currBox)
	{
		slideIt(bx1Src, oSrc, smallWidthX);
	}
}		

function startSlide(thisBox)
{
	//this can be used to change initial background, then start slide
	var bx1Src = document.getElementById("box" + thisBox);
	//bx1Src.style.border = "solid 1px green";
	//bx1Src.style.width = smallWidth + "px";

	//setTimeout(function() {pausecomp(50, thisBox, 'true')}, 100);
	slideBox(thisBox);

}

function pausecomp(millis, thisBox, doStart) 
{
	var date = new Date();
	var curDate = null;
	
	if(doStart=="true")
	{
		do { curDate = new Date(); } 
		while(curDate-date < millis);
		
		slideBox(thisBox);
	}
	else
	{
		//alert("green border");
		pausecomp(millis, thisBox, 'true');
	}
} 


