<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

/**
*
* @package BookLibrary
* @copyright Andrey Kvasnevskiy-OrdaSoft(akbet@mail.ru); Rob de Cleen(rob@decleen.com); 
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* Homepage: http://www.ordasoft.com
* @version: 2.2 Free
*
**/


require_once($mosConfig_absolute_path."/libraries/joomla/plugin/helper.php");
require_once ($mosConfig_absolute_path."/administrator/includes/toolbar.php");
require_once ($mosConfig_absolute_path."/libraries/joomla/html/toolbar.php");

require_once ($mosConfig_absolute_path."/components/com_booklibrary/booklibrary.php");
require_once($mosConfig_absolute_path."/administrator/components/com_booklibrary/menubar_ext.php");

$mosConfig_live_site = JURI::root(true); //for 1.6
$GLOBALS['mosConfig_live_site'] = $mosConfig_live_site;
$GLOBALS['mosConfig_absolute_path'] = $mosConfig_absolute_path;//for 1.6


// for J 1.6
	$mainframe = JFactory::getApplication(); 
	$GLOBALS['mainframe'] = $mainframe; 

	$templateDir = JPATH_THEMES.DS.JFactory::getApplication()->getTemplate().DS;	
	$GLOBALS['templateDir'] = $templateDir;
		
	$doc =JFactory::getDocument();  
	$GLOBALS['doc'] = $doc; 
// --

$g_item_count = 0;

class HTML_booklibrary 
{



	function showLendRequest( & $books, & $currentcat, & $params, & $tabclass, & $catid, & $sub_categories,$is_exist_sub_categories, $sort_arr){
		HTML_booklibrary::displayBooks($books, $currentcat, $params, $tabclass, $catid, $sub_categories, $is_exist_sub_categories, $sort_arr);
		// add the formular for send to :-)
	}

	function displayBooks($rows, $currentcat, &$params, $tabclass, $catid, $categories,$is_exist_sub_categories,$sort_arr, &$pageNav = null)
        {
         $session = JFactory::getSession();
         $arr = $session->get("array","default");

         
        global $doc, $hide_js, $Itemid,$mosConfig_live_site,$mosConfig_absolute_path;
		global $limit, $total, $limitstart, $task, $paginations, $mainframe, $booklibrary_configuration;

        // for 1.6
        $doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_booklibrary/includes/booklibrary.css' );
        $doc->addStyleSheet( $mosConfig_live_site.'/components/com_booklibrary/includes/custom.css' );
?>
		 <noscript>Javascript is required to use Book Library <a href="http://ordasoft.com/Book-Library/booklibrary-versions-feature-comparison.html">Book Library - create book library, ebook, book collection  </a>, 

<a href="http://ordasoft.com/location-map.html">Book library book sowftware for Joomla</a></noscript>
                <script type="text/javascript">
		function lend_request_submitbutton() {
			var form = document.userForm;
			if (form.user_name.value == "") {
				alert( "<?php echo _BOOKLIBRARY_INFOTEXT_JS_LEND_REQ_NAME; ?>" );				
			} else if (form.user_email.value == "" || !isValidEmail(form.user_email.value)) {
				alert( "<?php echo _BOOKLIBRARY_INFOTEXT_JS_LEND_REQ_EMAIL;?>" );
			} else if (form.user_mailing == "") {       
				alert( "<?php echo _BOOKLIBRARY_INFOTEXT_JS_LEND_REQ_MAILING;?>" );
			} else if ((form.lend_until.value == "") || (form.lend_until.value < form.lend_from.value)) {  
				alert( "<?php echo _BOOKLIBRARY_INFOTEXT_JS_LEND_REQ_UNTIL;?>" );
			} else {
				form.submit();
			}
		}
		function isValidEmail(str) {
			return (str.indexOf("@") > 1);
		}
     function allreordering(){
        if(document.orderForm.direction.value=='asc')
          document.orderForm.direction.value='desc';
        else document.orderForm.direction.value='asc';

        document.orderForm.submit();
    }
		</script>
<?php positions_bl($params->get('singleuser01'));?>
<?php positions_bl($params->get('singlecategory01')); ?>
		<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo $currentcat->header; ?>
		</div>
				<?php positions_bl($params->get('singleuser02'));?>
<?php positions_bl($params->get('singlecategory02')); ?>
		<table border="0" class="basictable"  cellpadding="4" cellspacing="0" width="100%">
			<tr>				
				<?php
				if($currentcat->img != null && $currentcat->align == 'left' && $params->get( 'show_cat_pic') ){
				?>
				<td>
                    <img src="<?php echo $currentcat->img; ?>" align="<?php echo $currentcat->align; ?>" alt="?"/>
   	            </td>
		        <?php
				}
				?>
				<td width="100%">
					<?php echo $currentcat->descrip; ?>
				</td>
		        <?php
					if($currentcat->img != null && $currentcat->align == 'right'){
				?>
				<td>
		        	  <img src="<?php echo $currentcat->img; ?>" align="<?php echo $currentcat->align; ?>" alt="?" />
		        	</td>
		        <?php
				}
				?>
		     	</tr>
		   </table>
		              <?php positions_bl($params->get('singlecategory03')); ?>
		<?php
                if(strpos($currentcat->header,_BOOKLIBRARY_LABEL_SEARCH) && count($rows) == 0  ){
                ?>
                  <div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
                          <?php echo _BOOKLIBRARY_NOTHING_FOUND ; ?>
                  </div>
                <?php
				mosHTML::BackButton ( $params, $hide_js );
                  return; 
                }
               if($params->get('show_search')){

		?>
                    <div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
                      <table class="basictable"  width="100%" border="0" cellspacing="0" cellpadding="0">
                       <tr>
                          <td width="60%">&nbsp;
                          </td>
                          <td width="40%" nowrap align="right">
                              <?php
										echo HTML_booklibrary::displaySimpleSearch();
										echo "<div style=\"font-size: smaller;line-height: 0.9em;text-align:right;\">	<a href=\"index.php?option=com_booklibrary&task=show_search&catid=0&Itemid=$Itemid\"> Advanced search</a></div>";
                              ?>
                          </td>
                        </tr>
                      </table>
                    </div>
		<?php
	               }	
         $total = count($rows);
    if($total > 0) {
    
      $view_type =$params->get('view_type');
      if(isset($_REQUEST['viewtype'])) {
         $view_type_selected=mosGetParam($_REQUEST, 'viewtype');
         $session =JFactory::getSession();
         $session->set('view_type_selected', $view_type_selected);
      }
      else {
         $session =JFactory::getSession();
         $view_type_selected=$session->get('view_type_selected');
      }
      
      $is_show_view_type = false;
      //add view type selecting
       if($view_type==2){
         $redirect_url = $_SERVER["REQUEST_URI"];
         $pos = strpos($redirect_url,"viewtype=");
         if( $pos != FALSE ){
           $redirect_url1 = str_replace("viewtype=1","viewtype=0",$redirect_url);
           $redirect_url2 = str_replace("viewtype=0","viewtype=1",$redirect_url);
         } else {
           $redirect_url1 = $_SERVER["REQUEST_URI"].'&amp;viewtype=0';
           $redirect_url2 = $_SERVER["REQUEST_URI"].'&amp;viewtype=1';
         }
         $is_show_view_type = true;
       }
       
      $sort_arr['field'] = $params->get('sort_arr_field');
      $sort_arr['direction'] = $params->get('sort_arr_direction');      

                 ?>
				 	<?php positions_bl($params->get('singleuser03'));?>
<?php positions_bl($params->get('singlecategory04')); ?>
                    <table width="100%" class="basictable">
                    <tr>
                      <?php 
                      if( $is_show_view_type ) {
                      ?>
                        <td>
                           <div id="viewtype">
                           <a href="<?php echo $redirect_url1;?>"  ><?php echo _BOOKLIBRARY_CONFIG_VIEW_TYPE_LIST;?></a>
                           &nbsp;|&nbsp;<a href="<?php echo $redirect_url2 ;?>" style="active" ><?php echo _BOOKLIBRARY_CONFIG_VIEW_TYPE_GALLERY;?></a>
                           </div>
                        </td>
                      <?php 
                      }
                      ?>
                      
                      
                     <td >
                        <div id="ShowOrderBy" style="text-align:right" >

                        <form id="adminForm" method="POST" action="<?php echo $_SERVER["REQUEST_URI"];?>" name="orderForm">

                        <input type="hidden" id="direction" name="direction" value="<?php echo $sort_arr['direction']; ?>" >

                        <a title="Click to sort by this column." onclick="javascript:allreordering();return false;" href="#">
                          <img alt="" src="./components/com_booklibrary/images/sort_<?php 
						  if ($sort_arr['direction'] == false){echo 'asc';}
						  else {
						  echo $sort_arr['direction'];} ?>.png" />
                        </a>
                          <?php echo _BOOKLIBRARY_LABEL_ORDER_BY; ?> <select size="1" class="inputbox" onchange="javascript:document.orderForm.direction.value='asc'; document.orderForm.submit();" id="field" name="field">
                          <option value="authors" <?php if($sort_arr['field'] == "authors") echo 'selected="selected"'; ?> > <?php echo _BOOKLIBRARY_LABEL_AUTHORS; ?></option>
                          <option value="title" <?php if($sort_arr['field'] == "title") echo 'selected="selected"'; ?> > <?php echo _BOOKLIBRARY_LABEL_TITLE; ?></option>
						  <option value="rating" <?php if($sort_arr['field'] == "rating") echo 'selected="selected"'; ?> > <?php echo _BOOKLIBRARY_LABEL_RATING; ?></option>
						  <option value="hits" <?php if($sort_arr['field'] == "hits") echo 'selected="selected"'; ?> > <?php echo _BOOKLIBRARY_LABEL_HITS; ?></option>
						  </select>       
                        </form>

                        </div>
                      </td>
                    </tr>
                    </table>                           
     <?php positions_bl($params->get('singleuser04'));?>
<?php positions_bl($params->get('singlecategory05')); ?>

			
<?php
  $available = false;   
  if(  $view_type==0||($view_type==2 && ($view_type_selected==0 ||!isset($view_type_selected)))){ 
?>
    <div id="list">
    <table  width="100%" border="0" cellspacing="0" cellpadding="0" class="basictable">
			<tr>
				<td height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">
					<?php echo _BOOKLIBRARY_LABEL_COVER; ?>
				</td>
				<td height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">
				<?php echo _BOOKLIBRARY_LABEL_TITLE; ?>
				</td>
				<td height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo _BOOKLIBRARY_LABEL_AUTHORS; ?>
				</td>
				<?php
				if ( $params->get( 'show_rating' ) ) {
					?>
					<td height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">
						<?php echo _BOOKLIBRARY_LABEL_RATING; ?>
						</td>
				<?php
				} 				
				if ( $params->get( 'hits' ) ) {
					?>
					<td width="30" height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>" align="right">
						<?php echo _BOOKLIBRARY_LABEL_HITS; ?>
					</td>
					<?php 
				}
				if ( $params->get( 'search_request' ) ) {
					?>
					<td height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>" align="right">
						<?php echo _BOOKLIBRARY_LABEL_CATEGORY; ?>
					</td>
					<?php
				}
				if ($params->get('show_lendstatus') && $params->get('show_lendrequest')) {
				?>
					<td height="20" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">	
						<?php echo _BOOKLIBRARY_LABEL_LEND_CB; ?>
					</td>
				<?php
				}
				?>
			</tr>
		<?php 
   
		$k = 0;
//****************************************   add my perenos
		foreach ($rows as $row) {
//****************************************   add my perenos
			$link = 'index.php?option=com_booklibrary&task=view&id='. $row->id . '&catid='.$catid.'&Itemid='. $Itemid;     //
			?>			
			<tr class="<?php echo $tabclass[$k]; ?>" >
				<td style="padding-left:5px; padding-top:5px; padding-right:10px;">
                                              <?php
          $book = $row;
          //for local images
          $imageURL = $book->imageURL;
?>	<a href="<?php echo sefRelToAbs( $link ); ?>" class="category<?php echo $params->get( 'pageclass_sfx' ); ?>">
 <?php
          if($imageURL != '' && substr($imageURL,0,4) != "http")
          {
            $imageURL = $mosConfig_live_site . ''. $book->imageURL;;
          }

          if($imageURL != ''){
            echo '<img src="'.$imageURL.'" alt="cover" border="0" height="50" ' ;
          } else{
            echo '<img src="'.$mosConfig_live_site.'/components/com_booklibrary/images/' . _BOOKLIBRARY_NO_PICTURE.'" alt="no-img_eng.gif" border="0" />';
          }?> 	</a> 
				</td>
				<td  width="45%">
				<a href="<?php echo sefRelToAbs( $link ); ?>" class="category<?php echo $params->get( 'pageclass_sfx' ); ?>">
				<?php echo $row->title; ?> 
				</a> 
				<!--<?php 
				if ( $params->get( 'item_description' ) ) {
					?>
					<br /> 
					<?php echo $row->description; ?>
					<?php 
				} 
				?>-->
				</td>
				<td  width="55%"> 				
					<?php echo $row->authors; ?> 
				</td>
				<?php
				if ( $params->get( 'show_rating' ) ) {
       
					?>
					<td align="right">
						<img src="<?php echo $mosConfig_live_site; ?>/components/com_booklibrary/images/rating-<?php echo $row->rating; ?>.gif" alt="<?php echo ($row->rating)/2; ?>" align="left" border="0" />&nbsp;&nbsp;
					</td>
				<?php
				}
				if ( $params->get( 'hits' ) ) {
					?>
					<td align="left">
					<?php echo $row->hits; ?>
					</td>
					<?php 
				} 
				if ( $params->get( 'search_request' ) ) {
					$link1 = 'index.php?option=com_booklibrary&task=showCategory&catid='.$row->category_id.'&Itemid='. $Itemid;
				?>
					<td align="right">
						<a href="<?php echo sefRelToAbs( $link1 ); ?>" class="category<?php echo $params->get( 'pageclass_sfx' ); ?>">
					<?php echo $row->category; ?>
						</a>
					</td>
				<?php
				}
				
				if ($params->get('show_lendstatus') && $params->get('show_lendrequest')) {
                    $data1 = JFactory::getDBO();
                    $query = "SELECT  b.lend_from , b.lend_until  FROM #__booklibrary_lend  AS b LEFT JOIN #__booklibrary AS c ON b.fk_bookid = c.id WHERE  c.id=" . $row->id . " AND c.published='1' AND c.approved='1' AND b.lend_return IS NULL";

                    $data1->setQuery($query);
                    $rents1 = $data1->loadObjectList();
                ?>
                    <td align="center">
        <?php
                    if (count($rents1) == 0 ) {
?>
        <?php
                        echo "<img src='" . $mosConfig_live_site . "/components/com_booklibrary/images/available.png' alt='Available' name='image' border='0' align='middle' />";
                    } else {
                        echo _BOOKLIBRARY_LABEL_LEND_FROM_UNTIL . "<br />";
                        for ($a = 0; $a < count($rents1); $a++) {
                            $from_until = substr($rents1[$a]->lend_from, 0, 10) .
                                    "&nbsp;/&nbsp;" .
                                    substr($rents1[$a]->lend_until, 0, 10) . "\n";
                            print_r($from_until);
                        }
                    } 
                if($params->get( 'lend_save')){
							
								$available = true;  
							} else {
							
								$available = false;   
							}
        ?>
            <br>
        </td>
<?php } ?>
			</tr>
			<?php
			$k = 1 - $k;
		} 
		?>
    <tr><td colspan="6" align="center">&nbsp;</td></tr>
    </table>
    </div>
  	<?php positions_bl($params->get('singleuser05'));?>
<?php positions_bl($params->get('singlecategory06')); ?>
  <?php
             }else{
?>
                <div id="gallery">
				 <table  width="100%" border="0" cellspacing="0" cellpadding="0">
                     <?php $total = count($rows);
                        foreach ($rows as $row) {
                        $link = 'index.php?option=com_booklibrary&amp;task=view&amp;id=' . $row->id . '&amp;catid=' . $catid . '&amp;Itemid=' . $Itemid;
                         $imageURL = $row->imageURL;
                         ?>
                         <tr>
                         <div style="border: 1px solid white;
    float: left;
    height: 225px;
    margin: 5px;
    padding: 10px;
    position: relative;
    width: 134px;">
                            <div>
                             <a href="<?php echo sefRelToAbs($link); ?>" >
                             <?php

                             if ($imageURL != '') {
                                    if($imageURL != '' && substr($imageURL,0,4) != "http")
                                    {
                                      $imageURL = $mosConfig_live_site . '/'. $imageURL;;
                                    }
                                    echo '<img height="'.$booklibrary_configuration['foto']['high'].'"
                                      width="'.$booklibrary_configuration['foto']['width'].' "src="' .$imageURL
                                     . '" border="0">';
                             } else {
                                    echo '<img  height="'.$booklibrary_configuration['foto']['high'].'"
                                      width="'.$booklibrary_configuration['foto']['width'].'" src="' .
                                     './components/com_booklibrary/images/'._BOOKLIBRARY_NO_PICTURE .
                                     '" alt="no-img_eng_big.gif" border="0"  />&nbsp;';
                             }?>
                             </a>
                            </div>
                             <div class="textmedia">
                             <div class="titlemedia">
                                 <a href="<?php echo sefRelToAbs($link); ?>" >
                                    <?php if(strlen($row->title)>30) echo substr($row->title,0,30),'...';
                                    else {
                                        echo $row->title;
                                    }?>
                                 </a>
                             </div>
                             <div class="authors">
                                    <?php if(strlen($row->authors)>15) echo substr($row->authors,0,15),'...';
                                    else {
                                        echo $row->authors;
                                    }?>
                              </div>
                          </div>
                          </div>
                     <?php }?>

                     </table>
                </div>
                <br />
             <?php }?>
	<table cellspacing="0" cellpadding="0" border="0" width="100%" class="basictable">
		<tr>
			<td colspan="6" align="center">
				<div id="paginator-custom">
<?php
      if ($pageNav !=null && $pageNav->total > $pageNav->limit ) {
		   echo $pageNav->getPagesLinks( ); //for 1.6
      }
?>
				</div>
			</td>
		</tr>
   </table>
		<?php
		if ($params->get('show_lendstatus') && $params->get('show_lendrequest') && $params->get( 'lend_save')){   

		?>

		<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo _BOOKLIBRARY_LABEL_LEND_INFORMATIONS; ?>
			  <input type="hidden"  name="bookid" id="bookid"  value="<?php echo $row->id ?>"  maxlength="80" />
        
		</div>
		<form id="adminForm" action="<?php echo sefRelToAbs("index.php");?>" name="userForm" method="post">
            <table  class="basictable" width="100%" border="0" cellspacing="0" cellpadding="0">			
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>

			<tr>
				<td>
					<?php echo _BOOKLIBRARY_LABEL_LEND_REQUEST_NAME; ?>:<br />
					<input class="inputbox" type="text" name="user_name" size="38" maxlength="80" />       
				</td>
				<td>
					<?php echo _BOOKLIBRARY_LABEL_LEND_REQUEST_EMAIL; ?>:<br />
			<input class="inputbox" type="text" name="user_email" size="38" maxlength="80" />
			</td>
			</tr>
			<tr>
			<td colspan="2">&nbsp;</td>
			</tr>
		</table>                                                        
		<table  class="basictable" width="100%" border="0" cellspacing="0" cellpadding="0">  			
			<tr>
				<td>
					<?php echo _BOOKLIBRARY_LABEL_LEND_REQUEST_MAILING; ?>:<br /> 					
					<?php
					 editorArea( 'editor1',  '' , 'user_mailing', '400', '200', '30', '5' ) ;       
					 ?> 				
				</td>
				<td>
				<br />
                                     <p>
	                	<?php echo _BOOKLIBRARY_LABEL_LEND_REQUEST_FROM; ?>:<br />
						<!--<input class="inputbox" type="text" name="lend_from" id="lend_from" size="12" maxlength="10" value="<?php echo date("Y-m-d"); ?>" />-->
	                	<!--<input type="reset" class="button" value="..." onclick="return showCalendar('lend_from', 'y-mm-dd');" />-->
						<?php /*for 1.6*/ echo JHtml::_('calendar',date("Y-m-d"), 'lend_from','lend_from','%Y-%m-%d' );?>
					</p>
					<p>
						<?php echo _BOOKLIBRARY_LABEL_LEND_REQUEST_UNTIL; ?>:<br />
						<!--<input class="inputbox" type="text" name="lend_until" id="lend_until" size="12" maxlength="10" value="<?php echo date("Y-m-d"); ?>" />
	                	<input type="reset" class="button" value="..." onclick="return showCalendar('lend_until', 'y-mm-dd');" />-->
						<?php /*for 1.6*/ echo JHtml::_('calendar',date("Y-m-d"), 'lend_until','lend_until','%Y-%m-%d' );?>
                	</p>
				</td>
			</tr>
		</table>
	<?php } ?>

		<table  class="basictable" width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td colspan="2">&nbsp;</td>
		</tr>

		<tr>
			<td width="260">
				<?php		
if ($params->get('show_lendstatus') && $params->get('show_lendrequest') && $params->get( 'lend_save')){    
				?>
                      <input type="hidden" name="option" value="com_booklibrary"/>
                      <input type="hidden" name="task" value="save_lend_request"/>
                      <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>"/>
                      <input type="button" class="button" value="<?php echo _BOOKLIBRARY_LABEL_BUTTON_LEND_REQU_SAVE; ?>" onclick="lend_request_submitbutton()" />
              		    <input type="hidden" name="bookid" value="<?php echo $rows[0]->id;?>"/>
              		    <input type="hidden" name="bid[]" value="<?php echo $rows[0]->id;?>"/>
            		</form> 
                        <?php 
				}else{ ?>
					&nbsp;
				<?php
				}
				?>
                        </td>                         
			<td align="right">
				<?php
					// 	displays back button
				if(count($rows))
					mosHTML::BackButton ( $params, $hide_js );
				?>
			</td>
		</tr>
		<tr>
			<td colspan="2">&nbsp;</td>
		</tr>
     <div style="text-align: center;"><a href="http://ordasoft.com" style="font-size: 10px;">Powered by OrdaSoft!</a></div>
		</table>
    
    
     <?php
  } ?> 

		<?php
		if ( $is_exist_sub_categories )
    {
		?>			<?php positions_bl($params->get('singlecategory07')); ?>
			<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
				<?php echo _BOOKLIBRARY_LABEL_FETCHED_SUBCATEGORIES . " : " . $params->get( 'category_name' ); ?>
			</div>
	<?php positions_bl($params->get('singlecategory08')); ?>
    		<?php
			HTML_booklibrary::listCategories($params, $categories, $catid, $tabclass , $currentcat);
		}
		?>
 
  
<?php

	}
	

	/**
	 * Displays simple search
	 * Lend Status 
	 */

	 function displaySimpleSearch($align='right')
	 {
		 global $Itemid,$mosConfig_live_site;

		 ?>
		 <form id="adminForm" name="simlesearchform" action="<?php echo sefRelToAbs("index.php?option=com_booklibrary&Itemid=".$Itemid."&task=search");?>"  method="get">
		 <div style="text-align: <?php echo $align?>">
		 <input type="text" name="searchtext" value="" />
		 <a href="javascript:document.simlesearchform.submit();" ><img src="<?php echo $mosConfig_live_site; ?>/components/com_booklibrary/images/search.gif" alt="Search" title="Search" /></a>
		 <input type="hidden" name="option" value="com_booklibrary">
		 <input type="hidden" name="task" value="search">
		 <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>">
		 <input type="hidden" name="searchtype" value="simplesearch">
		 </div>
		 </form>
		 <?php
	 }


	function displayBook( & $book, & $tabclass, & $params, & $currentcat, & $cat, & $rating,$book_lang, $id, $catid){

    if($book->published==0) JError::raiseError (404, JText::_('Resource Not Found'));
		global $doc, $hide_js,$mainframe, $Itemid, $booklibrary_configuration, $mosConfig_live_site, $mosConfig_absolute_path, $my, $option;						
                
    $doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_booklibrary/includes/booklibrary.css' );
    JPluginHelper::importPlugin('content');
		$dispatcher = JDispatcher::getInstance();

		?>
 <noscript>Javascript is required to use Book Library <a href="http://ordasoft.com/Book-Library/booklibrary-versions-feature-comparison.html">Book Library - create book library, ebook, book collection  </a>, 

<a href="http://ordasoft.com/location-map.html">Book library book sowftware for Joomla</a></noscript>
		<script language="javascript" type="text/javascript">

		function review_submitbutton() {
			var form = document.review;
			// do field validation
			var rating_checked = false;
			for (c = 0;  c < form.rating.length; c++){
				if (form.rating[c].checked){
					rating_checked = true;
				} 
			}
			if (form.title.value == "") {
				alert( "<?php echo _BOOKLIBRARY_INFOTEXT_JS_REVIEW_TITLE; ?>" );
			} else if (form.comment == "") {
				alert( "<?php echo _BOOKLIBRARY_INFOTEXT_JS_REVIEW_COMMENT;?>" );
			} else if (!rating_checked) {				
				alert( "<?php echo _BOOKLIBRARY_INFOTEXT_JS_REVIEW_RATING;?>" );
			} else {
				form.submit();
			}
		}
//*****************   begin add for show/hiden button "Add review" ********************
			function button_hidden( is_hide ) {
				var el  = document.getElementById('button_hidden_review');
				var el2 = document.getElementById('hidden_review');
				if(is_hide){
					el.style.display = 'none';
					el2.style.display = 'block';
				} else {
					el.style.display = 'block';
					el2.style.display = 'none';
				}
			}
//****************   end add for show/hiden button "Add review"   *********************
		</script>

<?php // for 1.6

    $cat_link_arr = array ();

    foreach ($cat as $category ) {
            $link = sefRelToAbs('index.php?option=' . $option . '&task=showCategory&catid=' . $category->catid . '&Itemid=' . $Itemid);
            $anchor = "<a href='$link'>{$category->name}</a>";
            $cat_link_arr[] = $anchor;
		}

// -- ?>
    
    <?php positions_bl($params->get('view01'));?>
		<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
		<?php echo $currentcat->header;  ?>
		</div>
		
		
    <?php positions_bl($params->get('view02')); ?>
		<table class="basictable" width="100%" cellpadding="4" cellspacing="0" border="0" align="center" class="contentpane<?php echo $params->get( 'pageclass_sfx' ); ?>">
		<?php if($book->title!='') {?>
		<tr>
			<td nowrap="nowrap" width="20%" align="right">       
				<strong><?php echo _BOOKLIBRARY_LABEL_TITLE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
			</td>
			<td>
				<?php echo $book->title; ?>
			</td>
		</tr>
    <tr>
			<td nowrap="nowrap" width="20%" align="right">       
				<strong><?php echo _BOOKLIBRARY_CATEGORIES_NAME; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
			</td>
			<td>
				<?php echo implode ( ", " , $cat_link_arr  ); //for J 1.6 ?>
			</td>
		</tr>
		<tr>
			<td nowrap="nowrap" width="20%" align="right">       
				<strong><?php echo _BOOKLIBRARY_LABEL_BOOKID; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
			</td>
			<td>
				<?php echo $book->bookid; ?>
			</td>
		</tr>
		<?php }
		if($book->authors!='') {?>
		<tr>
			<td nowrap="nowrap" align="right">
				<strong><?php echo _BOOKLIBRARY_LABEL_AUTHORS; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
			</td>
			<td>
				<?php echo $book->authors; ?>
			</td>
		</tr>
		<?php }
		if($book->isbn!='') {?>
		<tr>
			<td nowrap="nowrap" align="right">
				<strong><?php echo _BOOKLIBRARY_LABEL_ISBN; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
			</td>
			<td>
				<?php echo $book->isbn; ?>
			</td>
		</tr>		
		<?php }
		if($book->manufacturer!='') {?>
		<tr>
			<td nowrap="nowrap" align="right">
				<strong><?php echo _BOOKLIBRARY_LABEL_MANUFACTURER; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
			</td>
			<td>
				<?php echo $book->manufacturer; ?>
			</td>
		</tr>
		<?php }
		if($book->release_Date!='') {?>
		<tr>
			<td nowrap="nowrap" align="right">
				<strong><?php echo _BOOKLIBRARY_LABEL_PUB_DATE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
			</td>
			<td>
				<?php echo $book->release_Date; ?>
			</td>
		</tr>
		<?php }
		if($book->edition!='') {?>
		<tr>
			<td nowrap="nowrap" align="right">
				<strong><?php echo _BOOKLIBRARY_LABEL_EDITION; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
			</td>
			<td>
				<?php echo $book->edition; ?>
			</td>
		</tr>
		<?php }
    if($book->numberOfPages!='') {?>
		<tr>
			<td nowrap="nowrap" align="right">
				<strong><?php echo _BOOKLIBRARY_LABEL_NUMPAGES; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
			</td>
			<td>
				<?php echo $book->numberOfPages; ?>
			</td>
		</tr>
		<?php }
		if($book_lang!='') {?>
		<tr>
			<td nowrap="nowrap" align="right">
				<strong><?php echo _BOOKLIBRARY_LABEL_LANGUAGE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
			</td>
			<td>
				<?php 
				  echo $book_lang;
				?>
			</td>
		</tr>
		<?php } ?>
		<?php if($params->get( 'show_price' ) == '1'){ ?>
			<tr>
				<td nowrap="nowrap" align="right">
					<strong><?php echo _BOOKLIBRARY_LABEL_PRICE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
				</td>
				<td>
					<?php echo $book->price; ?>&nbsp;&nbsp;<?php echo $book->priceunit; ?>
				</td>
			</tr>
		<?php } ?>
		<tr>
			<td nowrap="nowrap" align="right">
				<strong><?php echo _BOOKLIBRARY_LABEL_RATING; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
			</td>
			<td>
				<img src="<?php echo  $mosConfig_live_site; ?>/components/com_booklibrary/images/rating-<?php echo $book->rating; ?>.gif" alt="<?php echo ($book->rating)/2; ?>" border="0" />&nbsp;
			</td>
		</tr>		
		<tr>
			<td nowrap="nowrap" align="right" valign="top">
				<strong><?php echo _BOOKLIBRARY_LABEL_PICTURE; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
			</td>
			<td>
				<?php 
					//for local images
					$imageURL = $book->imageURL;
					if($imageURL != '' && substr($imageURL,0,4) != "http")
					{
						$imageURL = $mosConfig_live_site . ''. $book->imageURL;;
					}

					if($imageURL != ''){
						echo '<img src="'.$imageURL.'" alt="cover" border="0" height="'.$booklibrary_configuration['foto']['high'].'" width="'.$booklibrary_configuration['foto']['width'].'"/>';
					} else{
						echo '<img src="'.$mosConfig_live_site.'/components/com_booklibrary/images/' . _BOOKLIBRARY_NO_PICTURE.'" alt="no-img_eng.gif" border="0" />';
					}?>


<!--************   begin add button 'buy now'   ************************-->

				<?php //show button 'buy now'
				 if ( $params->get('show_input_buy_now') )
          {
           if($book->URL !=''){
           
				?>

				  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          <a href="<?php echo sefRelToAbs($book->URL);?>" target="blank">
				  <img src="<?php echo $mosConfig_live_site;?>/components/com_booklibrary/images/amazon/buy_now.png" alt="Button Buy now" border="0" height="27" width="82" />
				  </a>
	
			<?php   }
          }
      ?>
<!--************************   end add button 'buy now'   ******************-->

			</td>
		</tr>
		<?php 
			if($params->get( 'show_ebooksrequest' ) && $book->ebookURL != null )  {
	
          $session =JFactory::getSession();
          $sid = $session->getId();
                  $session->set("ssmid",$sid);
          setcookie('ssd',$sid,mktime().time()+60*60*24, "/" );
                                         
		?>
				<tr>
				<td align="right" >
				<strong><?php echo _BOOKLIBRARY_LABEL_EBOOK; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
				</td>
						<td align ="left">	
					<a href="<?php echo sefRelToAbs($book->ebookURL); ?>" target="blank">
						<?php echo _BOOKLIBRARY_LABEL_EBOOK_DOWNLOAD;?>
					</a>
				</td>
			</tr>	
		<?php				
			}
		?>
		<?php //lend out?? 
		if ($params->get('show_lendstatus') ) {
                    $data1 = JFactory::getDBO();
                    $query = "SELECT  b.lend_from , b.lend_until  FROM #__booklibrary_lend  AS b LEFT JOIN #__booklibrary AS c ON b.fk_bookid = c.id WHERE  c.id=" . $book->id . " AND c.published='1' AND c.approved='1' AND b.lend_return IS NULL";

                    $data1->setQuery($query);
                    $rents1 = $data1->loadObjectList();
                ?>
                    <td align="center">
        <?php
                    if (count($rents1) == 0 ) {
?>
        <?php
                        
                    } else {
                        echo '<tr><td align="right"><strong>'. _BOOKLIBRARY_LABEL_LEND_FROM_UNTIL .':&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</strong></td>'. "<br />";
                        echo '<td>';
                        for ($a = 0; $a < count($rents1); $a++) {
                            $from_until = substr($rents1[$a]->lend_from, 0, 10) .
                                    "&nbsp;/&nbsp;" .
                                    substr($rents1[$a]->lend_until, 0, 10) . "<br />";
                            print_r($from_until);
                        }
                        echo '</td>';
                    } 
                if($params->get( 'lend_save')){
							
								$available = true;  
							} else {
							
								$available = false;   
							}
        ?>
            <br>
        </td>
<?php } 
    if($book->comment!='') {?>
      <tr>
        <td align="right" valign="top">
          <strong><?php echo _BOOKLIBRARY_LABEL_COMMENT; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
        </td>
        <td>
          <?php
		      JPluginHelper::importPlugin('content');
                        $dispatcher = JDispatcher::getInstance();
positions_bl($params->get('viewdescription'));
            $err_state = ini_get('display_errors');
            ini_set('display_errors','Off');
            $idesc = $book->comment; //load the desc into a variable
            $plug_row->text = $idesc; // load the var into plugin_row object
            $results = $dispatcher->trigger('onPrepareContent', array (&$plug_row, &$plug_params ), true); //run mambot onPrepareContent on plug_row object
            $idesc = $plug_row->text; //get new content from plug_row object to value
            echo $idesc; //echo new content out
  
            ini_set('display_errors',$err_state);
          ?>
        </td>
      </tr>
    <?php if( $book->owneremail!='' ) {?>
        <tr>
          <td align="right">
            <strong><?php echo _BOOKLIBRARY_LABEL_BOOKOWNER; ?>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
          </td>
          <td>
            <?php echo $book->ownername; ?>
          </td>
        </tr>
      <?php }	?>
    <tr>
    <?php } ?>
      <td>&nbsp;
      </td>
      <td>&nbsp;
      </td>
    </tr>	
    </table> 
<form id="adminForm" action="<?php echo sefRelToAbs("index.php?option=com_booklibrary&task=lend_request&Itemid=$Itemid");?>" method="post" name="book" id="book">
  <table class="basictable" >
    <tr>
      <td >
        <input type="submit" name="submit" value="<?php echo _BOOKLIBRARY_LABEL_BUTTON_LEND_REQU; ?>" class="button" onclick="if(typeof document.getElementById('book').submit=='function') document.getElementById('book').submit();	else if(typeof document.getElementById('book').submit.click=='function')document.getElementById('book').submit.click();"/>
      </td>
      <td align="right">
        <?php
        // displays back button
        mosHTML::BackButton ( $params, $hide_js );
        ?>
      </td>
    </tr>
    </table>
    <input type="hidden" name="bid[]" value="<?php echo $book->id; ?>" />
    </form>
    <?php //sow the reviews

    if( $params->get('show_reviews')) 
    {
      $reviews = $book->getReviews();	
    ?>
        <br />
        <div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
          <?php echo _BOOKLIBRARY_LABEL_REVIEWS; ?>
        </div>
        <table class="basictable" width="100%" cellpadding="4" cellspacing="0" border="0" align="center" class="front-end-reviews contentpane<?php echo $params->get( 'pageclass_sfx' ); ?>">
      <?php
      if ($reviews != null && count($reviews) > 0)
      {
        for($m = 0, $n = count($reviews); $m < $n; $m ++ )
        {
        $review = $reviews[$m];
      ?>
          <tr class="line-1">
            <td colspan="3" class="col-1">
              <strong>
                <?php echo $review->title; ?>
              </strong>
            </td>
          </tr>
          <tr class="line-2">	
            <td class="col-1">
              <?php echo $review->date; ?>
            </td>				
            <td class="col-2">
              <?php 
                $help = $review->getReviewFrom();
                echo $help['name']; 
              ?>
            </td>					
            <td width="10" class="col-3">
              <img src="<?php echo  $mosConfig_live_site; ?>/components/com_booklibrary/images/rating-<?php echo $review->rating; ?>.gif" alt="<?php echo ($review->rating)/2; ?>" border="0" align="right"/>&nbsp;
            </td>
          </tr>
          <tr class="line-3">
            <td colspan="3" class="col-1">
              <?php echo $review->comment; ?>
            </td>
          </tr>
          <tr class="line-4">
            <td colspan="3" class="col-1">
              <hr />
            </td>
          </tr>
      <?php
        }
      }
        
      ?>
        <tr class="line-5">
          <td colspan="2">&nbsp;
            
          </td>
        </tr>
      </table>     
      <?php positions_bl($params->get('view03')); ?>
      <?php 
      if($params->get('show_inputreviews')){
      ?>
  <!--***********   begin add for show/hiden button "Add review"   ***********************-->
  <div id ="button_hidden_review" style="<?php if(isset($_REQUEST['err_msg'] ) ) {echo 'display:none';}?>">
    <input type="submit" name="submit" value="<?php echo _BOOKLIBRARY_LABEL_BUTTON_ADD_REVIEW; ?>" class="button" onclick="javascript:button_hidden(true)"/>
  </div>
<!--***********   end add for show/hiden button "Add review"   ************************-->

      <div id="hidden_review" style="<?php if(isset($_REQUEST['err_msg'] ) ) {echo 'display:block';} else {echo 'display:none';} ?>">
        <div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
        <?php echo _BOOKLIBRARY_LABEL_ADDREVIEW; ?>
        </div>
        
        <form id="adminForm" action="<?php echo sefRelToAbs("index.php?option=com_booklibrary&task=review&Itemid=". $Itemid); ?>" method="post" name="review">
        <table class="basictable" width="100%" cellpadding="4" cellspacing="0" border="0" align="center" class="contentpane<?php echo $params->get( 'pageclass_sfx' ); ?>">
          <tr>
            <td colspan="2">
            <?php echo _BOOKLIBRARY_LABEL_REVIEW_TITLE; ?>
            </td>				
          </tr>
          <tr>
            <td colspan="2">					
              <input class="inputbox" type="text" name="title" size="80" value="<?php if ( isset($_REQUEST["title"]) ) {echo $_REQUEST["title"];}?>" />
            </td>
          </tr>
          <tr>
            <td>
              <?php echo _BOOKLIBRARY_LABEL_REVIEW_COMMENT; ?>
            </td>
            <td>
              <?php echo _BOOKLIBRARY_LABEL_REVIEW_RATING; ?>
            </td>
          </tr>
          <tr>
            <td>
                <?php
                  $comm_val = "";
                  if ( isset($_REQUEST["comment"]) )
                    {
                        $comm_val = $_REQUEST["comment"];
                    }
                  editorArea( 'editor1',  $comm_val, 'comment', '410', '200', '60', '10' ) ;     			
                ?>
            </td>
            <td width="102">  
              <?php
                $k = 0;
                while($k < 11){
                ?>
                  <input type="radio" name="rating" value="<?php echo $k;?>" <?php if ( isset($_REQUEST["rating"]) && $_REQUEST["rating"] == $k ) {echo "CHECKED";}?> alt="Rating" />
                  <img src="<?php echo  $mosConfig_live_site; ?>/components/com_booklibrary/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>
					<tr>
						<td>
							<!-- save review button-->
							<input class="button" type="button" value="<?php echo _BOOKLIBRARY_LABEL_BUTTON_SAVE; ?>" onclick="review_submitbutton()"/>						
						</td>
						<td>
							<!-- hifde review button-->
							<input class="button" type="button" value="<?php echo _BOOKLIBRARY_LABEL_BUTTON_REVIEW_HIDE;?>" onclick="javascript:button_hidden(false);"/>						
						</td>
						<td align="right">							
							<?php
							// displays back button
//							mosHTML::BackButton ( $params, $hide_js );
							?>	
						</td>
					</tr>
					<tr>
						<td colspan="2">&nbsp;
							
						</td>
					</tr>
				</table>
		<input type="hidden" name="fk_bookid" value="<?php echo $book->id; ?>" />
		<input type="hidden" name="catid" value="<?php echo $catid; ?>" />
		</form>


		</div> <!-- end <div id="hidden_review"> -->
<br />
<br />
			<?php
			}
		} 
		positions_bl($params->get('view04')); 
		?>
  <div style="text-align: center;"><a href="http://ordasoft.com" style="font-size: 10px;">Powered by OrdaSoft!</a></div>
  
		<?php
	}
	
	/**
	* Display links to categories
	*/

	function showCategories( &$params, &$categories, &$catid, &$tabclass , &$currentcat)
         { 
		 global $doc; // for 1.6
		global $hide_js, $Itemid, $acl, $mosConfig_live_site, $my,$mainframe;
$doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_booklibrary/includes/booklibrary.css' );
$doc->addStyleSheet( $mosConfig_live_site.'/components/com_booklibrary/includes/custom.css' ); // for 1.6
		?><?php positions_bl($params->get('allcategories01'));?>
		<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo $currentcat->header; ?>
		</div><?php positions_bl($params->get('allcategories02'));?>
		<table class="basictable" border="0" cellpadding="4" cellspacing="0" width="100%">
			<tr>
				<td>
					<?php echo $currentcat->descrip; ?>
				</td>     
	        	        <td width="120" align="center">
	          		 <img src="<?php echo  $mosConfig_live_site; ?>/components/com_booklibrary/images/book.png" align="right" alt="Books"/>
	        	        </td>
	      	       </tr>
	        </table>
			<?php positions_bl($params->get('allcategories03'));?>
			
		<?php	
		if($params->get('show_search')){
		?>
			<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<table class="basictable" width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                                  <td colspan="2">&nbsp;
                                  </td>
                          </tr>
                          <tr>
                              <td width="60%">&nbsp;
                              </td>
                             <td width="40%" nowrap align="right">
                                  <?php
										echo HTML_booklibrary::displaySimpleSearch();
										echo "<div style=\"font-size: smaller;line-height: 0.9em;text-align:right;\">	<a href=\"index.php?option=com_booklibrary&task=show_search&catid=0&Itemid=$Itemid\"> Advanced search</a></div>";
                              ?>
											 <?php
                                      $link = 'index.php?option=com_booklibrary&task=show_search&catid='.
                                         $catid. '&Itemid='. $Itemid;;
                                  ?>
                               </td>
                          </tr>
			</table>
		</div>
		<?php	
		}
		?>

		<form id="adminForm" action="<?php echo sefRelToAbs("index.php?option=com_booklibrary&Itemid=".$Itemid);?>" method="post" name="adminForm">
		<?php		
			HTML_booklibrary::listCategories($params, $categories, $catid, $tabclass , $currentcat);
			positions_bl($params->get('allcategories07'));
		?>
			<table class="basictable" width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="50%">&nbsp;
						
					</td>
					<td width="50%">
						<?php mosHTML::BackButton ( $params, $hide_js ); ?>
					</td>
				</tr>
			</table>
 		</form>
         <?php
          		positions_bl($params->get('allcategories08')); ?>
  <div style="text-align: center;"><a href="http://ordasoft.com" style="font-size: 10px;">Powered by OrdaSoft!</a></div>    
		<?php
}


	
	function listCategories( &$params, $cat_all, $catid, $tabclass , $currentcat) {
		global $Itemid, $mosConfig_live_site;
		
	?>
		<table class="basictable" width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td colspan="2" height="20" width="90%" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo _BOOKLIBRARY_LABEL_CATEGORY;?>
			</td>
			<td height="20" width="10%" class="sectiontableheader<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo _BOOKLIBRARY_LABEL_BOOKS;?> 
			</td>
		</tr>
		<tr>
			<td colspan="4">
			<?php
			
			HTML_booklibrary::showInsertSubCategory($catid, $cat_all, $params, $tabclass, $Itemid, 0);
			?>
			</td>
      
		</tr>
		<tr>
			<td colspan="3">&nbsp;
				
			</td>
		</tr>
		</table>
  
<?php	
	}
/*

* function for show subcategory
*/
function showInsertSubCategory($id, $cat_all, $params, $tabclass, $Itemid, $deep) {
	global $g_item_count,$booklibrary_configuration,$mosConfig_live_site ;
	
	$deep++;
	for ($i = 0; $i < count($cat_all); $i++) {
	    if ( ($id == $cat_all[$i]->parent_id) && ($cat_all[$i]->display == 1) ) {
		$g_item_count++;

		$link = 'index.php?option=com_booklibrary&task=showCategory&catid='. $cat_all[$i]->id .'&Itemid='. $Itemid;
		?>
		<table class="basictable" width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr class="<?php echo $tabclass[($g_item_count%2)]; ?>">
				<td width="1%">
					<?php
					if ($deep != 1 ) {
					   $jj = $deep;
					   while ($jj--){echo "&nbsp;&nbsp;&nbsp;&nbsp;";}
					   echo "&nbsp;|_";
					}
					?>
				</td>
				<td width="9%">
				<?php 
			
					if ( ($params->get( 'show_cat_pic')) && ($cat_all[$i]->image != "")) {?>
					   <img src="./images/stories/<?php echo $cat_all[$i]->image;?>" alt="picture for subcategory" height="48" width="48" />&nbsp;
				<?php
					} else  {?>
						<img src="<?php echo  $mosConfig_live_site; ?>/components/com_booklibrary/images/folder.png" alt="picture for subcategory" height="48" width="48" />&nbsp;
					  <?php }?>
				</td>
				<td width="80%">	
					<a href="<?php echo sefRelToAbs( $link ); ?>" class="category<?php echo $params->get( 'pageclass_sfx' ); ?>">
					<?php echo $cat_all[$i]->title;?>
					</a>					
				</td>
				<td  align="left" width="10%">				
					<?php if ($cat_all[$i]->books == '') echo "0";else echo $cat_all[$i]->books;?>
				</td>
			</tr>
		</table>
		<?php

if($GLOBALS['subcategory_show']) {
	
	HTML_booklibrary::showInsertSubCategory($cat_all[$i]->id, $cat_all, $params, $tabclass, $Itemid, $deep); }

	    }//end if ($id == $cat_all[$i]->parent_id)
	}//end for(...)	
}//end function showInsertSubCategory($id, $cat_all)


function showSearchBooks( $params, $currentcat, $clist , $option)
{
		global $doc, $hide_js, $Itemid, $mainframe, $mosConfig_live_site;
		$doc->addStyleSheet( $mosConfig_live_site.'/administrator/components/com_booklibrary/includes/booklibrary.css' ); // for 1.6
				 positions_bl($params->get('showsearch01'));

// for J 1.6
$script_content = '';	

$script_content .= 		"	function trim(string){	return string.replace(/(^\s+)|(\s+$)/g, '');	} \n";
$script_content .= 		"	function searchsubmit() \n";
$script_content .= 		"	{ \n";
$script_content .= 		"		var form = document.com_booklibsearchForm; \n";
$script_content .= 		"		var flag = true; \n";
$script_content .= "// 				var t_lprice = trim(document.getElementById('lprice').value); \n";
$script_content .= "// 				var t_uprice = trim(document.getElementById('uprice').value); \n";
$script_content .= "// 				var t_ldate = trim(document.getElementById('ldate').value); \n";
$script_content .= "// 				var t_udate = trim(document.getElementById('udate').value); \n";
$script_content .= "// 				if(!((t_lprice!='' && t_uprice!='') || (t_uprice == t_lprice))) \n";
$script_content .= "// 				{ \n";
$script_content .= "// 					alert('If you want search by price - interval must be set') \n";
$script_content .= "// 					flag=false; \n";
$script_content .= "// 				} \n";
$script_content .= "// 				if(!((t_ldate!='' && t_udate!='') || (t_ldate == t_udate))) \n";
$script_content .= "// 				{ \n";
$script_content .= "// 					alert('If you want search by release date - interval must be set') \n";
$script_content .= "// 					flag=false; \n";
$script_content .= "// 				} \n";

$script_content .= "				if(flag) \n";
$script_content .= "					form.submit(); \n";
$script_content .= "			} \n";



$doc->addScriptDeclaration( $script_content );
// --
	?>
		<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
			<?php echo $currentcat->header; ?>
		</div><?php positions_bl($params->get('showsearch02'));?>
		<table class="basictable" border="0" cellpadding="4" cellspacing="0" width="100%">
			<tr>				
				<?php
				if($currentcat->img != null && $currentcat->align == 'left')                    {
				 ?>
				<td>
		                 <img src="<?php echo $currentcat->img; ?>" align="<?php echo $currentcat->align; ?>" />
		        	</td>
		         <?php
				}
				?>
				<td width="100%">
				  <?php echo $currentcat->descrip; ?>
				</td>
		         <?php
					if($currentcat->img != null && $currentcat->align == 'right')
                                        {
				?>
				 <td>
		        	  <img src="<?php echo $currentcat->img; ?>" align="<?php echo $currentcat->align; ?>"  alt = "?"/>
		        	 </td>
		         <?php
				}
				?>
		        </tr>
	       </table>
    <?php positions_bl($params->get('showsearch03'));?>

<form id="adminForm" action="<?php echo sefRelToAbs("index.php?option=com_booklibrary&Itemid=".$Itemid."&task=search");?>" method="get" name="com_booklibsearchForm">
 <table class="basictable" border="0" cellpadding="4" cellspacing="0" width="100%">
   <tr>
              <td align="center" colspan="2" >
                    <?php echo _BOOKLIBRARY_LABEL_SEARCH_KEYWORD; ?>&nbsp;
                    <input class="inputbox" type="text" name="searchtext" size="20" maxlength="20"/>
              </td>
        </tr>
            <tr>
              <td colspan="2" align="center">
              <input type="hidden" name="title" value="on" />
              <input type="hidden" name="bookid" value="on"  />
              <input type="hidden" name="isbn" value="on"  />
              <input type="hidden" name="author" value="on"  />
              <input type="hidden" name="description" value="on"  />
              <input type="hidden" name="publisher" value="on" />
			  
			</td>
          </tr>
          <tr>      
            <td align="center" colspan="2" >
                <?php echo _BOOKLIBRARY_LABEL_CATEGORY; ?>&nbsp;
                <?php echo $clist; ?>
            </td>
          </tr>
          <tr>
            <td align="center" colspan="2">
                <input type="button" onclick="searchsubmit();" 
                  value="<?php echo _BOOKLIBRARY_LABEL_SEARCH_BUTTON;?>" class="button" />
                <input type="hidden" name="option" value="<?php echo $option; ?>">
                <input type="hidden" name="task" value="search">
                <input type="hidden" name="Itemid" value="<?php echo $Itemid ?>">
            </td>       
          </tr>
        </table>      
			<br />       
			<?php
				mosHTML::BackButton ( $params, $hide_js );
			?>
		</form>
				<?php positions_bl($params->get('showsearch04'));?>
  <div style="text-align: center;"><a href="http://ordasoft.com" style="font-size: 10px;">Powered by OrdaSoft!</a></div>
  
<?php
}



	function showLendRequestThanks( $params, $currentcat){
		global $hide_js, $Itemid;
	?>
	<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
	   <?php echo $currentcat->header; ?>
	</div>
	<table class="basictable" border="0" cellpadding="4" cellspacing="0" width="100%">
			<tr>				
			  <?php
			    if($currentcat->img != null )
				{
			  ?>
			     <td>

		        	<img src="<?php echo $currentcat->img; ?>" alt="?" />
		             </td>
		        <?php
				}
				?>
			     <td width="100%">
			       <?php echo $currentcat->descrip; ?>
			     </td>

		     </tr>
	    </table>
		<form id="adminForm" action="<?php echo sefRelToAbs("index.php?option=com_booklibrary&Itemid=".$Itemid);?>" method="post" name="userForm">
			<table class="basictable" border="0" cellpadding="4" cellspacing="0" width="100%">
		      	<tr>
			   <td colspan="2" align="right">&nbsp;			
			   </td>
		      	</tr>
		      	<tr>
			  <td>
			  </td>
			  <td>
			   <input type="submit" name="submit" value="<?php echo _BOOKLIBRARY_LABEL_OK; ?>" class="button" />
			  </td>
		      	</tr>

		    </table>			
		</form>
  <div style="text-align: center;"><a href="http://ordasoft.com" style="font-size: 10px;">Powered by OrdaSoft!</a></div>
  
<?php
	}
  

}

