//this file is referenced in several of his wrappers. If the id changes, update wrappers for all stores.

function updateCart() {

	$('contentMinicart').innerHTML = 'Updating - please wait!';
	new Effect.Highlight($('contentMinicart'));
	
	// this gets called by handleResponse (which is in zoovy.js)
   var postBody = 'm=RenderElement&format=WRAPPER&docid='+DOCID+'&element=IMAGECART&targetDiv=contentMinicart';
	new Ajax.Request(magic_url+'/ajax/RenderElement', { postBody: postBody, asynchronous: 1,
		onComplete: function(request){handleResponse(request.responseText);} }
		) ;
	}

//
// this function is overloaded, and is run whenever an "add_to_cart" button is clicked
//		it finds the form with a product id that matches on it.
//
function addToCart(id,pid) {
	// alert("adding To Cart (product: " + pid + ")");

   var postBody = 'm=AddToCart&cart='+session_id+'&pid='+pid;
	for (i = document.forms.length-1; i>=0; --i) {
		if (document.forms[i].elements['product_id']) {
			if (document.forms[i].elements['product_id'].value == pid) {
				postBody = postBody + '&' + Form.serialize(document.forms[i]);
			   new Ajax.Request(magic_url+'/ajax/AddToCart', { postBody: postBody, asynchronous: 1,
			      onComplete: function(request){handleResponse(request.responseText);} }
			      ) ;
				}
			}
		}
	// alert('finished with addToCart');	
	}
	
function clearText(thefield)	{
	if (thefield.defaultValue == thefield.value)
		thefield.value = "";
	}
