function checkform()
{
	var invalid_list = [];
	var result = true;
	
	$( 'rego' ).getElements( 'div[class=field_input]' ).each( function(e) {
		//alert( e.get( 'html' ));
		e_child = e.getElement( 'input' );
		if ( e_child != undefined && e_child.get( 'id' ) != 'postal_street2' && e_child.get( 'id' ) != 'submit_btn' )
		{
			if ( e_child.get( 'value' ).length < 2 )
				invalid_list.push( e_child.get( 'id' ));
		}
	});
	
	//alert( $( 'postal_state' ).getSelected().get( 'value' ));
	if ( $( 'postal_state' ).getSelected().get( 'value' ) == '' )
		invalid_list.push( 'postal_state' );
	
	//alert( invalid_list.length );
	if ( invalid_list.length > 0 )
	{
		var msg = 'Invalid field(s): \n';
		for( i = 0; i < invalid_list.length; i++ )
			msg += '-' + str_replace( '_', ' ', invalid_list[i] ) + '\n';
		alert( msg );
	}
	else
	{
		document.rego.submit();
	}
}

function str_replace(search, replace, subject) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'
 
    var f = search, r = replace, s = subject;
    var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;
 
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    };
 
    return sa ? s : s[0];
}