function buildRvi(count, _count, ar){
	if (ar.length == 0 || ar.length - _count == 0 || (ar.length == 1 && nodeid == ar[0].id))
		return "";
	var str = _buildRviStart();
	for(var i=_count, y=0; i< ar.length; i++){
		if (nodeid == ar[i].id){
			continue;
		}
		str += _buildRvi(count, ar[i]);
		y++;
		if (y >= count)
			break;
	}
	str += _buildRviEnd();
	return str;
}

function _buildRvi(count, prod){
	if (count == 0) return "";	
	var width = 100/count;
	width = parseInt(width);
	var content = '<td class="itemlist" width="'+width+'%">';
	content +='<div class="catprd">';
	if (prod.img.length > 0){
		content +='<a href="'+prod.url+'">';
		content +='<img src="'+prod.img+'" alt="' + prod.title + '"';
		if (prod.width > 0)
			content +=' width="'+prod.width+'"';
		if (prod.height > 0)
			content +=' height="'+prod.height+'"';
		content +=' border="0"></a>';
	}
	content +='<a href="'+prod.url+'"class="prodlink">';
	content +=prod.title+'</a>';
	content +='</div></td>';
	return content;
}

function _buildRviStart(){
	return '<h2 class="title">Recently Viewed</h2><table width="100%" border="0" cellpadding="4" cellspacing="0" align="center">'+
        '<tr>';
}

function _buildRviEnd(){
	return '</tr>'+
      '</table>';
}

function updateImg(text){
    var ctrl = document.getElementById("prd_img");
	if (!ctrl){
		return;
	}
	ctrl.innerHTML = text;
}

