function saveLogin(name)
{
	var doyou = confirm("This feature is only available to members.  Would you like to register for you free account now? (OK = Yes   Cancel = No)");
	if (doyou == true)
		return true;
	else if (doyou == false)
		return false;
}

function validateForm(formname) { //v4.0
	var p, formname, varname, vartype, varvalue, varcap, errors='', args=validateForm.arguments;
	for (i=1; i<(args.length-2); i+=3) { 
		varname = args[i];
		varcap = args[i+1];
		vartype = args[i+2];
		if( vartype != "checkboxes" && vartype != "P" )
			varvalue = eval( 'document.'+formname+'.'+varname+'.value' );
		
//			alert( varcap + "    " + vartype );
		
		if( vartype == "R" ) {
			if( varvalue.length == "0" )
				errors += '- '+varcap+' is required.\n'
		} else if( vartype == "N" ) {
			if( varvalue.length == 0 || isNaN(varvalue) )
				errors += '- '+varcap+' must contain a number.\n'
		} else if( vartype == "P" ) {
			varvalue1 = eval( 'document.'+formname+'.'+varname+'1.value' );
			varvalue2 = eval( 'document.'+formname+'.'+varname+'2.value' );
			varvalue3 = eval( 'document.'+formname+'.'+varname+'3.value' );
			if( (varvalue1.length != 0 || varvalue2.length != 0 || varvalue3.length != 0 ) &&
			  	( varvalue1.length < 3 || varvalue2.length < 3 || varvalue3.length < 4 ||
			  	  isNaN(varvalue1) || isNaN(varvalue2) || isNaN(varvalue3) ) )
				errors += '- '+varcap+' must be a valid phone number.\n'
		} else if( vartype == "Z" ) {
			varvalue = varvalue.replace(/-/gi, '');
			if( varvalue.length != 0 && ( varvalue.length < 5  || isNaN(varvalue) ) )
				errors += '- '+varcap+' must be a valid zip code.\n'
		} else if( vartype == "Drop" ) {
			if( varvalue == "" )
				errors += '- '+varcap+' must contain a valid selection.\n';
		} else if( vartype == "Email" ) {
			p = varvalue.indexOf('@');
    		if (p<1 || p==(varvalue.length-1))
    			errors+='- '+varcap+' must contain an e-mail address.\n';
		} else if( vartype == "checkboxes" ) {
			var elements = eval( 'document.'+formname+'.elements' );
			var size = elements.length;
			var good = false;
			for( p = 0; p < size; p++ ) {
				if( elements[p].name.substring(0,varname.length) == varname )
					if( elements[p].checked == true )
						good = true;
			}
			if( good == false )
				errors+='- '+varcap+' must contain a valid selection.\n';
		}
	}
	if (errors != "" ) {
		alert('The following error(s) occurred:\n'+errors);
		return false;
	} else
		return true;
}

function validateSearch() {
	countyval = eval( 'document.search.county.value' );
	subdivisionval = eval( 'document.search.subdivision.value' );
	cityval = eval( 'document.search.city.value' );
	postalcodeval = eval( 'document.search.postalCode.value' );
	listingID = eval( 'document.search.listingID.value' );
	errors = "";

	var elements = eval( 'document.search.elements' );
	var size = elements.length;
	var good = false;
	for( p = 0; p < size; p++ ) {
	if( elements[p].name.substring(0,4) == 'type' )
		if( elements[p].checked == true ) {
			good = true;
		}
	}
	if( good == false )
		errors+='Please select at least one Property Type.\n';


	if( countyval == "" && subdivisionval == "" && cityval == "" && postalcodeval == "" && listingID == "" ) {
		errors += "Please enter a valid selection for at least one of the following search fields:\n";
		errors += " - Listing Number\n";
		errors += " - County\n";
		errors += " - Subdivision\n";
		errors += " - City\n";
		errors += " - Zip Code\n";
	}
	
	if (errors != "" ) {
		alert(errors);
		return false;
	} else
		return true;
}

function validateQuickSearch() {
	cityval = eval( 'document.quicksearch.city.value' );
	postalcodeval = eval( 'document.quicksearch.postalCode.value' );
	listingID = eval( 'document.quicksearch.listingID.value' );
	errors = "";

	if( cityval == "" && postalcodeval == "" && listingID == "" ) {
		errors += "Please enter a valid selection for at least one of the following search fields:\n";
		errors += " - Listing Number\n";
		errors += " - City\n";
		errors += " - Zip Code\n";
	}
	
	if (errors != "" ) {
		alert(errors);
		return false;
	} else
		return true;
}