<?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
 *
 */

if (!defined('DS')) define('DS', DIRECTORY_SEPARATOR);
//require_once ($mosConfig_absolute_path . "/libraries/joomla/factory.php");
require_once (JPATH_BASE . DS . 'includes' . DS . 'defines.php');
require_once (JPATH_BASE . DS . 'includes' . DS . 'framework.php');
require_once ($mosConfig_absolute_path 
        . "/administrator/components/com_medialibrary/admin.medialibrary.class.conf.php");
?>

<?php
// for J 1.6
$mainframe = JFactory::getApplication();
$templateDir = 'templates/' . $mainframe->getTemplate();
$GLOBALS['mainframe'] = $mainframe;
$GLOBALS['templateDir'] = $templateDir;
$mosConfig_live_site = JURI::root(true);
$GLOBALS['mosConfig_live_site'] = $mosConfig_live_site;
$doc = JFactory::getDocument();
$GLOBALS['doc'] = $doc;
// --
// ensure this file is being included by a parent file
$bid = mosGetParam($_POST, 'bid', array(0));
require_once ($mosConfig_absolute_path 
        . "/administrator/components/com_medialibrary/admin.medialibrary.class.ws.php");
require_once ($mosConfig_absolute_path 
        . "/administrator/components/com_medialibrary/admin.medialibrary.class.others.php");
class HTML_Categories {
    static function show($rows, $myid, &$pageNav, $type) {
        global $my, $mainframe, $mosConfig_live_site;
        global $templateDir;
        global $doc;
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $section = "com_medialibrary";
        $section_name = "MediaLibrary";
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_CATEGORIES_MANAGER . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;
?>
        <form id="adminForm" action="index.php" method="post" name="adminForm">
                        <div id="limit">
             <?php
     if (version_compare(JVERSION, "3.0.0", "gt")) {
              echo $pageNav->getLimitBox();
         }
                ?>
        </div>
       <table class="adminlist my_table my_table-bordered my_table-hover bl_admin_categories_main_table">
        <tr  class="cat-header">
            <th width="20"  style="text-align:center;">id</th>
            <th width="20"  style="text-align:center;">

         <?php
        if (version_compare(JVERSION, "3.0.0", "ge")) { ?>
            <input type="checkbox" name="toggle" value="" onClick="Joomla.checkAll( this);" />
         <?php
        } ?>
         <?php
        if (version_compare(JVERSION, "2.6.0", "lt")) { ?>
            <input type="checkbox" name="toggle" value="" onClick="checkAll(<?php echo count($rows) ?>);" />
         <?php
        } ?>
            </th>
            <th align = "center" class="title">
            <?php echo _MEDIALIBRARY_HEADER_MEDIALIBRARY_LABEL_CATEGORY; ?></th>
            <th align = "center" width="5%">
            <?php echo _MEDIALIBRARY_HEADER_NUMBER; ?></th>
            <th align = "center" width="10%">
            <?php echo _MEDIALIBRARY_HEADER_PUBLISHED; ?></th>

            <?php
        if ($section <> 'content') {
?>
                <th align = "center" colspan="2">
                <?php //echo _HEADER_REORDER;
?>
                </th>
                <?php
        }
?>

            <?php
        if ($section == 'content') {
?>
                <th width="12%" align="left">
                Section
                </th>
                <?php
        }
?>
            <th align = "center" width="12%">
            ID
            </th>
            <th align = "center" width="12%">
            <?php echo _MEDIALIBRARY_HEADER_CHECKED_OUT; ?>
            </th>
          </tr>
        <?php
        $k = 0;
        $i = 0;
        $n = count($rows);
        foreach($rows as $row) {
            $img = $row->published ? 'tick.png' : 'publish_x.png';
            $task = $row->published ? 'unpublish' : 'publish';
            $alt = $row->published ? 'Published' : 'Unpublished';
            if (!$row->access) {
                $color_access = 'style="color: green;"';
                $task_access = 'accessregistered';
            } else if ($row->access == 1) {
                $color_access = 'style="color: red;"';
                $task_access = 'accessspecial';
            } else {
                $color_access = 'style="color: black;"';
                $task_access = 'accesspublic';
            }
?>
            <tr class="<?php echo "row$k"; ?>">
                <td width="20" align="center" >
                <?php echo $pageNav->getRowOffset /*rowNumber*/
            ($i); ?>
                </td>
                <td width="20">
                <?php echo mosHTML::idBox($i, $row->id, 
                  ($row->checked_out_contact_category && $row->checked_out_contact_category != $my->id),'bid'); ?>
                </td>
                <td width="35%">
                <?php

            if ($row->checked_out_contact_category && ($row->checked_out_contact_category != $my->id)) {
?>
                    <?php echo $row->treename . ' ( ' . $row->title . ' )'; ?>
                    &nbsp;[ <i>Checked Out</i> ]
                    <?php

            } else {
?>
                    <a href="#edit" onClick="return listItemTask('cb<?php echo $i; ?>','edit')">
                    <?php echo $row->treename . ' ( ' . $row->title . ' )'; ?>
                    </a>
                    <?php
            }
?>
                </td>
                <td align="center">
                <?php echo $row->cc; ?>
                </td>

                <td align="center">
                <a href="javascript: void(0);" onClick="return listItemTask('cb<?php echo $i; 
                  ?>','<?php echo $task; ?>')">
<?php
            if (version_compare(JVERSION, "1.6.0", "lt")) {
?>
                    <img src="<?php echo $mosConfig_live_site . "/administrator/images/" .
                       $img; ?>" width="12" height="12" border="0" alt="<?php echo $alt; ?>" />
<?php
            } else {
?>
                    <img src="<?php echo $templateDir . "/images/admin/" .
                       $img; ?>" width="12" height="12" border="0" alt="<?php echo $alt; ?>" />
<?php
            }
?>
                </a>
                </td>


                    <!-- old td  >
                    <?php echo $i . $pageNav->orderUpIcon($i); ?>
                    </td>
                    <td>
                    <?php echo $i . "::" . $n . $pageNav->orderDownIcon($i, $n); ?>
                    </td-->
                    <td>
                    <?php
            echo catOrderUpIcon($row->ordering - 1, $i); ?>
                    </td>
                    <td>
                    <?php
            echo catOrderDownIcon($row->ordering - 1, $row->all_fields_in_list, $i); ?>
                    </td>

                <td align="center">
                <?php echo $row->id; ?>
                </td>
                <td align="center">
                <?php echo $row->checked_out_contact_category ? $row->editor : ""; ?>
                </td>
                <?php
            $k = 1 - $k;
?>
            </tr>
            <?php
            $k = 1 - $k;
            $i++;
        }
		?>
                <tr><td colspan = "11"><?php echo $pageNav->getListFooter(); ?></td></tr>
        </table>


        <input type="hidden" name="option" value="com_medialibrary" />
        <input type="hidden" name="section" value="categories" />
        <input type="hidden" name="task" value="" />
        <input type="hidden" name="chosen" value="" />
        <input type="hidden" name="act" value="" />
        <input type="hidden" name="boxchecked" value="0" />
        <input type="hidden" name="type" value="<?php echo $type; ?>" />
        </form>
        <?php
    }

    static function edit(&$row, $section, &$lists, $redirect, $langshow, $associate_cat_arr) {
        global $my, $mosConfig_live_site, $mainframe;
        global $doc; // for J 1.6
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_CATEGORIES_MANAGER . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;
        if ($row->image == "") {
            $row->image = 'blank.png';
        }
        mosMakeHtmlSafe($row, ENT_QUOTES, 'description');
?>
        <script language="javascript" type="text/javascript">
        //function submitbutton(pressbutton, section) {
    Joomla.submitbutton = function(pressbutton,section) {

      title = document.getElementById('title'); 
      title = trim(title.value);

      name_name = document.getElementById('name_name');
      name_name = trim(name_name.value);

      category = document.getElementById('category_registrationlevel'); 
      category = trim(category.value);

        if (title == ''){ 
            alert('Please set category alias');
            return;
        }

        if (name_name == ''){
            alert('_MEDIALIBRARY_DML_CAT_MUST_SELECT_NAME');
            return;
        }

        if (category == ''){ 
            alert( 'Please set user group');
            return;
        }

        submitform(pressbutton);

    }
    function trim(string)
    {
      return string.replace(/(^\s+)|(\s+$)/g, "");
    }

        </script>

        <form id="adminForm" action="index.php" method="post" name="adminForm">
        <table >
        <tr>
            <th  class="media_manager_caption" align="left">
            <?php echo $row->id ? _MEDIALIBRARY_HEADER_EDIT : _MEDIALIBRARY_HEADER_ADD; ?> <?php
               echo _MEDIALIBRARY_HEADER_MEDIALIBRARY_LABEL_CATEGORY; ?> <?php echo $row->name; ?>
            </th>
        </tr>
        </table>

        <table width="100%">
        <tr>
            <td valign="top">


                <table class="adminform">
                <tr>
                    <th colspan="3">
                    <?php echo _MEDIALIBRARY_CATEGORIES__DETAILS; ?>
                    </th>
                </tr>
          <tr>
          <td>
          <?php echo _MEDIALIBRARY_CATEGORIES_HEADER_TITLE; ?>:
                    </td>
                    <td colspan="2">
                      <input type="hidden" name="catid" id="catid" value="<?php echo $row->id; 
                        ?>" size="50" maxlength="50" title="" />
                      <input class="text_area" type="text" name="title" id="title" 
                        value="<?php echo $row->title; ?>" size="50" maxlength="50" 
                        title="A short name to appear in menus" />
                    </td>
                </tr>
                <tr>
                    <td>
                    <?php echo _MEDIALIBRARY_CATEGORIES_HEADER_NAME; ?>:
                    </td>
                    <td colspan="2">
                      <input class="text_area" type="text" name="name" id="name_name" 
                        value="<?php echo $row->name; ?>" size="50" maxlength="255" 
                        title="A short name to appear in menus" />
                         <input type="hidden" name="name" id="category_registrationlevel" 
                        value="-2"/>                        
                    </td>
                </tr>



          <?php
                /*********************************************************************************************/
                if (!empty($associate_cat_arr) && 
                  !empty($row->langDescription) && $row->langDescription != '' && $row->langDescription != '*') {
          ?>
                        <tr>
                            <td width="15%"><?php echo 'language associate category' ?>:</td>
                        </tr>
          <?php
                    $j = 1;
                    foreach($associate_cat_arr as $lang => $value) {
                        $displ = '';
                        if (!$value['list']) {
                            $displ = 'none';
                        }
          ?>
                        <tr style="display: <?php echo $displ ?>">
                            <td width="15%"><?php echo $lang; ?>:</td>
                            <td width="60%"><?php echo $value['list']; ?>
                            <input class="inputbox" id="associate_category" type="text"
                            name="associate_category<?php echo $j; ?>" size="20" readonly="readonly"
                            maxlength="20" style="width:25px;"
                            value="<?php echo $value['assocId']; ?>" />
                            <input style="display: none" name="associate_category_lang<?php echo $j; ?>"
                            value="<?php echo $lang ?>"/>
                            </td>
                        </tr>
          <?php
                        $j++;
                    }
                } else {
          ?>
                        <tr>
                            <td width="15%"><?php echo 'language associate category' ?>:</td>
                            <td width="60%"><?php echo 'this property only for category with language' ?>
                        </tr>
          <?php
                }
                /*********************************************************************************************/
          ?>

    <script>
    window.onload = function(){
        var languageParentId = document.querySelectorAll('#language_associate_category');
        for(var i = 0; i < languageParentId.length; i++){
            var el = languageParentId[i];
            var idField = languageParentId[i].nextSibling.nextSibling;
            el.value = idField.value;
            var field = (function(x){
                el.onchange= function(){
                    var el = languageParentId[x];
                    var idField = languageParentId[x].nextSibling.nextSibling;
                    idField.value = el.value;
                };
            })(i);
        }
    };
   </script>
                 <tr>
                 <td width="185"><?php echo _MEDIALIBRARY_LABEL_LANGUAGE_DESCRIPTION; ?>:</td>
                     <td colspan="2"><?php echo $langshow; ?></td>
                </tr>
                <!-- <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_CONFIG_VIEW_TYPE_ALONE; ?>:</td>
                    <td colspan="2"><?php echo $lists['alonecategory']; ?></td>
                </tr> -->
                <!-- <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_CONFIG_VIEW_TYPE_DISPLAY_BOOK; ?>:</td>
                    <td colspan="2"><?php echo $lists['view_type_display_book']; ?>
                    </td>
                </tr>
                <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_CONFIG_VIEW_TYPE_DISPLAY_VIDEO; ?>:</td>
                    <td colspan="2"><?php echo $lists['view_type_display_video']; ?>
                    </td>
                </tr>
                <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_CONFIG_VIEW_TYPE_DISPLAY_MUSIC; ?>:</td>
                    <td colspan="2"><?php echo $lists['view_type_display_music']; ?>
                    </td>
                </tr>
                <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_CONFIG_VIEW_TYPE_DISPLAY_GAME; ?>:</td>
                    <td colspan="2"><?php echo $lists['view_type_display_game']; ?>
                    </td>
                </tr> -->
                <tr>
                    <td align="left">
                    <?php echo _MEDIALIBRARY_CATEGORIES__PARENTITEM; ?>:</td>
                    <td>
                      <?php echo $lists['parent']; ?>
                    </td>
                </tr>
                <tr>
                    <td>
                    <?php echo _MEDIALIBRARY_CATEGORIES_HEADER_IMAGE; ?>:
                    </td>
                    <td>
                       <?php echo $lists['image']; ?>
                    </td>
                    <td rowspan="4" width="50%">
                    <script language="javascript" type="text/javascript">
                    if (document.forms[0].image.options.value!=''){
                        jsimg='../images/stories/' + getSelectedValue( 'adminForm', 'image' );
                    }
                    else
                    {
                        jsimg='../images/M_images/blank.png';
                    }
                    document.write('<img src=' + jsimg + 
                      ' name="imagelib" width="80" height="80" border="2" alt="<?php 
                      echo _MEDIALIBRARY_CATEGORIES__IMAGEPREVIEW; ?>" />');
                    </script>
                    </td>
                </tr>
                <tr>
                    <td>
                    <?php echo _MEDIALIBRARY_CATEGORIES_HEADER_IMAGEPOS; ?>:
                    </td>
                    <td>
                      <?php echo $lists['image_position']; ?>
                    </td>
                </tr>
                <tr>
                    <td>
                    <?php echo _MEDIALIBRARY_CATEGORIES_HEADER_ORDER; ?>:
                    </td>
                    <td>
                      <?php echo $lists['ordering']; ?>
                    </td>
                </tr>
                <tr>
                    <td>
                    <?php echo _MEDIALIBRARY_HEADER_PUBLISHED; ?>:
                    </td>
                    <td>
                      <?php echo $lists['published']; ?>
                    </td>
                </tr>
                <tr>
                    <td valign="top">
                    <?php echo _MEDIALIBRARY_CATEGORIES__DETAILS; ?>:
                    </td>
                    <td colspan="2">
                    <?php
        // parameters : areaname, content, hidden field, width, height, rows, cols
        editorArea('editor1', $row->description, 'description', '500', '200', '50', '5');
?>
                    </td>
                </tr>
               </table>
            </td>
            </tr>
        </table>

        <input type="hidden" name="option" value="com_medialibrary" />
        <input type="hidden" name="section" value="categories" />
        <input type="hidden" name="task" value="" />
        <input type="hidden" name="id" value="<?php echo $row->id; ?>" />
        <input type="hidden" name="sectionid" value="com_medialibrary" />
        <input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
        </form>
        <?php
    }
}
/**
 * MediaLibrary Class
 * Handles the data from the medialibrary.
 */
class HTML_medialibrary {
    static function sort_head_let($sortby) {
        global $mosConfig_live_site;
        $img_str = "";
        $templateDir = $mosConfig_live_site . "/components/com_medialibrary";
        switch ($sortby) {
            case 'lend_out':
                $title = "";
            break;
            case 'lend_out_desc':
                $title = "";
            break;
            case 'lend_until':
                $img_str = "<img src=\"" . $templateDir . 
                  "/images/uparrow-1.png\" width=\"12\" height=\"12\" border=\"0\" alt='Sorted up' />";
                $title = _MEDIALIBRARY_ORDER_LEND_UNTIL;
            break;
            case 'lend_until_desc':
                $img_str = "<img src=\"" . $templateDir . 
                  "/images/downarrow-1.png\" width=\"12\" height=\"12\" border=\"0\" alt='Sorted up' />";
                $title = _MEDIALIBRARY_ORDER_LEND_UNTIL;
            break;
            case 'lend_from':
                $img_str = "<img src=\"" . $templateDir . 
                  "/images/uparrow-1.png\" width=\"12\" height=\"12\" border=\"0\" alt='Sorted up' />";
                $title = _MEDIALIBRARY_ORDER_LEND_FROM;
            break;
            case 'lend_from_desc':
                $img_str = "<img src=\"" . $templateDir . 
                  "/images/downarrow-1.png\" width=\"12\" height=\"12\" border=\"0\" alt='Sorted up' />";
                $title = _MEDIALIBRARY_ORDER_LEND_FROM;
            break;
            default:
                $value = "lend_until";
                $title = _MEDIALIBRARY_LABEL_LEND;
            break;
        }
        $enums = Array('none', 'lend_until', 'lend_until_desc', 'lend_from', 'lend_from_desc');
        for ($i = 0;$i < count($enums);$i++) {
            if ($enums[$i] == $sortby) {
                if (($i + 1) != count($enums)) {
                    $value = $enums[$i + 1];
                } else {
                    $value = $enums[0];
                }
                break;
            }
        }
        $str = "<a href='" . $mosConfig_live_site . 
          "/administrator/index.php?option=com_medialibrary&amp;sortlet=$value'>" . $img_str . $title . "</a>";
        return $str;
    }











        //ОТРИСОВКА АВТОРОВ showAuthors (старт)

    static function showAuthors($option,$rows,$pageNav, $search, $search_for_list, $langshow_filter, 
        $typeshow_filter){

        global $doc, $mosConfig_live_site, $templateDir, $my; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_SHOW_PEOPLE . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;
         ?>
        <form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
            <table cellpadding="4" cellspacing="0" border="0" width="100%"
                class="adminlist my_table bl_admin_books_top_table_with_search_ans_orders">
                <tr>
                    <td width="5%"><label><?php echo _MEDIALIBRARY_SHOW_SEARCH; ?></label></td>
                    <td width="18%">
                        <input type="text" name="auth_search" value="<?php echo $search; ?>" class="inputbox" />
                   </td>
                   <td width="3%">
                        <label><?php echo _MEDIALIBRARY_SHOW_SEARCH_FOR; ?></label>
                    </td>
                    <td width="15%">
                        <?php echo $search_for_list; ?>
                    </td>
                    <td width="7%">
                        <input class="my_btn my_btn_go" type="submit" name="go" 
                          value="<?php echo _MEDIALIBRARY_SHOW_SEARCH_GO; ?>" >
                    </td>
                    <td width="10%">
                        <?php echo $langshow_filter ?>
                    </td>
                    <td width="10%">
                        <?php  echo $typeshow_filter?>
                    </td>
                    <td align="right">
                        <?php
                        if (version_compare(JVERSION, "3.0.0", "ge")) { ?>
                         <div class="btn-group pull-right hidden-phone">
                            <label for="limit" class="element-invisible">
                            <?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC'); ?></label>
                            <?php echo $pageNav->getLimitBox(); ?>
                         </div>
                         <?php
                        } ?>

                    </td>
                </tr>
            </table>

              <table cellpadding="4" cellspacing="0" border="0" width="100%" class="my_table my_table-bordered my_table-hover adminlist bl_admin_books_main_table">
                <tr class="cat-header">
                    <th width="4%">
                        <input type="checkbox" name="toggle" value="" onClick="Joomla.checkAll(this);" />
                    </th>
                    <th width="4%">id</th>
                    <th width="12%" align = "center"  class="title" nowrap="nowrap">
        <?php echo _MEDIALIBRARY_LABEL_PEOPLE; ?>
                    </th>
                    <th width="12%" align = "center"  class="title" nowrap="nowrap">
        <?php echo _MEDIALIBRARY_LABEL_TYPE; ?>
                    </th>
                   <th width="12%" align = "center" class="title" nowrap="nowrap">
        <?php echo _MEDIALIBRARY_LABEL_TITLE_MEDIA; ?>
                    </th>
                    <th width="12%" align = "center" class="title" nowrap="nowrap">
        <?php echo _MEDIALIBRARY_LABEL_HITS; ?>
                    </th>
                    <th width="12%" align = "center"  class="title" nowrap="nowrap">
        <?php echo _MEDIALIBRARY_LABEL_PUBLIC; ?>
                    </th>
                    <th width="12%" align = "center" class="title" nowrap="nowrap">
        <?php echo _MEDIALIBRARY_LABEL_CONTROL; ?>
                    </th>
                    <th width="12%" align = "center" class="title" nowrap="nowrap">
       <?php echo _MEDIALIBRARY_LABEL_LANGUAGE; ?>
                    </th>
                </tr>

<?php for ($i = 0, $n = count($rows);$i < $n;$i++) {
            $row = $rows[$i];
?>
             <tr class="row<?php echo $i % 2; ?>">

<!--check box people

-->
            <td width="4%" align="center">

    <?php if($row->checked_out && $row->checked_out != $my->id) { ?>
                &nbsp;
    <?php
    } else {
    ?>
                <input type="checkbox" id="cb<?php echo $i; ?>" name="bid[]" value="<?php echo $row->id; ?>"
                onClick="Joomla.isChecked(this.checked);" />
    <?php
        }
    ?>
                
                

            </td>


                        <td align="center" width="30"><?php echo $row->id; ?></td>

                        <!--td align="center" width="12%"><?php echo $row->name; ?></td-->

                       <td align="left">

                          <a href="#edit" onClick="return listItemTask('cb<?php echo $i; ?>','edit_author')">
                    <?php echo $row->people_name; ?>

                            </a>
                        </td>
                        <td align="center" width="16%"><?php echo $row->type; ?></td>
                        <td align="center" width="25%"><?php echo $row->title; ?></td>
                        <td align="center" width="16%"><?php echo $row->hits; ?></td>
                        <td align="center" width="7%" style="text-align:center;vertical-align:middle;">
            <?php
            $task = $row->published ? 'unpublish_author' : 'publish_author';
            $alt = $row->published ? 'Unpublish' : 'Publish';
            $img = $row->published ? 'tick.png' : 'publish_x.png';
?>

                <a href="javascript: void(0);" onClick="return listItemTask('cb<?php echo $i; ?>',
                '<?php echo $task; ?>')">


            <?php if (version_compare(JVERSION, "1.6.0", "lt")) { ?>
                        <img src="<?php echo $templateDir . "/images/admin/" . $img; ?>"
                        border="0" alt="<?php echo $alt; ?>" />
            <?php
            } else { ?>
                        <img src="<?php echo $templateDir . "/images/admin/" . $img; ?>"
                        border="0" alt="<?php echo $alt; ?>" />
            <?php 
            } ?> 
              </a>
                        </td>
                        
<?php

//Checked OUT people 

            if ($row->checked_out) {
                echo "<td align='center'>".$row->checked_out_user."</td>";
            } else {
                echo "<td align='center'>-</td>";
            }
?>
                        <td align="center" width="12%"><?php echo $row->langshow; ?></td>
                    </tr>
            <?php 
        } //end for(...)

?>
                <tr class="for_paginator">
                    <td align="center" colspan = "11"><?php echo $pageNav->getListFooter(); ?></td>
                </tr>
            </table>
        <input type="hidden" name="task" value="manage_author" />
        <input type="hidden" name="option" value="<?php echo $option; ?>"/>
        <input type="hidden" name="boxchecked" value="0" />

        </form>
        <?php
    }
//ОТРИСОВКА АВТОРОВ showAuthors (конец)












//Редактирование авторов editAuthor (старт)
    static function editAuthor($option, $author, $langshow,  
      $associateArray,$people_type_list,$message){


        global $doc, $mosConfig_live_site, $medialibrary_configuration; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_SHOW_PEOPLE . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html; ?>
        
        <script>

        function set_description(sel) {
          var value = sel.options[sel.selectedIndex].value;
          if (value =="actor") {
              document.getElementById('PEOPLE_DESCTIPTION').innerHTML= "<?php 
                echo _MEDIALIBRARY_ADMIN_CONFIG_ACTOR_DESCTIPTION; ?>";
          }else if (value == "artist") {
              document.getElementById('PEOPLE_DESCTIPTION').innerHTML= "<?php 
                echo _MEDIALIBRARY_ADMIN_CONFIG_ARTIST_DESCTIPTION; ?>";
          }else if (value == "author") {
              document.getElementById('PEOPLE_DESCTIPTION').innerHTML= "<?php 
                echo _MEDIALIBRARY_ADMIN_CONFIG_AUTHOR_DESCTIPTION; ?>";
          }else if (value == "director") {
              document.getElementById('PEOPLE_DESCTIPTION').innerHTML= "<?php 
                echo _MEDIALIBRARY_ADMIN_CONFIG_DIRECTOR_DESCTIPTION; ?>";
          }else if (value == "game_studio") {
              document.getElementById('PEOPLE_DESCTIPTION').innerHTML= "<?php 
                echo _MEDIALIBRARY_ADMIN_CONFIG_GAME_STUDIO_DESCTIPTION; ?>";
          }else if (value == "producer") {
              document.getElementById('PEOPLE_DESCTIPTION').innerHTML= "<?php 
                echo _MEDIALIBRARY_ADMIN_CONFIG_PRODUCER_DESCTIPTION; ?>";
          }else if (value == "video_studio") {
              document.getElementById('PEOPLE_DESCTIPTION').innerHTML= "<?php 
                echo _MEDIALIBRARY_ADMIN_CONFIG_VIDEO_STUDIO_DESCTIPTION; ?>";
          } else
          {
              document.getElementById('PEOPLE_DESCTIPTION').html="";
          }
      }
</script>        
        <form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
            <table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform">
               <tr>
                    <td width="20%" align="right"><?php echo "ID"; ?>:</td>
                    <td colspan="2" width="80%">
                        <input readonly="readonly" class="text_area id" type="text" name="people_id"
                        id="people_id" size="50" maxlength="50" title="" value="<?php echo $author->id; ?>"/>
                    </td>
                </tr>
               <tr>
                    <td valign="top" align="right">
                        <strong><?php echo _MEDIALIBRARY_LABEL_PEOPLE_NAME; ?>:</strong>
                    </td>
                    <td align="left">
                        <input class="inputbox" id="people_name" type="text" name="people_name" size="200"
                        value="<?php echo $author->people_name; ?>"/>
                    </td>
                </tr>
                <tr>
                    <td valign="top" align="right">
                        <strong><?php echo _MEDIALIBRARY_LABEL_TYPE; ?>:</strong>
                    </td>
                    <td align="left">
                        <!-- input class="inputbox" id="type" type="text" name="type" size="200"
                        value="<?php echo $author->type; ?>"/ -->
                        <?php echo $people_type_list; ?>
                    </td>

                </tr>

 <?php
        /*******************************************    language    **********************************/
        if (!empty($associateArray) && !empty($author->langshow) && $author->langshow != '' && 
            $author->langshow != '*') {
?>
                <tr>
                    <td width="15%"><?php echo 'language associate authors' ?>:</td>
                </tr>

<?php
            $j = 1;
            foreach($associateArray as $lang => $value) {
                $displ = '';
                if (!$value['list']) {
                    $displ = 'none';
                } 
?>
                <tr style="display: <?php echo $displ ?>">
                    <td width="15%"><?php echo $lang; ?>:</td>
                    <td width="60%"><?php echo $value['list']; ?>
                    <input class="inputbox" id="associate_author" type="text"
                           name="associate_author<?php echo $j; ?>" size="20"
                           readonly="readonly" maxlength="20" style="width:25px;"
                           value="<?php echo $value['assocId']; ?>" />
                    <input style="display: none" name="associate_author_lang<?php echo $j; ?>"
                           value="<?php echo $lang ?>"/>
                    </td>
                </tr>
<?php
                $j++;
            }
        } else {
?>
                <tr>
                    <td width="15%"><?php echo 'language associate authors' ?>:</td>
                    <td width="60%"><?php echo 'this property only for authors with language' ?>
                </tr>
<?php
        }
        /*********************************************************************************************/
?>
                 <tr>
                    <td valign="top" align="right"><strong>
                    <?php echo _MEDIALIBRARY_LABEL_LANGUAGEDESCRIPTION; ?>:</strong></td>
                    <td align="left"><?php echo $langshow; ?></td>
                </tr>

                <tr>
                    <td valign="top" align="right"><strong>
                    <?php echo _MEDIALIBRARY_LABEL_COMMENT; ?>:</strong></td>
                    <td align="left">
        <?php editorArea('editor1', $author->description, 'description', 500, 250, '400', '400'); ?>
                    </td>
                </tr>
                <tr>
                    <td valign="top" align="right">
                        <strong><?php echo _MEDIALIBRARY_LABEL_PEOPLE_GENERATE_DESCRIPTION; ?>:</strong>
                    </td>
                    <td align="left">
                    <div  id="auto_gener_desc" name="auto_gener_desc"
                          style="width: 650px; border: 1px solid #9e9e9e; height: auto; padding:10px;"/>
                        <?php echo $message; ?>
                  </div>
                    </td>

                     <td align="right">
                     <?php echo _MEDIALIBRARY_ADMIN_CONFIG_TAG_FOR_DESCRIPTION; ?>
                     <div id="PEOPLE_DESCTIPTION" style="background:#F5F5F5; padding:10px;">
                    <?php 
                    
                    switch ($author->type) {
                        case "actor":
                            echo '<input type="hidden" name="auto_desc" 
                                value="'._MEDIALIBRARY_ADMIN_CONFIG_ACTOR_DESCTIPTION.'"/>';
                            echo _MEDIALIBRARY_ADMIN_CONFIG_ACTOR_DESCTIPTION;
                            break;
                        case "artist":
                            echo '<input type="hidden" name="auto_desc" 
                                value="'._MEDIALIBRARY_ADMIN_CONFIG_ARTIST_DESCTIPTION.'"/>';
                            echo _MEDIALIBRARY_ADMIN_CONFIG_ARTIST_DESCTIPTION;
                            break;
                        case "author":
                            echo '<input type="hidden" name="auto_desc" 
                                value="'._MEDIALIBRARY_ADMIN_CONFIG_AUTHOR_DESCTIPTION.'"/>';
                            echo _MEDIALIBRARY_ADMIN_CONFIG_AUTHOR_DESCTIPTION;
                            break;
                        case "director":
                            echo '<input type="hidden" name="auto_desc" 
                                value="'._MEDIALIBRARY_ADMIN_CONFIG_DIRECTOR_DESCTIPTION.'"/>';
                            echo _MEDIALIBRARY_ADMIN_CONFIG_DIRECTOR_DESCTIPTION;
                            break;
                        case "producer":
                            echo '<input type="hidden" name="auto_desc" 
                                value="'._MEDIALIBRARY_ADMIN_CONFIG_PRODUCER_DESCTIPTION.'"/>';
                            echo _MEDIALIBRARY_ADMIN_CONFIG_PRODUCER_DESCTIPTION;
                            break;
                        case "game_studio":
                            echo '<input type="hidden" name="auto_desc" 
                                value="'._MEDIALIBRARY_ADMIN_CONFIG_GAME_STUDIO_DESCTIPTION.'"/>';
                            echo _MEDIALIBRARY_ADMIN_CONFIG_GAME_STUDIO_DESCTIPTION;
                            break;
                        case "video_studio":
                            echo '<input type="hidden" name="auto_desc" 
                                value="'._MEDIALIBRARY_ADMIN_CONFIG_VIDEO_STUDIO_DESCTIPTION.'"/>';
                            echo _MEDIALIBRARY_ADMIN_CONFIG_VIDEO_STUDIO_DESCTIPTION;
                            break;

                    } ?>
                    </div>

                    </td>
                </tr>
                <tr>
                    <td valign="top" align="right">
                        <strong><?php echo _MEDIALIBRARY_LABEL_PUB_DATE; ?>:</strong>
                    </td>
                    <td align="left">
                        <input class="inputbox" type="text" name="pub_date_author" size="30" value="<?php
                            if (empty($author->date)) {
                                echo date("Y-m-d H:i:s");
                            } else {
                                echo $author->date;
                            }
                    ?>" />
                    </td>
                   </tr>
                   <tr>
                    <td valign="top" align="right">
                        <strong><?php echo _MEDIALIBRARY_LABEL_PICTURE_URL_UPLOAD; ?>:</strong>
                    </td>

                   <td align="left">
                        <input class="inputbox" type="file" name="picture_file_author" value="" size="50"
                               maxlength="250" />
                        <br /><?php echo _MEDIALIBRARY_LABEL_PICTURE_URL_DESC; ?>
                        <?php
                        if ($author->imageURL != "" && !strstr($author->imageURL, "http")) {
                            echo '<div><img class="view_media_image" src="' . $mosConfig_live_site . 
                                '' . $author->imageURL .
                                '" alt="' . $author->people_name . '" border="0" height="' .
                                $medialibrary_configuration['foto']['high'] . 
                                '" width="' . $medialibrary_configuration['foto']['width'] .
                                '"/></div>';
                        } else if ($author->imageURL != "" && strstr($author->imageURL, "http")) {
                            echo '<div><img class="view_media_image" src="' . $author->imageURL . 
                              '" alt="' . $author->people_name . '" border="0" height="' .
                               $medialibrary_configuration['foto']['high'] . 
                               '" width="' . $medialibrary_configuration['foto']['width'] .
                                '"/></div>';
                        } ?>
                   </td>
                </tr>

                <!-- <tr>
                    <td valign="top" align="right">
                        <strong><?php echo _MEDIALIBRARY_LABEL_PEOPLE_OWNER; ?>:</strong>

                    </td>
                    <td align="left">
                        <?php echo $author->owner; ?>(<?php echo $author->owner_id; ?>)
                        <input type="hidden" name="owneremail_author" size="80"
                               value="<?php echo $author->owneremail; ?>" />
                    </td>
                </tr> -->
                <tr>
                    <td valign="top" align="right">
                        <strong><?php echo _MEDIALIBRARY_LABEL_PEOPLE_OWNER; ?>:</strong>
                    </td>
                    <td align="left">
                        <?php echo $author->name = JFactory::getUser($author->owner_id)->name; ?>
                        <?php $user = JFactory::getUser();?>
                        <input type="text" name="owner_id" size="80" value="<?php if(!$author->owner_id) {
                                echo $user->id;
                            } else {
                                echo $author->owner_id;
                            } ?>" />
                    </td>
                </tr>
            </table>
        <input type="hidden" name="task" value="edit_author" />
        <input type="hidden" name="option" value="<?php echo $option; ?>"/>
        </form>
        <?php
    }
//Редактирование авторов editAuthor (конец)








    static function editing_video($option, $medialibrary, $media_class, $clist, $wslist, $langlist, 
          $ratinglist, $delete_edocument,
          $reviews, $type_list, $langshow = null, $files, $videos, $audios, $tracks, $youtubeCode, $youtubeId,
          $associateArray, $actorshow, $studioshow, $producershow, $directorshow) {
        global $my, $mosConfig_live_site, $mainframe, $medialibrary_configuration;
        global $doc, $database; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_SHOW . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;?>

     <script language="javascript" type="text/javascript">
     function type_select(){
        var el = document.forms["adminForm"].elements["task"];
        el.value = "add";
        el = document.getElementById("media_type_field");
        var el2 = document.getElementById("media_type");
        el.value = el2.options[el2.selectedIndex].value;
        el = document.forms["adminForm"];
        el.submit();
        return ;
     }


      function findPosY(obj) {
        var curtop = 0;
        if (obj.offsetParent) {
            while (1) {
                curtop+=obj.offsetTop;
                if (!obj.offsetParent) {
                    break;
                }
                obj=obj.offsetParent;
            }
        } else if (obj.y) {
            curtop+=obj.y;
        }
        return curtop-20;
      }

    function trim(string) {
      return string.replace(/(^\s+)|(\s+$)/g, "");
    }



    Joomla.submitbutton = function(pressbutton) { 
      var form = document.adminForm;
      var post_max_size = <?php echo return_bytes(ini_get('post_max_size')) ?>;
      var upl_max_fsize = <?php echo return_bytes(ini_get('upload_max_filesize')) ?>;
      var file_upl = <?php echo ini_get('file_uploads') ?>;

      var title = document.getElementById('title').value;
      var studio = document.getElementById("new_video_studio_select").value;
      var actor = document.getElementById("new_actor_select").value;
      var producer = document.getElementById("new_producer_select").value;
      var director = document.getElementById("new_director_select").value;
      var studioName = document.getElementById("new-studio-field").value;
      var actorName = document.getElementById("new-actor-field").value;
      var producerName = document.getElementById("new-producer-field").value;
      var directorName = document.getElementById("new-director-field").value;

      studioSelectName = jQuery('#new_producer_select [value="0"]')
      var informationFrom = document.adminForm.informationFrom.value;
      //console.log(informationFrom);
      if (pressbutton == 'save' || pressbutton =='apply') {
            if (trim(form.asin_isbn.value) == '') {
                window.scrollTo(0,findPosY(form.asin_isbn)-100);
                form.asin_isbn.placeholder = "<?php
                echo _MEDIALIBRARY_ADMIN_INFOTEXT_JS_EDIT_ISBN_ASIN_CHECK; ?>";
                form.asin_isbn.style.borderColor = "#FF0000";
                form.asin_isbn.style.color = "#FF0000";
                return;
            } else if (form.catid.value == '0') {
                window.scrollTo(0,findPosY(form.catid)-100);
                form.catid.style.borderColor = "#FF0000";
                form.catid.style.color = "#FF0000";
                return;
            }
            else if ((title == '0' || title == '') && informationFrom == 0) {
                window.scrollTo(0,findPosY(form.title)-100);
                form.title.style.borderColor = "#FF0000";
                alert( "<?php echo _MEDIALIBRARY_LABEL_B_TITLE; ?>");
                return;
            }
            else if ((actor == '0' || actor == '') && informationFrom == 0) {
                if (actorName == '0' || actorName == '') {
                    window.scrollTo(0,findPosY(actor)-100);
                    alert( "<?php echo _MEDIALIBRARY_ADMIN_INFOTEXT_JS_EDIT_ACTOR; ?>");
                    return;
                }
            }
            else if ((studio == '0' || studio == '') && informationFrom == 0) {
                if ((studioName == '0' || studioName == '') && informationFrom == 0) {
                    window.scrollTo(0,findPosY(studio)-100);
                    alert( "<?php echo _MEDIALIBRARY_ADMIN_INFOTEXT_JS_EDIT_STUDIO; ?>");
                    return;
                }
            }
            else if ((producer == '0' || producer == '') && informationFrom == 0) {
                if ((producerName == '0' || producerName == '') && informationFrom == 0) {
                    window.scrollTo(0,findPosY(producer)-100);
                    alert( "<?php echo _MEDIALIBRARY_ADMIN_INFOTEXT_JS_EDIT_PRODUCER; ?>");
                    return;
                }
            }
            else if ((director == '0' || director == '') && informationFrom == 0) {
                if ((directorName == '0' || directorName == '') && informationFrom == 0) {
                    window.scrollTo(0,findPosY(director)-100);
                    alert( "<?php echo _MEDIALIBRARY_ADMIN_INFOTEXT_JS_EDIT_DIRECTOR; ?>");
                    return;
                }
            }

            for (i=1; document.getElementById('new_upload_video'+i); i++){
                if(document.getElementById('new_upload_video'+i).files != null){
                    if(!file_upl){
                      window.scrollTo(0,findPosY(document.getElementById('new_upload_video'+i))-100);
                      document.getElementById('error_video').innerHTML = "<?php
                      echo _MEDIALIBRARY_ADMIN_SETTINGS_VIDEO_ERROR_UPLOAD_OFF; ?>";
                      document.getElementById('new_upload_video'+i).style.borderColor = "#FF0000";
                      document.getElementById('new_upload_video'+i).style.color = "#FF0000";
                      document.getElementById('error_video').style.color = "#FF0000";
                      return;
                    }
                    if(document.getElementById('new_upload_video'+i).files.length != 0 &&
                       document.getElementById('new_upload_video_youtube_code'+i).value != null) {
                    if(document.getElementById('new_upload_video'+i).files[0].size >= post_max_size){
                      window.scrollTo(0,findPosY(document.getElementById('new_upload_video'+i))-100);
                      document.getElementById('error_video').innerHTML = "<?php
                      echo _MEDIALIBRARY_ADMIN_SETTINGS_VIDEO_ERROR_POST_MAX_SIZE; ?>";
                      document.getElementById('new_upload_video'+i).style.borderColor = "#FF0000";
                      document.getElementById('new_upload_video'+i).style.color = "#FF0000";
                      document.getElementById('error_video').style.color = "#FF0000";
                      return;
                    }
                  }
                  if(document.getElementById('new_upload_video'+i).files.length != 0 &&
                     document.getElementById('new_upload_video_youtube_code'+i).value != null) {
                    if(document.getElementById('new_upload_video'+i).files[0].size >= upl_max_fsize){
                      window.scrollTo(0,findPosY(document.getElementById('new_upload_video'+i))-100);
                      document.getElementById('error_video').innerHTML = "<?php
                      echo _MEDIALIBRARY_ADMIN_SETTINGS_VIDEO_ERROR_UPLOAD_MAX_SIZE; ?>";
                      document.getElementById('new_upload_video'+i).style.borderColor = "#FF0000";
                      document.getElementById('new_upload_video'+i).style.color = "#FF0000";
                      document.getElementById('error_video').style.color = "#FF0000";
                      return;
                    }
                }
              }
            }
            if(form.new_upload_track_url1){
              for (i = 1;form.getElementById('new_upload_track_url'+i); i++) {
                if(form.getElementById('new_upload_track'+i).value != ''
                  || form.getElementById('new_upload_track_url'+i).value != ''){
                    if(form.getElementById('new_upload_track_kind'+i).value == ''){
                      window.scrollTo(0,findPosY(document.getElementById('new_upload_track_kind'+i))-100);
                      document.getElementById('new_upload_track_kind'+i).placeholder = "<?php
                        echo _MEDIALIBRARY_ADMIN_SETTINGS_INFOTEXT_JS_TRACK_KIND; ?>";
                      document.getElementById('new_upload_track_kind'+i).style.borderColor = "#FF0000";
                      document.getElementById('new_upload_track_kind'+i).style.color = "#FF0000";
                      return;
                    }else if(form.getElementById('new_upload_track_scrlang'+i).value == ''){
                      window.scrollTo(0,findPosY(document.getElementById('new_upload_track_scrlang'+i))-100);
                      document.getElementById('new_upload_track_scrlang'+i).placeholder = "<?php
                        echo _MEDIALIBRARY_ADMIN_SETTINGS_INFOTEXT_JS_TRACK_LANGUAGE; ?>";
                      document.getElementById('new_upload_track_scrlang'+i).style.borderColor = "#FF0000";
                      document.getElementById('new_upload_track_scrlang'+i).style.color = "#FF0000";
                      return;
                    }else if(form.getElementById('new_upload_track_label'+i).value == ''){
                      window.scrollTo(0,findPosY(document.getElementById('new_upload_track_label'+i))-100);
                      document.getElementById('new_upload_track_label'+i).placeholder = "<?php
                        echo _MEDIALIBRARY_ADMIN_INFOTEXT_JS_TRACK_TITLE; ?>";
                      document.getElementById('new_upload_track_label'+i).style.borderColor = "#FF0000";
                      document.getElementById('new_upload_track_label'+i).style.color = "#FF0000";
                      return;
                    }
                }
              }
              submitform(pressbutton);
            }else {
              submitform(pressbutton);
            }
      } else {
        submitform( pressbutton );
      }
   }
    </script>
        <form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
        <table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform">
      <!-- anton code type -->
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?>:</strong>
      </td>
      <td align="left">
        <?php echo $type_list; ?>
      </td>
    </tr>
    <!-- anton code -->
        <tr>
            <td width="15%" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_VIDEOID; ?>:</strong>
            </td>
            <td width="85%" align="left">
                <input class="inputbox" type="text" name="media_type_id" size="20"
                   maxlength="20" value="<?php echo $media_class->video_id; ?>" />
            </td>
        </tr>
        <tr>
            <td width="20%" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_ASIN; ?>*:</strong>
            </td>
            <td align="left">
                <input class="inputbox" type="text" name="asin_isbn" size="20" 
                  maxlength="20" value="<?php echo $media_class->asin; ?>" />
      </td>
    </tr>



    <?php
          /*******************    language    **************************************************/
          if (!empty($associateArray) && !empty($media_class->langDescription) 
                && $media_class->langDescription != '' && $media_class->langDescription != '*') {
          ?>
                  <tr>
                      <td width="15%"><?php echo 'language associate media' ?>:</td>
                  </tr>
        <?php
              $j = 1;
              foreach($associateArray as $lang => $value) {
                  $displ = '';
                  if (!$value['list']) {
                      $displ = 'none';
                  }
        ?>
                  <tr style="display: <?php echo $displ ?>">
                      <td width="15%"><?php echo $lang; ?>:</td>
                      <td width="60%"><?php echo $value['list']; ?>

                      <input class="inputbox" id="associate_media" type="text"
                              name="associate_media<?php echo $j; ?>" size="20"
                              readonly="readonly" maxlength="20" style="width:25px;"
                              value="<?php echo $value['assocId']; ?>" />
                      <input style="display: none" name="associate_media_lang<?php echo $j; ?>"
                              value="<?php echo $lang ?>"/>
                      </td>
                  </tr>
        <?php
                  $j++;
              }
          } else {
        ?>
                  <tr>
                      <td width="15%"><?php echo 'language associate media' ?>:</td>
                      <td width="60%"><?php echo 'this property only for media with language' ?>
                  </tr>
        <?php
          }
          /*********************************************************************************************/
        ?>




    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_LANGUAGE; ?>:</strong>
      </td>
      <td align="left">
        <?php echo $langlist; ?>
            </td>
        </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_LANGUAGE_DESCRIPTION; ?>:</strong>
            </td>
            <td align="left">
                <?php echo $langshow; ?>
            </td>
        </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_CATEGORY; ?>*:</strong>
            </td>
            <td align="left">
                <?php echo $clist; ?>
            </td>
        </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_FETCH_INFO; ?>:</strong>
            </td>
            <td align="left">
                <?php echo $wslist; ?>
                &nbsp;&nbsp;&nbsp;<img src="../components/com_medialibrary/images/amazon/com-logo.gif" 
                  alt="amazon.com" border="0"/>
             </td>
        </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_COMMENT; ?>:</strong>
            </td>
            <td align="left">
                <?php
        editorArea('editor1', $media_class->comment, 'comment', 500, 250, '70', '10');
?>
                <!--<textarea name="comment" id="comment" cols="50" rows="25" style="width:800;height:200;"><?php 
                  /*echo $row->comment;*/ ?></textarea>-->
            </td>
        <tr>
            <td width="185"></td>
            <td><span id="error_video"></span></td>
        </tr>
        </tr>
            <td colspan="2">
                  <hr size="2" width="100%" />
            </td>
        </tr>
        <tr>
            <td valign="top" align="right">&nbsp;
            </td>
            <td align="left">
                <?php echo _MEDIALIBRARY_ADMIN_TEXT_WSINFO_TEXT1; ?>
                <strong>
                <?php echo _MEDIALIBRARY_LABEL_FETCH_INFO; ?>
                ->
                <?php echo _MEDIALIBRARY_WS_NO; ?>
                </strong>
            </td>
        </tr>
            <!-- anton code type -->
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_TITLE; ?>*:</strong>
            </td>
            <td align="left">
                <input class="inputbox" type="text" id="title" name="title" size="80" 
                        value="<?php echo $media_class->title; ?>" />
            </td>
        </tr>
        <!-- ***********block video************* -->

        <tr>
            <td valign="top" align="right">
            <strong><?php echo _MEDIALIBRARY_RELEASE_DATA; ?>:</strong>
            </td>
            <td align="left">
                <input class="inputbox" type="text" name="release_date" size="80" 
                  value="<?php echo $media_class->release_date; ?>" />
            </td>
        </tr>
        <tr>
            <td valign="top" align="right"><strong>
                    <?php echo _MEDIALIBRARY_LABEL_ACTORS; ?>:</strong></td>
            <td align="left">
                <div class="toggle-actor">
                    <?php echo $actorshow;?>
                </div>
                <input type="text" name="new_actor_field" class="new-actor-field toggle-actor" 
                       id="new-actor-field" style="display: none;"></input>
                <div style="clear: both;"></div>
                <input type="button" id="switch-enter-actor" value="Change actor field."
                       onclick="jQuery('.toggle-actor').toggle('slow')" <?php 
                       if($medialibrary->get('informationFrom')) echo ' style="display: none;"';?>></input>
            </td>
        </tr>
        <tr>
            <td valign="top" align="right"><strong>
                    <?php echo _MEDIALIBRARY_LABEL_STUDIO; ?>:</strong></td>
            <td align="left">
                <div class="toggle-studio">
                    <?php echo $studioshow;?>
                </div>
                <input type="text" name="new_studio_field" class="new-studio-field toggle-studio" 
                       id="new-studio-field" style="display: none;"></input>
                <div style="clear: both;"></div>
                <input type="button" id="switch-enter-studio" value="Change studio field."
                       onclick="jQuery('.toggle-studio').toggle('slow')" <?php 
                       if($medialibrary->get('informationFrom')) echo ' style="display: none;"';?>></input>
            </td>
        </tr>
        <tr>
            <td valign="top" align="right"><strong>
                    <?php echo _MEDIALIBRARY_LABEL_PRODUCER; ?>:</strong></td>
            <td align="left">
                <div class="toggle-producer">
                    <?php echo $producershow;?>
                </div>
                <input type="text" name="new_producer_field" class="new-producer-field toggle-producer" 
                       id="new-producer-field" style="display: none;"></input>
                <div style="clear: both;"></div>
                <input type="button" id="switch-enter-producer" value="Change producer field."
                       onclick="jQuery('.toggle-producer').toggle('slow')" <?php 
                       if($medialibrary->get('informationFrom')) echo ' style="display: none;"';?>></input>
            </td>
        </tr>
        <tr>
            <td valign="top" align="right"><strong>
                    <?php echo _MEDIALIBRARY_LABEL_DIRECTOR; ?>:</strong></td>
            <td align="left">
                <div class="toggle-director">
                    <?php echo $directorshow;?>
                </div>
                <input type="text" name="new_director_field" class="new-producer-field toggle-director" 
                       id="new-director-field" style="display: none;"></input>
                <div style="clear: both;"></div>
                <input type="button" id="switch-enter-director" value="Change director field."
                       onclick="jQuery('.toggle-director').toggle('slow')" <?php 
                       if($medialibrary->get('informationFrom')) echo ' style="display: none;"';?>></input>
            </td>
        </tr>

        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_REGION; ?>:</strong>
            </td>
            <td align="left">
                <input class="inputbox" type="text" name="region" size="80" 
                  value="<?php echo $media_class->region; ?>" />
            </td>
        </tr>
        <tr  >
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_NUMBER_OF_DISCS; ?>:</strong>
            </td>
            <td align="left">
                <input class="inputbox" type="text" name="number_of_discs" size="80" 
                  value="<?php echo $media_class->number_of_discs; ?>" />
            </td>
        </tr>
        <tr >
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_RUNTIME; ?>:</strong>
            </td>
            <td align="left">
                <input class="inputbox" type="text" name="run_time" size="80" 
                  value="<?php echo $media_class->run_time; ?>" />
            </td>
        </tr>
        <tr  >
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_FORMAT; ?>:</strong>
            </td>
            <td align="left">
                <input class="inputbox" type="text" name="video_format" size="80" 
                  value="<?php echo $media_class->format; ?>" />
            </td>
        </tr>
        <!-- ***********block************* -->
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_PRICE; ?>:</strong>
            </td>
            <td align="left">
                <input class="inputbox" type="text" name="price" size="15" 
                  value="<?php echo $media_class->price; ?>" />
                <input class="inputbox" type="text" name="priceunit" size="6" 
                  value="<?php echo $media_class->priceunit; ?>" />
            </td>
        </tr>
     <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_RATING; ?>:</strong>
      </td>
      <td align="left">
        <?php echo $ratinglist; ?>
      </td>
     </tr>
     <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_PICTURE_URL; ?>:</strong>
      </td>
            <!-- /////////////////////////////Begin AddPatch CODE///////////////////-->
      <td align="left">
        <input class="inputbox" type="text" name="imageURL" size="80"
          value="<?php echo $media_class->imageURL; ?>" />
        <input class="inputbox" type="button" name="default_patch"
          value="Set Local Cover Path" onClick="build_patch()" />

        <script type="text/javascript" language="javascript">
        function build_patch()
        {
          var asin_isbn = "<?php echo $media_class->asin; ?>" ;
          var url = 'components/com_medialibrary/asin_isbn_build.php';
          <?php $cover_path = $medialibrary_configuration['fetchImages']['location']; ?>
          var cover_path = "<?php echo $cover_path; ?>";
          if (window.XMLHttpRequest)
          {
            // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType)
            {
              http_request.overrideMimeType('text/xml');
            }
          }
          else if (window.ActiveXObject)
          {
            // IE
            try
            {
              http_request = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e)
            {
              try
              {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
              }
              catch (e)
              {}
            }
          }
          if (!http_request)
          {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
          }
          http_request.onreadystatechange = alertContents;
          http_request.open("POST", url, true);
          http_request.setRequestHeader('Content-Type' , 'application/x-www-form-urlencoded');
          http_request.send('asin_isbn='+asin_isbn+'&cover_path='+cover_path);
        }
        function alertContents()
        {
          if (http_request.readyState == 4)
          {
            if (http_request.status == 200)
            {
              if (http_request.responseText == 1)
              {
                alert("<?php echo _MEDIALIBRARY_TOOLBAR_NEW_MEDIA_INCORRECT_FOLDER . " " . $cover_path; ?>");
              }
              if (http_request.responseText == false)
              {
                alert("<?php echo _MEDIALIBRARY_TOOLBAR_NEW_MEDIA_INCORRECT_FILE; ?>");
              }
              else
              {
                document.adminForm.imageURL.value = http_request.responseText;
              }
            }
            else
            {
              alert('There was a problem with the request.');
            }
          }
        }
        jQuery('#informationFrom').change(function() {
            var amazonServ = jQuery('#informationFrom').val();
            if (amazonServ === '0'){
                jQuery('#switch-enter-actor').css('display', 'block');
                jQuery('#switch-enter-studio').css('display', 'block');
                jQuery('#switch-enter-director').css('display', 'block');
                jQuery('#switch-enter-producer').css('display', 'block');
            } else {
                jQuery('#switch-enter-actor').css('display', 'none');
                jQuery('#switch-enter-studio').css('display', 'none');
                jQuery('#switch-enter-director').css('display', 'none');
                jQuery('#switch-enter-producer').css('display', 'none');
            }
        });
        </script>
        <script language="javascript" type="text/javascript">
          window.onload = function(){
            var button_video = document.getElementById("v_add");
            var allowed_vid_files = 5;
            <?php if (count($videos) > 0) echo "allowed_files = " . (5 - count($videos)) . ";"; ?>
            if(allowed_vid_files >= 1) {
            button_video.removeAttribute("style");
            }
            var button_audio = document.getElementById("a_add");
            var allowed_aud_files = 5;
            <?php if (count($audios) > 0) echo "allowed_files = " . (5 - count($audios)) . ";"; ?>
            if(allowed_aud_files >= 1) {
            button_audio.removeAttribute("style");
            }
            // for (var i=1; i < 5; i++) {
            //     if (document.getElementById('new_upload_video_youtube_code'+i) != 'undefined' &&
            //         document.getElementById('new_upload_video_youtube_code'+i) !== null){
            //         var add =  document.getElementById('new_upload_video_youtube_code'+i).value;
            //         if(add.length){
            //             var obj = document.getElementById('v_add');
            //             obj.style.display = "none";
            //         }
            //     }
            //}
          }
        </script>

      </td>
    </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_PICTURE_URL_UPLOAD; ?>:</strong>
            </td>
            <td align="left">
              <input class="inputbox" type="file" name="picture_file" value="" size="50" maxlength="250" />
              <br /><?php echo _MEDIALIBRARY_LABEL_PICTURE_URL_DESC; ?>
      <?php
        if ($media_class->imageURL != "" && !strstr($media_class->imageURL, "http")) {
            echo '<div><img class="bl_view_media_image" src="' . $mosConfig_live_site . '' 
                . $media_class->imageURL .
                '" alt="' . $media_class->title . '" border="0"
                              height="' . $medialibrary_configuration['foto']['high'] . '" width="' .
                              $medialibrary_configuration['foto']['width'] .
                '"/></div>';
        } else if ($media_class->imageURL != "" && strstr($media_class->imageURL, "http")) {
            echo '<div><img class="bl_view_media_image" src="' . $media_class->imageURL . '" alt="' .
                $media_class->title . '" border="0"
                height="' . $medialibrary_configuration['foto']['high'] . '" width="' .
                $medialibrary_configuration['foto']['width'] .
                  '"/></div>';
        }
    ?>
        </td>
    </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_URL; ?>:</strong>
      </td>
      <td align="left">
        <input class="inputbox" type="text" name="URL" size="80" value="<?php echo $media_class->URL; ?>" />
      </td>
    </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_MEDIAOWNER; ?>:</strong>
            </td>
            <td valign="top" align="left">
               <input class="inputbox" type="text" name="owneremail" size="50" 
                value="<?php echo $medialibrary->owneremail; ?>"/>
            </td>
        </tr>
    <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_MEDIAOWNER_ID; ?>:</strong>
            </td>
        <td align="left">
        <?php echo $medialibrary->name = JFactory::getUser($medialibrary->owner_ID)->name; ?>
        <?php $user = JFactory::getUser();?>
        <input type="text" name="owner_ID" size="80" value="<?php if(!$medialibrary->owner_ID) {
          echo $user->id;
        } else {
          echo $medialibrary->owner_ID;
        } ?>" />
            </td>
    </tr>

   <!---------------------------------Start AJAX load track------------------------------>

  <script language="javascript" type="text/javascript">
                var request = null;
                var tid=1;
                function createRequest_track() {
                    if (request != null)
                    return;
                    try {
                       request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                           request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }

                function testInsert_track(id1,upload){
                    for(var i=1; i< upload_tracks; i++){
                        if(upload.id != ('new_upload_track'+i) &&
                        document.getElementById('new_upload_track'+i).value == upload.value){
                            return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1_track(id1,upload){
                    id=id1;
                    if(testInsert_audio(id1,upload)){
                        createRequest_track();
                        var url = "<?php echo $mosConfig_live_site . 
                          "/administrator/index.php?option=$option&task=randNumber&format=raw";
                        ?>&file="+encodeURI(upload.value)+"&path=<?php
                        echo str_replace("\\", "/", $mosConfig_live_site) 
                            . '/components/com_medialibrary/media/track/'?>";
                       try{
                        request.onreadystatechange = updateRandNumber1_track;
                        request.open("GET", url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert("You alredy select this track file");
                        upload.value="";
                    }
                }

                function updateRandNumber1_track() {
                    if (request.readyState == 4) {
                        document.getElementById("randNumTrack"+tid).innerHTML = request.responseText;
                    }
                }
  </script>

 <!-------------------------------- END Ajax load track---------------------------------->


 <!-------------------------------- END Ajax load audio---------------------------------->
  <script language="javascript" type="text/javascript">
                var request = null;
                var aid=1;
                function createRequest_audio() {
                    if (request != null)
                    return;
                    try {
                          request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                           request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }

                function testInsert_audio(id1,upload){
                    for(var i=1; i< upload_audios; i++){
                        if(upload.id != ('new_upload_audio'+i) &&
                        document.getElementById('new_upload_audio'+i).value == upload.value){
                            return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1_audio(id1,upload){
                    id=id1;
                    if(testInsert_audio(id1,upload)){
                        createRequest_audio();
                        var url = "<?php echo $mosConfig_live_site . 
                          "/administrator/index.php?option=$option&task=randNumber&format=raw";
                        ?>&file="+encodeURI(upload.value)+"&path=<?php
                        echo str_replace("\\", "/", $mosConfig_live_site) 
                            . '/components/com_medialibrary/media/audio/'?>";
                       try{
                        request.onreadystatechange = updateRandNumber1_audio;
                        request.open("GET", url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert( "You alredy select this audio file");
                        upload.value="";
                    }
                }

                function updateRandNumber1_audio(){
                    if (request.readyState == 4) {
                        document.getElementById("randNumAudio"+aid).innerHTML = request.responseText;
                    }
                }
  </script>

<!-------------------------------- END Ajax load audio---------------------------------->


<!-------------------------------- START Ajax load video---------------------------------->


            <script language="javascript" type="text/javascript">

               var request = null;
               var vid=1;

               function createRequest_video(){
                    if (request != null)
                    return;
                    try {
                       request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                            request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }

                function testInsertVideo1(id1,upload){
                    for(var i=1 ;i< upload_videos; i++){
                        if(upload.id != ('new_upload_video'+i) &&
                        document.getElementById('new_upload_video'+i).value == upload.value)
                        {
                          return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1_video(id1,upload){
                    id=id1;
                    if(testInsertVideo1(id1,upload)){
                        createRequest_video();
                    var url = "<?php echo $mosConfig_live_site . 
                      "/administrator/index.php?option=$option&task=randNumber&format=raw";
                    ?>&file="+encodeURI(upload.value)+"&path=<?php echo str_replace("\\", "/", $mosConfig_live_site) . 
                      '/components/com_medialibrary/media/video/'?>";
                       try{
                        request.onreadystatechange = updateRandNumber1_video;
                        request.open("GET",url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert("You alredy select this video file");
                        upload.value="";
                    }
                }

                function updateRandNumber1_video() {
                    if (request.readyState == 4) {
                        document.getElementById("randNumVideo"+vid).innerHTML = request.responseText;
                    }
                }
                </script>


  <!-------------------------------- END Ajax load video---------------------------------->


  <!---------------------------------Start AJAX load file------------------------------>


                <script language="javascript" type="text/javascript">

                var request = null;
                var fid=1;
                function createRequest() {
                    if (request != null)
                    return;
                    try {
                        request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                               request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }


                function testInsertFile1(id1,upload){
                    for(var i=1; i< upload_files; i++){
                        if(upload.id != ('new_upload_file'+i) &&
                        document.getElementById('new_upload_file'+i).value==upload.value){
                            return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1(id1,upload) {
                    id=id1;
                    if(testInsertFile1(id1,upload)){
                        createRequest();
                        var url = "<?php echo $mosConfig_live_site . 
                          "/administrator/index.php?option=$option&task=randNumber&format=raw";
                        ?>&file="+encodeURI(upload.value)+"&path=<?php
                        echo str_replace("\\", "/", $mosConfig_live_site) . 
                          '/components/com_medialibrary/emedia/'?>";
                        try{
                        request.onreadystatechange = updateRandNumber1;
                        request.open("GET",url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert( "You alredy select this file");
                        upload.value="";
                    }
                }
                function updateRandNumber1() {
                    if (request.readyState == 4) {
                        document.getElementById("randNumFile"+fid).innerHTML = request.responseText;
                    }
                }
                </script>

<!-------------------------------- END Ajax load file ---------------------------------->


    <script language="javascript" type="text/javascript">
    var upload_tracks=0;
    function new_tracks(index, div0){
        // div=document.getElementById("t_items");
        // button=document.getElementById("t_add");
        div = document.getElementById(div0);
        button=document.getElementById(div0);
        upload_tracks++;
        newitem="<table width='50%'><tr><td width='15%'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_LABEL_TRACK_UPLOAD ?>"+upload_tracks+": </strong></td>";
        newitem+="<td width='85%'>";
        newitem+="<input type='hidden' name='new_upload_track"+upload_tracks;
        newitem+="' value='"+index+"' />";
        
        newitem+="<input style=\"float:left; width:100%\" type=\"file\" "+
        "onClick=\"document.adminForm.new_upload_track"+upload_tracks+".value ='';\" " +
        " onChange=\"refreshRandNumber1_track("+upload_tracks+
        ",this);\"  name=\"new_upload_track"+upload_tracks+"\" "+"id=\"new_upload_track"+upload_tracks;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumTrack"+upload_tracks+"\" ";
        newitem+="style=\"color:red;\"></span></td></tr></td></tr>"+ "<tr><td ";
        newitem+="style=\"text-align:center\"> OR </td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        newitem="<table width='50%'><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_TRACK_UPLOAD_URL; ?>" +upload_tracks+ ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
          "name=\"new_upload_track_url"+upload_tracks+"\" "+"id=\"new_upload_track_url"+upload_tracks;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        div.appendChild(newnode,button);
        newitem="<table width='50%' style=\"display:none;\"><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_CONFIG_TRACK_UPLOAD_KIND; ?>" +upload_tracks+ ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left;display:none; width:90%\" type=\"text\" "+
          "name=\"new_upload_track_kind"+upload_tracks+"\" "+"id=\"new_upload_track_kind"+upload_tracks;
        newitem+="\" value=\"eng\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        div.appendChild(newnode,button);
        newitem="<table width='50%'><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_TRACK_UPLOAD_SCRLANG; ?>" +upload_tracks+ ": ";
        newitem+="</strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
          " name=\"new_upload_track_scrlang"+upload_tracks+"\" ";
        newitem+="id=\"new_upload_track_scrlang"+upload_tracks;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        div.appendChild(newnode,button);
        newitem="<table width='50%' style=\"display:none;\"><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_TRACK_UPLOAD_LABEL; ?>" +upload_tracks+ ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
        "name=\"new_upload_track_label"+upload_tracks+"\" "+"id=\"new_upload_track_label"+upload_tracks;
        newitem+="\" value=\"eng\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
    }
    </script>

   <script language="javascript" type="text/javascript">
    var upload_videos=0;
    function new_videos(){
        div=document.getElementById("v_items");
        button=document.getElementById("v_add");
        upload_videos++;
        newitem="<table width='50%'><tr><td width='160px'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD ?>" +upload_videos+ ": </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:150%\" "+
        "type=\"file\" onClick=\"document.adminForm.new_upload_video_url"+upload_videos+".value ='';\" " +
        " onChange=\"refreshRandNumber1_video("+upload_videos+
        ",this);\" name=\"new_upload_video"+upload_videos+"\" "+"id=\"new_upload_video"+upload_videos;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumVideo"+upload_videos+"\" style=\"color:red;\">"+
        "</span></td></tr></td></tr><tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD_URL; ?>" +upload_videos+ ": </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" "+
          "name=\"new_upload_video_url"+upload_videos+"\" "+"id=\"new_upload_video_url"+upload_videos;
        newitem+="\" value=\"\"size=\"45\"></td></tr></td></tr></td></tr>"+
        "<tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD_YOUTUBE_CODE; ?>" + ": </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" "+
          "name=\"new_upload_video_youtube_code"+upload_videos+"\" "+"id=\"new_upload_video_youtube_code"
            +upload_videos;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        var allowed_files = 5;
        // if(upload_videos + <?php echo count($videos); ?> >= allowed_files) {
        //  button.setAttribute("style","display:none");
        // }
    }
  </script>

   <script language="javascript" type="text/javascript">
    var upload_video_altern_id=1;
    function new_altern_videos(index, div0){
        div = document.getElementById(div0);
        button=document.getElementById(div0);
        upload_altern_videos = index;
        newitem="<table width='50%'><tr><td width='160px'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD ?>: </strong></td>";
        newitem+="<td width='400px'>";
        //newitem+="<input type='hidden' name='new_upload_altern_video"+upload_video_altern_id+"' 
        //value='"+index+"' />";
        newitem+="<input type='hidden' name='new_upload_altern_video"+upload_video_altern_id;
        newitem+="' value='"+index+"' />";
        newitem+="<input style=\"float:left; width:150%\" type=\"file\" "+
        " onClick=\"document.adminForm.new_upload_altern_video_url"+upload_altern_videos;
        newitem+=".value ='';\" " +
        " onChange=\"refreshRandNumber1_video("+upload_altern_videos+
        ",this);\" name=\"new_upload_altern_video"+upload_video_altern_id+"\" ";
        newitem+="id=\"new_upload_altern_video"+upload_video_altern_id;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumVideo"+upload_video_altern_id;
        newitem+="\" style=\"color:red;\"></span></td></tr></td></tr>"
        +"<tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD_URL; ?>: </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" ";
        newitem+="name=\"new_upload_altern_video_url"+ upload_altern_videos+"\" ";
        newitem+="id=\"new_upload_altern_video_url"+upload_altern_videos;
        newitem+="\" value=\"\"size=\"45\"></td></tr></td></tr></td></tr>"+
          "<tr><td style=\"text-align:center\"></td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        // var allowed_files = 5;
        // if(upload_altern_videos + <?php echo count($videos); ?> >= allowed_files) {
        //  button.setAttribute("style","display:none");
        // }
        upload_video_altern_id++;
    }
  </script>

  <script language="javascript" type="text/javascript">
    var upload_audios=0;
    function new_audios(){
        div=document.getElementById("a_items");
        button=document.getElementById("a_add");
        upload_audios++;
        newitem="<table width='50%'><tr><td width='15%'><strong style=\"float:left\">" + 
          "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD ?>" + upload_audios + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:100%\" type=\"file\" "+
        " onClick=\"document.adminForm.new_upload_audio_url"+upload_audios+".value ='';\" " +
        " onChange=\"refreshRandNumber1_audio("+upload_audios+
        ",this);\"  name=\"new_upload_audio"+upload_audios+"\" "+"id=\"new_upload_audio"+upload_audios;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumAudio"+upload_audios+"\" style=\"color:red;\"></span></td></tr>"+
          "<tr><td style=\"text-align:center\"> OR </td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='15%'><strong>" + 
          "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD_URL; ?>" + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" "+
          " type=\"text\" name=\"new_upload_audio_url"+upload_audios+"\" "+
          "id=\"new_upload_audio_url"+upload_audios;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br />";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
         var allowed_aud_files = 5;
        if(upload_audios + <?php echo count($audios); ?> >= allowed_aud_files) {
         button.setAttribute("style","display:none");
        }
    }
  </script>


   <script language="javascript" type="text/javascript">
    var upload_audio_altern_id=1;
    function new_altern_audios(index, div0){
        div = document.getElementById(div0);
        button=document.getElementById(div0);
        upload_altern_audios = index;
        newitem="<table width='50%'><tr><td width='160px'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD ?>: </strong></td>";
        newitem+="<td width='400px'>";
        //newitem+="<input type='hidden' name='new_upload_altern_audio"+upload_audio_altern_id;
        //newitem+="' value='"+index+"' />";
        newitem+="<input type='hidden' name='new_upload_altern_audio"+upload_audio_altern_id;
        newitem+="' value='"+index+"' />";
        newitem+="<input style=\"float:left; width:150%\" type=\"file\" "+
        " onClick=\"document.adminForm.new_upload_altern_audio_url"+upload_altern_audios+".value ='';\" " +
        " onChange=\"refreshRandNumber1_audio("+upload_altern_audios+
        ",this);\" name=\"new_upload_altern_audio"+upload_audio_altern_id+"\" ";
        newitem+="id=\"new_upload_altern_audio"+upload_audio_altern_id;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumaudio"+upload_audio_altern_id;
        newitem+="\" style=\"color:red;\"></span></td></tr></td></tr>"
        +"<tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD_URL; ?>: </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" ";
        newitem+="name=\"new_upload_altern_audio_url"+upload_altern_audios+"\" ";
        newitem+="id=\"new_upload_altern_audio_url"+upload_altern_audios;
        newitem+="\" value=\"\"size=\"45\"></td></tr></td></tr></td></tr>";
        newitem+= "<tr><td style=\"text-align:center\"></td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        // var allowed_files = 5;
        // if(upload_altern_audios + <?php echo count($audios); ?> >= allowed_files) {
        //  button.setAttribute("style","display:none");
        // }
        upload_audio_altern_id++;
    }
  </script>

 <script language="javascript" type="text/javascript">
    var upload_files=0;
    function new_files(){
        div=document.getElementById("f_items");
        button=document.getElementById("f_add");
        upload_files++;
        newitem="<table width='50%'><tr><td width='15%'><strong style=\"float:left\">" + 
          "<?php echo _MEDIALIBRARY_ADMIN_LABEL_EBOOK_UPLOAD ?>" + upload_files + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:100%\" "+
        " type=\"file\" onClick=\"document.adminForm.new_upload_file_url"+upload_files+".value ='';\" " +
        " onChange=\"refreshRandNumber1("+upload_files+
        ",this);\"  name=\"new_upload_file"+upload_files+"\" "+"id=\"new_upload_file"+upload_files;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumFile"+upload_files+"\" style=\"color:red;\"></span></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='15%'><strong>" + 
          "<?php echo _MEDIALIBRARY_ADMIN_LABEL_EBOOK_UPLOAD_URL; ?>" + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
          " name=\"new_upload_file_url"+upload_files+"\" "+"id=\"new_upload_file_url"+upload_files;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br><br />";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
    }
  </script>

    <?php
    if ($medialibrary_configuration['videos_tracks']['allow']) {
            if (count($videos) > 0 ) {
                 $upload_videos = 1;
                $upload_sourcess = 1;
                $video_queue = [];
                foreach ($videos as $kay => $value) {
                    if ($value->sequence_number){
                        $video_queue[$value->sequence_number][] = $value;
                    } else {
                        $video_queue[$value->id][] = $value;
                    }
                }
                foreach ($video_queue as $kay => $videos) {
                    echo '</table>';
                    echo '<div class="upload_video-items" style="margin-left:243px">';
                    if (empty($videos[0]->youtube)) {
                    echo '<div class="upload_video-item">';
                    //echo '<img src="'.$media_class->imageURL.'" alt="image upload video">';
                    echo '<div style="position: absolute; margin: 8px 0 0 -112px;">'
                            ._MEDIALIBRARY_LABEL_VIDEO.$upload_videos.":".'</div>';
                    if (isset($videos[0]->title) && $videos[0]->title != '') 
                                echo "<input type='text' name='video_source_title" . $upload_videos . "'
                                  id='video_source_title" . $upload_videos . "' size='60' value='" 
                                  . $videos[0]->title . "' readonly=\"readonly\"/>";
                    echo '<input type="button" name="show_altern_video" class="show-button" ';
                    echo ' value="'._MEDIALIBRARY_CATEGORIES__DETAILS.'"  style="margin: -8px 0 0 5px;" ';
                    echo ' onclick="jQuery(\'#altern-video-source'.$upload_videos.'\').toggle(\'slow\')"/>';
                    
                    echo  '<div id="altern-video-source'.$upload_videos.'" style = "display:none">';
                    for ($i = 0;$i < count($videos);$i++) {
                        echo _MEDIALIBRARY_LABEL_VIDEO_ATTRIBUTE . ($i + 1) . ":";
                            $type_src =  explode('.', $videos[$i]->src);
                            echo  ' '.$type_src[(count($type_src)-1)];

                        echo  '<div class="altern-video-one-source">';
                        if (isset($videos[$i]->src) && substr($videos[$i]->src, 0, 4) != "http" &&
                        empty($videos[$i]->youtube)){
                            echo "<input type='text' name='new_upload_video" . $i . "' id='new_upload_video" . $i 
                                . "' size='60' value='" . $videos[$i]->src . "' readonly='readonly' />";
                        } elseif (isset($videos[$i]->src) && substr($videos[$i]->src, 0, 4) == "http" &&
                        empty($videos[$i]->youtube)){
                            echo "<input type='text' name='new_upload_video" .  $i 
                                . "' id='new_upload_video_url" . $i 
                                . "' size='60' value='" . $videos[$i]->src . "' readonly='readonly' />";
                        }
                        echo _MEDIALIBRARY_LABEL_VIDEO_DELETE . ":";
                        echo isset($videos[$i]->id) ? "<input type=\"checkbox\" name=\"video_option_del" . 
                          $videos[$i]->id . "\" value=\"" . $videos[$i]->id . "\">" : "";
                        echo  '</div>';
                    }?>
                        <div id="upload-altern-video_add_here<?php echo $upload_videos;?>">
                            <span style="display: none;"></span>
                        </div>
                    <?php
                    echo    '<div class="hidden-details upload-altern-video'.$upload_videos.'">';
                    echo    '<input type="button" name="new_altern_video" ';
                    echo    ' value="'._MEDIALIBRARYLABEL_VIDEO_ADD_ALTERNATIVE_VIDEO.'"';
                    echo    ' onclick="new_altern_videos(\''.$kay.'\',\'upload-altern-video_add_here'
                                     .$upload_videos.'\')" ID="new_altern_video" style="display:block"/>';
                    if ($medialibrary_configuration['videos_tracks']['allow']) {
                        echo '<table class="adminform" width="100%" cellspacing="1" cellpadding="4" border="0">';
                        echo '<tr><td colspan="2"></td></tr>';
                        echo "<tr > <td valign='top' align='right'>"./*_MEDIALIBRARY_LABEL_TRACK.":".**/"</td>";
                        if (count($tracks) > 0) {
                            for ($i = 0;$i < count($tracks);$i++) {
                                if($kay == $tracks[$i]->sequence_number){
                                    echo "<tr><td align='right'>" . _MEDIALIBRARY_LABEL_TRACK_UPLOAD_URL
                                         .($i + 1) . ":";
                                    echo "</td><td>";
                                    if (isset($tracks[$i]->src) && substr($tracks[$i]->src, 0, 4) != "http")
                                    echo "<input type='text' class='trackitems' size='60' value='" .
                                        'components/com_medialibrary/media/track/' 
                                        . $tracks[$i]->src . "' readonly='readonly'/>";
                                    elseif (isset($tracks[$i]->src) && substr($tracks[$i]->src, 0, 4) == "http")
                                    echo "<input type='text' class='trackitems' size='60' value='" . 
                                      $tracks[$i]->src . "' readonly='readonly'/>";
                                    // if (!empty($tracks[$i]->kind)) 
                                    //   echo "<input class='trackitems' type='text' size='60' value='" . 
                                    //     $tracks[$i]->kind . "' readonly='readonly'/>";
                                    if (!empty($tracks[$i]->scrlang)) 
                                      echo "<input class='trackitems' type='text' size='60' value='" . 
                                        $tracks[$i]->scrlang . "' readonly='readonly'/>";
                                    // if (!empty($tracks[$i]->label)) 
                                    //   echo "<input class='trackitems' type='text' size='60' value='" . 
                                    //     $tracks[$i]->label . "' readonly='readonly'/>";
                                    echo "</td></tr>";
                                    echo "<tr><td align='right'>"._MEDIALIBRARY_LABEL_TRACK_DELETE.($i + 1).":";
                                    echo "</td><td>";
                                    echo isset($tracks[$i]->id) ? "<input type=\"checkbox\" "
                                            ."name=\"track_option_del" . 
                                      $tracks[$i]->id . "\" value=\"" . $tracks[$i]->id . "\">" : "";
                                    echo "</td></tr>";
                                }
                            }
                        }?>
                        <tr>
                            <td></td>
                            <td id="track_items_add_here<?php echo $upload_videos;?>">
                                <span style="display: none;"></span>
                            </td>
                        </tr>
                        <tr>
                            <td id="t_items">
                                <input  type="button" name="new_track"
                                  value="<?php echo _MEDIALIBRARY_LABEL_ADD_NEW_TRACK; ?>" onClick="<?php 
                                    echo 'new_tracks(\''.$kay.'\',\'track_items_add_here'
                                         .$upload_videos."'"; ?>)" ID="t_add"/>
                            </td>
                        </tr>
                        
                    <?php  echo '</table>';
                        
                    echo    '</div>';
                    echo  '</div>';
                    
                    
                    echo '</div>';
                    $upload_videos++;
                    }
                    }
                    echo "</div>";
                    echo '<table class="adminform" width="100%" cellspacing="1" cellpadding="4" border="0">';
                // }
                // $upload_videos = 1;
                // foreach ($video_queue as $kay => $videos) {
                    if (!empty($videos[0]->youtube)) {
                        echo '<tr><td colspan="2"></td></tr>';
                        $youtubeCode = array('youtube'=> $videos[0]->youtube);
                        for ($i = 0;$i < count($youtubeCode);$i++) {
                            echo "<tr><td align='right' width='230'>"._MEDIALIBRARY_LABEL_VIDEO.' YouTube '
                                .$upload_videos.":";
                            echo "</td><td>";
                            if (isset($videos[0]->title) && $videos[0]->title != '') 
                                echo "<input type='text' name='video_youtube_title" . $upload_videos . "'
                                  id='video_youtube_title" . $upload_videos . "' size='60' value='" 
                                  . $videos[0]->title . "' readonly=\"readonly\"/>";
                            // echo "</td>";
                            // echo "<td>";
                            echo '<input type="button" name="show_altern_video" class="show-button" ';
                            echo ' value="'._MEDIALIBRARY_CATEGORIES__DETAILS.'" style="margin: -8px 0 0 5px;" ';
                            echo ' onclick="jQuery(\'.youtube-video-source'.$upload_videos.'\').toggle(\'slow\')"/>';
                            echo "</td></tr>";

                            echo '<tr class="youtube-video-source'.$upload_videos
                                    .'" style="display:none;"><td align="right">'
                                    ._MEDIALIBRARY_ADD_NEW_VIDEO_FILE.$upload_videos.':';
                            echo "</td><td>";
                            if (isset($youtubeCode['youtube'])) 
                                echo "<input type='text' name='video_youtube_code" . $upload_videos . "'
                                  id='video_youtube_code" . $upload_videos . "' size='60' value='" 
                                  . $youtubeCode['youtube'] . "' readonly=\"readonly\"/>"
                                  ._MEDIALIBRARY_LABEL_VIDEO_DELETE.$upload_videos.":";
                            echo isset($youtubeId) ? "<input type=\"checkbox\" name=\"youtube_option_del" . 
                              $videos[0]->id  . "\" value=\"" . $videos[0]->id  . "\">" : "";
                            echo "</td></tr>"
                            ;
                            $upload_videos++;
                        }
                    }
                } 
            }?>
            <tr>
              <td width='230' align='left'></td>
                <td ID="v_items">
                    <input type="button" name="new_video"
                      value="<?php echo _MEDIALIBRARY_ADD_NEW_VIDEO_FILE; ?>"
                      onClick="new_videos()" ID="v_add" style="display:block;"/>
              </td>
            </tr>
          <?php 
        }

        if ($medialibrary_configuration['audios']['allow']) {
                echo '</table>';
            echo '<div class="upload_audio-items" style="margin-left:243px">';
            $upload_audios = 1;
            $upload_sourcess = 1;
            $audio_queue = [];
            foreach ($audios as $kay => $value) {
                if ($value->sequence_number){
                    $audio_queue[$value->sequence_number][] = $value;
                } else {
                    $audio_queue[$value->id][] = $value;
                }
            }
            foreach ($audio_queue as $kay => $audios) {
                echo '<div class="upload_audio-item">';
                // echo '<img src="'.$media_class->imageURL.'" alt="image upload audio">';
                echo '<div style="position: absolute; margin: 8px 0 0 -112px;">'
                            ._MEDIALIBRARY_LABEL_AUDIO.$upload_audios.":".'</div>';
                    if (isset($audios[0]->title) && $audios[0]->title != '') 
                                echo '<input type="text" name="video_source_title' . $upload_audios . '"
                                  id="video_source_title"' . $upload_audios . '" size="60" value="' 
                                  .  $audios[0]->title . '" readonly="readonly"/>';
                echo '<input type="button" name="show_altern_audio" class="show-button"';
                echo 'value="'._MEDIALIBRARY_CATEGORIES__DETAILS.'" style="margin: -8px 0 0 5px;" ';
                echo 'onclick="jQuery(\'#altern-audio-source'.$upload_audios.'\').toggle(\'slow\')"/>';
                
                echo  '<div id="altern-audio-source'.$upload_audios.'" style = "display:none">';
                for ($i = 0;$i < count($audios);$i++) {
                    echo _MEDIALIBRARY_LABEL_AUDIO_ATTRIBUTE . ($i + 1) . ":";
                        $type_src =  explode('.', $audios[$i]->src);
                        echo  ' '.$type_src[(count($type_src)-1)];

                    echo  '<div class="altern-audio-one-source">';
                    if (isset($audios[$i]->src) && substr($audios[$i]->src, 0, 4) != "http" &&
                    empty($audios[$i]->youtube)){
                        echo "<input type='text' name='new_upload_audio" . $i . "' id='new_upload_audio" . $i 
                            . "' size='60' value='" . $audios[$i]->src . "' readonly='readonly' />";
                    } elseif (isset($audios[$i]->src) && substr($audios[$i]->src, 0, 4) == "http" &&
                    empty($audios[$i]->youtube)){
                        echo "<input type='text' name='new_upload_audio" .  $i . "' id='new_upload_audio_url" 
                            . $i . "' size='60' value='" . $audios[$i]->src . "' readonly='readonly' />";
                    }
                    echo _MEDIALIBRARY_LABEL_AUDIO_DELETE . ":";
                    echo isset($audios[$i]->id) ? "<input type=\"checkbox\" name=\"audio_option_del" . 
                      $audios[$i]->id . "\" value=\"" . $audios[$i]->id . "\">" : "";
                    echo  '</div>';
                }
                
                echo    '<div class="hidden-details upload-altern-audio'.$upload_audios.'">';
                echo    '<input type="button" name="new_altern_audio" ';
                echo    'value="'._MEDIALIBRARYLABEL_AUDIO_ADD_ALTERNATIVE_AUDIO.'"';
                echo    ' onclick="new_altern_audios(\''.$kay.'\',\'altern-audio-source'
                                 .$upload_audios.'\')" ID="new_altern_audio" style="display:block"/>';
                echo    '</div>';
                echo  '</div>';

                
                echo '</div>';
                $upload_audios++;
            }
            echo '</div>';
            echo '<table class="adminform" width="100%" cellspacing="1" cellpadding="4" border="0">';
            
            ?>
            <td width="232">
                <td ID="a_items">
                  <input  type="button" name="new_audio"
                  value="<?php echo _MEDIALIBRARYLABEL_ADD_NEW_AUDIO_FILE; ?>" onClick="new_audios()"
                  ID="a_add"/>
                </td>
            <td>    
        <?php 
        }


        if ($medialibrary_configuration['emedias']['allow']) {
            echo '<tr><td colspan="2"></td></tr>';
            echo "<tr > <td valign='top' align='right'><strong>" . _MEDIALIBRARY_LABEL_EMEDIA . ":</strong></td>";
            if (count($files) > 0) {
                for ($i = 0;$i < count($files);$i++) {
                    echo "<tr><td align='right'>" . _MEDIALIBRARY_LABEL_EMEDIA_UPLOAD_URL . ($i + 1) . ":";
                    echo "</td><td>";
                    if (isset($files[$i]->location) && substr($files[$i]->location, 0, 4) != "http")
                    echo "<input type='text' size='60' value='" . $mosConfig_live_site . 
                      $files[$i]->location . "' readonly='readonly'/>";
                    elseif (isset($files[$i]->location) && substr($files[$i]->location, 0, 4) == "http")
                    echo "<input type='text' size='60' value='".$files[$i]->location."' readonly='readonly'/>";
                    echo "</td></tr>";
                    echo "<tr><td align='right'>" . _MEDIALIBRARY_LABEL_EMEDIA_DELETE . ":";
                    echo "</td><td>";
                    echo isset($files[$i]->id) ? "<input type=\"checkbox\" name=\"file_option_del" . 
                      $files[$i]->id . "\" value=\"" . $files[$i]->id . "\">" : "";
                    echo "</td></tr>";
                }
            }
            if (count($files) > 0) echo "<td>"; ?>
                        <td ID="f_items">
                            <input  type="button" name="new_file"
                            value="<?php echo "Add new emedia file"; ?>" onClick="new_files()"  ID="f_add"/>
                         </td>
        <?php if (count($files) > 0) echo "<td>";
        }?>


     <!--*****************   begin change review   ********************************-->
     <?php if ($reviews > false) /*show, if review exist*/ { ?>
    <tr>
      <td colspan="7">
        <hr width="100%" size="2" align="left"> <h3><?php echo _MEDIALIBRARY_LABEL_REVIEWS; ?>:</h3>
      </td>
    </tr>
    <table class="adminlist">
      <tr class="row0">
        <td width="3%" valign="top" align="center">
          <div>#</div>
        </td>
        <td width="2%" valign="top" align="center">
          <div></div>
        </td>
        <td width="10%" valign="top" align="center">
          <strong><?php echo _MEDIALIBRARY_LABEL_REVIEW_TITLE; ?>:</strong>
        </td>
        <td width="10%" valign="top" align="center">
          <strong><?php echo _MEDIALIBRARY_LABEL_LEND_USER; ?>:</strong>
        </td>
        <td width="65%" valign="top" align="center">
          <strong><?php echo _MEDIALIBRARY_LABEL_REVIEW_COMMENT; ?>:</strong>
        </td>
        <td width="5%" valign="top" align="center">
          <strong><?php echo _MEDIALIBRARY_LABEL_PUB_DATE; ?>:</strong>
        </td>
        <td width="5%" valign="top" align="center">
          <strong><?php echo _MEDIALIBRARY_LABEL_REVIEW_RATING; ?>:</strong>
        </td>
      </tr>
    <?php for ($i = 0, $nn = 1;$i < count($reviews);$i++, $nn++) /*if not one comment*/ { ?>
      <tr class="row0">
        <td valign="top" align="center">
          <div><?php echo $nn; ?></div>
        </td>
        <td valign="top" align="center">
          <div>
          <?php echo "<input type='radio' id='cb" . $i . "' name='bid[]' value='" . 
            $medialibrary->id . "," . $reviews[$i]->id . "' onclick='Joomla.isChecked(this.checked);' />"; ?>
          </div>
        </td>
        <td valign="top" align="center">
          <div><?php print_r($reviews[$i]->title); ?></div>
        </td>
        <td valign="top" align="left">
          <div><?php print_r($reviews[$i]->name); ?></div>
        </td>
        <td valign="top" align="left">
            <div><?php print_r(strip_tags($reviews[$i]->comment)); ?></div>
            </td>
        <td valign="top" align="left">
          <div><?php print_r($reviews[$i]->date); ?></div>
        </td>
        <td valign="top" align="left">
          <div><img src="../components/com_medialibrary/images/rating-<?php 
            echo $reviews[$i]->rating; ?>.gif" alt="<?php echo ($reviews->rating[$i]) / 2; ?>" 
            border="0" align="right"/>&nbsp;</div>
        </td>
      </tr>
        <?php
            } /*end for(...)*/ ?>

    </table>
    <?php
        } /*end if(...)*/ ?>

    </table>
    <input type="hidden" name="id" value="<?php echo $medialibrary->id; ?>" />
    <input type="hidden" name="media_id" value="<?php echo $media_class->id; ?>" />
    <input type="hidden" name="option" value="<?php echo $option; ?>" />
    <input type="hidden" id="media_type_field" name="media_type" value="<?php 
      echo $medialibrary->media_type; ?>" />
    <input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="task" value="" />
    
    </form>

    <!-- ***********************   end change review   ****************************** -->

    <?php
    }

    //show(edit) music
    static function editing_music($option, $medialibrary, $media_class, $clist, $wslist, 
      $langlist, $ratinglist, $delete_edocument,
      $reviews, $type_list, $langshow = null, $files, $videos, $audios, $tracks, $youtubeCode,
      $youtubeId,$associateArray, $artistshow) {
        global $my, $mosConfig_live_site, $mainframe, $medialibrary_configuration;
        global $doc, $database; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_SHOW . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;

?>
    <script language="javascript" type="text/javascript">

    function type_select(){
      var el = document.forms["adminForm"].elements["task"];
      el.value = "add";
      el = document.getElementById("media_type_field");
      var el2 = document.getElementById("media_type");
      el.value = el2.options[el2.selectedIndex].value;
      el = document.forms["adminForm"];
      el.submit();
      return ;
    }

    function findPosY(obj) {
      var curtop = 0;
      if (obj.offsetParent) {
          while (1) {
              curtop+=obj.offsetTop;
              if (!obj.offsetParent) {
                  break;
              }
              obj=obj.offsetParent;
          }
      } else if (obj.y) {
          curtop+=obj.y;
      }
      return curtop-20;
    }

 function trim(string) {return string.replace(/(^\s+)|(\s+$)/g, "");}

    Joomla.submitbutton = function(pressbutton) {

    var form = document.adminForm;
    var el = document.getElementById("media_type_field");
    el.value = "music";

    var post_max_size = <?php echo return_bytes(ini_get('post_max_size')) ?>;
    var upl_max_fsize = <?php echo return_bytes(ini_get('upload_max_filesize')) ?>;
    var file_upl = <?php echo ini_get('file_uploads') ?>;
    var title = document.getElementById('title').value;
    var artists = document.getElementById("new_artist_select").value;// for J 1.6
    var artistsName = document.getElementById("new-artist-field").value;// for J 1.6
    var informationFrom = document.adminForm.informationFrom.value;

    if (pressbutton == 'save' || pressbutton =='apply') {
        if (trim(form.asin_isbn.value) == '') {
            window.scrollTo(0,findPosY(form.asin_isbn)-100);
            form.asin_isbn.placeholder = "<?php
            echo _MEDIALIBRARY_ADMIN_INFOTEXT_JS_EDIT_ISBN_ASIN_CHECK; ?>";
            form.asin_isbn.style.borderColor = "#FF0000";
            form.asin_isbn.style.color = "#FF0000";
            return;
        } else if (form.catid.value == '0') {
            window.scrollTo(0,findPosY(form.catid)-100);
            form.catid.style.borderColor = "#FF0000";
            form.catid.style.color = "#FF0000";
            return;
        }
        else if ((title == '0' || title == '') && informationFrom == 0) {
                window.scrollTo(0,findPosY(form.title)-100);
                form.title.style.borderColor = "#FF0000";
                alert( "<?php echo _MEDIALIBRARY_LABEL_B_TITLE; ?>");
            return;
        } 
        else if ((artists == '0' || artists == '') && informationFrom == 0) {
            if (artistsName == '0' || artistsName == '') { 
                window.scrollTo(0,findPosY(artists)-100);
                alert( "<?php echo _MEDIALIBRARY_ADMIN_INFOTEXT_JS_EDIT_ARTIST; ?>");
                return;
            }
        }

        for (i=1; document.getElementById('new_upload_video'+i); i++){
        if(document.getElementById('new_upload_video'+i).files != null){
            if(!file_upl){
              window.scrollTo(0,findPosY(document.getElementById('new_upload_video'+i))-100);
              document.getElementById('error_video').innerHTML = "<?php
              echo _MEDIALIBRARY_ADMIN_SETTINGS_VIDEO_ERROR_UPLOAD_OFF; ?>";
              document.getElementById('new_upload_video'+i).style.borderColor = "#FF0000";
              document.getElementById('new_upload_video'+i).style.color = "#FF0000";
              document.getElementById('error_video').style.color = "#FF0000";
              return;
            }
            if(document.getElementById('new_upload_video'+i).files.length != 0 &&
               document.getElementById('new_upload_video_youtube_code'+i).value != null) {
            if(document.getElementById('new_upload_video'+i).files[0].size >= post_max_size){
              window.scrollTo(0,findPosY(document.getElementById('new_upload_video'+i))-100);
              document.getElementById('error_video').innerHTML = "<?php
              echo _MEDIALIBRARY_ADMIN_SETTINGS_VIDEO_ERROR_POST_MAX_SIZE; ?>";
              document.getElementById('new_upload_video'+i).style.borderColor = "#FF0000";
              document.getElementById('new_upload_video'+i).style.color = "#FF0000";
              document.getElementById('error_video').style.color = "#FF0000";
              return;
            }
          }
          if(document.getElementById('new_upload_video'+i).files.length != 0 &&
             document.getElementById('new_upload_video_youtube_code'+i).value != null) {
            if(document.getElementById('new_upload_video'+i).files[0].size >= upl_max_fsize){
              window.scrollTo(0,findPosY(document.getElementById('new_upload_video'+i))-100);
              document.getElementById('error_video').innerHTML = "<?php
              echo _MEDIALIBRARY_ADMIN_SETTINGS_VIDEO_ERROR_UPLOAD_MAX_SIZE; ?>";
              document.getElementById('new_upload_video'+i).style.borderColor = "#FF0000";
              document.getElementById('new_upload_video'+i).style.color = "#FF0000";
              document.getElementById('error_video').style.color = "#FF0000";
              return;
            }
        }
      }
  }
      if(form.new_upload_track_url1){
      for (i = 1;form.getElementById('new_upload_track_url'+i); i++) {
        if(form.getElementById('new_upload_track'+i).value != ''
          || form.getElementById('new_upload_track_url'+i).value != ''){
            if(form.getElementById('new_upload_track_kind'+i).value == ''){
              window.scrollTo(0,findPosY(document.getElementById('new_upload_track_kind'+i))-100);
              document.getElementById('new_upload_track_kind'+i).placeholder = "<?php
                echo _MEDIALIBRARY_ADMIN_SETTINGS_INFOTEXT_JS_TRACK_KIND; ?>";
              document.getElementById('new_upload_track_kind'+i).style.borderColor = "#FF0000";
              document.getElementById('new_upload_track_kind'+i).style.color = "#FF0000";
              return;
            }else if(form.getElementById('new_upload_track_scrlang'+i).value == ''){
              window.scrollTo(0,findPosY(document.getElementById('new_upload_track_scrlang'+i))-100);
              document.getElementById('new_upload_track_scrlang'+i).placeholder = "<?php
                echo _MEDIALIBRARY_ADMIN_SETTINGS_INFOTEXT_JS_TRACK_LANGUAGE; ?>";
              document.getElementById('new_upload_track_scrlang'+i).style.borderColor = "#FF0000";
              document.getElementById('new_upload_track_scrlang'+i).style.color = "#FF0000";
              return;
            }else if(form.getElementById('new_upload_track_label'+i).value == ''){
              window.scrollTo(0,findPosY(document.getElementById('new_upload_track_label'+i))-100);
              document.getElementById('new_upload_track_label'+i).placeholder = "<?php
                echo _MEDIALIBRARY_ADMIN_INFOTEXT_JS_TRACK_TITLE; ?>";
              document.getElementById('new_upload_track_label'+i).style.borderColor = "#FF0000";
              document.getElementById('new_upload_track_label'+i).style.color = "#FF0000";
              return;
            }
        }
    }
      submitform(pressbutton);
    }else {
      submitform(pressbutton);
    }
 } else {
      submitform( pressbutton );
    }
 }

    </script>
    <form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
    <table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform">
      <!-- anton code type -->
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?>:</strong>
      </td>
      <td align="left">
        <?php echo $type_list; ?>
      </td>
    </tr>
    <!-- anton code -->
    <tr>
      <td width="15%" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_MUSICID; ?>:</strong>
      </td>
      <td width="85%" align="left">
        <input class="inputbox" type="text" name="media_type_id" size="20" maxlength="20" 
          value="<?php echo $media_class->music_id; ?>" />
      </td>
    </tr>
    <tr>
      <td width="20%" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_ASIN; ?>*:</strong>
      </td>
      <td align="left">
        <input class="inputbox" type="text" name="asin_isbn" size="20" maxlength="20" 
          value="<?php echo $media_class->asin; ?>" />
      </td>
    </tr>



    <?php
      /*******************************************    language    ***********************************************/
      if (!empty($associateArray) && !empty($media_class->langDescription) && $media_class->langDescription != ''
                                  && $media_class->langDescription != '*') {
      ?>
              <tr>
                  <td width="15%"><?php echo 'language associate media' ?>:</td>
              </tr>
    <?php
          $j = 1;
          foreach($associateArray as $lang => $value) {
              $displ = '';
              if (!$value['list']) {
                  $displ = 'none';
              }
    ?>
              <tr style="display: <?php echo $displ ?>">
                  <td width="15%"><?php echo $lang; ?>:</td>
                  <td width="60%"><?php echo $value['list']; ?>

                  <input class="inputbox" id="associate_media" type="text"
                          name="associate_media<?php echo $j; ?>" size="20"
                          readonly="readonly" maxlength="20" style="width:25px;"
                          value="<?php echo $value['assocId']; ?>" />
                  <input style="display: none" name="associate_media_lang<?php echo $j; ?>"
                          value="<?php echo $lang ?>"/>
                  </td>
              </tr>
    <?php
              $j++;
          }
      } else {
    ?>
              <tr>
                  <td width="15%"><?php echo 'language associate media' ?>:</td>
                  <td width="60%"><?php echo 'this property only for media with language' ?>
              </tr>
    <?php
      }
      /*********************************************************************************************/
    ?>





    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_LANGUAGE; ?>:</strong>
      </td>
      <td align="left">
        <?php echo $langlist; ?>
      </td>
    </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_LANGUAGE_DESCRIPTION; ?>:</strong>
      </td>
      <td align="left">
        <?php echo $langshow; ?>
      </td>
    </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_CATEGORY; ?>*:</strong>
      </td>
      <td align="left">
        <?php echo $clist; ?>
      </td>
    </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_FETCH_INFO; ?>:</strong>
      </td>
      <td align="left">
        <?php echo $wslist; ?>
        &nbsp;&nbsp;&nbsp;<img src="../components/com_medialibrary/images/amazon/com-logo.gif" 
          alt="amazon.com" border="0"/>
       </td>
    </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_COMMENT; ?>:</strong>
      </td>
      <td align="left">
        <?php
        editorArea('editor1', $media_class->comment, 'comment', 500, 250, '70', '10');
?>
        <!--<textarea name="comment" id="comment" cols="50" rows="25" style="width:800;height:200;"><?php 
          /*echo $row->comment;*/ ?></textarea>-->
      </td>
    </tr>
    <tr>
        <td width="185"></td>
        <td><span id="error_video"></span></td>
    </tr>
    <tr>
      <td valign="top" align="right">&nbsp;
      </td>
      <td align="left">
        <?php echo _MEDIALIBRARY_ADMIN_TEXT_WSINFO_TEXT1; ?>
        <strong>
        <?php echo _MEDIALIBRARY_LABEL_FETCH_INFO; ?>
        ->
        <?php echo _MEDIALIBRARY_WS_NO; ?>
        </strong>
      </td>
    </tr>
      <!-- anton code type -->
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_TITLE; ?>*:</strong>
      </td>
      <td align="left">
        <input class="inputbox" type="text" id="title" name="title" size="80" value="<?php
             echo $media_class->title; ?>" />
      </td>
    </tr>

    <tr>
        <td valign="top" align="right"><strong>
            <?php echo _MEDIALIBRARY_LABEL_ARTIST; ?>:</strong></td>
        <td align="left">
            <div class="toggle-artist">
                <?php echo $artistshow;?>
            </div>
            <input type="text" name="new_artist_field" class="new-artist-field toggle-artist" 
                   id="new-artist-field" style="display: none;"></input>
            <div style="clear: both;"></div>
            <input type="button" id="switch-enter-artist" value="Change artist field."
                   onclick="jQuery('.toggle-artist').toggle('slow')" <?php 
                   if($medialibrary->get('informationFrom')) echo ' style="display: none;"';?>></input>
        </td>
</tr>


    <!-- ***********block music************* -->
  <!--  <tr >
      <td valign="top" align="right">
        <strong><?php //echo _MEDIALIBRARY_LABEL_ARTIST; ?>:</strong>
      </td>
      <td align="left">
        <input class="inputbox" type="text" name="artist" size="80" value="<?php
             //echo $media_class->artist; ?>" />
      </td>
    </tr>-->
    <tr  >
      <td valign="top" align="right">
      <strong><?php echo _MEDIALIBRARY_RELEASE_DATA; ?>:</strong>
      </td>
      <td align="left">
        <input class="inputbox" type="text" name="release_date" size="80" 
          value="<?php echo $media_class->release_date; ?>" />
      </td>
    </tr>
    <tr >
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_NUMBER_OF_DISCS; ?>:</strong>
      </td>
      <td align="left">
        <input  class="inputbox" type="text" name="number_of_discs" size="80" 
          value="<?php echo $media_class->number_of_discs; ?>" />
      </td>
    </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_LABEL; ?>:</strong>
      </td>
      <td align="left">
        <input  class="inputbox" type="text" name="label" size="80" value="<?php echo $media_class->label; ?>" />
      </td>
    </tr>
    <tr >
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_BINDING; ?>:</strong>
      </td>
      <td align="left">
        <input  class="inputbox" type="text" name="binding" size="80" 
          value="<?php echo $media_class->binding; ?>" />
      </td>
    </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_TRACKLIST; ?>:</strong>
      </td>
      <td align="left">
        <input  class="inputbox" type="text" name="tracklist" size="80"
           value="<?php echo $media_class->tracklist; ?>" />
      </td>
    </tr>

    <!-- ***********block************* -->
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_PRICE; ?>:</strong>
      </td>
      <td align="left">
        <input  class="inputbox" type="text" name="price" size="15" value="<?php echo $media_class->price; ?>" />
        <input  class="inputbox" type="text" name="priceunit" size="6" value="<?php 
            echo $media_class->priceunit; ?>" />
     </td>
    </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_RATING; ?>:</strong>
      </td>
      <td align="left">
        <?php echo $ratinglist; ?>
      </td>
    </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_PICTURE_URL; ?>:</strong>
      </td>
      <!-- /////////////////////////////ANTON CODE///////////////////-->
          <!-- /////////////////////////////Begin AddPatch CODE///////////////////-->
      <td align="left">
        <input  class="inputbox" type="text" name="imageURL" size="80"
          value="<?php echo $media_class->imageURL; ?>" />
        <input  class="inputbox" type="button" name="default_patch"
          value="Set Local Cover Path" onClick="build_patch()" />

        <script type="text/javascript" language="javascript">
        function build_patch()
        {
          var asin_isbn = "<?php echo $media_class->asin; ?>" ;
          var url = 'components/com_medialibrary/asin_isbn_build.php';
          <?php $cover_path = $medialibrary_configuration['fetchImages']['location']; ?>
          var cover_path = "<?php echo $cover_path; ?>";
          if (window.XMLHttpRequest)
          {
            // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType)
            {
              http_request.overrideMimeType('text/xml');
            }
          }
          else if (window.ActiveXObject)
          {
            // IE
            try
            {
              http_request = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e)
            {
              try
              {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
              }
              catch (e)
              {}
            }
          }
          if (!http_request)
          {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
          }
          http_request.onreadystatechange = alertContents;
          http_request.open("POST", url, true);
          http_request.setRequestHeader('Content-Type' , 'application/x-www-form-urlencoded');
          http_request.send('asin_isbn='+asin_isbn+'&cover_path='+cover_path);
        }
        function alertContents()
        {
          if (http_request.readyState == 4)
          {
            if (http_request.status == 200)
            {
              if (http_request.responseText == 1)
              {
                alert("<?php echo _MEDIALIBRARY_TOOLBAR_NEW_MEDIA_INCORRECT_FOLDER . " " . $cover_path; ?>");
              }
              if (http_request.responseText == false)
              {
                alert("<?php echo _MEDIALIBRARY_TOOLBAR_NEW_MEDIA_INCORRECT_FILE; ?>");
              }
              else
              {
                document.adminForm.imageURL.value = http_request.responseText;
              }
            }
            else
            {
              alert('There was a problem with the request.');
            }
          }
        }
        jQuery('#informationFrom').change(function() {
            var amazonServ = jQuery('#informationFrom').val();
            if (amazonServ === '0'){
                jQuery('#switch-enter-artist').css('display', 'block');
            } else {
                jQuery('#switch-enter-artist').css('display', 'none');
            }
        });
        </script>

        <script language="javascript" type="text/javascript">
        window.onload = function(){
        var button_video = document.getElementById("v_add");
        var allowed_vid_files = 5;
        <?php if (count($videos) > 0) echo "allowed_files = " . (5 - count($videos)) . ";"; ?>
        if(allowed_vid_files >= 1) {
           button_video.removeAttribute("style");
        }
        var button_audio = document.getElementById("a_add");
        var allowed_aud_files = 5;
        <?php if (count($audios) > 0) echo "allowed_files = " . (5 - count($audios)) . ";"; ?>
        if(allowed_aud_files >= 1) {
           button_audio.removeAttribute("style");
        }
        // for (var i=1; i < 5; i++) {
        // var add =  document.getElementById('new_upload_video_youtube_code'+i).value;
        //   if(add.length){
        //     var obj = document.getElementById('v_add');
        //     obj.style.display = "none";
        //    }
        // }
      }

  </script>

      </td>
    </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_PICTURE_URL_UPLOAD; ?>:</strong>
            </td>
            <td align="left">
              <input class="inputbox" type="file" name="picture_file" value="" size="50" maxlength="250" />
              <br /><?php echo _MEDIALIBRARY_LABEL_PICTURE_URL_DESC; ?>
      <?php
        if ($media_class->imageURL != "" && !strstr($media_class->imageURL, "http")) {
            echo '<div><img class="bl_view_media_image" src="' . $mosConfig_live_site . '' 
                . $media_class->imageURL .
                '" alt="' . $media_class->title . '" border="0"
                              height="' . $medialibrary_configuration['foto']['high'] . '" width="' .
                              $medialibrary_configuration['foto']['width'] .
                '"/></div>';
        } else if ($media_class->imageURL != "" && strstr($media_class->imageURL, "http")) {
            echo '<div><img class="bl_view_media_image" src="' . $media_class->imageURL . '" alt="' .
                $media_class->title . '" border="0"
                height="' . $medialibrary_configuration['foto']['high'] . '" width="' .
                $medialibrary_configuration['foto']['width'] .
                  '"/></div>';
        }
    ?>
        </td>
    </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_URL; ?>:</strong>
      </td>
      <td align="left">
        <input class="inputbox" type="text" name="URL" size="80" value="<?php echo $media_class->URL; ?>" />
      </td>
    </tr>
         <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_MEDIAOWNER; ?>:</strong>
            </td>
            <td valign="top" align="left">
               <input class="inputbox" type="text" name="owneremail" size="50" 
                value="<?php echo $medialibrary->owneremail; ?>"/>
            </td>
        </tr>

        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_MEDIAOWNER_ID; ?>:</strong>
            </td>
            <td align="left">
            <?php echo $medialibrary->name = JFactory::getUser($medialibrary->owner_ID)->name; ?>
            <?php $user = JFactory::getUser();?>
            <input type="text" name="owner_ID" size="80" value="<?php if(!$medialibrary->owner_ID) {
                            echo $user->id;
                        } else {
                            echo $medialibrary->owner_ID;
                        } ?>" />
            </td>
        </tr>

   <!---------------------------------Start AJAX load track------------------------------>

  <script language="javascript" type="text/javascript">
                var request = null;
                var tid=1;
                function createRequest_track() {
                    if (request != null)
                    return;
                    try {
                       request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                           request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }

                function testInsert_track(id1,upload){
                    for(var i=1; i< upload_tracks; i++){
                        if(upload.id != ('new_upload_track'+i) &&
                        document.getElementById('new_upload_track'+i).value == upload.value){
                            return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1_track(id1,upload){
                    id=id1;
                    if(testInsert_audio(id1,upload)){
                        createRequest_track();
                        var url = "<?php echo $mosConfig_live_site . 
                          "/administrator/index.php?option=$option&task=randNumber&format=raw";
                        ?>&file="+encodeURI(upload.value)+"&path=<?php
                        echo str_replace("\\", "/", $mosConfig_live_site) 
                            . '/components/com_medialibrary/media/track/'?>";
                       try{
                        request.onreadystatechange = updateRandNumber1_track;
                        request.open("GET", url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert("You alredy select this track file");
                        upload.value="";
                    }
                }

                function updateRandNumber1_track() {
                    if (request.readyState == 4) {
                        document.getElementById("randNumTrack"+tid).innerHTML = request.responseText;
                    }
                }
  </script>

 <!-------------------------------- END Ajax load track---------------------------------->


 <!-------------------------------- END Ajax load audio---------------------------------->
  <script language="javascript" type="text/javascript">
                var request = null;
                var aid=1;
                function createRequest_audio() {
                    if (request != null)
                    return;
                    try {
                          request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                           request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }

                function testInsert_audio(id1,upload){
                    for(var i=1; i< upload_audios; i++){
                        if(upload.id != ('new_upload_audio'+i) &&
                        document.getElementById('new_upload_audio'+i).value == upload.value){
                            return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1_audio(id1,upload){
                    id=id1;
                    if(testInsert_audio(id1,upload)){
                        createRequest_audio();
                        var url = "<?php echo $mosConfig_live_site .
                           "/administrator/index.php?option=$option&task=randNumber&format=raw";
                        ?>&file="+encodeURI(upload.value)+"&path=<?php
                        echo str_replace("\\", "/", $mosConfig_live_site) . 
                          '/components/com_medialibrary/media/audio/'?>";
                       try{
                        request.onreadystatechange = updateRandNumber1_audio;
                        request.open("GET", url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert( "You alredy select this audio file");
                        upload.value="";
                    }
                }

                function updateRandNumber1_audio(){
                    if (request.readyState == 4) {
                        document.getElementById("randNumAudio"+aid).innerHTML = request.responseText;
                    }
                }
  </script>

<!-------------------------------- END Ajax load audio---------------------------------->


<!-------------------------------- START Ajax load video---------------------------------->


            <script language="javascript" type="text/javascript">

               var request = null;
               var vid=1;

               function createRequest_video(){
                    if (request != null)
                    return;
                    try {
                       request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                            request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }

                function testInsertVideo1(id1,upload){
                    for(var i=1 ;i< upload_videos; i++){
                        if(upload.id != ('new_upload_video'+i) &&
                        document.getElementById('new_upload_video'+i).value == upload.value)
                        {
                          return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1_video(id1,upload){
                    id=id1;
                    if(testInsertVideo1(id1,upload)){
                        createRequest_video();
                    var url = "<?php echo $mosConfig_live_site . 
                      "/administrator/index.php?option=$option&task=randNumber&format=raw";
                    ?>&file="+encodeURI(upload.value)+"&path=<?php echo str_replace("\\", "/", $mosConfig_live_site) .
                       '/components/com_medialibrary/media/video/'?>";
                       try{
                        request.onreadystatechange = updateRandNumber1_video;
                        request.open("GET",url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert("You alredy select this video file");
                        upload.value="";
                    }
                }

                function updateRandNumber1_video() {
                    if (request.readyState == 4) {
                        document.getElementById("randNumVideo"+vid).innerHTML = request.responseText;
                    }
                }
                </script>


  <!-------------------------------- END Ajax load video---------------------------------->


  <!---------------------------------Start AJAX load file------------------------------>


                <script language="javascript" type="text/javascript">

                var request = null;
                var fid=1;
                function createRequest() {
                    if (request != null)
                    return;
                    try {
                        request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                               request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }


                function testInsertFile1(id1,upload){
                    for(var i=1; i< upload_files; i++){
                        if(upload.id != ('new_upload_file'+i) &&
                        document.getElementById('new_upload_file'+i).value==upload.value){
                            return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1(id1,upload) {
                    id=id1;
                    if(testInsertFile1(id1,upload)){
                        createRequest();
                        var url = "<?php echo $mosConfig_live_site . 
                          "/administrator/index.php?option=$option&task=randNumber&format=raw";
                        ?>&file="+encodeURI(upload.value)+"&path=<?php
                        echo str_replace("\\", "/", $mosConfig_live_site) . 
                          '/components/com_medialibrary/emedia/'?>";
                        try{
                        request.onreadystatechange = updateRandNumber1;
                        request.open("GET",url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert( "You alredy select this file");
                        upload.value="";
                    }
                }
                function updateRandNumber1() {
                    if (request.readyState == 4) {
                        document.getElementById("randNumFile"+fid).innerHTML = request.responseText;
                    }
                }
                </script>

<!-------------------------------- END Ajax load file ---------------------------------->


   <script language="javascript" type="text/javascript">
    var upload_tracks=0;
    function new_tracks(index, div0){
        // div=document.getElementById("t_items");
        // button=document.getElementById("t_add");
        div = document.getElementById(div0);
        button=document.getElementById(div0);
        upload_tracks++;
        newitem="<table width='50%'><tr><td width='15%'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_LABEL_TRACK_UPLOAD ?>"+upload_tracks+": </strong></td>";
        newitem+="<td width='85%'>";
        newitem+="<input type='hidden' name='new_upload_track"+upload_tracks;
        newitem+="' value='"+index+"' />";
        
        newitem+="<input style=\"float:left; width:100%\" type=\"file\" "+
        "onClick=\"document.adminForm.new_upload_track"+upload_tracks+".value ='';\" " +
        " onChange=\"refreshRandNumber1_track("+upload_tracks+
        ",this);\"  name=\"new_upload_track"+upload_tracks+"\" "+"id=\"new_upload_track"+upload_tracks;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumTrack"+upload_tracks+"\" ";
        newitem+="style=\"color:red;\"></span></td></tr></td></tr>"+ "<tr><td ";
        newitem+="style=\"text-align:center\"> OR </td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        newitem="<table width='50%'><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_TRACK_UPLOAD_URL; ?>" +upload_tracks+ ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
          "name=\"new_upload_track_url"+upload_tracks+"\" "+"id=\"new_upload_track_url"+upload_tracks;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        div.appendChild(newnode,button);
        newitem="<table width='50%' style=\"display:none;\"><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_CONFIG_TRACK_UPLOAD_KIND; ?>" +upload_tracks+ ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left;display:none; width:90%\" type=\"text\" "+
          "name=\"new_upload_track_kind"+upload_tracks+"\" "+"id=\"new_upload_track_kind"+upload_tracks;
        newitem+="\" value=\"eng\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        div.appendChild(newnode,button);
        newitem="<table width='50%'><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_TRACK_UPLOAD_SCRLANG; ?>" +upload_tracks+ ": ";
        newitem+="</strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
          " name=\"new_upload_track_scrlang"+upload_tracks+"\" ";
        newitem+="id=\"new_upload_track_scrlang"+upload_tracks;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        div.appendChild(newnode,button);
        newitem="<table width='50%' style=\"display:none;\"><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_TRACK_UPLOAD_LABEL; ?>" +upload_tracks+ ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
        "name=\"new_upload_track_label"+upload_tracks+"\" "+"id=\"new_upload_track_label"+upload_tracks;
        newitem+="\" value=\"eng\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
    }
    </script>

  <script language="javascript" type="text/javascript">
    var upload_videos=0;
    function new_videos(){
        div=document.getElementById("v_items");
        button=document.getElementById("v_add");
        upload_videos++;
        newitem="<table width='50%'><tr><td width='160px'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD ?>" +upload_videos+ ": </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:150%\" type=\"file\" "+
        " onClick=\"document.adminForm.new_upload_video_url"+upload_videos+".value ='';\" " +
        " onChange=\"refreshRandNumber1_video("+upload_videos+
        ",this);\" name=\"new_upload_video"+upload_videos+"\" "+"id=\"new_upload_video"+upload_videos;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumVideo"+upload_videos+"\" style=\"color:red;\"></span></td></tr></td></tr>"
        +"<tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD_URL; ?>" +upload_videos+ ": </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" ";
        newitem+=" name=\"new_upload_video_url"+
          upload_videos+"\" "+"id=\"new_upload_video_url"+upload_videos;
        newitem+="\" value=\"\"size=\"45\"></td></tr></td></tr></td></tr>"+
          "<tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD_YOUTUBE_CODE; ?>" + ": </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" ";
        newitem+="name=\"new_upload_video_youtube_code"+upload_videos+"\" ";
        newitem+="id=\"new_upload_video_youtube_code"+upload_videos;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        var allowed_files = 5;
        // if(upload_videos + <?php echo count($videos); ?> >= allowed_files) {
        //  button.setAttribute("style","display:none");
        // }
    }
  </script>

   <script language="javascript" type="text/javascript">
    var upload_video_altern_id=1;
    function new_altern_videos(index, div0){
        div = document.getElementById(div0);
        button=document.getElementById(div0);
        upload_altern_videos = index;
        newitem="<table width='50%'><tr><td width='160px'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD ?>: </strong></td>";
        newitem+="<td width='400px'>";
        //newitem+="<input type='hidden' name='new_upload_altern_video"+upload_video_altern_id;
        //newitem+="' value='"+index+"' />";
        newitem+="<input type='hidden' name='new_upload_altern_video"+upload_video_altern_id+"' ";
        newitem+=" value='"+index+"' />";
        newitem+="<input style=\"float:left; width:150%\" type=\"file\" "+
        " onClick=\"document.adminForm.new_upload_altern_video_url"+upload_altern_videos+".value ='';\" " +
        " onChange=\"refreshRandNumber1_video("+upload_altern_videos+
        ",this);\" name=\"new_upload_altern_video"+upload_video_altern_id+"\" ";
        newitem+="id=\"new_upload_altern_video"+upload_video_altern_id;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumVideo"+upload_video_altern_id+"\" ";
        newitem+="style=\"color:red;\"></span></td></tr></td></tr>"
        +"<tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD_URL; ?>: </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" ";
        newitem+="name=\"new_upload_altern_video_url"+
          upload_altern_videos+"\" "+"id=\"new_upload_altern_video_url"+upload_altern_videos;
        newitem+="\" value=\"\"size=\"45\"></td></tr></td></tr></td></tr>"+
          "<tr><td style=\"text-align:center\"></td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        // var allowed_files = 5;
        // if(upload_altern_videos + <?php echo count($videos); ?> >= allowed_files) {
        //  button.setAttribute("style","display:none");
        // }
        upload_video_altern_id++;
    }
  </script>

  <script language="javascript" type="text/javascript">
    var upload_audios=0;
    function new_audios(){
        div=document.getElementById("a_items");
        button=document.getElementById("a_add");
        upload_audios++;
        newitem="<table width='50%'><tr><td width='15%'><strong style=\"float:left\">" + 
          "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD ?>" + upload_audios + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:100%\" type=\"file\" "+
          "onClick=\"document.adminForm.new_upload_audio_url"+upload_audios+".value ='';\" " +
        " onChange=\"refreshRandNumber1_audio("+upload_audios+
        ",this);\"  name=\"new_upload_audio"+upload_audios+"\" "+"id=\"new_upload_audio"+upload_audios;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumAudio"+upload_audios+"\" style=\"color:red;\"></span></td></tr>"+
        "<tr><td style=\"text-align:center\"> OR </td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='15%'><strong>" + 
          "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD_URL; ?>" + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
          "name=\"new_upload_audio_url"+upload_audios+"\" "+"id=\"new_upload_audio_url"+upload_audios;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br />";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
         var allowed_aud_files = 5;
        if(upload_audios + <?php echo count($audios); ?> >= allowed_aud_files) {
         button.setAttribute("style","display:none");
        }
    }
  </script>

   <script language="javascript" type="text/javascript">
    var upload_audio_altern_id=1;
    function new_altern_audios(index, div0){
        div = document.getElementById(div0);
        button=document.getElementById(div0);
        upload_altern_audios = index;
        newitem="<table width='50%'><tr><td width='160px'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD ?>: </strong></td>";
        newitem+="<td width='400px'>";
        //newitem+="<input type='hidden' name='new_upload_altern_audio"+upload_audio_altern_id+"' ";
        //newitem+="value='"+index+"' />";
        newitem+="<input type='hidden' name='new_upload_altern_audio"+upload_audio_altern_id+"' ";
        newitem+="value='"+index+"' />";
        newitem+="<input style=\"float:left; width:150%\" type=\"file\" "+
        " onClick=\"document.adminForm.new_upload_altern_audio_url"+upload_altern_audios+".value ='';\" " +
        " onChange=\"refreshRandNumber1_audio("+upload_altern_audios+
        ",this);\" name=\"new_upload_altern_audio"+upload_audio_altern_id+"\" ";
        newitem+="id=\"new_upload_altern_audio"+upload_audio_altern_id;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumaudio"+upload_audio_altern_id+"\" ";
        newitem+="style=\"color:red;\"></span></td></tr></td></tr>"
        +"<tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD_URL; ?>: </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" ";
        newitem+="name=\"new_upload_altern_audio_url"+
          upload_altern_audios+"\" "+"id=\"new_upload_altern_audio_url"+upload_altern_audios;
        newitem+="\" value=\"\"size=\"45\"></td></tr></td></tr></td></tr>"+
          "<tr><td style=\"text-align:center\"></td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        // var allowed_files = 5;
        // if(upload_altern_audios + <?php echo count($audios); ?> >= allowed_files) {
        //  button.setAttribute("style","display:none");
        // }
        upload_audio_altern_id++;
    }
  </script>
  

 <script language="javascript" type="text/javascript">
    var upload_files=0;
    function new_files(){
        div=document.getElementById("f_items");
        button=document.getElementById("f_add");
        upload_files++;
        newitem="<table width='50%'><tr><td width='15%'><strong style=\"float:left\">" + 
          "<?php echo _MEDIALIBRARY_ADMIN_LABEL_EBOOK_UPLOAD ?>" + upload_files + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:100%\" type=\"file\" "+
        "onClick=\"document.adminForm.new_upload_file_url"+upload_files+".value ='';\" " +
        " onChange=\"refreshRandNumber1("+upload_files+
        ",this);\"  name=\"new_upload_file"+upload_files+"\" "+"id=\"new_upload_file"+upload_files;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumFile"+upload_files+"\" style=\"color:red;\"></span></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='15%'><strong>" + 
          "<?php echo _MEDIALIBRARY_ADMIN_LABEL_EBOOK_UPLOAD_URL; ?>" + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
          "name=\"new_upload_file_url"+upload_files+"\" "+"id=\"new_upload_file_url"+upload_files;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br><br />";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
    }
  </script>

    <?php
    if ($medialibrary_configuration['videos_tracks']['allow']) {
            if (count($videos) > 0 ) {
                 $upload_videos = 1;
                $upload_sourcess = 1;
                $video_queue = [];
                foreach ($videos as $kay => $value) {
                    if ($value->sequence_number){
                        $video_queue[$value->sequence_number][] = $value;
                    } else {
                        $video_queue[$value->id][] = $value;
                    }
                }
                foreach ($video_queue as $kay => $videos) {
                    echo '</table>';
                    echo '<div class="upload_video-items" style="margin-left:243px">';
                    if (empty($videos[0]->youtube)) {
                    echo '<div class="upload_video-item">';
                    //echo '<img src="'.$media_class->imageURL.'" alt="image upload video">';
                    echo '<div style="position: absolute; margin: 8px 0 0 -112px;">'
                            ._MEDIALIBRARY_LABEL_VIDEO.$upload_videos.":".'</div>';
                    if (isset($videos[0]->title) && $videos[0]->title != '') 
                                echo "<input type='text' name='video_source_title" . $upload_videos . "'
                                  id='video_source_title" . $upload_videos . "' size='60' value='" 
                                  . $videos[0]->title . "' readonly=\"readonly\"/>";
                    echo '<input type="button" name="show_altern_video" class="show-button" ';
                    echo ' value="'._MEDIALIBRARY_CATEGORIES__DETAILS.'"  style="margin: -8px 0 0 5px;" ';
                    echo ' onclick="jQuery(\'#altern-video-source'.$upload_videos.'\').toggle(\'slow\')"/>';
                    
                    echo  '<div id="altern-video-source'.$upload_videos.'" style = "display:none">';
                    for ($i = 0;$i < count($videos);$i++) {
                        echo _MEDIALIBRARY_LABEL_VIDEO_ATTRIBUTE . ($i + 1) . ":";
                            $type_src =  explode('.', $videos[$i]->src);
                            echo  ' '.$type_src[(count($type_src)-1)];

                        echo  '<div class="altern-video-one-source">';
                        if (isset($videos[$i]->src) && substr($videos[$i]->src, 0, 4) != "http" &&
                        empty($videos[$i]->youtube)){
                            echo "<input type='text' name='new_upload_video" . $i . "' id='new_upload_video" . $i 
                                . "' size='60' value='" . $videos[$i]->src . "' readonly='readonly' />";
                        } elseif (isset($videos[$i]->src) && substr($videos[$i]->src, 0, 4) == "http" &&
                        empty($videos[$i]->youtube)){
                            echo "<input type='text' name='new_upload_video" .  $i 
                                . "' id='new_upload_video_url" . $i 
                                . "' size='60' value='" . $videos[$i]->src . "' readonly='readonly' />";
                        }
                        echo _MEDIALIBRARY_LABEL_VIDEO_DELETE . ":";
                        echo isset($videos[$i]->id) ? "<input type=\"checkbox\" name=\"video_option_del" . 
                          $videos[$i]->id . "\" value=\"" . $videos[$i]->id . "\">" : "";
                        echo  '</div>';
                    }?>
                        <div id="upload-altern-video_add_here<?php echo $upload_videos;?>">
                            <span style="display: none;"></span>
                        </div>
                    <?php
                    echo    '<div class="hidden-details upload-altern-video'.$upload_videos.'">';
                    echo    '<input type="button" name="new_altern_video" ';
                    echo    ' value="'._MEDIALIBRARYLABEL_VIDEO_ADD_ALTERNATIVE_VIDEO.'"';
                    echo    ' onclick="new_altern_videos(\''.$kay.'\',\'upload-altern-video_add_here'
                                     .$upload_videos.'\')" ID="new_altern_video" style="display:block"/>';
                    if ($medialibrary_configuration['videos_tracks']['allow']) {
                        echo '<table class="adminform" width="100%" cellspacing="1" cellpadding="4" border="0">';
                        echo '<tr><td colspan="2"></td></tr>';
                        echo "<tr > <td valign='top' align='right'>"./*_MEDIALIBRARY_LABEL_TRACK.":".**/"</td>";
                        if (count($tracks) > 0) {
                            for ($i = 0;$i < count($tracks);$i++) {
                                if($kay == $tracks[$i]->sequence_number){
                                    echo "<tr><td align='right'>" . _MEDIALIBRARY_LABEL_TRACK_UPLOAD_URL
                                         .($i + 1) . ":";
                                    echo "</td><td>";
                                    if (isset($tracks[$i]->src) && substr($tracks[$i]->src, 0, 4) != "http")
                                    echo "<input type='text' class='trackitems' size='60' value='" .
                                        'components/com_medialibrary/media/track/' 
                                        . $tracks[$i]->src . "' readonly='readonly'/>";
                                    elseif (isset($tracks[$i]->src) && substr($tracks[$i]->src, 0, 4) == "http")
                                    echo "<input type='text' class='trackitems' size='60' value='" . 
                                      $tracks[$i]->src . "' readonly='readonly'/>";
                                    // if (!empty($tracks[$i]->kind)) 
                                    //   echo "<input class='trackitems' type='text' size='60' value='" . 
                                    //     $tracks[$i]->kind . "' readonly='readonly'/>";
                                    if (!empty($tracks[$i]->scrlang)) 
                                      echo "<input class='trackitems' type='text' size='60' value='" . 
                                        $tracks[$i]->scrlang . "' readonly='readonly'/>";
                                    // if (!empty($tracks[$i]->label)) 
                                    //   echo "<input class='trackitems' type='text' size='60' value='" . 
                                    //     $tracks[$i]->label . "' readonly='readonly'/>";
                                    echo "</td></tr>";
                                    echo "<tr><td align='right'>"._MEDIALIBRARY_LABEL_TRACK_DELETE.($i + 1).":";
                                    echo "</td><td>";
                                    echo isset($tracks[$i]->id) ? "<input type=\"checkbox\" "
                                            ."name=\"track_option_del" . 
                                      $tracks[$i]->id . "\" value=\"" . $tracks[$i]->id . "\">" : "";
                                    echo "</td></tr>";
                                }
                            }
                        }?>
                        <tr>
                            <td></td>
                            <td id="track_items_add_here<?php echo $upload_videos;?>">
                                <span style="display: none;"></span>
                            </td>
                        </tr>
                        <tr>
                            <td id="t_items">
                                <input  type="button" name="new_track"
                                  value="<?php echo _MEDIALIBRARY_LABEL_ADD_NEW_TRACK; ?>" onClick="<?php 
                                    echo 'new_tracks(\''.$kay.'\',\'track_items_add_here'
                                         .$upload_videos."'"; ?>)" ID="t_add"/>
                            </td>
                        </tr>
                        
                    <?php  echo '</table>';
                        
                    echo    '</div>';
                    echo  '</div>';
                    
                    
                    echo '</div>';
                    $upload_videos++;
                    }
                    }
                    echo "</div>";
                    echo '<table class="adminform" width="100%" cellspacing="1" cellpadding="4" border="0">';
                // }
                // $upload_videos = 1;
                // foreach ($video_queue as $kay => $videos) {
                    if (!empty($videos[0]->youtube)) {
                        echo '<tr><td colspan="2"></td></tr>';
                        $youtubeCode = array('youtube'=> $videos[0]->youtube);
                        for ($i = 0;$i < count($youtubeCode);$i++) {
                            echo "<tr><td align='right' width='230'>"._MEDIALIBRARY_LABEL_VIDEO.' YouTube '
                                .$upload_videos.":";
                            echo "</td><td>";
                            if (isset($videos[0]->title) && $videos[0]->title != '') 
                                echo "<input type='text' name='video_youtube_title" . $upload_videos . "'
                                  id='video_youtube_title" . $upload_videos . "' size='60' value='" 
                                  . $videos[0]->title . "' readonly=\"readonly\"/>";
                            // echo "</td>";
                            // echo "<td>";
                            echo '<input type="button" name="show_altern_video" class="show-button" ';
                            echo ' value="'._MEDIALIBRARY_CATEGORIES__DETAILS.'" style="margin: -8px 0 0 5px;" ';
                            echo ' onclick="jQuery(\'.youtube-video-source'.$upload_videos.'\').toggle(\'slow\')"/>';
                            echo "</td></tr>";

                            echo '<tr class="youtube-video-source'.$upload_videos
                                    .'" style="display:none;"><td align="right">'
                                    ._MEDIALIBRARY_ADD_NEW_VIDEO_FILE.$upload_videos.':';
                            echo "</td><td>";
                            if (isset($youtubeCode['youtube'])) 
                                echo "<input type='text' name='video_youtube_code" . $upload_videos . "'
                                  id='video_youtube_code" . $upload_videos . "' size='60' value='" 
                                  . $youtubeCode['youtube'] . "' readonly=\"readonly\"/>"
                                  ._MEDIALIBRARY_LABEL_VIDEO_DELETE.$upload_videos.":";
                            echo isset($youtubeId) ? "<input type=\"checkbox\" name=\"youtube_option_del" . 
                              $videos[0]->id  . "\" value=\"" .  $videos[0]->id . "\">" : "";
                            echo "</td></tr>"
                            ;
                            $upload_videos++;
                        }
                    }
                } 
            }?>
            <tr>
              <td width='230' align='left'></td>
                <td ID="v_items">
                    <input type="button" name="new_video"
                      value="<?php echo _MEDIALIBRARY_ADD_NEW_VIDEO_FILE; ?>"
                      onClick="new_videos()" ID="v_add" style="display:block;"/>
              </td>
            </tr>
          <?php 
        }

    if ($medialibrary_configuration['audios']['allow']) {
                echo '</table>';
            echo '<div class="upload_audio-items" style="margin-left:243px">';
            $upload_audios = 1;
            $upload_sourcess = 1;
            $audio_queue = [];
            foreach ($audios as $kay => $value) {
                if ($value->sequence_number){
                    $audio_queue[$value->sequence_number][] = $value;
                } else {
                    $audio_queue[$value->id][] = $value;
                }
            }
            foreach ($audio_queue as $kay => $audios) {
                echo '<div class="upload_audio-item">';
                // echo '<img src="'.$media_class->imageURL.'" alt="image upload audio">';
                echo '<div style="position: absolute; margin: 8px 0 0 -112px;">'
                            ._MEDIALIBRARY_LABEL_AUDIO.$upload_audios.":".'</div>';
                    if (isset($audios[0]->title) && $audios[0]->title != '') 
                                echo '<input type="text" name="video_source_title' . $upload_audios . '"
                                  id="video_source_title"' . $upload_audios . '" size="60" value="' 
                                  .  $audios[0]->title . '" readonly="readonly"/>';
                echo '<input type="button" name="show_altern_audio" class="show-button"';
                echo 'value="'._MEDIALIBRARY_CATEGORIES__DETAILS.'" style="margin: -8px 0 0 5px;" ';
                echo 'onclick="jQuery(\'#altern-audio-source'.$upload_audios.'\').toggle(\'slow\')"/>';
                
                echo  '<div id="altern-audio-source'.$upload_audios.'" style = "display:none">';
                for ($i = 0;$i < count($audios);$i++) {
                    echo _MEDIALIBRARY_LABEL_AUDIO_ATTRIBUTE . ($i + 1) . ":";
                        $type_src =  explode('.', $audios[$i]->src);
                        echo  ' '.$type_src[(count($type_src)-1)];

                    echo  '<div class="altern-audio-one-source">';
                    if (isset($audios[$i]->src) && substr($audios[$i]->src, 0, 4) != "http" &&
                    empty($audios[$i]->youtube)){
                        echo "<input type='text' name='new_upload_audio" . $i . "' id='new_upload_audio" . $i 
                            . "' size='60' value='" . $audios[$i]->src . "' readonly='readonly' />";
                    } elseif (isset($audios[$i]->src) && substr($audios[$i]->src, 0, 4) == "http" &&
                    empty($audios[$i]->youtube)){
                        echo "<input type='text' name='new_upload_audio" .  $i . "' id='new_upload_audio_url" 
                            . $i . "' size='60' value='" . $audios[$i]->src . "' readonly='readonly' />";
                    }
                    echo _MEDIALIBRARY_LABEL_AUDIO_DELETE . ":";
                    echo isset($audios[$i]->id) ? "<input type=\"checkbox\" name=\"audio_option_del" . 
                      $audios[$i]->id . "\" value=\"" . $audios[$i]->id . "\">" : "";
                    echo  '</div>';
                }
                
                echo    '<div class="hidden-details upload-altern-audio'.$upload_audios.'">';
                echo    '<input type="button" name="new_altern_audio" ';
                echo    'value="'._MEDIALIBRARYLABEL_AUDIO_ADD_ALTERNATIVE_AUDIO.'"';
                echo    ' onclick="new_altern_audios(\''.$kay.'\',\'altern-audio-source'
                                 .$upload_audios.'\')" ID="new_altern_audio" style="display:block"/>';
                echo    '</div>';
                echo  '</div>';

                
                echo '</div>';
                $upload_audios++;
            }
            echo '</div>';
            echo '<table class="adminform" width="100%" cellspacing="1" cellpadding="4" border="0">';
            
            ?>
            <td width="232">
                <td ID="a_items">
                  <input  type="button" name="new_audio"
                  value="<?php echo _MEDIALIBRARYLABEL_ADD_NEW_AUDIO_FILE; ?>" onClick="new_audios()"
                  ID="a_add"/>
                </td>
            <td>    
        <?php 
        }

    if ($medialibrary_configuration['emedias']['allow']) {
        echo '<tr><td colspan="2"></td></tr>';
        echo "<tr > <td valign='top' align='right'><strong>" . _MEDIALIBRARY_LABEL_EMEDIA . ":</strong></td>";
        if (count($files) > 0) {
            for ($i = 0;$i < count($files);$i++) {
                  echo "<tr><td align='right'>" . _MEDIALIBRARY_LABEL_EMEDIA_UPLOAD_URL . ($i + 1) . ":";
                  echo "</td><td>";
                  if (isset($files[$i]->location) && substr($files[$i]->location, 0, 4) != "http")
                  echo "<input type='text' size='60' value='" . $mosConfig_live_site . $files[$i]->location . 
                        "' readonly='readonly'/>";
                  elseif (isset($files[$i]->location) && substr($files[$i]->location, 0, 4) == "http")
                  echo "<input type='text' size='60' value='" . $files[$i]->location . "' readonly='readonly'/>";
                  echo "</td></tr>";
                  echo "<tr><td align='right'>" . _MEDIALIBRARY_LABEL_EMEDIA_DELETE . ":";
                  echo "</td><td>";
                  echo isset($files[$i]->id) ? "<input type=\"checkbox\" name=\"file_option_del" . 
                        $files[$i]->id . "\" value=\"" . $files[$i]->id . "\">" : "";
                  echo "</td></tr>";
            }
        }
        if (count($files) > 0) echo "<td>"; ?>
                      <td ID="f_items">
                      <input  type="button" name="new_file"
                      value="<?php echo "Add new emedia file"; ?>" onClick="new_files()"  ID="f_add"/>
                    </td>
  <?php if (count($files) > 0) echo "<td>";
  }?>
    <tr>
      <td colspan="2">
          <hr size="2" width="100%" />
      </td>
    </tr>
    
    <!-- **********************   begin change review   ***************************-->
     <?php if ($reviews > false) /*show, if review exist*/ { ?>
    <tr>
      <td colspan="7">
        <hr width="100%" size="2" align="left"> <h3><?php echo _MEDIALIBRARY_LABEL_REVIEWS; ?>:</h3>
      </td>
    </tr>
    <table class="adminlist">
      <tr class="row0">
        <td width="3%" valign="top" align="center">
          <div>#</div>
        </td>
        <td width="2%" valign="top" align="center">
          <div></div>
        </td>
        <td width="10%" valign="top" align="center">
          <strong><?php echo _MEDIALIBRARY_LABEL_REVIEW_TITLE; ?>:</strong>
        </td>
        <td width="10%" valign="top" align="center">
          <strong><?php echo _MEDIALIBRARY_LABEL_LEND_USER; ?>:</strong>
        </td>
        <td width="65%" valign="top" align="center">
          <strong><?php echo _MEDIALIBRARY_LABEL_REVIEW_COMMENT; ?>:</strong>
        </td>
        <td width="5%" valign="top" align="center">
          <strong><?php echo _MEDIALIBRARY_LABEL_PUB_DATE; ?>:</strong>
        </td>
        <td width="5%" valign="top" align="center">
          <strong><?php echo _MEDIALIBRARY_LABEL_REVIEW_RATING; ?>:</strong>
        </td>
      </tr>
    <?php for ($i = 0, $nn = 1;$i < count($reviews);$i++, $nn++) /*if not one comment*/ { ?>
      <tr class="row0">
        <td valign="top" align="center">
          <div><?php echo $nn; ?></div>
        </td>
        <td valign="top" align="center">
          <div>
          <?php echo "<input type='radio' id='cb" . $i . "' name='bid[]' value='" .
             $medialibrary->id . "," . $reviews[$i]->id . "' onclick='Joomla.isChecked(this.checked);' />"; ?>
          </div>
        </td>
        <td valign="top" align="center">
          <div><?php print_r($reviews[$i]->title); ?></div>
        </td>
        <td valign="top" align="left">
          <div><?php print_r($reviews[$i]->name); ?></div>
        </td>
        <td valign="top" align="left">
            <div><?php print_r(strip_tags($reviews[$i]->comment)); ?></div>
            </td>
        <td valign="top" align="left">
          <div><?php print_r($reviews[$i]->date); ?></div>
        </td>
        <td valign="top" align="left">
          <div><img src="../components/com_medialibrary/images/rating-<?php echo $reviews[$i]->rating; ?>.gif"
             alt="<?php echo ($reviews[$i]->rating) / 2; ?>" border="0" align="right"/>&nbsp;</div>
        </td>
      </tr>
        <?php
            } /*end for(...)*/ ?>

    </table>
    <?php
        } /*end if(...)*/ ?>



    </table>

    <input type="hidden" name="id" value="<?php echo $medialibrary->id; ?>" />
    <input type="hidden" name="media_id" value="<?php echo $media_class->id; ?>" />
    <input type="hidden" name="option" value="<?php echo $option; ?>" />
    <input type="hidden" id="media_type_field" name="media_type" value="<?php
         echo $medialibrary->media_type; ?>" />
    <input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="task" value="" />
    </form>
    <!--*********************   end change review   **************************-->
    <?php
    }
    //------------------------------------------------------------------------------
    // show(edit) game
    static function editing_game($option, $medialibrary, $media_class, $clist, $wslist,
       $langlist, $ratinglist, $delete_edocument,
       $reviews, $type_list, $langshow = null,$files,$videos,$audios,$tracks,$youtubeCode,
       $youtubeId,$associateArray, $studioshow) {
        global $my, $mosConfig_live_site, $mainframe, $medialibrary_configuration, $database;
        global $doc; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " .
           _MEDIALIBRARY_SHOW . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;
    ?>

    <script language="javascript" type="text/javascript">
      function type_select(){
        var el = document.forms["adminForm"].elements["task"];
        el.value = "add";
        el = document.getElementById("media_type_field");
        var el2 = document.getElementById("media_type");
        el.value = el2.options[el2.selectedIndex].value;
        el = document.forms["adminForm"];
        el.submit();
      return ;
      }

      function trim(string) {
        return string.replace(/(^\s+)|(\s+$)/g, "");
      }

    function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.y) {
        curtop+=obj.y;
    }
    return curtop-20;
    }

    Joomla.submitbutton = function(pressbutton) { // for 1.6
    var form = document.adminForm;
    var post_max_size = <?php echo return_bytes(ini_get('post_max_size')) ?>;
    var upl_max_fsize = <?php echo return_bytes(ini_get('upload_max_filesize')) ?>;
    var file_upl = <?php echo ini_get('file_uploads') ?>;
    var title = document.getElementById('title').value;
    var studio = document.getElementById("new_game_studio_select").value;// for J 1.6
    var studioName = document.getElementById("new-studio-field").value;// for J 1.6
    var informationFrom = document.adminForm.informationFrom.value;

    if (pressbutton == 'save' || pressbutton =='apply') {
        if (trim(form.asin_isbn.value) == '') {
            window.scrollTo(0,findPosY(form.asin_isbn)-100);
            form.asin_isbn.placeholder = "<?php
            echo _MEDIALIBRARY_ADMIN_INFOTEXT_JS_EDIT_ISBN_ASIN_CHECK; ?>";
            form.asin_isbn.style.borderColor = "#FF0000";
            form.asin_isbn.style.color = "#FF0000";
            return;
        } else if (form.catid.value == '0') {
            window.scrollTo(0,findPosY(form.catid)-100);
            form.catid.style.borderColor = "#FF0000";
            form.catid.style.color = "#FF0000";
            return;
        }
        else if ((title == '0' || title == '') && informationFrom == 0) {
            window.scrollTo(0,findPosY(form.title)-100);
            form.title.style.borderColor = "#FF0000";
            alert( "<?php echo _MEDIALIBRARY_LABEL_B_TITLE; ?>");
            return;
        }
        else if ((studio == '0' || studio == '') && informationFrom == 0) {
            if (studioName == '0' || studioName == ''){
                window.scrollTo(0,findPosY(studio)-100);
                alert( "<?php echo _MEDIALIBRARY_ADMIN_INFOTEXT_JS_EDIT_STUDIO; ?>");
                return;
            }
        }

        for (i=1; document.getElementById('new_upload_video'+i); i++){
        if(document.getElementById('new_upload_video'+i).files != null){
            if(!file_upl){
              window.scrollTo(0,findPosY(document.getElementById('new_upload_video'+i))-100);
              document.getElementById('error_video').innerHTML = "<?php
              echo _MEDIALIBRARY_ADMIN_SETTINGS_VIDEO_ERROR_UPLOAD_OFF; ?>";
              document.getElementById('new_upload_video'+i).style.borderColor = "#FF0000";
              document.getElementById('new_upload_video'+i).style.color = "#FF0000";
              document.getElementById('error_video').style.color = "#FF0000";
              return;
            }
            if(document.getElementById('new_upload_video'+i).files.length != 0 &&
               document.getElementById('new_upload_video_youtube_code'+i).value != null) {
            if(document.getElementById('new_upload_video'+i).files[0].size >= post_max_size){
              window.scrollTo(0,findPosY(document.getElementById('new_upload_video'+i))-100);
              document.getElementById('error_video').innerHTML = "<?php
              echo _MEDIALIBRARY_ADMIN_SETTINGS_VIDEO_ERROR_POST_MAX_SIZE; ?>";
              document.getElementById('new_upload_video'+i).style.borderColor = "#FF0000";
              document.getElementById('new_upload_video'+i).style.color = "#FF0000";
              document.getElementById('error_video').style.color = "#FF0000";
              return;
            }
          }
          if(document.getElementById('new_upload_video'+i).files.length != 0 &&
             document.getElementById('new_upload_video_youtube_code'+i).value != null) {
            if(document.getElementById('new_upload_video'+i).files[0].size >= upl_max_fsize){
              window.scrollTo(0,findPosY(document.getElementById('new_upload_video'+i))-100);
              document.getElementById('error_video').innerHTML = "<?php
              echo _MEDIALIBRARY_ADMIN_SETTINGS_VIDEO_ERROR_UPLOAD_MAX_SIZE; ?>";
              document.getElementById('new_upload_video'+i).style.borderColor = "#FF0000";
              document.getElementById('new_upload_video'+i).style.color = "#FF0000";
              document.getElementById('error_video').style.color = "#FF0000";
              return;
            }
        }
      }
  }
      if(form.new_upload_track_url1){
      for (i = 1;form.getElementById('new_upload_track_url'+i); i++) {
        if(form.getElementById('new_upload_track'+i).value != ''
          || form.getElementById('new_upload_track_url'+i).value != ''){
            if(form.getElementById('new_upload_track_kind'+i).value == ''){
              window.scrollTo(0,findPosY(document.getElementById('new_upload_track_kind'+i))-100);
              document.getElementById('new_upload_track_kind'+i).placeholder = "<?php
                echo _MEDIALIBRARY_ADMIN_SETTINGS_INFOTEXT_JS_TRACK_KIND; ?>";
              document.getElementById('new_upload_track_kind'+i).style.borderColor = "#FF0000";
              document.getElementById('new_upload_track_kind'+i).style.color = "#FF0000";
              return;
            }else if(form.getElementById('new_upload_track_scrlang'+i).value == ''){
              window.scrollTo(0,findPosY(document.getElementById('new_upload_track_scrlang'+i))-100);
              document.getElementById('new_upload_track_scrlang'+i).placeholder = "<?php
                echo _MEDIALIBRARY_ADMIN_SETTINGS_INFOTEXT_JS_TRACK_LANGUAGE; ?>";
              document.getElementById('new_upload_track_scrlang'+i).style.borderColor = "#FF0000";
              document.getElementById('new_upload_track_scrlang'+i).style.color = "#FF0000";
              return;
            }else if(form.getElementById('new_upload_track_label'+i).value == ''){
              window.scrollTo(0,findPosY(document.getElementById('new_upload_track_label'+i))-100);
              document.getElementById('new_upload_track_label'+i).placeholder = "<?php
                echo _MEDIALIBRARY_ADMIN_INFOTEXT_JS_TRACK_TITLE; ?>";
              document.getElementById('new_upload_track_label'+i).style.borderColor = "#FF0000";
              document.getElementById('new_upload_track_label'+i).style.color = "#FF0000";
              return;
            }
        }
    }
      submitform(pressbutton);
    }else {
      submitform(pressbutton);
    }
 } else {
      submitform( pressbutton );
    }
 }
    </script>

    <form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
    <table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform">
      <!-- anton code type -->
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?>:</strong>
      </td>
      <td align="left">
        <?php echo $type_list; ?>
      </td>
    </tr>
    <!-- anton code -->
    <tr>
      <td width="15%" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_GAMEID; ?>:</strong>
      </td>
      <td width="85%" align="left">
        <input class="inputbox" type="text" name="media_type_id" size="20" maxlength="20" 
          value="<?php echo $media_class->game_id; ?>" />
      </td>
    </tr>
    <tr>
      <td width="20%" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_ASIN; ?>*:</strong>
      </td>
      <td align="left">
        <input class="inputbox" type="text" name="asin_isbn" size="20" maxlength="20" 
          value="<?php echo $media_class->asin; ?>" />
      </td>
    </tr>



        <?php
          /*******************************************    language    **************************************************/
          if (!empty($associateArray) && !empty($media_class->langDescription) && $media_class->langDescription != ''
                                      && $media_class->langDescription != '*') {
          ?>
                  <tr>
                      <td width="15%"><?php echo 'language associate media' ?>:</td>
                  </tr>
        <?php
              $j = 1;
              foreach($associateArray as $lang => $value) {
                  $displ = '';
                  if (!$value['list']) {
                      $displ = 'none';
                  }
        ?>
                  <tr style="display: <?php echo $displ ?>">
                      <td width="15%"><?php echo $lang; ?>:</td>
                      <td width="60%"><?php echo $value['list']; ?>

                      <input class="inputbox" id="associate_media" type="text"
                              name="associate_media<?php echo $j; ?>" size="20"
                              readonly="readonly" maxlength="20" style="width:25px;"
                              value="<?php echo $value['assocId']; ?>" />
                      <input style="display: none" name="associate_media_lang<?php echo $j; ?>"
                              value="<?php echo $lang ?>"/>
                      </td>
                  </tr>
        <?php
                  $j++;
              }
          } else {
        ?>
                  <tr>
                      <td width="15%"><?php echo 'language associate media' ?>:</td>
                      <td width="60%"><?php echo 'this property only for media with language' ?>
                  </tr>
        <?php
          }
          /*********************************************************************************************/
        ?>




    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_LANGUAGE; ?>:</strong>
      </td>
      <td align="left">
        <?php echo $langlist; ?>
      </td>
    </tr>
    <tr>
  <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_LANGUAGE_DESCRIPTION; ?>:</strong>
            </td>
            <td align="left">
                <?php echo $langshow; ?>
            </td>
        </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_CATEGORY; ?>*:</strong>
      </td>
      <td align="left">
        <?php echo $clist; ?>
      </td>
    </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_FETCH_INFO; ?>:</strong>
      </td>
      <td align="left">
        <?php echo $wslist; ?>
        &nbsp;&nbsp;&nbsp;<img src="../components/com_medialibrary/images/amazon/com-logo.gif" 
          alt="amazon.com" border="0"/>
       </td>
    </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_COMMENT; ?>:</strong>
      </td>
      <td align="left">
        <?php
        editorArea('editor1', $media_class->comment, 'comment', 500, 250, '70', '10');
?>
        <!--<textarea name="comment" id="comment" cols="50" rows="25" style="width:800;height:200;"><?php 
          /*echo $row->comment;*/ ?></textarea>-->
      </td>
    </tr>
    <tr>
      <td width="185"></td>
      <td><span id="error_video"></span></td>
    </tr>
    <tr>
      <td valign="top" align="right">&nbsp;
      </td>
      <td align="left">
        <?php echo _MEDIALIBRARY_ADMIN_TEXT_WSINFO_TEXT1; ?>
        <strong>
        <?php echo _MEDIALIBRARY_LABEL_FETCH_INFO; ?>
        ->
        <?php echo _MEDIALIBRARY_WS_NO; ?>
        </strong>
      </td>
    </tr>
      <!-- anton code type -->
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_TITLE; ?>*:</strong>
      </td>
      <td align="left">
        <input class="inputbox" type="text" id="title" name="title" size="80" value="<?php 
            echo $media_class->title; ?>" />
      </td>
    </tr>
    <!-- ***********block game************* -->
    <tr>
        <td valign="top" align="right"><strong>
            <?php echo _MEDIALIBRARY_LABEL_STUDIO; ?>:</strong></td>
        <td align="left">
            <div class="toggle-author">
                <?php echo $studioshow;?>
            </div>
            <input type="text" name="new_studio_field" class="new-studio-field toggle-author" 
                   id="new-studio-field" style="display: none;"></input>
            <div style="clear: both;"></div>
            <input type="button" id="switch-enter-author" value="Change studio field."
                   onclick="jQuery('.toggle-author').toggle('slow')" <?php 
                   if($medialibrary->get('informationFrom')) echo ' style="display: none;"';?>></input>
        </td>
    </tr>

    <tr>
      <td valign="top" align="right"><!-- ***********block************* -->
        <strong><?php echo _MEDIALIBRARY_LABEL_BINDING; ?>:</strong>
      </td>
      <td align="left">
        <input class="inputbox" type="text" name="binding" size="80" value="<?php 
            echo $media_class->binding; ?>" />
      </td>
    </tr>

    <tr>
      <td valign="top" align="right"><!-- ***********block************* -->
      <strong><?php echo _MEDIALIBRARY_RELEASE_DATA ?>:</strong>
      </td>
      <td align="left">
        <input class="inputbox" type="text" name="release_date" size="80" 
          value="<?php echo $media_class->release_date; ?>" />
      </td>
    </tr>

    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_PLATFORM; ?>:</strong>
      </td>
      <td align="left">
        <input class="inputbox" type="text" name="platform" size="80" value="<?php 
            echo $media_class->platform; ?>" />
      </td>
    </tr>
    <!-- ***********block************* -->
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_PRICE; ?>:</strong>
      </td>
      <td align="left">
        <input class="inputbox" type="text" name="price" size="15" value="<?php echo $media_class->price; ?>" />
    <input class="inputbox" type="text" name="priceunit" size="6" value="<?php 
        echo $media_class->priceunit; ?>" />
      </td>
    </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_RATING; ?>:</strong>
      </td>
      <td align="left">
        <?php echo $ratinglist; ?>
      </td>
    </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_PICTURE_URL; ?>:</strong>
      </td>
          <!-- /////////////////////////////Begin AddPatch CODE///////////////////-->
      <td align="left">
        <input class="inputbox" type="text" name="imageURL" size="80"
          value="<?php echo $media_class->imageURL; ?>" />
        <input class="inputbox" type="button" name="default_patch"
          value="Set Local Cover Path" onClick="build_patch()" />

        <script type="text/javascript" language="javascript">
        function build_patch()
        {
          var asin_isbn = "<?php echo $media_class->asin; ?>" ;
          var url = 'components/com_medialibrary/asin_isbn_build.php';
          <?php $cover_path = $medialibrary_configuration['fetchImages']['location']; ?>
          var cover_path = "<?php echo $cover_path; ?>";
          if (window.XMLHttpRequest)
          {
            // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType)
            {
              http_request.overrideMimeType('text/xml');
            }
          }
          else if (window.ActiveXObject)
          {
            // IE
            try
            {
              http_request = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e)
            {
              try
              {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
              }
              catch (e)
              {}
            }
          }
          if (!http_request)
          {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
          }
          http_request.onreadystatechange = alertContents;
          http_request.open("POST", url, true);
          http_request.setRequestHeader('Content-Type' , 'application/x-www-form-urlencoded');
          http_request.send('asin_isbn='+asin_isbn +'&cover_path='+cover_path);
        }

        function alertContents()
        {
          if (http_request.readyState == 4)
          {
            if (http_request.status == 200)
            {
              if (http_request.responseText == 1)
              {
                alert("<?php echo _MEDIALIBRARY_TOOLBAR_NEW_MEDIA_INCORRECT_FOLDER . " " . $cover_path; ?>");
              }
              if (http_request.responseText == false)
              {
                alert("<?php echo _MEDIALIBRARY_TOOLBAR_NEW_MEDIA_INCORRECT_FILE; ?>");
              }
              else
              {
                document.adminForm.imageURL.value = http_request.responseText;
              }
            }
            else
            {
              alert('There was a problem with the request.');
            }
          }
        }
        jQuery('#informationFrom').change(function() {
            var amazonServ = jQuery('#informationFrom').val();
            if (amazonServ === '0'){
                jQuery('#switch-enter-author').css('display', 'block');
            } else {
                jQuery('#switch-enter-author').css('display', 'none');
            }
        });
        </script>

        <script language="javascript" type="text/javascript">
          window.onload = function(){
          var button_video = document.getElementById("v_add");
          var allowed_vid_files = 5;
          <?php if (count($videos) > 0) echo "allowed_files = " . (5 - count($videos)) . ";"; ?>
          if(allowed_vid_files >= 1) {
          button_video.removeAttribute("style");
          }
          var button_audio = document.getElementById("a_add");
          var allowed_aud_files = 5;
          <?php if (count($audios) > 0) echo "allowed_files = " . (5 - count($audios)) . ";"; ?>
          if(allowed_aud_files >= 1) {
          button_audio.removeAttribute("style");
          }
          // for (var i=1; i < 5; i++) {
          // var add =  document.getElementById('new_upload_video_youtube_code'+i).value;
          //   if(add.length){
          //       var obj = document.getElementById('v_add');
          //       obj.style.display = "none";
          //     }
          // }
        }

    </script>

      </td>
    </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_PICTURE_URL_UPLOAD; ?>:</strong>
            </td>
            <td align="left">
              <input class="inputbox" type="file" name="picture_file" value="" size="50" maxlength="250" />
              <br /><?php echo _MEDIALIBRARY_LABEL_PICTURE_URL_DESC; ?>
      <?php
        if ($media_class->imageURL != "" && !strstr($media_class->imageURL, "http")) {
            echo '<div><img class="bl_view_media_image" src="' . $mosConfig_live_site . '' 
                . $media_class->imageURL .
                '" alt="' . $media_class->title . '" border="0"
                              height="' . $medialibrary_configuration['foto']['high'] . '" width="' .
                              $medialibrary_configuration['foto']['width'] .
                '"/></div>';
        } else if ($media_class->imageURL != "" && strstr($media_class->imageURL, "http")) {
            echo '<div><img class="bl_view_media_image" src="' . $media_class->imageURL . '" alt="' .
                $media_class->title . '" border="0"
                height="' . $medialibrary_configuration['foto']['high'] . '" width="' .
                $medialibrary_configuration['foto']['width'] .
                  '"/></div>';
        }
    ?>
        </td>
    </tr>
    <tr>
      <td valign="top" align="right">
        <strong><?php echo _MEDIALIBRARY_LABEL_URL; ?>:</strong>
      </td>
      <td align="left">
        <input class="inputbox" type="text" name="URL" size="80" value="<?php echo $media_class->URL; ?>" />
      </td>
     </tr>
     <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_MEDIAOWNER; ?>:</strong>
            </td>
            <td valign="top" align="left">
               <input class="inputbox" type="text" name="owneremail" size="50" 
                value="<?php echo $medialibrary->owneremail; ?>"/>
            </td>
        </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_MEDIAOWNER_ID; ?>:</strong>
            </td>
            <td align="left">
            <?php echo $medialibrary->name = JFactory::getUser($medialibrary->owner_ID)->name; ?>
            <?php $user = JFactory::getUser();?>
            <input type="text" name="owner_ID" size="80" value="<?php if(!$medialibrary->owner_ID) {
                echo $user->id;
              } else {
                echo $medialibrary->owner_ID;
              } ?>" />
            </td>
        </tr>

   <!---------------------------------Start AJAX load track------------------------------>

  <script language="javascript" type="text/javascript">
                var request = null;
                var tid=1;
                function createRequest_track() {
                    if (request != null)
                    return;
                    try {
                       request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                           request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }

                function testInsert_track(id1,upload){
                    for(var i=1; i< upload_tracks; i++){
                        if(upload.id != ('new_upload_track'+i) &&
                        document.getElementById('new_upload_track'+i).value == upload.value){
                            return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1_track(id1,upload){
                    id=id1;
                    if(testInsert_audio(id1,upload)){
                        createRequest_track();
                        var url = "<?php echo $mosConfig_live_site . 
                          "/administrator/index.php?option=$option&task=randNumber&format=raw";
                        ?>&file="+encodeURI(upload.value)+"&path=<?php
                        echo str_replace("\\", "/", $mosConfig_live_site) 
                            . '/components/com_medialibrary/media/track/'?>";
                       try{
                        request.onreadystatechange = updateRandNumber1_track;
                        request.open("GET", url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert("You alredy select this track file");
                        upload.value="";
                    }
                }

                function updateRandNumber1_track() {
                    if (request.readyState == 4) {
                        document.getElementById("randNumTrack"+tid).innerHTML = request.responseText;
                    }
                }
  </script>

 <!-------------------------------- END Ajax load track---------------------------------->


 <!-------------------------------- END Ajax load audio---------------------------------->
  <script language="javascript" type="text/javascript">
                var request = null;
                var aid=1;
                function createRequest_audio() {
                    if (request != null)
                    return;
                    try {
                          request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                           request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }

                function testInsert_audio(id1,upload){
                    for(var i=1; i< upload_audios; i++){
                        if(upload.id != ('new_upload_audio'+i) &&
                        document.getElementById('new_upload_audio'+i).value == upload.value){
                            return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1_audio(id1,upload){
                    id=id1;
                    if(testInsert_audio(id1,upload)){
                        createRequest_audio();
                        var url = "<?php echo $mosConfig_live_site . 
                          "/administrator/index.php?option=$option&task=randNumber&format=raw";
                        ?>&file="+encodeURI(upload.value)+"&path=<?php
                        echo str_replace("\\", "/", $mosConfig_live_site) 
                            . '/components/com_medialibrary/media/audio/'?>";
                       try{
                        request.onreadystatechange = updateRandNumber1_audio;
                        request.open("GET", url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert( "You alredy select this audio file");
                        upload.value="";
                    }
                }

                function updateRandNumber1_audio(){
                    if (request.readyState == 4) {
                        document.getElementById("randNumAudio"+aid).innerHTML = request.responseText;
                    }
                }
  </script>

<!-------------------------------- END Ajax load audio---------------------------------->


<!-------------------------------- START Ajax load video---------------------------------->


            <script language="javascript" type="text/javascript">

               var request = null;
               var vid=1;

               function createRequest_video(){
                    if (request != null)
                    return;
                    try {
                       request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                            request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }

                function testInsertVideo1(id1,upload){
                    for(var i=1 ;i< upload_videos; i++){
                        if(upload.id != ('new_upload_video'+i) &&
                        document.getElementById('new_upload_video'+i).value == upload.value)
                        {
                          return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1_video(id1,upload){
                    id=id1;
                    if(testInsertVideo1(id1,upload)){
                        createRequest_video();
                    var url = "<?php echo $mosConfig_live_site . 
                      "/administrator/index.php?option=$option&task=randNumber&format=raw";
                    ?>&file="+encodeURI(upload.value)+"&path=<?php echo str_replace("\\", "/", $mosConfig_live_site) . 
                      '/components/com_medialibrary/media/video/'?>";
                       try{
                        request.onreadystatechange = updateRandNumber1_video;
                        request.open("GET",url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert("You alredy select this video file");
                        upload.value="";
                    }
                }

                function updateRandNumber1_video() {
                    if (request.readyState == 4) {
                        document.getElementById("randNumVideo"+vid).innerHTML = request.responseText;
                    }
                }
                </script>


  <!-------------------------------- END Ajax load video---------------------------------->


  <!---------------------------------Start AJAX load file------------------------------>


                <script language="javascript" type="text/javascript">

                var request = null;
                var fid=1;
                function createRequest() {
                    if (request != null)
                    return;
                    try {
                        request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                               request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }


                function testInsertFile1(id1,upload){
                    for(var i=1; i< upload_files; i++){
                        if(upload.id != ('new_upload_file'+i) &&
                        document.getElementById('new_upload_file'+i).value==upload.value){
                            return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1(id1,upload) {
                    id=id1;
                    if(testInsertFile1(id1,upload)){
                        createRequest();
                        var url = "<?php echo $mosConfig_live_site .
                           "/administrator/index.php?option=$option&task=randNumber&format=raw";
                        ?>&file="+encodeURI(upload.value)+"&path=<?php
                        echo str_replace("\\", "/", $mosConfig_live_site) 
                            . '/components/com_medialibrary/emedia/'?>";
                        try{
                        request.onreadystatechange = updateRandNumber1;
                        request.open("GET",url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert( "You alredy select this file");
                        upload.value="";
                    }
                }
                function updateRandNumber1() {
                    if (request.readyState == 4) {
                        document.getElementById("randNumFile"+fid).innerHTML = request.responseText;
                    }
                }
                </script>

<!-------------------------------- END Ajax load file ---------------------------------->

    <script language="javascript" type="text/javascript">
    var upload_tracks=0;
    function new_tracks(index, div0){
        // div=document.getElementById("t_items");
        // button=document.getElementById("t_add");
        div = document.getElementById(div0);
        button=document.getElementById(div0);
        upload_tracks++;
        newitem="<table width='50%'><tr><td width='15%'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_LABEL_TRACK_UPLOAD ?>"+upload_tracks+": </strong></td>";
        newitem+="<td width='85%'>";
        newitem+="<input type='hidden' name='new_upload_track"+upload_tracks;
        newitem+="' value='"+index+"' />";
        
        newitem+="<input style=\"float:left; width:100%\" type=\"file\" "+
        "onClick=\"document.adminForm.new_upload_track"+upload_tracks+".value ='';\" " +
        " onChange=\"refreshRandNumber1_track("+upload_tracks+
        ",this);\"  name=\"new_upload_track"+upload_tracks+"\" "+"id=\"new_upload_track"+upload_tracks;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumTrack"+upload_tracks+"\" ";
        newitem+="style=\"color:red;\"></span></td></tr></td></tr>"+ "<tr><td ";
        newitem+="style=\"text-align:center\"> OR </td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        newitem="<table width='50%'><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_TRACK_UPLOAD_URL; ?>" +upload_tracks+ ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
          "name=\"new_upload_track_url"+upload_tracks+"\" "+"id=\"new_upload_track_url"+upload_tracks;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        div.appendChild(newnode,button);
        newitem="<table width='50%' style=\"display:none;\"><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_CONFIG_TRACK_UPLOAD_KIND; ?>" +upload_tracks+ ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left;display:none; width:90%\" type=\"text\" "+
          "name=\"new_upload_track_kind"+upload_tracks+"\" "+"id=\"new_upload_track_kind"+upload_tracks;
        newitem+="\" value=\"eng\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        div.appendChild(newnode,button);
        newitem="<table width='50%'><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_TRACK_UPLOAD_SCRLANG; ?>" +upload_tracks+ ": ";
        newitem+="</strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
          " name=\"new_upload_track_scrlang"+upload_tracks+"\" ";
        newitem+="id=\"new_upload_track_scrlang"+upload_tracks;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        div.appendChild(newnode,button);
        newitem="<table width='50%' style=\"display:none;\"><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_TRACK_UPLOAD_LABEL; ?>" +upload_tracks+ ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
        "name=\"new_upload_track_label"+upload_tracks+"\" "+"id=\"new_upload_track_label"+upload_tracks;
        newitem+="\" value=\"eng\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
    }
    </script>

   <script language="javascript" type="text/javascript">
    var upload_videos=0;
    function new_videos(){
        div=document.getElementById("v_items");
        button=document.getElementById("v_add");
        upload_videos++;
        newitem="<table width='50%'><tr><td width='160px'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD ?>" +upload_videos+ ": </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:150%\" type=\"file\" "+
          "onClick=\"document.adminForm.new_upload_video_url"+upload_videos+".value ='';\" " +
        " onChange=\"refreshRandNumber1_video("+upload_videos+
        ",this);\" name=\"new_upload_video"+upload_videos+"\" "+"id=\"new_upload_video"+upload_videos;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumVideo"+upload_videos+"\" style=\"color:red;\"></span></td></tr></td></tr>"+
          "<tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD_URL; ?>" +upload_videos+ ": </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" "+
          "name=\"new_upload_video_url"+upload_videos+"\" "+"id=\"new_upload_video_url"+upload_videos;
        newitem+="\" value=\"\"size=\"45\"></td></tr></td></tr></td></tr>"+
        "<tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD_YOUTUBE_CODE; ?>" + ": </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" "+
          "name=\"new_upload_video_youtube_code"+upload_videos+"\" "+
          "id=\"new_upload_video_youtube_code"+upload_videos;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        var allowed_files = 5;
        if(upload_videos + <?php echo count($videos); ?> >= allowed_files) {
         button.setAttribute("style","display:none");
        }
    }
  </script>

   <script language="javascript" type="text/javascript">
    var upload_video_altern_id=1;
    function new_altern_videos(index, div0){
        div = document.getElementById(div0);
        button=document.getElementById(div0);
        upload_altern_videos = index;
        newitem="<table width='50%'><tr><td width='160px'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD ?>: </strong></td>";
        newitem+="<td width='400px'>";
        newitem+="<input type='hidden' name='new_upload_altern_video"+upload_video_altern_id+"' ";
        newitem+="value='"+index+"' />";
        newitem+="<input style=\"float:left; width:150%\" type=\"file\" "+
        " onClick=\"document.adminForm.new_upload_altern_video_url"+upload_altern_videos+".value ='';\" " +
        " onChange=\"refreshRandNumber1_video("+upload_altern_videos+
        ",this);\" name=\"new_upload_altern_video"+upload_video_altern_id+"\" ";
        newitem+="id=\"new_upload_altern_video"+upload_video_altern_id;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumVideo"+upload_video_altern_id+"\" ";
        newitem+="style=\"color:red;\"></span></td></tr></td></tr>"
        +"<tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD_URL; ?>: </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" ";
        newitem+="name=\"new_upload_altern_video_url"+
          upload_altern_videos+"\" "+"id=\"new_upload_altern_video_url"+upload_altern_videos;
        newitem+="\" value=\"\"size=\"45\"></td></tr></td></tr></td></tr>"+
          "<tr><td style=\"text-align:center\"></td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        // var allowed_files = 5;
        // if(upload_altern_videos + <?php echo count($videos); ?> >= allowed_files) {
        //  button.setAttribute("style","display:none");
        // }
        upload_video_altern_id++;
    }
  </script>

  <script language="javascript" type="text/javascript">
    var upload_audios=0;
    function new_audios(){
        div=document.getElementById("a_items");
        button=document.getElementById("a_add");
        upload_audios++;
        newitem="<table width='50%'><tr><td width='15%'><strong style=\"float:left\">" + 
          "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD ?>" + upload_audios + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:100%\" type=\"file\" "+
        " onClick=\"document.adminForm.new_upload_audio_url"+upload_audios+".value ='';\" " +
        " onChange=\"refreshRandNumber1_audio("+upload_audios+
        ",this);\"  name=\"new_upload_audio"+upload_audios+"\" "+"id=\"new_upload_audio"+upload_audios;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumAudio"+upload_audios+
          "\" style=\"color:red;\"></span></td></tr>"+
          "<tr><td style=\"text-align:center\"> OR </td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='15%'><strong>" + 
          "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD_URL; ?>" + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
          "name=\"new_upload_audio_url"+upload_audios+"\" "+"id=\"new_upload_audio_url"+upload_audios;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br />";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
         var allowed_aud_files = 5;
        if(upload_audios + <?php echo count($audios); ?> >= allowed_aud_files) {
         button.setAttribute("style","display:none");
        }
    }
  </script>

   <script language="javascript" type="text/javascript">
    var upload_audio_altern_id=1;
    function new_altern_audios(index, div0){
        div = document.getElementById(div0);
        button=document.getElementById(div0);
        upload_altern_audios = index;
        newitem="<table width='50%'><tr><td width='160px'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD ?>: </strong></td>";
        newitem+="<td width='400px'>";
        newitem+="<input type='hidden' name='new_upload_altern_audio"+upload_audio_altern_id+"' ";
        newitem+="value='"+index+"' />";
        newitem+="<input style=\"float:left; width:150%\" type=\"file\" "+
        " onClick=\"document.adminForm.new_upload_altern_audio_url"+upload_altern_audios+".value ='';\" " +
        " onChange=\"refreshRandNumber1_audio("+upload_altern_audios+
        ",this);\" name=\"new_upload_altern_audio"+upload_audio_altern_id+"\" ";
        newitem+="id=\"new_upload_altern_audio"+upload_audio_altern_id;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumaudio"+upload_audio_altern_id+"\" ";
        newitem+="style=\"color:red;\"></span></td></tr></td></tr>"
        +"<tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD_URL; ?>: </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" ";
        newitem+="name=\"new_upload_altern_audio_url"+
          upload_altern_audios+"\" "+"id=\"new_upload_altern_audio_url"+upload_altern_audios;
        newitem+="\" value=\"\"size=\"45\"></td></tr></td></tr></td></tr>"+
          "<tr><td style=\"text-align:center\"></td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        // var allowed_files = 5;
        // if(upload_altern_audios + <?php echo count($audios); ?> >= allowed_files) {
        //  button.setAttribute("style","display:none");
        // }
        upload_audio_altern_id++;
    }
  </script>

 <script language="javascript" type="text/javascript">
    var upload_files=0;
    function new_files(){
        div=document.getElementById("f_items");
        button=document.getElementById("f_add");
        upload_files++;
        newitem="<table width='50%'><tr><td width='15%'><strong style=\"float:left\">" + 
          "<?php echo _MEDIALIBRARY_ADMIN_LABEL_EBOOK_UPLOAD ?>" + upload_files + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:100%\" type=\"file\" "+
        "onClick=\"document.adminForm.new_upload_file_url"+upload_files+".value ='';\" " +
        " onChange=\"refreshRandNumber1("+upload_files+
        ",this);\"  name=\"new_upload_file"+upload_files+"\" "+"id=\"new_upload_file"+upload_files;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumFile"+upload_files+"\" style=\"color:red;\"></span></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='15%'><strong>" + 
          "<?php echo _MEDIALIBRARY_ADMIN_LABEL_EBOOK_UPLOAD_URL; ?>" + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
          "name=\"new_upload_file_url"+upload_files+"\" "+"id=\"new_upload_file_url"+upload_files;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br><br />";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
    }
  </script>

    <?php
    if ($medialibrary_configuration['videos_tracks']['allow']) {
            if (count($videos) > 0 ) {
                 $upload_videos = 1;
                $upload_sourcess = 1;
                $video_queue = [];
                foreach ($videos as $kay => $value) {
                    if ($value->sequence_number){
                        $video_queue[$value->sequence_number][] = $value;
                    } else {
                        $video_queue[$value->id][] = $value;
                    }
                }
                foreach ($video_queue as $kay => $videos) {
                    echo '</table>';
                    echo '<div class="upload_video-items" style="margin-left:243px">';
                    if (empty($videos[0]->youtube)) {
                    echo '<div class="upload_video-item">';
                    //echo '<img src="'.$media_class->imageURL.'" alt="image upload video">';
                    echo '<div style="position: absolute; margin: 8px 0 0 -112px;">'
                            ._MEDIALIBRARY_LABEL_VIDEO.$upload_videos.":".'</div>';
                    if (isset($videos[0]->title) && $videos[0]->title != '') 
                                echo "<input type='text' name='video_source_title" . $upload_videos . "'
                                  id='video_source_title" . $upload_videos . "' size='60' value='" 
                                  . $videos[0]->title . "' readonly=\"readonly\"/>";
                    echo '<input type="button" name="show_altern_video" class="show-button" ';
                    echo ' value="'._MEDIALIBRARY_CATEGORIES__DETAILS.'"  style="margin: -8px 0 0 5px;" ';
                    echo ' onclick="jQuery(\'#altern-video-source'.$upload_videos.'\').toggle(\'slow\')"/>';
                    
                    echo  '<div id="altern-video-source'.$upload_videos.'" style = "display:none">';
                    for ($i = 0;$i < count($videos);$i++) {
                        echo _MEDIALIBRARY_LABEL_VIDEO_ATTRIBUTE . ($i + 1) . ":";
                            $type_src =  explode('.', $videos[$i]->src);
                            echo  ' '.$type_src[(count($type_src)-1)];

                        echo  '<div class="altern-video-one-source">';
                        if (isset($videos[$i]->src) && substr($videos[$i]->src, 0, 4) != "http" &&
                        empty($videos[$i]->youtube)){
                            echo "<input type='text' name='new_upload_video" . $i . "' id='new_upload_video" . $i 
                                . "' size='60' value='" . $videos[$i]->src . "' readonly='readonly' />";
                        } elseif (isset($videos[$i]->src) && substr($videos[$i]->src, 0, 4) == "http" &&
                        empty($videos[$i]->youtube)){
                            echo "<input type='text' name='new_upload_video" .  $i 
                                . "' id='new_upload_video_url" . $i 
                                . "' size='60' value='" . $videos[$i]->src . "' readonly='readonly' />";
                        }
                        echo _MEDIALIBRARY_LABEL_VIDEO_DELETE . ":";
                        echo isset($videos[$i]->id) ? "<input type=\"checkbox\" name=\"video_option_del" . 
                          $videos[$i]->id . "\" value=\"" . $videos[$i]->id . "\">" : "";
                        echo  '</div>';
                    }?>
                        <div id="upload-altern-video_add_here<?php echo $upload_videos;?>">
                            <span style="display: none;"></span>
                        </div>
                    <?php
                    echo    '<div class="hidden-details upload-altern-video'.$upload_videos.'">';
                    echo    '<input type="button" name="new_altern_video" ';
                    echo    ' value="'._MEDIALIBRARYLABEL_VIDEO_ADD_ALTERNATIVE_VIDEO.'"';
                    echo    ' onclick="new_altern_videos(\''.$kay.'\',\'upload-altern-video_add_here'
                                     .$upload_videos.'\')" ID="new_altern_video" style="display:block"/>';
                    if ($medialibrary_configuration['videos_tracks']['allow']) {
                        echo '<table class="adminform" width="100%" cellspacing="1" cellpadding="4" border="0">';
                        echo '<tr><td colspan="2"></td></tr>';
                        echo "<tr > <td valign='top' align='right'>"./*_MEDIALIBRARY_LABEL_TRACK.":".**/"</td>";
                        if (count($tracks) > 0) {
                            for ($i = 0;$i < count($tracks);$i++) {
                                if($kay == $tracks[$i]->sequence_number){
                                    echo "<tr><td align='right'>" . _MEDIALIBRARY_LABEL_TRACK_UPLOAD_URL
                                         .($i + 1) . ":";
                                    echo "</td><td>";
                                    if (isset($tracks[$i]->src) && substr($tracks[$i]->src, 0, 4) != "http")
                                    echo "<input type='text' class='trackitems' size='60' value='" .
                                        'components/com_medialibrary/media/track/' 
                                        . $tracks[$i]->src . "' readonly='readonly'/>";
                                    elseif (isset($tracks[$i]->src) && substr($tracks[$i]->src, 0, 4) == "http")
                                    echo "<input type='text' class='trackitems' size='60' value='" . 
                                      $tracks[$i]->src . "' readonly='readonly'/>";
                                    // if (!empty($tracks[$i]->kind)) 
                                    //   echo "<input class='trackitems' type='text' size='60' value='" . 
                                    //     $tracks[$i]->kind . "' readonly='readonly'/>";
                                    if (!empty($tracks[$i]->scrlang)) 
                                      echo "<input class='trackitems' type='text' size='60' value='" . 
                                        $tracks[$i]->scrlang . "' readonly='readonly'/>";
                                    // if (!empty($tracks[$i]->label)) 
                                    //   echo "<input class='trackitems' type='text' size='60' value='" . 
                                    //     $tracks[$i]->label . "' readonly='readonly'/>";
                                    echo "</td></tr>";
                                    echo "<tr><td align='right'>"._MEDIALIBRARY_LABEL_TRACK_DELETE.($i + 1).":";
                                    echo "</td><td>";
                                    echo isset($tracks[$i]->id) ? "<input type=\"checkbox\" "
                                            ."name=\"track_option_del" . 
                                      $tracks[$i]->id . "\" value=\"" . $tracks[$i]->id . "\">" : "";
                                    echo "</td></tr>";
                                }
                            }
                        }?>
                        <tr>
                            <td></td>
                            <td id="track_items_add_here<?php echo $upload_videos;?>">
                                <span style="display: none;"></span>
                            </td>
                        </tr>
                        <tr>
                            <td id="t_items">
                                <input  type="button" name="new_track"
                                  value="<?php echo _MEDIALIBRARY_LABEL_ADD_NEW_TRACK; ?>" onClick="<?php 
                                    echo 'new_tracks(\''.$kay.'\',\'track_items_add_here'
                                         .$upload_videos."'"; ?>)" ID="t_add"/>
                            </td>
                        </tr>
                        
                    <?php  echo '</table>';
                        
                    echo    '</div>';
                    echo  '</div>';
                    
                    
                    echo '</div>';
                    $upload_videos++;
                    }
                    }
                    echo "</div>";
                    echo '<table class="adminform" width="100%" cellspacing="1" cellpadding="4" border="0">';
                // }
                // $upload_videos = 1;
                // foreach ($video_queue as $kay => $videos) {
                    if (!empty($videos[0]->youtube)) {
                        echo '<tr><td colspan="2"></td></tr>';
                        $youtubeCode = array('youtube'=> $videos[0]->youtube);
                        for ($i = 0;$i < count($youtubeCode);$i++) {
                            echo "<tr><td align='right' width='230'>"._MEDIALIBRARY_LABEL_VIDEO.' YouTube '
                                .$upload_videos.":";
                            echo "</td><td>";
                            if (isset($videos[0]->title) && $videos[0]->title != '') 
                                echo "<input type='text' name='video_youtube_title" . $upload_videos . "'
                                  id='video_youtube_title" . $upload_videos . "' size='60' value='" 
                                  . $videos[0]->title . "' readonly=\"readonly\"/>";
                            // echo "</td>";
                            // echo "<td>";
                            echo '<input type="button" name="show_altern_video" class="show-button" ';
                            echo ' value="'._MEDIALIBRARY_CATEGORIES__DETAILS.'" style="margin: -8px 0 0 5px;" ';
                            echo ' onclick="jQuery(\'.youtube-video-source'.$upload_videos.'\').toggle(\'slow\')"/>';
                            echo "</td></tr>";

                            echo '<tr class="youtube-video-source'.$upload_videos
                                    .'" style="display:none;"><td align="right">'
                                    ._MEDIALIBRARY_ADD_NEW_VIDEO_FILE.$upload_videos.':';
                            echo "</td><td>";
                            if (isset($youtubeCode['youtube'])) 
                                echo "<input type='text' name='video_youtube_code" . $upload_videos . "'
                                  id='video_youtube_code" . $upload_videos . "' size='60' value='" 
                                  . $youtubeCode['youtube'] . "' readonly=\"readonly\"/>"
                                  ._MEDIALIBRARY_LABEL_VIDEO_DELETE.$upload_videos.":";
                            echo isset($youtubeId) ? "<input type=\"checkbox\" name=\"youtube_option_del" . 
                              $videos[0]->id  . "\" value=\"" . $videos[0]->id  . "\">" : "";
                            echo "</td></tr>"
                            ;
                            $upload_videos++;
                        }
                    }
                } 
            }?>
            <tr>
              <td width='230' align='left'></td>
                <td ID="v_items">
                    <input type="button" name="new_video"
                      value="<?php echo _MEDIALIBRARY_ADD_NEW_VIDEO_FILE; ?>"
                      onClick="new_videos()" ID="v_add" style="display:block;"/>
              </td>
            </tr>
          <?php 
        }

  if ($medialibrary_configuration['audios']['allow']) {
                echo '</table>';
            echo '<div class="upload_audio-items" style="margin-left:243px">';
            $upload_audios = 1;
            $upload_sourcess = 1;
            $audio_queue = [];
            foreach ($audios as $kay => $value) {
                if ($value->sequence_number){
                    $audio_queue[$value->sequence_number][] = $value;
                } else {
                    $audio_queue[$value->id][] = $value;
                }
            }
            foreach ($audio_queue as $kay => $audios) {
                echo '<div class="upload_audio-item">';
                // echo '<img src="'.$media_class->imageURL.'" alt="image upload audio">';
                echo '<div style="position: absolute; margin: 8px 0 0 -112px;">'
                            ._MEDIALIBRARY_LABEL_AUDIO.$upload_audios.":".'</div>';
                    if (isset($audios[0]->title) && $audios[0]->title != '') 
                                echo '<input type="text" name="video_source_title' . $upload_audios . '"
                                  id="video_source_title"' . $upload_audios . '" size="60" value="' 
                                  .  $audios[0]->title . '" readonly="readonly"/>';
                echo '<input type="button" name="show_altern_audio" class="show-button"';
                echo 'value="'._MEDIALIBRARY_CATEGORIES__DETAILS.'" style="margin: -8px 0 0 5px;" ';
                echo 'onclick="jQuery(\'#altern-audio-source'.$upload_audios.'\').toggle(\'slow\')"/>';
                
                echo  '<div id="altern-audio-source'.$upload_audios.'" style = "display:none">';
                for ($i = 0;$i < count($audios);$i++) {
                    echo _MEDIALIBRARY_LABEL_AUDIO_ATTRIBUTE . ($i + 1) . ":";
                        $type_src =  explode('.', $audios[$i]->src);
                        echo  ' '.$type_src[(count($type_src)-1)];

                    echo  '<div class="altern-audio-one-source">';
                    if (isset($audios[$i]->src) && substr($audios[$i]->src, 0, 4) != "http" &&
                    empty($audios[$i]->youtube)){
                        echo "<input type='text' name='new_upload_audio" . $i . "' id='new_upload_audio" . $i 
                            . "' size='60' value='" . $audios[$i]->src . "' readonly='readonly' />";
                    } elseif (isset($audios[$i]->src) && substr($audios[$i]->src, 0, 4) == "http" &&
                    empty($audios[$i]->youtube)){
                        echo "<input type='text' name='new_upload_audio" .  $i . "' id='new_upload_audio_url" 
                            . $i . "' size='60' value='" . $audios[$i]->src . "' readonly='readonly' />";
                    }
                    echo _MEDIALIBRARY_LABEL_AUDIO_DELETE . ":";
                    echo isset($audios[$i]->id) ? "<input type=\"checkbox\" name=\"audio_option_del" . 
                      $audios[$i]->id . "\" value=\"" . $audios[$i]->id . "\">" : "";
                    echo  '</div>';
                }
                
                echo    '<div class="hidden-details upload-altern-audio'.$upload_audios.'">';
                echo    '<input type="button" name="new_altern_audio" ';
                echo    'value="'._MEDIALIBRARYLABEL_AUDIO_ADD_ALTERNATIVE_AUDIO.'"';
                echo    ' onclick="new_altern_audios(\''.$kay.'\',\'altern-audio-source'
                                 .$upload_audios.'\')" ID="new_altern_audio" style="display:block"/>';
                echo    '</div>';
                echo  '</div>';

                
                echo '</div>';
                $upload_audios++;
            }
            echo '</div>';
            echo '<table class="adminform" width="100%" cellspacing="1" cellpadding="4" border="0">';
            
            ?>
            <td width="232">
                <td ID="a_items">
                  <input  type="button" name="new_audio"
                  value="<?php echo _MEDIALIBRARYLABEL_ADD_NEW_AUDIO_FILE; ?>" onClick="new_audios()"
                  ID="a_add"/>
                </td>
            <td>    
        <?php 
        }

  if ($medialibrary_configuration['emedias']['allow']) {
      echo '<tr><td colspan="2"></td></tr>';
      echo "<tr > <td valign='top' align='right'><strong>" . _MEDIALIBRARY_LABEL_EMEDIA . ":</strong></td>";
      if (count($files) > 0) {
          for ($i = 0;$i < count($files);$i++) {
              echo "<tr><td align='right'>" . _MEDIALIBRARY_LABEL_EMEDIA_UPLOAD_URL . ($i + 1) . ":";
              echo "</td><td>";
              if (isset($files[$i]->location) && substr($files[$i]->location, 0, 4) != "http")
              echo "<input type='text' size='60' value='" . $mosConfig_live_site . $files[$i]->location .
                 "' readonly='readonly'/>";
              elseif (isset($files[$i]->location) && substr($files[$i]->location, 0, 4) == "http")
              echo "<input type='text' size='60' value='" . $files[$i]->location . "' readonly='readonly'/>";
              echo "</td></tr>";
              echo "<tr><td align='right'>" . _MEDIALIBRARY_LABEL_EMEDIA_DELETE . ":";
              echo "</td><td>";
              echo isset($files[$i]->id) ? "<input type=\"checkbox\" name=\"file_option_del" . 
                $files[$i]->id . "\" value=\"" . $files[$i]->id . "\">" : "";
              echo "</td></tr>";
          }
      }
      if (count($files) > 0) echo "<td>"; ?>
                  <td ID="f_items">
                      <input  type="button" name="new_file"
                      value="<?php echo "Add new emedia file"; ?>" onClick="new_files()"  ID="f_add"/>
                    </td>
  <?php if (count($files) > 0) echo "<td>";
  }?>
    <!-- **********************   begin change review   ***************************-->
     <?php if ($reviews > false) /*show, if review exist*/ { ?>
    <tr>
      <td colspan="7">
        <hr width="100%" size="2" align="left"> <h3><?php echo _MEDIALIBRARY_LABEL_REVIEWS; ?>:</h3>
      </td>
    </tr>
    <table class="adminlist">
      <tr class="row0">
        <td width="3%" valign="top" align="center">
          <div>#</div>
        </td>
        <td width="2%" valign="top" align="center">
          <div></div>
        </td>
        <td width="10%" valign="top" align="center">
          <strong><?php echo _MEDIALIBRARY_LABEL_REVIEW_TITLE; ?>:</strong>
        </td>
        <td width="10%" valign="top" align="center">
          <strong><?php echo _MEDIALIBRARY_LABEL_LEND_USER; ?>:</strong>
        </td>
        <td width="65%" valign="top" align="center">
          <strong><?php echo _MEDIALIBRARY_LABEL_REVIEW_COMMENT; ?>:</strong>
        </td>
        <td width="5%" valign="top" align="center">
          <strong><?php echo _MEDIALIBRARY_LABEL_PUB_DATE; ?>:</strong>
        </td>
        <td width="5%" valign="top" align="center">
          <strong><?php echo _MEDIALIBRARY_LABEL_REVIEW_RATING; ?>:</strong>
        </td>
      </tr>
     <?php for ($i = 0, $nn = 1;$i < count($reviews);$i++, $nn++) /*if not one comment*/ { ?>
      <tr class="row0">
        <td valign="top" align="center">
          <div><?php echo $nn; ?></div>
        </td>
        <td valign="top" align="center">
          <div>
          <?php echo "<input type='radio' id='cb" . $i . "' name='bid[]' value='" . 
            $medialibrary->id . "," . $reviews[$i]->id . "' onclick='Joomla.isChecked(this.checked);' />"; ?>
          </div>
        </td>
        <td valign="top" align="center">
          <div><?php print_r($reviews[$i]->title); ?></div>
        </td>
        <td valign="top" align="left">
          <div><?php print_r($reviews[$i]->name); ?></div>
        </td>
        <td valign="top" align="left">
            <div><?php print_r(strip_tags($reviews[$i]->comment)); ?></div>
            </td>
        <td valign="top" align="left">
          <div><?php print_r($reviews[$i]->date); ?></div>
        </td>
        <td valign="top" align="left">
          <div><img src="../components/com_medialibrary/images/rating-<?php echo $reviews[$i]->rating; ?>.gif" 
            alt="<?php echo ($reviews->rating[$i]) / 2; ?>" border="0" align="right"/>&nbsp;</div>
        </td>
      </tr>
        <?php
            } /*end for(...)*/ ?>

    </table>
    <?php
        } /*end if(...)*/ ?>

    </table>

    <input type="hidden" name="id" value="<?php echo $medialibrary->id; ?>" />
    <input type="hidden" name="media_id" value="<?php echo $media_class->id; ?>" />
    <input type="hidden" name="option" value="<?php echo $option; ?>" />
    <input type="hidden" id="media_type_field" name="media_type" value="<?php 
        echo $medialibrary->media_type; ?>" />
    <input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="task" value="" />
    </form>
    <!--*********************   end change review   **************************-->
    <?php
    }
    // show(edit) book



    static function editing_book($option, $medialibrary, $media_class, $clist, $wslist, $langlist,
      $ratinglist, $delete_edocument,
      $reviews, $type_list, $langshow = null,$files, $videos, $audios, $tracks, $youtubeCode, 
      $youtubeId, $associateArray, $authorsshow, $action) {
        global $my, $mosConfig_live_site, $mainframe, $medialibrary_configuration;
        global $doc,$database; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_SHOW . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;
?>
    <script language="javascript" type="text/javascript">

   function type_select(){
      var el = document.forms["adminForm"].elements["task"];
      el.value = "add";
      el = document.getElementById("media_type_field");
      var el2 = document.getElementById("media_type");
      el.value = el2.options[el2.selectedIndex].value;
      el = document.forms["adminForm"];
      el.submit();
      return ;
    }

     function findPosY(obj) {
      var curtop = 0;
      if (obj.offsetParent) {
          while (1) {
              curtop+=obj.offsetTop;
              if (!obj.offsetParent) {
                  break;
              }
              obj=obj.offsetParent;
          }
      } else if (obj.y) {
          curtop+=obj.y;
      }
      return curtop-20;
      }

    function trim(string) { return string.replace(/(^\s+)|(\s+$)/g, "");}



    /*function submitbutton(pressbutton) {*/
    Joomla.submitbutton = function(pressbutton) { // for 1.6
    var form = document.adminForm;
    var post_max_size = <?php echo return_bytes(ini_get('post_max_size')) ?>;
    var upl_max_fsize = <?php echo return_bytes(ini_get('upload_max_filesize')) ?>;
    var file_upl = <?php echo ini_get('file_uploads') ?>;
    var title = document.getElementById('title').value;
    var authors = document.getElementById("new_author_select").value;// for J 1.6
    var authorName = document.getElementById("new-author-field").value;// for J 1.6
    var informationFrom = document.adminForm.informationFrom.value;


    if (pressbutton == 'save' || pressbutton =='apply') {
        if (trim(form.asin_isbn.value) == '') {
            window.scrollTo(0,findPosY(form.asin_isbn)-100);
            form.asin_isbn.placeholder = "<?php
            echo _MEDIALIBRARY_ADMIN_INFOTEXT_JS_EDIT_ISBN_ASIN_CHECK; ?>";
            form.asin_isbn.style.borderColor = "#FF0000";
            form.asin_isbn.style.color = "#FF0000";
            return;
        }
       else if (form.catid.value == '0') {
            window.scrollTo(0,findPosY(form.catid)-100);
            form.catid.style.borderColor = "#FF0000";
            form.catid.style.color = "#FF0000";
            return;
        }
        else if ((title == '0' || title == '') && informationFrom == 0) {
            window.scrollTo(0,findPosY(form.title)-100);
            form.title.style.borderColor = "#FF0000";
            alert( "<?php echo _MEDIALIBRARY_LABEL_B_TITLE; ?>");
            return;
        }
        else if ((authors == '0' || authors == '') && informationFrom == 0) {
            if (authorName  == '0' || authorName  == '') {
                window.scrollTo(0,findPosY(authors)-100);
                alert( "<?php echo _MEDIALIBRARY_ADMIN_INFOTEXT_JS_EDIT_AUTHOR; ?>");
                return;
            }
        }

        for (i=1; document.getElementById('new_upload_video'+i); i++){
            if(document.getElementById('new_upload_video'+i).files != null){
                if(!file_upl){
                  window.scrollTo(0,findPosY(document.getElementById('new_upload_video'+i))-100);
                  document.getElementById('error_video').innerHTML = "<?php
                  echo _MEDIALIBRARY_ADMIN_SETTINGS_VIDEO_ERROR_UPLOAD_OFF; ?>";
                  document.getElementById('new_upload_video'+i).style.borderColor = "#FF0000";
                  document.getElementById('new_upload_video'+i).style.color = "#FF0000";
                  document.getElementById('error_video').style.color = "#FF0000";
                  return;
                }
                if(document.getElementById('new_upload_video'+i).files.length != 0 &&
                   document.getElementById('new_upload_video_youtube_code'+i).value != null) {
                if(document.getElementById('new_upload_video'+i).files[0].size >= post_max_size){
                  window.scrollTo(0,findPosY(document.getElementById('new_upload_video'+i))-100);
                  document.getElementById('error_video').innerHTML = "<?php
                  echo _MEDIALIBRARY_ADMIN_SETTINGS_VIDEO_ERROR_POST_MAX_SIZE; ?>";
                  document.getElementById('new_upload_video'+i).style.borderColor = "#FF0000";
                  document.getElementById('new_upload_video'+i).style.color = "#FF0000";
                  document.getElementById('error_video').style.color = "#FF0000";
                  return;
                }
              }
              if(document.getElementById('new_upload_video'+i).files.length != 0 &&
                 document.getElementById('new_upload_video_youtube_code'+i).value != null) {
                if(document.getElementById('new_upload_video'+i).files[0].size >= upl_max_fsize){
                  window.scrollTo(0,findPosY(document.getElementById('new_upload_video'+i))-100);
                  document.getElementById('error_video').innerHTML = "<?php
                  echo _MEDIALIBRARY_ADMIN_SETTINGS_VIDEO_ERROR_UPLOAD_MAX_SIZE; ?>";
                  document.getElementById('new_upload_video'+i).style.borderColor = "#FF0000";
                  document.getElementById('new_upload_video'+i).style.color = "#FF0000";
                  document.getElementById('error_video').style.color = "#FF0000";
                  return;
                }
            }
          }
        }
        if(form.new_upload_track_url1){
          for (i = 1;form.getElementById('new_upload_track_url'+i); i++) {
            if(form.getElementById('new_upload_track'+i).value != ''
              || form.getElementById('new_upload_track_url'+i).value != ''){
                if(form.getElementById('new_upload_track_kind'+i).value == ''){
                  window.scrollTo(0,findPosY(document.getElementById('new_upload_track_kind'+i))-100);
                  document.getElementById('new_upload_track_kind'+i).placeholder = "<?php
                    echo _MEDIALIBRARY_ADMIN_SETTINGS_INFOTEXT_JS_TRACK_KIND; ?>";
                  document.getElementById('new_upload_track_kind'+i).style.borderColor = "#FF0000";
                  document.getElementById('new_upload_track_kind'+i).style.color = "#FF0000";
                  return;
                }else if(form.getElementById('new_upload_track_scrlang'+i).value == ''){
                  window.scrollTo(0,findPosY(document.getElementById('new_upload_track_scrlang'+i))-100);
                  document.getElementById('new_upload_track_scrlang'+i).placeholder = "<?php
                    echo _MEDIALIBRARY_ADMIN_SETTINGS_INFOTEXT_JS_TRACK_LANGUAGE; ?>";
                  document.getElementById('new_upload_track_scrlang'+i).style.borderColor = "#FF0000";
                  document.getElementById('new_upload_track_scrlang'+i).style.color = "#FF0000";
                  return;
                }else if(form.getElementById('new_upload_track_label'+i).value == ''){
                  window.scrollTo(0,findPosY(document.getElementById('new_upload_track_label'+i))-100);
                  document.getElementById('new_upload_track_label'+i).placeholder = "<?php
                    echo _MEDIALIBRARY_ADMIN_INFOTEXT_JS_TRACK_TITLE; ?>";
                  document.getElementById('new_upload_track_label'+i).style.borderColor = "#FF0000";
                  document.getElementById('new_upload_track_label'+i).style.color = "#FF0000";
                  return;
                }
            }
        }
      submitform(pressbutton);
    }else {
      submitform(pressbutton);
    }
 } else {
      submitform( pressbutton );
    }
 }
 function checkDisabled(){}


 </script>
     <form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
     <table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform" id="media_table">
      <!-- anton code type -->
    <tr>
      <td valign="top" align="right" width="255">
        <strong><?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?>:</strong>
      </td>
      <td align="left">
        <?php echo $type_list; ?>
      </td>
    </tr>
    <!-- anton code -->
        <tr>
            <td width="15%" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_BOOKID; ?>:</strong>
            </td>
            <td width="85%" align="left">
                <input class="inputbox" type="text" name="media_type_id" size="20" maxlength="20" 
                  value="<?php echo $media_class->book_id; ?>" />
            </td>
        </tr>
        <tr>
            <td width="20%" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_ISBN; ?>*:</strong>
            </td>
            <td align="left">
                <input class="inputbox" type="text" name="asin_isbn" size="20" maxlength="20" 
                  value="<?php echo $media_class->isbn; ?>" />
            </td>
        </tr>



        <?php
          /*******************************************    language    *******************/
          if (!empty($associateArray) && !empty($media_class->langDescription) && 
                $media_class->langDescription != ''&& $media_class->langDescription != '*') {
          ?>
                  <tr>
                      <td width="15%"><?php echo 'language associate media' ?>:</td>
                  </tr>
        <?php
              $j = 1;
              foreach($associateArray as $lang => $value) {
                  $displ = '';
                  if (!$value['list']) {
                      $displ = 'none';
                  }
        ?>
                  <tr style="display: <?php echo $displ ?>">
                      <td width="15%"><?php echo $lang; ?>:</td>
                      <td width="60%"><?php echo $value['list']; ?>

                      <input class="inputbox" id="associate_media" type="text"
                              name="associate_media<?php echo $j; ?>" size="20"
                              readonly="readonly" maxlength="20" style="width:25px;"
                              value="<?php echo $value['assocId']; ?>" />

                      <input style="display: none" name="associate_media_lang<?php echo $j; ?>"
                              value="<?php echo $lang ?>"/>
                      </td>
                  </tr>
        <?php
                  $j++;
              }
          } else {
        ?>
                  <tr>
                      <td width="15%"><?php echo 'language associate media' ?>:</td>
                      <td width="60%"><?php echo 'this property only for media with language' ?>
                  </tr>
        <?php
          }
          /*********************************************************************************************/
        ?>





        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_LANGUAGE_DESCRIPTION; ?>:</strong>
            </td>
            <td align="left">
                <?php echo $langshow; ?>
            </td>
        </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_LANGUAGE; ?>:</strong>
            </td>
            <td align="left">
                <?php echo $langlist; ?>
            </td>
        </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_CATEGORY; ?>*:</strong>
            </td>
            <td align="left">
                <?php echo $clist; ?>
            </td>
        </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_FETCH_INFO; ?>:</strong>
            </td>
            <td align="left">
                <?php echo $wslist; ?>
                <img src="../components/com_medialibrary/images/amazon/com-logo.gif" alt="amazon.com" border="0"/>
             </td>
        </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_COMMENT; ?>:</strong>
            </td>
            <td align="left">
                <?php
        editorArea('editor1', $media_class->comment, 'comment', 500, 250, '70', '10');?>
                <!--<textarea name="comment" id="comment" cols="50" rows="25" style="width:800;height:200;"><?php 
                  /*echo $row->comment;*/ ?></textarea>-->
            </td>
        </tr>
        <tr>
          <td width="185"></td>
          <td><span id="error_video"></span></td>
      </tr>
        <tr>
            <td valign="top" align="right">&nbsp;
            </td>
            <td align="left">
                <?php echo _MEDIALIBRARY_ADMIN_TEXT_WSINFO_TEXT1; ?>
                <strong>
                <?php echo _MEDIALIBRARY_LABEL_FETCH_INFO; ?>
                ->
                <?php echo _MEDIALIBRARY_WS_NO; ?>
                </strong>
            </td>
        </tr>
            <!-- anton code type -->
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_TITLE; ?>*:</strong>
            </td>
            <td align="left">
                <input class="inputbox" type="text" id="title" name="title" size="80" value="<?php 
                    echo $media_class->title; ?>" />
            </td>
        </tr>
        <!-- ***********block book************* -->


           <tr>
                <td valign="top" align="right"><strong>
                    <?php echo _MEDIALIBRARY_LABEL_AUTHORS; ?>:</strong></td>
                <td align="left">
                    <div class="toggle-author">
                        <?php echo $authorsshow;?>
                    </div>
                    <input type="text" name="new_author_field" class="new-author-field toggle-author" 
                           id="new-author-field" style="display: none;"></input>
                    <div style="clear: both;"></div>
                    <input type="button" id="switch-enter-author" value="Change author field."
                           onclick="jQuery('.toggle-author').toggle('slow')" <?php 
                           if($medialibrary->get('informationFrom')) echo ' style="display: none;"';?>></input>
                </td>
            </tr>

        <tr >
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_MANUFACTURER; ?>:</strong>
            </td>
            <td align="left">
                <input  class="inputbox" type="text" name="manufacturer" size="80" value="<?php 
                  echo $media_class->manufacturer; ?>" />
            </td>
        </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_PUB_DATE; ?>:</strong>
            </td>
            <td align="left">
                <input  class="inputbox" type="text" name="release_date" size="30" value="<?php 
                  echo $media_class->release_date; ?>" />
            </td>
        </tr>

        <!-- ***********block************* -->
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_PRICE; ?> :</strong>
            </td>
            <td align="left">
                <input  class="inputbox" type="text" name="price" size="15" value="<?php 
                echo $media_class->price; ?>" />
                <input  class="inputbox" type="text" name="priceunit" size="6" 
                value="<?php echo $media_class->priceunit; ?>" />

            </td>
        </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_RATING; ?>:</strong>
            </td>
            <td align="left">
                <?php echo $ratinglist; ?>
            </td>
        </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_NUMPAGES; ?>:</strong>
            </td>
            <td align="left">
                <input  class="inputbox" type="text" name="numberOfPages" size="6" value="<?php 
                echo $media_class->numberOfPages; ?>" />
            </td>
        </tr>

        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_PICTURE_URL; ?>:</strong>
            </td>
            <!-- /////////////////////////////Begin AddPatch CODE///////////////////-->
            <td align="left">

                <input  class="inputbox" type="text" name="imageURL" size="80" value="<?php 
                echo $media_class->imageURL; ?>" />
                <input  class="inputbox" type="button" name="default_patch" 
                value="Set Local Cover Path" onClick="build_patch()" />

               <script language="javascript" type="text/javascript">

              window.onload = function(){
              var button_video = document.getElementById("v_add");
              var allowed_vid_files = 5;
              <?php if (count($videos) > 0) echo "allowed_files = " . (5 - count($videos)) . ";"; ?>
                if(allowed_vid_files >= 1) {
                  button_video.removeAttribute("style");
                  }
                var button_audio = document.getElementById("a_add");
                var allowed_aud_files = 5;
                <?php if (count($audios) > 0) echo "allowed_files = " . (5 - count($audios)) . ";"; ?>
                  if(allowed_aud_files >= 1) {
                  button_audio.removeAttribute("style");
                  }
                // for (var i=1; i < 5; i++) {
                //   var add =  document.getElementById('new_upload_video_youtube_code'+i).value;
                //     if(add.length){
                //         var obj = document.getElementById('v_add');
                //         obj.style.display = "none";
                //       }
                //   }
              }
                jQuery('#informationFrom').change(function() {
                    var amazonServ = jQuery('#informationFrom').val();
                    if (amazonServ === '0'){
                        jQuery('#switch-enter-author').css('display', 'block');
                    } else {
                        jQuery('#switch-enter-author').css('display', 'none');
                    }
                });
            </script>

                <script type="text/javascript" language="javascript">
                function build_patch()
                {
                var asin_isbn = "<?php echo $media_class->isbn; ?>" ;
                    var url = 'components/com_medialibrary/asin_isbn_build.php';
                    <?php $cover_path = $medialibrary_configuration['fetchImages']['location']; ?>
                    var cover_path = "<?php echo $cover_path; ?>";
                    if (window.XMLHttpRequest)
                    {
                        // Mozilla, Safari,...
                        http_request = new XMLHttpRequest();
                        if (http_request.overrideMimeType)
                        {
                            http_request.overrideMimeType('text/xml');
                        }
                    }
                    else if (window.ActiveXObject)
                    {
                        // IE
                        try
                        {
                            http_request = new ActiveXObject("Msxml2.XMLHTTP");
                        }
                        catch (e)
                        {
                            try
                            {
                                http_request = new ActiveXObject("Microsoft.XMLHTTP");
                            }
                            catch (e)
                            {}
                        }
                    }
                    if (!http_request)
                    {
                        alert('Giving up :( Cannot create an XMLHTTP instance');
                        return false;
                    }
                    http_request.onreadystatechange = alertContents;
                    http_request.open("POST", url, true);
                    http_request.setRequestHeader('Content-Type' , 'application/x-www-form-urlencoded');
                    http_request.send('asin_isbn='+asin_isbn+'&cover_path='+cover_path);
                }

                function alertContents()
                {
                    if (http_request.readyState == 4)
                    {
                        if (http_request.status == 200)
                        {
                            if (http_request.responseText == 1)
                            {
                                alert("<?php echo _MEDIALIBRARY_TOOLBAR_NEW_MEDIA_INCORRECT_FOLDER . " " 
                                    . $cover_path; ?>");
                            }
                            if (http_request.responseText == false)
                            {
                                alert("<?php echo _MEDIALIBRARY_TOOLBAR_NEW_MEDIA_INCORRECT_FILE; ?>");
                            }
                            else
                            {
                              document.adminForm.imageURL.value = http_request.responseText;
                            }
                        }
                        else
                        {
                            alert('There was a problem with the request.');
                        }
                    }
                }
                </script>
            </td>

        </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_PICTURE_URL_UPLOAD; ?>:</strong>
            </td>
            <td align="left">
              <input class="inputbox" type="file" name="picture_file" value="" size="50" maxlength="250" />
              <br /><?php echo _MEDIALIBRARY_LABEL_PICTURE_URL_DESC; ?>
      <?php
        if ($media_class->imageURL != "" && !strstr($media_class->imageURL, "http")) {
            echo '<div><img class="bl_view_media_image" src="' . $mosConfig_live_site . '' 
                . $media_class->imageURL .
                '" alt="' . $media_class->title . '" border="0"
                              height="' . $medialibrary_configuration['foto']['high'] . '" width="' .
                              $medialibrary_configuration['foto']['width'] .
                '"/></div>';
        } else if ($media_class->imageURL != "" && strstr($media_class->imageURL, "http")) {
            echo '<div><img class="bl_view_media_image" src="' . $media_class->imageURL . '" alt="' .
                $media_class->title . '" border="0"
                height="' . $medialibrary_configuration['foto']['high'] . '" width="' .
                $medialibrary_configuration['foto']['width'] .
                  '"/></div>';
        }
    ?>
        </td>
        </tr>
        <tr>
            <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_URL; ?>:</strong>
            </td>
            <td align="left">
                <input  class="inputbox" type="text" name="URL" size="80" value="<?php 
                    echo $media_class->URL; ?>" />
            </td>
        </tr>
        <tr>
        <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_MEDIAOWNER; ?>:</strong>
            </td>
            <td valign="top" align="left">
               <input  class="inputbox" type="text" name="owneremail" size="50" 
               value="<?php echo $medialibrary->owneremail; ?>"/>
            </td>
        </tr>
        <td valign="top" align="right">
                <strong><?php echo _MEDIALIBRARY_LABEL_MEDIAOWNER_ID; ?>:</strong>
            </td>
        <td align="left">
        <?php  echo $medialibrary->name = JFactory::getUser($medialibrary->owner_ID)->name; ?>
        <?php $user = JFactory::getUser();?>
        <input type="text" name="owner_ID" size="80" value="<?php if(!$medialibrary->owner_ID) {
                echo $user->id;
            } else {
                echo $medialibrary->owner_ID;
            } ?>" />
        </td>

        <tr>
                <td valign="top" align="right">
                        <strong><?php echo _MEDIALIBRARY_LOAD_ARTICLE_BOOK; ?>:</strong>
                    
                    <?php if (version_compare(JVERSION, "1.7.0", "ge")) { ?>
                               <?php 
                                    echo mosToolTip('', _MEDIALIBRARY_LOAD_ARTICLE_BOOK_TT_BODY, '', 
                                    JURI::root() . '/components/com_medialibrary/images/circle-info.png');?>
                    </td>

                            <?php } else { ?>

                                <?php 
                                    echo mosToolTip('', _MEDIALIBRARY_LOAD_ARTICLE_BOOK_TT_BODY, '', 
                                    '../../../components/com_medialibrary/images/circle-info.png');?>
                     </td>

                    <?php } ?>

                    <td align="left">
                        <?php echo $medialibrary->modal_article; ?>
                    </td>
                </tr>

                   <?php if (!empty($media_class->id_article_book)) { ?>

                <tr>
                    <td align="right"><strong><?php echo _MEDIALIBRARY_DELETE_ARTICLE_BOOK; ?></strong> 
                    </td>

                    <td>
                        <input type=checkbox name="article_book_del" value="<?php echo $media_class->id;?>"/>
                    </td>
                </tr>

                    <?php } ?>


   <!---------------------------------Start AJAX load track------------------------------>

  <script language="javascript" type="text/javascript">
                var request = null;
                var tid=1;
                function createRequest_track() {
                    if (request != null)
                    return;
                    try {
                       request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                           request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }

                function testInsert_track(id1,upload){
                    for(var i=1; i< upload_tracks; i++){
                        if(upload.id != ('new_upload_track'+i) &&
                        document.getElementById('new_upload_track'+i).value == upload.value){
                            return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1_track(id1,upload){
                    id=id1;
                    if(testInsert_audio(id1,upload)){
                        createRequest_track();
                        var url = "<?php echo $mosConfig_live_site . 
                        "/administrator/index.php?option=$option&task=randNumber&format=raw";
                        ?>&file="+encodeURI(upload.value)+"&path=<?php
                        echo str_replace("\\", "/", $mosConfig_live_site) . 
                        '/components/com_medialibrary/media/track/'?>";
                       try{
                        request.onreadystatechange = updateRandNumber1_track;
                        request.open("GET", url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert("You alredy select this track file");
                        upload.value="";
                    }
                }

                function updateRandNumber1_track() {
                    if (request.readyState == 4) {
                        document.getElementById("randNumTrack"+tid).innerHTML = request.responseText;
                    }
                }
  </script>

 <!-------------------------------- END Ajax load track---------------------------------->


 <!-------------------------------- END Ajax load audio---------------------------------->
  <script language="javascript" type="text/javascript">
                var request = null;
                var aid=1;
                function createRequest_audio() {
                    if (request != null)
                    return;
                    try {
                          request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                           request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }

                function testInsert_audio(id1,upload){
                    for(var i=1; i< upload_audios; i++){
                        if(upload.id != ('new_upload_audio'+i) &&
                        document.getElementById('new_upload_audio'+i).value == upload.value){
                            return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1_audio(id1,upload){
                    id=id1;
                    if(testInsert_audio(id1,upload)){
                        createRequest_audio();
                        var url = "<?php echo $mosConfig_live_site . 
                        "/administrator/index.php?option=$option&task=randNumber&format=raw";
                        ?>&file="+encodeURI(upload.value)+"&path=<?php
                        echo str_replace("\\", "/", $mosConfig_live_site) . 
                        '/components/com_medialibrary/media/audio/'?>";
                       try{
                        request.onreadystatechange = updateRandNumber1_audio;
                        request.open("GET", url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert( "You alredy select this audio file");
                        upload.value="";
                    }
                }

                function updateRandNumber1_audio(){
                    if (request.readyState == 4) {
                        document.getElementById("randNumAudio"+aid).innerHTML = request.responseText;
                    }
                }
  </script>

<!-------------------------------- END Ajax load audio---------------------------------->


<!-------------------------------- START Ajax load video---------------------------------->


            <script language="javascript" type="text/javascript">

               var request = null;
               var vid=1;

               function createRequest_video(){
                    if (request != null)
                    return;
                    try {
                       request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                            request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }

                function testInsertVideo1(id1,upload){
                    for(var i=1 ;i< upload_videos; i++){
                        if(upload.id != ('new_upload_video'+i) &&
                        document.getElementById('new_upload_video'+i).value == upload.value)
                        {
                          return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1_video(id1,upload){
                    id=id1;
                    if(testInsertVideo1(id1,upload)){
                        createRequest_video();
                    var url = "<?php echo $mosConfig_live_site . 
                    "/administrator/index.php?option=$option&task=randNumber&format=raw";
                    ?>&file="+encodeURI(upload.value)+"&path=<?php echo str_replace("\\", "/", $mosConfig_live_site) .
                     '/components/com_medialibrary/media/video/'?>";
                       try{
                        request.onreadystatechange = updateRandNumber1_video;
                        request.open("GET",url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert("You alredy select this video file");
                        upload.value="";
                    }
                }

                function updateRandNumber1_video() {
                    if (request.readyState == 4) {
                        document.getElementById("randNumVideo"+vid).innerHTML = request.responseText;
                    }
                }
                </script>

  <!-------------------------------- END Ajax load video---------------------------------->


  <!---------------------------------Start AJAX load file------------------------------>


               <script language="javascript" type="text/javascript">

                var request = null;
                var fid=1;
                function createRequest() {
                    if (request != null)
                    return;
                    try {
                        request = new XMLHttpRequest();
                    } catch (trymicrosoft) {
                        try {
                               request = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (othermicrosoft) {
                            try {
                                request = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (failed) {
                                request = null;
                            }
                        }
                    }
                    if (request == null)
                        alert(" :-( ___ Error creating request object! ");
                }


                function testInsertFile1(id1,upload){
                    for(var i=1; i< upload_files; i++){
                        if(upload.id != ('new_upload_file'+i) &&
                        document.getElementById('new_upload_file'+i).value==upload.value){
                            return false;
                        }
                    }
                    return true;
                }

                function refreshRandNumber1(id1,upload) {
                    id=id1;
                    if(testInsertFile1(id1,upload)){
                        createRequest();
                        var url = "<?php echo $mosConfig_live_site . 
                        "/administrator/index.php?option=$option&task=randNumber&format=raw";
                        ?>&file="+encodeURI(upload.value)+"&path=<?php
                        echo str_replace("\\", "/", $mosConfig_live_site)
                            .'/components/com_medialibrary/emedia/'?>";
                        try{
                        request.onreadystatechange = updateRandNumber1;
                        request.open("GET",url,true);
                        request.send(null);
                        }catch (e)
                        {
                            alert(e);
                        }
                    }
                    else
                    {
                        alert( "You alredy select this file");
                        upload.value="";
                    }
                }
                function updateRandNumber1() {
                    if (request.readyState == 4) {
                        document.getElementById("randNumFile"+fid).innerHTML = request.responseText;
                    }
                }
                </script>

<!-------------------------------- END Ajax load file ---------------------------------->






  <script language="javascript" type="text/javascript">
    var upload_tracks=0;
    function new_tracks(index, div0){
        // div=document.getElementById("t_items");
        // button=document.getElementById("t_add");
        div = document.getElementById(div0);
        button=document.getElementById(div0);
        upload_tracks++;
        newitem="<table width='50%'><tr><td width='15%'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_LABEL_TRACK_UPLOAD ?>"+upload_tracks+": </strong></td>";
        newitem+="<td width='85%'>";
        newitem+="<input type='hidden' name='new_upload_track"+upload_tracks;
        newitem+="' value='"+index+"' />";
        
        newitem+="<input style=\"float:left; width:100%\" type=\"file\" "+
        "onClick=\"document.adminForm.new_upload_track"+upload_tracks+".value ='';\" " +
        " onChange=\"refreshRandNumber1_track("+upload_tracks+
        ",this);\"  name=\"new_upload_track"+upload_tracks+"\" "+"id=\"new_upload_track"+upload_tracks;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumTrack"+upload_tracks+"\" ";
        newitem+="style=\"color:red;\"></span></td></tr></td></tr>"+ "<tr><td ";
        newitem+="style=\"text-align:center\"> OR </td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        newitem="<table width='50%'><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_TRACK_UPLOAD_URL; ?>" +upload_tracks+ ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
          "name=\"new_upload_track_url"+upload_tracks+"\" "+"id=\"new_upload_track_url"+upload_tracks;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        div.appendChild(newnode,button);
        newitem="<table width='50%' style=\"display:none;\"><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_CONFIG_TRACK_UPLOAD_KIND; ?>" +upload_tracks+ ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left;display:none; width:90%\" type=\"text\" "+
          "name=\"new_upload_track_kind"+upload_tracks+"\" "+"id=\"new_upload_track_kind"+upload_tracks;
        newitem+="\" value=\"eng\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        div.appendChild(newnode,button);
        newitem="<table width='50%'><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_TRACK_UPLOAD_SCRLANG; ?>" +upload_tracks+ ": ";
        newitem+="</strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
          " name=\"new_upload_track_scrlang"+upload_tracks+"\" ";
        newitem+="id=\"new_upload_track_scrlang"+upload_tracks;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);

        div.appendChild(newnode,button);
        newitem="<table width='50%' style=\"display:none;\"><tr><td width='15%'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_TRACK_UPLOAD_LABEL; ?>" +upload_tracks+ ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
        "name=\"new_upload_track_label"+upload_tracks+"\" "+"id=\"new_upload_track_label"+upload_tracks;
        newitem+="\" value=\"eng\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
    }
    </script>

   <script language="javascript" type="text/javascript">
    var upload_videos=0;
    function new_videos(){
        div=document.getElementById("v_items");
        button=document.getElementById("v_add");
        upload_videos++;
        newitem="<table width='50%'><tr><td width='160px'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD ?>" +upload_videos+ ": </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:150%\" type=\"file\" "+
        "onClick=\"document.adminForm.new_upload_video_url"+upload_videos+".value ='';\" " +
        " onChange=\"refreshRandNumber1_video("+upload_videos+
        ",this);\" name=\"new_upload_video"+upload_videos+"\" "+"id=\"new_upload_video"+upload_videos;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumVideo"+upload_videos+"\" style=\"color:red;\">"+
        "</span></td></tr></td></tr><tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD_URL; ?>" +upload_videos+ ": </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" "+
        "name=\"new_upload_video_url"+upload_videos+"\" "+"id=\"new_upload_video_url"+upload_videos;
        newitem+="\" value=\"\"size=\"45\"></td></tr></td></tr></td></tr>"+
        "<tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD_YOUTUBE_CODE; ?>" + ": </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" "+
        "name=\"new_upload_video_youtube_code"+upload_videos+"\" ";
        newitem+="id=\"new_upload_video_youtube_code"+upload_videos;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br/>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        var allowed_files = 5;
        if(upload_videos + <?php echo count($videos); ?> >= allowed_files) {
         button.setAttribute("style","display:none");
        }
    }
  </script>


   <script language="javascript" type="text/javascript">
    var upload_video_altern_id=1;
    function new_altern_videos(index, div0){
        div = document.getElementById(div0);
        button=document.getElementById(div0);
        upload_altern_videos = index;
        newitem="<table width='50%'><tr><td width='160px'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD ?>: </strong></td>";
        newitem+="<td width='400px'>";
        newitem+="<input type='hidden' name='new_upload_altern_video"+upload_video_altern_id+"' ";
        newitem+="value='"+index+"' />";
        newitem+="<input style=\"float:left; width:150%\" type=\"file\" "+
        " onClick=\"document.adminForm.new_upload_altern_video_url"+upload_altern_videos+".value ='';\" " +
        " onChange=\"refreshRandNumber1_video("+upload_altern_videos+
        ",this);\" name=\"new_upload_altern_video"+upload_video_altern_id+"\" ";
        newitem+="id=\"new_upload_altern_video"+upload_video_altern_id;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumVideo"+upload_video_altern_id+"\" ";
        newitem+="style=\"color:red;\"></span></td></tr></td></tr>"
        +"<tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_VIDEO_UPLOAD_URL; ?>: </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" ";
        newitem+="name=\"new_upload_altern_video_url"+
          upload_altern_videos+"\" "+"id=\"new_upload_altern_video_url"+upload_altern_videos;
        newitem+="\" value=\"\"size=\"45\"></td></tr></td></tr></td></tr>"+
          "<tr><td style=\"text-align:center\"></td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        // var allowed_files = 5;
        // if(upload_altern_videos + <?php echo count($videos); ?> >= allowed_files) {
        //  button.setAttribute("style","display:none");
        // }
        upload_video_altern_id++;
    }
  </script>

   
  <script language="javascript" type="text/javascript">
    var upload_audios=0;
    function new_audios(){
        div=document.getElementById("a_items");
        button=document.getElementById("a_add");
        upload_audios++;
        newitem="<table width='50%'><tr><td width='15%'><strong style=\"float:left\">" + 
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD ?>" + upload_audios + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:100%\" type=\"file\" "+
        "onClick=\"document.adminForm.new_upload_audio_url"+upload_audios+".value ='';\" " +
        " onChange=\"refreshRandNumber1_audio("+upload_audios+
        ",this);\"  name=\"new_upload_audio"+upload_audios+"\" "+"id=\"new_upload_audio"+upload_audios;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumAudio"+upload_audios+"\" style=\"color:red;\"></span></td></tr>"+
        "<tr><td style=\"text-align:center\"> OR </td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='15%'><strong>" + 
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD_URL; ?>" + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
        "name=\"new_upload_audio_url"+upload_audios+"\" "+"id=\"new_upload_audio_url"+upload_audios;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br />";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
         var allowed_aud_files = 5;
        if(upload_audios + <?php echo count($audios); ?> >= allowed_aud_files) {
         button.setAttribute("style","display:none");
        }
    }
  </script>


   <script language="javascript" type="text/javascript">
    var upload_audio_altern_id=1;
    function new_altern_audios(index, div0){
        div = document.getElementById(div0);
        button=document.getElementById(div0);
        upload_altern_audios = index;
        newitem="<table width='50%'><tr><td width='160px'><strong style=\"float:left\">" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD ?>: </strong></td>";
        newitem+="<td width='400px'>";
        newitem+="<input type='hidden' name='new_upload_altern_audio"+upload_audio_altern_id+"' ";
        newitem+="value='"+index+"' />";
        newitem+="<input style=\"float:left; width:150%\" type=\"file\" "+
        " onClick=\"document.adminForm.new_upload_altern_audio_url"+upload_altern_audios+".value ='';\" " +
        " onChange=\"refreshRandNumber1_audio("+upload_altern_audios+
        ",this);\" name=\"new_upload_altern_audio"+upload_audio_altern_id+"\" ";
        newitem+="id=\"new_upload_altern_audio"+upload_audio_altern_id;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumaudio"+upload_audio_altern_id+"\" ";
        newitem+="style=\"color:red;\"></span></td></tr></td></tr>"
        +"<tr><td style=\"text-align:center\">OR</td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        newitem="<table width='50%'><tr><td width='160px'><strong>" +
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_AUDIO_UPLOAD_URL; ?>: </strong></td>";
        newitem+="<td width='400px'><input style=\"float:left; width:90%\" type=\"text\" ";
        newitem+="name=\"new_upload_altern_audio_url"+
          upload_altern_audios+"\" "+"id=\"new_upload_altern_audio_url"+upload_altern_audios;
        newitem+="\" value=\"\"size=\"45\"></td></tr></td></tr></td></tr>"+
          "<tr><td style=\"text-align:center\"></td><td></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.appendChild(newnode,button);
        // var allowed_files = 5;
        // if(upload_altern_audios + <?php echo count($audios); ?> >= allowed_files) {
        //  button.setAttribute("style","display:none");
        // }
        upload_audio_altern_id++;
    }
  </script>
  
 <script language="javascript" type="text/javascript">
    var upload_files=0;
    function new_files(){
        div=document.getElementById("f_items");
        button=document.getElementById("f_add");
        upload_files++;
        newitem="<table width='50%'><tr><td width='15%'><strong style=\"float:left\">" + 
        "<?php echo _MEDIALIBRARY_ADMIN_LABEL_EBOOK_UPLOAD ?>" + upload_files + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:100%\" type=\"file\" "+
        "onClick=\"document.adminForm.new_upload_file_url"+upload_files+".value ='';\" " +
        " onChange=\"refreshRandNumber1("+upload_files+
        ",this);\"  name=\"new_upload_file"+upload_files+"\" "+"id=\"new_upload_file"+upload_files;
        newitem+="\" value=\"\"size=\"45\">";
        newitem+="<span id=\"randNumFile"+upload_files+"\" style=\"color:red;\"></span></td></tr></table>";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
        newitem="<table width='50%'><tr><td width='15%'><strong>" +
         "<?php echo _MEDIALIBRARY_ADMIN_LABEL_EBOOK_UPLOAD_URL; ?>" + ": </strong></td>";
        newitem+="<td width='85%'><input style=\"float:left; width:90%\" type=\"text\" "+
        "name=\"new_upload_file_url"+upload_files+"\" "+"id=\"new_upload_file_url"+upload_files;
        newitem+="\" value=\"\"size=\"45\"></td></tr></table><br><br />";
        newnode=document.createElement("span");
        newnode.innerHTML=newitem;
        div.insertBefore(newnode,button);
    }
  </script>

    <?php
    if ($medialibrary_configuration['videos_tracks']['allow']) {
            if (count($videos) > 0 ) {
                 $upload_videos = 1;
                $upload_sourcess = 1;
                $video_queue = [];
                foreach ($videos as $kay => $value) {
                    if ($value->sequence_number){
                        $video_queue[$value->sequence_number][] = $value;
                    } else {
                        $video_queue[$value->id][] = $value;
                    }
                }
                foreach ($video_queue as $kay => $videos) {
                    echo '</table>';
                    echo '<div class="upload_video-items" style="margin-left:243px">';
                    if (empty($videos[0]->youtube)) {
                    echo '<div class="upload_video-item">';
                    //echo '<img src="'.$media_class->imageURL.'" alt="image upload video">';
                    echo '<div style="position: absolute; margin: 8px 0 0 -112px;">'
                            ._MEDIALIBRARY_LABEL_VIDEO.$upload_videos.":".'</div>';
                    if (isset($videos[0]->title) && $videos[0]->title != '') 
                                echo "<input type='text' name='video_source_title" . $upload_videos . "'
                                  id='video_source_title" . $upload_videos . "' size='60' value='" 
                                  . $videos[0]->title . "' readonly=\"readonly\"/>";
                    echo '<input type="button" name="show_altern_video" class="show-button" ';
                    echo ' value="'._MEDIALIBRARY_CATEGORIES__DETAILS.'"  style="margin: -8px 0 0 5px;" ';
                    echo ' onclick="jQuery(\'#altern-video-source'.$upload_videos.'\').toggle(\'slow\')"/>';
                    
                    echo  '<div id="altern-video-source'.$upload_videos.'" style = "display:none">';
                    for ($i = 0;$i < count($videos);$i++) {
                        echo _MEDIALIBRARY_LABEL_VIDEO_ATTRIBUTE . ($i + 1) . ":";
                            $type_src =  explode('.', $videos[$i]->src);
                            echo  ' '.$type_src[(count($type_src)-1)];

                        echo  '<div class="altern-video-one-source">';
                        if (isset($videos[$i]->src) && substr($videos[$i]->src, 0, 4) != "http" &&
                        empty($videos[$i]->youtube)){
                            echo "<input type='text' name='new_upload_video" . $i . "' id='new_upload_video" . $i 
                                . "' size='60' value='" . $videos[$i]->src . "' readonly='readonly' />";
                        } elseif (isset($videos[$i]->src) && substr($videos[$i]->src, 0, 4) == "http" &&
                        empty($videos[$i]->youtube)){
                            echo "<input type='text' name='new_upload_video" .  $i 
                                . "' id='new_upload_video_url" . $i 
                                . "' size='60' value='" . $videos[$i]->src . "' readonly='readonly' />";
                        }
                        echo _MEDIALIBRARY_LABEL_VIDEO_DELETE . ":";
                        echo isset($videos[$i]->id) ? "<input type=\"checkbox\" name=\"video_option_del" . 
                          $videos[$i]->id . "\" value=\"" . $videos[$i]->id . "\">" : "";
                        echo  '</div>';
                    }?>
                        <div id="upload-altern-video_add_here<?php echo $upload_videos;?>">
                            <span style="display: none;"></span>
                        </div>
                    <?php
                    echo    '<div class="hidden-details upload-altern-video'.$upload_videos.'">';
                    echo    '<input type="button" name="new_altern_video" ';
                    echo    ' value="'._MEDIALIBRARYLABEL_VIDEO_ADD_ALTERNATIVE_VIDEO.'"';
                    echo    ' onclick="new_altern_videos(\''.$kay.'\',\'upload-altern-video_add_here'
                                     .$upload_videos.'\')" ID="new_altern_video" style="display:block"/>';
                    if ($medialibrary_configuration['videos_tracks']['allow']) {
                        echo '<table class="adminform" width="100%" cellspacing="1" cellpadding="4" border="0">';
                        echo '<tr><td colspan="2"></td></tr>';
                        echo "<tr > <td valign='top' align='right'>"./*_MEDIALIBRARY_LABEL_TRACK.":".**/"</td>";
                        if (count($tracks) > 0) {
                            for ($i = 0;$i < count($tracks);$i++) {
                                if($kay == $tracks[$i]->sequence_number){
                                    echo "<tr><td align='right'>" . _MEDIALIBRARY_LABEL_TRACK_UPLOAD_URL
                                         .($i + 1) . ":";
                                    echo "</td><td>";
                                    if (isset($tracks[$i]->src) && substr($tracks[$i]->src, 0, 4) != "http")
                                    echo "<input type='text' class='trackitems' size='60' value='" .
                                        'components/com_medialibrary/media/track/' 
                                        . $tracks[$i]->src . "' readonly='readonly'/>";
                                    elseif (isset($tracks[$i]->src) && substr($tracks[$i]->src, 0, 4) == "http")
                                    echo "<input type='text' class='trackitems' size='60' value='" . 
                                      $tracks[$i]->src . "' readonly='readonly'/>";
                                    // if (!empty($tracks[$i]->kind)) 
                                    //   echo "<input class='trackitems' type='text' size='60' value='" . 
                                    //     $tracks[$i]->kind . "' readonly='readonly'/>";
                                    if (!empty($tracks[$i]->scrlang)) 
                                      echo "<input class='trackitems' type='text' size='60' value='" . 
                                        $tracks[$i]->scrlang . "' readonly='readonly'/>";
                                    // if (!empty($tracks[$i]->label)) 
                                    //   echo "<input class='trackitems' type='text' size='60' value='" . 
                                    //     $tracks[$i]->label . "' readonly='readonly'/>";
                                    echo "</td></tr>";
                                    echo "<tr><td align='right'>"._MEDIALIBRARY_LABEL_TRACK_DELETE.($i + 1).":";
                                    echo "</td><td>";
                                    echo isset($tracks[$i]->id) ? "<input type=\"checkbox\" "
                                            ."name=\"track_option_del" . 
                                      $tracks[$i]->id . "\" value=\"" . $tracks[$i]->id . "\">" : "";
                                    echo "</td></tr>";
                                }
                            }
                        }?>
                        <tr>
                            <td></td>
                            <td id="track_items_add_here<?php echo $upload_videos;?>">
                                <span style="display: none;"></span>
                            </td>
                        </tr>
                        <tr>
                            <td id="t_items">
                                <input  type="button" name="new_track"
                                  value="<?php echo _MEDIALIBRARY_LABEL_ADD_NEW_TRACK; ?>" onClick="<?php 
                                    echo 'new_tracks(\''.$kay.'\',\'track_items_add_here'
                                         .$upload_videos."'"; ?>)" ID="t_add"/>
                            </td>
                        </tr>
                        
                    <?php  echo '</table>';
                        
                    echo    '</div>';
                    echo  '</div>';
                    
                    
                    echo '</div>';
                    $upload_videos++;
                    }
                    }
                    echo "</div>";
                    echo '<table class="adminform" width="100%" cellspacing="1" cellpadding="4" border="0">';
                // }
                // $upload_videos = 1;
                // foreach ($video_queue as $kay => $videos) {
                    if (!empty($videos[0]->youtube)) {
                        echo '<tr><td colspan="2"></td></tr>';
                        $youtubeCode = array('youtube'=> $videos[0]->youtube);
                        for ($i = 0;$i < count($youtubeCode);$i++) {
                            echo "<tr><td align='right' width='230'>"._MEDIALIBRARY_LABEL_VIDEO.' YouTube '
                                .$upload_videos.":";
                            echo "</td><td>";
                            if (isset($videos[0]->title) && $videos[0]->title != '') 
                                echo "<input type='text' name='video_youtube_title" . $upload_videos . "'
                                  id='video_youtube_title" . $upload_videos . "' size='60' value='" 
                                  . $videos[0]->title . "' readonly=\"readonly\"/>";
                            // echo "</td>";
                            // echo "<td>";
                            echo '<input type="button" name="show_altern_video" class="show-button" ';
                            echo ' value="'._MEDIALIBRARY_CATEGORIES__DETAILS.'" style="margin: -8px 0 0 5px;" ';
                            echo ' onclick="jQuery(\'.youtube-video-source'.$upload_videos.'\').toggle(\'slow\')"/>';
                            echo "</td></tr>";

                            echo '<tr class="youtube-video-source'.$upload_videos
                                    .'" style="display:none;"><td align="right">'
                                    ._MEDIALIBRARY_ADD_NEW_VIDEO_FILE.$upload_videos.':';
                            echo "</td><td>";
                            if (isset($youtubeCode['youtube'])) 
                                echo "<input type='text' name='video_youtube_code" . $upload_videos . "'
                                  id='video_youtube_code" . $upload_videos . "' size='60' value='" 
                                  . $youtubeCode['youtube'] . "' readonly=\"readonly\"/>"
                                  ._MEDIALIBRARY_LABEL_VIDEO_DELETE.$upload_videos.":";
                            echo isset($youtubeId) ? "<input type=\"checkbox\" name=\"youtube_option_del" . 
                              $videos[0]->id  . "\" value=\"" .  $videos[0]->id  . "\">" : "";
                            echo "</td></tr>"
                            ;
                            $upload_videos++;
                        }
                    }
                } 
            }?>
            <tr>
              <td width='230' align='left'></td>
                <td ID="v_items">
                    <input type="button" name="new_video"
                      value="<?php echo _MEDIALIBRARY_ADD_NEW_VIDEO_FILE; ?>"
                      onClick="new_videos()" ID="v_add" style="display:block;"/>
              </td>
            </tr>
          <?php 
        }

        if ($medialibrary_configuration['audios']['allow']) {
                echo '</table>';
            echo '<div class="upload_audio-items" style="margin-left:243px">';
            $upload_audios = 1;
            $upload_sourcess = 1;
            $audio_queue = [];
            foreach ($audios as $kay => $value) {
                if ($value->sequence_number){
                    $audio_queue[$value->sequence_number][] = $value;
                } else {
                    $audio_queue[$value->id][] = $value;
                }
            }
            foreach ($audio_queue as $kay => $audios) {
                echo '<div class="upload_audio-item">';
                // echo '<img src="'.$media_class->imageURL.'" alt="image upload audio">';
                echo '<div style="position: absolute; margin: 8px 0 0 -112px;">'
                            ._MEDIALIBRARY_LABEL_AUDIO.$upload_audios.":".'</div>';
                    if (isset($audios[0]->title) && $audios[0]->title != '') 
                                echo '<input type="text" name="video_source_title' . $upload_audios . '"
                                  id="video_source_title"' . $upload_audios . '" size="60" value="' 
                                  .  $audios[0]->title . '" readonly="readonly"/>';
                echo '<input type="button" name="show_altern_audio" class="show-button"';
                echo 'value="'._MEDIALIBRARY_CATEGORIES__DETAILS.'" style="margin: -8px 0 0 5px;" ';
                echo 'onclick="jQuery(\'#altern-audio-source'.$upload_audios.'\').toggle(\'slow\')"/>';
                
                echo  '<div id="altern-audio-source'.$upload_audios.'" style = "display:none">';
                for ($i = 0;$i < count($audios);$i++) {
                    echo _MEDIALIBRARY_LABEL_AUDIO_ATTRIBUTE . ($i + 1) . ":";
                        $type_src =  explode('.', $audios[$i]->src);
                        echo  ' '.$type_src[(count($type_src)-1)];

                    echo  '<div class="altern-audio-one-source">';
                    if (isset($audios[$i]->src) && substr($audios[$i]->src, 0, 4) != "http" &&
                    empty($audios[$i]->youtube)){
                        echo "<input type='text' name='new_upload_audio" . $i . "' id='new_upload_audio" . $i 
                            . "' size='60' value='" . $audios[$i]->src . "' readonly='readonly' />";
                    } elseif (isset($audios[$i]->src) && substr($audios[$i]->src, 0, 4) == "http" &&
                    empty($audios[$i]->youtube)){
                        echo "<input type='text' name='new_upload_audio" .  $i . "' id='new_upload_audio_url" 
                            . $i . "' size='60' value='" . $audios[$i]->src . "' readonly='readonly' />";
                    }
                    echo _MEDIALIBRARY_LABEL_AUDIO_DELETE . ":";
                    echo isset($audios[$i]->id) ? "<input type=\"checkbox\" name=\"audio_option_del" . 
                      $audios[$i]->id . "\" value=\"" . $audios[$i]->id . "\">" : "";
                    echo  '</div>';
                }
                
                echo    '<div class="hidden-details upload-altern-audio'.$upload_audios.'">';
                echo    '<input type="button" name="new_altern_audio" ';
                echo    'value="'._MEDIALIBRARYLABEL_AUDIO_ADD_ALTERNATIVE_AUDIO.'"';
                echo    ' onclick="new_altern_audios(\''.$kay.'\',\'altern-audio-source'
                                 .$upload_audios.'\')" ID="new_altern_audio" style="display:block"/>';
                echo    '</div>';
                echo  '</div>';

                
                echo '</div>';
                $upload_audios++;
            }
            echo '</div>';
            echo '<table class="adminform" width="100%" cellspacing="1" cellpadding="4" border="0">';
            
            ?>
            <td width="232">
                <td ID="a_items">
                  <input  type="button" name="new_audio"
                  value="<?php echo _MEDIALIBRARYLABEL_ADD_NEW_AUDIO_FILE; ?>" onClick="new_audios()"
                  ID="a_add"/>
                </td>
            <td>    
        <?php 
        }


        if ($medialibrary_configuration['emedias']['allow']) {
            echo '<tr><td colspan="2"></td></tr>';
            echo "<tr > <td valign='top' align='right'><strong>" . _MEDIALIBRARY_LABEL_EMEDIA . ":</strong></td>";
            if (count($files) > 0) {
                for ($i = 0;$i < count($files);$i++) {
                    echo "<tr><td align='right'>" . _MEDIALIBRARY_LABEL_EMEDIA_UPLOAD_URL . ($i + 1) . ":";
                    echo "</td><td>";
                    if (isset($files[$i]->location) && substr($files[$i]->location, 0, 4) != "http")
                    echo "<input type='text' size='60' value='" . $mosConfig_live_site . 
                    $files[$i]->location . "' readonly='readonly'/>";
                    elseif (isset($files[$i]->location) && substr($files[$i]->location, 0, 4) == "http")
                    echo "<input type='text' size='60' value='" . $files[$i]->location . 
                    "' readonly='readonly'/>";
                    echo "</td></tr>";
                    echo "<tr><td align='right'>" . _MEDIALIBRARY_LABEL_EMEDIA_DELETE . ":";
                    echo "</td><td>";
                    echo isset($files[$i]->id) ? "<input type=\"checkbox\" name=\"file_option_del" . 
                    $files[$i]->id . "\" value=\"" . $files[$i]->id . "\">" : "";
                    echo "</td></tr>";
                }
            }
            if (count($files) > 0) echo "<td>"; ?>
                        <td ID="f_items">
                            <input  type="button" name="new_file"
                            value="<?php echo "Add new emedia file"; ?>" onClick="new_files()"  ID="f_add"/>
                         </td>
        <?php if (count($files) > 0) echo "<td>";
        }


?>
    <tr>
      <td colspan="2">
          <hr size="2" width="100%" />
      </td>
    </tr>
    <!--************************   begin change review   **************************-->
     <?php if ($reviews > false) /*show, if review exist*/ { ?>
        <tr>
            <td colspan="7">
              <hr width="100%" size="2" align="left"> <h3><?php echo _MEDIALIBRARY_LABEL_REVIEWS; ?>:</h3>
            </td>
        </tr>
        <table class="adminlist">
            <tr class="row0">
                <td width="3%" valign="top" align="center">
                    <div>#</div>
                </td>
                <td width="2%" valign="top" align="center">
                    <div></div>
                </td>
                <td width="10%" valign="top" align="center">
                    <strong><?php echo _MEDIALIBRARY_LABEL_REVIEW_TITLE; ?>:</strong>
                </td>
                <td width="10%" valign="top" align="center">
                    <strong><?php echo _MEDIALIBRARY_LABEL_LEND_USER; ?>:</strong>
                </td>
                <td width="65%" valign="top" align="center">
                    <strong><?php echo _MEDIALIBRARY_LABEL_REVIEW_COMMENT; ?>:</strong>
                </td>

                <td width="5%" valign="top" align="center">
                    <strong><?php echo _MEDIALIBRARY_LABEL_PUB_DATE; ?>:</strong>
                </td>
                <td width="5%" valign="top" align="center">
                    <strong><?php echo _MEDIALIBRARY_LABEL_REVIEW_RATING; ?>:</strong>
                </td>
            </tr>
      <?php for ($i = 0, $nn = 1;$i < count($reviews);$i++, $nn++) /*if not one comment*/ { ?>
            <tr class="row0">
                <td valign="top" align="center">
                    <div><?php echo $nn; ?></div>
                </td>
                <td valign="top" align="center">
                    <div>
                    <?php echo "<input type='radio' id='cb" . $i . "' name='bid[]' value='" . 
                    $medialibrary->id.",".$reviews[$i]->id."' onclick='Joomla.isChecked(this.checked);' />";?>
                    </div>
                </td>
                <td valign="top" align="center">
                    <div><?php print_r($reviews[$i]->title); ?></div>
                </td>
                <td valign="top" align="left">
                    <div><?php print_r($reviews[$i]->name); ?></div>
                </td>
                <td valign="top" align="left">
            <div><?php print_r(strip_tags($reviews[$i]->comment)); ?></div>
            </td>
                <td valign="top" align="left">
                    <div><?php print_r($reviews[$i]->date); ?></div>
                </td>
                <td valign="top" align="left">
                    <div><img src="../components/com_medialibrary/images/rating-<?php 
                    echo $reviews[$i]->rating; ?>.gif" alt="<?php echo ($reviews[$i]->rating) / 2; ?>" 
                    border="0" align="right"/>&nbsp;</div>
                </td>
            </tr>
          <?php
            } /*end for(...)*/ ?>

        </table>
    <?php
        } /*end if(...)*/ ?>

        </table>

    <input type="hidden" name="id" value="<?php echo $medialibrary->id; ?>" />
    <input type="hidden" name="media_id" value="<?php echo $media_class->id; ?>" />
        <input type="hidden" name="option" value="<?php echo $option; ?>" />
    <input type="hidden" id="media_type_field" name="media_type" value="<?php 
        echo $medialibrary->media_type; ?>" />
    <input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="task" value="" />
        </form>
     <!--  ***********************   end change review   ****************************** -->
        <?php
    }

    static function edit_review($option, $book_id, $review) {
        global $my, $mosConfig_live_site, $mainframe;
        global $doc; // for J 1.6
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_TOOLBAR_ADMIN_EDIT_REVIEW . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;
?>
        <form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">

        <table cellpadding="4" cellspacing="5" border="0" width="100%" class="adminform">
        <tr>
          <td colspan="2">
            <?php echo _MEDIALIBRARY_LABEL_REVIEW_TITLE; ?>
        </td>
      </tr>
      <tr>
        <td colspan="2">
           <input class="inputbox" type="text" id="title" name="title" size="80"
                            value="<?php echo $review[0]->title ?>" />
        </td>
      </tr>
      <tr>
        <td>
            <?php echo _MEDIALIBRARY_LABEL_REVIEW_COMMENT; ?>
        </td>
        <td align="left" >
           <?php echo _MEDIALIBRARY_LABEL_REVIEW_RATING; ?>
        </td>
      </tr>
      <tr>
        <td>
         <!--<textarea align="top" name="comment" id="comment" cols="60" rows="10" 
         style="width:400;height:100;"/></textarea>-->
           <?php
        editorArea('editor1', $review[0]->comment, 'comment', '410', '200', '60', '10');
?>
        </td>
                <td width="102" align='left'>
           <?php
        $k = 0;
        while ($k < 11) {
?>
            <input type="radio" name="rating" value="<?php echo $k; ?>"
                     <?php if ($k == $review[0]->rating) echo 'checked="checked"'; ?> alt="Rating" />

            <img src="../components/com_medialibrary/images/rating-<?php echo $k; ?>.gif"
                            alt="<?php echo ($k) / 2; ?>" border="0" /><br />
           <?php
            $k++;
        }
?>
         </td>
       </tr>
       <tr>
           <td colspan="2">&nbsp;

         </td>
       </tr>

      </table>

        <input type="hidden" name="option" value="<?php echo $option; ?>" />
        <input type="hidden" name="task" value="update_review" />
        <input type="hidden" name="book_id" value="<?php echo $book_id; ?>" />
        <input type="hidden" name="review_id" value="<?php echo $review[0]->id; ?>" />
    </form>
    <?php
    }
    //*************   begin for manage reviews   ********************
    static function edit_manage_review($option, &$review) {
        global $my, $mosConfig_live_site, $mainframe;
        global $doc; // for J 1.6
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        //$mainframe->addCustomHeadTag('<script type = "text/JavaScript" src ="'.
        //$mosConfig_live_site.'/administrator/components/com_medialibrary/includes/functions.js"></script>');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_SHOW_REVIEW_MANAGER . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;
?>
        <form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
        <table cellpadding="4" cellspacing="5" border="0" width="100%" class="adminform">
        <tr>
          <td colspan="2">
            <?php echo _MEDIALIBRARY_LABEL_REVIEW_TITLE; ?>
        </td>
      </tr>
      <tr>
        <td colspan="2">
           <input class="inputbox" type="text" id="title" name="title" size="80"
                            value="<?php echo $review[0]->title ?>" />
        </td>
      </tr>
      <tr>
        <td>
            <?php echo _MEDIALIBRARY_LABEL_REVIEW_COMMENT; ?>
        </td>
        <td align="left" >
           <?php echo _MEDIALIBRARY_LABEL_REVIEW_RATING; ?>
        </td>
      </tr>
      <tr>
        <td>
         <!--<textarea align= "top" name="comment" id="comment" cols="60" rows="10" 
         style="width:400;height:100;"/></textarea>-->

           <?php
        editorArea('editor1', $review[0]->comment, 'comment', '410', '200', '60', '10');
?>
        </td>
                <td width="102" align='left'>
           <?php
        $k = 0;
        while ($k < 11) {
?>
           <input type="radio" name="rating" value="<?php echo $k; ?>"
                            <?php if ($k == $review[0]->rating) echo 'checked="checked"'; ?> alt="Rating" />
           <img src="../components/com_medialibrary/images/rating-<?php echo $k; ?>.gif"
                            alt="<?php echo ($k) / 2; ?>" border="0" /><br />
           <?php
            $k++;
        }
?>
         </td>
       </tr>
       <tr>
           <td colspan="2">&nbsp;

         </td>
       </tr>

      </table>

        <input type="hidden" name="option" value="<?php echo $option; ?>" />
        <input type="hidden" name="task" value="update_edit_manage_review" />
        <input type="hidden" name="review_id" value="<?php echo $review[0]->id; ?>" />
    </form>
    <?php
    }


    //***************   end for manage reviews   ********************
    static function showRequestLendMedias($option, $lend_requests, &$pageNav) {
        global $my, $mosConfig_live_site, $mainframe,$database;
        global $doc, $medialibrary_configuration; // for J 1.6
        $d_format = str_replace("%", '', $medialibrary_configuration["date_format"]);
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addScript($mosConfig_live_site . '/media/system/js/core.js');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_ADMIN_REQUEST_LEND . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;

?>

        <form id="adminForm" action="index.php" method="post" name="adminForm">
     <div id="limit">
             <?php
     if (version_compare(JVERSION, "3.0.0", "gt")) {
              echo $pageNav->getLimitBox();
         }
                ?>
        </div>

        <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist my_table my_table-bordered my_table-hover bl_admin_categories_main_table">
           <tr class="cat-header">
                <th align = "center" width="20">
                    <?php
        if (version_compare(JVERSION, "2.5.0", "ge")) { ?>
            <input type="checkbox" name="toggle" value="" onClick="Joomla.checkAll( this);" />
                                                        <?php
        } ?>
  <?php 
        if (version_compare(JVERSION, "2.4.0", "lt")) { ?>
          <input type="checkbox" name="toggle" value="" onClick="checkAll(<?php echo count($rows) ?>);" />
         <?php
        } ?>
                </th>
                <th align = "center" width="30">#</th>
                <th align = "center" class="title" width="10%" nowrap="nowrap">
          <?php echo _MEDIALIBRARY_LABEL_LEND_FROM; ?></th>
                <th align = "center" class="title" width="10%" nowrap="nowrap">
          <?php echo _MEDIALIBRARY_LABEL_LEND_UNTIL; ?></th>
                <th align = "center" class="title" width="5%" nowrap="nowrap">
          <?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_ID; ?></th>
        <th align = "center" class="title" width="10%" nowrap="nowrap">
          <?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?></th>
        <th align = "center" class="title" width="7%" nowrap="nowrap">
        <?php echo _MEDIALIBRARY_HEADER_MEDIALIBRARY_LABEL_CATEGORY; ?></th>
                <th align = "center" class="title" width="20%" nowrap="nowrap">
          <?php echo _MEDIALIBRARY_LABEL_TITLE; ?></th>
                <th align = "center" class="title" width="15%" nowrap="nowrap">
          <?php echo _MEDIALIBRARY_LABEL_LEND_USER; ?></th>
                <th align = "center" class="title" width="15%" nowrap="nowrap">
          <?php echo _MEDIALIBRARY_LABEL_LEND_EMAIL; ?></th>
                <th align = "center" class="title" width="20%" nowrap="nowrap">
          <?php echo _MEDIALIBRARY_LABEL_LEND_ADRES; ?></th>
            </tr>
     <?php

        for ($i = 0, $n = count($lend_requests);$i < $n;$i++) {
            $row = $lend_requests[$i];
            $d1 = date(str_replace("%", "", $medialibrary_configuration['date_format']), 
              strtotime($lend_requests[$i]->lend_from));
            $d2 = date(str_replace("%", "", $medialibrary_configuration['date_format']), 
              strtotime($lend_requests[$i]->lend_until));
            $row->lend_from = $d1;
            $row->lend_until = $d2;

            $title_assoc = array();
            $one = array();
            $query = "select associate_media from #__medialibrary where id = " . $row->fk_media_id . 
              " and associate_media is not null";
            $database->setQuery($query);
            $mediaAssociateMedia = $database->loadResult();
            if (!empty($mediaAssociateMedia)) {
                $mediaIds = unserialize($mediaAssociateMedia);
                foreach($mediaIds as $oneMedia) {
                    if ($oneMedia != 0) {
                        $one[] = $oneMedia;
                    }
                }
                $assoc_med = implode(',', $one);
                }
            if(isset($assoc_med) && $assoc_med){
              $selectstring = "SELECT DISTINCT other_table.title as title  " .
              " FROM #__medialibrary_lend_request AS l, #__medialibrary AS library " .
              " LEFT JOIN (SELECT id, title, 'game' as type FROM #__medialibrary_game " .
              " UNION all SELECT id, title, 'music' as type FROM #__medialibrary_music " .
              " UNION all SELECT id, title, 'book' as type FROM #__medialibrary_book " .
              " UNION all SELECT id, title, 'video' as type FROM #__medialibrary_video) " .
              " AS other_table ON other_table.id = library.media_id and other_table.type = library.media_type " .
              "\nWHERE library.id in ($assoc_med)";
              $database->setQuery($selectstring);
              $title_assoc = $database->loadObjectList();
            }
            $assoc_title = '';
            for ($t = 0, $z = count($title_assoc); $t < $z; $t++) {
                if($title_assoc[$t]->title != $row->title) $assoc_title .= " ".$title_assoc[$t]->title;
            }
?>
            <tr class="row<?php echo $i % 2; ?>">
                <td width="20">
     <?php
            echo mosHTML::idBox($i, $row->id, 0, 'bid');
?>
                </td>
                <td align = "center"><?php echo $row->id; ?></td>
                <td align = "center">
                    <?php $date2 = $row->lend_from;
            echo ($date2); ?>
                </td>
                <td align = "center">
                    <?php $date3 = $row->lend_until;
            echo ($date3);
?>
                </td>
                <td align = "center"><?php echo $row->media_type_id; ?></td>
        <td align = "center">
          <?php echo $row->media_type; ?>
        </td>
        <td align = "center">
          <?php echo $row->category; ?>
        </td>
                <td align = "center">
                    <?php echo $row->title . " ( " . $assoc_title ." ) "; ?>
                </td>
                <td align = "center">
                    <?php echo $row->user_name; ?>
                </td>
                <td align = "center">
                    <a href=mailto:"<?php echo $row->user_email; ?>">
                        <?php echo $row->user_email; ?>
                    </a>
                </td>
                <td align = "center">
                    <?php echo $row->user_mailing; ?>
                </td>
            </tr>
        <?php
        }
?>
      <tr><td colspan = "11"><?php echo $pageNav->getListFooter(); ?></td></tr>
        </table>

        <input type="hidden" name="option" value="<?php echo $option; ?>" />
        <input type="hidden" name="task" value="lend_requests" />
        <input type="hidden" name="boxchecked" value="0" />
        </form>

     <?php
    }



//show MEDIAS

    static function showMedias($option, $rows_book, &$clist, &$ownerlist, &$lendlist, &$publist, 
      &$applist, &$typelist, &$search, &$pageNav, &$mediasequence, $search_for_list, $order_let, &$userlist) {
        global $my, $mosConfig_live_site, $mainframe, $session;
        global $mainframe; // for J 1.6
        global $templateDir; // for J 1.6
        global $doc; // for J 1.6
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $script_content = ''; // for J 1.6
        $script_content.= "function before_print_check() \n";
        $script_content.= " { \n";
        $script_content.= "  var add = document.getElementsByName('bid[]'); \n";
        $script_content.= "  var count=0;    \n";
        $script_content.= "  for(var i=0;i<add.length;i++) \n";
        $script_content.= "  { \n";
        $script_content.= "      if(add[i].checked) \n";
        $script_content.= "        { \n";
        $script_content.= "         count++; \n";
        $script_content.= "         break; \n";
        $script_content.= "       } \n";
        $script_content.= "   } \n";
        $script_content.= "  if(count == 0) \n";
        $script_content.= "    {\n";
        $script_content.= "     alert('Please make a selection first'); \n";
        $script_content.= "     exit; \n";
        $script_content.= "    } \n";
        $script_content.= "  else \n";
        $script_content.= "   {\n";
        $script_content.= "    document.adminForm.target = '_blank' ; \n";
        $script_content.= "    document.adminForm.task.value='print_medias'; \n";
        $script_content.= "    document.adminForm.submit(); \n";
        $script_content.= "  }\n";
        $script_content.= "}\n";
        $doc->addScriptDeclaration($script_content);
        $html = "<div class='media_manager_caption' >"."<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " 
            . _MEDIALIBRARY_SHOW . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;

?>      <div style="float: right">This is <b>FREE</b> version of the Medialibrary!<br>
                <a target = "_blank" href="//ordasoft.com/media-library-joomla-extension">
                    Buy PRO version for more features!</a>
        </div>      

        <form id="adminForm" action="index.php" method="post" name="adminForm">


        <?php echo _MEDIALIBRARY_SHOW_SEARCH; ?>

        <table cellpadding="4" cellspacing="0" border="0" width="55%" class="adminlist">
            <tr>
                <td>
                    <input type="text" name="search" value="<?php echo $search; ?>" class="inputbox"  />
                </td>
                <td>
                    <?php echo _MEDIALIBRARY_SHOW_SEARCH_FOR;
                    echo $search_for_list;
                    ?>
                    <input type="submit" name="go" value="<?php 
                        echo _MEDIALIBRARY_SHOW_SEARCH_GO; ?>" class="inputbox_go" >
                </td>
            </tr>
        </table>

        <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
            <tr>
            <td width="50px">
                <?php echo $mediasequence; ?>
            </td>


            <td width="50px">
                <?php echo $publist; ?>
            </td>
      <td width="50px">
        <?php echo $applist; ?>
      </td>
      <td width="50px">
        <?php echo $lendlist; ?>
      </td>
      <td width="50px">
        <?php echo $typelist; ?>
      </td>
      <td width="50px">
        <?php echo $clist; ?>
      </td>
      <td width="50px">
        <?php echo $userlist; ?>
      </td>
    <td width="50px">
        <?php
     if (version_compare(JVERSION, "3.0.0", "gt")) {
            echo $pageNav->getLimitBox();
            }
        ?>
    </td>

        </tr>
        </table>

     <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist my_table my_table-bordered my_table-hover bl_admin_categories_main_table">
    <tr class="cat-header">
    <th width="20" align = "center">
    <?php
        if (version_compare(JVERSION, "3.0.0", "ge")) {
    ?>
            <input type="checkbox" name="toggle" value="" onClick="Joomla.checkAll( this);" />
    <?php
        }
    ?>
     <?php if (version_compare(JVERSION, "2.6.0", "lt")) { ?>
            <input type="checkbox" name="toggle" value="" onClick="checkAll(<?php echo count($rows_book) ?>);" />
    <?php
        }
    ?>

  </th>
  <th width="30">Id</th>
  <th align = "center" class="title" width="5%" nowrap="nowrap"><?php echo "MediaID"; ?></th>
  <th align = "center" class="title" width="5%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?></th>
  <th align = "center" class="title" width="28%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_TITLE; ?></th>
  <!--<th align = "center" class="title" width="28%" nowrap="nowrap"><?php 
        echo _MEDIALIBRARY_LABEL_PEOPLE_NAME; ?></th>-->
  <th align = "center" class="title" width="6%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_FETCH_INFO; ?></th>
  <th align = "center" class="title" width="12%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_CATEGORY; ?></th>

  <th align = "center" class="title" width="10%" nowrap="nowrap">
    <?php echo HTML_medialibrary::sort_head_let($order_let);
        //_MEDIALIBRARY_LABEL_LEND;

?>
    </th>
  <th align = "center" class="title" width="5%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_HITS; ?></th>
  <th align = "center"  class="title" width="5%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_PUBLIC; ?></th>
  <th align = "center"  class="title" width="5%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_APPROVED; ?></th>

  <th align = "center"  class="title" width="5%" nowrap="nowrap"><?php 
        echo _MEDIALIBRARY_LABEL_MEDIAOWNER_ID; ?></th>
  <th align = "center" class="title" width="5%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_CONTROL; ?></th>
  <th align = "center" class="title" width="5%" nowrap="nowrap"><?php 
    echo _MEDIALIBRARY_LABEL_LANGUAGE_DESCRIPTION; ?></th>
  </tr>
  <?php

        

        for ($i = 0;$i < count($rows_book);$i++) {

            $row = $rows_book[$i];

?>
            <tr class="row<?php echo $i % 2; ?>">



<!--CHeck box media-->
                <td width="30" align="left">

                    <?php if($row->checked_out && $row->checked_out != $my->id) { ?>
                        &nbsp;
  <?php
            } else {
                $mediaInfo= array( $row->id,$row->media_id, $row->media_type);
                $mediaInfo = implode (",", $mediaInfo);
                echo mosHTML::idBox($i, $mediaInfo, ($row->checked_out && $row->checked_out != $my->id), 'bid');
            }
?>
                </td>
                <td align = "center" ><?php echo $row->id; ?></td>
                <td align = "center"><?php echo $row->media_id; ?></td>
                <td align = "center"><?php echo $row->media_type; ?></td>
                <td align="left">
                    <a href="#" onClick="return listItemTask('cb<?php echo $i; ?>','edit')">
                        <?php echo $row->title; ?>
                    </a>
                </td>
               <!-- <td align="left">
                        <?php echo $row->people_name; ?>
                </td>-->
                <td align="center">
                    <?php echo mosMedialibraryWS::getWsNameById($row->informationFrom); ?>
                </td>
                <td align = "center"><?php echo $row->category; ?></td>
                <td align = "center">
                <?php
            if ($row->lend_from == null) {
?>
                    <a href="javascript: void(0);" onClick="return listItemTask('cb<?php echo $i; ?>','lend')">
                    <img src='./components/com_medialibrary/images/lend_f2.png' align='middle' 
                    width='15' height='15' border='0' alt='Lend out' /><br />
                    </a>
                <?php
            } else {
?>

                <a href="javascript: void(0);" onClick="return listItemTask('cb<?php echo $i; ?>','lend_return')">
                <img src='./components/com_medialibrary/images/lend_return_f2.png' align='middle' 
                width='15' height='15' border='0' alt='Return media' /><br />

                </a>

                <?php
            }
?>

                </td>

                <td align = "center"><?php echo $row->hits; ?></td>
            <?php
            $task = $row->published ? 'unpublish' : 'publish';
            $alt = $row->published ? 'Unpublish' : 'Publish';
            $img = $row->published ? 'tick.png' : 'publish_x.png';
            $task1 = $row->approved ? 'unapprove' : 'approve';
            $alt1 = $row->approved ? 'Unapproved' : 'Approved';
            $img1 = $row->approved ? 'tick.png' : 'publish_x.png';
?>
              <td width="5%" align="center">
                  <a href="javascript: void(0);" onClick="return listItemTask('cb<?php 
                  echo $i; ?>','<?php echo $task; ?>')">
    <?php
            if (version_compare(JVERSION, "1.6.0", "lt")) {
?>
                    <img src="<?php echo $mosConfig_live_site . "/administrator/images/" . 
                    $img; ?>" width="12" height="12" border="0" alt="<?php echo $alt; ?>" />
    <?php
            } else {
?>
                    <img src="<?php echo $templateDir . "/images/admin/" .
                     $img; ?>" width="12" height="12" border="0" alt="<?php echo $alt; ?>" />
    <?php
            }
?>
                  </a>
              </td>

            <td width="5%" align="center">
                      <a href="javascript: void(0);" onClick="return listItemTask('cb<?php 
                      echo $i; ?>','<?php echo $task1; ?>')">
    <?php
            if (version_compare(JVERSION, "1.6.0", "lt")) {
?>
                    <img src="<?php echo $mosConfig_live_site . "/administrator/images/" . 
                    $img1; ?>" width="12" height="12" border="0" alt="<?php echo $alt1; ?>" />
    <?php
            } else {
?>
                    <img src="<?php echo $templateDir . "/images/admin/" . $img1; ?>" 
                    width="12" height="12" border="0" alt="<?php echo $alt1; ?>" />
    <?php
            }
?>
                      </a>
                         </td>

            <?php
            

?>
                <td align="center"><?php echo $row->editor; ?></td>
    <?php 

//Checked Out media

        if ($row->checked_out) {
                echo "<td align='center'>".$row->checked_out_user."</td>";
        } else {
                echo "<td align='center' ></td>";
        }
?>


<td align = "center"><?php echo $row->langDescription; ?></td>
            </tr>
    <?php
        } //end for

?>
                <tr><td align="center" colspan = "14"><?php echo $pageNav->getListFooter(); ?></td>
        </tr>
        </table>
        <input type="hidden" name="option" value="<?php echo $option; ?>" />
        <input type="hidden" name="task" value="" />
        <input type="hidden" name="boxchecked" value="0" />
        </form>

    <?php
    }


    //**********   begin for manage reviews  *****************
    static function showManageReviews($option, &$pageNav, &$reviews) {


        global $my, $mosConfig_live_site, $mainframe, $templateDir;
        global $doc; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_SHOW_REVIEW_MANAGER . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;
?>

        <form id="adminForm" action="index.php" method="post" name="adminForm">

        <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist _reviews">
                         <div id="limit">
             <?php
     if (version_compare(JVERSION, "3.0.0", "gt")) {
              echo $pageNav->getLimitBox();
         }
                ?>
        </div>
        <tr class="cat-header">

        <th width="20">
        <?php
        if (version_compare(JVERSION, "2.5.0", "ge")) { ?>
            <input type="checkbox" name="toggle" value="" onClick="Joomla.checkAll( this);" />
                                                        <?php
        } ?>
                         <?php if (version_compare(JVERSION, "2.4.0", "lt")) { ?>
                        <input type="checkbox" name="toggle" value="" onClick="checkAll(<?php 
                        echo count($reviews) ?>);" />
                        <?php
        } ?>
        </th>
        <th align="center" width="30">
       <a href="#numer" onClick="return listItemTask('cb<?php echo "1"; ?>','sorting_manage_review_numer');">#</a>
    </th>
    <!--  <th align="center" class="title" width="12%" nowrap="nowrap">-->
    <!--      <a href="#isbn"
        onClick="return listItemTask('cb<?php echo "1"; ?>','sorting_manage_review_isbn');"><?php 
        echo _MEDIALIBRARY_LABEL_ISBN; ?></a>
    </th>-->
        <th align="center" class="title" width="12%" nowrap="nowrap">
      <a href="#media_type"
        onClick="return listItemTask('cb<?php echo "1"; ?>','sorting_manage_review_media_type');">
        <?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?></a>
    </th>
    <th align="center" class="title" width="25%" nowrap="nowrap">
      <a href="#media_title"
        onClick="return listItemTask('cb<?php echo "1"; ?>','sorting_manage_review_media_title');">
        <?php echo _MEDIALIBRARY_LABEL_TITLE; ?></a>
    </th>
    <th align="center" class="title" width="16%" nowrap="nowrap">
      <a href="#title_catigory"
        onClick="return listItemTask('cb<?php echo "1"; ?>','sorting_manage_review_title_catigory');">
        <?php echo _MEDIALIBRARY_LABEL_CATEGORY; ?></a>
    </th>
        <th align="center" class="title" width="25%" nowrap="nowrap">
      <a href="#title_review"
        onClick="return listItemTask('cb<?php echo "1"; ?>','sorting_manage_review_title_review');">
        <?php echo _MEDIALIBRARY_LABEL_TITLE_COMMENT; ?></a>
    </th>
        <th align="center" class="title" width="7%" nowrap="nowrap">
      <a href="#user_name"
        onClick="return listItemTask('cb<?php echo "1"; ?>','sorting_manage_review_user_name');">
        <?php echo _MEDIALIBRARY_LABEL_LEND_USER; ?></a>
    </th>
        <th align="center" class="title" width="8%" nowrap="nowrap">
      <a href="#date"
        onClick="return listItemTask('cb<?php echo "1"; ?>','sorting_manage_review_date');">
      <?php echo _MEDIALIBRARY_LABEL_PUB_DATE; ?></a>
    </th>
        <th align="center" class="title" width="7%" nowrap="nowrap">
      <a href="#rating"
        onClick="return listItemTask('cb<?php echo "1"; ?>','sorting_manage_review_rating');">
      <?php echo _MEDIALIBRARY_LABEL_RATING; ?></a>
    </th>
    <th align="center" class="title" width="7%" nowrap="nowrap">
    <a href="#published" onClick="return listItemTask('cb<?php echo "1"; ?>','sorting_manage_review_published');">
    <?php echo _MEDIALIBRARY_HEADER_PUBLISHED; ?></a>
    </th>
    </tr>

    <?php
        for ($i = 0, $n = count($reviews);$i < $n;$i++) {
            $row = $reviews[$i];
?>
            <tr class="row<?php echo $i % 2; ?>">
                <td width="20" align="left">
                <?php
                      $mediaInfo= array($row->review_id, $row->media_id, $row->media_type);
                                $mediaInfo = implode (",", $mediaInfo);
                ?>
                    <input type="checkbox" id="cb<?php echo $i; ?>" name="bid[]" 
                    value="<?php echo $mediaInfo; ?>" onClick="Joomla.isChecked(this.checked);" />
                </td>
                <td align="center" width="30"><?php echo $reviews[$i]->review_id; ?></td>
            <!--    <td align="center" width="12%"><?php echo $reviews[$i]->isbn; ?></td>-->
        <td align="center" width="25%"><?php echo $reviews[$i]->media_type; ?></td>
                <td align="center" width="25%"><?php echo $reviews[$i]->media_title; ?></td>
                <td align="center" width="16%"><?php echo $reviews[$i]->title_catigory; ?></td>
                <td align="center" width="25%">
                    <a href="#edit" onClick="return listItemTask('cb<?php echo $i; ?>','edit_manage_review');">
                        <?php
            //if 'title_comment' >55 else 'title_comment' -- all
            if (strlen($reviews[$i]->title_review) > 55) {
                for ($j = 0;$j < 55;$j++) {
                    echo $reviews[$i]->title_review[$j];
                }
            } else {
                echo $reviews[$i]->title_review; /*title comment*/
            }
?>
                    </a>
                </td>
                <td align="center" width="7%"><?php echo $reviews[$i]->user_name; ?></td>
                <td align="center" width="8%"><?php echo $reviews[$i]->date; ?></td>
                <td align="center" width="7%">
                    <div><img src="../components/com_medialibrary/images/rating-<?php 
                    echo $reviews[$i]->rating; ?>.gif" alt="<?php echo ($reviews[$i]->rating) / 2; ?>" 
                    border="0" align="right"/>&nbsp;</div>
                </td>
                <td align="center" width="7%">
                    <?php
            $task = $reviews[$i]->published ? 'unpublish_manage_review' : 'publish_manage_review';
            $alt = $reviews[$i]->published ? 'Unpublish' : 'Publish';
            $img = $reviews[$i]->published ? 'tick.png' : 'publish_x.png';
?>
                    <a href="javascript: void(0);" onClick="return listItemTask('cb<?php 
                    echo $i; ?>','<?php echo $task; ?>')">
            <?php
            if (version_compare(JVERSION, "1.6.0", "lt")) {
?>
                <img src="<?php echo $mosConfig_live_site . 
                "/administrator/images/" . $img; ?>" width="12" height="12" 
                border="0" alt="<?php echo $alt; ?>" />
                <?php
            } else {
?>
                    <img src="<?php echo $templateDir . "/images/admin/" . $img; ?>" 
                    width="12" height="12" border="0" alt="<?php echo $alt; ?>" />
                        <?php
            }
?>
                            </a>

                        </td>
                    </tr>
        <?php
        } //end for(...)

?>
                <tr><td align="center" colspan = "11"><?php echo $pageNav->getListFooter(); ?></td></tr>
        </table>

        <input type="hidden" name="option" value="<?php echo $option; ?>" />
        <input type="hidden" name="task" value="manage_review" />
        <input type="hidden" name="boxchecked" value="0" />

        </form>

    <?php
    }
    //************   end for manage reviews   ***************************
    //*********   begin add for button print in Manager Medias   *********
    static function showPrintMedias($rows) {
        global $my, $mosConfig_live_site, $mainframe;
        global $doc; // for J 1.6
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
?>
    <html>
    <head>
      <title>
      </title>
    </head>
    <body>
    <form id="adminForm" name="Print" action="<?php 
      echo $mosConfig_live_site; ?>/administrator/index.php?option=com_medialibrary&task=print_item" 
      method="post" target="_top">
    <div align="left">
        <?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_PRINT_FONT_SIZE; ?>:
        <select name="font_size" title="Select size font!">
            <option value="1">1
            <option value="2">2
            <option value="3">3
            <option value="4">4
            <option value="5">5
            <option value="6">6
            <option value="7">7
            <option value="8" selected >8
            <option value="9">9
            <option value="10">10
            <option value="11">11
            <option value="12">12
            <option value="13">13
            <option value="14">14
            <option value="15">15
            <option value="16">16
            <option value="17">17
            <option value="18">18
        </select>
        <br /><?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_PRINT_FORMAT; ?>:<br />
    <!--
        <input type="radio" name="format_w_h" value="verticall" title="Checked format!" checked/>Vertically
        <input type="radio" name="format_w_h" value="horizontall" title="Checked format!"/>Horizontally<br />
    -->
        <input type="hidden" name="format_w_h" value="verticall" title="Checked format!" checked />

        <select name="format" title="Select size font!">
            <option value="A5">A5&nbsp;(148x210&nbsp;mm)
            <option value="A4" selected >A4&nbsp;(210x297&nbsp;mm)
            <option value="A3">A3&nbsp;(297x420&nbsp;mm)
            <option value="Letter">Letter&nbsp;(8,5x11&nbsp;inch)
            <option value="Legal">Legal&nbsp;(8,5x14&nbsp;inch)
            <option value="Tabloid">Tabloid&nbsp;(11x17&nbsp;inch)
            <option value="Executive">Executive&nbsp;(7,5x10&nbsp;inch)
        </select>
        <p>
        <?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_PRINT_SELECT; ?>
        <br />
        <input type="submit" value="Next" title="Next step for print!"/>
        </p>
    </div>

    <table cellpadding="4" cellspacing="0" border="1px" style="width:180mm" class="adminlist">
        <tr bgcolor="#d0d0d0">
            <td width="5%" nowrap="nowrap" align="center"><?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_PRINT; ?>
                <input type="checkbox" name="print_id" value="1" title="Select for print!" checked />
            </td>
            <td width="5%" nowrap="nowrap" align="center"><?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_PRINT; ?>
                <input type="checkbox" name="print_media_type_id" value="1" title="Select for print!" checked />
            </td>
            <td width="5%" nowrap="nowrap" align="center"><?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_PRINT; ?>
                <input type="checkbox" name="print_isbn_asin" value="1" title="Select for print!" checked />
            </td>
            <td width="16%" nowrap="nowrap" align="center"><?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_PRINT; ?>
                <input type="checkbox" name="print_title" value="1" title="Select for print!" checked />
            </td>
      <td width="7%" nowrap="nowrap" align="center"><?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_PRINT; ?>
        <input type="checkbox" name="print_category" value="1" title="Select for print!" checked />
      </td>
      <td width="7%" nowrap="nowrap" align="center"><?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_PRINT; ?>
        <input type="checkbox" name="print_media_type" value="1" title="Select for print!" checked />
      </td>
            <td width="10%" nowrap="nowrap" align="center"><?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_PRINT; ?>
                <input type="checkbox" name="print_lend_from" value="1" title="Select for print!" checked/>
            </td>
            <td width="10%" nowrap="nowrap" align="center"><?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_PRINT; ?>
                <input type="checkbox" name="print_lend_until" value="1" title="Select for print!" checked/>
            </td>
            <td width="10%" nowrap="nowrap" align="center"><?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_PRINT; ?>
                <input type="checkbox" name="print_user_name" value="1" title="Select for print!" checked />
            </td>
            <td width="10%" nowrap="nowrap" align="center"><?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_PRINT; ?>
                <input type="checkbox" name="print_user_email" value="1" title="Select for print!" checked/>
            </td>
            <td width="10%" nowrap="nowrap" align="center"><?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_PRINT; ?>
                <input type="checkbox" name="print_user_mailing" value="1" title="Select for print!" checked />
            </td>
            <td width="5%" nowrap="nowrap" align="center"><?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_PRINT; ?>
                <input type="checkbox" name="print_hits" value="1" title="Select for print!" checked />
            </td>
        </tr>
        <tr bgcolor="#d0d0d0">
            <th width="5%">#</th>
            <th width="5%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_ID; ?></th>
            <th width="5%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_ISBN_ASIN; ?></th>
            <th width="16%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_TITLE; ?></th>
      <th width="7%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_CATEGORY; ?></th>
      <th width="7%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?></th>
            <th width="10%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_LEND_FROM; ?></th>
            <th width="10%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_LEND_UNTIL; ?></th>
            <th width="10%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_LEND_USER; ?></th>
            <th width="10%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_LEND_EMAIL; ?></th>
            <th width="10%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_LEND_ADRES; ?></th>
            <th width="5%" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_HITS; ?></th>
        </tr>

    <?php for ($i = 0;$i < count($rows);$i++) { ?>
        <tr bgcolor="#<?php if (($i % 2) != 1) {
                echo "efefef";
            } else {
                echo "ffffff";
            } ?>" >
            <td width="5%"><?php echo wordwrap($rows[$i][0]->id, 6, "<br />\n", 1); ?></td>
            <td width="5%" nowrap="nowrap"><?php echo wordwrap($rows[$i][0]->media_id, 6, "<br />\n", 1); ?></td>
            <td width="5%" nowrap="nowrap"><?php echo $rows[$i][0]->asin_isbn; ?></td>
            <td width="16%" nowrap="nowrap"><?php echo wordwrap($rows[$i][0]->title, 20, "<br />\n", 1); ?></td>
      <td width="7%" nowrap="nowrap"><?php echo wordwrap($rows[$i][0]->category, 10, "<br />\n", 1); ?></td>
      <td width="7%" nowrap="nowrap"><?php echo wordwrap($rows[$i][0]->media_type, 10, "<br />\n", 1); ?></td>
            <td width="10%" nowrap="nowrap">
                <?php if (isset($rows[$i][0]->lend_from)) {
                for ($j = 0;$j < 10;$j++) {
                    echo $rows[$i][0]->lend_from[$j];
                }
            } else {
                echo "--";
            } ?>
            </td>
            <td width="10%" nowrap="nowrap">
                <?php if (isset($rows[$i][0]->lend_until)) {
                for ($j = 0;$j < 10;$j++) {
                    echo $rows[$i][0]->lend_until[$j];
                }
            } else {
                echo "--";
            } ?>
            </td>
            <td width="10%" nowrap="nowrap">
                <?php if (isset($rows[$i][0]->user_name) && ($rows[$i][0]->user_name != "")) {
                echo wordwrap($rows[$i][0]->user_name, 10, "<br />\n", 1);
            } else {
                echo "--";
            } ?>
            </td>
            <td width="10%" nowrap="nowrap">
                <?php if (isset($rows[$i][0]->user_email) && ($rows[$i][0]->user_email != "")) {
                echo wordwrap($rows[$i][0]->user_email, 10, "<br />\n", 1);
            } else {
                echo "--";
            } ?>
            </td>
            <td width="10%" nowrap="nowrap">
                 <?php if (isset($rows[$i][0]->user_mailing) && ($rows[$i][0]->user_mailing != "")) {
                echo wordwrap($rows[$i][0]->user_mailing, 10, "<br />\n", 1);
            } else {
                echo "--";
            } ?>
            </td>
            <td width="5%" nowrap="nowrap"><?php echo wordwrap($rows[$i][0]->hits, 6, "<br />\n", 1); ?></td>
        </tr>
    <?php
        } ?>
    </table>
    </form>
    </body>
    </html>
    <?php
        @session_start();
        $_SESSION['rows'] = $rows;
        exit();
    } //end showPrintBooks($rows)
    //*********************************************************************************
    static function showPrintItem($rows) {
        global $my, $mosConfig_live_site, $mainframe;
        global $doc; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
?>
      <html>
      <head>
        <title>
        </title>
        <style type="text/css">
            .print_font_nik {
                    background-color: #ffffff;
                    font-size: <?php echo $_REQUEST['font_size']; ?>pt;
                    font-color: #000000;
                    font-family: Arial, Times, Helvetica, Zapf-Chancery, Western, or Courier;
                    }
        </style>
        <script language="JavaScript" type="text/javascript">
        function print_item_no_button() {
            var el  = document.getElementById('print_button_off');
            el.style.display = 'none';
            window.print();
        }
        </script>
    </head>
    <body>
    <div align="left" id="print_button_off">
        <p align="left">
        <a href="#" onClick="javascript:print_item_no_button();" title="Print">
            <img src="<?php echo $mosConfig_live_site; 
                ?>/administrator/components/com_medialibrary/images/print.png"
              alt="Print" name="Print" align="center" border="0" />
        </a>
        </p>
    </div>
<?php
        $kol = 0;
        if (isset($_REQUEST['print_id'])) $kol++;
        if (isset($_REQUEST['print_media_type_id'])) $kol++;
        if (isset($_REQUEST['print_isbn_asin'])) $kol++;
        if (isset($_REQUEST['print_title'])) $kol++;
        if (isset($_REQUEST['print_category'])) $kol++;
        if (isset($_REQUEST['print_media_type'])) $kol++;
        if (isset($_REQUEST['print_lend_from'])) $kol++;
        if (isset($_REQUEST['print_lend_until'])) $kol++;
        if (isset($_REQUEST['print_user_name'])) $kol++;
        if (isset($_REQUEST['print_user_email'])) $kol++;
        if (isset($_REQUEST['print_user_mailing'])) $kol++;
        if (isset($_REQUEST['print_hits'])) $kol++;
        if (($kol < 11) && (isset($_REQUEST['print_title']) == 0) && ($kol != 0)) $k = (int)(100 / $kol);
        if (($kol < 11) && (isset($_REQUEST['print_title'])) && ($kol != 0)) {
            $k = (int)(100 / $kol);
            if ($kol == 10) {
                $k_tit = $k + 9;
                $k-= 1;
            }
            if ($kol == 9) {
                $k_tit = $k + 8;
                $k-= 1;
            }
            if ($kol == 8) {
                $k_tit = $k + 15;
                $k-= 2;
            }
            if ($kol == 7) {
                $k_tit = $k + 16;
                $k-= 3;
            }
            if ($kol == 6) {
                $k_tit = $k + 20;
                $k-= 4;
            }
            if ($kol == 5) {
                $k_tit = $k + 20;
                $k-= 5;
            }
            if ($kol == 4) {
                $k_tit = $k + 15;
                $k-= 5;
            }
            if ($kol == 3) {
                $k_tit = $k + 10;
                $k-= 5;
            }
            if ($kol == 2) {
                $k_tit = $k;
            }
        } //end if
        if ($kol != 0) {
            if (($_REQUEST['format_w_h'] == 'verticall') && ($_REQUEST['format'] == 'A5')) {
                $width_tabl = 118;
            } //138;}
            if (($_REQUEST['format_w_h'] == 'verticall') && ($_REQUEST['format'] == 'A4')) {
                $width_tabl = 180;
            } //200;}
            if (($_REQUEST['format_w_h'] == 'verticall') && ($_REQUEST['format'] == 'A3')) {
                $width_tabl = 267;
            } //287;}
            if (($_REQUEST['format_w_h'] == 'verticall') && ($_REQUEST['format'] == 'Letter')) {
                $width_tabl = 185;
            } //205;}
            if (($_REQUEST['format_w_h'] == 'verticall') && ($_REQUEST['format'] == 'Legal')) {
                $width_tabl = 185;
            } //205;}
            if (($_REQUEST['format_w_h'] == 'verticall') && ($_REQUEST['format'] == 'Tabloid')) {
                $width_tabl = 249;
            } //269;}
            if (($_REQUEST['format_w_h'] == 'verticall') && ($_REQUEST['format'] == 'Executive')) {
                $width_tabl = 160;
            } //180;}
            if (($_REQUEST['format_w_h'] == 'horizontall') && ($_REQUEST['format'] == 'A5')) {
                $width_tabl = 200;
            }
            if (($_REQUEST['format_w_h'] == 'horizontall') && ($_REQUEST['format'] == 'A4')) {
                $width_tabl = 287;
            }
            if (($_REQUEST['format_w_h'] == 'horizontall') && ($_REQUEST['format'] == 'A3')) {
                $width_tabl = 410;
            }
            if (($_REQUEST['format_w_h'] == 'horizontall') && ($_REQUEST['format'] == 'Letter')) {
                $width_tabl = 269;
            }
            if (($_REQUEST['format_w_h'] == 'horizontall') && ($_REQUEST['format'] == 'Legal')) {
                $width_tabl = 343;
            }
            if (($_REQUEST['format_w_h'] == 'horizontall') && ($_REQUEST['format'] == 'Tabloid')) {
                $width_tabl = 421;
            }
            if (($_REQUEST['format_w_h'] == 'horizontall') && ($_REQUEST['format'] == 'Executive')) {
                $width_tabl = 244;
            }
?>
    <table cellpadding="4" cellspacing="0" border="1px" style="width:<?php echo $width_tabl; ?>mm" 
        class="print_font_nik">
        <tr bgcolor="#d0d0d0">
            <?php if (isset($_REQUEST['print_id'])) { ?>
                <th width="<?php if (isset($k)) {
                    echo $k . "%";
                } else {
                    echo "5%";
                } ?>">#</th>
            <?php
            } ?>
            <?php if (isset($_REQUEST['print_media_type_id'])) { ?>
                <th width="<?php if (isset($k)) {
                    echo $k . "%";
                } else {
                    echo "5%";
                } ?>" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_ID; ?></th>
            <?php
            } ?>
            <?php if (isset($_REQUEST['print_isbn_asin'])) { ?>
                <th width="<?php if (isset($k)) {
                    echo $k . "%";
                } else {
                    echo "5%";
                } ?>" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_ISBN_ASIN; ?></th>
            <?php
            } ?>
            <?php if (isset($_REQUEST['print_title'])) { ?>
                <th width="<?php if (isset($k_tit)) {
                    echo $k_tit . "%";
                } else if (($kol == 1) && (isset($_REQUEST['print_title']))) {
                    echo "100%";
                } else {
                    echo "16%";
                } ?>" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_TITLE; ?></th>
            <?php
            } ?>
      <?php if (isset($_REQUEST['print_category'])) { ?>
        <th width="<?php if (isset($k)) {
                    echo $k . "%";
                } else {
                    echo "7%";
                } ?>" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_CATEGORY; ?></th>
      <?php
            } ?>
      <?php if (isset($_REQUEST['print_media_type'])) { ?>
        <th width="<?php if (isset($k)) {
                    echo $k . "%";
                } else {
                    echo "7%";
                } ?>" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?></th>
      <?php
            } ?>
            <?php if (isset($_REQUEST['print_lend_from'])) { ?>
                <th width="<?php if (isset($k)) {
                    echo $k . "%";
                } else {
                    echo "10%";
                } ?>" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_LEND_FROM; ?></th>
            <?php
            } ?>
            <?php if (isset($_REQUEST['print_lend_until'])) { ?>
                <th width="<?php if (isset($k)) {
                    echo $k . "%";
                } else {
                    echo "10%";
                } ?>" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_LEND_UNTIL; ?></th>
            <?php
            } ?>
            <?php if (isset($_REQUEST['print_user_name'])) { ?>
                <th width="<?php if (isset($k)) {
                    echo $k . "%";
                } else {
                    echo "10%";
                } ?>" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_LEND_USER; ?></th>
            <?php
            } ?>
            <?php if (isset($_REQUEST['print_user_email'])) { ?>
                <th width="<?php if (isset($k)) {
                    echo $k . "%";
                } else {
                    echo "10%";
                } ?>" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_LEND_EMAIL; ?></th>
            <?php
            } ?>
            <?php if (isset($_REQUEST['print_user_mailing'])) { ?>
                <th width="<?php if (isset($k)) {
                    echo $k . "%";
                } else {
                    echo "10%";
                } ?>" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_LEND_ADRES; ?></th>
            <?php
            } ?>
            <?php if (isset($_REQUEST['print_hits'])) { ?>
                <th width="<?php if (isset($k)) {
                    echo $k . "%";
                } else {
                    echo "5%";
                } ?>" nowrap="nowrap"><?php echo _MEDIALIBRARY_LABEL_HITS; ?></th>
            <?php
            } ?>
        </tr>
<?php for ($i = 0;$i < count($rows);$i++) {
?>
        <tr bgcolor="#<?php if (($i % 2) != 1) {
                    echo "efefef";
                } else {
                    echo "ffffff";
                } ?>" >
            <?php if (isset($_REQUEST['print_id'])) { ?>
                <td width="<?php if (isset($k)) {
                        echo $k . "%";
                    } else {
                        echo "5%";
                    } ?>">
                    <?php if (isset($k)) {
                        $symbol = $k;
                    } else {
                        $symbol = 6;
                    }
                     echo wordwrap($rows[$i][0]->id, $symbol, "<br />\n", 1); ?>
                </td>
            <?php
                } ?>
            <?php if (isset($_REQUEST['print_media_type_id'])) { ?>
                <td width="<?php if (isset($k)) {
                        echo $k . "%";
                    } else {
                        echo "5%";
                    } ?>" nowrap="nowrap">
                    <?php if (isset($k)) {
                        $symbol = $k;
                    } else {
                        $symbol = 6;
                    }
                    echo wordwrap($rows[$i][0]->media_id, $symbol, "<br />\n", 1); ?>
                </td>
            <?php
                } ?>
            <?php if (isset($_REQUEST['print_isbn_asin'])) { ?>
                <td width="<?php if (isset($k)) {
                        echo $k . "%";
                    } else {
                        echo "5%";
                    } ?>" nowrap="nowrap">
                    <?php echo $rows[$i][0]->asin_isbn; ?>
                </td>
            <?php
                } ?>
            <?php if (isset($_REQUEST['print_title'])) { ?>
                <td width="<?php if (isset($k_tit)) {
                        echo $k_tit . "%";
                    } else if (($kol == 1) && (isset($_REQUEST['print_title']))) {
                        echo "100%";
                    } else {
                        echo "20%";
                    } ?>" nowrap="nowrap">
                    <?php if (isset($k_tit)) {
                        $symbol = $k_tit;
                    } else if (($kol == 1) && (isset($_REQUEST['print_title']))) {
                        $symbol = $k;
                    } else {
                        $symbol = 20;
                    }
                    echo wordwrap($rows[$i][0]->title, $symbol, "<br />\n", 1); ?>
                </td>
            <?php
                } ?>
      <?php if (isset($_REQUEST['print_category'])) { ?>
        <td width="<?php if (isset($k)) {
                        echo $k . "%";
                    } else {
                        echo "10%";
                    } ?>" nowrap="nowrap">
          <?php if (isset($k)) {
                        $symbol = $k;
                    } else {
                        $symbol = 10;
                    }
                    echo wordwrap($rows[$i][0]->category, $symbol, "<br />\n", 1); ?>
        </td>
      <?php
                } ?>
      <?php if (isset($_REQUEST['print_media_type'])) { ?>
        <td width="<?php if (isset($k)) {
                        echo $k . "%";
                    } else {
                        echo "10%";
                    } ?>" nowrap="nowrap">
          <?php if (isset($k)) {
                        $symbol = $k;
                    } else {
                        $symbol = 10;
                    }
                    echo wordwrap($rows[$i][0]->media_type, $symbol, "<br />\n", 1); ?>
        </td>
      <?php
                } ?>
            <?php if (isset($_REQUEST['print_lend_from'])) { ?>
                <td width="<?php if (isset($k)) {
                        echo $k . "%";
                    } else {
                        echo "10%";
                    } ?>" nowrap="nowrap">
                    <?php if (isset($rows[$i][0]->lend_from)) {
                        for ($j = 0;$j < 10;$j++) {
                            echo $rows[$i][0]->lend_from[$j];
                        }
                    } else {
                        echo "--";
                    } ?>
                </td>
            <?php
                } ?>
            <?php if (isset($_REQUEST['print_lend_until'])) { ?>
                <td width="<?php if (isset($k)) {
                        echo $k . "%";
                    } else {
                        echo "10%";
                    } ?>" nowrap="nowrap">
                    <?php if (isset($rows[$i][0]->lend_until)) {
                        for ($j = 0;$j < 10;$j++) {
                            echo $rows[$i][0]->lend_until[$j];
                        }
                    } else {
                        echo "--";
                    } ?>
                </td>
            <?php
                } ?>
            <?php if (isset($_REQUEST['print_user_name'])) { ?>
                <td width="<?php if (isset($k)) {
                        echo $k . "%";
                    } else {
                        echo "10%";
                    } ?>" nowrap="nowrap">
                    <?php if (isset($rows[$i][0]->user_name) && ($rows[$i][0]->user_name != "")) {
                        if (isset($k)) {
                            $symbol = $k;
                        } else {
                            $symbol = 10;
                        }
                        echo wordwrap($rows[$i][0]->user_name, $symbol, "<br />\n", 1);
                    } else {
                        echo "--";
                    } ?>
                </td>
            <?php
                } ?>
            <?php if (isset($_REQUEST['print_user_email'])) { ?>
                <td width="<?php if (isset($k)) {
                        echo $k . "%";
                    } else {
                        echo "10%";
                    } ?>" nowrap="nowrap">
                    <?php if (isset($rows[$i][0]->user_email) && ($rows[$i][0]->user_email != "")) {
                        if (isset($k)) {
                            $symbol = $k;
                        } else {
                            $symbol = 10;
                        }
                        echo wordwrap($rows[$i][0]->user_email, $symbol, "<br />\n", 1);
                    } else {
                        echo "--";
                    } ?>
                </td>
            <?php
                } ?>
            <?php if (isset($_REQUEST['print_user_mailing'])) { ?>
                <td width="<?php if (isset($k)) {
                        echo $k . "%";
                    } else {
                        echo "10%";
                    } ?>" nowrap="nowrap">
                    <?php if (isset($rows[$i][0]->user_mailing) && ($rows[$i][0]->user_mailing != "")) {
                        if (isset($k)) {
                            $symbol = $k;
                        } else {
                            $symbol = 10;
                        }
                        echo wordwrap($rows[$i][0]->user_mailing, $symbol, "<br />\n", 1);
                    } else {
                        echo "--";
                    } ?>
                </td>
            <?php
                } ?>
            <?php if (isset($_REQUEST['print_hits'])) { ?>
                <td width="<?php if (isset($k)) {
                        echo $k . "%";
                    } else {
                        echo "5%";
                    } ?>" nowrap="nowrap">
                    <?php if (isset($k)) {
                        $symbol = $k;
                    } else {
                        $symbol = 6;
                    }
                    echo wordwrap($rows[$i][0]->hits, $symbol, "<br />\n", 1); ?>
                </td>
            <?php
                } ?>
        </tr>
<?php
            } /*end for*/ ?>

    </table>
<?php
        } //end if($kol != 0)

?>
 </body>
 </html>
<?php
        exit();
    } //end function showPrintItem()
    //****************   end add for button print in Manager Books   *******************

    function showNoAddProduct() {
        echo "<script>alert('";
        echo _MEDIALIBRARY_TOOLBAR_TOVAR_ALREADY_ADD;
        echo "');window.history.go(-1);</script>";
    }

    function showAddProduct($id) {
        global $mosConfig_live_site, $mainframe;
        header("Location:" . $mosConfig_live_site . "/administrator/index.php?option=com_virtuemart&view=product&task=edit&virtuemart_product_id=$id&product_parent_id=0");
    }

    /**
     * Writes the edit form for new and existing records
     *
     * A new record is defined when <var>$row</var> is passed with the <var>id</var>
     * property set to 0.
     * @param mosMediaLibrary The media object
     * @param mosMediaType  The media type object
     * @param string The html for the categories select list
     * @param string The html for the ordering select list
     */

    static function editMedia($option, $medialibrary, &$media_class, &$clist, &$wslist, &$langlist, 
          &$ratinglist, &$delete_edocument,
          &$reviews, &$type_list, &$multimedia_type, &$langshow, $files, 
          $videos, $audios, $tracks, $youtubeCode, $youtubeId,
          $associateArray, $artistshow='', $authorsshow='', $actorshow = '',
           $studioshow='', $producershow='', $directorshow='', $action='') {
        global $medialibrary_configuration;
        switch ($multimedia_type) {
            case 'book':
                HTML_medialibrary::editing_book($option, $medialibrary, $media_class, $clist, $wslist, 
                  $langlist, $ratinglist,
                  $delete_edocument, $reviews, $type_list, $langshow,$files, $videos, $audios, $tracks,
                  $youtubeCode, $youtubeId, $associateArray, $authorsshow, $action);
            break;
            case 'video':
                HTML_medialibrary::editing_video($option, $medialibrary, $media_class, $clist, $wslist,
                 $langlist, $ratinglist,
                 $delete_edocument, $reviews, $type_list, $langshow,$files, $videos, $audios, $tracks,
                 $youtubeCode, $youtubeId,$associateArray,$actorshow,$studioshow,$producershow,$directorshow);
            break;
            case 'music':
                HTML_medialibrary::editing_music($option, $medialibrary, $media_class, $clist, $wslist, 
                 $langlist, $ratinglist,
                 $delete_edocument, $reviews, $type_list, $langshow,$files, $videos, $audios, $tracks,
                 $youtubeCode, $youtubeId, $associateArray, $artistshow);
            break;
            case 'game':
                HTML_medialibrary::editing_game($option, $medialibrary, $media_class, $clist, $wslist, 
                 $langlist, $ratinglist,
                 $delete_edocument, $reviews, $type_list, $langshow,$files, $videos, $audios, $tracks,
                 $youtubeCode, $youtubeId, $associateArray, $studioshow);
            break;
        }
    }


    static function showInfoRefetchMedias($option, $result, &$wslist) {
        global $my, $mosConfig_live_site, $mainframe, $doc; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
?>

    <form id="adminForm" action="index.php" method="post" name="adminForm">
    <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
        <tr>
            <td colspan="6">
              <strong><?php echo _MEDIALIBRARY_LABEL_INFO_FETCH; ?></strong>
          <?php echo $wslist; ?>
          &nbsp;&nbsp;&nbsp;
          <img src="../components/com_medialibrary/images/amazon/com-logo.gif"
                                  alt="amazon.com" border="0" />
           </td>
            </tr>
            <tr>
                <th align = "center" class="title" width="20">
                    <?php echo _MEDIALIBRARY_LABEL_INFO_REFETCH; ?>
                    <!--<input type="checkbox" name="toggle" value="" checked="checked" onclick="checkAll(<?php
                     echo count($rows); ?>);" />-->
                </th>
                <th align = "center" class="title" width="30">#</th>
                <th align = "center"  class="title" width="15%" nowrap="nowrap"><?php 
                echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?></th>
                <th align = "center" class="title" width="30%" nowrap="nowrap"><?php 
                echo _MEDIALIBRARY_LABEL_TITLE; ?></th>
                <th align = "center"  class="title" width="30%" nowrap="nowrap"><?php 
                echo _MEDIALIBRARY_LABEL_RESULT; ?></th>
            </tr>
<?php
        $i = 0;
        while ($i < count($result)) {
            $row = $result[$i];
?>
            <tr class="row<?php echo $i % 2; ?>">
                <td align = "center">
                <?php
            if ($row[3] != "OK") {
                echo "<input type='checkbox' id='cb'" . $i . "' name='bid[]' value='" . $row[0] .
                 "' onclick='Joomla.isChecked(this.checked);' />";
            } else {
                echo "&nbsp";
            }
?>
                </td>
                <td align = "center">
                    <?php echo $row[0] ?>
                </td>
                <td align = "center">
                    <?php echo $row[1] ?>
                </td>
                <td align = "center">
                    <?php echo $row[2] ?>
                </td>
                <td align = "center">
                    <?php echo $row[3] ?>
                </td>
            </tr>

<?php $i++;
        } ?>

        <input type="hidden" name="option" value="<?php echo $option; ?>" />
        <input type="hidden" name="task" value="" />
        <input type="hidden" name="boxchecked" value="0" />
    </table>
    </form>

<?php
    }
    static function refetchMedias($option, $rows, &$wslist) {
        global $my, $mosConfig_live_site, $mainframe;
        global $doc; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_LABEL_INFO_FETCH . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;
?>

    <form id="adminForm" action="index.php" method="post" name="adminForm">

    <table cellpadding="4" cellspacing="0" border="0" width="100%">

        <tr>
        <td  width="30%">
                <img src="./components/com_medialibrary/images/cfg.png" align="right" alt="Config" />
        </td>
        <td  width="70%" class="media_manager_caption" valign='bottom' >
                <?php echo _MEDIALIBRARY_REFETCH; ?>
        </td>
        </tr>
        <tr>
            <td align="left">&nbsp;
            </td>
        </tr>
        </table>
    <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
            <tr>
              <td  colspan="6">
                <strong><?php echo _MEDIALIBRARY_LABEL_INFO_FETCH; ?></strong>

            <?php echo $wslist; ?>
              &nbsp;&nbsp;&nbsp;<img src="../components/com_medialibrary/images/amazon/com-logo.gif" 
              alt="amazon.com" border="0" />

              </td>
            </tr>
            <tr>

        <th  class="title" width="20">
          <?php
        if (version_compare(JVERSION, "2.5.0", "ge")) { ?>
            <input type="checkbox" name="toggle" value="" onClick="Joomla.checkAll( this);" />
                                                        <?php
        } ?>
       <?php if (version_compare(JVERSION, "2.6.0", "lt")) { ?>
          <input type="checkbox" name="toggle" value="" onClick="checkAll(<?php echo count($rows) ?>);" />
          <?php
        } ?>
        </th>
        <th align = "center" class="title" width="30">#</th>
        <th  align = "center" class="title" width="15%" nowrap="nowrap"><?php 
        echo _MEDIALIBRARY_HEADER_MEDIALIBRARY_LABEL_CATEGORY; ?></th>
        <th align = "center" class="title" width="30%" nowrap="nowrap"><?php 
        echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?></th>
        <th align = "center" class="title" width="30%" nowrap="nowrap"><?php 
        echo _MEDIALIBRARY_LABEL_TITLE; ?></th>
        <th align = "center" class="title" width="25%" nowrap="nowrap"><?php 
        echo _MEDIALIBRARY_LABEL_FETCHED_FROM; ?></th>

            </tr>

<?php
        $i = 0;
        while ($i < count($rows)) {
            $row = $rows[$i];
?>
            <tr class="row<?php echo $i % 2; ?>">
                <td align = "center">
                <input type="checkbox" checked="checked" id="cb<?php echo $i; ?>" name="bid[]" 
                  value="<?php echo $row->id; ?>" onClick="Joomla.isChecked(this.checked);" />
                </td>
                <td align = "center">
                    <?php echo $row->id ?>
                </td>
                <td align = "center">
                    <?php echo $row->category ?>
                </td>
                <td align = "center">
                    <?php echo $row->media_type ?>
                </td>
                <td align = "left">
                    <?php echo $row->title ?>
                </td>
                <td align = "center">
                    <?php
            echo mosMedialibraryWS::getWsNameById($row->informationFrom);
?>                                                      </td>
            </tr>
<?php $i++;
        } ?>
        <input type="hidden" name="option" value="<?php echo $option; ?>" />
        <input type="hidden" name="task" value="" />
        <input type="hidden" name="boxchecked" value="1" />
    </table>
    </form>
<?php
    }
    static function showImportExport($params, $option) {
        global $my, $mosConfig_live_site, $mainframe, $doc; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_ADMIN_IMPEXP . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;
?>

<div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div>

<script type="text/javascript" language="Javascript" src="<?php 
  echo $mosConfig_live_site; ?>/includes/js/overlib_mini.js">
</script>

<script language="javascript" type="text/javascript">
function impch()
{
    var a = document.getElementById('import_type').value;
    if(a == 3)
    document.getElementById('import_catid').disabled=true;
    else
    document.getElementById('import_catid').disabled=false;
    //    alert(a);
}
function expch()
{
    var a = document.getElementById('export_type').value;
    if(a == 3)
    document.getElementById('export_catid').disabled=true;
    else
    document.getElementById('export_catid').disabled=false;
    //    alert(a);
}
//function submitbutton(pressbutton) {
Joomla.submitbutton = function(pressbutton) { // for 1.6
    var form = document.adminForm;
    if (pressbutton == 'import') {
        if (form.import_type.value == '0') {
            alert("<?PHP echo _MEDIALIBRARY_SHOW_IMPEXP_ERR1; ?>" );
            return;
        }
        if (form.import_file.value == '' && form.import_type.value == '3') {
            alert("<?PHP echo _MEDIALIBRARY_SHOW_IMPEXP_ERR3; ?>");
            return;
        }
        if (form.import_catid.value == '0' && form.import_type.value != '3' && form.import_type.value != '0') {
            alert("<?PHP echo _MEDIALIBRARY_SHOW_IMPEXP_ERR2; ?>");
            return;
        }
        if (form.import_catid.value != '0' && form.import_file.value == '') {
            alert("<?PHP echo _MEDIALIBRARY_SHOW_IMPEXP_ERR3; ?>");
            return;
        }
        if ((form.import_type.value == '2') && (form.import_catid.value != '0' && form.import_file.value != '')) {
            alert("<?php echo _MEDIALIBRARY_SHOW_IMPEXP_ERR5; ?>");
            submitform( pressbutton );
        }
        if ((form.import_type.value == '1') && (form.import_catid.value != '0' && form.import_file.value != '')) {
            submitform( pressbutton );
        }
        if (form.import_file.value != '' && form.import_type.value == '3') {
            resultat_1 = confirm("<?php echo _MEDIALIBRARY_SHOW_IMPEXP_CONF; ?>");
            if (resultat_1) submitform( pressbutton );
        }
    }
    if (pressbutton == 'export') {
        if (form.export_type.value == '0') {
            alert("<?PHP echo _MEDIALIBRARY_SHOW_IMPEXP_ERR4; ?>");
            return;
        }
        if (form.export_type.value == '3') {
            submitform( pressbutton );
        }
        if (form.export_type.value == '1') {
            submitform( pressbutton );
        }
        if (form.export_type.value == '2') {
            //alert("<?php echo _MEDIALIBRARY_SHOW_IMPEXP_ERR5; ?>");
            submitform( pressbutton );
        }
    }
}//end function submitbutton(pressbutton)
</script>

      <!-- <table cellpadding="4" cellspacing="0" border="0" width="100%">
        <tr>
            <td width="30%">
              <img src="./components/com_medialibrary/images/cfg.png" align="right" alt="Config" />
            </td>
            <td width="70%" class="media_manager_caption" valign='bottom' >
                <?php echo _MEDIALIBRARY_ADMIN_IMPEXP; ?>
            </td>
        </tr>
      </table> -->

    <form id="adminForm" action="index.php" method="post" name="adminForm" enctype="multipart/form-data">
<?php
        if (version_compare(JVERSION, "3.0.0", "ge")) {
            $options = Array();
            echo JHtml::_('tabs.start', 'impexPane', $options);
            echo JHtml::_('tabs.panel', _MEDIALIBRARY_ADMIN_IMP, 'panel_1_impexPane');
            echo "<br><br><br>";
        } else {
            $tabs = new mosTabs(1);
            $tabs->startPane("impexPane");
            $tabs->startTab(_MEDIALIBRARY_ADMIN_IMP, "impexPane");
        }
?>
      <table class="adminform" style="float: left; margin: 20px;">
<!--**********   begin add Warning in 'Import' for 'CSV', 'XML', 'MySQL tables import'   *********-->
    <tr>
        <td colspan="3">
        <?php echo _MEDIALIBRARY_SHOW_IMPORT_WARNING_MESSAG; ?>
        <hr />
        </td>
    </tr>
<!--************   end add Warning in 'Import' for 'CSV', 'XML', 'MySQL tables import'   *******-->
      <tr>
         <td width="185"><?php echo _MEDIALIBRARY_SHOW_IMPEXP_LABEL_IMPORT_TYP; ?>:</td> 
         <td width="20"><?php 
         echo mosToolTip(_MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_IMPORT_TYP_TT_HEAD,
          _MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_IMPORT_TYP); ?></td>
         <td><?php echo $params['import']['type']; ?></td>
      </tr>
      <tr>
      <td width="185"><?php echo _MEDIALIBRARY_SHOW_IMPEXP_LABEL_IMPORT_MEDIALIBRARY_LABEL_CATEGORY; ?>:</td> 
         <td width="20"><?php echo mosToolTip(_MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_IMPORT_CAT_TT_HEAD,
          _MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_IMPORT_CAT); ?></td>
         <td><?php echo $params['import']['category']; ?></td>
      </tr>
      <tr>
         <td width="185"><?php echo _MEDIALIBRARY_SHOW_IMPEXP_LABEL_IMPORT_FILE; ?>:</td>
         <td width="20"><?php echo mosToolTip(_MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_IMPORT_FILE_TT_HEAD, 
         _MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_IMPORT_FILE); ?></td>
         <td><input class="inputbox" type="file" name="import_file" value="" size="50" maxlength="250" /></td>
      </tr>
      <tr>
    <td colspan="3">&nbsp;</td>
      </tr>
<!-- begin old poka ostavim
      <tr>
         <td width="185">&nbsp;</td>
         <td width="20">&nbsp;</td>
         <td>
        <?php //echo _MEDIALIBRARY_SHOW_IMPEXP_FORMAT;

?>
     </td>
      </tr>
end old poka ostavim -->
      </table>


<?php
        if (version_compare(JVERSION, "3.0.0", "ge")) {
            echo JHtml::_('tabs.panel', _MEDIALIBRARY_ADMIN_EXP, 'panel_2_impexPane');
            echo "<br><br><br>";
        } else {
            $tabs->endTab();
            $tabs->startTab(_MEDIALIBRARY_ADMIN_EXP, "impexPane");
        }
?>
      <table class="adminform" style="float: left; margin: 20px;">
<!--*******************************-->
<!--*****************   begin add Warning in 'Export' for 'CSV', 'XML', 'MySQL tables import'   **********-->
<!--*******************************-->
    <tr>
        <td colspan="3">
        <?php echo _MEDIALIBRARY_SHOW_EXPORT_WARNING_MESSAG; ?>
        <hr />
        </td>
    </tr>
<!--************************************************************-->
<!--********************   end add Warning in 'Export' for 'CSV', 'XML', 'MySQL tables import'   *****-->
<!--*******************************************************************-->
      <tr>
         <td width="185"><?php echo _MEDIALIBRARY_SHOW_IMPEXP_LABEL_EXPORT_TYP; ?>:</td>
         <td width="20"><?php echo mosToolTip(_MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_EXPORT_TYP_TT_HEAD,
          _MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_EXPORT_TYP); ?></td>
         <td><?php echo $params['export']['type']; ?></td>
      </tr>
      <tr>
      <td width="185"><?php echo _MEDIALIBRARY_SHOW_IMPEXP_LABEL_EXPORT_MEDIALIBRARY_LABEL_CATEGORY; ?>:</td>
         <td width="20"><?php echo mosToolTip(_MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_EXPORT_CAT_TT_HEAD, 
         _MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_EXPORT_CAT); ?></td>
         <td><?php echo $params['export']['category']; ?></td>
      </tr>
      <tr>
    <td colspan="3">&nbsp;</td>
      </tr>
      </table>
<?php
        if (version_compare(JVERSION, "3.0.0", "ge")) {
            echo JHtml::_('tabs.end');
        } else {
            $tabs->endTab();
            $tabs->endPane();
        }
?>
        <input type="hidden" name="option" value="<?php echo $option; ?>" />
        <input type="hidden" name="task" value="" />
    </form>
<?php
    }
    function showImportExport111($params, $option) {
        global $my, $mosConfig_live_site, $mainframe, $doc; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
?>

<div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div>

<script type="text/javascript" language="Javascript" src="<?php 
echo $mosConfig_live_site; ?>/includes/js/overlib_mini.js">
</script>

<script language="javascript" type="text/javascript">
function impch()
{
    var a = document.getElementById('import_type').value;
    if(a == 4 )
    document.getElementById('import_catid').disabled=true;
    else
    document.getElementById('import_catid').disabled=false;
    //    alert(a);
}
function expch()
{
    var a = document.getElementById('export_type').value;
    if(a == 4)
    document.getElementById('export_catid').disabled=true;
    else
    document.getElementById('export_catid').disabled=false;
}
Joomla.submitbutton = function(pressbutton) { // for 1.6
    var form = document.adminForm;
    if (pressbutton == 'import') {
        if (form.import_type.value == '0') {
            alert("<?PHP echo _MEDIALIBRARY_SHOW_IMPEXP_ERR1; ?>" );
            return;
        }
        if (form.import_file.value == '' ) {
            alert("<?PHP echo _MEDIALIBRARY_SHOW_IMPEXP_ERR3; ?>");
            return;
        }
        if (form.import_catid.value == '0' && form.import_type.value != '4' && form.import_type.value != '0') {
            alert("<?PHP echo _MEDIALIBRARY_SHOW_IMPEXP_ERR2; ?>");
            return;
        }
        if (form.import_catid.value != '0' && form.import_file.value == '' ) {
            alert("<?PHP echo _MEDIALIBRARY_SHOW_IMPEXP_ERR3; ?>");
            return;
        }
        if ((form.import_type.value == '2') && (form.import_catid.value != '0' && form.import_file.value != '')) {
            alert("<?php echo _MEDIALIBRARY_SHOW_IMPEXP_ERR5; ?>");
            submitform( pressbutton );
        }
        if ((form.import_type.value == '1') && (form.import_catid.value != '0' && form.import_file.value != '')) {
            submitform( pressbutton );
        }
        if (form.import_type.value == '4') {
            resultat_1 = confirm("<?php echo _MEDIALIBRARY_SHOW_IMPEXP_CONF; ?>");
            if (resultat_1) submitform( pressbutton );
        }
    }

    if (pressbutton == 'export') {
            if (form.export_type.value == '0') {
                alert("<?PHP echo _MEDIALIBRARY_SHOW_IMPEXP_ERR4; ?>");
                return;
            }
            if (form.export_type.value == '1') {
                submitform( pressbutton );
            }
            if (form.export_type.value == '2') {
                submitform( pressbutton );
            }
            if (form.export_type.value == '4') {
                submitform( pressbutton );
            }
        }


}//end function submitbutton(pressbutton)


</script>

      <table cellpadding="4" cellspacing="0" border="0" width="100%">
        <tr>
            <td width="30%">
              <img src="./components/com_medialibrary/images/cfg.png" align="right" alt="Config" />
            </td>
            <td width="70%" class="media_manager_caption" valign='bottom' >
                <?php echo _MEDIALIBRARY_ADMIN_IMPEXP; ?>
            </td>
        </tr>
      </table>

    <form id="adminForm" action="index.php" method="post" name="adminForm" enctype="multipart/form-data">
<?php
        if (version_compare(JVERSION, "3.0.0", "ge")) {
            $options = Array();
            echo JHtml::_('tabs.start', 'impexPane', $options);
            echo JHtml::_('tabs.panel', '_MEDIALIBRARY_MANAGER_ADMIN_IMP', 'panel_1_impexPane');
        } else {
            $tabs = new mosTabs(1);
            $tabs->startPane("impexPane");
            $tabs->startTab(_MEDIALIBRARY_ADMIN_IMP, "impexPane");
        }
?>
      <table class="adminform">
<!--**********   begin add Warning in 'Import' for 'CSV', 'XML', 'MySQL tables import'   *********-->
    <tr>
        <td colspan="3">
        <?php echo _MEDIALIBRARY_SHOW_IMPORT_WARNING_MESSAG; ?>
        <hr />
        </td>
    </tr>
<!--************   end add Warning in 'Import' for 'CSV', 'XML', 'MySQL tables import'   *******-->
      <tr>
         <td width="185"><?php echo _MEDIALIBRARY_SHOW_IMPEXP_LABEL_IMPORT_TYP; ?>:</td> <!-- Typ importu -->
         <td width="20"><?php echo mosToolTip(_MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_IMPORT_TYP_TT_HEAD, 
         _MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_IMPORT_TYP); ?></td>
         <td><?php echo $params['import']['type']; ?></td>
      </tr>
      <tr>
         <td width="185"><?php echo _MEDIALIBRARY_SHOW_IMPEXP_LABEL_IMPORT_MEDIALIBRARY_LABEL_CATEGORY; ?>:</td>
         <td width="20"><?php echo mosToolTip(_MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_IMPORT_CAT_TT_HEAD, 
         _MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_IMPORT_CAT); ?></td>
         <td><?php echo $params['import']['category']; ?></td>
      </tr>
      <tr>
         <td width="185"><?php echo _MEDIALIBRARY_SHOW_IMPEXP_LABEL_IMPORT_FILE; ?>:</td>  
             <!-- Plik do importu -->
         <td width="20"><?php echo mosToolTip(_MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_IMPORT_FILE_TT_HEAD, 
         _MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_IMPORT_FILE); ?></td>
         <td><input class="inputbox" type="file" name="import_file" value="" size="50" maxlength="250" /></td>
      </tr>
      <tr>
    <td colspan="3">&nbsp;</td>
      </tr>
<!-- begin old poka ostavim
      <tr>
         <td width="185">&nbsp;</td>
         <td width="20">&nbsp;</td>
         <td>
        <?php //echo _MEDIALIBRARY_SHOW_IMPEXP_FORMAT;

?>
     </td>
      </tr>
end old poka ostavim -->
      </table>


<?php
        if (version_compare(JVERSION, "3.0.0", "ge")) {
            echo JHtml::_('tabs.panel', '_MEDIALIBRARY_ADMIN_EXP', 'panel_2_impexPane');
        } else {
            $tabs->endTab();
            $tabs->startTab(_MEDIALIBRARY_ADMIN_EXP, "impexPane");
        }
?>
      <table class="adminform">
<!--*********************************************************************-->
<!--********************   begin add Warning in 'Export' for 'CSV', 'XML', 'MySQL tables import'   **-->
<!--*******************************************************-->
    <tr>
        <td colspan="3">
        <?php echo _MEDIALIBRARY_SHOW_EXPORT_WARNING_MESSAG; ?>
        <hr />
        </td>
    </tr>
<!--*********************************************************-->
<!--********************   end add Warning in 'Export' for 'CSV', 'XML', 'MySQL tables import'   **********-->
<!--************************************************************-->
      <tr>
         <td width="185"><?php echo _MEDIALIBRARY_SHOW_IMPEXP_LABEL_EXPORT_TYP; ?>:</td>
         <td width="20"><?php echo mosToolTip(_MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_EXPORT_TYP_TT_HEAD, 
         _MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_EXPORT_TYP); ?></td>
         <td><?php echo $params['export']['type']; ?></td>
      </tr>
      <tr>
         <td width="185"><?php echo _MEDIALIBRARY_SHOW_IMPEXP_LABEL_EXPORT_CATEGORY; ?>:</td>
         <td width="20"><?php echo mosToolTip(_MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_EXPORT_CAT_TT_HEAD, 
         _MEDIALIBRARY_ADMIN_SHOW_IMPEXP_LABEL_EXPORT_CAT); ?></td>
         <td><?php echo $params['export']['category']; ?></td>
      </tr>
      <tr>
    <td colspan="3">&nbsp;</td>
      </tr>
      </table>
<?php
        $tabs->endTab();
        $tabs->endPane();
?>
        <input type="hidden" name="option" value="<?php echo $option; ?>" />
        <input type="hidden" name="task" value="" />
    </form>
<?php
    }

      static function showLendMedias($option, $medias, $rows, &$userlist, $type) {
        global $my, $mosConfig_live_site, $mainframe, $medialibrary_configuration;
        global $doc; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addStyleSheet($mosConfig_live_site .
                '/components/com_medialibrary/includes/js/calendar/calendar-mos.css');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/js/mambojavascript.js');
        $doc->addScript($mosConfig_live_site . 
                '/administrator/components/com_medialibrary/js/calendar/calendar.js');
        $doc->addScript($mosConfig_live_site . 
                '/components/com_medialibrary/includes/js/calendar/lang/calendar-en-GB.js');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/js/overlib_mini.js');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_SHOW_LEND_MEDIAS . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;

        switch ($type) {
            case 'lend':
                $a = _MEDIALIBRARY_SHOW_LEND_MEDIAS;
            break;
            case 'lend_return':
                $a = _MEDIALIBRARY_SHOW_LEND_RETURN;
            break;
            case 'edit_lend':
                $a = _MEDIALIBRARY_SHOW_LEND_EDIT;
            break;
            default:
                $a = "&nbsp;";
            break;
        }
?>
       <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
        <form action="index.php" method="post" name="adminForm" id="adminForm">

     <?php if ($type == "lend" or $type == "edit_lend") { ?>

           <table cellpadding="4" cellspacing="0" border="0" width="100%">
                <tr>
             <td align="center" nowrap="nowrap">
                     <?php echo _MEDIALIBRARY_LABEL_LEND_TO . ':'; ?>
                  </td>
                 <td align="center" nowrap="nowrap">
                     <?php echo $userlist; ?>
                 </td>
             <td align="center" nowrap="nowrap">
                      <?php echo _MEDIALIBRARY_LABEL_LEND_USER . ':'; ?>
          </td>
          <td>
              <input type="text" name="user_name" class="inputbox" />
          </td>
          <td width="1000%">
          </td>
                 </tr>
                 <tr>
          <td align="left">&nbsp;
          </td>
          <td align="left">&nbsp;
          </td>
          <td align="left" nowrap="nowrap">
              <?php echo _MEDIALIBRARY_LABEL_LEND_EMAIL . ':'; ?>
          </td>
          <td>
              <input type="text" name="user_email" class="inputbox" />
          </td>
          <td width="30%">&nbsp;
          </td>
        </tr>
           <script>
                 jQuerMedia( "#lend_from, #lend_until" ).datepicker(
                        {
                          minDate: "+0",
                          dateFormat: "<?php echo transforDateFromPhpToJqueryML();?>",
                          beforeShowDay: unavailable,
                        });
                   </script>
        <tr>
          <td align="left" nowrap="nowrap">
            <?php echo _MEDIALIBRARY_LABEL_LEND_FROM . ":"; ?>
          </td>
          <td align="left" nowrap="nowrap">
                  <?php echo JHtml::_('calendar', date("Y-m-d"), 'lend_from', 'lend_from'); ?>
          </td>
          <td align="left" nowrap="nowrap">
            <?php echo _MEDIALIBRARY_LABEL_LEND_UNTIL . ':'; ?>
          </td>
          <td align="left" nowrap="nowrap">
                <?php echo JHtml::_('calendar', date("Y-m-d"), 'lend_until', 'lend_until'); ?>
          </td>
           <td colspan="3">&nbsp;</td>
        </tr>
        <tr>
          <td align="left">&nbsp;</td>
       </tr>
        </table>  
        <?php
        } else { ?>
                &nbsp;
        <?php
        }
?>
            <table cellpadding="4" cellspacing="0" border="0" width="100%"
                   class="adminlist bl_admin_lent-bottom_table my_table">
                <tr>
      <th width="20" align="center">
      <?php if ($type != 'lend') { ?> <?php
            if (version_compare(JVERSION, "2.5.0", "ge")) { ?>
            <input type="checkbox" name="toggle" value="" onClick="Joomla.checkAll( this);" />
                                                        <?php
            } ?>
                 <?php if (version_compare(JVERSION, "2.6.0", "lt")) { ?>
                 <input type="checkbox" name="toggle" value="" onClick="checkAll(<?php echo count($rows) ?>);" />
                    <?php
            } ?>
        <?php
        } ?> </th>
              <th align = "center" width="30">#</th>
              <th align = "center" class="title" width="5%" nowrap="nowrap">
                <?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_ID; ?></th>
              <th align = "center" class="title" width="7%" nowrap="nowrap">
              <?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?></th>
              <th align = "center" class="title" width="25%" nowrap="nowrap">
              <?php echo _MEDIALIBRARY_LABEL_TITLE; ?></th>
              <th align = "center" class="title" width="15%" nowrap="nowrap">
              <?php echo _MEDIALIBRARY_LABEL_LEND_FROM; ?></th>
              <th align = "center" class="title" width="15%" nowrap="nowrap">
              <?php echo _MEDIALIBRARY_LABEL_LEND_UNTIL; ?></th>
              <th align = "center" class="title" width="15%" nowrap="nowrap">
              <?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_RETURN; ?></th>
              <th align = "center" class="title" width="15%" nowrap="nowrap">
              <?php echo _MEDIALIBRARY_LABEL_LEND_TO; ?></th>
                </tr>
                <tr>
                <?php
        if ($type == "lend") {
?>
            <td align="center">  <input class="inputbox"  type="checkbox"
                name="checkMedia" id="checkMedia" size="0" maxlength="0" value="on" /></td>
                 <?php
        } else if ($type == "edit_lend") { ?>
                  <td align="center">
                    <input type="hidden"  name="checkMedia" id="checkMedia" value="on" />
                  </td>
                 <?php
        }

        $assoc_title = '';
        for ($t = 0, $z = count($rows);$t < $z;$t++) {
            if ($rows[$t]->id != $medias->id) $assoc_title.= " " . $rows[$t]->title;
        } ?>


                    <td align="center"> <?php echo $t; ?> </td>

                    <td align="center"> <?php echo $medias->media_id; ?> </td>
                    <td align="center"> <?php echo $medias->media_type; ?> </td>
                    <td align="center"> <?php 

                    if (!empty($assoc_title)) echo $medias->title . '(' . $assoc_title . ')';
                    else echo $medias->title; ?> 
                    </td>

                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td>
                    <td align="center"></td></tr>
      
	<?php
        print_r("<tr>
                  <td align=\"center\">-</td>
                  <td align=\"center\">-</td>
                  <td align=\"center\">-------</td>
                  <td align=\"center\">" . "-----------" . "</td>
                  <td align=\"center\">" . "-----------------" . "</td>
                  <td align=\"center\">" . " -------------" . "</td>
                  <td align=\"center\">" . " ---------" . "</td>
                  <td align=\"center\">" . " ---------------------" . "</td>
                  <td align=\"center\">" . "------------------" . "</td>
                  </tr>");

        for ($j = 0, $n = count($rows);$j < $n;$j++) {
            $row = $rows[$j];
?>
                    <input class="inputbox" type="hidden"  name="mediaid" id="mediaid" size="0"
                           maxlength="0" value="<?php echo $row->media_id; ?>" />
                    <input class="inputbox"  type="hidden"  name="id" id="id" size="0"
                           maxlength="0" value="<?php echo $row->id; ?>" />
                    <input class="inputbox" type="hidden" name="title" id="title" size="0" maxlength="0"
                            value="<?php echo $row->title; ?>" />
                    <?php
            $data = JFactory::getDBO();
            $query = "SELECT * FROM #__medialibrary_lend WHERE fk_mediaid =" . $row->id 
                   . " ORDER BY lend_return ";
            $data->setQuery($query);
            $alllend = $data->loadObjectList();
			
			if (!empty($alllend)) {
                for ($i = 0; $i < count($alllend); $i++) {

                    $cutfrom = explode(' ', $alllend[$i]->lend_from);
                    $cutuntil = explode(' ', $alllend[$i]->lend_until);

                    $alllend[$i]->lend_from = $cutfrom[0];
                    $alllend[$i]->lend_until = $cutuntil[0];
                }   
            }

            $num = 1;
            for ($i = 0, $n2 = count($alllend);$i < $n2;$i++) {
                if (!isset($alllend[$i]->lend_return) && $type != "lend") {
?>
           <td align="center"><input type="checkbox" id="cb<?php echo $i; ?>"
           name="mid[]" value="<?php echo $alllend[$i]->id; ?>" onClick="Joomla.isChecked(this.checked);" /></td>
                                <?php
                } else {

				$cutfrom = explode(' ', $alllend[$i]->lend_from);
		        $cutuntil = explode(' ', $alllend[$i]->lend_until);

		        $alllend[$i]->lend_from = $cutfrom[0];
		        $alllend[$i]->lend_until = $cutuntil[0];
				?>
                <td align="center"></td>
                                <?php
                }
                print_r("
                <td align=\"center\">" . $num . "</td>
                <td align=\"center\">" . $row->media_id . "</td>
                <td align=\"center\">" . $row->media_type . "</td>
                <td align=\"center\">" . $row->title . "</td>
                <td align=\"center\">" . $alllend[$i]->lend_from . "</td>
                <td align=\"center\">" . $alllend[$i]->lend_until . "</td>
                <td align=\"center\">" . $alllend[$i]->lend_return . "</td>
                <td align=\"center\">" . $alllend[$i]->user_name . ":  " . $alllend[$i]->user_email 
                                       . "</td> </tr>");
                $num++;
            }
?>
        <?php
        } ?>
            </table>
            <input type="hidden" name="option" value="<?php echo $option; ?>" />
            <input type="hidden" name="task" value="" />
            <input type="hidden" name="boxchecked" value="1" />
            <input type="hidden" name="save" value="1" />
        </form>
        <?php
    }

static function userLendHistory($option, $medias, $rows, &$userlist, $type) {

        
        global $my, $mosConfig_live_site, $mainframe, $medialibrary_configuration;
        global $doc; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
     
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_SHOW_LEND_MEDIAS . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;

        $a = _MEDIALIBRARY_SHOW_LEND_MEDIAS;
        ?>
        <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
        <form action="index.php" method="post" name="adminForm" id="adminForm">
            <table cellpadding="4" cellspacing="0" border="0" width="100%" >
                <tr>
                    <td align="right" nowrap="nowrap">
                        <?php echo $userlist; ?>
                    </td>
                </tr>
                <script>
                     function submitUser(teg){
                        jQuery('#userIdSubmit').val(jQuery('#userid').val());
                        jQuery('#adminForm').submit();
                     }
                   
                </script>
            </table>   
          <table cellpadding="4" cellspacing="0" border="0" width="100%"
                   class="adminlist bl_admin_lent-bottom_table my_table">
          <tr class="cat-header">
              
            <th align = "center" class="title" width="5%" nowrap="nowrap">#</th>

            <th align = "center" class="title" width="5%" nowrap="nowrap">
                <a href = "index.php?option=com_medialibrary&task=sorting_userlend_media_type_id">
                    <?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_ID; ?></a>
            </th>
         
            <th align = "center" class="title" width="5%" nowrap="nowrap">
                <a href="index.php?option=com_medialibrary&task=sorting_userlend_media_type"> 
                    <?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?></a>
            </th>
                    
            <th align = "center" class="title" width="15%" nowrap="nowrap">
                <a href="index.php?option=com_medialibrary&task=sorting_userlend_media_title">
                    <?php echo _MEDIALIBRARY_LABEL_TITLE; ?></a>
            </th>

            <th align = "center" class="title" width="15%" nowrap="nowrap">
                <a href="index.php?option=com_medialibrary&task=sorting_userlend_lendfrom">
                    <?php echo _MEDIALIBRARY_LABEL_LEND_FROM; ?></a>
            </th>

            <th align = "center" class="title" width="15%" nowrap="nowrap">
                <a href="index.php?option=com_medialibrary&task=sorting_userlend_lentuntil">
                    <?php echo _MEDIALIBRARY_LABEL_LEND_UNTIL; ?></a>
            </th>

            <th align = "center" class="title" width="15%" nowrap="nowrap">
                <a href="index.php?option=com_medialibrary&task=sorting_userlend_returnmedia">
                    <?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_RETURN; ?></a>
			</th>

            <th align = "center" class="title" width="15%" nowrap="nowrap">
                            <?php echo _MEDIALIBRARY_LABEL_LEND_ADRES; ?></a>
            </th>

			<th align = "center" class="title" width="15%" nowrap="nowrap">
				 <a href="index.php?option=com_medialibrary&task=sorting_userlend_email">
				            <?php echo _MEDIALIBRARY_LABEL_LEND_EMAIL; ?>
			</th>

          </tr>
             
            <?php
				$i = 1;
            foreach ($medias as $num => $media) {
                if($media->lendid > 0) {
                    print_r("<tr>
                        <td align=\"center\">" . $i++ . "</td>
                        <td align=\"center\">" . $media->media_id . "</td>
                        <td align=\"center\">" . $media->media_type . "</td>
                        <td align=\"center\">" . $media->title . "</td>
                        <td align=\"center\">" . $media->lend_from . "</td>
                        <td align=\"center\">" . $media->lend_until . "</td>
                        <td align=\"center\">" . $media->lend_return . "</td>
						<td align=\"center\">" . $media->user_mailing . "</td>
                        <td align=\"center\">" . $media->user_name . ":  " . $media->user_email 
                                               . "</td> </tr>");
                }
            }?>
        
            </table>
            <input type="hidden" name="option" value="<?php echo $option; ?>" />
            <input type="hidden" name="task" value="user_lend_history" />
            <!-- <input id="userIdSubmit" type="hidden" name="userId" value="" /> -->
        </form>
        <?php
    }


    static function editLendMedias($option, $medias, $rows, $title_assoc, $all_assosiate_lend, $usermenu, $type) {
       global $my, $mosConfig_live_site, $mainframe, $medialibrary_configuration;
        global $doc; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addStyleSheet($mosConfig_live_site . 
                '/components/com_medialibrary/includes/js/calendar/calendar-mos.css');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/js/mambojavascript.js');
        $doc->addScript($mosConfig_live_site . 
                '/administrator/components/com_medialibrary/js/calendar/calendar.js');
        $doc->addScript($mosConfig_live_site . 
                '/components/com_medialibrary/includes/js/calendar/lang/calendar-en-GB.js');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/js/overlib_mini.js');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_SHOW_LEND_MEDIAS . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;
?>

    <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>

    <form action="index.php" method="post" name="adminForm" id="adminForm">
    <table cellpadding="4" cellspacing="0" border="0" width="100%">
    <tr>
     <td width="100%" class="media_manager_caption"  >
      <?php
        if ($type == "lend") {
            echo _MEDIALIBRARY_SHOW_LEND_MEDIAS;
        } else if ($type == "lend_return") {
            echo _MEDIALIBRARY_SHOW_LEND_RETURN;
        } if ($type == "edit_lend") {
            echo _MEDIALIBRARY_SHOW_LEND_EDIT;
        } else {
            echo "&nbsp;";
        }
?>
       </td>
       </tr>
       <tr>
           <td align="left">
           &nbsp;
           </td>
        </tr>
    </table>
<?php
        if ($type == "lend" or $type == "edit_lend") {
?>
           <table cellpadding="4" cellspacing="0" border="0" width="100%">
                <tr>
             <td align="center" nowrap="nowrap">
                     <?php echo _MEDIALIBRARY_LABEL_LEND_TO . ':'; ?>
                  </td>
                 <td align="center" nowrap="nowrap">
                     <?php echo $userlist; ?>
                 </td>
             <td align="center" nowrap="nowrap">
                      <?php echo _MEDIALIBRARY_LABEL_LEND_USER . ':'; ?>
          </td>
          <td>
              <input type="text" name="user_name" class="inputbox" />
          </td>
          <td width="100%">
          </td>
                 </tr>
                 <tr>
          <td align="left">&nbsp;
          </td>
          <td align="left">&nbsp;
          </td>
          <td align="left" nowrap="nowrap">
              <?php echo _MEDIALIBRARY_LABEL_LEND_EMAIL . ':'; ?>
          </td>
          <td>
              <input type="text" name="user_email" class="inputbox" />
          </td>
          <td width="30%">&nbsp;
          </td>
        </tr>
           <script>
                  jQuerMedia( "#lend_from, #lend_until" ).datepicker(
                        {
                          minDate: "+0",
                          dateFormat: "<?php echo transforDateFromPhpToJqueryML();?>",
                          beforeShowDay: unavailable,
                        }); 
           </script>
        <tr>
          <td align="left" nowrap="nowrap">
            <?php echo _MEDIALIBRARY_LABEL_LEND_FROM . ":"; ?>
          </td>
          <td align="left" nowrap="nowrap">
                  <?php echo JHtml::_('calendar', date("Y-m-d"), 'lend_from', 'lend_from'); ?>
          </td>
        <td align="left" nowrap="nowrap">
          <?php echo _MEDIALIBRARY_LABEL_LEND_UNTIL . ':'; ?>
        </td>
              <td align="left" nowrap="nowrap">
                    <?php echo JHtml::_('calendar', date("Y-m-d"), 'lend_until', 'lend_until'); ?>
                </td>
                <td colspan="3">&nbsp;
        </td>
            </tr>
      <tr>
        <td align="left">&nbsp;
        </td>
            </tr>
        </table>
<?php
        } else {
?>
        &nbsp;
<?php   }
?>

  <table cellpadding="4" cellspacing="0" border="0" width="100%"
         class="adminlist bl_admin_lent-bottom_table my_table">
                <tr>
                    <th width="20" align="center">
        <?php if ($type != 'lend') {
?> <input type="checkbox" name="toggle" value="" onClick="Joomla.checkAll(this);" />
        <?php
        } ?> </th>
                  <th align = "center" width="30">#</th>
                  <th align = "center" class="title" width="5%" nowrap="nowrap">
                  <?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE_ID; ?></th>
                  <th align = "center" class="title" width="7%" nowrap="nowrap">
                  <?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?></th>
                  <th align = "center" class="title" width="25%" nowrap="nowrap">
                  <?php echo _MEDIALIBRARY_LABEL_TITLE; ?></th>
                  <th align = "center" class="title" width="15%" nowrap="nowrap">
                  <?php echo _MEDIALIBRARY_LABEL_LEND_FROM; ?></th>
                  <th align = "center" class="title" width="15%" nowrap="nowrap">
                  <?php echo _MEDIALIBRARY_LABEL_LEND_UNTIL; ?></th>
                  <th align = "center" class="title" width="15%" nowrap="nowrap">
                  <?php echo _MEDIALIBRARY_TOOLBAR_ADMIN_RETURN; ?></th>
                  <th align = "center" class="title" width="15%" nowrap="nowrap">
                  <?php echo _MEDIALIBRARY_LABEL_LEND_TO; ?></th>
            </tr>
                <?php
        if ($type == "edit_lend") { ?>
                  <input type="hidden"  name="checkHouse" id="checkHouse" value="on" /></td>
                 <?php
        }

        $assoc_title = '';
        for ($t = 0, $z = count($title_assoc);$t < $z;$t++) {
            if ($title_assoc[$t]->id != $medias->id) $assoc_title.= " " . $title_assoc[$t]->title;
        }
?>
                <input class="inputbox" type="hidden"  name="mediaid" id="mediaid" size="0"
                       maxlength="0" value="<?php echo $medias->mediaid; ?>" />
                <input class="inputbox"  type="hidden"  name="id" id="id" size="0"
                       maxlength="0" value="<?php echo $medias->id; ?>" />
        <?php
        $num = 1;
        for ($i = 0, $n2 = count($all_assosiate_lend[0]);$i < $n2;$i++) {
            $assoc_lend_ids = '';
            for ($j = 0, $n3 = count($all_assosiate_lend);$j < $n3;$j++) {
                if (isset($all_assosiate_lend[$j][$i]->id)) {
                if ($assoc_lend_ids != "") $assoc_lend_ids.= "," . $all_assosiate_lend[$j][$i]->id;
                else $assoc_lend_ids = $all_assosiate_lend[$j][$i]->id;
            	}
            }

?>
                  <td align="center"><input type="checkbox"  id="cb<?php echo $i; ?>" name="mid[]"
                    value="<?php echo $assoc_lend_ids; ?>" onClick="Joomla.isChecked(this.checked);" /></td>
                       
            <td align="center"> <?php echo $num; ?> </td>

                    <td align="center"> <?php echo $medias->id; ?> </td>
                    <td align="center"> <?php echo $medias->media_type; ?> </td>
                    <td align="center"> <?php 

                    if(!empty($assoc_title)) echo $medias->title . '(' . $assoc_title . ')';
                    else echo $medias->title; ?>
                     
                     </td>
                    
                    <td align="center"> <?php if (isset($all_assosiate_lend[0][$i]->lend_from ))
                                                    echo $all_assosiate_lend[0][$i]->lend_from; ?> </td>
                    <td align="center"> <?php if (isset($all_assosiate_lend[0][$i]->lend_until ))
                                                    echo $all_assosiate_lend[0][$i]->lend_until; ?> </td>
                    <td align="center"> <?php if (isset($all_assosiate_lend[0][$i]->lend_return ))
                                                    echo $all_assosiate_lend[0][$i]->lend_return; ?> </td>
                    <td align="center"> <?php echo $all_assosiate_lend[0][$i]->user_name . ': '. $all_assosiate_lend[0][$i]->user_email;  ?> </td></tr>
       <?php $num++; }

            print_r("
                          <td align=\"center\">-</td>
                          <td align=\"center\">-</td>
                          <td align=\"center\">" . "------------" . "</td>
                          <td align=\"center\">" . "-----------------" . "</td>
                          <td align=\"center\">" . " -------------" . "</td>
                          <td align=\"center\">" . " ---------" . "</td>
                          <td align=\"center\">" . " ---------------------" . "</td>
						  <td align=\"center\">" . "------------------" . "</td>
                          <td align=\"center\">" . "------------------" . "</td></tr>");
        //show rent history what we can't change
 		$num = 1;
        for ($j = 0, $n = count($rows);$j < $n;$j++) {
            $row = $rows[$j];
            if ($row->lend_return == "") continue;
           
?>
                        &nbsp;
                    </td>
                    <input class="inputbox" type="hidden"  name="mediaid" id="mediaid" size="0"
                           maxlength="0" value="<?php echo $row->media_id; ?>" />
                    <input class="inputbox"  type="hidden"  name="id" id="id" size="0"
                           maxlength="0" value="<?php echo $row->id; ?>" />
                    <td align="center">
                    </td>
                        <?php
            print_r("
                <td align=\"center\">" . $num . "</td>
                <td align=\"center\">" . $row->media_id . "</td>
                <td align=\"center\">" . $row->media_type . "</td>
                <td align=\"center\">" . $row->title . "</td>
                <td align=\"center\">" . $row->lend_from . "</td>
                <td align=\"center\">" . $row->lend_until . "</td>

                <td align=\"center\">" . $row->lend_return . "</td>
                <td align=\"center\">" . $row->user_name . ":  " . $row->user_email . "</td></tr>");
                $num++;
?>
        <?php
        } ?>
            </table>
            <input type="hidden" name="option" value="<?php echo $option; ?>"/>
            <input type="hidden" name="task" value="" />
            <input type="hidden" name="boxchecked" value="1" />
            <input type="hidden" name="save" value="1" />
        </form>
        <?php
    }

    //--------------------------------------------------
    static function showConfiguration($lists, $option, $txt) {
        global $my, $mosConfig_live_site, $mainframe, $act, $task;
        global $doc; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_ADMIN_CONFIG_FRONTEND . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;?>

        <div style="float: right">This is <b>FREE</b> version of the Medialibrary!<br>
                <a target = "_blank" href="//ordasoft.com/media-library-joomla-extension">
                    Buy PRO version for more features!</a>
        </div>
        
        <div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div>
        <script>
            window.onload=function()
            {
                if (document.getElementById('money_select').options[
                      document.getElementById('money_select').selectedIndex].value == 'other') { 
                    document.getElementById('patt').type="text";
                    document.getElementById('patt').removeAttribute('readonly');
                }
            }
            function set_pricetype(sel) {
                var value = sel.options[sel.selectedIndex].value;
                if (value=="space") {
                    document.getElementById('patt').value="&nbsp;";

                }
                else if (value!="other") {
                    document.getElementById('patt').value=value;
                    document.getElementById('patt').setAttribute('readonly', true); 
                    document.getElementById('patt').type="hidden";
                } else
                {
                    document.getElementById('patt').value="";
                    document.getElementById('patt').type="text";
                    document.getElementById('patt').removeAttribute('readonly');
                }
            }
        </script>
        
        <script language="javascript" type="text/javascript">      
            jQuery(document).ready(function() {
               if (jQuery("[rel=tooltip]").length) {
         jQuery("[rel=tooltip]").tooltip();
         }
            });
        </script>
    

        <form action="index.php" method="post" name="adminForm" id="adminForm"> 
            <!-- ////////////  START  TAB 1  ///////////// -->
            <?php
            if (version_compare(JVERSION, "3.0.0", "ge")) {
                $options = Array();
                echo JHtml::_('tabs.start', 'configurePane', $options);
            } else {
                $tabs = new mosTabs(7);
                $tabs->startPane("configurePane");
            }?>

            <!-- ////////////  START  TAB 2  ///////////// -->
            <?php
            if (version_compare(JVERSION, "3.0.0", "ge")) {
                echo JHtml::_('tabs.panel', JText::_('Show buttons'),
                 'panel_2_configurePane');
            } else {
                $tabs->endTab();
                $tabs->startTab('Show buttons', "panel_2_configurePane");
            }
            ?>
            <!-- START OPTION TAB 2 -->
            <div style="clear: both;"></div>
            <h2><?php echo 'Show buttons'; ?></h2>
            <table class="adminform form_18 show_buttons adminform-flex-table" border="0">
           
                
            
                <!--************   begin add button 'buy now'   ******************-->
                <tr>
                    <td>
                    <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_BUYNOW_SHOW; ?>:</span>
                    <?php echo mosToolTip(_MEDIALIBRARY_ADMIN_CONFIG_BUYNOW_SHOW_TT_BODY); ?></td>
                    <td><div style="min-width:48px;"><?php echo $lists['buy_now']['show']; ?></div></td>
                </tr>
                <!--************   end add button 'buy now'   *********************-->

      
            </table>
            <!-- END OPTION TAB 2 -->
            <!-- ////////////  END  TAB 2  ///////////// -->
            
            <!-- ////////////  START  TAB 3  ///////////// -->
            <?php
            if (version_compare(JVERSION, "3.0.0", "ge")) {
                echo JHtml::_('tabs.panel', JText::_('Page Settings'),
                 'panel_3_configurePane');
            } else {
                $tabs->endTab();
                $tabs->startTab('Page Settings', "panel_3_configurePane");
            }
            ?>
            <!-- START OPTION TAB 3 -->
            <div style="clear: both;"></div>
            <h2><?php echo 'Show field'; ?></h2> <!-- const -->
            <table class="adminform form_18 adminform-flex-table show_field" border="0">
                <tr>
                    <td>
                    <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_LENDSTATUS_SHOW; ?>:
                    </span>
                    <?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_LENDSTATUS_SHOW_TT_BODY); ?>
                    </td>
                    <td><div style="min-width:48px;"><?php echo $lists['lendstatus']['show']; ?></div></td>
                    <td>
                    <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_LENDREQUEST_REGISTRATIONLEVEL; ?>:</span>                    <?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_LENDREQUEST_REGISTRATIONLEVEL_TT_BODY); ?></td>
                    <td><?php echo $lists['lendrequest']['registrationlevel']; ?></td>
                </tr>

                <tr>
                    <td>
                    <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_PRICE_SHOW; ?>:</span>                    <?php echo mosToolTip(_MEDIALIBRARY_ADMIN_CONFIG_PRICE_SHOW_TT_BODY); ?></td>
                    <td><div style="min-width:48px;"><?php echo $lists['price']['show']; ?></div></td>
                    <td>
                    </td>
                    <td></td>
                </tr>

                <tr>
                    <td>
                    <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_EMEDIAS_SHOW; ?>:</span>                    <?php echo mosToolTip(_MEDIALIBRARY_ADMIN_CONFIG_EMEDIAS_SHOW_TT_BODY); ?></td>
                    <td><div style="min-width:48px;"><?php echo $lists['emedias']['show']; ?></div></td>
                    <td>
                    <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_EMEDIS_REGISTRATIONLEVEL; ?>:</span>                    <?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_EMEDIS_REGISTRATIONLEVEL_TT_BODY); ?></td>
                    <td><?php echo $lists['emedias']['registrationlevel']; ?></td>
                </tr>

                <tr>
                    <td>
                    <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_SEARCHFIELD_SHOW; ?>:</span>                    <?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_SEARCHFIELD_SHOW_TT_BODY); ?></td>
                    <td><div style="min-width:48px;"><?php echo $lists['search_field']['show']; ?></div></td>
                    <td>
                    <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_SEARCHFIELD_REGISTRATIONLEVEL; ?>:</span>                    <?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_SEARCHFIELD_REGISTRATIONLEVEL_TT_BODY); ?></td>
                    <td><?php echo $lists['search_field']['registrationlevel']; ?></td>
                </tr>

                <tr>
                    <td>
                    <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_ADVSEARCH_SHOW; ?>:</span>                    <?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_ADVSEARCH_SHOW_TT_BODY); ?></td>
                    <td><div style="min-width:48px;"><?php echo $lists['advsearch']['show']; ?></div></td>
                    <td>
                    <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_ADVSEARCH_REGISTRATIONLEVEL; ?>:</span>                    <?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_ADVSEARCH_REGISTRATIONLEVEL_TT_BODY); ?></td>
                    <td><?php echo $lists['advsearch']['registrationlevel']; ?></td>
                </tr>
            </table>
            <br/>
            <h2><?php echo 'Image settings'; ?></h2> <!-- const -->
            <table class="adminform form_18" border="0">
                <!-- ******* begin add CoverSize *****-->
                <tr>
                    <td><?php echo _MEDIALIBRARY_ADMIN_CONFIG_FOTO_SIZE; ?>:</td>
                    <td><?php echo mosToolTip('', _MEDIALIBRARY_ADMIN_CONFIG_FOTO_SIZE_TT_BODY);?></td>
                    <td><?php echo ($lists['foto']['high']) . ($lists['foto']['width']); ?> </td>
                </tr>
                <!-- ******* end add CoverSize *****-->

                <tr>
                    <td width="185" colspan=""><?php echo _MEDIALIBRARY_ADMIN_CONFIG_IMAGES_DOWNLOAD; ?>:</td>
                    <td width="20" colspan=""><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_IMAGES_DOWNLOAD_TT_BODY); ?></td>
                    <td colspan=""><?php echo $lists['fetchImages']['boolean']; ?></td>
                </tr>

                <tr>
                    <td width="185" colspan=""><?php echo 
                        _MEDIALIBRARY_ADMIN_CONFIG_IMAGES_DOWNLOAD_LOCATION; ?>:</td>
                    <td width="20" colspan=""><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_IMAGES_DOWNLOAD_LOCATION_TT_BODY); ?></td>
                    <td colspan=""><?php echo $lists['fetchImages']['location']; ?></td>
                </tr>

                <!-- ******* begin add FotoSize *****-->
                <tr>
                    <td><?php echo _MEDIALIBRARY_ADMIN_CONFIG_FOTO_PEOPLE_SIZE; ?>:</td>
                    <td><?php echo mosToolTip('', _MEDIALIBRARY_ADMIN_CONFIG_FOTO_SIZE_TT_BODY_PEOPLE);?></td>
                    <td><?php echo ($lists['foto']['high_author']) . ($lists['foto']['width_author']); ?></td>
                </tr>
                <!-- ******* end add FotoSize *****-->

            </table>
            <br/>
            <tr><td colspan="6">    <hr />    </td></tr>
            <h2><?php echo 'Count settings'; ?></h2> <!-- const -->
            <table class="adminform form_18" border="0">
                <!-- audio player skin-->
                <!-- <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_PAGE_AUDIO_PLAYER_SKIN; ?>:</td>
                    <td width="20"><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_PAGE_AUDIO_PLAYER_SKIN_TT_BODY); ?></td>
                    <td><?php echo $lists['audio_player']['skin']; ?></td>
                </tr> -->
                
                <!-- audio player count item-->
                <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_PAGE_AUDIO_PLAYER_ITEMS; ?>:</td>
                    <td width="20"><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_PAGE_AUDIO_PLAYER_ITEMS_TT_BODY); ?></td>
                    <td><?php echo $lists['audio_player']['items']; ?></td>
                </tr>
      
                <!-- video player skin-->
                <!-- <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_PAGE_VIDEO_PLAYER_SKIN; ?>:</td>
                    <td width="20"><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_PAGE_VIDEO_PLAYER_SKIN_TT_BODY); ?></td>
                    <td><?php echo $lists['video_player']['skin']; ?></td>
                </tr> -->

                <!-- video player count item-->
                <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_PAGE_VIDEO_PLAYER_ITEMS; ?>:</td>
                    <td width="20"><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_PAGE_VIDEO_PLAYER_ITEMS_TT_BODY); ?></td>
                    <td><?php echo $lists['video_player']['items']; ?></td>
                </tr>
                
                <!-- begin add PageItems -->
                <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_PAGE_MEDIA_ITEMS; ?>:</td>
                    <td width="20"><?php 
                        echo mosToolTip(_MEDIALIBRARY_ADMIN_CONFIG_PAGE_MEDIA_ITEMS_TT_BODY); ?></td>
                    <td><?php echo $lists['page']['items']; ?></td>
                </tr>
                
                <!-- begin add PageItems -->
                <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_PAGE_ITEMS_PEOPLE; ?>:</td>
                    <td width="20"><?php 
                        echo mosToolTip(_MEDIALIBRARY_ADMIN_CONFIG_PAGE_ITEMS_TT_BODY_PEOPLE); ?></td>
                    <td><?php echo $lists['people']['items']; ?></td>
                </tr>
            </table>
            <!-- END OPTION TAB 3 -->
            <!-- ////////////  END  TAB 3  ///////////// -->
            
            <!-- ////////////  START  TAB 4  ///////////// -->
            <?php
            if (version_compare(JVERSION, "3.0.0", "ge")) {
                echo JHtml::_('tabs.panel', JText::_('Media settings'),
                 'panel_4_configurePane');
            } else {
                $tabs->endTab();
                $tabs->startTab('Media settings', "panel_4_configurePane");
            }
            ?>
            <!-- START OPTION TAB 4 -->
            <div style="clear: both;"></div>


            <h2><?php echo 'Exts'; ?></h2> <!-- const -->
            <table class="adminform form_18" border="0">
                <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_ALLOWED_EXTS; ?>:</td>
                    <td></td>
                    <td colspan=""><?php echo $lists['allowed_exts']; ?></td>
                </tr>

                <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_ALLOWED_EXTS_IMG; ?>:</td>
                    <td></td>
                    <td colspan=""><?php echo $lists['allowed_exts_img']; ?></td>
                </tr>  

                <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_ALLOWED_EXTS_VIDEO; ?>:</td>
                    <td></td>
                    <td colspan=""><?php echo  $lists['allowed_exts_video']; ?></td>
                </tr>

                <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_ALLOWED_EXTS_TRACK; ?>:</td>
                    <td></td>
                    <td colspan=""><?php echo  $lists['allowed_exts_track']; ?></td>
                </tr>

                <tr>
                    <td width="185"><?php echo _MEDIALIBRARY_ALLOWED_EXTS_AUDIO; ?>:</td>
                    <td></td>
                    <td colspan=""><?php echo $lists['allowed_exts_audio']; ?></td>
                </tr>
            </table>
            <br/>
            <tr><td colspan="6">    <hr />    </td></tr>
            <h2><?php echo 'Media support settings'; ?></h2> <!-- const -->
            <table class="adminform form_18" border="0">

                <tr>
                    <td width="185" colspan=""><?php echo 
                        _MEDIALIBRARY_ADMIN_CONFIG_EMEDIAS_DOWNLOAD_LOCATION; ?>:</td>
                    <td width="20" colspan=""><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_EMEDIAS_DOWNLOAD_LOCATION_TT_BODY); ?></td>
                    <td colspan=""><?php echo $lists['emedias']['location']; ?></td>
                </tr>


                <tr>
                    <td width="185" colspan=""><?php echo 
                        _MEDIALIBRARY_ADMIN_CONFIG_EMEDIAS_DOWNLOAD; ?>:</td>
                    <td width="20" colspan=""><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_EMEDIAS_DOWNLOAD_TT_BODY); ?></td>
                    <td colspan=""><?php echo $lists['emedias']['allow']; ?></td>
                </tr>

                <tr>
                    <td width="185" colspan=""><?php echo 
                        _MEDIALIBRARY_ADMIN_CONFIG_VIDEO_TRACK_DOWNLOAD; ?>:</td>
                    <td width="20" colspan=""><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_VIDEO_TRACK_DOWNLOAD_TT_BODY); ?></td>
                    <td colspan=""><?php echo $lists['videos_tracks']['allow']; ?></td>
                </tr>

                <tr>
                    <td width="185" colspan=""><?php echo 
                        _MEDIALIBRARY_ADMIN_CONFIG_VIDEO_DOWNLOAD_LOCATION; ?>:</td>
                    <td width="20" colspan=""><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_VIDEO_DOWNLOAD_LOCATION_TT_BODY); ?></td>
                    <td colspan=""><?php echo $lists['videos']['location']; ?></td>
                </tr>

                <tr>
                    <td width="185" colspan=""><?php echo 
                        _MEDIALIBRARY_ADMIN_CONFIG_TRACK_DOWNLOAD_LOCATION; ?>:</td>
                    <td width="20" colspan=""><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_TRACK_DOWNLOAD_LOCATION_TT_BODY); ?></td>
                    <td colspan=""><?php echo $lists['tracks']['location']; ?></td>
                </tr>

                <tr>
                    <td width="185" colspan=""><?php echo 
                        _MEDIALIBRARY_ADMIN_CONFIG_AUDIO_DOWNLOAD; ?>:</td>
                    <td width="20" colspan=""><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_AUDIO_DOWNLOAD_TT_BODY); ?></td>
                    <td colspan=""><?php echo $lists['audios']['allow']; ?></td>
                </tr>

                <tr>
                    <td width="185" colspan=""><?php echo 
                        _MEDIALIBRARY_ADMIN_CONFIG_AUDIO_DOWNLOAD_LOCATION; ?>:</td>
                    <td width="20" colspan=""><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_AUDIO_DOWNLOAD_LOCATION_TT_BODY); ?></td>
                    <td colspan=""><?php echo $lists['audios']['location']; ?></td>
                </tr>
            </table>
            <br/>
            <tr><td colspan="6">    <hr />    </td></tr>
            <h2><?php echo 'Reviews settings'; ?></h2> <!-- const -->
            <table class="adminform form_18 adminform-flex-table reviews_settings" border="0">
                <!-- BEGIN__REVIEW__ -->
                <tr>
                    <td>
                    <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_REVIEWS_SHOW; ?>:</span>                    <?php echo mosToolTip(_MEDIALIBRARY_ADMIN_CONFIG_REVIEWS_SHOW_TT_BODY); ?></td>
                    <td class="yesno"><div style="min-width:48px;"><?php echo $lists['reviews']['show']; ?></div></td>
                    <td>
                    <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_REVIEWS_REGISTRATIONLEVEL; ?>:</span>                    <?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_REVIEWS_REGISTRATIONLEVEL_TT_BODY); ?></td>
                    <td><?php echo $lists['reviews']['registrationlevel']; ?></td>
                </tr>


            </table>
            <!-- END OPTION TAB 4 -->
            <!-- ////////////  END  TAB 4  ///////////// -->
            
            <!-- ////////////  START  TAB 5  ///////////// -->
            <?php
            if (version_compare(JVERSION, "3.0.0", "ge")) {
                echo JHtml::_('tabs.panel', JText::_('Other settings'),
                 'panel_5_configurePane');
            } else {
                $tabs->endTab();
                $tabs->startTab('Other settings', "panel_5_configurePane");
            }
            ?>
            <!-- START OPTION TAB 5 -->
            <div style="clear: both;"></div>
            <h2><?php echo 'Amazon settings'; ?></h2> <!-- const -->
            <table class="adminform form_18" border="0">
                <tr>
                    <td width="185" colspan=""><?php echo _MEDIALIBRARY_ADMIN_CONFIG_WS_AMAZON_TAG; ?>:</td>
                    <td width="20" colspan=""><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_WS_AMAZON_TAG_TT_BODY); ?></td>
                    <td colspan=""><?php echo $lists['ws']['amazon']['tag']; ?></td>
                </tr>

                <tr>
                    <td width="185" colspan=""><?php echo _MEDIALIBRARY_ADMIN_CONFIG_WS_AMAZON_DEVTAG; ?>:</td>
                    <td width="20" colspan=""><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_WS_AMAZON_DEVTAG_TT_BODY); ?></td>
                    <td colspan=""><?php echo $lists['ws']['amazon']['devtag']; ?></td>
                </tr>

                <tr>
                    <td width="185" colspan=""><?php echo 
                        _MEDIALIBRARY_ADMIN_CONFIG_WS_AMAZON_SECRET_KEY; ?>:</td>
                    <td width="20" colspan=""><?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_WS_AMAZON_SECRET_KEY_TT_BODY); ?></td>
                    <td colspan=""><?php echo $lists['ws']['amazon']['secret_key']; ?></td>
                </tr>


            </table>
            <br/>
            <h2><?php echo 'Other'; ?></h2> <!-- const -->
            <table class="adminform form_18 adminform-flex-table other_settings" border="0">
                <tr>
                    <td>
                        <span class="pre_tooltip_text"><?php echo 
                        _MEDIALIBRARY_ADMIN_CONFIG_PICTURE_IN_MEDIALIBRARY_LABEL_CATEGORY; ?>:
                        </span>
                        <?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_PICTURE_IN_MEDIALIBRARY_LABEL_CATEGORY_TT_BODY); ?>
                    </td>
                    <td>
                    <?php echo $lists['cat_pic']['show']; ?>
                    </td>
                    <td></td>
                    <td></td>
                </tr>

                <tr>
                    <td>
                        <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_SUBCATEGORY_SHOW; ?>:</span>
                        <?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_SUBCATEGORY_SHOW_TT_BODY); ?>
                    </td>
                    <td>
                        <?php echo $lists['subcategory']['show']; ?>
                    </td>
                    <td></td>
                    <td></td>
                </tr>

  
              
            
                <tr>
                    <td >
                        <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_EDITMEDIA_CHECK_ISBN_ASIN; ?>:</span>
                        <?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_EDITMEDIA_CHECK_ISBN_ASIN_TT_BODY); ?>
                    </td>
                    <td >
                        <?php echo $lists['editmedia']['check']['isbn_asin']; ?>
                        
                    </td>
                    <td></td>
                    <td></td>
                </tr>

                <tr>
                    <td>
                        <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_ADMIN_CONFIG_DESCRIPTION_MERGE_USE; ?>:</span>
                        <?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_DESCRIPTION_MERGE_USE_TT_BODY); ?>
                    </td>
                    <td>
                        <div style="width:200px;overflow:hidden;">
                        <?php echo $lists['merge_description']['use']; ?>
                        </div>
                    </td>
                    <td >
                        <span class="pre_tooltip_text"><?php echo 
                        _MEDIALIBRARY_ADMIN_CONFIG_DESCRIPTION_MERGE_REGISTRATIONLEVEL; ?>:</span>
                        <?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_DESCRIPTION_MERGE_REGISTRATIONLEVEL_TT_BODY);?>
                    </td>
                    <td>
                        <?php echo $lists['merge_description']['registrationlevel']; ?>
                    </td>
                </tr>

                <tr>
                    <td >
                        <span class="pre_tooltip_text"><?php echo 
                        _MEDIALIBRARY_ADMIN_CONFIG_EDITMEDIA_DEFAULT_LANG; ?>:</span>
                        <?php echo mosToolTip(
                        _MEDIALIBRARY_ADMIN_CONFIG_EDITMEDIA_DEFAULT_LANG_TT_BODY); ?> 
                    </td>
                    <td ><?php echo $lists['editmedia']['default']['lang']; ?></td>
                    <td></td>
                    <td></td>
                </tr>

                <tr>
                    <td>
                        <span class="pre_tooltip_text">
                        <?php echo _MEDIALIBRARY_PRICE_FORMAT; ?>:
                        </span>
                        <?php echo mosToolTip(_MEDIALIBRARY_PRICE_FORMAT_INFO); ?>
                    </td>
                    <td>
                        <?php echo $lists['money_ditlimer'] ?><br />
                        <?php echo $lists['patern']; ?>
                    </td>
                    <td></td>
                    <td></td>
                </tr>

                <tr>
                    <td>
                        <span class="pre_tooltip_text"><?php echo _MEDIALIBRARY_PRICE_UNIT_SHOW; ?>:</span>
                        <?php echo mosToolTip(_MEDIALIBRARY_PRICE_UNIT_SHOW_INFO); ?>
                    </td>
                    <td class="yesno"><?php echo $lists['price_unit_show'] ?></td>
                    <td></td>
                    <td></td>
                </tr>
                
                <!--date format -->
                <tr>
                    <td >
                        <span class="pre_tooltip_text">
                        <?php echo _MEDIALIBRARY_DATE_TIME_FORMAT; ?></span>                    <?php echo mosToolTip(_MEDIALIBRARY_MANAGER_DATE); ?>
                    </td>
                    <td>
                        <?php echo $lists['date_format'] ?>
                    </td>
                    <td>
                        <?php echo mosToolTip(_MEDIALIBRARY_TIME); ?>
                    </td>
                    <td><?php echo $lists['datetime_format'] ?></td>
                </tr>

            </table>
            <!-- END OPTION TAB 5 -->
            <!-- ////////////  END  TAB 5  ///////////// -->
            
            <input type="hidden" name="option" value="<?php echo $option; ?>" />
            <input type="hidden" name="task" value="config_save" />
        </form>
              
    <?php
        
    }
    
    static function about() {
        global $mosConfig_live_site, $mainframe;
        // for 1.6
        global $doc;
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        // --
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_ADMIN_ABOUT . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;
?>
        <div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div>

        <form action="index.php"  class="veh_about veh_dd_tabs"  method="post" name="adminForm" id="adminForm">

                <?php
        if (version_compare(JVERSION, "3.0.0", "ge")) {
            $options = Array();
            echo JHtml::_('tabs.start', 'aboutPane', $options);
            echo JHtml::_('tabs.panel', JText::_(_MEDIALIBRARY_ADMIN_ABOUT_ABOUT), 'panel_1_id');
        } else {
            $tabs = new mosTabs(0);
            $tabs->startPane("aboutPane");
            $tabs->startTab(_MEDIALIBRARY_ADMIN_ABOUT_ABOUT, "display-page");
        }
?>
       <div class="adminform_44">
            <table class="adminform">
                <tr>
                    <td width="80%"><h3><?PHP echo _MEDIALIBRARY_ADMIN_ABOUT_ABOUT; ?></h3><?PHP 
                      echo _MEDIALIBRARY__HTML_ABOUT_INTRO; ?></td>
                    <td width="20%"><img src="../components/com_medialibrary/images/medialibrary_logo.png" 
                      align="right" alt="Media" /></td>
                </tr>
            </table>
      </div>
            <?php
        /* $tabs->endTab();
        //****************   tab--2 about   **************************************
        $tabs->startTab(_MEDIALIBRARY_ADMIN_ABOUT_RELEASENOTE, "display-page");
        include_once("./components/com_medialibrary/doc/releasenote.php");
        $tabs->endTab();
        //***************   tab--3 about--changelog.txt   ***********************
        $tabs->startTab(_MEDIALIBRARY_ADMIN_ABOUT_CHANGELOG, "display-page");
        include_once("./components/com_medialibrary/doc/changelog.html");
        $tabs->endTab();

        $tabs->endPane(); */
        global $medialibrary_configuration, $mosConfig_absolute_path;
            if (version_compare(JVERSION, "1.6.0", "lt")){
                $xml =& JFactory::getXMLParser( 'simple' );
                $xml->loadFile( $mosConfig_absolute_path
                        .'/administrator/components/com_medialibrary/medialibraryj15.xml' );
                if ($xml->document == ''){
                    unset($xml);
                    return;
                }
                $version_from_xml = $xml->document->getElementByPath( 'version' )->_data;
                $date_from_xml = $xml->document->getElementByPath( 'creationdate')->_data;
            } else {
                $xml=JFactory::getXml($mosConfig_absolute_path
                  ."/administrator/components/com_medialibrary/medialibrary.xml");
                $version_from_xml = (string)$xml->version;
                $date_from_xml = (string)$xml->creationDate;
            }
            $medialibrary_configuration['release']['version'] = (string)$version_from_xml;
            $medialibrary_configuration['release']['date'] = (string)$date_from_xml;
            mosMedialibraryOthers::setParams();
            unset($xml);
?>

        <?php
        //***************   tab--2 about   **************************************
        if (version_compare(JVERSION, "3.0.0", "ge")) {
            echo JHtml::_('tabs.panel', JText::_(_MEDIALIBRARY_ADMIN_ABOUT_RELEASENOTE), 'panel_2_id');
        } else {
            $tabs->endTab();
            $tabs->startTab(_MEDIALIBRARY_ADMIN_ABOUT_RELEASENOTE, "display-page");
        } ?><div class='adminform_50'> <?php include_once ("./components/com_medialibrary/doc/releasenote.php");
?></div> <?php
        //******************************   tab--3 about--changelog.txt   ***********************
        if (version_compare(JVERSION, "3.0.0", "ge")) {
            echo JHtml::_('tabs.panel', JText::_(_MEDIALIBRARY_ADMIN_ABOUT_CHANGELOG), 'panel_2_id');
        } else {
            $tabs->endTab();
            $tabs->startTab(_MEDIALIBRARY_ADMIN_ABOUT_CHANGELOG, "display-page");
        }
        include_once ("./components/com_medialibrary/doc/changelog.html");
        //End Pane
        if (version_compare(JVERSION, "3.0.0", "ge")) {
            echo JHtml::_('tabs.end');
        } else {
            $tabs->endTab();
            $tabs->endPane();
        }
?>

        </form>
                <?php
    }
   static function showImportResult($table, $option) {
        global $my, $mosConfig_live_site, $mainframe, $doc; // for J 1.6
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
?>
        <form action="index.php" method="post" name="adminForm" id="adminForm">
            <table cellpadding='4' cellspacing='0' border='1' width='100%'>
                <tr>
                    <td>#</td>
                    <td><?php echo _MEDIALIBRARY_LABEL_ISBN_ASIN; ?></td>
            <td><?php echo _MEDIALIBRARY_LABEL_MEDIA_TYPE; ?></td>
            <?php if (isset($table[0][3])) {
            echo "<td>" . _MEDIALIBRARY_SHOW_IMPEXP_LABEL_IMPORT_MEDIALIBRARY_LABEL_CATEGORY . "</td>";
        } ?>
                    <td><?php echo _MEDIALIBRARY_LABEL_TITLE; ?></td>

                <td><?php echo _MEDIALIBRARY_LABEL_LANGUAGE_DESCRIPTION; ?></td>
                    <td><?php echo _MEDIALIBRARY_LABEL_STATUS; ?></td>

                </tr>

            <?php foreach($table as $entry) {
?>
                <tr>
                    <td><?php echo $entry[0]; ?></td>
                    <td><?php echo $entry[1]; ?></td>
                    <td><?php echo $entry[2]; ?></td>
                    <?php if (isset($table[0][3])) {
                echo '<td>' . $entry[3] . '</td>';
            } ?>
                    <td><?php echo $entry[4]; ?></td>
                    <td><?php echo $entry[5]; ?></td>
                <td><?php echo $entry[6]; ?></td>
                </tr>
            <?php
        }
?>
                </table>
                <input type="hidden" name="option" value="<?php echo $option; ?>" />
                <input type="hidden" name="task" value="cancel" />
            </form>

    <?php
    }
   static function showExportResult($InformationArray, $option) {
?>
    <form action="index.php" method="post" name="adminForm" id="adminForm">

      <div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div>
      <script type="text/javascript" language="Javascript" 
        src="<?php echo $mosConfig_live_site; ?>/includes/js/overlib_mini.js"></script>

     <table border="0" class="adminheading" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="middle">
        <th class="config"><?php echo _MEDIALIBRARY_SHOW_IMPEXP_RESULT; ?></th>
        <td align="right"></td>
      </tr>
      </table>

        <?php echo _MEDIALIBRARY_SHOW_IMPEXP_RESULT_DOWNLOAD; ?>  <br />
        <a href="<?php echo $InformationArray['urlBase'] . $InformationArray['out_file']; ?>" 
          target="blank"><?php echo $InformationArray['urlBase'] . $InformationArray['out_file']; ?></a>
          <br />
          <?php echo _MEDIALIBRARY_SHOW_IMPEXP_RESULT_REMEMBER; ?>  <br />
            <input type="hidden" name="option" value="<?php echo $option; ?>" />
            <input type="hidden" name="task" value="cancel" />
        </form>

  <?php
    }
    static function showLanguageManager($const_languages, $pageNav, $search) {
        global $my, $mosConfig_live_site, $mainframe, $templateDir;
        // for 1.6
        global $doc;
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
            _MEDIALIBRARY_ADMIN_LANGUAGE_MANAGER . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;
?>
        <form action="index.php" method="post" name="adminForm" id="adminForm">

        <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist language_manager">
            <tr>

                <?php if (version_compare(JVERSION, "3.0.0", "ge")) {
                ?>
                    <td>
                        <div class="btn-group pull-right hidden-phone">
                            <label for="limit" class="element-invisible"><?php 
                              echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC'); ?></label>
                                    <?php echo $pageNav->getLimitBox(); ?>
                        </div>
                    </td>
                <?php
                } ?>

            </tr>
        </table>

            <table cellpadding="4" cellspacing="0" border="0" width="100%"  class="adminlist language_manager" >
                <tr>
                    <td><?php echo _MEDIALIBRARY_SHOW_SEARCH; ?></td>
                    <td><input type="text" name="search_const" value="<?php echo $search['const']; ?>" 
                      class="inputbox input-medium" onChange="document.adminForm.submit();" /></td>
                    <td><input type="text" name="search_const_value" 
                      value="<?php echo $search['const_value']; ?>" class="inputbox input-medium" 
                        onChange="document.adminForm.submit();" /></td>
                    <td><?php echo $search['languages']; ?></td>
                    <td style=" text-align: right; "><?php echo $search['sys_type']; ?></td>
                    <td align = "right" class="title" width="10%" nowrap="nowrap">
                    <input class="loadLang" type="button" name="loadLang"
                      value="Load languages"
                      onclick="window.location.replace(
                        'index.php?option=com_medialibrary&section=language_manager&task=loadLang')"/>
                   </td>
                </tr>
                </table>
                <table class="adminlist language_manager">
                <tr class="cat-header">
                    <th width="5" align="center"></th>
                    <th align = "center" class="title" width="30%" nowrap="nowrap"><?php 
                      echo _MEDIALIBRARY_ADMIN_LANGUAGE_MANAGER_CONST; ?></th>
                    <th align = "center" class="title" width="30%" nowrap="nowrap"><?php 
                      echo _MEDIALIBRARY_ADMIN_LANGUAGE_MANAGER_VALUE_CONST; ?></th>
                    <th align = "center" class="title" width="10%" nowrap="nowrap"><?php 
                      echo _MEDIALIBRARY_LABEL_LANGUAGE; ?></th>
                    <th align = "center" class="title" width="30%" nowrap="nowrap"><?php 
                      echo _MEDIALIBRARY_ADMIN_LANGUAGE_MANAGER_SYS_TYPE; ?></th>
                </tr>

        <?php
        $i = 0;
        foreach($const_languages as $k => $const_language) {
?>
                    <tr>
                        <td align="center"><?php 
                            echo mosHTML::idBox($k, $const_language->id, false, 'vid');?></td>
                        <td><a href="#edit" onClick="return listItemTask('cb<?php echo $k; ?>','edit')"><?php 
                        echo $const_language->const; ?></a></td>
                        <td><a href="#edit" onClick="return listItemTask('cb<?php echo $k; ?>','edit')"><?php 
                        echo $const_language->value_const; ?></a></td>
                        <td align="center"><?php echo $const_language->title; ?></td>
                        <td align="center"><?php echo $const_language->sys_type; ?></td>
                    </tr>
            <?php
        }
?>
                <tr><td align="center" colspan = "13"><?php echo $pageNav->getListFooter(); ?></td></tr>
            </table>
            <input type="hidden" name="option" value="com_medialibrary" />
            <input type="hidden" name="section" value="language_manager" />
            <input type="hidden" name="task" value="" />
            <input type="hidden" value="0" name="boxchecked" />
        </form>
        <?php
    }
    static function editLanguageManager($row, $lists) {
        global $mosConfig_live_site;
        global $doc;
        $doc->addStyleSheet($mosConfig_live_site . '/components/com_medialibrary/includes/medialibrary.css');
        $doc->addScript($mosConfig_live_site . '/components/com_medialibrary/includes/functions.js');
        $html = "<div class='media_manager_caption' >".
          "<img src='./components/com_medialibrary/images/cfg.png' alt ='Config' /> " . 
          _MEDIALIBRARY_ADMIN_LANGUAGE_MANAGER . "</div>";
        $app = JFactory::getApplication();
        $app->JComponentTitle = $html;
?>
        <form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
            <table >
                <tr>
                    <th  class="media_manager_caption" align="left"><?php 
                    echo $row->id ? _MEDIALIBRARY_HEADER_EDIT : _MEDIALIBRARY_HEADER_ADD; ?> <?php 
                    echo _MEDIALIBRARY_ADMIN_LANGUAGE_MANAGER_CONST; ?> </th>
                </tr>
            </table>
            <table width="100%"  class="table_10">
                <tr>
                    <td valign="top">
                        <table class="adminform adminform_48" style="height: 150px;">
                            <tr>
                                <td><?php echo _MEDIALIBRARY_ADMIN_LANGUAGE_MANAGER_CONST; ?>:</td>
                                <td colspan="2"><?php echo $lists['const']; ?></td>
                            </tr>
                            <tr>
                                <td><?php echo _MEDIALIBRARY_ADMIN_LANGUAGE_MANAGER_VALUE_CONST; ?>:</td>
                                <td colspan="2"><textarea class="text_area" type="text" 
                                name="value_const"><?php echo $row->value_const; ?></textarea></td>
                            </tr>
                            <tr>
                                <td><?php echo _MEDIALIBRARY_ADMIN_LANGUAGE_MANAGER_SYS_TYPE; ?>:</td>
                                <td colspan="2"><?php echo $lists['sys_type']; ?></td>
                            </tr>
                            <tr>
                                <td><?php echo _MEDIALIBRARY_LABEL_LANGUAGE; ?>:</td>
                                <td colspan="2"><?php echo $lists['languages']; ?></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
            <input type="hidden" name="const" value="<?php echo $lists['const']; ?>"/>
            <input type="hidden" name="option" value="com_medialibrary" />
            <input type="hidden" name="section" value="language_manager" />
            <input type="hidden" name="task" value="" />
            <input type="hidden" name="id" value="<?php echo $row->id; ?>" />
            <input type="hidden" name="sectionid" value="com_medialibrary" />
        </form>
        <?php
    }
}
