@extends('layouts.app')

@section('title')

Advance Search

@parent

@stop

{{-- page level styles --}}

@section('header_styles')

<!--page level css -->

<link href="{{ asset('assets/vendors/select2/css/select2.min.css') }}" type="text/css" rel="stylesheet">

<link href="{{ asset('assets/vendors/select2/css/select2-bootstrap.css') }}" rel="stylesheet">

<!--end of page level css-->

@stop

{{-- Page content --}}

@section('content')

<!----Banner Section Starts----> 

<section class="pt-4" id="listing-search">

                <div class="container">

                    <div class="row">

                        <div class="col-md-12 text-white">

                            <h1 class="h3">

                                Search

                            </h1>

                            <hr>                            

                        </div>

                    </div>

                    <div class="row">

                        <div class="col-12">

                            <div class="card bigbox-hvr-slow">

                                <div class="card-body">

                                    <form action="{{ route('advancesearch') }}" enctype="multipart/form-data" method="post">

                                      <input type="hidden"  name="_token" value="{{ csrf_token() }}">

                                    <h5 class="card-title text-dark text-center">

                                        Find Journals, Volumes, Issues, Articles, Ebooks and Chapters

                                    </h5>

                                    <div class="row">

                                        <div class="col-md-8 offset-md-2" >

                                            <div class="input-group input-group-lg pull-right" >        

                        <input id="normal_search_bar" class="form-control" name="searchvalue" autocomplete="off" autocorrect="off" id="exampleFormControlInput1" placeholder="Search here..." type="text">

                        <div class="input-group-prepend">

                          <button id="normal_search_btn" class="btn btn-info" value="basic_search" name="btnjournalsearch" type="submit">Search</button>

                          <a id="adv_search" class="btn btn-link text-dark " >Advance Filters</a>

                        </div> 

                                            </div> 

                                            <br>

                                            <div class="d-none" id="collapse_advfilter">

                                              <div class="card card-body">

                                              <div class="form-group row">

                                                <div class="col-md-4">

                                                    <select id="fields-search" name="fields" class="form-control">

                                                     <option title="all fields" value="0">All fields</option>

                                                     <option title="title" value="title">title</option>

                                                     <option title="titleabstractkeywords" value="titleabstractkeywords">abstract, title, keywords</option>

                                                     <option title="authors" value="authors">Authors</option>

                                                     <option title="affiliation" value="affiliation">Affiliation</option>

                                                     <option title="issn" value="issn">ISSN</option>

                                                     <option title="isbn" value="isbn">ISBN</option>

                                                     <option title="text" value="text">Full text</option>

                                                    </select>

                                                </div><label class="col-sm-2 form-label lead">Include</label>

                                                <div class="col-md-3 pt-1">

                                                  <div class="custom-control custom-switch">

                                                    <input checked="checked" name="isjournal" value="1" type="checkbox" class="custom-control-input" id="isjournal">

                                                    <label class="custom-control-label" for="isjournal">All Journals</label>

                                                  </div>

                                                </div>

                                                <div class="col-md-3 pt-1">

                                                  <div class="custom-control custom-switch">

                                                    <input checked="checked" name="isebook" type="checkbox" value="1" class="custom-control-input" id="isebook">

                                                    <label class="custom-control-label" for="isebook">All e-Books</label>

                                                  </div>

                                                </div>

                                              </div>

                                              <div class="form-group row">

                                                <div class="col-md-4">

                                                <label class="control-label" for="subjects">Subjects:</label>

                                               <select name="subject[]" id="sub" multiple="multiple" class="form-control select2" id="subjects" size="5">                                                 

                                                     @foreach($subject_list as $subject)

                                                     <option value='{{$subject->title}}'>{{$subject->title}}</option>

                                                      @endforeach                                                               

                                                 </select>

                                               </div>

                                               <div class="col-md-4">

                                                 <label class="control-label" for="journals">Journals:</label>

                                                 <select name="journal[]" id="sub" multiple="multiple" class="form-control select2" id="journals" size="5"> 

                                                     @foreach($journal_list as $journal)

                                                     <option value='{{$journal->subtitle}}'>{{$journal->title}}</option>

                                                      @endforeach                                                               

                                                 </select>

                                                 </div>

                                               <div class="col-md-4">

                                                 <label class="control-label" for="ebook_id">Ebook:</label>

                                                 <select name="ebook[]" id="sub" multiple="multiple" class="form-control select2" id="ebook" size="5"> 

                                                     @foreach($ebook_list as $ebook)

                                                     <option value='{{$ebook->title}}'>{{$ebook->title}}</option>

                                                      @endforeach                                                               

                                                 </select>

                                                 </div>

                                                 </div>

                                                 <div class="form-group row">

                                                  <div class="col-md-12 lead">

                                                    Date Range

                                                  </div>

                                                  <div class="col-md-3">

                                                  <div class="custom-control custom-radio">

                                                    <input type="radio" id="customRadio1" name="daterange" class="custom-control-input"  value="all" checked onclick="EnableDisableDateRangeDDl(this);">

                                                    <label class="custom-control-label" for="customRadio1">All Years</label>

                                                  </div>

                                                  </div>

                                                   <div class="col-md-3">

                                                  <div class="custom-control custom-radio">

                                                    <input type="radio" id="customRadio2"  value="custom" name="daterange" class="custom-control-input" onclick="EnableDisableDateRangeDDl(this);">

                                                    <label class="custom-control-label" for="customRadio2">Custom</label>

                                                  </div>

                                                  </div>

                                                    <div class="col-md-3">

                                                    <select name="fromyear" disabled="disabled" class="form-control" id="edit-fromyear">

                                                         <?php

                                                          $from = 2000;

                                                          $to = date("Y");

                                                          $arr = array();

                                                          

                                                          for($i=$from; $i<=$to; $i++)

                                                          {

                                                            $arr[$i] = $i;

                                                              echo "<option value='".$arr[$i]."'>".$arr[$i]."</option>";

                                                          }

                                                        ?>

                                                        </select>

                                                        </div>

                                                      <div class="col-md-3">

                                                    <select name="toyear" disabled="disabled" class="form-control" id="edit-toyear">

                                                         <?php

                                                          $from = 2000;

                                                          $to = date("Y");

                                                          $arr = array();

                                                          

                                                          for($i=$from; $i<=$to; $i++)

                                                          {

                                                            $arr[$i] = $i;

                                                              echo "<option value='".$arr[$i]."'>".$arr[$i]."</option>";

                                                          }

                                                        ?>

                                                        </select>

                                                        </div>      

                                                  </div>  

                                                  <button class="btn btn-info col-md-4 m-auto" value="advance_search" name="btnjournalsearch" type="submit">

                                                            Search

                                                        </button>

                                                </div>

                                              </div>

                                            </div>

                                            

                                        </div>

                                    

                                    </form>

                                    </div>

                                </div>

                            </div>

                        </div>

                    </div>

                </div>

            </section>

<!----Banner Section Ends----> 



<!----Main Section Starts (where all content bodies exist)----> 

<main id="advancesearch">

  

  <section>

    <div class="container">

      <div class="row">

        <div class="col-md-8 listing">  

          <h2 class="h4">Search Result @if($searchvalue)<span class="text-primary">"{{$searchvalue}}"</span>@endif</h2>

         @if($found>0)

        <hr>

        @for($i = 0; $i < $size; $i++)

        <?php 

        $author='';

        $first_page='';

        $last_page='';

        $title ='';

        if(isset($print->hits->hit[$i]->fields->title)){

          $title = $print->hits->hit[$i]->fields->title; 

        }

        if(isset($print->hits->hit[$i]->fields->first_page)){

          $first_page = $print->hits->hit[$i]->fields->first_page;

          $last_page  = $print->hits->hit[$i]->fields->last_page;

        }

        if(isset($print->hits->hit[$i]->fields->author)){

          $author     = $print->hits->hit[$i]->fields->author ? $print->hits->hit[$i]->fields->author : array(0);        

          $author     = implode(',',$author); 

        }

        $doi        = $print->hits->hit[$i]->fields->doi;

        $art_obj = \App\Models\Article::GetArticleByDOI($doi);
        $nid        = $print->hits->hit[$i]->fields->nid;
        if(empty($art_obj)){
          $article_id        = $print->hits->hit[$i]->fields->id;
        }else{
          $article_id        = $art_obj->article_id;
        }

        $genre        = $print->hits->hit[$i]->fields->genre;

        $journal_ebook_title = $print->hits->hit[$i]->fields->journal_ebook_title;

        $volume_title = $print->hits->hit[$i]->fields->volume_title;

        $issue_title = $print->hits->hit[$i]->fields->issue_title;

        $volumeyear = $print->hits->hit[$i]->fields->volumeyear;
        $facets = $print->facets;        
		//$title = str_replace('/','',$title);
        //$title = preg_replace("/\p{L}*?".preg_quote($searchvalue)."\p{L}*/ui", "<strong><i>$0</i></strong>", $title);
		$title = preg_replace("/".preg_quote($searchvalue,"/")."/ui", "<strong style='background-color:yellow'><i>$0</i></strong>", $title);
        if($genre=='article'){
       
          $article = \App\Models\Article::where(['article_id' => $article_id])->first();
          
          if($article)
          {

        
          $data = app('App\Http\Controllers\SearchController')->GetSearchArticleAccess($article_id);

         $param=encrypt(array('readpdf',$data['article']->article_id,config('constants.admin.token'), $data['content_download_type']));
       
          ?>

           <div class="card bigbox-hvr-slow">

            <div class="card-body">
              <span class="badge badge-pill badge-info mb-2">{{$data['article']->type_name}}</span> 
                  <span class="badge badge-pill badge-danger float-right">{{$data['access_base_text']}}</span>

              <h4 class="card-title"><a href ="{{url('article')}}/{{$article_id}}">{!!$title!!}</a></h4>

              <p class="details"><strong>Journal:</strong> {!!$journal_ebook_title!!}<br>

              <strong>Volume:</strong> {{$volume_title}} <strong>Issue:</strong> {{$issue_title}} <strong>Year:</strong> {{$volumeyear}} <strong>Page:</strong> {{$first_page}}-{{$last_page}}<br>

              <strong>Author(s):</strong> {{$author}} <!--br>

              <strong>Doi:</strong> <a href="http://dx.doi.org/{{$doi}}">{{$doi}}</a-->

            </p>
             </div>
            <div class="card-footer text-muted p-0">

          @if(isset($data['DownloadAccess']) && $data['DownloadAccess'] > 0)        
          
            @if($data['DownloadAccess']) {{-- Trail Access Show Popup --}}
            
                        @php $checklicense = '';//'javascript:return CheckLicense(this.id)'; @endphp
                
            @else {{-- Single/Multiple Token Access Show Login Popup --}}
            
                        @php
                            $checklicense ='';
                  $D_key = false;
                  
                  if (isset($data['type']) && ($data['type'] == 444 || $data['type'] == 555))
                  {
                    $D_key = true;
                    
                  }
                  
                    if($data['access_base_text']==="Token Based Access" && $D_key == true){
                      $checklicense ="javascript:return LoginToDownload('download_hide_".$data['article']->article_id."')";
                    }      
                  @endphp
                
            @endif 
          
           {{ Form::open(array('class' =>'mb-0','method' => 'POST','route' => 'download_article','id' => 'download-form-'.$data['article']->article_id)) }}     
            <input type="hidden" value="{{csrf_token()}}" name="_token">
              <input type="hidden" name="agree-flag" id="agree-flag" value="1">
                  <input type="hidden" name="param" value="{{Crypt::encrypt($data['article']->article_id.'||'.'pdf'.'||'.$data['content_download_type'].'||'.$data['restricted_user_access_key'].'||'.$data['user_access_id'] )}}">

          <!-- if User Access Info View Option is zero than allow to download-->
                @if($data['view_option']==0)   
              <button type="submit" id="{{$data['article']->article_id}}" name="download{{$data['article']->article_id}}" class="card-link btn btn-outline-primary border-0 py-2 px-4" onclick="{{$checklicense}}" >Download PDF File</button> 
                @elseif($val->view_option==1)   
              <a type="button" id="readpdf_{{$data['article']->article_id}}" name="download{{$data['article']->article_id}}" class="card-link btn btn-outline-primary border-0 py-2 px-4" href="{{route('article', ['article_id' => $data['article']->article_id,'param' => $param])}}" onclick="{{$checklicense}}" >Read Article</a> 
            @endif  
           {{ Form::close() }}

          <!-- Model Window Start -->
          {{ Form::open(array('method' => 'POST','route' => 'download_article','id' => 'download-form-pdf')) }}
            <input type="hidden" name="agree-flag" id="agree-flag" value="1">
            <input type="hidden" name="param" value="{{Crypt::encrypt($data['article']->article_id.'||'.'pdf'.'||'.$data['content_download_type'].'||'.$data['restricted_user_access_key'].'||'.$data['user_access_id'] )}}">  
            <div class="modal fade" id="download_hide_{{$data['article']->article_id}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
              <div class="modal-dialog">
                <div class="modal-content">
                  <div class='modal-header bg-primary'>
                    <h4 class="modal-title text-white" id="modalLabelprimary">Restricted Access Panel</h4>
                    <button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>
                  </div>
                  <div class='modal-body'>
                    <label class="control-label">Content Access Key</label>
                    <input type="text" name="user_name" class="form-control" >
                    <label class="control-label">Password</label>
                    <input type="password" name="password" class="form-control">
                  </div> <!-- /.modal-body -->   
                  <div class="modal-footer">
                     <button type="submit" class="btn btn-primary" onclick="javascript: $('#download_hide_{{$data['article']->article_id}}').modal('hide');" ><span class="glyphicon glyphicon-remove-circle"></span> Login to Download</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove-circle"></span> Close</button>
                  
                  </div> 
                </div>
              </div> 
            </div>
          {{ Form::close() }}
          <!-- Model Window End -->
          
          @else
            @if(empty($data['bundle_content']) || $data['bundle_content']->article==0)
              <!--button href="#" class="card-link text-dark">Add to Wish List</button-->
              @if($data['checkIfMarked'])          
              @endif 
            @else
             {{ Form::open(array('class' =>'mb-0','method' => 'POST','route' => 'download_bundle_file','id' => 'download-form-'.$data['article']->article_id)) }}     
              <input type="hidden" value="{{csrf_token()}}" name="_token">
                <input type="hidden" name="agree-flag" id="agree-flag" value="1">
                  <input type="hidden" name="bundle_offer_order_id" id="bundle_offer_order_id" value="{{$data['bundle_content']->bundle_offer_order_id}}"> 
                    <input type="hidden" name="param" value="{{Crypt::encrypt($data['article']->article_id.'||'.'pdf'.'||'.$data['bundle_content']->content_download_type.'||'.$data['restricted_user_access_key'].'||'.$data['user_access_id'] )}}">
              <button type="submit" id="{{$data['article']->article_id}}" name="download{{$data['article']->article_id}}" class="card-link text-dark" >Download PDF File</button>  
             {{ Form::close() }}
              @endif        

          @endif
           



            </div>

            <!-- --------------Trial Trial Terms Condition------------------------- -->
              @if (isset($val->type) && $val->type == 111)
                        <a id="license{{$data['article']->article_id}}" href="{{route('termstrial', ['access_type' => $data['type'],'content_id' => $data['article']->article_id,'param' => $param])}}"  ></a>
              @else
                        <a id="license{{$data['article']->article_id}}" href="{{route('terms', ['content_id' => $data['article']->article_id,'param' => $param])}}"  ></a>
              @endif  


                  
              <div style="text-align:left;" class="modal fade" id="TnCModal" tabindex="-1" role="dialog" aria-labelledby="TnCModalLabel" aria-hidden="true">
                <div class="modal-dialog modal-lg">
                  <div class="modal-content">
                  </div> <!-- /.modal-content -->
                </div> <!-- /.modal-dialog -->
              </div>

              <input type="hidden" name="license_downloadid" id="license_downloadid" value="0">

          </div>

      <?php }
        } if($genre=='chapter'){

          $chapter_id = $article_id;

            $cdata = app('App\Http\Controllers\SearchController')->GetSearchChapterAccess($chapter_id);
			if($cdata){
            $DownloadAccess = $cdata['DownloadAccess'];
            $terms_popup = $cdata['terms_popup'];
            $chapter_details = $cdata['chapter_details'];
            $view_option = $cdata['view_option'];
            $access_base_text = $cdata['access_base_text'];
            $checkLoginFlag=false;
            $content_download_type = $cdata['content_download_type'];
             
        ?>

         <div class="card bigbox-hvr-slow">

          <div class="card-body">
            <span class="badge badge-pill badge-danger float-right">{{$access_base_text}}</span>
            <h4 class="card-title"><a href ="{{url('chapter')}}/{{$chapter_id}}">{!!$title!!}</a></h4>

            <p class="details"><strong>Ebook:</strong> {!!$journal_ebook_title!!}<br></p>

            <strong>Volume:</strong> {{$volume_title}}  <strong>Year:</strong> {{$volumeyear}} <br>

            <strong>Author(s):</strong> {{$author}} <br>

            <strong>Doi:</strong> <a href="http://dx.doi.org/{{$doi}}">{{$doi}}</a>
           </div>
            <div class="card-footer text-muted p-0">  
            @if((isset($DownloadAccess) && $DownloadAccess > 0))
            
              @if($terms_popup)
                  @php
                    $checklicense = 'javascript:return CheckLicense(this.id)';
                  @endphp
                @else
                  @php
                  $checklicense ='';                  
                    @endphp
                @endif
         @endif   
         @if((isset($DownloadAccess) && $DownloadAccess > 0) && $view_option==0)
              {{ Form::open(array('class' =>'mb-0','method' => 'POST','route' => 'ebook_download_chapter','id' => 'download-form-pdf')) }}
               <input type="hidden" name="agree-flag" id="agree-flag" value="1">
                      <input type="hidden" name="param" value="{{Crypt::encrypt($chapter_details->chapter_id.'||'.'pdf'.'||'.$content_download_type.'||'.$chapter_details->restricted_user_access_key.'||'.$chapter_details->user_access_id)}}">
              @if($view_option==0)   
              <button type="submit" id="{{$chapter_details->chapter_id}}" name="download{{$chapter_details->chapter_id}}" class="card-link btn btn-outline-primary border-0 py-2 px-4" onclick="{{$checklicense}}" >Download Chapter </button> 
                @elseif($view_option==1)   
              <a type="button" id="readpdf_{{$chapter_details->chapter_id}}" name="download{{$chapter_details->chapter_id}}" class="card-link btn btn-outline-primary border-0 py-2 px-4" href="{{route('article', ['article_id' => $data['article']->article_id,'param' => $param])}}" onclick="{{$checklicense}}" >Read Chapter</a> 
            @endif  
            {{ Form::close() }}
            
            @elseif((isset($DownloadAccess) && $DownloadAccess > 0) && ($content_download_type != 'F' && $content_download_type != 'FO') && $view_option==1)
                  @php 
                    $cparam=encrypt(array('readchapterpdf',$chapter_details->chapter_id,config('constants.admin.token'),$content_download_type));
                    @endphp
                    
            
                <a class="card-link btn btn-outline-primary border-0 py-2 px-4" id="readpdf_{{$chapter_details->chapter_id}}" href="{{route('chapter', ['id' => $chapter_details->chapter_id,'param' => $cparam])}}" role="button" id="dropdownMenuLink" aria-haspopup="true" aria-expanded="false" onclick="{{$checklicense}}">
                  Read Chapter                         
                </a>
                           
              
            @endif
          
          

          

         

          </div>

        </div>

			<?php }
			} if($genre=='ebookvolume'){

        $ebook_volume_id = $article_id;

        $edata = app('App\Http\Controllers\SearchController')->GetSearchEbookVolumeAccess($ebook_volume_id);
		if($edata){
        $VolumeDownloadAccess = $edata['VolumeDownloadAccess'];
        $terms_popup = $edata['terms_popup'];
        $ebook_volume_details = $edata['ebook_volume_details'];
        $view_option = $edata['view_option'];
        $access_base_text = $edata['access_base_text'];
        $restricted_user_access_key = $edata['restricted_user_access_key'];        
        $user_access_id = $edata['user_access_id'];        
        $checkLoginFlag=false;
        $content_download_type = $edata['content_download_type'];
        ?>

         <div class="card bigbox-hvr-slow">

          <div class="card-body">
            <span class="badge badge-pill badge-danger float-right">{{$access_base_text}}</span>
            <h4 class="card-title"><a href ="{{url('ebook_volume')}}/{{$ebook_volume_id}}">{!!$title!!}</a></h4>

            <p class="details"><strong>Ebook:</strong> {!!$journal_ebook_title!!}<br></p>

            <strong>Volume:</strong> {{$volume_title}}  <strong>Year:</strong> {{$volumeyear}} <br>

            <strong>Author(s):</strong> {{$author}} <br>

            <strong>Doi:</strong> <a href="http://dx.doi.org/{{$doi}}">{{$doi}}</a>
           </div>
            <div class="card-footer text-muted p-0">    
             @if((isset($VolumeDownloadAccess) && $VolumeDownloadAccess > 0))
            
              @if($terms_popup)
                  @php
                    $checklicense = 'javascript:return CheckLicense(this.id)';
                  @endphp
                @else
                  @php
                  $checklicense ='';                  
                    @endphp
                @endif
         @endif   
         
          @if((isset($VolumeDownloadAccess) && $VolumeDownloadAccess > 0) && $view_option==0)              
              {{ Form::open(array('class' =>'mb-0','method' => 'POST','route' => 'download_volume_file','id' => 'download-form-pdf')) }}
               <input type="hidden" name="agree-flag" id="agree-flag" value="1">
                      <input type="hidden" name="param" value="{{Crypt::encrypt($ebook_volume_details->ebook_volume_id.'||'.'pdf'.'||'.$content_download_type.'||'.$restricted_user_access_key.'||'.$user_access_id)}}">
              
              <button type="submit" id="{{$ebook_volume_details->ebook_volume_id}}" name="download{{$ebook_volume_details->ebook_volume_id}}" class="card-link btn btn-outline-primary border-0 py-2 px-4" onclick="{{$checklicense}}" >Download Book </button>                
            @endif  
            {{ Form::close() }}            

          

                  

          </div>

        </div>

      <?php } 
		}?>



        @endfor



        @include('pagination')

        @endif



        </div>

        <div class="col-md-4">
          <div class="card bg-spring-green bigbox-hvr-slow">

              <div class="card-header">
                <h2>Filter Result</h2>
              </div>
              
                @if(isset($facets))
                  <h5><a href="javascript: history.back();" class="btn-link"><i class="fa fa-arrow-left"></i></a>  Volume Year</h5>
                  <ul class="list-group list-group-flush">
                  @foreach($facets->volumeyear->buckets as $vyear)
                    @php 
                      parse_str($pagename, $pagenameVars);                    
                      unset($pagenameVars['/search?xe']);                    
                      $pagenameVars['fromyear']=$vyear->value;
                      $pagenameVars['toyear']=$vyear->value;
                      $pagename = http_build_query($pagenameVars,'&amp;','&');
                    @endphp
                    <li class="list-group-item"><a href="/search?xe=1&{{$pagename}}" class='btn-link'>{{$vyear->value}}</a> ({{$vyear->count}})</li>
                  @endforeach
              </ul>   
              @endif
              

          </div>
          

          <div class="card bg-spring-green bigbox-hvr-slow">

              <div class="card-header">

              </div>
              
              <div class="card-body p-5">

                  <span class="p-5 m-5">Ads</span>   

              </div>

          </div>

        </div>

      </div>

    </div>

  </section>

  

</main>



<!----Main Section Starts----> 

@endsection

{{-- page level scripts --}}

@section('footer_scripts')

<script src="{!! asset('assets/vendors/select2/js/select2.js') !!}"></script>    

<script>

$(".select2").select2({

            theme:"bootstrap",

            placeholder:"Select",

            width: '100%'



        });         



$("#adv_search").click(function() 

{  

  //var disabled = $("#normal_search_btn").is(":disabled");

  if ($('#normal_search_btn').is(':disabled') == true) { 

    $("#normal_search_btn").removeAttr("disabled");  

  }else{

    $("#normal_search_btn").attr("disabled", true);

  }



  $("#collapse_advfilter").toggleClass('d-none');

  

});    

    

</script>

<script>

function EnableDisableDateRangeDDl(obj){  

  

  if(obj.value == "all"){

    document.getElementById("edit-fromyear").disabled = 'disabled';

    document.getElementById("edit-toyear").disabled = 'disabled';

  }

  else{

    document.getElementById("edit-fromyear").disabled = '';

    document.getElementById("edit-toyear").disabled = '';

    

  }


}

function CheckLicense(id) {
  $('#license_downloadid').val(id);

  var array = id.split('_');
  var file_type = '';
  if(array[0] != "readpdf")
  {
    id=id;
  }
  else
  {
    id=array[1];
    file_type="readpdf";
  }
  if($("#agree-flag").val() == "" || $("#agree-flag").val() != "Y"){
    
    var target = $("#license"+id).attr("href");
    $("#TnCModal .modal-content").load(target+'/article/'+file_type, function() {                      
      $("#TnCModal").modal("show"); 
    });                     
      return false;
    }
  
} 

function LoginToDownload(id) {  
                            
   $("#"+id).modal("show"); 
   return false;
}   


</script>

@stop



