<?php
function youtubecats() {
global  $htmlorphp,$youtube_catsloop,$LANGAUGE;

if($youtube_catsloop=="1"){$width = "100%";}
elseif($youtube_catsloop=="2"){$width = "50%";}
elseif($youtube_catsloop=="3"){$width = "33%";}
elseif($youtube_catsloop=="4"){$width = "25%";}
elseif($youtube_catsloop=="5"){$width = "20%";}
elseif($youtube_catsloop=="6"){$width = "16%";}
else{$width = "";}

$sql = @mysql_query("SELECT * FROM youtubecat where sub='0' AND active='1' order by order_cat");
$nu = mysql_num_rows($sql);
if($nu == 0){
$printcats = $LANGAUGE[91];
}else{
$printcats = "<table border='0' width='100%' id='AutoNumber2' style='border-collapse: collapse'>";

$tslsls = '0';
while ($Row2 = @mysql_fetch_array($sql))
{
$sql2 = @mysql_query("select id from story where cat='".$Row2['id']."' AND active='1'");
$nu = mysql_num_rows($sql2);

++$tslsls;
if($tslsls=="$youtube_catsloop"){
$tslslats = "</tr><tr>";
$tslsls="0";
}else{
$tslslats = "";
}

$Row2[name_cat] = text(3,$Row2[name_cat]);

if ($htmlorphp=="1"){
$p = "<a href='youtubecat-$Row2[id].html'>$Row2[name_cat]</a>";
}else{
$p = "<a href='youtube.php?action=cat&id=$Row2[id]'>$Row2[name_cat]</a>";
}

$printcats .= "<td width='$width' class='category'><div>".$p."</div></td>
$tslslats";

}
$printcats .= "</table>";
}


return $printcats;
}

function youtube() {
global $id,$htmlorphp,$LANGAUGE,$folder,$youtube_catsloop,$youtube_vidloop,$youtube_limit;

if($youtube_catsloop=="1"){$width = "100%";}
elseif($youtube_catsloop=="2"){$width = "50%";}
elseif($youtube_catsloop=="3"){$width = "33%";}
elseif($youtube_catsloop=="4"){$width = "25%";}
elseif($youtube_catsloop=="5"){$width = "20%";}
elseif($youtube_catsloop=="6"){$width = "16%";}
else{$width = "";}

$sqlx = @mysql_query("SELECT * FROM youtubecat where sub='$id' AND active='1' order by order_cat");
$nux = mysql_num_rows($sqlx);
if($nux == 0){
$printcats = "";
}else{
$printcats = "<table border='0' width='100%' id='AutoNumber2' style='border-collapse: collapse'>";
$tslsls = '0';
while ($Row2 = @mysql_fetch_array($sqlx))
{
$numall = @mysql_query("select id from youtube where cat='".$Row2['id']."' AND active='1'");
$number = mysql_num_rows($numall);

++$tslsls;
if($tslsls=="$youtube_catsloop"){
$tslslats = "</tr><tr>";
$tslsls="0";
}else{
$tslslats = "";
}

$Row2[name_cat] = text(3,$Row2[name_cat]);

if ($htmlorphp=="1"){
$p = "<a href='youtubecat-$Row2[id].html'>$Row2[name_cat]</a>";
}else{
$p = "<a href='youtube.php?action=cat&id=$Row2[id]'>$Row2[name_cat]</a>";
}

$printcats .= "<td width='$width' class='category'><div>".$p."</div></td>
$tslslats";

}
$printcats .= "</table>";
}

$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$page = ($page == 0 ? 1 : $page);
$perpage = $youtube_limit;
$startpoint = ($page * $perpage) - $perpage;

$sql = @mysql_query("SELECT id,name,image,vis,date FROM youtube where cat='$id' AND active='1' order by id desc limit $startpoint,$perpage");
$nu = mysql_num_rows($sql);

if($nu != 0 AND $nux != 0){
$printcats .= "<br />";
}

if($nu==0 ){

if($nux == 0){
$printcats .= $LANGAUGE[253];
}else{
$printcats .= "";
}
}else{

if($youtube_vidloop=="1"){$widthx = "100%";}
elseif($youtube_vidloop=="2"){$widthx = "50%";}
elseif($youtube_vidloop=="3"){$widthx = "33%";}
elseif($youtube_vidloop=="4"){$widthx = "25%";}
elseif($youtube_vidloop=="5"){$widthx = "20%";}
elseif($youtube_vidloop=="6"){$widthx = "16%";}
else{$widthx = "";}

$printcats .= "<table border='0' width='100%' id='utoNumber25' style='border-collapse: collapse'>";
$tslslsc = '0';
while ($Row = @mysql_fetch_array($sql))
{
$Row['name'] = text(3,$Row['name']);
$Row['image'] = text(3,$Row['image']);

if($Row['image']==""){
$iimm = '<img src="icons/nopic.jpg" alt="'.$Row['name'].'" border="0" /><br />';
}else{
$iimm = '<img src="'.$Row['image'].'" alt="'.$Row['name'].'" border="0" /><br />';
}

++$tslslsc;
if($tslslsc==$youtube_vidloop){
$tslslatsv = "</tr><tr>";
$tslslsc="0";
}else{
$tslslatsv = "";
}

if ($htmlorphp=="1"){
$prur = "<a href='youtubeshow-$Row[id].html'>".$iimm."".$Row['name']."</a>";
}else{
$prur = "<a href='youtube.php?action=show&id=$Row[id]'>".$iimm."".$Row['name']."</a>";
}

$printcats .= "<td width='$widthx' class='youtube'><div>".$prur."</div></td>
$tslslatsv";
}

$printcats .= "</table>";

$pagesnum = @ceil(mysql_num_rows(mysql_query("select `id` from `youtube` where cat='$id' AND active='1'")) / $perpage);

if($pagesnum > 1){
$printcats .= "<div class='multipage'>";
for ($i=1; $i<=$pagesnum; $i++) {
if ($i != $page) {

if ($htmlorphp=="1"){
$z = "<span><a href='t-$id-$i.html'>$i</a></span>";
}else{
$z = "<span><a href='youtube.php?action=cat&id=$id&page=$i'>$i</a></span>";
}

} else {
$z = "<span class='act'>$i</span>";
}
$printcats .= "$z";

}
$printcats .= "</div>";
}
}

return $printcats;
}
?>