@if($survey->background_image!="" and $survey->show_background_image==1)
	<style type="text/css">
         body{
             background-image:url('{{\Image::url($survey->background_image)}}') !important;
             background-repeat:repeat;
        }
    </style>	
@endif    

@if($survey->show_website_footer==0)
	<style type="text/css">
         .main-footer{
			display:none; 
		 }
    </style>
@endif     

@if(Auth::check())
	<style type="text/css">
         #content-container{
		 	margin-top: 66px;
		 }
    </style>
@endif

<?php 
	$alignCenter='left';
	$background='#000';
	$color='#fff';
	$font_weight='normal';
	$font_size='25px';
	
	if($survey->title_alignment==0){
		$alignCenter='center';
	}elseif($survey->title_alignment==1){
		$alignCenter='left';
	}elseif($survey->title_alignment==2){
		$alignCenter='right';
	}elseif($survey->title_alignment==3){
		$alignCenter='center';
	}
	
	if($survey->header_text_color!=""){
		$color=$survey->header_text_color;
	}
	
	if($survey->header_background_color!=""){
		$background=$survey->header_background_color;
	}
	
	if($survey->font_weight ==1){
		$font_weight='bold';
	}
	
	if($survey->font_size!="" and $survey->font_size!="0"){
		$font_size=$survey->font_size."px";
	}
	
	$backgroundImage='';
	$backgroundImageResponsive='';
	if($survey->header_image!=""){
		$backgroundImage=\Image::url($survey->header_image);
		$backgroundImageResponsive=\Image::url($survey->header_image);
	}
	
	
	if($survey->header_image_responsive!=""){
		$backgroundImageResponsive=\Image::url($survey->header_image_responsive);
	}
	
	$loginRequired="";
	if($survey->login_required_for_action==1 and !\Auth::check() and $canViewLink) 
	{
		$loginRequired="login_required_for_action";
	}
?>



<div class="container cmformscontainer community-survey-form" style="padding:0px">
    	
        <div class="survey-title survey-box-header" style="margin:0; @if($survey->title_alignment==3)  display:flex; flex-direction:column; @endif  text-align:{{$alignCenter}}; color:{{$color}}; font-weight:{{$font_weight}}; font-size:{{$font_size}}; @if($survey->use_header_image==0) background-color:{{$background}}; @endif">
            
            @if($survey->use_header_image==1)
				<style>
                    /*@media (min-width: 481px) {
                        .survey-box-header{	
                           background-image: url({{$backgroundImage}}); 
                           background-size: cover;
                        }
                    }	
                
                    @media (max-width: 1024px){
                       .survey-box-header{	
                           background-image: url({{$backgroundImageResponsive}});
                           background-size: cover;
                       }
                    }*/	
					
					.survey-box-header {
						position: relative;   /* REQUIRED */
						width: 100%;
						padding:0px !important;
					}
					
					.survey-image {
						width: 100%;
						height: auto;
						display: block;
					}
					
					/* Common title style */
					.survey-title-text {
						position: absolute;
						width: 100%;
						padding: 15px;
					}

                </style>  
                
                <img src="{{$backgroundImage}}" alt="Survey Banner" class="survey-image">
            @else
                <div></div>   
            @endif
            
           
			<div class="survey-title-text" style="width:100%; @if($survey->title_alignment==3) margin-top:auto; @endif">{{nl2br($survey->title)}}</div>
        </div>

		 @if (Session::has('captcha_error_msg') and Session::get('captcha_error_msg')!="")
			<br> 
			<div class="row">
				<div class="col-sm-10 col-sm-offset-1" >
					  <div class="alert alert-dismissible alert-success" style="font-size: 20px;"> <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>{{nl2br(Session::get('captcha_error_msg'))}}</div>
				 </div>
			 </div>
			
              <?php
			 	\Session::put('captcha_error_msg', "");
			 ?>				 
		 @endif 	 
		
		 @if (Session::has('survey_submit_msg') and Session::get('survey_submit_msg')!="")
			<br> 
			<div class="row">
				<div class="col-sm-10 col-sm-offset-1" >
					  <div class="alert alert-dismissible alert-success" style="font-size: 20px;"> <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>{!! nl2br(Session::get('survey_submit_msg')) !!}</div>
				 </div>
			 </div>	
             
             <?php
			 	\Session::put('survey_submit_msg', "");
			 ?>	
             
             @if($survey->submit_redirect_link)
				 <script language="javascript">
                     window.setTimeout(function(){
                            var link = document.createElement('a');
                            link.href = "{{$survey->submit_redirect_link}}";						
                            document.body.appendChild(link);
                            link.click();  
                    
                      }, 4000);
                </script> 	 
            @endif    
		@endif         
        
		@if($survey->description)
			<div class="row survey-description">
				{!! nl2br($survey->description) !!}
			</div>
		@endif	
        
        @if(!$community->present()->isAdmin() and $survey->status==0 || !$canViewLink)
            <div class="survey-form-closed">
                Survey not started yet or expired.
            </div>
        @else
        
        @if($canViewLink)
        	
            @if($survey->set_time==1 and $survey->survey_time > 0)
            
                <div class="survey-timer-box">	
                    
                    <span class="total-survey-time-show">Time : {{sprintf("%02d", $survey->survey_time)}} mins</span>
                    
                    <span class="btn red-color-button start-survey-timer {{$loginRequired}}">Click to Start</span>
                
                	<input type="hidden" id="total-survey-time" value="{{$survey->survey_time}}" />
                    
                	<span class="survey-time-left">Time Left 
                    	<span class="show-survey-time-left"></span>
                    </span>    
                </div>
            @endif
        
            <div class="row community-survey-input-box" style="@if($survey->set_time==1 and $survey->survey_time > 0) display:none @endif">
                <div class="col-sm-12 community-survey">
                   
                    @if(count($questions)>0)
                        <form class="dynamic-survey-form autocomplete-address-form" id="community-dynamic-survey-frm" action="" method="post" enctype="multipart/form-data">
                            {{ csrf_field() }}
                            <input type="hidden" id="comurl" value="{{$community->present()->urlWithId()}}" />
                            <?php $qid=1;?>
                                
                              @foreach($questions as $question)
                                    {!! Theme::section('community.survey.survey-questions',['qid'=>$qid,'question'=>$question,'survey'=>$survey,'community'=>$community,'loginRequired'=>$loginRequired]) !!}
                               
                               <?php $qid++; ?> 
                                 
                              @endforeach 
                              
                              @if($survey->show_declaration==1 and $survey->box_texts!="")
                                  <div class="form-group">
                                        {!! $survey->box_texts !!}
                                  </div>	
                              @endif
							  
							  @if($survey->activate_captcha==1)
								<div style="padding: 5px;">	
									<div class="form-group">
										<label>Enter the security characters below</label>
										<input class="form-control captcha_code" id="captcha_code" required="required" type="text" name="captcha_code" value="" placeholder="Enter captcha from below" autocomplete="off"/>
									</div>	
								
									<div class="form-group">
										<div class="col-md-12">
											 <img src="{{URL::to('/')}}/captcha.php?rand=<?php echo rand(); ?>" class="captcha-image">
										</div>
									</div>
								</div>	
						      @endif
                              
                              
                              <div class="form-group" style="text-align:center; margin-top:60px;">
                                <input type="submit" class="btn red-color-button cm-survey-submit-btn {{$loginRequired}} survey-check-duplicate-emails" value="@if($survey->btn_texts!=""){{$survey->btn_texts}}@else Submit @endif"/>
                              </div>	
                         </form>
                    @endif	
                </div>
            </div>
        @endif
      @endif
</div>



    
@if(!Auth::check())
	{!! Theme::section('home.ask-participate-login',['community_url'=>$community->present()->url('login'),'signup_url'=>$community->present()->url('signup')]) !!}
@endif    
