<section class="overlay submitform" ng-if="!myform.submitted && !myform.startPage.showStart"></section>

<!-- Start Page View -->
<div ng-show="!myform.submitted && myform.startPage.showStart" 
	class="form-submitted" 
	style="margin-top: 35vh;">
    <div class="row">
        <div class="col-xs-12 text-center" style="overflow-wrap: break-word;">
            <h1 style="font-weight: 400; font-size: 25px;">
            	{{myform.startPage.introTitle}}
            </h1>
        </div>
        <div class="col-xs-10 col-xs-offset-1 text-center" style="overflow-wrap: break-word;">
            <p style="color: grey; font-weight: 100; font-size: 16px;">
            	{{myform.startPage.introParagraph}}
            </p>
        </div>
    </div>

    <div class="row form-actions text-center" style="padding: 5px 25px 5px 25px;">
        <button ng-click="exitStartPage()" class="btn btn-info" type="button">
            <a style="color:grey; font-size: 1.6em; text-decoration: none;">
                Start
            </a>
        </button>
    </div>
     <div class="row form-actions" style="padding-bottom:3em; padding-left: 1em; padding-right: 1em;">
        <p ng-repeat="button in myform.startPage.buttons" class="text-center" style="display:inline;">
            <button class="btn" style="background-color:rgb(156, 226, 235)" type="button" ng-style="{'background-color':button.bgColor, 'color':button.color}">
                <a href="{{button.url}}" 
			style="font-size: 1.6em; text-decoration: none;" 
			ng-style="{'color':button.color}">
                    {{button.text}}
                </a>
            </button>
        </p>
    </div>
</div>

<!-- Form Fields View -->
<div class="form-fields" cg-busy="{promise:submitPromise,message:'Submitting form...',wrapperClass:'busy-submitting-wrapper',backdrop:true}" ng-show="!myform.submitted && !myform.startPage.showStart">
    <!--<div class="field row" style="padding-bottom:5em;">-->
    <!--    <div class="col-sm-10 col-sm-offset-1">-->
    <!--        <h1>{{ myform.title }} <span style="font-size:0.8em; color: #bbb;" ng-if="!myform.isLive">(private preview)</span></h1>-->
    <!--        <hr>-->
    <!--    </div>-->
    <!--</div>-->
    <div class="row">
        <form name="myForm" class="submission-form col-sm-12 col-md-offset-1 col-md-10">
                <div ng-repeat="field in myform.form_fields"  
				ng-if="!field.deletePreserved" 
				data-index="{{$index}}" 
				data-id="{{field._id}}" 
				ng-class="{activeField: selected._id == field._id }" 
				class="row field-directive">
                    <field-directive field="field" design="myform.design" index="$index">
                    </field-directive>
                </div>
        </form>
    </div>


    <div class="row form-actions" id="submit_field" 
	ng-click="setActiveField('submit_field', myform.form_fields.length)" 
	ng-class="{activeField: selected._id == 'submit_field' }" 
	style="border-top: 1px solid #ddd; margin-right: -13% ;margin-left: -13%; padding-bottom: 25vh;">
        
	<button ng-focus="setActiveField('submit_field', myform.form_fields.length)" 
		class="btn btn-success col-sm-2" 
		type="button" 
		ng-disabled="myform.$invalid || $scope.loading" 
		ng-click="submitForm()" 
		style="font-size: 1.6em; margin-left: 1em; margin-top: 1em;"> 
		Submit
        </button>
	
	<div class="col-sm-2" style="font-size: 75%; margin-top:2.5em">
		<small>
		 press ENTER
		</small>
	</div>
    </div>

    <section ng-if="!myform.hideFooter" class="navbar navbar-fixed-bottom" style="background-color:rgba(242,242,242,0.5); padding-top:15px;">
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-5 col-md-6" ng-show="!myform.submitted">
                        <p class="lead">{{myform | formValidity}} out of {{myform.visible_form_fields.length}} answered</p>
                </div>
                <div class="col-md-6 col-md-offset-0 col-sm-offset-2 col-sm-3 row">
                    <div class="col-md-4 col-md-offset-2 hidden-sm hidden-xs" ng-if="!authentication.isAuthenticated()">
                        <a href="/#!/forms" class="btn btn-default">Create 
                        a TellForm</a>
                    </div>
                    <div class="col-md-4 col-md-offset-2 hidden-sm hidden-xs" ng-if="authentication.isAuthenticated()">
                        <a href="/#!/forms/{{myform._id}}/admin/create" class="btn btn-default">Edit this TellForm</a>
                    </div>
                    <div class="col-md-4 col-sm-10 col-md-offset-0 col-sm-offset-4"> 
                        <button class="btn btn-info btn-lg" id="focusDownButton"
				ng-click="nextField()" 
				ng-disabled="selected.index > myform.form_fields.length-1">
                        	<i class="fa fa-chevron-down"></i>
                        </button>
                        <button class="btn btn-info btn-lg" id="focusUpButton" ng-click="prevField()" ng-disabled="selected.index == 0">
                        	<i class="fa fa-chevron-up"></i>
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>

<!-- End Page View -->
<div ng-if="myform.submitted" class="form-submitted">

    <div class="field row text-center">
        <div class="col-xs-6 col-xs-offset-3 text-center">Form entry successfully submitted!</div>
    </div>
    <div class="row form-actions">
        <p class="text-center col-xs-4 col-xs-offset-4">
            <button ng-click="reloadForm()" class="btn btn-info" type="button">
                <a style="color:white; font-size: 1.6em; text-decoration: none;"> Go back to Form</a>
            </button>
        </p>
    </div>
</div>
