
/*
find all with class 'pfield', get list if items and send request for prices.
*/
function insertPrices()
    {
		var items = $$('.pfield').pluck('id').toJSON();
    var url = 'http://www.automationdirect.com/ajax?' +
              'fctype=adc.falcon.FormControllers.ProductDisplayFormCtrl&' +
              'cmd=getProductPrices&' +
              'items='+items;
    new Ajax.CrossSiteRequest ( url, { method:'get' } );
    };

/*
process returned data (insert returned prices into document).
*/
function processPrices ( data )
    {
    data.evalJSON().each ( function(item) { $(item.code).update(item.price); } );
    }


/*
trigger to start process once the document is loaded.
*/
document.observe ( 'dom:loaded', insertPrices );
