<?php
//filter by gallery categories
$filter = explode("filter=", $_SERVER['REQUEST_URI']);
$filter = (int)$filter[1];
//master filter passed from gallery include mod
if($gobalFilter)
{
$filter = (int)$gobalFilter;
}
//category names
$gallcats = '<div id="gallery"><a name="gall"></a><p class="gallery-cats">Gallery categories: ';
//cat links
$catquery = $mysql->query("ID,name,password", $mysql->perfix."gallery_cats", "1 ORDER BY `order`");
if($mysql->num_rows($catquery) <= 10)
{
while($cats = $mysql->get_array($catquery))
{
$temp = explode("?", $_SERVER['REQUEST_URI']);	
if(!empty($cats['password']))
{
if(isset($_COOKIE['gallery'.$cats['ID']]))
{
$gallcats .= '<a href="/'.$url['pid'].'/'.seo_str($cats['name']).'?filter='.$cats['ID'].'#gall">'.stripslashes($cats['name']).'</a>|';
}
else
{
$gallcats .= '<a href="javascript:;" onclick="window.open(\'/inc/gallery/login.php?cat='.$cats['ID'].'\',\'\',\'status=yes,scrollbars=yes,resizable=yes,width=400,height=150\');">'.stripslashes($cats['name']).'</a>|';
}	
}
else
{
$gallcats .= '<a href="/'.$url['pid'].'/'.seo_str($cats['name']).'?filter='.$cats['ID'].'#gall">'.stripslashes($cats['name']).'</a>|';
}
}
$gallcats = substr($gallcats, 0, -1);
}
else
{
$gallcats .= '<select name="j" onchange="window.location=this.value;">';
while($cats = $mysql->get_array($catquery))
{
$temp = explode("?", $_SERVER['REQUEST_URI']);
$selected = ($filter == $cats['ID']) ? ' selected' : '';
if(!empty($cats['password']))
{
if(isset($_COOKIE['gallery'.$cats['ID']]))
{
$gallcats .= '<option value="/'.$url['pid'].'/'.seo_str($cats['name']).'/?filter='.$cats['ID'].'#gall"'.$selected.'>'.stripslashes($cats['name']).'</option>';
}
else
{
$gallcats .= '<option value="/inc/gallery/login.php?cat='.$cats['ID'].'#gall"'.$selected.'>'.stripslashes($cats['name']).'</option>';
}	
}
else
{
$gallcats .= '<option value="/'.$url['pid'].'/'.seo_str($cats['name']).'/?filter='.$cats['ID'].'#gall"'.$selected.'>'.stripslashes($cats['name']).'</option>';
}
}
$gallcats .= '</select>';
}
$gallcats .= '</p>';
if($gobalFilter)
{
echo $gallcats;
}
else
{
$mainhtml .= $gallcats;
}
//if filter is 0, show first cat without a password
if($filter == 0)
{
$filter = $mysql->get_array($mysql->query("ID", $mysql->perfix."gallery_cats", "password = '' ORDER BY `order` LIMIT 1"));
$filter = ((int)$filter['ID'] > 0) ? $filter['ID'] : 0;
}
//show gallery
$h = '<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script><script type="text/javascript">var flashvars={};flashvars.galleryURL="/inc/gallery/'.$filter.'-'.time().'.xml";var params={};params.allowfullscreen=true;params.allowscriptaccess="always";params.wmode ="transparent";swfobject.embedSWF("/inc/gallery/simpleviewer.swf?rand='.time().'","flashContent","574","500","9.0.124",false,flashvars,params);</script><div id="flashContent">SimpleViewer requires JavaScript and the Flash Player. <a href="http://get.adobe.com/flashplayer/">Get Flash</a></div></div>';
if(!$gobalFilter)
{
$mainhtml .= $h;
}
else
{
echo $h;
}
//include this add-ons's overwrite css file from the template being used, if there is one
$t = settings('template');
if(file_exists('templates/'.$t['template'].'/addons/gallery_slideshow.css'))
{
$mainhtml = str_replace("</head>", '<link rel="stylesheet" type="text/css" href="/templates/'.$t['template'].'/addons/gallery_slideshow.css" /></head>', $mainhtml);
}
else
{
$mainhtml = str_replace("</head>", '<link rel="stylesheet" type="text/css" href="//www.freesites.com.au/addons/gallery_slideshow.css" /></head>', $mainhtml);
}
//end
?>