function fjgwpp_settings()
{
    global $fjgwpp_imagesHeight_default;
    global $fjgwpp_maxPhotosPP_default;
    global $fjgwpp_lastRow_default;
    global $fjgwpp_fixedHeight_default;
    global $fjgwpp_pagination_default;
    global $fjgwpp_lightbox_default;
    global $fjgwpp_provideColorbox_default;
    global $fjgwpp_provideSwipebox_default;
    global $fjgwpp_captions_default;
    global $fjgwpp_showDescriptions_default;
    global $fjgwpp_randomize_default;
    global $fjgwpp_margins_default;
    global $fjgwpp_openOriginals_default;
    global $fjgwpp_bcontextmenu_default;
    global $fjgwpp_flickrAPIWrapperVersion_default;
    //Get Values
    $fjgwpp_userID_saved = fjgwpp_getOption('userID', '');
    $fjgwpp_APIKey_saved = fjgwpp_getOption('APIKey', '');
    $fjgwpp_imagesHeight_saved = (int) fjgwpp_getOption('imagesHeight', $fjgwpp_imagesHeight_default);
    $fjgwpp_maxPhotosPP_saved = (int) fjgwpp_getOption('maxPhotosPP', $fjgwpp_maxPhotosPP_default);
    $fjgwpp_lastRow_saved = (int) fjgwpp_getOption('lastRow', $fjgwpp_lastRow_default);
    $fjgwpp_fixedHeight_saved = (int) fjgwpp_getOption('fixedHeight', $fjgwpp_fixedHeight_default);
    $fjgwpp_pagination_saved = fjgwpp_getOption('pagination', $fjgwpp_pagination_default);
    $fjgwpp_lightbox_saved = fjgwpp_getOption('lightbox', $fjgwpp_lightbox_default);
    $fjgwpp_provideColorbox_saved = (int) fjgwpp_getOption('provideColorbox', $fjgwpp_provideColorbox_default);
    $fjgwpp_provideSwipebox_saved = (int) fjgwpp_getOption('provideSwipebox', $fjgwpp_provideSwipebox_default);
    $fjgwpp_captions_saved = (int) fjgwpp_getOption('captions', $fjgwpp_captions_default);
    $fjgwpp_showDescriptions_saved = (int) fjgwpp_getOption('showDescriptions', $fjgwpp_showDescriptions_default);
    $fjgwpp_randomize_saved = (int) fjgwpp_getOption('randomize', $fjgwpp_randomize_default);
    $fjgwpp_margins_saved = (int) fjgwpp_getOption('margins', $fjgwpp_margins_default);
    $fjgwpp_openOriginals_saved = (int) fjgwpp_getOption('openOriginals', $fjgwpp_openOriginals_default);
    $fjgwpp_bcontextmenu_saved = (int) fjgwpp_getOption('bcontextmenu', $fjgwpp_bcontextmenu_default);
    $fjgwpp_flickrAPIWrapperVersion_saved = (int) fjgwpp_getOption('flickrAPIWrapperVersion', $fjgwpp_flickrAPIWrapperVersion_default);
    //Save Values
    if (isset($_POST['Submit'])) {
        $error = false;
        $error_msg = "";
        $fjgwpp_flickrAPIWrapperVersion_saved = (int) $_POST["fjgwpp_flickrAPIWrapperVersion"];
        if ($fjgwpp_flickrAPIWrapperVersion_saved == 0) {
            require_once "phpFlickr/phpFlickr.php";
        } else {
            require_once "phpFlickr_a" . $fjgwpp_flickrAPIWrapperVersion_saved . "/phpFlickr.php";
        }
        //Check the API Key
        $fjgwpp_APIKey_saved = trim($_POST["fjgwpp_APIKey"]);
        $f = new phpFlickr($fjgwpp_APIKey_saved);
        if ($f->test_echo() == false) {
            $error = true;
            $error_msg .= '<li>' . __('API Key is not valid', 'fjgwpp') . '</li>';
        }
        $fjgwpp_userID_saved = trim($_POST["fjgwpp_userID"]);
        if (!$error) {
            if ($f->urls_getUserProfile($fjgwpp_userID_saved) == false) {
                $error = true;
                $error_msg .= '<li>' . __('Invalid UserID', 'fjgwpp') . '</li>';
            }
        }
        $fjgwpp_imagesHeight_saved = (int) $_POST["fjgwpp_imagesHeight"];
        if ($fjgwpp_imagesHeight_saved < 30) {
            $error = true;
            $error_msg .= '<li>' . __('The \'Images Height\' field must have a value greater than or equal to 30', 'fjgwpp') . '</li>';
        }
        $fjgwpp_maxPhotosPP_saved = (int) $_POST["fjgwpp_maxPhotosPP"];
        if ($fjgwpp_maxPhotosPP_saved <= 0) {
            $error = true;
            $error_msg .= '<li>' . __('The \'Photos per page\' field must have a value greater than 0', 'fjgwpp') . '</li>';
        }
        $fjgwpp_lastRow_saved = $_POST["fjgwpp_lastRow"];
        if (isset($_POST["fjgwpp_fixedHeight"])) {
            $fjgwpp_fixedHeight_saved = (int) $_POST["fjgwpp_fixedHeight"] != 0 ? 1 : 0;
        } else {
            $fjgwpp_fixedHeight_saved = 0;
        }
        $fjgwpp_pagination_saved = $_POST["fjgwpp_pagination"];
        $fjgwpp_lightbox_saved = $_POST["fjgwpp_lightbox"];
        if (isset($_POST["fjgwpp_provideColorbox"])) {
            $fjgwpp_provideColorbox_saved = (int) $_POST["fjgwpp_provideColorbox"] != 0 ? 1 : 0;
        } else {
            $fjgwpp_provideColorbox_saved = 0;
        }
        if (isset($_POST["fjgwpp_provideSwipebox"])) {
            $fjgwpp_provideSwipebox_saved = (int) $_POST["fjgwpp_provideSwipebox"] != 0 ? 1 : 0;
        } else {
            $fjgwpp_provideSwipebox_saved = 0;
        }
        if (isset($_POST["fjgwpp_captions"])) {
            $fjgwpp_captions_saved = (int) $_POST["fjgwpp_captions"] != 0 ? 1 : 0;
        } else {
            $fjgwpp_captions_saved = 0;
        }
        if (isset($_POST["fjgwpp_showDescriptions"])) {
            $fjgwpp_showDescriptions_saved = (int) $_POST["fjgwpp_showDescriptions"] != 0 ? 1 : 0;
        } else {
            $fjgwpp_showDescriptions_saved = 0;
        }
        if (isset($_POST["fjgwpp_randomize"])) {
            $fjgwpp_randomize_saved = (int) $_POST["fjgwpp_randomize"] != 0 ? 1 : 0;
        } else {
            $fjgwpp_randomize_saved = 0;
        }
        if (isset($_POST["fjgwpp_openOriginals"])) {
            $fjgwpp_openOriginals_saved = (int) $_POST["fjgwpp_openOriginals"] != 0 ? 1 : 0;
        } else {
            $fjgwpp_openOriginals_saved = 0;
        }
        if (isset($_POST["fjgwpp_bcontextmenu"])) {
            $fjgwpp_bcontextmenu_saved = (int) $_POST["fjgwpp_bcontextmenu"] != 0 ? 1 : 0;
        } else {
            $fjgwpp_bcontextmenu_saved = 0;
        }
        $fjgwpp_margins_saved = (int) $_POST["fjgwpp_margins"];
        if ($fjgwpp_margins_saved < 0 || $fjgwpp_margins_saved > 30) {
            $error = true;
            $error_msg .= '<li>' . __('The \'Margins\' field must have a value greater or equal than 0, and not greater than 30', 'fjgwpp') . '</li>';
        }
        if ($error == false) {
            update_option('$fjgwpp_APIKey', $fjgwpp_APIKey_saved);
            update_option('$fjgwpp_userID', $fjgwpp_userID_saved);
            update_option('$fjgwpp_imagesHeight', $fjgwpp_imagesHeight_saved);
            update_option('$fjgwpp_maxPhotosPP', $fjgwpp_maxPhotosPP_saved);
            update_option('$fjgwpp_lastRow', $fjgwpp_lastRow_saved);
            update_option('$fjgwpp_fixedHeight', $fjgwpp_fixedHeight_saved);
            update_option('$fjgwpp_pagination', $fjgwpp_pagination_saved);
            update_option('$fjgwpp_lightbox', $fjgwpp_lightbox_saved);
            update_option('$fjgwpp_provideColorbox', $fjgwpp_provideColorbox_saved);
            update_option('$fjgwpp_provideSwipebox', $fjgwpp_provideSwipebox_saved);
            update_option('$fjgwpp_captions', $fjgwpp_captions_saved);
            update_option('$fjgwpp_showDescriptions', $fjgwpp_showDescriptions_saved);
            update_option('$fjgwpp_randomize', $fjgwpp_randomize_saved);
            update_option('$fjgwpp_margins', $fjgwpp_margins_saved);
            update_option('$fjgwpp_openOriginals', $fjgwpp_openOriginals_saved);
            update_option('$fjgwpp_bcontextmenu', $fjgwpp_bcontextmenu_saved);
            update_option('$fjgwpp_flickrAPIWrapperVersion', $fjgwpp_flickrAPIWrapperVersion_saved);
            ?>
		<div class="updated">
			<p><strong><?php 
            _e('Settings updated.', 'fjgwpp');
            ?>
</strong></p>
		</div>
<?php 
        } else {
            ?>
		<div class="updated">
			<p><strong><?php 
            _e('Invalid values, the settings have not been updated', 'fjgwpp');
            ?>
</strong></p>
			<ul style="color:red"><?php 
            echo $error_msg;
            ?>
</ul>
		</div>
<?php 
        }
    }
    ?>

	<style type="text/css">
		#poststuff h3 { cursor: auto; }
	</style>

			 
	<div class="wrap">
		<h2>Flickr Justified Gallery</h2>

		<div id="poststuff">

			<div class="postbox">

				<h3><?php 
    _e('Help', 'fjgwpp');
    ?>
</h3>
				<div class="inside">
					<p>
						<?php 
    _e('To display the default user\'s photostream, create a page and simply write the following shortcode where you want to display the gallery.', 'fjgwpp');
    ?>
						<div style="margin-left: 30px">
							<pre>[flickr_photostream]</pre>
						</div>
					</p>
					<p>
						<?php 
    _e('However, you can also use the attributes to have settings that are different than the defaults. For example:', 'fjgwpp');
    ?>
						<div style="margin-left: 30px">
							<pre>[flickr_photostream max_num_photos="50" no_pages="true"]</pre>
							<?php 
    _e('displays the latest 50 photos of the default user photostream, without any page navigation. (the other settings are the defaults)', 'fjgwpp');
    ?>
						</div>
					</p>
					<p>
						<?php 
    _e('You can also configure it to show other photostreams. For example:', 'fjgwpp');
    ?>
						<div style="margin-left: 30px">
							<pre>[flickr_photostream user_id="67681714@N03"]</pre>
							<?php 
    _e('displays the photostream of the specified user, no matter what is the default user ID in the settings. Remember that you can use <a href="http://idgettr.com/" target="_blank">idgettr</a> to retrieve the <code>user_id</code>.', 'fjgwpp');
    ?>
						</div>
					</p>

		
					<h4><?php 
    _e('Sets', 'fjgwpp');
    ?>
</h4>
					<p>
						<?php 
    _e('To show the photos of a particular photo set, you need to know its <code>photoset_id</code>.', 'fjgwpp');
    ?>
						<?php 
    _e('For example, the <code>photoset_id</code> of the photo set located in the URL:', 'fjgwpp');
    ?>
						<code>http://www.flickr.com/photos/miro-mannino/sets/72157629228993613/</code>
						<?php 
    _e('is: ', 'fjgwpp');
    ?>
						<code>72157629228993613</code>.
						<?php 
    _e('You can see that it is always the number after the word \'/sets/\'.', 'fjgwpp');
    ?>
						<div>
							<?php 
    _e('To show a particular photoset, you need to use the <code>flickr_set</code> shortcode, and specify the <code>photoset_id</code> with the attribute <code>id</code>. For example:', 'fjgwpp');
    ?>
							<div style="margin-left: 30px">
								<pre>[flickr_set id="72157629228993613"]</pre>
							</div>
						</div>
					</p>

					<h4><?php 
    _e('Galleries', 'fjgwpp');
    ?>
</h4>
					<p>
						<?php 
    _e('To show the photos of a particular gallery, you need to know the <code>user_id</code> of the user that owns it, and its <code>id</code>.', 'fjgwpp');
    ?>
						<?php 
    _e('For example, the <code>id</code> of the gallery located in the URL:', 'fjgwpp');
    ?>
						<code>http://www.flickr.com/photos/miro-mannino/galleries/72157636382842016/</code>
						<?php 
    _e('is: ', 'fjgwpp');
    ?>
						<code>72157636382842016</code>.
						<?php 
    _e('You can see that it is always the number after the word \'/galleries/\'.', 'fjgwpp');
    ?>
						<div>
							<?php 
    _e('To show a particular gallery, you need to use the <code>flickr_gallery</code> shortcode, and specify the <code>user_id</code> with the attribute <code>user_id</code>, and the <code>gallery_id</code> with the attribute <code>id</code>. For example:', 'fjgwpp');
    ?>
							<div style="margin-left: 30px">
								<pre>[flickr_gallery user_id="67681714@N03" id="72157636382842016"]</pre>
							</div>
						</div>
						<?php 
    _e('Remember that, if the gallery is owned by the default user (specified in the settings), you don\'t need the <code>user_id</code> attribute in the shortcode.', 'fjgwpp');
    ?>
					</p>

					<h4><?php 
    _e('Group pools', 'fjgwpp');
    ?>
</h4>
					<p>
						<?php 
    _e('To show the photos of a particular group pool, you need to know the group id, that you can retrieve using <a href="http://idgettr.com/" target="_blank">idgettr</a>.', 'fjgwpp');
    ?>
						<div>
							<?php 
    _e('To show a particular group pool, you need to use the <code>flickr_group</code> shortcode, and specify the group id with the attribute <code>id</code>. For example:', 'fjgwpp');
    ?>
							<div style="margin-left: 30px">
								<pre>[flickr_group id="1563131@N22"]</pre>
							</div>
						</div>
					</p>

					<h4><?php 
    _e('Tags', 'fjgwpp');
    ?>
</h4>
					<p>
						<?php 
    _e('To show the photos that have some particular tags, you need to use the <code>flickr_tags</code> shortcode, and specify the <code>user_id</code> and the tags with the attribute <code>tags</code>, as a comma-delimited list of words. For example:', 'fjgwpp');
    ?>
						<div style="margin-left: 30px">
							<pre>[flickr_tags user_id="67681714@N03" tags="cat, square, nikon"]</pre>
							<?php 
    _e('Displays photos with one or more of the tags listed (the list is viewed as an OR combination, that is the default behavior).', 'fjgwpp');
    ?>
						</div>
						<p>
							<?php 
    _e('You can also exclude results that match a term by prepending it with a <code>-</code> character.', 'fjgwpp');
    ?>
							<?php 
    _e('Then, you can choose to use the list as a OR combination of tags (to return photos that have <b>any</b> tag), or an AND combination (to return photos that have <b>all</b> the tags).', 'fjgwpp');
    ?>
							<?php 
    _e('To do this, you need to use the <code>tags_mode</code>, specifying "any" or "all". For example:', 'fjgwpp');
    ?>
						
							<div style="margin-left: 30px">
								<pre>[flickr_tags user_id="67681714@N03" tags="cat, square, nikon" tags_mode="all"]</pre>
								<?php 
    _e('Displays photos with all the tags listed (the list is viewed as an AND combination).', 'fjgwpp');
    ?>
							</div>
						</p>
						<?php 
    _e('Remember that, if the photo that you want to display is owned by the default user (specified in the settings), you don\'t need the <code>user_id</code> attribute in the shortcode.', 'fjgwpp');
    ?>
					</p>

				</div>
			</div>

			<div class="postbox">

				<h3><?php 
    _e('Settings', 'fjgwpp');
    ?>
</h3>
				<div class="inside">

					<form method="post" name="options" target="_self">
						<h4><?php 
    _e('Global Settings', 'fjgwpp');
    ?>
</h4>

						<table class="form-table">
							<tr>
								<th scope="row">
									<label><?php 
    _e('Flickr API Key', 'fjgwpp');
    ?>
</label>
								</th>
								<td>
									<label for="fjgwpp_APIKey">
									<input type="text" name="fjgwpp_APIKey" 
										value="<?php 
    echo $fjgwpp_APIKey_saved;
    ?>
"
										style="margin-right:10px"
									/> 	
									<?php 
    _e('Get your Flickr API Key from ', 'fjgwpp');
    ?>
<a href="http://www.flickr.com/services/api/keys/" target="_blank">Flickr API</a>
									<div><?php 
    _e('You can\'t use an attribute to change this setting', 'fjgwpp');
    ?>
</div>
									</label>
								</td>
							</tr>
						</table>

						<h4><?php 
    _e('Default Settings', 'fjgwpp');
    ?>
</h4>

						<table class="form-table">
							<tr>
								<th scope="row"><?php 
    _e('User ID', 'fjgwpp');
    ?>
</th>
								<td>
									<label for="fjgwpp_userID">
										<input type="text" name="fjgwpp_userID"
											value="<?php 
    echo $fjgwpp_userID_saved;
    ?>
"
											style="margin-right:10px"
										/>
										<?php 
    _e('Get the User ID from ', 'fjgwpp');
    ?>
<a href="http://idgettr.com/" target="_blank">idgettr</a>
										<div><?php 
    echo __('You can use the <code>', 'fjgwpp') . 'user_id' . __('</code> attribute to change this default value', 'fjgwpp');
    ?>
</div>
									</label>
								</td>
							</tr>
							<tr>
								<th scope="row"><?php 
    _e('Images Height (in px)', 'fjgwpp');
    ?>
</th>
								<td>
									<label for="fjgwpp_imagesHeight">
										<input type="text" name="fjgwpp_imagesHeight" 
											value="<?php 
    echo $fjgwpp_imagesHeight_saved;
    ?>
"
										/>
										<div><?php 
    echo __('You can use the <code>', 'fjgwpp') . 'images_height' . __('</code> attribute to change this default value', 'fjgwpp');
    ?>
</div>
									</label>
								</td>
							</tr>
							<tr>
								<th scope="row"><?php 
    _e('Maximum number of photos per page', 'fjgwpp');
    ?>
</th>
								<td>
									<label for="fjgwpp_maxPhotosPP">
										<input type="text" name="fjgwpp_maxPhotosPP" 
											value="<?php 
    echo $fjgwpp_maxPhotosPP_saved;
    ?>
"
										/>
										<div><?php 
    echo __('You can use the <code>', 'fjgwpp') . 'max_num_photos' . __('</code> attribute to change this default value', 'fjgwpp');
    ?>
</div>
									</label> 	
								</td>
							</tr>
							<tr>
								<th scope="row"><?php 
    _e('Last Row', 'fjgwpp');
    ?>
</th>
								<td>
									<label for="">
										<select name="fjgwpp_lastRow" style="margin-right:5px">
											<option value="justify" <?php 
    if ($fjgwpp_lastRow_saved === 'justify') {
        echo 'selected="selected"';
    }
    ?>
 ><?php 
    _e('Justify', 'fjgwpp');
    ?>
</option>
											<option value="nojustify" <?php 
    if ($fjgwpp_lastRow_saved === 'nojustify') {
        echo 'selected="selected"';
    }
    ?>
 ><?php 
    _e('No justify', 'fjgwpp');
    ?>
</option>
											<option value="hide" <?php 
    if ($fjgwpp_lastRow_saved === 'hide') {
        echo 'selected="selected"';
    }
    ?>
 ><?php 
    _e('Hide if it cannot be justified', 'fjgwpp');
    ?>
</option>
										</select>
										<div><?php 
    echo __('You can use the <code>', 'fjgwpp') . 'last_row' . __('</code> attribute to change this default value (with the value <code>justify</code>, <code>nojustify</code> or <code>hide</code>)', 'fjgwpp');
    ?>
</div>
									</label>
								</td>
							</tr>
							<tr>
								<th scope="row"><?php 
    _e('Fixed Height', 'fjgwpp');
    ?>
</th>
								<td>
									<label for="fjgwpp_fixedHeight">
										<input type="checkbox" name="fjgwpp_fixedHeight" 
											<?php 
    if ($fjgwpp_fixedHeight_saved == 1) {
        echo 'checked="checked"';
    }
    ?>
 
											value="1"
											style="margin-right:5px"
										/>
										<?php 
    _e('If enabled, each row has the same height, but the images will be cut more.', 'fjgwpp');
    ?>
</li>
										<div><?php 
    echo __('You can use the <code>', 'fjgwpp') . 'fixed_height' . __('</code> attribute to change this default value (with the value <code>true</code> or <code>false</code>)', 'fjgwpp');
    ?>
</div>
									</label>
								</td>
							</tr>
							<tr>
								<th scope="row"><?php 
    _e('Pagination', 'fjgwpp');
    ?>
</th>
								<td>
									<label for="fjgwpp_pagination">
										<select name="fjgwpp_pagination" style="margin-right:5px">
											<option value="none" <?php 
    if ($fjgwpp_pagination_saved === 'none') {
        echo 'selected="selected"';
    }
    ?>
 ><?php 
    _e('None', 'fjgwpp');
    ?>
</option>
											<option value="prevnext" <?php 
    if ($fjgwpp_pagination_saved === 'prevnext') {
        echo 'selected="selected"';
    }
    ?>
 ><?php 
    _e('Previous and Next', 'fjgwpp');
    ?>
</option>
											<option value="numbers" <?php 
    if ($fjgwpp_pagination_saved === 'numbers') {
        echo 'selected="selected"';
    }
    ?>
 ><?php 
    _e('Page Numbers', 'fjgwpp');
    ?>
</option>
										</select>
										<?php 
    _e('If enabled, navigation buttons will be shown, and you can see the older photos.<br/><i>Use only one instance per page with this settings enabled!</i>', 'fjgwpp');
    ?>
</li>
										<div><?php 
    echo __('You can use the <code>', 'fjgwpp') . 'pagination' . __('</code> attribute to change this default value (with the value <code>none</code>, <code>prevnext</code> or <code>numbers</code>)', 'fjgwpp');
    ?>
</div>
									</label>
								</td>
							</tr>
							<tr>
								<th scope="row"><?php 
    _e('Lightbox', 'fjgwpp');
    ?>
</th>
								<td>
									<label for="fjgwpp_lightbox">
									<select name="fjgwpp_lightbox" style="margin-right:5px">
										<option value="none" <?php 
    if ($fjgwpp_lightbox_saved === 'none') {
        echo 'selected="selected"';
    }
    ?>
 ><?php 
    _e('None', 'fjgwpp');
    ?>
</option>
										<option value="colorbox" <?php 
    if ($fjgwpp_lightbox_saved === 'colorbox') {
        echo 'selected="selected"';
    }
    ?>
 >Colorbox</option>
										<option value="swipebox" <?php 
    if ($fjgwpp_lightbox_saved === 'swipebox') {
        echo 'selected="selected"';
    }
    ?>
 >Swipebox</option>
									</select>
									<div><?php 
    echo __('You can use the <code>', 'fjgwpp') . 'lightbox' . __('</code> attribute to change this default value (with the value <code>none</code>, <code>colorbox</code> or <code>swipebox</code>).', 'fjgwpp');
    ?>
</div>
									</label>
									<br/>
									<label for="fjgwpp_provideColorbox">
										<input type="checkbox" name="fjgwpp_provideColorbox" 
											<?php 
    if ($fjgwpp_provideColorbox_saved == 1) {
        echo 'checked="checked"';
    }
    ?>
 
											value="1"
											style="margin-right:5px"
										/>
										<?php 
    _e('Provide Colorbox', 'fjgwpp');
    ?>
									</label>
									<span>&nbsp;</span>
									<label for="fjgwpp_provideSwipebox">
										<input type="checkbox" name="fjgwpp_provideSwipebox" 
											<?php 
    if ($fjgwpp_provideSwipebox_saved == 1) {
        echo 'checked="checked"';
    }
    ?>
 
											value="1"
											style="margin-right:5px"
										/>
										<?php 
    _e('Provide Swipebox', 'fjgwpp');
    ?>
									</label>
									<div>
										<?php 
    echo __('Decide to include the lightbox libraries. Without them checked, make sure that you have installed the chosen lightboxes with a plugin (e.g. ', 'fjgwpp') . '<a href="https://wordpress.org/plugins/responsive-lightbox/">Responsive Lightbox</a>, ' . '<a href="http://wordpress.org/extend/plugins/jquery-colorbox/">jQuery Colorbox</a>, ' . '<a href="http://wordpress.org/extend/plugins/lightbox-plus/">Lightbox Plus Colorbox</a>).';
    ?>
									</div>
								</td>
							</tr>
							<tr>
								<th scope="row"><?php 
    _e('Captions', 'fjgwpp');
    ?>
</th>
								<td>
									<label for="fjgwpp_captions">
									<input type="checkbox" name="fjgwpp_captions" 
										<?php 
    if ($fjgwpp_captions_saved == 1) {
        echo 'checked="checked"';
    }
    ?>
 
										value="1" 
										style="margin-right:5px"
									/>
									<?php 
    _e('If enabled, the title of the photo will be shown over the image when the mouse is over. Note: <i>captions, with small images, become aesthetically unpleasing</i>.', 'fjgwpp');
    ?>
</li>
										<div><?php 
    echo __('You can use the <code>', 'fjgwpp') . 'captions' . __('</code> attribute to change this default value (with the value <code>true</code> or <code>false</code>)', 'fjgwpp');
    ?>
</div>
									</label>
								</td>
							</tr>
							<tr>
								<th scope="row"><?php 
    _e('Show descriptions', 'fjgwpp');
    ?>
</th>
								<td>
									<label for="fjgwpp_showDescriptions">
									<input type="checkbox" name="fjgwpp_showDescriptions" 
										<?php 
    if ($fjgwpp_showDescriptions_saved == 1) {
        echo 'checked="checked"';
    }
    ?>
 
										value="1" 
										style="margin-right:5px"
									/>
									<?php 
    _e('If the captions are enabled, the descriptions of the photos will be shown. Note: <i>descriptions, with small images, become aesthetically unpleasing</i>.', 'fjgwpp');
    ?>
</li>
										<div><?php 
    echo __('You can use the <code>', 'fjgwpp') . 'show_descriptions' . __('</code> attribute to change this default value (with the value <code>true</code> or <code>false</code>)', 'fjgwpp');
    ?>
</div>
									</label>
								</td>
							</tr>
							<tr>
								<th scope="row"><?php 
    _e('Randomize order', 'fjgwpp');
    ?>
</th>
								<td>
									<label for="fjgwpp_randomize">
										<input type="checkbox" name="fjgwpp_randomize" 
											<?php 
    if ($fjgwpp_randomize_saved == 1) {
        echo 'checked="checked"';
    }
    ?>
 
											value="1"
											style="margin-right:5px"
										/>
										<?php 
    _e('If enabled, the photos of the same page are randomized.', 'fjgwpp');
    ?>
</li>
										<div><?php 
    echo __('You can use the <code>', 'fjgwpp') . 'randomize' . __('</code> attribute to change this default value (with the value <code>true</code> or <code>false</code>)', 'fjgwpp');
    ?>
</div>
									</label>
								</td>
							</tr>
							<tr>
								<th scope="row"><?php 
    _e('Margin between the images', 'fjgwpp');
    ?>
</th>
								<td>
									<label for="fjgwpp_margins">
										<input type="text" name="fjgwpp_margins" 
											value="<?php 
    echo $fjgwpp_margins_saved;
    ?>
"
											style="margin-right:10px"
										/>
										<div><?php 
    echo __('You can use the <code>', 'fjgwpp') . 'margins' . __('</code> attribute to change this default value', 'fjgwpp');
    ?>
</div>
									</label> 	
								</td>
							</tr>
							<tr>
								<th scope="row"><?php 
    _e('Open original images', 'fjgwpp');
    ?>
</th>
								<td>
									<label for="fjgwpp_openOriginals">
										<input type="checkbox" name="fjgwpp_openOriginals" 
											<?php 
    if ($fjgwpp_openOriginals_saved == 1) {
        echo 'checked="checked"';
    }
    ?>
 
											value="1"
											style="margin-right:5px"
										/>
										<?php 
    _e('If enabled, the lightbox will show the original images if they are available. Consider to leave this option off if your original images are very large.', 'fjgwpp');
    ?>
</li>
										<div><?php 
    echo __('You can use the <code>', 'fjgwpp') . 'open_originals' . __('</code> attribute to change this default value (with the value <code>true</code> or <code>false</code>)', 'fjgwpp');
    ?>
</div>
									</label>
								</td>
							</tr>
							<tr>
								<th scope="row"><?php 
    _e('Block right click', 'fjgwpp');
    ?>
</th>
								<td>
									<label for="fjgwpp_bcontextmenu">
										<input type="checkbox" name="fjgwpp_bcontextmenu" 
											<?php 
    if ($fjgwpp_bcontextmenu_saved == 1) {
        echo 'checked="checked"';
    }
    ?>
 
											value="1"
											style="margin-right:5px"
										/>
										<?php 
    _e('If enabled, the context menu will be blocked, so for the user is more difficult to save the images', 'fjgwpp');
    ?>
</li>
										<div><?php 
    echo __('You can use the <code>', 'fjgwpp') . 'block_contextmenu' . __('</code> attribute to change this default value (with the value <code>true</code> or <code>false</code>)', 'fjgwpp');
    ?>
</div>
									</label>
								</td>
							</tr>
							<tr>
								<th scope="row"><?php 
    _e('Flickr API Wrapper Version', 'fjgwpp');
    ?>
</th>
								<td>
									<label for="fjgwpp_flickrAPIWrapperVersion">
										<select name="fjgwpp_flickrAPIWrapperVersion" style="margin-right:5px">
											<option value="0" <?php 
    if ($fjgwpp_flickrAPIWrapperVersion_saved === 0) {
        echo 'selected="selected"';
    }
    ?>
 >phpFlickr</option>
											<option value="1" <?php 
    if ($fjgwpp_flickrAPIWrapperVersion_saved === 1) {
        echo 'selected="selected"';
    }
    ?>
 >phpFlickr (alternative version)</option>
										</select>
										<div><?php 
    echo __('If you have some problems to communicate with the Flickr\'s API could be useful to change the current version of phpFlickr', 'fjgwpp');
    ?>
</div>
									</label> 	
								</td>
							</tr>
						</table>

						<p>
							<input type="submit" class="button-primary" name="Submit" value="<?php 
    _e('Save Changes', 'fjgwpp');
    ?>
" />
						</p>
					</form>
				</div>
			</div>

			<div class="postbox">
				<h3><?php 
    _e('Help the project', 'fjgwpp');
    ?>
</h3>
				<div class="inside">
					<p>
						<?php 
    _e('Help the project to grow. Donate something, or simply <a href="http://wordpress.org/plugins/flickr-justified-gallery" target="_blank">rate the plugin on Wordpress</a>.', 'fjgwpp');
    ?>
						<form action="https://www.paypal.com/<cgi-bin/webscr" method="post" target="_top">
							<input type="hidden" name="cmd" value="_s-xclick">
							<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHLwYJKoZIhvcNAQcEoIIHIDCCBxwCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBaCyf+oIknmFhsXzg6/NMzIQqul6xv29/NoxNeLY9qTQx7cWHk58Zr8VoWG1ukzEr6kPHash3WD0EeMFtjnNaYXi9aYkvhwF6eSBYXwQYuQLNqKs4bN7QIoa5FLy6SZ0zWwPmgv/0U7338IJVIGsXftvFNQyb5S8MjHO6avNgmHDELMAkGBSsOAwIaBQAwgawGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQIvVcVYkSJki+AgYjC6BBHnJH4/eA8hmo8xUB5j3TRadrqtaz/7o4OMu0lHsFilPob3qDJfZN7IQlL/PwJ0lN5x1Ruc2PyxTnDcc7eo/ho0N8wXTROArUcKpct4Tw7h/sFe4NW25B6lG+hx9fK/57569WwyRPK5psQumX4XQ+QIF/s6wYq84ufhbYVmY3oISDrzfGroIIDhzCCA4MwggLsoAMCAQICAQAwDQYJKoZIhvcNAQEFBQAwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tMB4XDTA0MDIxMzEwMTMxNVoXDTM1MDIxMzEwMTMxNVowgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBR07d/ETMS1ycjtkpkvjXZe9k+6CieLuLsPumsJ7QC1odNz3sJiCbs2wC0nLE0uLGaEtXynIgRqIddYCHx88pb5HTXv4SZeuv0Rqq4+axW9PLAAATU8w04qqjaSXgbGLP3NmohqM6bV9kZZwZLR/klDaQGo1u9uDb9lr4Yn+rBQIDAQABo4HuMIHrMB0GA1UdDgQWBBSWn3y7xm8XvVk/UtcKG+wQ1mSUazCBuwYDVR0jBIGzMIGwgBSWn3y7xm8XvVk/UtcKG+wQ1mSUa6GBlKSBkTCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb22CAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCBXzpWmoBa5e9fo6ujionW1hUhPkOBakTr3YCDjbYfvJEiv/2P+IobhOGJr85+XHhN0v4gUkEDI8r2/rNk1m0GA8HKddvTjyGw/XqXa+LSTlDYkqI8OwR8GEYj4efEtcRpRYBxV8KxAW93YDWzFGvruKnnLbDAF6VR5w/cCMn5hzGCAZowggGWAgEBMIGUMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbQIBADAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTMxMDA4MTUwOTE1WjAjBgkqhkiG9w0BCQQxFgQUiz62NrfLtqFKo3ajhtRp1q7EJzkwDQYJKoZIhvcNAQEBBQAEgYBPmyE8cQbzBqmOu2G4U7UguyWIoWopnGd/4TSzOpekRgUGO1AuRSECyUOirZozJDRqxnSBkuh6LKU9BuSQKErrLYaWWY0eIsyr7g1tD6v0ZllRFdAAWznJnqsw5pligM0YItaZ7ARTbk1IQP4fKm3I0rRMirxNQE4k1/8BPIMzTA==-----END PKCS7-----
							">
							<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
							<img alt="" border="0" src="https://www.paypalobjects.com/it_IT/i/scr/pixel.gif" width="1" height="1">
						</form>
					</p>
				</div>
			</div>

		</div>
	</div>

<?php 
}
function fjgwpp_createGallery($action, $atts)
{
    global $fjgwpp_imagesHeight_default;
    global $fjgwpp_maxPhotosPP_default;
    global $fjgwpp_lastRow_default;
    global $fjgwpp_fixedHeight_default;
    global $fjgwpp_pagination_default;
    global $fjgwpp_lightbox_default;
    global $fjgwpp_captions_default;
    global $fjgwpp_showDescriptions_default;
    global $fjgwpp_randomize_default;
    global $fjgwpp_margins_default;
    global $fjgwpp_openOriginals_default;
    global $fjgwpp_bcontextmenu_default;
    global $fjgwpp_flickrAPIWrapperVersion_default;
    static $shortcode_unique_id = 0;
    $ris = "";
    $page_num = get_query_var('page') ? get_query_var('page') : 1;
    $flickrGalID = 'flickrGal' . $shortcode_unique_id;
    //Options-----------------------
    extract(shortcode_atts(array('user_id' => fjgwpp_getOption('userID'), 'id' => NULL, 'tags' => NULL, 'tags_mode' => 'any', 'images_height' => fjgwpp_getOption('imagesHeight', $fjgwpp_imagesHeight_default), 'max_num_photos' => fjgwpp_getOption('maxPhotosPP', $fjgwpp_maxPhotosPP_default), 'last_row' => fjgwpp_getOption('lastRow', $fjgwpp_lastRow_default), 'fixed_height' => fjgwpp_getOption('fixedHeight', $fjgwpp_fixedHeight_default) == 1, 'lightbox' => fjgwpp_getOption('lightbox', $fjgwpp_lightbox_default), 'captions' => fjgwpp_getOption('captions', $fjgwpp_captions_default) == 1, 'show_descriptions' => fjgwpp_getOption('showDescriptions', $fjgwpp_showDescriptions_default) == 1, 'randomize' => fjgwpp_getOption('randomize', $fjgwpp_randomize_default) == 1, 'pagination' => fjgwpp_getOption('pagination', $fjgwpp_pagination_default), 'margins' => fjgwpp_getOption('margins', $fjgwpp_margins_default), 'open_originals' => fjgwpp_getOption('openOriginals', $fjgwpp_openOriginals_default) == 1, 'block_contextmenu' => fjgwpp_getOption('bcontextmenu', $fjgwpp_bcontextmenu_default) == 1, 'flickrAPIWrapperVersion' => fjgwpp_getOption('flickrAPIWrapperVersion', $fjgwpp_flickrAPIWrapperVersion_default) == 0), $atts));
    //Trim string options
    $user_id = trim($user_id);
    $id = trim($id);
    $lightbox = trim($lightbox);
    $last_row = trim($last_row);
    if ($flickrAPIWrapperVersion == 0) {
        require_once "phpFlickr/phpFlickr.php";
    } else {
        require_once "phpFlickr_a" . $flickrAPIWrapperVersion . "/phpFlickr.php";
    }
    //LEGACY for the old options
    if ($pagination === '1') {
        $pagination = 'prevnext';
    } else {
        if ($pagination !== 'none' && $pagination !== 'prevnext' && $pagination !== 'numbers') {
            $pagination = 'none';
        }
    }
    if ($lightbox === '1') {
        $lightbox = 'colorbox';
    }
    if ($lightbox === '0') {
        $lightbox = 'none';
    }
    $images_height = (int) $images_height;
    if ($images_height < 30) {
        $images_height = 30;
    }
    $max_num_photos = (int) $max_num_photos;
    if ($max_num_photos < 1) {
        $max_num_photos = 1;
    }
    $margins = (int) $margins;
    if ($margins < 0) {
        $margins = 1;
    }
    if ($margins > 30) {
        $margins = 30;
    }
    if ($pagination === 'none') {
        $page_num = 1;
    }
    //-----------------------------
    //Inizialization---------------
    $flickrAPIKey = trim(fjgwpp_getOption('APIKey'));
    //Flickr API Key
    $flickrAPISecret = trim(fjgwpp_getOption('APISecret'));
    //Flickr API Secret
    $flickrAPIToken = trim(fjgwpp_getOption('APIToken'));
    //Flickr API Token
    if ($flickrAPISecret && $flickrAPIToken) {
        // fully authenticated call
        $f = new phpFlickr($flickrAPIKey, $flickrAPISecret);
        $f->setToken($flickrAPIToken);
        $f->auth("read");
    } else {
        // standard call
        $f = new phpFlickr($flickrAPIKey);
    }
    $upload_dir = wp_upload_dir();
    $f->enableCache("fs", $upload_dir['basedir'] . "/phpFlickrCache");
    $photos_url = array();
    $photos = array();
    $photos_main_index = '';
    $maximum_pages_nums = 10;
    //TODO configurable?
    //Errors-----------------------
    if ($action === 'phs' || $action === 'gal' || $action === 'tag') {
        if (!isset($user_id) || strlen($user_id) == 0) {
            return fjgwpp_formatError(__('You must specify the user_id for this action, using the "user_id" attribute', 'fjgwpp'));
        }
    }
    if ($action === 'gal') {
        if (!isset($id) || strlen($id) == 0) {
            return fjgwpp_formatError(__('You must specify the id of the gallery, using the "id" attribute', 'fjgwpp'));
        }
    }
    if ($action === 'set') {
        if (!isset($id) || strlen($id) == 0) {
            return fjgwpp_formatError(__('You must specify the id of the set, using the "id" attribute', 'fjgwpp'));
        }
    }
    if ($action === 'tag') {
        if (!isset($tags) || strlen($tags) == 0) {
            return fjgwpp_formatError(__('You must specify the tags using the "tags" attribute', 'fjgwpp'));
        }
        if ($tags_mode !== 'any' && $tags_mode !== 'all') {
            return fjgwpp_formatError(__('You must specify a valid tags_mode: "any" or "all"', 'fjgwpp'));
        }
    }
    if ($action === 'grp') {
        if (!isset($id) || strlen($id) == 0) {
            return fjgwpp_formatError(__('You must specify the id of the group, using the "id" attribute', 'fjgwpp'));
        }
    }
    if ($pagination !== 'none' && $pagination !== 'prevnext' && $pagination !== 'numbers') {
        return fjgwpp_formatError(__('The pagination attribute can be only "none", "prevnext" or "numbers".', 'fjgwpp'));
    }
    if ($last_row !== 'hide' && $last_row !== 'justify' && $last_row !== 'nojustify') {
        return fjgwpp_formatError(__('The last_row attribute can be only "hide", "justify" or "nojustify".', 'fjgwpp'));
    }
    if ($lightbox !== 'none' && $lightbox !== 'colorbox' && $lightbox !== 'swipebox') {
        return fjgwpp_formatError(__('The lightbox attribute can be only "none", "colorbox" or "swipebox".', 'fjgwpp'));
    }
    //Photo loading----------------
    $extras = "description, original_format, url_l, url_z";
    if ($action === 'set') {
        //Show the photos of a particular photoset
        $photos = $f->photosets_getPhotos($id, $extras, NULL, $max_num_photos, $page_num, NULL);
        $photos_main_index = 'photoset';
    } else {
        if ($action === 'gal') {
            //Show the photos of a particular gallery
            $photos_url[$user_id] = $f->urls_getUserPhotos($user_id);
            if ($f->getErrorCode() != NULL) {
                return fjgwpp_formatFlickrAPIError($f->getErrorMsg());
            }
            $gallery_info = $f->urls_lookupGallery($photos_url[$user_id] . 'galleries/' . $id);
            if ($f->getErrorCode() != NULL) {
                return fjgwpp_formatFlickrAPIError($f->getErrorMsg());
            }
            $photos = $f->galleries_getPhotos($gallery_info['gallery']['id'], $extras, $max_num_photos, $page_num);
            $photos_main_index = 'photos';
        } else {
            if ($action === 'tag') {
                $photos = $f->photos_search(array('user_id' => $user_id, 'tags' => $tags, 'tag_mode' => $tags_mode, 'extras' => $extras, 'per_page' => $max_num_photos, 'page' => $page_num));
                $photos_main_index = 'photos';
            } else {
                if ($action === 'grp') {
                    //Show the photos of a particular group pool
                    //groups_pools_getPhotos ($group_id, $tags = NULL, $user_id = NULL, $jump_to = NULL, $extras = NULL, $per_page = NULL, $page = NULL) {
                    $photos = $f->groups_pools_getPhotos($id, $tags, NULL, NULL, $extras, $max_num_photos, $page_num);
                    $photos_main_index = 'photos';
                } else {
                    //Show the classic photostream
                    $photos = $f->people_getPublicPhotos($user_id, NULL, $extras, $max_num_photos, $page_num);
                    //Need the authentication (TODO)
                    //$photos = $f->people_getPhotos($user_id,
                    //	array("privacy_filter" => "1", "extras" => "description", "per_page" => $max_num_photos, "page" => $page_num));
                    $photos_main_index = 'photos';
                }
            }
        }
    }
    if ($f->getErrorCode() != NULL) {
        return fjgwpp_formatFlickrAPIError($f->getErrorMsg());
    }
    $photos_pool = $photos[$photos_main_index];
    if (count((array) $photos_pool['photo']) == 0) {
        return __('No photos', 'fjgwpp');
    }
    //we calculate that the aspect ratio has an average of 4:3
    if ($images_height <= 75) {
        $imgSize = "thumbnail";
        //thumbnail (longest side:100)
    } else {
        if ($images_height <= 180) {
            $imgSize = "small";
            //small (longest side:240)
        } else {
            //if <= 240
            $imgSize = "small_320";
            //small (longest side:320)
        }
    }
    $ris .= '<!-- Flickr Justified Gallery Wordpress Plugin by Miro Mannino -->' . "\n" . '<div id="' . $flickrGalID . '" class="justified-gallery" >';
    $r = 0;
    $use_large_thumbnails = true;
    foreach ($photos_pool['photo'] as $photo) {
        if (!isset($photo['url_l'])) {
            $use_large_thumbnails = false;
        }
        fjgwpp_entryLink($id, $f, $ris, $photo, $photos_pool, $photos_url, $lightbox, $open_originals, $flickrGalID, $action);
        $ris .= '<img alt="' . htmlspecialchars($photo['title'], ENT_QUOTES, 'UTF-8') . '" src="' . $f->buildPhotoURL($photo, $imgSize) . '" data-safe-src="' . $f->buildPhotoURL($photo, $imgSize) . '" />';
        if ($captions) {
            $ris .= '<div class="caption">' . '<div class="photo-title' . ($show_descriptions ? ' photo-title-with-desc' : '') . '">' . htmlspecialchars($photo['title'], ENT_QUOTES, 'UTF-8') . '</div>';
            if ($show_descriptions && isset($photo['description']) && isset($photo['description']['_content'])) {
                $ris .= '<div class="photo-desc">' . fjgwpp_filterDescription($photo['description']['_content']) . '</div>';
            }
            $ris .= '</div>';
        }
        $ris .= '</a>';
        //end link
    }
    $ris .= '</div>' . '<script type="text/javascript">';
    $ris .= 'function fjgwppInit_' . $flickrGalID . '() {
				jQuery("#' . $flickrGalID . '")';
    if ($lightbox === 'colorbox') {
        $ris .= '.on(\'jg.rowflush jg.complete\', function() {
					jQuery(this).find("> a").colorbox({
						title:function() {
        					var tit= \'<div class="boxTitle">\'+jQuery(this).find(\'.photo-title\').html()+\'</div>\';
        					var cap =\'<div class="boxCaption">\'+jQuery(this).find(\'.photo-desc\').html()+\'</div>\';
        					return tit+cap;
        				},
						maxWidth : "85%",
						maxHeight : "85%",
						current : "",';
        if ($block_contextmenu) {
            $ris .= 'onComplete: function() {
							fjgwppDisableContextMenu(jQuery("#colorbox .cboxPhoto"));
						}';
        }
        $ris .= '});
				})';
    } else {
        if ($lightbox === 'swipebox') {
            $ris .= '.on(\'jg.complete\', function() {
					jQuery("#' . $flickrGalID . '").find("> a").swipebox(';
            if ($block_contextmenu) {
                $ris .= '{
						afterOpen : function () {
							setTimeout(function() {
								fjgwppDisableContextMenu(jQuery("#swipebox-overlay .slide img"));
							}, 100);
						}
					}';
            }
            $ris .= ');
				})';
        }
    }
    $ris .= '.justifiedGallery({' . '\'lastRow\': \'' . $last_row . '\', ' . '\'rowHeight\':' . $images_height . ', ' . '\'fixedHeight\':' . ($fixed_height ? 'true' : 'false') . ', ' . '\'captions\':' . ($captions ? 'true' : 'false') . ', ' . '\'randomize\':' . ($randomize ? 'true' : 'false') . ', ' . '\'margins\':' . $margins . ', ' . '\'sizeRangeSuffixes\': {
			 			\'lt100\':\'_t\', \'lt240\':\'_m\', \'lt320\':\'_n\',
						\'lt500\':\'\', \'lt640\':\'_z\',' . ($use_large_thumbnails ? '\'lt1024\':\'_b\'' : '\'lt1024\':\'_z\'') . '}});';
    if ($block_contextmenu) {
        $ris .= 'fpDisableContextMenu(jQuery("#' . $flickrGalID . '").find("> a"));';
    }
    $ris .= '}' . 'if (typeof fjgwpp_galleriesInit_functions === "undefined") fjgwpp_galleriesInit_functions = [];' . 'fjgwpp_galleriesInit_functions.push(fjgwppInit_' . $flickrGalID . ');' . '</script>';
    //Navigation---------------------
    if ($pagination !== 'none') {
        $num_pages = $photos[$photos_main_index]['pages'];
        if ($num_pages > 1) {
            $permalink = get_permalink();
            if ($pagination === 'numbers') {
                $ris .= '<div class="page-links">' . '<span class="page-links-title">Pages:</span> ';
                $low_num = $page_num - floor($maximum_pages_nums / 2);
                $high_num = $page_num + ceil($maximum_pages_nums / 2) - 1;
                if ($low_num < 1) {
                    $high_num += 1 - $low_num;
                    $low_num = 1;
                }
                if ($high_num > $num_pages) {
                    $high_num = $num_pages;
                }
                if ($low_num > 1) {
                    $ris .= '<a href="' . add_query_arg('page', $low_num - 1, $permalink) . '"><span>...</span></a> ';
                }
                for ($i = $low_num; $i <= $high_num; $i++) {
                    if ($i == $page_num) {
                        $ris .= '<span>' . $i . '</span> ';
                    } else {
                        $ris .= '<a href="' . add_query_arg('page', $i, $permalink) . '"><span>' . $i . '</span></a> ';
                    }
                }
                if ($high_num < $num_pages) {
                    $ris .= '<a href="' . add_query_arg('page', $high_num + 1, $permalink) . '"><span>...</span></a> ';
                }
                $ris .= '</div>';
            } else {
                if ($pagination === 'prevnext') {
                    $ris .= '<div>';
                    if ($page_num < $num_pages) {
                        $ris .= '<div class="nav-previous">' . '<a href="' . add_query_arg('page', (int) $page_num + 1, $permalink) . '">' . __('<span class="meta-nav">&larr;</span> Older photos', 'fjgwpp') . '</a>' . '</div>';
                    }
                    if ($page_num > 1) {
                        //a link to the newer photos
                        $ris .= '<div class="nav-next">' . '<a href="' . add_query_arg('page', (int) $page_num - 1, $permalink) . '">' . __('Newer photos <span class="meta-nav">&rarr;</span>', 'fjgwpp') . '</a>' . '</div>';
                    }
                    $ris .= '</div>';
                }
            }
        }
    }
    $shortcode_unique_id++;
    return $ris;
}