function checkdata()	{

// RESET PREVIOUS FLAGGED FIELDS HERE

for (i=1;i<fieldarray[0];i++)	{

	eval("reset = document.f"+i);
	reset.src = "/store/images/required.gif";

}

// DEFINE THE NECCESARY VARIABLES HERE
addlen = document.checkthis.customer_email.value.length;
invalidchar = 0;
usernamelength = 0;
ampcount = 0;
ampposition = 0;
domainlength = 0;
domaindotcount = 0;
lastdomaindot = 0;
errorcount = 0;
var errorlist = new Array();

//BEGIN EMAIL VALIDATION HERE
 for(i = 0;i < addlen;i++)	{
  thischar = document.checkthis.customer_email.value.substring(i,i+1);

if (/^\w|-|\.|@$/.test(thischar))	{
		if (ampcount == 0 && thischar != "@")	{
			usernamelength++;
		}
 	if (thischar == "@")	{
			ampcount++;
			ampposition = i;
		}
		if (ampcount == 1 && thischar != "@")	{
			domainlength++;
		}
		if (ampcount == 1 && thischar == ".")	{
			if (i == ampposition+1 || i == lastdomaindot+1)	{
				invalidchar++;
			}
			domaindotcount++;
			lastdomaindot = i;
    	}
			}
	else	{
	invalidchar++;
		}
}
	if (invalidchar == 0 && usernamelength >= 1 && ampcount == 1 && ampposition != 0 && domaindotcount >= 1 && lastdomaindot+3 <= addlen && lastdomaindot+8 >= addlen && domainlength >= 4)	{
	var blah = "wee";
	}
	else	{
		errorcount++;
		eval("errorlist["+errorcount+"] = 'f"+emailfield+"'");
	}
// BEGIN ARRAY FIELD CHECK HERE
	for (i=1;i<fieldarray[0];i++)	{
		eval("checkit = fieldarray[" + i + "]");
            if (document.checkthis [checkit].value.length < 1)	{
				errorcount++;
				eval("errorlist["+errorcount+"] = 'f"+i+"'");	
			}
	}	

// BEGIN FLAGGING ERROR FIELDS HERE
		if(errorcount >= 1)	{
			for(i=1;i<errorcount+1;i++)	{
				eval("flagit = errorlist[" + i + "]");
				document [flagit].src = err1.src;
			}
        alert("Please complete all required fields as shown.");
        return false;
		}
}
