static function getGalleryDimensions($mainFiles, $lboxFiles, $thumbFiles, $lboxThumbFiles, $categoryChildren, $profile)
 {
     /*START DEFINING OF IMAGE PADDING AND MARGIN */
     /*the padding and margin values below are in pixels, later in the script, the gallery
       will convert them to percentages*/
     if ($profile->style == 'grey-border-shadow') {
         /*IF THE STYLE IN THE PROFILE -> GENERAL TAB IS GREY-BORDER-SHADOW, and you want to
           change the margin or padding on any of the images, please change the values below*/
         /*main image padding/margin*/
         $mainImagePadding = 5;
         $mainImageMargin = 0;
         /*thumb padding/margin*/
         $thumbPadding = 5;
         $thumbMargin = 2;
         /*lightbox image padding/margin*/
         $lboxImagePadding = 5;
         $lboxImageMargin = 0;
         /*lightbox thumb padding/margin*/
         $lboxThumbPadding = 5;
         $lboxThumbMargin = 2;
         if ($profile->mobile) {
             $mainSlideShowLeftRightWidth = 64;
             $lboxSlideShowLeftRightWidth = 64;
         } else {
             $mainSlideShowLeftRightWidth = 32;
             $lboxSlideShowLeftRightWidth = 32;
         }
     } else {
         /*IF THE STYLE IN THE PROFILE -> GENERAL TAB IS PLAIN, and you want to
           change the margin or padding on any of the images, please change the values below*/
         /*main image padding/margin*/
         $mainImagePadding = 0;
         $mainImageMargin = 0;
         /*thumb padding/margin*/
         $thumbPadding = 0;
         $thumbMargin = 2;
         /*lightbox iamge padding/margin*/
         $lboxImagePadding = 0;
         $lboxImageMargin = 0;
         /*lightbox thumb padding/margin*/
         $lboxThumbPadding = 0;
         $lboxThumbMargin = 2;
         if ($profile->mobile) {
             $mainSlideShowLeftRightWidth = 64;
             $lboxSlideShowLeftRightWidth = 64;
         } else {
             $mainSlideShowLeftRightWidth = 32;
             $lboxSlideShowLeftRightWidth = 32;
         }
     }
     /*END DEFINING OF IMAGE PADDING AND MARGIN */
     //work out the largest width/height of the images
     $largestHeight = 0;
     $largestWidth = 0;
     $largestLboxHeight = 0;
     $largestLboxWidth = 0;
     for ($i = 0; $i < count($mainFiles); $i++) {
         $largestWidth = $mainFiles[$i]['width'] > $largestWidth ? $mainFiles[$i]['width'] : $largestWidth;
         $largestHeight = $mainFiles[$i]['height'] > $largestHeight ? $mainFiles[$i]['height'] : $largestHeight;
         $largestLboxWidth = $lboxFiles[$i]['width'] > $largestLboxWidth ? $lboxFiles[$i]['width'] : $largestLboxWidth;
         $largestLboxHeight = $lboxFiles[$i]['height'] > $largestLboxHeight ? $lboxFiles[$i]['height'] : $largestLboxHeight;
     }
     //if the width/height has been manually set in the backend then override
     $mainImageDivWidth = $profile->img_container_width > $largestWidth ? $profile->img_container_width : $largestWidth;
     $largestHeight = $profile->img_container_height > $largestHeight ? $profile->img_container_height : $largestHeight;
     $lboxImageDivWidth = $profile->lbox_img_container_width > $largestLboxWidth ? $profile->lbox_img_container_width : $largestLboxWidth;
     $largestLboxHeight = $profile->lbox_img_container_height > $largestLboxHeight ? $profile->lbox_img_container_height : $largestLboxHeight;
     //add large_img padding
     $mainImageDivWidth = $mainImageDivWidth + $mainImagePadding * 2 + $mainImageMargin * 2;
     $lboxImageDivWidth = $lboxImageDivWidth + $lboxImagePadding * 2 + $lboxImageMargin * 2;
     $mainSlideShowDivWidth = $mainImageDivWidth;
     $lboxSlideShowDivWidth = $lboxImageDivWidth;
     $thumbRowCount = $profile->images_per_row == 0 ? count($mainFiles) : $profile->images_per_row;
     $mainThumbTableWidths = igUtilityHelper::getThumbTableWidth($thumbFiles, $thumbRowCount, $thumbPadding, $thumbMargin);
     $thumbRowCount = $profile->lbox_images_per_row == 0 ? count($mainFiles) : $profile->lbox_images_per_row;
     $lboxThumbTableWidths = igUtilityHelper::getThumbTableWidth($lboxThumbFiles, $thumbRowCount, $lboxThumbPadding, $lboxThumbMargin);
     //work out the overall gallery width
     if ($profile->show_large_image == 1) {
         $galleryWidth = $mainSlideShowDivWidth;
     } else {
         if ($profile->thumb_container_width != 0) {
             $galleryWidth = $profile->thumb_container_width;
         } else {
             $galleryWidth = $mainThumbTableWidths['overallWidth'];
         }
     }
     //if the thumbs or descriptions are set to left/right, add on some width
     if (($profile->photo_des_position == 'left' || $profile->photo_des_position == 'right') && $profile->show_descriptions == 1 && $profile->show_large_image == 1) {
         $desWidth = $profile->photo_des_width == 0 ? 200 : $profile->photo_des_width;
         $galleryWidth = $galleryWidth + $desWidth;
     }
     if (($profile->thumb_position == 'left' || $profile->thumb_position == 'right') && $profile->show_thumbs == 1 && $profile->show_large_image == 1) {
         $extra = 4;
         $scrollBarWidth = $profile->thumb_scrollbar == 1 ? 26 : 0;
         $thumbTableWidth = $mainThumbTableWidths['overallWidth'];
         $thumbContainerWidth = $profile->thumb_container_width == 0 ? $thumbTableWidth + $scrollBarWidth + $extra : $profile->thumb_container_width;
         $thumbContainerWidthNoScroll = $thumbContainerWidth - $scrollBarWidth;
         $galleryWidth = $galleryWidth + $thumbContainerWidth;
     } else {
         $thumbTableWidth = $mainThumbTableWidths['overallWidth'];
         $thumbContainerWidth = $profile->thumb_container_width == 0 ? 0 : $profile->thumb_container_width;
         $thumbContainerWidthNoScroll = $thumbContainerWidth;
     }
     $galleryLboxWidth = $lboxSlideShowDivWidth;
     if (($profile->lbox_photo_des_position == 'left' || $profile->lbox_photo_des_position == 'right') && $profile->lbox_show_descriptions == 1) {
         $desWidth = $profile->lbox_photo_des_width == 0 ? 200 : $profile->lbox_photo_des_width;
         $galleryLboxWidth = $galleryLboxWidth + $desWidth;
     }
     if (($profile->lbox_thumb_position == 'left' || $profile->lbox_thumb_position == 'right') && $profile->lbox_show_thumbs == 1) {
         $extra = 4;
         $scrollBarWidth = $profile->lbox_thumb_scrollbar == 1 ? 26 : 0;
         $lboxThumbTableWidth = $lboxThumbTableWidths['overallWidth'];
         $lboxThumbContainerWidth = $profile->lbox_thumb_container_width == 0 ? $lboxThumbTableWidth + $scrollBarWidth + $extra : $profile->lbox_thumb_container_width;
         $lboxThumbContainerWidthNoScroll = $lboxThumbContainerWidth - $scrollBarWidth;
         $galleryLboxWidth = $galleryLboxWidth + $lboxThumbContainerWidth;
     } else {
         $lboxThumbTableWidth = $lboxThumbTableWidths['overallWidth'];
         $lboxThumbContainerWidth = $profile->lbox_thumb_container_width == 0 ? 0 : $profile->lbox_thumb_container_width;
         $lboxThumbContainerWidthNoScroll = $lboxThumbContainerWidth;
     }
     if ($profile->photo_des_width > $galleryWidth && $profile->show_descriptions == 1 && ($profile->photo_des_position == 'above' || $profile->photo_des_position == 'below')) {
         $galleryWidth = $profile->photo_des_width;
     }
     if ($profile->thumb_container_width > $galleryWidth && $profile->show_thumbs == 1 && ($profile->thumb_position == 'above' || $profile->thumb_position == 'below')) {
         $galleryWidth = $profile->thumb_container_width;
     }
     if ($profile->lbox_photo_des_width > $galleryLboxWidth && $profile->lbox_show_descriptions == 1 && ($profile->lbox_photo_des_position == 'above' || $profile->lbox_photo_des_position == 'below')) {
         $galleryLboxWidth = $profile->lbox_photo_des_width;
     }
     if ($profile->lbox_thumb_container_width > $galleryLboxWidth && $profile->lbox_show_thumbs == 1 && ($profile->lbox_thumb_position == 'above' || $profile->lbox_thumb_position == 'below')) {
         $galleryLboxWidth = $profile->lbox_thumb_container_width;
     }
     $sizesArray = array();
     $sizesArray['largestWidth'] = $largestWidth;
     $sizesArray['largestHeight'] = $largestHeight;
     $sizesArray['mainImgPadding'] = $mainImagePadding;
     $sizesArray['mainImageMargin'] = $mainImageMargin;
     $sizesArray['mainImageDivWidth'] = $mainImageDivWidth;
     $sizesArray['mainSlideShowDivWidth'] = $mainSlideShowDivWidth;
     $sizesArray['galleryWidth'] = $galleryWidth;
     $sizesArray['thumbPadding'] = $thumbPadding;
     $sizesArray['thumbMargin'] = $thumbMargin;
     $sizesArray['thumbTableWidth'] = $thumbTableWidth;
     $sizesArray['thumbContainerWidth'] = $thumbContainerWidth;
     $sizesArray['thumbContainerWidthNoScroll'] = $thumbContainerWidthNoScroll;
     $sizesArray['thumbColumnWidths'] = $mainThumbTableWidths['columns'];
     $sizesArray['mainSlideShowLeftRightWidth'] = $mainSlideShowLeftRightWidth;
     //lbox
     $sizesArray['largestLboxWidth'] = $largestLboxWidth;
     $sizesArray['largestLboxHeight'] = $largestLboxHeight;
     $sizesArray['lboxImagePadding'] = $lboxImagePadding;
     $sizesArray['lboxImageMargin'] = $lboxImageMargin;
     $sizesArray['lboxImageDivWidth'] = $lboxImageDivWidth;
     $sizesArray['lboxSlideShowDivWidth'] = $lboxSlideShowDivWidth;
     $sizesArray['galleryLboxWidth'] = $galleryLboxWidth;
     $sizesArray['lboxThumbPadding'] = $lboxThumbPadding;
     $sizesArray['lboxThumbMargin'] = $lboxThumbMargin;
     $sizesArray['lboxThumbTableWidth'] = $lboxThumbTableWidth;
     $sizesArray['lboxThumbContainerWidth'] = $lboxThumbContainerWidth;
     $sizesArray['lboxThumbContainerWidthNoScroll'] = $lboxThumbContainerWidthNoScroll;
     $sizesArray['lboxThumbColumnWidths'] = $lboxThumbTableWidths['columns'];
     $sizesArray['lboxSlideShowLeftRightWidth'] = $lboxSlideShowLeftRightWidth;
     return $sizesArray;
 }