/**
     *
     */
    function viewChannel($channel, $rows, $type, $pageNav, $total, $rows_favourites, $rows_recentlyviewed)
    {
		global $Itemid, $smartyvs, $mainframe, $hwdvsTemplateOverride, $limit;
		$c = hwd_vs_Config::get_instance();
  		$db =& JFactory::getDBO();
		// load the menu name
		jimport( 'joomla.application.menu' );
		$menu   = &JMenu::getInstance('site');
		$mparams = &$menu->getParams($Itemid);
		$mparams_pt	= $mparams->get( 'page_title', '');

		jimport( 'joomla.document.document' );
		$doc = & JFactory::getDocument();

		$active = &$menu->getActive();

		if (!empty($mparams_pt)) {
			$metatitle = $mparams_pt;
		} else if (!empty($active->name)) {
			$metatitle = $active->name;
		} else {
			$metatitle = _HWDVIDS_META_DEFAULT;
		}

		// set the page/meta title
		$doc->setTitle( $metatitle );
		$doc->setMetaData( 'title' , $metatitle );
		hwd_vs_tools::generateActiveLink(1);
		hwd_vs_tools::generateBreadcrumbs();

		// define javascript
		hwd_vs_javascript::confirmdelete();

		switch ($type)
		{
			case "videos":

				if (count($rows) > 0) {
					$smartyvs->assign("print_list", 1);
					$list = hwd_vs_tools::generateVideoListFromSql($rows, null, $hwdvsTemplateOverride['thumbWidth1']);
					$smartyvs->assign("list", $list);
				}

				$rpp = $c->vpp;
				$smartyvs->assign("noItems", "No user videos");

			break;
			case "groups":

				if (count($rows) > 0) {
					$smartyvs->assign("print_list", 1);
					$list = hwd_vs_tools::generateGroupListFromSql($rows, null, $hwdvsTemplateOverride['thumbWidth1']);
					$smartyvs->assign("list", $list);
				}

				$rpp = $c->gpp;
				$smartyvs->assign("noItems", "No user groups");

			break;
			case "playlists":

				if (count($rows) > 0) {
					$smartyvs->assign("print_list", 1);
					$list = hwd_vs_tools::generatePlaylistListFromSql($rows, null, $hwdvsTemplateOverride['thumbWidth1']);
					$smartyvs->assign("list", $list);
				}

				$rpp = $c->vpp;
				$smartyvs->assign("noItems", "No user playlists");

			break;
		}

		$smartyvs->assign("type", $type);

		$page = $total - $rpp;
		$pageNavigation = null;
		if ( $page > 0 ) {
			$link = "index.php?option=com_hwdvideoshare&Itemid=".$Itemid."&limit=".$limit;
			$pageNavigation.= $pageNav->getPagesLinks($link)."<br />";
			$pageNavigation.= $pageNav->getPagesCounter();
		}
		$smartyvs->assign("pageNavigation", $pageNavigation);

		if (count($rows_favourites) > 0) {
			$smartyvs->assign("print_favouriteslist", 1);
			$list_favourites = hwd_vs_tools::generateVideoListFromSql($rows_favourites, null, 50);
			$smartyvs->assign("list_favourites", $list_favourites);
		}

		if (count($rows_recentlyviewed) > 0) {
			$smartyvs->assign("print_recentlyviewedlist", 1);
			$list_recentlyviewed = hwd_vs_tools::generateVideoListFromSql($rows_recentlyviewed, null, 50);
			$smartyvs->assign("list_recentlyviewed", $list_recentlyviewed);
		}

		if (isset($channel->id))
		{
			$channelData->editchannel = hwd_vs_tools::generateEditChannelLink($channel);
			$channelData->channel_description = $channel->channel_description;
			$channelData->user_id = intval($channel->user_id);
			$channelData->views = intval($channel->views);
			$channelData->subscribe = hwd_vs_tools::generateChannelSubscriptionStatus($channel);
			$channelData->registerDate = strftime("%l%P - %b %e, %Y", strtotime($channel->registerDate));
			$channelData->lastvisitDate = strftime("%l%P - %b %e, %Y", strtotime($channel->lastvisitDate));
			$channelData->subscribers = $channel->subscribers;
			$channelData->uploads = $channel->uploads;
			$channelData->thumbnail = $channel->thumbnail;
			if (!empty($channelData->thumbnail))
			{
				$smartyvs->assign("displayChannelThumbnail", 1);
			}
		}
		else
		{
			$channelData->user_id = intval($channel->user_id);
		}
		$smartyvs->assign("channelData", $channelData);

		$query = "SELECT username FROM #__users WHERE id = $channel->user_id";
		$db->SetQuery( $query );
		$username = $db->loadResult();
		$smartyvs->assign("username", $username);

		$smartyvs->display('channel_view.tpl');
		return;
    }