//provide a random timestamp with each call to foil caching
function getTimestamp()
{
	var t = new Date();
	var r = "" + t.getFullYear() + t.getMonth() + t.getDate() + t.getHours() + t.getMinutes() + t.getSeconds(); 

	return(r);
}

function rateProduct(product_id, rating)
{	
	var url = '/services/rateproduct.php';
	var pars = 'p=' + product_id + '&r=' + rating + '&ts=' + getTimestamp();

	var stars = $('stars_'+product_id);	
	stars.innerHTML = '<center><blink>Updating</blink></center>';
	stars.style.display = "";
	
	var myAjax = new Ajax.Updater( 'stars_'+product_id, url, { method: 'get', parameters: pars, evalScripts: true}); 
}

function updateMiniSearch()
{
	if(!$('mini_searchresults'))
		return false;
	
	var url = '/services/minisearch.php';
	//todo add other fields to this search
	var pars = 'q=' + $F('title') + '&ts=' + getTimestamp();	
	
	Element.show('thinking');

	var myAjax = new Ajax.Updater('mini_searchresults', url, { method: 'get', parameters: pars, evalScripts: true }); 
}

function addTags(tags, product_id)
{	
	if(!tags)
		return false;

	var url = '/services/addtags.php';
	var pars = 'p=' +  product_id + '&t=' + tags + '&ts=' + getTimestamp();

	var tags = $('taglist');	
	tags.innerHTML = 'Updating...';
	tags.style.display = '';
	
	var myAjax = new Ajax.Updater( 'taglist', url, { method: 'get', parameters: pars, evalScripts: true}); 
	
	$('tags').value = '';
}