function ProductToolTip(name, picture, list_priceWithUnit, priceWithUnit, unitsInStock, product_code)
{
	in_stock = "";
	if (unitsInStock > 0)
		in_stock = "<strong style='color: #2DD10E;'>Produsul este in stoc.</strong>";
	else
		if (unitsInStock == 0)
			in_stock = "<strong style='color: #EC0800;'>Disponibil doar la comanda.</strong>";

	listPrice = "";
	if (parseFloat(list_priceWithUnit.replace(",", "")) > parseFloat(priceWithUnit.replace(",", "")))
		listPrice =
			"<span style='font-size: 12px; font-weight: bold'>" +
				"Pret lista:&nbsp;<strike style='color: brown;'>" + list_priceWithUnit + "</strike>" +
			"</span>" +
			"<br />";

	tipContent =
		"<strong style='font-size: 12px;'>" + name + "</strong><br />" +
		"<img src='products_pictures/" + picture + "' />" +
		"<br style='clear: both;'/>" +
		"<span style='float: right;'>" +
			listPrice +
			"<span style='font-size: 16px; font-weight: bold'>" +
				"Pret:&nbsp;" + priceWithUnit +
			"</span>" +
		"</span>" +
		in_stock +
		"&nbsp;&nbsp;<br />" +
		"Cod produs: " + product_code + "&nbsp;&nbsp;";

	Tip(tipContent, WIDTH, '-308');
}

function _formatPrice( _price )
{
	_pointIndex = -1;
	for( i=0; i<_price.length; i++ )
		if ( _price.charAt(i) == '.' )
		{
			_pointIndex = i;
			break;
		}

	if (  _pointIndex == -1 )
		_price = _price + ".00";
	else if (  _price.length-1 - _pointIndex == 1  )
		_price = _price + "0";

	_res = "";

	i=0;
	for( i=_price.length-1; i >= 0; i-- )
	{
		if ( _price.charAt(i) == '.' )
			break;
		else
			_res = _price.charAt(i) + _res;
	}

	_res = "." + _res;

	i--;
	_digitCounter = 0;
	for( ; i>=0; i-- )
	{
		_digitCounter ++;
		_res = _price.charAt(i) + _res;
		if ( _digitCounter == 3 && i != 0 )
		{
			_res = "," + _res;
			_digitCounter = 0;
		}
	}

	return _res;
}

function Cand_va_fi_pe_stoc(productID)
{
	if(productID>0)
	{
		window.open('index.php?productID=' + productID + '&when=yes', '',
					'top=' + ((screen.height-320)/2) + ',' +
					'left=' + ((screen.width-500)/2) + ',' +
					'width=500, height=250, ' +
					'scrollbars=no, resizable=no');
	}
}

function NewProductReview(productID)
{
	params = "new_product_review=yes&productID=" + productID;
	PostProductReviewAjaxCall(params);
}

function PostProductReview(elem, productID)
{
	form = elem.form;
	if (ValidateForm(form))
	{
		params = "post_product_review=yes&productID=" + productID;
		post = "nick=" + encodeURI(form.nick.value) + "&" +
				"topic=" + encodeURI(form.topic.value) + "&" +
				"email_review=" + encodeURI(form.email_review.value) + "&" +
				"body=" + encodeURI(form.body.value) + "&" +
				"rating=" + encodeURI(form.rating.value);
		PostProductReviewAjaxCall(params, post);
	}
}

function PostProductReviewBack(productID)
{
	params = "post_product_review=yes&productID=" + productID;
	PostProductReviewAjaxCall(params);
}

function ProductRating(rating)
{
	cr = "width: " + rating * 20 + "%";
	$("#new_product_rating").val(rating);
	$("#current_rating").attr("style", cr);
}
