<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__)
    .' is not allowed.' );
/**
 *
 * @package  MediaLibrary
 * @copyright 2021 Andrey Kvasnevskiy-OrdaSoft(akbet@mail.ru); Rob de Cleen(rob@decleen.com);
 * Homepage: https://ordasoft.com
 * @version: 4.6 Free
 * @license GNU General Public license version 2 or later; see LICENSE.txt
 *
 */
$doc = JFactory::getDocument();
$doc->addStyleSheet(JURI::root(true) . '/components/com_medialibrary/includes/jQuerMedia-ui.css');
$max_price = $params->get('max_price');
$min_price = $params->get('min_price');
?>

<?php positions_ml($params->get('allcategories01'));?>
<?php positions_ml($params->get('allcategories02'));?>
<?php positions_ml($params->get('allcategories03'));?>
<?php  if($params->get('show_search')){ ?>    
    <?php
    if($params->get('search_fieldshow') || 1){?>
        <script type="text/javascript">
            jQuerMedia(function() {
                jQuerMedia(".form_search #ml_slider").slider({
                    min: <?php echo $min_price;?>,
                    max: <?php echo $max_price;?>,
                    values: [<?php echo $min_price;?>,<?php echo $max_price;?>],
                    range: true,
                    stop: function(event, ui) {
                        jQuerMedia(".form_search input#pricefrom").val(jQuerMedia(
                            ".form_search #ml_slider").slider("values",0));
                        jQuerMedia(".form_search input#priceto").val(jQuerMedia(
                            ".form_search #ml_slider").slider("values",1));
                    },
                    slide: function(event, ui){
                        jQuerMedia(".form_search input#pricefrom").val(jQuerMedia(
                            ".form_search #ml_slider").slider("values",0));
                        jQuerMedia(".form_search input#priceto").val(jQuerMedia(
                            ".form_search #ml_slider").slider("values",1));
                    }
                });

                jQuerMedia(".form_search input#pricefrom").change(function(){
                    var value1=jQuerMedia(".form_search input#pricefrom").val();
                    var value2=jQuerMedia(".form_search input#priceto").val();

                    if(parseInt(value1) > parseInt(value2)){
                        value1 = value2;
                        jQuerMedia(".form_search input#pricefrom").val(value1);
                    }
                    jQuerMedia(".form_search #ml_slider").slider("values",0,value1);
                });

                jQuerMedia(".form_search input#priceto").change(function(){
                    var value1=jQuerMedia(".form_search input#pricefrom").val();
                    var value2=jQuerMedia(".form_search input#priceto").val();

                    if(parseInt(value1) > parseInt(value2)){
                        value2 = value1;
                        jQuerMedia(".form_search input#priceto").val(value2);
                    }
                    if(value2 > <?php echo $max_price;?>){
                        jQuerMedia(".form_search input#priceto").val(<?php echo $max_price;?>)
                    }
                    jQuerMedia(".form_search #ml_slider").slider("values",1,value2);
                });
            });
        </script>
        
        <noscript>
            Javascript is required to use MediaLibrary 
            <a href="https://ordasoft.com/media-library-joomla-extension">
                Media Library - Manager Software for create library manager website .
            </a>,
            <a href="https://ordasoft.com/media-library-joomla-extension">
                MediaLibrary this is media portal software for create media website for rent, sell medias
            </a>
        </noscript>

        <div id="medialibrary">
        <div class="componentheading<?php echo $params->get('pageclass_sfx'); ?>">
                        <?php echo $currentcat->header; ?>
        </div>

        <form  action="<?php echo sefRelToAbs("index.php?option=com_medialibrary" ); ?>"
            method="get" name="mediaEditForm">
            <div class="form_search">
                <div class="ml-row">
                    <div class="ml-collumn-xs-12 ml-collumn-sm-6 ml-collumn-md-5 ml-collumn-lg-5">
                        <div class="keyword_container">
                            <div class="row_bck">
                                <div class="search_title">
                                        <?php echo _MEDIALIBRARY_LABEL_SEARCH_KEYWORD ; ?>
                                </div>
                                        <input class="inputbox" type="text" name="searchtext" size="20" maxlength="20"/>
                                        <input type="hidden" name="option" value="com_medialibrary"/>
                                        <input type="hidden" name="task" value="search"/>
                                        <input type="hidden" name="type_desired" value="video"/>
                                        <input type="hidden" name="Itemid" value="<?php echo $Itemid;?>"/>

                            </div>

                            <div class="ck_r ck_ext">
                                <input id="ck_ext" type="checkbox" name="exactly" />
                                <label for="ck_ext" class="search_title">
                                    <?php echo _MEDIALIBRARY_SHOW_SEARCH_EXACTLY; ?>
                                </label>
                            </div>
                        </div>

                        <div class="chekbox_container">
                            <div>
                                <label for="<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_BOOK; ?>"><?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_BOOK; ?>
                                </label>  

                                <input type="checkbox" 
                                name="book" 
                                id="<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_BOOK; ?>" checked="checked" onclick="if(this.checked) {ml_checkboxs_on('checkboks<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_BOOK; ?>');} else {ml_checkboxs_off('checkboks<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_BOOK; ?>');}">
                            </div>

                            <div>
                                <label for="<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_GAME; ?>"><?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_GAME; ?>
                                </label>  

                                <input type="checkbox" 
                                name="game" 
                                id="<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_GAME; ?>" checked="checked" onclick="if(this.checked) {ml_checkboxs_on('checkboks<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_GAME; ?>');} else {ml_checkboxs_off('checkboks<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_GAME; ?>');}">
                            </div>
                            
                            <div>
                                <label for="<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_MUSIC; ?>"><?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_MUSIC; ?>
                                </label>  

                                <input type="checkbox" 
                                name="music" 
                                id="<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_MUSIC; ?>" checked="checked" onclick="if(this.checked) {ml_checkboxs_on('checkboks<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_MUSIC; ?>');} else {ml_checkboxs_off('checkboks<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_MUSIC; ?>');}">
                            </div>

                            <div>
                                <label for="<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_VIDEO; ?>"><?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_VIDEO; ?>
                                </label>  

                                <input type="checkbox" 
                                name="video" 
                                id="<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_VIDEO; ?>" checked="checked" onclick="if(this.checked) {ml_checkboxs_on('checkboks<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_VIDEO; ?>');} else {ml_checkboxs_off('checkboks<?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_VIDEO; ?>');}">
                            </div>
                        </div>
                    </div>

                    <div class="ml-collumn-xs-12 ml-collumn-sm-6 ml-collumn-md-6 ml-collumn-lg-6">

                        <div class="price_slider_container">
                            <div class="search_title">
                            <?php echo _MEDIALIBRARY_LABEL_PRICE; ?>
                            </div>

                            <div id="ml_slider" class="ui-slider ui-slider-horizontal ui-widget ui-widget-content
                            ui-corner-all">
                            </div>
                        </div>

                        <div class="ml-row">
                            <div class="pricefrom_2 ml-collumn-xs-12 ml-collumn-sm-6 ml-collumn-md-6 ml-collumn-lg-6">
                                <div class="search_title">
                                <?php echo _MEDIALIBRARY_LABEL_AVAILABLE_FOR_LEND_FROM; ?>
                                </div>
                                <input type="text" class="inputbox" id="pricefrom" name="pricefrom" 
                                       value="<?php echo $min_price;?>"/>
                            </div>
                            <div class="priceto_2 ml-collumn-xs-12 ml-collumn-sm-6 ml-collumn-md-6 ml-collumn-lg-6">
                                <div class="search_title">
                                <?php echo _MEDIALIBRARY_SHOW_SEARCH_PRICE_TO; ?>
                                </div>
                                <input type="text" class="inputbox" id="priceto" name="priceto" 
                                       value="<?php echo $max_price;?>"/>
                            </div>
                        </div>


                    </div>

                </div>

                <div class="ck_btr">
                        <input type="submit" name="submit" value="<?php
                                echo _MEDIALIBRARY_LABEL_SEARCH_BUTTON; ?>" class="button" />
                </div>
                
            </div>
        </form>

    <?php }?>
        <?php 
        }
        positions_ml($params->get('allcategories07'));
    if ($params->get('show_add_media')){
        HTML_medialibrary::showAddButton($params, 1, $catid, $Itemid);
    }
    positions_ml($params->get('allcategories08'));
if ($params->get('ownerslist_show')){
    HTML_medialibrary::showOwnersButton();
}


positions_ml($params->get('allcategories09'));
?>

<?php if ($params->get('back_button')!= '') {?>
                <div style="text-align: center;" class="back_button">
                    <?php mosHTML::BackButton ( $params, $hide_js ); ?>
                </div>
<?php } ?>
</div>
<?php?>
