
function checkCheckBox(agreement) {
if ( agreement.checked == true ){
	return true;
}else
	alert('Please read and designate your Agreement to Terms and Conditions.');
	return false;
}


function checkRate( rate ) {
	j=rate.length;
	for (a=0; a<j; a++){
		if(rate[a].checked) {
			//you found the rate
			return( rate[a].value );
		}
	}
}


function checkForReferred( thisForm ){
var start = 10 	// first referred company field in array
var opt40 = 5	// elements to check for at 40%
var opt100 = 4	// elements to check for at 100%
var vtocheck = 40
option1Good = checkOption( thisForm, start, opt40 );
start = 16;
option2Good = checkOption( thisForm, start, opt100 );
vtocheck = checkRate( thisForm.feerate );
if ( ((option1Good) && (vtocheck == 40)) || ( (option2Good) && ( vtocheck == 100)) ){
	return true;
}
else
	alert("You have not referred the proper number of company sites for the selected option. Please complete them, then submit again!");
	return false;
}


function checkOption( thisForm, start, max ) {
var i
var total = start + max
for (i=start;i<total;i++){
	if( thisForm.elements[i].value == '' ){
		break;
	}
}
if ( i < total ){
	return false;
}
else
	return true;
}



function checkForm( thisForm ) {
if (checkCheckBox( thisForm.agree ) && checkForReferred( thisForm ))
	{
		return true;
	}
	return false;
}


function printTerms(URL) {
var winRef;
winRef = popup5( URL );
winRef.print();
}
