function popUp(URL,w,h) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,height="+h+",width="+w+",left = 0,top = 0');");
}

function setRequiredColors(fieldName)
{
	var label = fieldName + "Label";
	if(fieldName == "phone2" || fieldName == "phone3")
	{
		label = "phone1Label"
	}
	if (document.getElementById(fieldName).value == "")
	{
		document.getElementById(label).style.color="#C00";
	}
	else
	{
		document.getElementById(label).style.color="#333";
	}
}

function checkFields() {
	var fieldsArray	= new Array();
		fieldsArray	= Array('contactName','production','businessName','address1','city','county','state','zip','email','phone1','phone2','phone3','income2006','income2005','income2004','income2003','income2002');
	for (var i=0; i<fieldsArray.length; i++)
	{
		var label = fieldsArray[i] + "Label";
		if(document.getElementById(fieldsArray[i]).value == "")
		{
			// set form action to nothing
			document.forms.quoteForm.action= "";
			// alert the problem
			alert ("You are missing one or more required field(s).");
			// loop through all fields for text color change
			for (var j=0; j<fieldsArray.length; j++)
			{
				setRequiredColors(fieldsArray[j]);
			}
			return(false);
		}
		else
		{
			document.forms.quoteForm.action="http://www.agr-insurance.com/form_action.php";
		}
	}
}

function autoTab(input, len, next)
{
	if(input.value.length >= len) {
	document.getElementById(next).focus();
	}
}