function Has(array, object)
{
	for(var i=0; i < array.length; i++)
		if(array[i] == object)
			return true;
	return false;
}

function WriteType(type)
{
	for(var i=0; i < type.length - 1; i++)
		document.write(type[i], ' / ');
	document.write(type[i]);
}

function ListForType(sites, names)
{
	var array = new Array;
	var n = 0;

	for(var i = 0; i < sites.length; i++)
		for(var j = 0; j < names.length; j++)
			if(Has(sites[i], names[j]))
			{
				array[n++] = i;
				break;
			}
	return array;
}

function PutListing(array, n)
{
	if(array.length == 1)
		tag = array[0][0];
	else
		tag = array[1];
	var list = new ListForType(paySiteTypes, array[0]);
	document.write('<td class="news" style="color:000000"> &nbsp;<a href="reviews.shtml?0,3,'+n+'">'+tag+'</a> ('+list.length+') <br></td>');
}

function WriteTypeTable(n)
{
	for(var i = 0; i < categories.length; i++)
	{
		if(i % n == 0)
			document.write('</tr><tr>');
		PutListing(categories[i], i);
	}
}

function GetTag(array, n)
{
	if(array.length == 1)
		return array[0][0];
	else
		return array[1];
}

function GetListLength(array, n)
{
	var list = new ListForType(paySiteTypes, array[0]);
	return list.length;
}

function GetUrl(array, n)
{
	return 'reviews.shtml?0,3,' + n;
}

function ProcessTypeList(fun)
{
	var array = new Array;

	for(var i = 0; i < categories.length; i++)
	{
		array[i] = fun(categories[i], i);
	}
	
	return array;
}

function OutputTypeList(var_name, style_class)
{
	urls = ProcessTypeList(GetUrl);
	tags = ProcessTypeList(GetTag);
	lens = ProcessTypeList(GetListLength);

	document.write('<SELECT class="'+style_class+'" onChange="(this.selectedIndex != 0) ? (window.top.location.href=\'../adultcenter/\'+('+var_name+'[this.selectedIndex-1])) : null;">'); 
	document.write("<OPTION>Choose yours...");
	for (var i = 0; i < tags.length; i++)
		document.write("<OPTION>" + tags[i] + ' (' + lens[i] + ')');
	document.write('</SELECT>');

	return urls;
}
