function RatingUI(starPrefix, maxStars, defaultRating, productId, messageId)
{
	this.starPrefix = starPrefix;
	this.defaultRating = defaultRating
	this.maxStars = maxStars;
	this.productId = productId;
	this.messageId = messageId;
	
	this.showStars = function(starId)
	{
		this.clearStars();
		while(starId > 0)
		{
			document.getElementById(this.starPrefix+starId).className = 'rateStarSelected';
			starId--;
		}
	}
	
	this.clearStars = function()
	{
		starId = 1;
		while(starId <= this.maxStars)
		{
			document.getElementById(this.starPrefix+starId).className = 'rateStar';
			starId++;
		}
	}
	
	this.doRate = function(rating)
	{
		this.showMessage();
		this.defaultRating = rating;
		__doAjaxPostBack(this.messageId, '/prodfunc.php', 'action=rate&product=' + this.productId + '&rating=' + rating, 'POST');
	}
	
	this.resetStars = function()
	{
		this.clearStars();
		starId = 1;
		while(starId <= this.defaultRating)
		{
			document.getElementById(this.starPrefix+starId).className = 'rateStarSelected';
			starId++;
		}
	}
	
	this.setDefaultRating = function(rating)
	{
		this.defaultRating = rating;
	}
	
	this.showMessage = function()
	{
		document.getElementById(this.messageId).style.display='block';
	}
}

function WatermarkUI(tbId, watermarkText, watermarkCssClass, normalCssClass)
{
	this.tbId = tbId;
	this.watermarkText = watermarkText;
	this.watermarkCssClass = watermarkCssClass;
	this.normalCssClass = normalCssClass;
	
	this.hideWatermark = function()
	{
		tbElement = document.getElementById(this.tbId);
		if(tbElement.value == this.watermarkText)
		{
			tbElement.value = '';
			tbElement.className = this.normalCssClass;
		}
	}
	
	this.showWatermark = function()
	{
		tbElement = document.getElementById(this.tbId);
		if(tbElement.value == '' || tbElement.value == this.watermarkText)
		{
			tbElement.value = this.watermarkText;
			tbElement.className = watermarkCssClass;
		}
	}
}

function Ajax()
{
	var handler = null;

	try
	{
		handler = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try
		{
			handler = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				handler = new XMLHttpRequest();
			}
			catch (e)
			{
				handler = null;
			}
		}
	}

	if ( handler == null )
		return null;

	this.Open = function(processFunction, url, method, vars)
	{
		this.URL = url;
		this.Method = method.toUpperCase();

		try
		{
			if (this.Method == "POST")
			{
				handler.open(this.Method, this.URL, true);
				handler.setRequestHeader("Method", "POST " + this.URL + " HTTP/1.1");
				handler.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			}
			else
			{
				handler.open("GET", this.URL + "?" + vars, true);
				vars = "";
			}

			handler.onreadystatechange = function()
			{
				processFunction(handler);
			}

			handler.send(vars);
		}
		catch (e)
		{
			alert(e);
		}
	};
}