<?php $__env->startSection('content'); ?>
<div class="container-fluid parallax-six modul-bt-one" data-speed="5" data-type="background">
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="big-title">
                    <h1>Add Page</h1>
                </div>
            </div>
        </div>
	</div>
</div>

<div class="container-fluid">
	<div class="row">
		<div class="col-md-8 col-md-offset-2">
			<div class="panelX panel-defaultX">

				<div class="panel-body">
					<?php if(session('status')): ?>
						<div class="alert alert-success">
							<?php echo e(session('status')); ?>

						</div>
					<?php endif; ?>
					<?php if(count($errors) > 0): ?>
						<div class="alert alert-danger">
							<strong>Whoops!</strong> There were some problems with your input.<br><br>
							<ul>
								<?php foreach($errors->all() as $error): ?>
									<li><?php echo e($error); ?></li>
								<?php endforeach; ?>
							</ul>
						</div>
					<?php endif; ?>

					<form id="theForm" class="form-horizontal" role="form" method="POST" action="<?php echo e(url('admin/pages/add')); ?>">
						<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
						
						<div class="form-group">
							<label class="col-md-3 control-label">Page Name</label>
							<div class="col-md-7">
								<input type="text" class="form-control" name="name" value="<?php echo e(old('name')); ?>">	
							</div>
						</div>
						<div class="form-group">
							<label class="col-md-3 control-label">Page Title</label>
							<div class="col-md-7">
								<input type="text" class="form-control" name="title" value="<?php echo e(old('title')); ?>">	
							</div>
						</div>
						<div class="form-group">
							<label class="col-md-3 control-label">Page URL</label>
							<div class="col-md-7">
								<input type="text" class="form-control" name="url" value="<?php echo e(old('url')); ?>">	
							</div>
						</div>
						<div class="form-group">
							<label class="col-md-3 control-label">Section 1</label>
							<div class="col-md-7">
								<select id="section1" class="form-control" name="section1">
									<option value="0">Select One</option>
									<?php foreach($sections as $section): ?>
									<option value="<?php echo e($section->id); ?>">
										<?php echo e($section->name); ?>

									</option>
									<?php endforeach; ?>
								</select>
							</div>
							<div class="col-md-2">
								<input type="number" min="0" max="12" class="form-control" name="width1" value="0">	
							</div>
						</div>
						<div class="form-group">
							<div class="col-md-12 col-md-offset-4">
								<button type="button" id="plus" class="btn btn-primary" onclick="addSection()">
									<i class="fa fa-plus"></i>
								</button>
								<button type="button" id='minus' class="btn btn-primary" onclick="removeSection()" disabled>
									<i class="fa fa-minus"></i>
								</button>
								<button type="submit" class="btn btn-primary">
									Add Page
								</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('extras'); ?>
	<script>
		function addSection()
		{

			var allSections = document.getElementById('section1');
			var theForm = document.getElementById('theForm');
			
			var newFormGroup = document.createElement("div");
			newFormGroup.className = "form-group";
			var newLabel = document.createElement("label");
			newLabel.className = "col-md-3 control-label";
			var newColumn = document.createElement("div");
			newColumn.className = "col-md-7";
			var newSelect = document.createElement("select");
			newSelect.className = "form-control";
			var newWidth = document.createElement("div");
			newWidth.className = "col-md-2";
			var newNumber = document.createElement("input");
			newNumber.className = "form-control";

			var count = 1;
			while(document.getElementById('section' + count) != null)
			{
				count++;
			}

			newSelect.setAttribute("id", 'section' + count);
			newSelect.setAttribute("name", 'section' + count);
			newSelect.innerHTML = allSections.innerHTML;

			newLabel.innerHTML = 'Section ' + count;

			newNumber.setAttribute('type', 'number');
			newNumber.setAttribute('name', 'width' + count);
			newNumber.setAttribute('min', '0');
			newNumber.setAttribute('max', '12');
			newNumber.setAttribute('value', '0');

			newWidth.appendChild(newNumber);
			
			newFormGroup.appendChild(newLabel);
			newColumn.appendChild(newSelect);
			newFormGroup.appendChild(newColumn);
			newFormGroup.appendChild(newWidth);

			theForm.insertBefore(newFormGroup, theForm.childNodes[count+8]);

			if(count >= 9) document.getElementById('plus').disabled = true;
			if(count > 1) document.getElementById('minus').disabled = false;
			
		}
		function removeSection()
		{
			var theForm = document.getElementById('theForm');
			
			var count = 1;
			while(document.getElementById('section' + count) != null)
			{
				count++;
			}
			count--;
			var section = document.getElementById('section' + count).parentNode.parentNode;
			theForm.removeChild(section);
			if(count == 2) document.getElementById('minus').disabled = true;
			if(count <= 9) document.getElementById('plus').disabled = false;
			
		}
		
	</script>
<?php $__env->stopSection(); ?>







<?php echo $__env->make('residential.templates.adminT', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>