var close=true;
var closeServ=true;
var closeAbout=true;
var closeTraining=true;
var workCount=0;
var servCount=0;
var aboutCount=0;
var trainingCount=0;

function startTimer()
{
	workCount++;
	close=true;
	setTimeout('tryClose()',400);
	
}

function startTimerAbout()
{
	aboutCount++;
	closeAbout=true;
	setTimeout('tryCloseAbout()',400);
	
}

function startTimerTraining()
{
	trainingCount++;
	closeTraining=true;
	setTimeout('tryCloseTraining()',400);
	
}

function cancelClose()
{
	close=false;
}

function tryClose()
{
	workCount--
	if(close&&workCount==0)
	{
		document.getElementById("workNav").style.zIndex='-1'
	}
}

function tryCloseAbout()
{
	aboutCount--
	if(closeAbout&&aboutCount==0)
	{
		document.getElementById("aboutNav").style.zIndex='-1'
	}
}

function tryCloseTraining()
{
	trainingCount--
	if(closeTraining&&trainingCount==0)
	{
		document.getElementById("trainingNav").style.zIndex='-1'
	}
}

function startTimerServ()
{
	servCount++;
	closeServ=true;
	setTimeout('tryCloseServ()',400);
	
}

function cancelCloseServ()
{
	closeServ=false;
}

function cancelCloseAbout()
{
	closeAbout=false;
}

function cancelCloseTraining()
{
	closeTraining=false;
}

function tryCloseServ()
{
	servCount--
	if(closeServ&&servCount==0)
	{
		document.getElementById("servicesNav").style.zIndex='-1'
	}
}

function EnlargeImage(imgSrc, desc)
{
	/*var newImg = new Image();
	newImg.src = imgSrc;
	
	if(newImg.width>newImg.height)
	{
		if(newImg.width>1000)
		{
			var scale = 1000/newImg.width;
			width = "1000";
			height = newImg.height*scale;
		}
		else
		{
			width = newImg.width;
			height = newImg.height;
		}
	}
	else
	{
		if(newImg.height>750)
		{
			var scale = 750/newImg.height;
			height = "750";
			width = newImg.width*scale;
		}
		else
		{
			width = newImg.width;
			height = newImg.height;
		}
	}
	*/
	document.getElementById('title').src = imgSrc.replace("size=2", "size=1");
	document.getElementById('text').innerHTML = "<h4 style'margin:0px; padding:0px; color:#f6e174'>"+desc+"</h4>";
	
	//newWindow = window.open("", "Enlarged", "width="+width+", height="+(height+30)+", scrollbars=no, status=yes, toolbar=no, location=no, resizable=no");
	//newWindow.document.write("<html><head><title>Enlarged Image</title></head><body onblur='this.close();' style='margin:0px'><img src='"+imgSrc+"' alt='Enlarged Image' title='Enlarged Image' width='"+width+"' height='"+height+"' />");
	//newWindow.document.write("<p style='text-align:center; padding-top:5px; margin:0px'><a href='javascript:this.close()'>Close Window</a></p></body></html>");
	//newWindow.document.close();
}
