/*
Will update the variable price when it is changed.

field->obj to update
quantity->var quantity to calc price for.
productid->var the product id.
*/
function variableUpdate(field,quantity,productid){
// give the field an ID for ajax_please to hook into.
	if(!field.id){
	
	//remove any of the id's already set on the page.
		if(document.getElementById("tempId")){
			
			document.getElementById("tempId").id='';
		
		}
		
		field.id = "tempId";
	}
ajax_please(field.id,'/workPrice.php','?id=' + productid + '&quantity=' + quantity,true);

}

/*
Used when updating the step pricing for list view.
pass it the dropdown box object that has all the attributes i need in it!
*/
function listViewUpdate(dropbox){
	//the dropdown box name happens to be the product ID. Score!
	var productID = dropbox.name;
	
	// the quantity is the selected index.
	var quantity = dropbox.options[dropbox.selectedIndex].value;
	
	//the field is the td element 1 left of the current drop down.
	var field = document.getElementById( 'price-' + productID);
	
	variableUpdate(field,quantity,productID);
	//field.style.fontWeight='bold';
}

/* Origional view update 
It's like the listViewUpdate except for the origional view.
*/
function origionalViewUpdate(dropbox){
	 productID = dropbox.name;
	 quantity = dropbox.options[dropbox.selectedIndex].value;
 	 var cell = document.getElementById('price-' + productID);
	
	variableUpdate(cell,quantity,productID);
}




/*
Update's price for product info page.
*/
function updateProductPrice(){
	var form = YAHOO.util.Dom.get('productinfo');

	callback =
	{
		success:priceUpdateOK,
  		failure:priceUpdateFAILED
	};
	
	YAHOO.util.Connect.setForm(YAHOO.util.Dom.get('productinfo'));
	YAHOO.util.Connect.asyncRequest('POST', "/workPrice.php?action=atts", callback, this);
}


function priceUpdateOK(o){
	YAHOO.util.Dom.get('productprice').innerHTML = o.responseText;

}

function priceUpdateFAILED(o){
	
}
	








function hotProductUpdate(dropbox){
	var field = document.getElementById('hotprice');
	var quantity = dropbox.options[dropbox.selectedIndex].value;
	var productID = dropbox.name;
variableUpdate(field,quantity,productID);

}


