function setMetaData()
 {
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     $metaData = $this->getMetaData();
     $document->addStyleSheet(JURI::root(true) . '/media/com_igallery/css/category.css');
     $document->addScript(JURI::root(true) . '/media/com_igallery/js/category_mt13.js');
     if (!empty($this->photoList)) {
         $headJs = igUtilityHelper::makeHeadJs($this->category, $this->profile, $this->photoList, $this->dimensions['galleryWidth'], $this->dimensions['galleryLboxWidth'], $this->mainFiles, $this->lboxFiles, $this->thumbFiles, $this->lboxThumbFiles, $this->source, $this->catid, $this->uniqueid, $this->activeImage, $this->dimensions, $this->params);
         $document->addScriptDeclaration($headJs);
         if ($this->profile->lightbox == 1) {
             $document->addStyleSheet(JURI::root(true) . '/media/com_igallery/css/lightbox.css');
         }
     }
     if (isset($metaData['title'])) {
         if ($app->getCfg('sitename_pagetitles', 0) == 1) {
             $pageTitle = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $metaData['title']);
         } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
             $pageTitle = JText::sprintf('JPAGETITLE', $metaData['title'], $app->getCfg('sitename'));
         } else {
             $pageTitle = $metaData['title'];
         }
         $document->addCustomTag('<meta property="og:title" content="' . $pageTitle . '" />');
         $document->setTitle($pageTitle);
     }
     if (isset($metaData['description'])) {
         $description = substr(JFilterOutput::cleanText($metaData['description']), 0, 200);
         $document->setDescription($description);
         $ogDescription = substr(strip_tags(str_replace('"', '\'', html_entity_decode($metaData['description'], ENT_QUOTES, 'UTF-8'))), 0, 200);
         $document->addCustomTag('<meta property="og:description" content="' . $ogDescription . '" />');
     }
     if (isset($metaData['image'])) {
         $metaTag = '<meta property="og:image" content="' . $metaData['image'] . '" />';
         $document->addCustomTag($metaTag);
     }
     if (!empty($this->photoList)) {
         if ($this->profile->share_facebook == 1 || $this->profile->lbox_share_facebook == 1 || $this->profile->allow_comments == 4 || $this->profile->lbox_allow_comments == 4) {
             $fb_comments_userid = $this->params->get('fb_comments_userid', '');
             if (!empty($fb_comments_userid)) {
                 $document->addCustomTag('<meta property="fb:admins" content="' . $fb_comments_userid . '" />');
             }
             $fb_comments_appid = $this->params->get('fb_comments_appid', '');
             if (!empty($fb_comments_appid)) {
                 $document->addCustomTag('<meta property="fb:app_id" content="' . $fb_comments_appid . '" />');
             }
             if ((empty($fb_comments_userid) || empty($fb_comments_appid)) && ($this->profile->allow_comments == 4 || $this->profile->lbox_allow_comments == 4)) {
                 JError::raise(2, 500, JText::_('Facebook comments are On, Please enter a facebook user id and app into the gallery component options, See support common questions'));
             }
         }
     }
 }
 profile<?php 
    echo $this->profile->id;
    ?>
" >
	<?php 
    $counter = 0;
    ?>
	
	<?php 
    while ($counter < count($this->categoryChildren)) {
        ?>

        <?php 
        if (isset($this->categoryChildren[$counter])) {
            $row = $this->categoryChildren[$counter];
            $linkItemid = $this->source == 'component' ? $this->Itemid : igUtilityHelper::getItemid($row->id);
            $link = JRoute::_('index.php?option=com_igallery&amp;view=category&amp;igid=' . $row->id . '&amp;Itemid=' . $linkItemid);
            $divStyle = isset($row->fileArray) ? 'max-width:' . ($row->fileArray['width'] + 6) . 'px;' : 'width:' . $this->profile->menu_max_width . 'px;';
            ?>

            <div class="cat_child" style="<?php 
            echo $divStyle;
            ?>
" >

            <?php 
            if (isset($row->fileArray)) {
                ?>
                <a href="<?php 
                echo $link;
                ?>
    $topCategory = $db->loadObject();
    ?>

    <script type="text/javascript">
    window.addEvent('load', function()
    {
       document.id('igallery_search').addEvent('submit', function(event)
       {
          event.stop();
          var tags = document.id('igallery_searchword').get('value');
          var tagsClean = tags.replace(" ", ",");
          var newLocation = 'index.php?option=com_igallery&amp;igid=<?php 
    echo $topCategory->id;
    ?>
&amp;igtype=category&amp;ighidemenu=1&amp;searchAll=1&amp;Itemid=<?php 
    echo igUtilityHelper::getItemid($topCategory->id);
    ?>
&amp;igchild=1&amp;&amp;igtags=' + tagsClean;
          window.location = newLocation.replace(/&amp;/g, "&");
       });
    });
    </script>

<?php 
}
?>

<div id="igallery_search<?php 
echo $this->uniqueid;
?>
" class="igallery_search">
    static function makeHeadJs($category, $profile, $photoList, $galleryWidth, $galleryLboxWidth, $mainFiles, $lboxFiles, $thumbFiles, $lboxThumbFiles, $source, $catid, $uniqueid, $activeImage, $dimensions, $params)
    {
        $params = JComponentHelper::getParams('com_igallery');
        $ref = str_replace('.', '', IG_VERSION);
        $headJs = '
//make arrays and classes for the category: ' . $category->name . ' (id= ' . $catid . ')
window.addEvent(\'load\', function()
{
if( !!(document.id(\'main_images_wrapper' . $uniqueid . '\') || document.id(\'main_images_wrapper' . $uniqueid . '\') === 0 ) )
{
';
        $headJs .= '
	var idArray' . $uniqueid . ' = [';
        for ($n = 0; $n < count($photoList); $n++) {
            $headJs .= $photoList[$n]->id;
            if ($n < count($photoList) - 1) {
                $headJs .= ',';
            }
        }
        $headJs .= '];
		';
        $headJs .= '
	var jsonImagesObject' . $uniqueid . ' =
	{';
        $headJs .= '
		"general":
		[
		';
        for ($i = 0; $i < count($photoList); $i++) {
            $row = $photoList[$i];
            if (JRequest::getInt('igaddlinks', 0) == 1) {
                if (strlen($row->link) < 2) {
                    $limitStart = '';
                    if ($row->thumb_pagination == 1) {
                        if ($row->ordering > $row->thumb_pagination_amount) {
                            $group = ceil($row->ordering / $row->thumb_pagination_amount) - 1;
                            if ($group > 0) {
                                $limitStart = '&thumb_limitstart=' . $group * $row->thumb_pagination_amount;
                            }
                        }
                    }
                    $fileHashNoExt = JFile::stripExt($row->filename);
                    $fileHashNoRef = substr($fileHashNoExt, 0, strrpos($fileHashNoExt, '-'));
                    $linkItemid = igUtilityHelper::getItemid($row->gallery_id);
                    $photoList[$i]->link = JRoute::_('index.php?option=com_igallery&view=category&igid=' . $row->gallery_id . '&Itemid=' . $linkItemid . $limitStart . '#!' . $fileHashNoRef, false);
                    $photoList[$i]->target_blank = 0;
                }
            }
            $authorText = $params->get('show_name_username', 'name') == 'name' ? $photoList[$i]->displayname : $photoList[$i]->username;
            $headJs .= '	{"filename": "' . $photoList[$i]->filename . '", "url": "' . $photoList[$i]->link . '", "targetBlank": ' . $photoList[$i]->target_blank . ', "hits": ' . $photoList[$i]->hits . ', "alt": "' . $photoList[$i]->alt_text . '", "author": "' . str_replace('"', "'", $authorText) . '", "ratingAverage": "' . (empty($photoList[$i]->rating_average) ? 0 : $photoList[$i]->rating_average) . '", "ratingCount": "' . (isset($photoList[$i]->rating_count) ? $photoList[$i]->rating_count : 0) . '"}';
            if ($i < count($photoList) - 1) {
                $headJs .= ',
		';
            }
        }
        $headJs .= '
		]';
        if ($profile->show_large_image == 1) {
            $headJs .= ',
		
		"main":
		[
		';
            for ($i = 0; $i < count($photoList); $i++) {
                $headJs .= '	{"filename": "' . $mainFiles[$i]['folderName'] . '/' . $mainFiles[$i]['fullFileName'] . '", "width": ' . $mainFiles[$i]['width'] . ', "height": ' . $mainFiles[$i]['height'] . '}';
                if ($i < count($photoList) - 1) {
                    $headJs .= ',
		';
                }
            }
            $headJs .= '
		]';
        }
        if ($profile->show_thumbs == 1) {
            $headJs .= ',

		"thumbs":
		[
		';
            for ($i = 0; $i < count($photoList); $i++) {
                $headJs .= '	{"filename": "' . $thumbFiles[$i]['folderName'] . '/' . $thumbFiles[$i]['fullFileName'] . '", "width": ' . $thumbFiles[$i]['width'] . ', "height": ' . $thumbFiles[$i]['height'] . '}';
                if ($i < count($photoList) - 1) {
                    $headJs .= ',
		';
                }
            }
            $headJs .= '
		]
		';
        }
        if ($profile->lightbox == 1) {
            $headJs .= ',

		"lbox":
		[
		';
            for ($i = 0; $i < count($photoList); $i++) {
                $headJs .= '	{"filename": "' . $lboxFiles[$i]['folderName'] . '/' . $lboxFiles[$i]['fullFileName'] . '", "width": ' . $lboxFiles[$i]['width'] . ', "height": ' . $lboxFiles[$i]['height'] . '}';
                if ($i < count($photoList) - 1) {
                    $headJs .= ',
		';
                }
            }
            $headJs .= '
		]';
        }
        if ($profile->lbox_show_thumbs == 1 && $profile->lightbox == 1) {
            $headJs .= ',

		"lboxThumbs":
		[
		';
            for ($i = 0; $i < count($photoList); $i++) {
                $headJs .= '	{"filename": "' . $lboxThumbFiles[$i]['folderName'] . '/' . $lboxThumbFiles[$i]['fullFileName'] . '", "width": ' . $lboxThumbFiles[$i]['width'] . ', "height": ' . $lboxThumbFiles[$i]['height'] . '}';
                if ($i < count($photoList) - 1) {
                    $headJs .= ',
		';
                }
            }
            $headJs .= '
		]
		';
        }
        $headJs .= '
	};

	var igalleryInt = new Class(igalleryClass);

	var igalleryMain' . $uniqueid . ' = new igalleryInt
	({
	    activeImage: ' . $activeImage . ',
		allowComments: ' . $profile->allow_comments . ',
		allowRating: ' . $profile->allow_rating . ',
		ratingsContainer: \'main_ratings_container' . $uniqueid . '\',
		catid: \'' . $catid . '\',
		calledFrom: \'' . $source . '\',
		collectImageViews: ' . $params->get('image_view_stats', 1) . ',
		desContainer: \'main_des_container' . $uniqueid . '\',
		desPostion: \'' . $profile->photo_des_position . '\',
		downArrow: \'main_thumb_down_arrow_wrapper' . $uniqueid . '\',
		downloadType: \'' . $profile->download_image . '\',
		downloadId: \'main_download_button' . $uniqueid . '\',
		host: \'' . IG_HOST . '\',
		hostRelative: \'' . JURI::root(true) . '\',
		fadeDuration: ' . $profile->fade_duration . ',
		facebookContainer: \'main_facebook_share' . $uniqueid . '\',
		facebookTempContainer: \'main_facebook_share_temp' . $uniqueid . '\',
		facebookShare: ' . $profile->share_facebook . ',
		facebookCommentsContainer: \'main_fbcomments' . $uniqueid . '\',
		facebookCommentsNumPosts: ' . $params->get('fb_comments_postcount', 5) . ',
		fbButtonType: \'' . $params->get('fb_button_type', 'share') . '\',
		fbLikeWidth: ' . $params->get('fb_like_width', 85) . ',
		facebookColor: \'' . $params->get('fb_colorscheme', 'light') . '\',
		facebookLegacy: ' . $params->get('fb_legacy_urls', 0) . ',
		galleryWidth: ' . $galleryWidth . ',
        idArray: idArray' . $uniqueid . ',
        imageSlideshowContainer: \'main_image_slideshow_wrapper' . $uniqueid . '\',
        imageAuthorContainer: \'main_image_author' . $uniqueid . '\',
        imageHitsContainer: \'main_image_hits' . $uniqueid . '\',
		imageAssetPath: \'' . IG_IMAGE_ASSET_PATH . '\',
		imageAlignHoriz: \'' . $profile->main_image_align_horiz . '\',
		imageAlignVert: \'' . $profile->main_image_align_vert . '\',
		jCommentsMain: \'main_jcomments_wrapper' . $uniqueid . '\',
		jCommentsLbox: \'lbox_jcomments_wrapper' . $uniqueid . '\',
		jsonImages: jsonImagesObject' . $uniqueid . ',
		jsonImagesImageType: jsonImagesObject' . $uniqueid . '.main,
		largeImage: \'main_large_image' . $uniqueid . '\',
		largestWidth: ' . $dimensions['largestWidth'] . ',
		largestHeight: ' . $dimensions['largestHeight'] . ',
		largeImageDivWidth: ' . $dimensions['mainImageDivWidth'] . ',
		largeImagePadding: ' . $dimensions['mainImgPadding'] . ',
		largeImageMargin: ' . $dimensions['mainImageMargin'] . ',
		lboxDark: \'lbox_dark' . $uniqueid . '\',
		lboxWhite: \'lbox_white' . $uniqueid . '\',
		lboxScalable: ' . $profile->lbox_scalable . ',
		lightboxWidth: ' . $galleryLboxWidth . ',
		lightboxOn: ' . $profile->lightbox . ',
		lightboxBackOpacity: ' . $profile->lbox_back_opacity . ',
		leftArrow: \'main_thumb_left_arrow_wrapper' . $uniqueid . '\',
		magnify: ' . $profile->magnify . ',
		main: 1,
		mainWrapper: \'main_images_wrapper' . $uniqueid . '\',
		numPics: ' . count($photoList) . ',
		numberingOn: ' . $profile->show_numbering . ',
		numberingContainer: \'main_img_numbering' . $uniqueid . '\',
		plusOneDiv: \'main_plus_one_div' . $uniqueid . '\',
		preload: ' . $profile->preload . ',
		prefix: \'main\',
		pinterestButton: ' . $profile->pinterest_button . ',
		pInterestContainer: \'main_pinterest' . $uniqueid . '\',
		pInterestTempContainer: \'main_pinterest_temp' . $uniqueid . '\',
		resizePath: \'' . IG_IMAGE_HTML_RESIZE . '\',
		resizePathAbsolute: \'' . IG_IMAGE_HTML_RESIZE_ABSOLUTE . '\',
		refreshMode: \'' . $profile->refresh_mode . '\',
		reportImage: ' . $profile->report_image . ',
		reportContainer: \'main_report' . $uniqueid . '\',
		rightArrow: \'main_thumb_right_arrow_wrapper' . $uniqueid . '\',
        showDescriptions: ' . $profile->show_descriptions . ',
		showThumbArrows: ' . $profile->show_thumb_arrows . ',
		showLargeImage: ' . $profile->show_large_image . ',
		showThumbs: ' . $profile->show_thumbs . ',
		showPlusOne: ' . $profile->plus_one . ',
		showImageAuthor: ' . $profile->show_image_author . ',
		showImageHits: ' . $profile->show_image_hits . ',
		showSlideshowControls: ' . $profile->show_slideshow_controls . ',
		slideshowPosition: \'' . $profile->slideshow_position . '\',
		showTags: ' . $profile->show_tags . ',
		slideshowAutostart: ' . $profile->slideshow_autostart . ',
		slideshowPause: ' . $profile->slideshow_pause . ',
		slideshowForward: \'slideshow_forward' . $uniqueid . '\',
		slideshowPlay: \'slideshow_play' . $uniqueid . '\',
		slideshowRewind: \'slideshow_rewind' . $uniqueid . '\',
		tagsContainer: \'main_tags_container' . $uniqueid . '\',
		thumbContainer: \'main_thumb_container' . $uniqueid . '\',
		thumbPostion: \'' . $profile->thumb_position . '\',
		thumbTable: \'main_thumb_table' . $uniqueid . '\',
		twitterButton: ' . $profile->twitter_button . ',
		twitterButtonDiv: \'main_twitter_button' . $uniqueid . '\',
		uniqueid: \'' . $uniqueid . '\',
		style: \'' . $profile->style . '\',
		upArrow: \'main_thumb_up_arrow_wrapper' . $uniqueid . '\',
		ref: \'' . $ref . '\'
	});
	';
        if ($profile->lightbox == 1) {
            $headJs .= '
	var igalleryLbox' . $uniqueid . ' = new igalleryInt
	({
	    activeImage: ' . $activeImage . ',
		allowComments: ' . $profile->lbox_allow_comments . ',
		allowRating: ' . $profile->lbox_allow_rating . ',
		ratingsContainer: \'lbox_ratings_container' . $uniqueid . '\',
		catid: \'' . $catid . '\',
		calledFrom: \'' . $source . '\',
		collectImageViews: ' . $params->get('image_view_stats', 1) . ',
		closeImage: \'closeImage' . $uniqueid . '\',
		desContainer: \'lbox_des_container' . $uniqueid . '\',
		desPostion: \'' . $profile->lbox_photo_des_position . '\',
		downArrow: \'lbox_thumb_down_arrow_wrapper' . $uniqueid . '\',
		downloadId: \'lbox_download_button' . $uniqueid . '\',
		downloadType: \'' . $profile->lbox_download_image . '\',
		host: \'' . IG_HOST . '\',
		hostRelative: \'' . JURI::root(true) . '\',
		fadeDuration: ' . $profile->lbox_fade_duration . ',
		facebookShare: ' . $profile->lbox_share_facebook . ',
		facebookContainer: \'lbox_facebook_share' . $uniqueid . '\',
		facebookTempContainer: \'lbox_facebook_share_temp' . $uniqueid . '\',
		facebookCommentsContainer: \'lbox_fbcomments' . $uniqueid . '\',
		facebookCommentsNumPosts: ' . $params->get('fb_comments_postcount', 5) . ',
		fbButtonType: \'' . $params->get('fb_button_type', 'share') . '\',
		fbLikeWidth: ' . $params->get('fb_like_width', 85) . ',
		facebookLegacy: ' . $params->get('fb_legacy_urls', 0) . ',
		facebookColor: \'' . $params->get('fb_colorscheme', 'light') . '\',
		idArray: idArray' . $uniqueid . ',
		imageSlideshowContainer: \'lbox_image_slideshow_wrapper' . $uniqueid . '\',
		imageAuthorContainer: \'lbox_image_author' . $uniqueid . '\',
        imageHitsContainer: \'lbox_image_hits' . $uniqueid . '\',
		imageAssetPath: \'' . IG_IMAGE_ASSET_PATH . '\',
		imageAlignHoriz: \'' . $profile->lbox_image_align_horiz . '\',
		imageAlignVert: \'' . $profile->lbox_image_align_vert . '\',
		jsonImages: jsonImagesObject' . $uniqueid . ',
		jsonImagesImageType: jsonImagesObject' . $uniqueid . '.lbox,
		largeImage: \'lbox_large_image' . $uniqueid . '\',
		largestWidth: ' . $dimensions['largestLboxWidth'] . ',
		largestHeight: ' . $dimensions['largestLboxHeight'] . ',
		largeImageDivWidth: ' . $dimensions['lboxImageDivWidth'] . ',
		largeImagePadding: ' . $dimensions['lboxImagePadding'] . ',
		largeImageMargin: ' . $dimensions['lboxImageMargin'] . ',
		lboxDark: \'lbox_dark' . $uniqueid . '\',
		lboxWhite: \'lbox_white' . $uniqueid . '\',
		lightboxBackOpacity: ' . $profile->lbox_back_opacity . ',
		lboxScalable: ' . $profile->lbox_scalable . ',
		lightboxWidth: ' . $galleryLboxWidth . ',
		leftArrow: \'lbox_thumb_left_arrow_wrapper' . $uniqueid . '\',
		lightboxOn: ' . $profile->lightbox . ',
		mainWrapper: \'lbox_white' . $uniqueid . '\',
		magnify: ' . $profile->magnify . ',
		main: 0,
		numPics: ' . count($photoList) . ',
		numberingOn: ' . $profile->lbox_show_numbering . ',
		numberingContainer: \'lbox_img_numbering' . $uniqueid . '\',
		plusOneDiv: \'lbox_plus_one_div' . $uniqueid . '\',
		preload: ' . $profile->lbox_preload . ',
		prefix: \'lbox\',
		pinterestButton: ' . $profile->lbox_pinterest_button . ',
		pInterestContainer: \'lbox_pinterest' . $uniqueid . '\',
		pInterestTempContainer: \'lbox_pinterest_temp' . $uniqueid . '\',
		resizePath: \'' . IG_IMAGE_HTML_RESIZE . '\',
		resizePathAbsolute: \'' . IG_IMAGE_HTML_RESIZE_ABSOLUTE . '\',
		reportImage: ' . $profile->lbox_report_image . ',
		reportContainer: \'lbox_report' . $uniqueid . '\',
		rightArrow: \'lbox_thumb_right_arrow_wrapper' . $uniqueid . '\',
		refreshMode: \'' . $profile->refresh_mode . '\',
		showDescriptions: ' . $profile->lbox_show_descriptions . ',
		showThumbArrows: ' . $profile->lbox_show_thumb_arrows . ',
		showLargeImage: 1,
		showThumbs: ' . $profile->lbox_show_thumbs . ',
		showTags: ' . $profile->lbox_show_tags . ',
		showPlusOne: ' . $profile->lbox_plus_one . ',
		showImageAuthor: ' . $profile->lbox_show_image_author . ',
		showImageHits: ' . $profile->lbox_show_image_hits . ',
		showSlideshowControls: ' . $profile->lbox_show_slideshow_controls . ',
		slideshowPosition: \'' . $profile->lbox_slideshow_position . '\',
		slideshowAutostart: ' . $profile->lbox_slideshow_autostart . ',
		slideshowForward: \'lbox_slideshow_forward' . $uniqueid . '\',
		slideshowPlay: \'lbox_slideshow_play' . $uniqueid . '\',
		slideshowRewind: \'lbox_slideshow_rewind' . $uniqueid . '\',
		slideshowPause: ' . $profile->lbox_slideshow_pause . ',
		style: \'' . $profile->style . '\',
		tagsContainer: \'lbox_tags_container' . $uniqueid . '\',
		thumbContainer: \'lbox_thumb_container' . $uniqueid . '\',
		thumbPostion: \'' . $profile->lbox_thumb_position . '\',
		thumbTable: \'lbox_thumb_table' . $uniqueid . '\',
		twitterButton: ' . $profile->lbox_twitter_button . ',
		twitterButtonDiv: \'lbox_twitter_button' . $uniqueid . '\',
		uniqueid: \'' . $uniqueid . '\',
		upArrow: \'lbox_thumb_up_arrow_wrapper' . $uniqueid . '\'
	});

	igalleryMain' . $uniqueid . '.lboxGalleryObject = igalleryLbox' . $uniqueid . ';
	igalleryLbox' . $uniqueid . '.mainGalleryObject = igalleryMain' . $uniqueid . ';
	';
        }
        $headJs .= '
}
});

';
        return $headJs;
    }