var as = new Array(" ", "programming", "websites", "small business", "databases", "display systems", "clients", "about us", "contact us");
var timeOut = null;
var lastPage = 0;
var countTO = null;
var lastTxt = null;

/*
$(document).ready(function() {
	$(".mN").hover(function() {
		over(this);
	}, function() {
		countOut(this);
	});

	$(".dv").hover(function() {
		overInfo();
	}, function () {
		dvOut();
	});
	$(document.getElementById("dMenu")).show();
});
*/
function over(t)
{
	$(t).children('img').get(0).src = GetImgSrc(t.id.substring(1), "s");
	if ( countTO != null)
	{
		clearTimeout( countTO);
		countTO = null;			
	}
	if ( lastTxt != null)
	{
		hideLT();
	}
	else
	{
		$(document.getElementById("dMenu")).hide();
	}
	$(GetTextDiv(t)).show();
}

function hideLT()
{
	if ( lastTxt != null)
	{
		$(lastTxt).children('img').get(0).src = GetImgSrc(lastTxt.id.substring(1), "n");
		$(GetTextDiv(lastTxt)).hide();
		lastTxt = null;
	}
}

function divOver( d1, d2)
{
	over( document.getElementById( d2));
	lastTxt = document.getElementById( d2);
}

function countOut( t)
{
	lastTxt = t;
	countTO = setTimeout( "out()", 500);
}

function dvOut()
{
	countTO = setTimeout( "out()", 500);
}

function out()
{
	hideLT();
	$(document.getElementById("dMenu")).show();
	countTO = null;
}

function overInfo()
{
	clearTimeout( countTO);
	countTO = null;
}

function GetImgSrc(idC, s) {
	return "images/" + s + idC + ".png";
}

function GetTextDiv( t)
{
	return document.getElementById( "d" + t.id.substring(1));
}

function getYear()
{
	var d = new Date();
	var y = d.getFullYear();
	var s = "";
	if ( y > 2009)
	{
		s = "2009-";
	}
	s += y;
	document.write(s);
}

function submitForm()
{
	if ( $("#contact").valid())
	{
		var s = '{"name":"' + document.getElementById( 'name').value + '", "email":"' + document.getElementById( 'email').value
				 + '", "telno":"' + document.getElementById( 'telno').value 
				 + '", "msg":"' + document.getElementById( 'msg').value
				 + '"}';
		$.ajax( {
			type: "POST",
			url: "Service1.asmx/SendMail",
			contentType: "application/json; charset=utf-8",
			data: s,
			dataType: "json",
			success: responseForm
		});
		return false;
	}
}

function responseForm( req)
{
	document.getElementById( "mf").innerHTML = "<br><h2>Enquiry response</h2><br/><br>" + req.d + "<br/>!!<br/>";
	document.getElementById( "df").style.visibility="hidden";
	document.getElementById( "ans").style.visibility="visible";
}

function restoreForm()
{
	document.getElementById( 'name').value = "";
	document.getElementById( 'email').value = "";
	document.getElementById( 'telno').value = "";
	document.getElementById( 'msg').value = "";
	document.getElementById( "df").style.visibility="visible";
	document.getElementById( "ans").style.visibility="hidden";
}