var assetDir = 'gifs/';
$("document").ready (function() {
	$("a .nav").mouseover(function()
	{
		doRoll(this.id);
	});
	$("a .nav").mouseout(function()
	{
		doRollOff(this.id);
	});
	$(".clickable").click(function() {
		getClick(this.href);
		
		return false;
	});
	$("#Name").focus();
});


function doRoll(id)
{
	var theImg = assetDir + id + "On.gif";
	var theTarget = $("#" + id).attr("src", theImg);
	
}

function doRollOff(id)
{
	var theImg = assetDir + id + "Off.gif";
	var theTarget = $("#" + id).attr("src", theImg);
}

// open a window to record a click and redirect
function getClick(theUrl)
{
	var url = 'index.php?act=c.getClick&url=' + theUrl;
	var objPopup = window.open(url,'detailWin','menubar=1,status=1,location=1,toolbar=1,scrollbars=1,directories=0');
	objPopup.focus();
}

// check the email Address
function chkAddr(email)
{
		var pattern = /^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]+$/;

		returnValue = pattern.test(email);
		
		return returnValue;		
	}

// check the email form
function chkMail()
{
		var returnValue = false;
		var email = $("#EmailAddress").val();
		var emailChk = chkAddr(email);
		alert(emailChk);
		
			var missing = new Array();
			
			
			$(".required").each(function()
			{
			var theId = this.id;
			var theValue = $("#" + this.id).val();
			if (theValue == '')
		
			{
		
			missing.push(theId);
		
			$("label[for='" + this.id + "']").addClass('error');
		
			}
		
			else
		
			{
		
			$("label[for='" + this.id + "']").removeClass('error');
		
			}
			});

			if (missing.length > 0)
			{
			var alertMsg = "'" + missing[0] + "' is a required field.";
			$("#" + missing[0]).focus();
			alert(alertMsg);
			missing.length = 0;
			}
			else if (!emailChk)
			{
				alert('That does not appear to be a valid email address.');
				$("#Email").focus();
			}
			else
			{
			returnValue = false;
			}
		return returnValue;
		}
