<style type="text/css">
  .ui-widget-content {
    background: none !important;
    border: none !important;
  }  
  .ui-widget-header {
    border: none !important;
    background: none !important;
  }
  .ui-widget {
    font-family: inherit !important;
  }
  .ui-tabs .ui-tabs-panel {
    padding: 0px !important;
  }
  .ui-tooltip {
    background: #FFF;
    border-radius: 0;    
    border: 1px solid #D1D4D7 !important;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    color:  #656565;
    font-size: 11px;
  }
</style>

<script>
  $(document).ready(function() {
    
    $( '#slider-code' ).tinycarousel({
      pager: true
    });
    
    $( ".tabs a" ).click( function () 
    {
			$( ".tabs .active" ).removeClass( "active" );
			$( this ).addClass( "active" );
			$( ".tabs-content" ).addClass( 'nondisplay' );
			var content_show = $( this ).attr( "href" );
			$( '#' + content_show ).removeClass( 'nondisplay' );
		  return false;
		});
    
    <? if ( $this -> _rw == 'add' ):?>
      $( "#id_page_type" ).val( '2' );
    <? endif;?>
    changePageType();
  });

  function changePageType()
  {
    var type = $("#id_page_type").val();
    if ( type == 5 || type == 6 || type == 7 || type == 8 || type == 9 || type == 10 || type == 11 )
    {
      $( '#div_article_number, #div_sort_type' ).hide();
      if ( type == 8 ) 
      {
        $( '#div_show_title' ).hide();
        $( '#div_link' ).show();
      } 
      else 
      {
        $( '#div_link' ).hide();
        $( '#div_show_title' ).show();
      }
    }
    else
    {
      $( '#div_article_number, #div_sort_type' ).show();
      $( '#div_link' ).hide();
      $( '#div_show_title' ).show();
    }
  }
</script>

<div class="edit-row">
  <form method='POST' id='formularz' action='./'>
    <? if ( $this -> _rw == 'edit' ):?>
      <input type='hidden' name='rw' value='save' />
      <input type='hidden' name='id' value='<?= $this -> _page['id'];?>' />
    <? else:?>
      <input type='hidden' name='rw' value='add_new' />
      <input type='hidden' name='check' value='<?= time();?>' />
    <? endif;?>
    <input type='hidden' name='o' value='<?= $this -> _order;?>' />
    <input type='hidden' name='menu_id' value='<?= $this -> _menu_id;?>' />
    <div id="slider-code">
      <ul class="pager">
          <li><a rel="0" class="pagenum" href="#"><span class="badge">1</span>Ustawienia podstawowe</a></li>
          <li><a rel="1" class="pagenum" href="#"><span class="badge">2</span>Ustawienia zaawansowane</a></li>
      </ul>
      <a class="buttons prev tip" href="#" title="Wstecz">
        <img src="../../images/system/img-left.png" />
      </a>
      <div class="viewport">
        <ul class="overview">
          <li>
            <div class="slide-title">Ustawienia podstawowe</div>
            <div id="tabs" class="tabs-container">
              <ul class="tabs">
                <?
                if ( is_array( $this -> _language ) ) foreach ( $this -> _language as $lg )
                {
                  ?>
                  <li class="tab-li">
                    <a href="lang_<?=$lg['id'];?>" class="li-tabs <? if ( !$j++ ) echo 'active';?>"><?= $lg['name'];?></a>
                  </li>
                  <?
                }
                ?>
              </ul>
              <?
              if ( is_array( $this -> _language ) ) foreach ( $this -> _language as $lg )
              {
                ?>
                <div id="lang_<?= $lg['id'];?>" class="tabs-content <? if ( $i++ ) echo 'nondisplay';?>">
                  <div class="group">
                    <label>Tytuł:</label>
                    <div class="content">
                      <input type='text' name='title_<?= $lg['id'];?>' id='title_<?= $lg['id'];?>' value='<?= $this -> secureHTML( $lg['title'] );?>' />
                    </div>
                  </div>
                  <div class="group">
                    <label>Link SEO:</label>
                    <div class="content">
                      <input type='text' name='seo_link_<?= $lg['id'];?>' id='seo_link_<?= $lg['id'];?>' value='<?= $this -> secureHTML( $lg['seo_link'] );?>' />
                      <a href="#" onclick="xajax_generateSeoLink( '<?= $lg['id'];?>', $( '#title_<?= $lg['id'];?>' ).val() )">
                        <i class="icon refresh" style="position: relative; top: 3px; margin: 0;"></i>
                        generuj
                      </a>
                    </div>
                  </div>
                  <div class="group">
                    <label>Meta title:</label>
                    <div class="content">
                      <input type='text' name='meta_title_<?= $lg['id'];?>' id='title_<?= $lg['id'];?>' value='<?= $this -> secureHTML( $lg['meta_title'] );?>' />
                    </div>
                  </div>
                  <div class="group">
                    <label>Meta description:</label>
                    <div class="content">
                      <textarea name='meta_description_<?= $lg['id'];?>' cols='60' rows='5'><?= $this -> secureHTML( $lg['meta_description'] );?></textarea>
                    </div>
                    <div class="clearfix"></div>
                  </div>
                  <div class="group">
                    <label>Meta keywords:</label>
                    <div class="content">
                      <textarea name='meta_keywords_<?= $lg['id'];?>' cols='60' rows='5'><?= $this -> secureHTML( $lg['meta_keywords'] );?></textarea>
                    </div>
                    <div class="clearfix"></div>
                  </div>
                </div>
                <?
              }
              ?>
            </div>
          </li>
          <li>
            <div class="slide-title">Ustawienia zaawansowane</div>
            <div class="tabs-container">
              <div class="group">
                <label>Menu:</label>
                <div class="content">
                  <select name='menu_id' id='menu_id'>
                    <? if ( is_array( $this -> _menu ) ):?>
                      <? foreach ( $this -> _menu as $menu ):?>
                        <option value="<?= $menu['id'];?>" <? if ( $menu['id'] == $this -> _page['id_menu'] ):?>selected="selected"<? endif;?>><?= $menu['name'];?></option>
                      <? endforeach;?>
                    <? endif;?>
                  </select>
                </div>
              </div>
              <div class="group">
                <label>Strona nadrzędna:</label>
                <div class="content">
                  <select name='parent_id' id='parent_id'>
                    <option value="0">---- pozycja główna ----</option>
                    <?
                    echo \admin\view\Pages::drawSubpagesEdit( $this -> _pages, $this -> _parent_id, $this -> _step, $this -> _id );
                    ?>
                  </select>
                </div>
              </div>
              <div class="group">
                <label>Typ strony:</label>
                <div class="content">
                  <select name='page_type_id' id='id_page_type' onChange='changePageType()'>
                    <?
                      if ( is_array ( $this -> _page_types ) ) foreach ( $this -> _page_types as $page_type )
                      {
                        ?>
                        <option value='<?=$page_type['id'];?>' <? if ( $this -> _page['id_page_type'] == $page_type['id'] ) echo "selected='selected'"; ?>>
                          <?= $page_type['name'];?>
                        </option>
                        <?
                      }
                    ?>
                  </select>
                </div>
              </div>
              <div class="group" id="div_sort_type">
                <label>Kolejność wyświetlania:</label>
                <div class="content">
                  <select name='sort_type'>
                    <?
                      if ( is_array( $this -> _sort ) ) foreach ( $this -> _sort as $sort )
                      {
                        ?>
                        <option value='<?=$sort['id'];?>' <? if ( $this -> _page['id_sort_type'] == $sort['id'] ) echo "selected='selected'";?>>
                          <?= $sort['name'];?>
                        </option>
                        <?
                      }
                    ?>
                  </select>
                </div>
              </div>
              <div class="group">
                <label>Szablon</label>
                <div class="content">
                  <select name="layout_id">
                    <option value="">---- szablon domyślny ----</option>
                    <? if ( is_array( $this -> _layouts ) ): foreach ( $this -> _layouts as $layout ):?>
                      <option value="<?= $layout['id'];?>" <? if ( $this -> _layout_id == $layout['id'] ):?>selected="selected"<? endif;?>><?= $layout['name'];?></option>
                    <? endforeach; endif;?>
                  </select>
                </div>
              </div>
              <div class="group" id="div_article_number">
                <label>Liczba artykułów:</label>
                <div class="content">
                  <input type='text' name='article_number' value='<?= $this -> _page['article_number'] ? $tmp = $this -> _page['article_number'] : $tmp = '2';?>' />
                </div>
              </div>
              <div class="group" id="div_show_title">
                <label>Pokaż tytuł:</label>
                <div class="content">
                  <input type="radio" name='show_title' id="show_title_0" value="0" <? if ( !$this -> _page['show_title'] ) echo "checked='checked'";?> />
                  nie
                  <input type="radio" name="show_title" value="1" <? if ( $this -> _page['show_title'] || $this -> _rw == 'add' ) echo "checked='checked'";?> />
                  tak
                </div>
              </div>
              <div class="group">
                <label>Aktywna:</label>
                <div class="content">
                  <input type="radio" name="enabled" id="enabled_0" value="0" <? if ( !$this -> _page['enabled'] ) echo "checked='checked'";?> />
                  nie
                  <input type="radio" name="enabled" id="enabled_1" value='1' <? if ( $this -> _page['enabled'] || $this -> _rw == 'add' ) echo "checked='checked'";?> />
                  tak
                </div>
              </div>
              <div class="group">
                <label>Tylko dla zalogowanych:</label>
                <div class="content">
                  <input type="radio" name="only_for_logged" id="only_for_logged_0" value="0" <? if ( !$this -> _page['only_for_logged'] ) echo "checked='checked'";?> />
                  nie
                  <input type="radio" name="only_for_logged" id="only_for_logged_1" value='1' <? if ( $this -> _page['only_for_logged'] ) echo "checked='checked'";?> />
                  tak
                </div>
              </div>
              <div class="group">
                <label>Podłącz formularz kontaktowy:</label>
                <div class="content">
                  <input type="radio" name="contact_form" id="contact_form_0" value="0" <? if ( !$this -> _page['contact_form'] ) echo "checked='checked'";?> />
                  nie
                  <input type="radio" name="contact_form" id="contact_form_1" value='1' <? if ( $this -> _page['contact_form'] ) echo "checked='checked'";?> />
                  tak
                </div>
              </div>
              <div class="group" id="div_link" style="display: none;">
                <label>Link:</label>
                <div class="content">
                  <input type="text" name="link" value="<?= $this -> _page['link'];?>">
                </div>
              </div>
            </div>
          </li>
        </ul>
      </div>
      <a class="buttons next tip" href="#" title="Dalej">
        <img src="../../images/system/img-right.png" />
      </a>
    </div>
  </form>
</div>