<?php
if (isset($_POST['append_ajax']) && $_POST['append_ajax']){	
	$action = 'reload';
	$next = 1;
	if (isset($_POST['resolutions_data'])) {
		foreach ($_POST['resolutions_data'] AS $key => $value){
			$next++;
		}
	}
	print "
<div class='form-row'>
	<label for='images_width_".$next."' class='form-label'>".LABEL_OPTIONS_THUMBNAIL." ".$next."</label>
	<div class='form-cols'>
		<div class='form-col form-xsmall'>
			<div class='form-controls'>
				<input type='text' class='field' id='images_width_".$next."' name='resolutions_data[".$next."][width]' value=''>
				<label for='images_width_".$next."' class='form-label-after'>X</label>
			</div><!-- /.form-controls -->
		</div><!-- /.form-col -->
						
		<div class='form-col form-xsmall'>
			<div class='form-controls'>
				<input type='text' class='field' id='images_height_".$next."' name='resolutions_data[".$next."][height]' value=''>
				<label for='images_height_".$next."' class='form-label-link'><a href='#' class='remove_ajax' data-file='resolutions'><i class='material-icons md-24'>delete</i></a></label>
			</div><!-- /.form-controls -->
		</div><!-- /.form-col -->
	
	</div><!-- /.form-cols -->
</div><!-- /.form-row -->";
} else if (isset($_POST['reload_ajax']) && $_POST['reload_ajax']){	
	$action = 'reload';
	$next = 1;
	if (isset($_POST['resolutions_data'])) {
		foreach ($_POST['resolutions_data'] AS $key => $value){
			$resolutions_data[$next] = $value;
			$next++;
		}
	}
} else {
print "
<div id='box_resolutions'>";
}
if (!isset($_POST['append_ajax']) OR !$_POST['append_ajax']){
	print "
	<span class='headline'>".LABEL_OPTIONS_THUMBNAILS."</span>
	<div class='form-row'>
		<label for='lightbox_width' class='form-label'>".LABEL_OPTIONS_LIGHTBOX."</label>
		<div class='form-cols'>
			<div class='form-col form-xsmall'>
				<div class='form-controls'>
					<input type='text' class='field' id='lightbox_width' name='lightbox_width' value='".$lightbox_width."'>
					<label for='lightbox_width' class='form-label-after'>X</label>
				</div><!-- /.form-controls -->
			</div><!-- /.form-col -->
							
			<div class='form-col form-xsmall'>
				<div class='form-controls'>
					<input type='text' class='field' id='lightbox_height' name='lightbox_height' value='".$lightbox_height."'>
				</div><!-- /.form-controls -->
			</div><!-- /.form-col -->
			
		</div><!-- /.form-cols -->
	</div><!-- /.form-row -->";
	if (isset($resolutions_data) && is_array($resolutions_data)){
		foreach ($resolutions_data AS $key => $value){
			print "
	<div class='form-row'>
		<label for='images_width_".$key."' class='form-label'>".LABEL_OPTIONS_THUMBNAIL." ".$key."</label>
		<div class='form-cols'>
			<div class='form-col form-xsmall'>
				<div class='form-controls'>
					<input type='text' class='field' id='images_width_".$key."' name='resolutions_data[".$key."][width]' value='".$value['width']."'>
					<label for='images_width_".$key."' class='form-label-after'>X</label>
				</div><!-- /.form-controls -->
			</div><!-- /.form-col -->
							
			<div class='form-col form-xsmall'>
				<div class='form-controls'>
					<input type='text' class='field' id='images_height_".$key."' name='resolutions_data[".$key."][height]' value='".$value['height']."'>
					<label for='images_height_".$key."' class='form-label-link'><a href='#' class='remove_ajax' data-file='resolutions'><i class='material-icons md-24'>delete</i></a></label>
				</div><!-- /.form-controls -->
			</div><!-- /.form-col -->
			
		</div><!-- /.form-cols -->
	</div><!-- /.form-row -->";
		}
	}
	print "
	<div id='box_append_resolutions'></div>
	
	<div class='form-row'>
		<span class='form-label'>".LABEL_OPTIONS_ADD."</span>
		<div class='form-cols'>
			<div class='form-col form-full'>
				<div class='form-controls'>
					<span class='form-label-after'><a href='#' class='append_ajax' data-file='resolutions'><i class='material-icons md-24'>add</i></a></span>
				</div><!-- /.form-controls -->
			</div><!-- /.form-col -->
		</div><!-- /.form-cols -->
	</div><!-- /.form-row -->";
}
if (!isset($_POST['reload_ajax']) OR !$_POST['reload_ajax']){
	print "
</div>
<hr />";
}

	