
fail=2;
function checkFields() 
{               
pass=1;
customer=document.contact.first.value;
customerlast=document.contact.last.value;
email=document.contact.email.value;  
	if(email=="" || customer=="" || customerlast=="")
	{
		alert("Please fill in all required fields");
		return false;		
	}  
	else
	{  
		if (email.indexOf("@")<1)
		{
			alert("I'm sorry. This email address seems wrong. Please check the prefix and '@' sign.");
			pass=fail;
			return false;
		}
		if ((email.indexOf(".")<1))
		{
			alert("I'm sorry. This email address seems wrong. Please check the suffix for accuracy.");
			pass=fail;
			return false;
		}
		if(pass!=fail)
		{
			
					setCookieArray();
					return true;
				
		}
	}
	
}

var expdate = new Date();
expdate.setTime (expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
store = new Array();
data = new Array();
store[0]="name";
store[1]="address";
store[2]="city";
store[3]="state";
store[4]="zip";
store[5]="tel";
store[6]="fax";
store[7]="url";
store[8]="email";

array_count=8;


function setCookie (name, value, expires)
{
        if (!expires)
		expires = new Date();
	document.cookie = name + "=" + escape (value) + 
	"; expires=" + expires.toGMTString() +  ";";
	
}

function setCookieArray()
{
	data[0]=document.contact.name.value;
	data[1]=document.contact.address.value
	data[2]=document.contact.city.value
	data[3]=document.contact.State.value
	data[4]=document.contact.zip.value
	data[5]=document.contact.Phone.value;
	data[6]=document.contact.FAX.value
	data[7]=document.contact.URL.value;
	data[8]=document.contact.email.value;

	for (var i = 0; i <= array_count; i++)
	{
    		setCookie (store[i], data[i], expdate);
	}        
}

function getCookieArray(parm)
{
	xtra=parm;
	array_count=8;
	if(document.cookie!="")
	{
		for (var i = 0; i <= array_count; i++)
		{
			getCookie(store[i],i);
        	}
	}
}

function getCookie (name,spot)
{
	var dcookie = document.cookie; 
	data[0]=document.contact.name;
	data[1]=document.contact.address;
	data[2]=document.contact.city;
	data[3]=document.contact.State;
	data[4]=document.contact.zip;
	data[5]=document.contact.Phone;
	data[6]=document.contact.FAX;
	data[7]=document.contact.URL;
	data[8]=document.contact.email;

	var cname = name + "=";
	var cooky="";
	var clen = dcookie.length;
	var cbegin = 0;
	while (cbegin < clen)
	{
        	var vbegin = cbegin + cname.length;
                if (dcookie.substring(cbegin, vbegin) == cname)
		{ 
                	var vend = dcookie.indexOf (";", vbegin);
                        if (vend == -1)
				vend = clen;
                	cooky=unescape(dcookie.substring(vbegin, vend));
                	data[spot].value=cooky;
			
		}
        	cbegin = dcookie.indexOf(" ", cbegin) + 1;
                if (cbegin == 0)
			break;
        }
}