function format(str)
{
		str = unescape(str.replace(/&amp;/g,"&"));
		return str;
}
	
function showAllCats(str)
{
	alert(unescape(str));
}

function trimString(str)
{
	if (!(str == "")) {
	while('' + str.charAt(0) == ' '){
		str=str.substring(1,str.length);
	}
	}
	//take out trailing spaces
	if (!(str == "")) {
	while (str.charAt(str.length - 1) == ' '){
    	str = str.substring(0, str.length - 1);
	}
	}
	return str;
}

function showCategories(str)
{

	var strcat 		= str;
	var arrcat 		= strcat.split("^");
	var count  		= 0;
	var cats   		= "";	
	var allcats 	= "";
	//if(ar[0])
	//{
	//	cats   		= (ar[0] + ", ");	
	//	allcats 	= (ar[0] + "<br>");
	//}

	//for (x=0; x<ar.length; x++)
	//{
		for (i=0; i< arrcat.length; i++)
		{
			//if((trimString(arrcat[i])) == trimString(ar[x]))
			//{				
			    if(count < 1)
			    {
					cats += ( trimString(arrcat[i]) + ", ");	
					allcats	+= (arrcat[i] + "<br>");				    
			    }
			    else if (count < 2)
				{
					cats += ("<br>" + trimString(arrcat[i]) + ", ");	
					allcats	+= (arrcat[i] + "<br>");	
				}else
				{
					allcats	+= (arrcat[i] + "<br>");							
				}	
				count ++;					
			//}
		}
	//}

	document.write(cats.substring(0,cats.length-2));

	if (!(count < 3))
	{
		var str = ",<br><a href='javascript://' onclick=\"callAlert('" + (allcats) + "');\">More</a>...";
		document.write(str);
	}
}

function callAlert(text)
{
	var title = "More Categories";
	var pos;
	if (window.innerHeight)
	{
		pos = window.pageYOffset
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	{
		pos = document.documentElement.scrollTop
	}
	else if (document.body)
	{
		pos = document.body.scrollTop
	}
	el = document.getElementById('alertbox');
	document.getElementById('alerttitle').getElementsByTagName('span')[0].firstChild.nodeValue = title;
	document.getElementById('alertcontent').innerHTML = text;
	el.style.display = 'block';
	el.style.top = (((f_clientHeight() - el.offsetHeight) / 2)+pos) + 'px';
	el.style.left = (f_clientWidth() - el.offsetWidth) / 2 + 'px';
}

function closeIt()
{
	document.getElementById('alertbox').style.display = 'none';
	//document.getElementById('cover').style.display = 'none';
}

function f_clientWidth()
{
	return f_filterResults
	(
	window.innerWidth ? window.innerWidth : 0,
	document.documentElement ? document.documentElement.clientWidth : 0,
	document.body ? document.body.clientWidth : 0
	);
}

function f_clientHeight()
{
	return f_filterResults
	(
	window.innerHeight ? window.innerHeight : 0,
	document.documentElement ? document.documentElement.clientHeight : 0,
	document.body ? document.body.clientHeight : 0
	);
}

function f_filterResults(n_win, n_docel, n_body)
{
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
	n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}