
function execPriceCheck( seq, cat ) {

    var formatseq  = dojo.byId('product_formatseq');
    var styleseq   = dojo.byId('product_styleseq');
    var optionseq  = dojo.byId('product_optionseq');
    var option2seq  = dojo.byId('product_option2seq');
    var product_formatseq  = 0;
    var product_styleseq   = 0;
    var product_optionseq  = 0;
    var product_option2seq  = 0;
    if ( formatseq ) parseInt(product_formatseq = formatseq.value);
    if ( styleseq )  parseInt(product_styleseq = styleseq.value);
    if ( optionseq ) parseInt(product_optionseq = optionseq.value);
    if ( option2seq ) parseInt(product_optionseq = option2seq.value);
    
    // performs the address lookup and on success uses updateFormAddress to update the form
    dojo.xhrGet( {
            url: "ajaxbroker.php?type=price_check&seq=" + seq + "&cat=" + cat + "&bkey=" + product_formatseq + "_" + product_styleseq + "_" + product_optionseq + "_" + product_option2seq,
            handleAs: "text",
            timeout: 5000,
            load: function(response, ioArgs) {
                updatePriceField( response );
                return response;
            },
            error: function(response, ioArgs) {
                console.error("HTTP status code: ", ioArgs.xhr.status);
                return response;
            }
    });
}

function updatePriceField( response ) {
    if ( response !== 'INVALID' ) {
        dojo.byId('ajaxprice').innerHTML = response;
    }
}

function validOptions( errorMsg ) {
	
	var errors = 0;
	var format_seq  = document.getElementById('product_formatseq');
	var style_seq   = document.getElementById('product_styleseq');
	var option_seq  = document.getElementById('product_optionseq');
	var option2_seq = document.getElementById('product_option2seq');

	if ( null !== format_seq ) {
		if ( format_seq.selectedIndex == 0 ) errors++;
	}
	if ( null !== style_seq ) {
		if ( style_seq.selectedIndex == 0 ) errors++;		
	}
	if ( null !== option_seq ) {
		if ( option_seq.selectedIndex == 0 ) errors++;
	}
	if ( null !== option2_seq ) {
		if ( option2_seq.selectedIndex == 0 ) errors++;
	}

	if ( errors > 0 ) {
		alert(errorMsg);
		return false;
	}
	return true;

}
