var pages = new Array( "index.htm", "programdevelopment.htm", "webdesign.htm", "smallbusinesssolutions.htm", 
					   "displaysystems.htm", "portfolio.htm", "casestudies.htm", "aboutus.htm", "contactus.htm")
var currentIndex = 0;
var countTO = null;
var restTO = null;
var pageIndex = GetPageIndex();

function showcursor( obj, index)
{
	if ( countTO != null)
	{
		clearTimeout( countTO);
		countTO = null;			
	}
	var cA = obj.coords.split(",");
	var cursor = document.getElementById("cursor");
	if ( cursor != null)
	{
		var y = parseInt(cA[1]);
		cursor.style.top = (y - 2) + "px";
		currentIndex = index;
		window.status = pages[ currentIndex];
	}
}

function showcursor2( obj, index)
{
	if ( restTO != null)
	{
		clearTimeout( restTO);
		restTO = null;			
	}
	if ( countTO != null)
	{
		clearTimeout( countTO);
		countTO = null;			
	}
	if ( pageIndex == index)
	{
		restore();
		return;
	}
	if ( currentIndex != 0)
		restore();
	showcursor( obj, index);
	document.getElementById("dText").className = "dv op";
	document.getElementById("dMenu").className = "d";
	//document.getElementById("darkoverlay").className = "dki";
	restTO = setTimeout ("restoreTimeout()", 5000);
	
	//return false;
}

function out()
{
	//restore();
	countTO = setTimeout( "restore()", 100);
	//return false;
}

function restore()
{
	currentIndex = 0;
	if ( countTO != null)
	{
		clearTimeout( countTO);
		countTO = null;			
	}
	var cursor = document.getElementById("cursor");
	if ( cursor != null)
	{
		cursor.style.top = "-1000px";
		document.getElementById("dText").className = "dv";
		document.getElementById("dMenu").className = "di";
		//document.getElementById("darkoverlay").className = "dk";
	}
}

function fadeRestore()
{
	currentIndex = 0;
	if ( countTO != null)
	{
		clearTimeout( countTO);
		countTO = null;			
	}
	var cursor = document.getElementById("cursor");
	if ( cursor != null)
	{
		cursor.style.top = "-1000px";
		$("#dText").fadeIn(1000);
		$("#dMenu").fadeOut(1000);
	}
}

function gotoindex()
{
	clearTimeout( countTO);
	clearTimeout( restTO);
	window.location = pages[currentIndex];
}

function gohome()
{
	window.location = pages[0];
}

function getYear()
{
	var d = new Date();
	var y = d.getFullYear();
	var s = "";
	if ( y > 2009)
	{
		s = "2009-";
	}
	s += y;
	document.write(s);
}

function restoreTimeout()
{
	clearTimeout( restTO);
	restore();
}

function GetPageIndex()
{
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	return pages.indexOf( sPage);
}