<?php
require '../jaivejaive/jaive1NoRefresh.php';
require '../jaivejaive/ScholasticaColors.php';
$CollectionName="";
$CategoryName="";
$CategoryCode="";
$DeptName="";
$DeptCode="";
$BookName="";
$BookCode="";
$AuthorName="";
$PublisherName="";
$ISBNName="";
$ColOption="";
$dirOption="Books";
$Categorytype="";
$Departmenttype="";
$RegisterType="";
$CollectionName="";
$DeptName="";
$BookName="";
$AuthorName="";
$TitleName="";
$ISBNName="";
$gOption="";
$CategoryValue="";
$DeptValue="";
$BookValue="";
$CatName="";
$myCurrentSRC="";
$BookSpec="Specifications:";
$BookSummary="Summary:";

$eBookName="Title:";
$BookSummary="eDescription";
$erprice=0;
$elPrice=0;
$ebPrice=0;
$epPrice=0;
$AuthorName="";
$PublisherName="";
$eBookISBN="";

$TableBG1="#f0f0ff";
$TableTXT1="#ffffff";
$ButtonBG2="#f0f0fa";
$ButtonTXT2="#000000";

$ffgot=1000;
for($ffg=0; $ffg< $ffgot; $ffg++)
{
$imagepath="eLibraryCategory".$ffg.".jpg";
	if(file_exists($imagepath))
	unlink($imagepath);
}

$ffgot=1000;
for($ffg=0; $ffg< $ffgot; $ffg++)
{
$imagepath="eLibraryDept".$ffg.".jpg";
	if(file_exists($imagepath))
	unlink($imagepath);
}
			
			$arRecentHistory[0]="Books.Arts.History.YoungObiansiandAbiribaWarDanceSongs.jpg";
			$arRecentHistory[1]="Books.Arts.History.TheAbiribaCivilizationearlydaystothe20thCenturyAD.jpg";
			$arRecentHistory[2]="Magazines.Events.ModernAfriqueMagazineEventsandStylesChapter2.jpg";
			$arRecentHistory[3]="Magazines.News.AtangAbiriba.Vol.1No.3ItuEye2010.jpg";
			$arRecentHistory[4]="";
			$ColCategory=array();
			$unColCategory=array();
 			$resultCategory[1]="";
 			$resultCategoryName[1]="";
 			$resultDept[1]="";
 			$resultDeptName[1]="";
 			$resultBook[1]="";
 			$resultBookName[1]="";
 			$arrayresultAuthor[1]="";
 			$arrayresultPublisher[1]="";
 			$arrayresultISBN[1]="";
			$resultDeptName[1]="";
			$resultDeptCount=0;
			$resultBookCount=0;
			$resultAuthorCount=0;
			$resultPublisherCount=0;
			$resultISBNCount=0;

			$resultAuthor="";
 			$resultPublisher="";
 			$resultISBN="";

if (isset($_SESSION['sCollectionName']))
$CollectionName=$_SESSION['sCollectionName'];

if (isset($_SESSION['sCategoryName']))
$CategoryName=$_SESSION['sCategoryName'];

if (isset($_SESSION['sDeptName']))
$DeptName=$_SESSION['sDeptName'];

if (isset($_SESSION['sBookName']))
$BookName=$_SESSION['sBookName'];

if (isset($_SESSION['sAuthorName']))
$AuthorName=$_SESSION['sAuthorName'];

if (isset($_SESSION['sPublisherName']))
$PublisherName=$_SESSION['sPublisherName'];

if (isset($_SESSION['sISBNName']))
$ISBNName=$_SESSION['sISBNName'];

if (isset($_SESSION['sColOption']))
$ColOption=$_SESSION['sColOption'];

if (isset($_SESSION['sdirOption']))
$dirOption=$_SESSION['sdirOption'];


if (isset($_REQUEST['Collection']))
{
//echo $_REQUEST['Collection'];
$theOption= $_REQUEST['Collection'];
$dirOptionpos= strpos($theOption, ",",0);
if($dirOptionpos>0){
$dirOption=substr($theOption, 0, $dirOptionpos);
$ColOptionpos= strpos($theOption, ".", $dirOptionpos+4);
$ColOption=substr($theOption,$dirOptionpos+1,$ColOptionpos-$dirOptionpos-1);
}else{
$dirOption=$theOption;
$ColOption="";
}
$ColOption=trim($ColOption);
$_SESSION['sColOption']=$ColOption;
$_SESSION['sdirOption']=$dirOption;
}


if (isset($_POST['GoBar']))
{
$gOption=$_POST['GoBar'];
$_SESSION['sgOption']=$gOption;
}


if (isset($_POST['CollectionName']))
{
$CollectionName=$_POST['CollectionName'];
$_SESSION['sCollectionName']=$CollectionName;
}



if(isset($_POST['CategoryName']))
{
$CategoryName= $_POST['CategoryName'];
$_SESSION['sCategoryName']=$CategoryName;
}

if(isset($_POST['CategoryCode']))
{
$CategoryCode= $_POST['CategoryCode'];
$_SESSION['sCategoryCode']=$CategoryCode;

	mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
	$result5=mysqli_query($connect,"SELECT*  FROM elibrary WHERE eCategoryCode='$CategoryCode'");
	while($row5 = mysqli_fetch_array($result5))
	{
 	$CategoryName=$row5["eCategoryName"];
	}

}


//echo "CategoryName:".$CategoryName;


if (isset($_POST['DeptName']))
{
$DeptName=$_POST['DeptName'];
$_SESSION['s']=$DeptName;
}


if (isset($_POST['DeptCode']))
{
$DeptCode=$_POST['DeptCode'];
$_SESSION['s']=$DeptCode;
	mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
	$result5=mysqli_query($connect,"SELECT*  FROM elibrary WHERE eDeptCode='$DeptCode'");
	while($row5 = mysqli_fetch_array($result5))
	{
 	$DeptName=$row5["eDeptName"];
	}


}

if (isset($_POST['BookName']))
{
$BookName=$_POST['BookName'];
$_SESSION['sBookName']=$BookName;
}

if (isset($_POST['BookCode']))
{
$BookCode=$_POST['BookCode'];
$_SESSION['sBookCode']=$BookCode;
	mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
	$result5=mysqli_query($connect,"SELECT*  FROM elibrary WHERE eBookCode='$BookCode'");
	while($row5 = mysqli_fetch_array($result5))
	{
 	$BookName=$row5["eBookName"];
	}

}


if (isset($_POST['AuthorName']))
{
$AuthorName=$_POST['AuthorName'];
$_SESSION['s']=$AuthorName;
}


if (isset($_POST['PublisherName']))
{
$PublisherName=$_POST['PublisherName'];
$_SESSION['sPublisherName']=$PublisherName;
}


if (isset($_POST['ISBNName']))
{
$ISBNName=$_POST['ISBNName'];
$_SESSION['sISBNName']=$ISBNName;
}

if (isset($_POST['Box1']))
{
$uname=$_POST['Box1'];
$_SESSION['sBox1']=$uname;
mysqli_select_db($connect,"$myjaiveDBname") or die ('did not find db'.mysql_error());
$qry = "UPDATE buzzprofile SET ActivePageP1='$uname' WHERE ProfileCode='$uname' ";
mysqli_query($connect, $qry) or die ('could not query: '.mysql_error());
//mysqli_close($connect);
}
else
{
$uname=$ap1;
}
if (isset($_POST['Box2']))
{
$nname=$_POST['Box2'];
$_SESSION['sBox2']=$nname;
mysqli_select_db($connect,"$myjaiveDBname") or die ('did not find db'.mysql_error());
$qry = "UPDATE buzzprofile SET ActivePageP2='$nname' WHERE ProfileCode='$uname' ";
mysqli_query($connect, $qry) or die ('could not query: '.mysql_error());
//mysqli_close($connect);
}
else
{
$nname=$ap2;
}

mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
$arHistory=mysqli_query($connect,"SELECT*  FROM erecent");
$recentcounter=4;
while($row5 = mysqli_fetch_array($arHistory))
{
$arRecentHistory[$recentcounter]=$row5["RecentName"];
$recentcounter++;
}
$aruniqueHistory=array_unique($arRecentHistory);
$arupsidedown=array_reverse($aruniqueHistory);
$myRecentHistory1=$arupsidedown[0];
$myRecentHistory2=$arupsidedown[1];
$myRecentHistory3=$arupsidedown[2];
$myRecentHistory4=$arupsidedown[3];

//print_r($arRecentHistory);
//print_r($myRecentHistory2=$arupsidedown[0]);
//print_r($myRecentHistory2=$arupsidedown[1]);
//print_r($myRecentHistory2=$arupsidedown[2]);
//print_r($myRecentHistory2=$arupsidedown[3]);

$boxCs = "";
$boxA = "";
$boxSt = "";
$boxSc = "";
$boxCs = "";
$boxTm = "";


mysqli_select_db($connect,"$myjaiveDBname") or die ('did not find db'.mysql_error());
$result1=mysqli_query($connect,"SELECT*  FROM buzzprofile WHERE ProfileCode='$uname'");
while($row1 = mysqli_fetch_array($result1))
{
$boxA = $row1["ProfileNumber"];
$boxSt = $row1["NickName"];
$boxSc = $row1["School"];
$boxCs = $row1["Class"];
$boxTm = $row1["Term"];
$RegisterType= $row1["RegisterType"];
}
$_SESSION['sBoxA']=$boxA;
$_SESSION['sBoxSc']=$boxSc;
$_SESSION['sBoxSt']=$boxSt;
$_SESSION['sBoxCs']=$boxCs;
$_SESSION['sBoxTm']=$boxTm;

if ($RegisterType=="EntranceRegistration")
{
$fpath="$forms/frmAdmission/index.php";
$action1="$ffname$fpath";
header("Location: $action1", true. 303);
exit;
}

if (isset($_SESSION['sBox1']))
$uname=$_SESSION['sBox1'];
if (isset($_SESSION['sBox2']))
$nname=$_SESSION['sBox2'];
$_SESSION['sBox1']=$uname;
$_SESSION['sBox2']=$nname;


if ($gOption=="Close")
{
$fpath="$forms/index/index.php";
$action1="$ffname$fpath";
header("Location: $action1", true. 303);
exit;
}


if ($gOption=="Add New")
{
$fpath="$forms/frmeLibrary/frmeLibraryUpload.php";
$action1="$ffname$fpath";
header("Location: $action1", true. 303);
exit;
}

//echo "<center>\n";

//====================================== Begin Menu Bar ==========================================		


$fpath="$forms/frmeLibrary/frmDisplayeLibrary.php";
$action1="$ffname$fpath";

echo "<Form Name=\"frmeLibrary1\" method=\"post\" action=\"$action1\"  align=\"center\"  style=\"background-color: #ffffff; text-align:center; font-size: 16.0pt; font-family: 'Cooper Black',serif; color: #ffffff; font-weight: Bold;  border: 1px solid; padding: 5px 4px\">\n";

echo "<div align=\"center\">";

//echo "<table text=\"#ffffff\" border=\"0\" align=\"center\" cellpadding=\"6\" width=\"1015\"  id=\"table2\"  style=\"border-collapse: collapse; background-color:#000091\" > ";
//echo "<table  id=\"table2\"  style=\" background-color:#000091\" > ";
echo "<table text=\"#ffffff\" border=\"0\" align=\"center\" cellpadding=\"6\"   id=\"table2\"  style=\"border-collapse: collapse; color:$TableTXT1; background-color:$TableBG1\" > ";

	echo "<tr>";
//====================================== Reference ==========================================		

		echo "<td  colspan=\"2\"    width=\"10%\" > ";
		$action2="http://www.loc.gov";	
		echo "<a href=\"$action2\"><input type=\"button\"  value=\"Reference\"  name=\"B13\"  style=\"width: 180; height: 20; color:$ButtonTXT2; background-color:$ButtonBG2\" ></a><br>\n";		
		echo "<input type=\"text\"  value=\"Search\"  name=\"SearchBook\"  style=\"width: 158; background-color:#FFffff\" >";
		echo "<input type=\"submit\"  value=\"-> GoSearch\"  name=\"GoBar\"  style=\"width: 20; color:$ButtonTXT2; background-color:$ButtonBG2; height: 20\">";
		echo "</td>";
//==================== Collections ====================
		echo "<td width=\"12%\" >";
	 	echo "<button name=\"B6\"  style=\"width: 100; color:#ffffff; color:$ButtonTXT2; background-color:$ButtonBG2\" > Collections</button>";
		echo "<br>";

		echo "<select size=\"1\"  name=\"CollectionName\"  style=\"width: 80;  height: 20\">";
		echo "<OPTION selected VALUE=\"$CollectionName\">$CollectionName</option>\n";		
		echo "<OPTION VALUE=\"Books\">Books</option>\n";		
		echo "<OPTION VALUE=\"Journals\">Journals</option>\n";		
		echo "<OPTION VALUE=\"Magazines\">Magazines</option>\n";		
		echo "<OPTION VALUE=\"Audio\">Audio</option>\n";		
		echo "<OPTION VALUE=\"Video\">Video</option>\n";		
		echo "<OPTION VALUE=\"Photos\">Photos</option>\n";		
		echo "<OPTION VALUE=\"Slides\">Slides</option>\n";		
		echo "</select>";

		echo "<INPUT TYPE =\"SUBMIT\"    style=\"width: 20; color:$ButtonTXT2; background-color:$ButtonBG2; height: 20\"   VALUE = \"-> GoCollection\" name=\"GoBar\" >\n";

		mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
		$result5=mysqli_query($connect,"SELECT*  FROM elibrary WHERE eCollectionName='$CollectionName'");
		$resultCategoryCount=mysqli_num_rows($result5);
		$BarCount=0;
		while($row5 = mysqli_fetch_array($result5))
		{
		$BarCount=$BarCount+1;
 			$resultCategory[$BarCount]=$row5["eCategoryCode"];
 			$resultCategoryName[$BarCount]=$row5["eCategoryName"];
 			$resultDept[$BarCount]=$row5["eDeptCode"];
 			$resultDeptName[$BarCount]=$row5["eDeptName"];
 			$resultBook[$BarCount]=$row5["eBookCode"];
			$resultBookName[$BarCount]=$row5["eBookName"];
 			$arrayresultAuthor[$BarCount]=$row5["eAuthorName"];
 			$arrayresultPublisher[$BarCount]=$row5["ePublisherName"];
 			$arrayresultISBN[$BarCount]=$row5["eBookISBN"];


		//$resultCategoryCount=$BarCount-1;
		$resultCategoryCount=$BarCount;
			$resultDeptCount=$BarCount;
			$resultBookCount=$BarCount;
			$resultAuthorCount=$BarCount;
			$resultPublisherCount=$BarCount;
			$resultISBNCount=$BarCount;

		}

		echo "</td>";
//=============================== category =================================
		echo "<td width=\"10%\" >";

		if($gOption=="-> GoCategory")
		{

		mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
		$result5=mysqli_query($connect,"SELECT* FROM elibrary WHERE eCollectionName='$CollectionName' AND eCategoryName='$CategoryName'");

			$BarCount=0;
			$resultCategoryValueCount=0;
			$resultDeptCount=0;
			$CategoryValue=array();
			//$row5 = mysqli_fetch_array($result5);
			while($row5 = mysqli_fetch_array($result5))
			{
			$BarCount=$BarCount+1;
 			//$outputValue=$row5["eCategoryName"];
 			$CategoryValue[$BarCount]=$row5["eCategoryCode"];
 			$CategoryValueName[$BarCount]=$row5["eCategoryName"];
 			$resultDept[$BarCount]=$row5["eDeptCode"];
 			$resultDeptName[$BarCount]=$row5["eDeptName"];
 			$resultBook[$BarCount]=$row5["eBookCode"];
 			$resultBookName[$BarCount]=$row5["eBookName"];
 			$arrayresultAuthor[$BarCount]=$row5["eAuthorName"];
 			$arrayresultPublisher[$BarCount]=$row5["ePublisherName"];
 			$arrayresultISBN[$BarCount]=$row5["eBookISBN"];
			//$resultDeptCount=$BarCount-1;
			//echo "<input type=\"text\"  value=\"$CategoryValue[$BarCount]\"  name=\"Booker\"  style=\"width: 345; background-color:#FFffff\" >\n";
			$resultCategoryValueCount=$BarCount;
			$resultDeptCount=$BarCount;
			$resultBookCount=$BarCount;
			$resultAuthorCount=$BarCount;
			$resultPublisherCount=$BarCount;
			$resultISBNCount=$BarCount;

			}

		}	

		echo "<button name=\"B7\"  style=\"width: 105; color:#ffffff; color:$ButtonTXT2; background-color:$ButtonBG2\" > Category</button>";
		echo "<br>";
		echo "<select size=\"1\" name=\"CategoryCode\" style=\"width: 80;  height: 20\">";
		echo "<option selected value=$CategoryCode>$CategoryName</option>\n";
		if($gOption=="-> GoCategory")
		{
			$BarCount=0;
			for($BarCount=1; $BarCount<=$resultCategoryValueCount; $BarCount++){
			echo "<OPTION VALUE=$CategoryValue[$BarCount]>$CategoryValueName[$BarCount]</option>\n";
			}
		}else{
			$BarCount=0;
			for($BarCount=1; $BarCount<=$resultCategoryCount; $BarCount++){
			echo "<OPTION VALUE=$resultCategory[$BarCount]>$resultCategoryName[$BarCount]</option>\n";
			}
		}
		echo "</select>\n";
		echo "<INPUT TYPE =\"SUBMIT\"    style=\"width: 20; color:$ButtonTXT2; background-color:$ButtonBG2;  height: 20\"   VALUE = \"-> GoCategory\" name=\"GoBar\" >\n";


		echo "</td>";

//======================================= Department ========================
	
		echo "<td width=\"10%\" >";

		if($gOption=="-> GoDepartment")
		{
		mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
		$result5=mysqli_query($connect,"SELECT*  FROM elibrary WHERE eCollectionName='$CollectionName' AND eCategoryName='$CategoryName' AND eDeptName='$DeptName'");
		$BarCount=0;
		$resultDeptValueCount=0;
			$DeptValue=array();
			while($row5 = mysqli_fetch_array($result5))
			{
			$BarCount=$BarCount+1;
 			$DeptName=$row5["eDeptName"];
 			$outputValue1=$row5["eDeptCode"];
 			$DeptValue[$BarCount]=$row5["eDeptCode"];
 			$DeptValueName[$BarCount]=$row5["eDeptName"];
 			$resultBook[$BarCount]=$row5["eBookCode"];
 			$resultBookName[$BarCount]=$row5["eBookName"];
 			$arrayresultAuthor[$BarCount]=$row5["eAuthorName"];
 			$arrayresultPublisher[$BarCount]=$row5["ePublisherName"];
 			$arrayresultISBN[$BarCount]=$row5["eBookISBN"];


			//$resultBookCount=$BarCount-1;
			$resultDeptValueCount=$BarCount;
			$resultBookCount=$BarCount;
			$resultAuthorCount=$BarCount;
			$resultPublisherCount=$BarCount;
			$resultISBNCount=$BarCount;
			}

		}	

		echo "<button name=\"B8\"  style=\"width: 105; color:#ffffff; color:$ButtonTXT2; background-color:$ButtonBG2\" > Department</button>";
		echo "<br>";
		echo "<select size=\"1\" name=\"DeptCode\" style=\"width: 80;  height: 20\">";
		echo "<option selected value=$DeptCode>$DeptName</option>\n";
		if($gOption=="-> GoDepartment")
		{
			$BarCount=0;
			for($BarCount=1; $BarCount<=$resultDeptValueCount; $BarCount++){
			echo "<OPTION VALUE=$DeptValue[$BarCount]>$DeptValueName[$BarCount]</option>\n";
			}
		}else{
			$BarCount=0;
			//for($BarCount=0; $BarCount<=$resultDeptCount; $BarCount++){
			for($BarCount=1; $BarCount<=$resultDeptCount; $BarCount++){
			echo "<OPTION VALUE=$resultDept[$BarCount]>$resultDeptName[$BarCount]</option>\n";
			}
		}

		echo "</select>\n";
		echo "<INPUT TYPE =\"SUBMIT\"    style=\"width: 20; color:$ButtonTXT2; background-color:$ButtonBG2;  height: 20\"   VALUE = \"-> GoDepartment\" name=\"GoBar\" >\n";
		echo "</td>";
//===================================== Title =====================================
		echo "<td width=\"14%\" >";

		if($gOption=="-> GoTitle")
		{	
			$dotting=".";
			$PagenumVal=1;
			mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
			$result5=mysqli_query($connect,"SELECT*  FROM elibrary WHERE eCollectionName='$CollectionName' AND eCategoryName='$CategoryName' AND eDeptName='$DeptName' AND eBookName='$BookName' AND ePageNumber='$PagenumVal'");
			$mycount=mysqli_num_rows($result5);
			$BarCount=0;
			$resultBookValueCount=0;
			while($row5 = mysqli_fetch_array($result5))
			{
 			$BarCount=$BarCount+1;
			$outputValue1=$row5["eBookCode"];
  			$BookName=$row5["eBookName"];
  			$BookCode=$row5["eBookCode"];
			$BookValue=$row5["eBookCode"];
			$BookValueName=$row5["eBookName"];
 			$outputValue=$row5["eBookName"];
			//echo "<OPTION VALUE=$outputValue>$outputValue</option>\n";
 			$resultAuthor=$row5["eAuthorName"];
 			$resultPublisher=$row5["ePublisherName"];
 			$resultISBN=$row5["eBookISBN"];
			$SearchBookDir=$row5["eCollectionName"].$dotting.$row5["eCategoryName"].$dotting.$row5["eDeptName"].$dotting.$row5["eBookName"].$row5["ePageExtCode"];
			$SearchBookPath=$row5["ePagePath"];
				if(!empty($SearchBookPath)){
				$gOption="DisplayBook";
				$SearchBookDir=preg_replace('/\s/','',$SearchBookDir);
				$SearchBookPath=preg_replace('/\s/','',$SearchBookPath);
				}
			$resultBookValueCount=$BarCount;
			}
			//echo preg_replace('/\s/','',$SearchBookDir);
			//echo preg_replace('/\s\s+/','%',$SearchBookPath);

		}	

		echo "<button name=\"B9\"  style=\"width: 140; color:#ffffff; color:$ButtonTXT2; background-color:$ButtonBG2\" > Title </button>";
		echo "<br>";
		echo "<select size=\"1\" name=\"BookCode\" style=\"width: 116;  height: 20\">";
		echo "<option selected value=$BookCode>$BookName</option>\n";
		if($gOption=="-> GoTitle")
		{
			$BarCount=0;
			echo "<OPTION VALUE=$BookCode>$BookName</option>\n";
			//for($BarCount=1; $BarCount<=$resultBookValueCount; $BarCount++){
			//echo "<OPTION VALUE=$BookValue[$BarCount]>$BookValueName[$BarCount]</option>\n";
			//}
		}else{
			$BarCount=0;
			//for($BarCount=0; $BarCount<=$resultBookCount; $BarCount++){
			for($BarCount=1; $BarCount<=$resultBookCount; $BarCount++){
			echo "<OPTION VALUE=$resultBook[$BarCount]>$resultBookName[$BarCount]</option>\n";
			}
		}

		echo "</select>\n";
		echo "<INPUT TYPE =\"SUBMIT\"    style=\"width: 20; color:$ButtonTXT2; background-color:$ButtonBG2;  height: 20\"   VALUE = \"-> GoTitle\" name=\"GoBar\" >\n";

		echo "</td>";
//====================================== Author =======================================
		echo "<td width=\"10%\" >";
		echo "<button name=\"B10\"  style=\"width: 105; color:#ffffff; color:$ButtonTXT2; background-color:$ButtonBG2\" > Author</button>";
		echo "<br>";

		echo "<select size=\"1\" name=\"AuthorName\" style=\"width: 80;  height: 20\">";
		echo "<option selected value=$AuthorName>$AuthorName</option>\n";
		if($gOption=="-> GoAuthor")
		{
			mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
			$result5=mysqli_query($connect,"SELECT*  FROM elibrary WHERE eAuthorName='$AuthorName'");
			while($row5 = mysqli_fetch_array($result5))
			{
 			$outputValue=$row5["eAuthorName"];
			echo "<OPTION VALUE=$outputValue>$outputValue</option>\n";
			}
		}else{
			$BarCount=0;
			echo "<OPTION VALUE=$resultAuthor>$resultAuthor</option>\n";
			//for($BarCount=0; $BarCount<$resultAuthorCount; $BarCount++){
			for($BarCount=1; $BarCount<$resultAuthorCount; $BarCount++){
			echo "<OPTION VALUE=$arrayresultAuthor[$BarCount]>$arrayresultAuthor[$BarCount]</option>\n";
			}
		}
		//echo "<option selected value=$AuthorName>$AuthorName</option>\n";
		echo "</select>\n";
		echo "<INPUT TYPE =\"SUBMIT\"    style=\"width: 20; color:$ButtonTXT2; background-color:$ButtonBG2;  height: 20\"   VALUE = \"-> GoAuthor\" name=\"GoBar\" >\n";
		echo "</td>";
//====================================== Publisher =======================================	
		echo "<td width=\"10%\" >";
		echo "<button name=\"B11\"  style=\"width: 105; color:#ffffff; color:$ButtonTXT2; background-color:$ButtonBG2\" > Publisher</button>";
		echo "<br>";

		echo "<select size=\"1\" name=\"PublisherName\" style=\"width: 80;  height: 20\">";
		echo "<option selected value=$PublisherName>$PublisherName</option>\n";
		mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
		$result5=mysqli_query($connect,"SELECT*  FROM elibrary WHERE ePublisherName='$PublisherName'");
		while($row5 = mysqli_fetch_array($result5))
		{
 		$outputValue=$row5["ePublisherName"];
		echo "<OPTION VALUE=$outputValue>$outputValue</option>\n";
		}
		//echo "<option selected value=$PublisherName>$PublisherName</option>\n";
		echo "<OPTION VALUE=$resultPublisher>$resultPublisher</option>\n";
		echo "</select>\n";
		echo "<INPUT TYPE =\"SUBMIT\"    style=\"width: 20; color:$ButtonTXT2; background-color:$ButtonBG2;  height: 20\"   VALUE = \"-> GoPublisher\" name=\"GoBar\" >\n";
		echo "</td>";
//====================================== ISBN ==========================================		
		echo "<td width=\"10%\" >";
		echo "<button name=\"B12\"  style=\"width: 105; color:#ffffff; color:$ButtonTXT2; background-color:$ButtonBG2\" > ISBN</button>";
		echo "<br>";

		mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
		$result5=mysqli_query($connect,"SELECT*  FROM elibrary WHERE eBookISBN='$ISBNName'");
		echo "<select size=\"1\" name=\"ISBNName\" style=\"width: 80;  height: 20\">";
		while($row5 = mysqli_fetch_array($result5))
		{
 		$outputValue=$row5["eBookISBN"];
		echo "<OPTION VALUE=$outputValue>$outputValue</option>\n";
		}
		//echo "<option selected value=$ISBNName>$ISBNName</option>\n";
		echo "<OPTION VALUE=$resultISBN>$resultISBN</option>\n";
		echo "</select>\n";
		echo "<INPUT TYPE =\"SUBMIT\"    style=\"width: 20; color:$ButtonTXT2; background-color:$ButtonBG2;  height: 20\"   VALUE = \"-> GoISBN\" name=\"GoBar\" >\n";
		echo "</td>";
//====================================== Close ==========================================		

		echo "<td   width=\"5%\" > ";
		echo "<input type=\"submit\"  value=\"Add New\"  name=\"GoBar\"  style=\"height: 40; width: 70; color:$ButtonTXT2; background-color:$ButtonBG2\" > ";
		echo "</td>";

		echo "<td   width=\"5%\" > ";
		echo "<input type=\"submit\"  value=\"Close\"  name=\"GoBar\"  style=\"height: 40; width: 70;  color:$ButtonTXT2; background-color:$ButtonBG2\" >";
		echo "</td>";
	echo "</tr>";
echo "</table>";

//-------------------------------------------------------------------------------------------------------------------------
//echo "<table border=\"1\" cellpadding=\"6\" width=\"1015\"  id=\"table3\"  style=\"border-collapse: collapse; background-color:#000091\" > ";
//echo "<table border=\"1\" cellpadding=\"6\"  id=\"table3\"  style=\"border-collapse: collapse; background-color:#000091\" > ";
//echo "<table width=\"100%\"  text=\"#ffffff\" border=\"0\" align=\"center\" cellpadding=\"6\"  id=\"table2\"  style=\"border-collapse: collapse; color:$TableTXT1; background-color:$TableBG1\" > ";
	//echo "<tr>";




		//echo "<td >";
		//echo "<input type=\"text\"  value=\"\"  name=\"SearchBook\"  style=\"width: 400; background-color:#FFffff\" >";
		//echo "<input type=\"submit\"  value=\"-> GoSearch\"  name=\"GoBar\"  style=\"width: 20; color:$ButtonTXT2; background-color:$ButtonBG2; height: 20\">";
 		//echo "</td>";

		//echo "<td  colspan=\"2\" width=\"15%\" > ";
		//	echo "<span style=\"text-align:center; font-size: 16.0pt; font-family: 'Cooper Black',serif; color: #ff0000; font-weight: Bold \">
        	//	eLibrary</span>\n";
		//echo "</td>";

		//echo "<td  > ";
		//echo "<input type=\"submit\"  value=\"Add New\"  name=\"GoBar\"  style=\"width: 120; color:$ButtonTXT2; background-color:$ButtonBG2\" > ";
		//echo "</td>";

	//echo "</tr>";
//echo "</table>";

//=========================================== END Collections================================================

//=========================================== Begin Header Library Graphics Bar================================================

echo "<table border=\"0\" cellpadding=\"6\"  id=\"table2\"  style=\"border-collapse: collapse; \" > ";
		echo "<tr>";

			echo "<td width=\"10%\"  height=\"80\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Books";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibraryBook.jpg";			
			echo "<img title=\"Books\" border=\"0\"  src=$ffname$mysrc  width=\"71\"  height=\"71\" > ";
			echo "</a>";
			//echo "<br>&nbsp&nbsp&nbsp&nbspBooks";
			echo "</td>";

			echo "<td width=\"10%\"  height=\"80\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Journals";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibraryJournals.jpg";
			echo "<img title=\"Journals\"  border=\"0\"  src=$ffname$mysrc  width=\"71\"  height=\"71\" > ";
			echo "</a>\n";
			//echo "<br>&nbsp&nbspjournals";
			echo "</td>";

			echo "<td width=\"10%\"  height=\"80\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Magazines";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibraryMargazine.jpg";
			echo "<img title=\"Magazines\"  border=\"0\"  src=$ffname$mysrc  width=\"71\"  height=\"71\" > ";
			echo "</a>\n";
			//echo "<br>&nbsp&nbspMagazines";			
			echo "</td>";

			echo "<td width=\"10%\"  height=\"80\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Audios";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibraryAudio.jpg";			
			echo "<img title=\"Audios\"  border=\"0\"  src=$ffname$mysrc  width=\"71\"  height=\"71\" > ";
			echo "</a>\n";
			//echo "<br>&nbsp&nbsp&nbsp&nbspAudios";			
			echo "</td>";

			echo "<td width=\"20%\" colspan=\"2\" height=\"80\"  align=\"center\" valign=\"top\" > ";
			$CatName="eLibrary";
			$mysrc="$BuzzImages/ScholasticaeLibrary.png";			
			echo "<img  title=\"$CatName\" border=\"0\"  src=$ffname$mysrc  width=\"100\"  height=\"81\" > ";
			//$mysrcName=$myRecentHistory1;
			//$CatName="Collection.".$myRecentHistory1;
			//$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=$mysrcName, $CatName";	
			//echo "<a href=\"$action2\">";
			//$mysrc="eLibraryImages/$myRecentHistory1";			
			//echo "<img  title=\"$CatName\" border=\"0\"  src=$ffname$mysrc  width=\"100\"  height=\"81\" > ";
			//echo "</a>\n";
			//echo "<br>";
			//echo "<input type=\"text\" name=\"Collectiontype\" size=\"20\"  maxlenght=\"60\"  style=\"width:200; text-align:Center; color:#ffffff; background-color:#00c000\" Value=\"$dirOption\" >";
			echo "</td>";

			echo "<td width=\"10%\"  height=\"80\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Videos";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibraryVideo.jpg";		
			echo "<img title=\"Videos\"  border=\"0\"  src=$ffname$mysrc  width=\"71\"  height=\"71\" > ";
			echo "</a>\n";
			//echo "<br>&nbsp&nbsp&nbsp&nbspVideos";			
			echo "</td>";

			echo "<td width=\"10%\"  height=\"80\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Photos";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibraryPhoto.jpg";		
			echo "<img title=\"Photos\"  border=\"0\"  src=\"$ffname$mysrc\"  width=\"71\"  height=\"71\" > ";
			echo "</a>\n";
			//echo "<br>&nbsp&nbsp&nbsp&nbspPhotos";			
			echo "</td>";

			echo "<td width=\"10%\"  height=\"80\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Slides";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibrarySlide.jpg";		
			echo "<img title=\"Slides\"  border=\"0\"  src=\"$ffname$mysrc\"  width=\"71\"  height=\"71\" > ";
			echo "</a>\n";
			//echo "<br>&nbsp&nbsp&nbsp&nbspSlides";			
			echo "</td>";

			echo "<td width=\"10%\"  height=\"80\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=myDocument";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibraryDocument.jpg";		
			echo "<img title=\"myDocument\"  border=\"0\"  src=$ffname$mysrc  width=\"71\"  height=\"71\" > ";
			echo "</a>\n";
			//echo "<br>myDocuments";			
			echo "</td>";

			//echo "<td width=\"20%\"  height=\"200\"  colspan=\"2\"  rowspan=\"2\" > ";
			//$mysrcName=$myRecentHistory1;
			//$CatName="Collection.".$myRecentHistory1;
			//$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=$mysrcName, $CatName";	
			//echo "<a href=\"$action2\">";
			//$mysrc="eLibraryImages/$myRecentHistory1";			
			//echo "<img border=\"0\"  src=$ffname$mysrc  width=\"200\"  height=\"200\" > ";
			//echo "</a>\n";
			//echo "</td>";
		echo "</tr>";

		echo "<tr>";
			echo "<td colspan=\"10\"  >";
			echo "<hr>";
			echo "</td>";
		echo "</tr>";


//============================================== Begin main Library Display Window========================================================
		echo "<tr>";
			echo "<td   height=\"600\" align=\"left\" valign=\"top\" >";
			echo "</td>";

			echo "<td   height=\"600\"  colspan=\"8\"  align=\"center\" valign=\"top\" >";

		if ($dirOption=="Books" OR $dirOption=="Journals" OR $dirOption=="Magazines" OR $dirOption=="Videos" OR $dirOption=="Audios" OR $dirOption=="Photos" OR $dirOption=="Slides")
		{
			//================================================
				$totggt=0;

				$dir = $path2Root."/eLibraryImages/";
				$dirtmp = $path2Root."/eLibraryImages/";
	
				// Open a known directory, and proceed to read its contents and get total number of files
				if (is_dir($dirtmp)) {
				if ($dh = opendir($dirtmp)) {
				while (($file = readdir($dh)) !== false) {
				$totggt=$totggt+1;
				//echo "filename: $file : filetype: " . filetype($dirtmp. $file) . "\n";
				}
				closedir($dh);
				}
				}
				//echo $totggt;

				// check that it is part of the owners Shop or company and include it in the list
				$files1 = scandir($dir);
				$ggt=0;
				//while($ggt<$totggt)
				$caCount=0;
				for($ggt=0; $ggt< $totggt; $ggt++)
				{
				$Invoutput1=$files1[$ggt];
				//$dirPOS=$dirOption.\".\";
				//$gfthPOS=strpos($Invoutput1, $dirPOS, 0);
				$dirOptionLEN=strlen($dirOption);
				$gfth=substr("$Invoutput1",0,$dirOptionLEN);

      					if("$gfth"=="$dirOption")
      					{
					$dirOptionLEN=strlen($dirOption);
					$catPOS=strpos($Invoutput1, ".", $dirOptionLEN+1);
					$unColCategory[$ggt]=substr("$Invoutput1",0,$catPOS);
					//$caPosINDEX[$caCount]=$ggt;
					//echo $caPosINDEX[$caCount];
					$caCount=$caCount+1;
      					}

				
				}
					$ColCategory=array_unique($unColCategory);
					$ffgot=count($ColCategory);
					$caPosINDEX=array_keys($ColCategory);
					//$CatName"Category";
					//========================Show Categories=============================
						$ffgVal=0;
						for($ffg=0; $ffg< $ffgot; $ffg++)
						{




						$ffgVal=$caPosINDEX[$ffg];
						$CatName="Category.".$ColCategory[$ffgVal];
						$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=$ColCategory[$ffgVal], $CatName";	
						echo "<a href=\"$action2\">";
						//$mysrc="eLibraryImages/eLibraryCategory.jpg";
						$mysrc="eLibraryCategory.jpg";
						$mysrc="eLibraryCategory.jpg";

// Create a blank image and add some text
$im = imagecreatetruecolor(250, 50);
$text_color = imagecolorallocate($im, 255, 255, 255);
imagestring($im,5, 5, 5, $ColCategory[$ffgVal], $text_color);
$imagepath="$ffname$mysrc";
$imagepath="eLibraryCategory".$ffgVal.".jpg";
// Save the image as 'simpletext.jpg'
imagejpeg($im, $imagepath);
//imagejpeg($im, "eLibraryCategory.jpg");
//imagejpeg($im, "eLibraryCategory.jpg");
//imagejpeg($im, 'c:\wamp\www\eLibraryImages\eLibraryCategory.jpg');
// Output the image
//header('Content-type: image/jpeg');

// Free up memory
imagedestroy($im);


						//$mysrc="simpletext.jpg";
						//echo "<img border=\"0\"  src=$ffname$mysrc  width=\"200\"  height=\"97\" > ";			
						//echo "<img border=\"0\"  src=$mysrc  width=\"200\"  height=\"50\" > ";
						echo "<img border=\"0\"  src=$imagepath  width=\"200\"  height=\"50\" > ";
						//echo "<input type=\"text\" name=\"Categorytype\" size=\"10\"  maxlenght=\"20\"  style=\"alignment: Center; background-color:#000091\" Value=\"$ColCategory[$ffgVal]\" >";
						echo "</a>&nbsp&nbsp\n";
						}
					//=====================================================

		}
		elseif ($ColOption=="Category")
		{

			//================================================
				$totggt=0;

				$dir = $path2Root."/eLibraryImages/";
				$dirtmp = $path2Root."/eLibraryImages/";
	
				// Open a known directory, and proceed to read its contents and get total number of files
				if (is_dir($dirtmp)) {
				if ($dh = opendir($dirtmp)) {
				while (($file = readdir($dh)) !== false) {
				$totggt=$totggt+1;
				//echo "filename: $file : filetype: " . filetype($dirtmp. $file) . "\n";
				}
				closedir($dh);
				}
				}
				//echo $totggt;

				// check that it is part of the owners Shop or company and include it in the list
				$files1 = scandir($dir);
				$ggt=0;
				//while($ggt<$totggt)
				$caCount=0;
				for($ggt=0; $ggt< $totggt; $ggt++)
				{
				$Invoutput1=$files1[$ggt];
				//$dirPOS=$dirOption.\".\";
				//$gfthPOS=strpos($Invoutput1, $dirPOS, 0);
				$dirOptionLEN=strlen($dirOption);
				$gfth=substr("$Invoutput1",0,$dirOptionLEN);
				//echo $gfth;

      					if("$gfth"=="$dirOption")
      					{
					$dirOptionLEN=strlen($dirOption);
					$catPOS=strpos($Invoutput1, ".", $dirOptionLEN+1);
					$unColCategory[$ggt]=substr("$Invoutput1",0,$catPOS);
					//$caPosINDEX[$caCount]=$ggt;
					//echo $caPosINDEX[$caCount];
					$caCount=$caCount+1;
      					}

				
				}
					$ColCategory=array_unique($unColCategory);
					$ffgot=count($ColCategory);
					$caPosINDEX=array_keys($ColCategory);
					//========================Show Departments =============================
						$ffgVal=0;
						for($ffg=0; $ffg< $ffgot; $ffg++)
						{
						$ffgVal=$caPosINDEX[$ffg];
						$CatName="Department.".$ColCategory[$ffgVal];
						$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=$ColCategory[$ffgVal], $CatName";	
						echo "<a href=\"$action2\">";
						$mysrc="eLibraryImages/eLibraryDept.jpg";


$im = imagecreatetruecolor(200, 50);
$text_color = imagecolorallocate($im, 255, 255, 255);
imagestring($im,5, 5, 5, $ColCategory[$ffgVal], $text_color);
$imagepath="eLibraryDept".$ffgVal.".jpg";
imagejpeg($im, $imagepath);
imagedestroy($im);
			
						echo "<img border=\"0\"  src=$imagepath  width=\"200\"  height=\"50\" > ";
						//echo "<input type=\"text\" name=\"Departmenttype\" size=\"10\"  maxlenght=\"20\"  style=\"alignment: Center; background-color:#000091\" Value=\"$ColCategory[$ffgVal]\" >";
						echo "</a>&nbsp&nbsp\n";
						}
					//==============================================================================================

		}

		elseif ($ColOption=="Department")

		{

			//================================================
				$totggt=0;

				$dir = $path2Root."/eLibraryImages/";
				$dirtmp = $path2Root."/eLibraryImages/";
	
				// Open a known directory, and proceed to read its contents and get total number of files
				if (is_dir($dirtmp)) {
				if ($dh = opendir($dirtmp)) {
				while (($file = readdir($dh)) !== false) {
				$totggt=$totggt+1;
				//echo "filename: $file : filetype: " . filetype($dirtmp. $file) . "\n";
				}
				closedir($dh);
				}
				}
				//echo $totggt;

				// check that it is part of the owners Shop or company and include it in the list
				$files1 = scandir($dir);
				$ggt=0;
				//while($ggt<$totggt)
				$caCount=0;
				for($ggt=0; $ggt< $totggt; $ggt++)
				{
				$Invoutput1=$files1[$ggt];
				//$dirPOS=$dirOption.\".\";
				//$gfthPOS=strpos($Invoutput1, $dirPOS, 0);
				$dirOptionLEN=strlen($dirOption);
				$gfth=substr("$Invoutput1",0,$dirOptionLEN);
				//echo $gfth;

      					if("$gfth"=="$dirOption")
      					{
					$dirOptionLEN=strlen($dirOption);
					$catPOS=strpos($Invoutput1, ".", $dirOptionLEN+1);
					$unColCategory[$ggt]=substr("$Invoutput1",0,$catPOS);
					//$caPosINDEX[$caCount]=$ggt;
					//echo $caPosINDEX[$caCount];
					$caCount=$caCount+1;
      					}

				
				}
					$ColCategory=array_unique($unColCategory);
					$ffgot=count($ColCategory);
					$caPosINDEX=array_keys($ColCategory);
					//========================Show Books =============================
						$ffgVal=0;
						for($ffg=0; $ffg< $ffgot; $ffg++)
						{
						$ffgVal=$caPosINDEX[$ffg];
						$CatName="ShowBook.".$ColCategory[$ffgVal]. ".jpg";
						$mysrcName=$ColCategory[$ffgVal]. ".jpg";
						$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=$mysrcName, $CatName";	
						echo "<a href=\"$action2\">";
						$mysrc="eLibraryImages/$mysrcName";			
						echo "<img title=\"$ColCategory[$ffgVal]\" border=\"0\"  src=$ffname$mysrc  width=\"97\"  height=\"97\" > ";
						echo "</a>\n";
						//echo "<input type=\"text\" name=\"Booktype\" size=\"12\"  maxlenght=\"20\"  style=\"alignment: Center; background-color:#000091\" Value=\"$CatName\">";
						//echo $mysrc;
						}

					//=====================================================

		}
		elseif ($ColOption=="Collection")
		{
			$ColOption="";
			$_SESSION['sColOption']="";

				$gfthPOS=0;
				$gfthType="";

				$gfthPOS=strpos($dirOption, ".", 0);
				$gfthType=substr("$dirOption",0,$gfthPOS);
     				$mybytes="";
			//========add to previous books menu=====
			$myCurrentSRC=$dirOption;
			//array_shift($arRecentHistory,$myCurrentSRC);
			//========================= update recent history================
  			mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
  			$qry = "INSERT INTO erecent (RecentName) VALUES ('" . mysqli_real_escape_string($connect, $myCurrentSRC) . "')";
			mysqli_query($connect, $qry) or die ('could not query: '.mysql_error());
			//===============================================================

			//=======================================
			if($gfthType=="Books"){
     				$mybytes=str_replace(".jpg", ".pdf", "$dirOption");
			}
			elseif($gfthType=="Magazines"){
     				$mybytes=str_replace(".jpg", ".pdf", "$dirOption");
			}
			elseif($gfthType=="Journals"){
     				$mybytes=str_replace(".jpg", ".pdf", "$dirOption");
			}
			elseif($gfthType=="Audios"){
     				$mybytes=str_replace(".jpg", ".mp3", "$dirOption");
			}
			elseif($gfthType=="Videos"){
     				$mybytes=str_replace(".jpg", ".mpeg", "$dirOption");
			}
			elseif($gfthType=="Photos"){
     				$mybytes=str_replace(".jpg", ".jpg", "$dirOption");
			}

			elseif($gfthType=="Slides"){
     				$mybytes=str_replace(".jpg", ".jpg", "$dirOption");
			}

								$dirOptionLEN=strlen($dirOption);
								$catPOS=strpos($dirOption, ".", $dirOptionLEN-5);
			     				$mybytes="";
			     				$mybytes=substr("$dirOption",0,$catPOS);
			if ($gfthType=="Books" OR $gfthType=="Magazines" OR $gfthType=="Journals" OR $gfthType=="Videos" OR $gfthType=="Audios" OR $gfthType=="Photos" OR $dirOption=="Slides")
			{

						if ($gfthType=="Books")
						{
						$dirpdf= $path2Root."/eLibraryBooks/";
						$dirpdftemp= $path2Root."/eLibraryBooks/";
						$bytes = $ffname."eLibraryBooks/".$mybytes;
								//header('Content-type: application/pdf');
								//echo "<embed readfile($bytes)>\n";
								echo "<embed src=$bytes  width=\"900\"  height=\"600\" >\n";
								//readfile("$bytes");
						}

						if ($gfthType=="Magazines")
						{
						$dirpdf= $path2Root."/eLibraryMagazines/";
						$dirpdftemp= $path2Root."/eLibraryMagazines/";
						$bytes = $ffname."eLibraryMagazines/".$mybytes;
								//header('Content-type: application/pdf');
								//echo "<embed readfile($bytes)>\n";
								//readfile("$bytes");
								echo "<embed src=$bytes  width=\"900\"  height=\"600\" >\n";
						}

						if ($gfthType=="Journals")
						{
						$dirpdf= $path2Root."/eLibraryJournals/";
						$dirpdftemp= $path2Root."/eLibraryJournals/";
						$bytes = $ffname."eLibraryJournals/".$mybytes;
								//header('Content-type: application/pdf');
								//echo "<embed readfile($bytes)>\n";
								//readfile("$bytes");
								echo "<embed src=$bytes  width=\"900\"  height=\"600\" >\n";
						}

						if ($gfthType=="Videos")
						{
						$dirpdf= $path2Root."/eLibraryVideos/";
						$dirpdftemp= $path2Root."/eLibraryVideos/";
						$bytes = $ffname."eLibraryVideos/".$mybytes;
								//header('Content-type: application/mp4');
 								echo "&nbsp<embed src=$bytes width=\"600\"  height=\"600\" >\n";
 								//echo "&nbsp<embed src=$bytes >\n";
								//echo "<embed $bytes>\n";
								//readfile("$bytes");
						}

						if ($gfthType=="Audios")
						{
						$dirpdf= $path2Root."/eLibraryAudios/";
						$dirpdftemp= $path2Root."/eLibraryAudios/";
						$bytes = $ffname."eLibraryAudios/".$mybytes;
								//header('Content-type: application/mp3');
 								echo "&nbsp<embed src=$bytes>\n";
								//echo "<embed readfile($bytes)>\n";
								//readfile("$bytes");
						}

						if ($gfthType=="Photos")
						{
						$dirpdf= $path2Root."/eLibraryPhotos/";
						$dirpdftemp= $path2Root."/eLibraryPhotos/";
						$bytes = $ffname."eLibraryPhotos/".$mybytes;
							echo "<img border=\"0\"  src=$bytes   width=\"600\"  height=\"600\" > ";
						}

						if ($gfthType=="Slides")
						{
						$dirpdf= $path2Root."/eLibrarySlides/";
						$dirpdftemp= $path2Root."/eLibrarySlides/";
						$bytes = $ffname."eLibrarySlides/".$mybytes;
							echo "<img border=\"0\"  src=$bytes   width=\"400\"  height=\"580\" > ";
		
						}

						if ($gfthType=="myDocuments")
						{
						$dirpdf= $path2Root."/eLibraryAudios/";
						$dirpdftemp= $path2Root."/eLibraryAudios/";
						$bytes = $ffname."eLibraryDocuments/".$mybytes;
 								echo "&nbsp<embed src=$bytes>\n";
						}



			}else{
			$mysrc="eLibraryImages/$dirOption";			
			//echo "<img border=\"0\"  src=$ffname$mysrc  width=\"400\"  height=\"600\" > ";
 			echo "&nbsp<embed src=$ffname$mysrc>\n";
			}
		}

//========================================== Begin Display Books =======================================================

		if ($gOption=="DisplayBook")
		{


			mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
			$result5=mysqli_query($connect,"SELECT*  FROM elibrary WHERE eFilePath='$dirOption'");
			while($row5 = mysqli_fetch_array($result5))
			{
			$eBookName=$row5["eBookName"];
 			$BookSummary=$row5["eDescription"];
			$erprice=$row5["erprice"];
			$elPrice=$row5["elPrice"];
			$ebPrice=$row5["ebPrice"];
			$epPrice=$row5["epPrice"];
			$AuthorName=$row5["eAuthorName"];
			$PublisherName=$row5["ePublisherName"];
			$eBookISBN=$row5["eBookISBN"];
			}


						echo "<table text=\"#ffffff\" border=\"0\" align=\"center\" cellpadding=\"6\"   id=\"table2\"  style=\"border-collapse: collapse; color:#000000; background-color:#ffffff\" > ";
						echo "<tr>";

						echo "<td   height=\"500\" width=\"500\" align=\"left\" valign=\"bottom\" >";

						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > Title</button>";
						echo "<br>$eBookName";
						//echo "<br><input type=\"text\"  value=\"$eBookName\"  name=\"eBookName\"  style=\"width: 100; background-color:#FFffff\" >";

						echo "<p>";
						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > Author</button>";
						echo "<br>$AuthorName";
						//echo "<br><input type=\"text\"  value=\"$AuthorName\"  name=\"AuthorName\"  style=\"width: 100; background-color:#FFffff\" >";

						echo "<p>";
						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > Publisher</button>";
						echo "<br>$PublisherName";
						//echo "<br><input type=\"text\"  value=\"$PublisherName\"  name=\"PublisherName\"  style=\"width: 100; background-color:#FFffff\" >";

						echo "<p>";
						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > ISBN</button>";
						echo "<br>$eBookISBN";
						//echo "<br><input type=\"text\"  value=\"$eBookISBN\"  name=\"eBookISBN\"  style=\"width: 100; background-color:#FFffff\" >";

						echo "<p>";
						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > Read Price</button>";
						echo "<br>$erprice";
						//echo "<br><input type=\"text\"  value=\"$erprice\"  name=\"erprice\"  style=\"width: 100; background-color:#FFffff\" >";

						echo "<p>";
						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > Loan Price</button>";
						echo "<br>$elPrice";
						//echo "<br><input type=\"text\"  value=\"$elPrice\"  name=\"elPrice\"  style=\"width: 100; background-color:#FFffff\" >";

						echo "<p>";
						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > Borrow Price</button>";
						echo "<br>$ebPrice";
						//echo "<br><input type=\"text\"  value=\"$ebPrice\"  name=\"ebPrice\"  style=\"width: 100; background-color:#FFffff\" >";

						echo "<p>";
						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > Purchase</button>";
						echo "<br>$epPrice";
						//echo "<br><input type=\"text\"  value=\"$epPrice\"  name=\"epPrice\"  style=\"width: 100; background-color:#FFffff\" >";
						//echo "<input type=\"submit\"  value=\"-> GoSearch\"  name=\"GoBar\"  style=\"width: 20; color:$ButtonTXT2; background-color:$ButtonBG2; height: 20\">";
					echo "</td>";



						echo "<td   height=\"500\" width=\"500\" align=\"left\" valign=\"bottom\" >";
						$mysrcName=$SearchBookDir;
						$CatName="Collection.".$SearchBookDir;
						$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=$mysrcName, $CatName";	
						$myPath=$ffname."eLibraryImages/".$SearchBookDir;	
						echo "<a href=\"$action2\">";
						//echo "<img title=\"$SearchBookPath\" border=\"0\"  src=$SearchBookPath width=\"500\"  height=\"500\" > ";
						//echo "<img title=\"$SearchBookDir\" border=\"0\"  src=$ffname$SearchBookDir width=\"500\"  height=\"500\" > ";
 						echo "<img title=\"$dirOption\" border=\"0\"  src=$myPath width=\"500\"  height=\"500\" > ";
						//echo "&nbsp<embed src=$SearchBookPath>\n";
						echo "</a>\n";
					echo "</td>";


						echo "<td   height=\"500\" width=\"100\" align=\"left\" valign=\"bottom\" >";
						echo "&nbsp&nbsp&nbsp<textarea name=\"BookSummary\" style=\"width:200; height :500\">$BookSummary</textarea>";
					echo "</td>";
						echo "</tr>";
						echo "</table>";


		}

//=================================================== Begin Show Book =====================================================
		if ($ColOption=="ShowBook")
		{

			mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
			$result5=mysqli_query($connect,"SELECT*  FROM elibrary WHERE eFilePath='$dirOption'");
			while($row5 = mysqli_fetch_array($result5))
			{
			$eBookName=$row5["eBookName"];
 			$BookSummary=$row5["eDescription"];
			$erprice=$row5["erPrice"];
			$elPrice=$row5["elPrice"];
			$ebPrice=$row5["ebPrice"];
			$epPrice=$row5["epPrice"];
			$AuthorName=$row5["eAuthorName"];
			$PublisherName=$row5["ePublisherName"];
			$eBookISBN=$row5["eBookISBN"];
			}


						echo "<table text=\"#ffffff\" border=\"0\" align=\"center\" cellpadding=\"6\"   id=\"table2\"  style=\"border-collapse: collapse; color:#000000; background-color:#ffffff\" > ";
						echo "<tr>";
						echo "<td   height=\"500\" width=\"100\" align=\"left\" valign=\"bottom\" >";

						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > Title</button>";
						echo "<br>$eBookName";
						//echo "<br><input type=\"text\"  value=\"$eBookName\"  name=\"eBookName\"  style=\"width: 100; background-color:#FFffff\" >";

						echo "<p>";
						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > Author</button>";
						echo "<br>$AuthorName";
						//echo "<br><input type=\"text\"  value=\"$AuthorName\"  name=\"AuthorName\"  style=\"width: 100; background-color:#FFffff\" >";

						echo "<p>";
						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > Publisher</button>";
						echo "<br>$PublisherName";
						//echo "<br><input type=\"text\"  value=\"$PublisherName\"  name=\"PublisherName\"  style=\"width: 100; background-color:#FFffff\" >";

						echo "<p>";
						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > ISBN</button>";
						echo "<br>$eBookISBN";
						//echo "<br><input type=\"text\"  value=\"$eBookISBN\"  name=\"eBookISBN\"  style=\"width: 100; background-color:#FFffff\" >";

						echo "<p>";
						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > Read Price</button>";
						echo "<br>$erprice";
						//echo "<br><input type=\"text\"  value=\"$erprice\"  name=\"erprice\"  style=\"width: 100; background-color:#FFffff\" >";

						echo "<p>";
						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > Loan Price</button>";
						echo "<br>$elPrice";
						//echo "<br><input type=\"text\"  value=\"$elPrice\"  name=\"elPrice\"  style=\"width: 100; background-color:#FFffff\" >";

						echo "<p>";
						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > Borrow Price</button>";
						echo "<br>$ebPrice";
						//echo "<br><input type=\"text\"  value=\"$ebPrice\"  name=\"ebPrice\"  style=\"width: 100; background-color:#FFffff\" >";

						echo "<p>";
						echo "<button name=\"B12\"  style=\"width: 105; color:#000000; color:$ButtonTXT2; background-color:$ButtonBG2\" > Purchase</button>";
						echo "<br>$epPrice";
						//echo "<br><input type=\"text\"  value=\"$epPrice\"  name=\"epPrice\"  style=\"width: 100; background-color:#FFffff\" >";
						//echo "<input type=\"submit\"  value=\"-> GoSearch\"  name=\"GoBar\"  style=\"width: 20; color:$ButtonTXT2; background-color:$ButtonBG2; height: 20\">";
					echo "</td>";


						echo "<td   height=\"500\" width=\"100\" align=\"left\" valign=\"bottom\" >";
						//echo "<textarea name=\"BookSpec\" style=\"width:200; height :100\">$BookSpec</textarea>&nbsp&nbsp&nbsp&nbsp";
						$mysrcName=$dirOption;
						$CatName="Collection.".$dirOption;
						$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=$mysrcName, $CatName";
						$myPath=$ffname."eLibraryImages/".$dirOption;	
						echo "<a href=\"$action2\">";
						//echo "<img title=\"$SearchBookPath\" border=\"0\"  src=$SearchBookPath width=\"500\"  height=\"500\" > ";
						echo "<img title=\"$dirOption\" border=\"0\"  src=$myPath width=\"500\"  height=\"500\" > ";
  						//echo "&nbsp<embed src=$SearchBookPath>\n";
						echo "</a>\n";
					echo "</td>";

						echo "<td   height=\"500\" width=\"100\" align=\"left\" valign=\"bottom\" >";
						echo "&nbsp&nbsp&nbsp<textarea name=\"BookSummary\" style=\"width:200; height :500\">$BookSummary</textarea>";
					echo "</td>";
						echo "</tr>";
						echo "</table>";



		}

		if ($gOption=="-> GoSearch")
		{

		if(isset($_POST['SearchBook']))
			{
			$arSearchBook=array();
			$SearchBook= $_POST['SearchBook'];
			//$_SESSION['sCategoryCode']=$CategoryCode;
				$NumberOfBooks=0;
				$BooksCounted=0;

				$dotting=".";
				$bcount=0;
				mysqli_select_db($connect,"$myjaiveDBname2") or die ('did not find db'.mysql_error());
				$result5=mysqli_query($connect,"SELECT*  FROM elibrary");
				while($row5 = mysqli_fetch_array($result5))
				{
 				$NumberOfBooks=0;
				preg_match("/$SearchBook/i",$row5["eBookName"],$arMatch);
				$NumberOfBooks=count($arMatch);
					if($NumberOfBooks>=1){
					$arSearchBook[$bcount]=$row5["eCollectionName"].$dotting.$row5["eCategoryName"].$dotting.$row5["eDeptName"].$dotting.$row5["eBookName"].$row5["ePageExtCode"];
					$bcount++;
					}
				}
				//preg_match("/$SearchBook/i",$arSearchBook,$arMatch);
				//$arMatch=array_intersect($arSearchBook,$SearchBook);
				$BooksCounted=count($arSearchBook);

					if($BooksCounted>=1){
						for($ffg=0; $ffg<=$BooksCounted-1; $ffg++){
						$mysrcName=$arSearchBook[$ffg];
						$CatName="Collection.".$arSearchBook[$ffg];
						$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=$mysrcName, $CatName";	
						echo "<a href=\"$action2\">";
						$mysrc=$arSearchBook[$ffg];
						$mysrc=preg_replace('/\s/','',$mysrc);
						$mysrc="eLibraryImages/$mysrc";
						echo "<img title=\"$mysrc\" border=\"0\"  src=$ffname$mysrc  width=\"100\"  height=\"100\" > ";
						echo "</a>\n";
						}
					}

			}


		}
			echo "</td>";

			echo "<td   height=\"600\" align=\"left\" valign=\"top\" >";
			echo "</td>";
			//echo "<span style=\"text-align:center; font-size: 16.0pt; font-family: 'Cooper Black',serif; color: #ff0000; font-weight: Bold \">
        		//eLibrary</span>\n";
		echo "</tr>";

	echo "</table>";
//============================================ End Main Library Display===============================================================
	
echo "</div>";

//=========================================== Begin Footer Library Graphics Bar================================================

echo "<table width=\"100%\"  border=\"0\" cellpadding=\"6\"  id=\"table2\"  style=\"border-collapse: collapse; \" > ";
		echo "<tr>";
			echo "<td width=\"10%\"   align=\"center\" valign=\"center\"  >";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Previous";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/blue_arrow_left.png";			
			echo "<img  title=\"Previous\"  border=\"0\"  src=$ffname$mysrc  width=\"60\"  height=\"60\" > ";
			echo "</td>";

			echo "<td colspan=\"3\" width=\"30%\"    align=\"center\" valign=\"center\"  >";
			echo "<hr>";
			echo "</td>";

			echo "<td colspan=\"2\" width=\"20%\"    align=\"center\" valign=\"center\"  >";
			echo "<span style=\"text-align:center; font-size: 16.0pt; font-family: 'Cooper Black',serif; color: #ff0000; font-weight: Bold \">
        		eLibrary</span>\n";
			echo "</td>";

			echo "<td colspan=\"3\" width=\"30%\"    align=\"center\" valign=\"center\"  >";
			echo "<hr>";
			echo "</td>";

			echo "<td width=\"10%\"   align=\"center\" valign=\"center\"  >";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Next";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/blue_arrow_right.png";			
			echo "<img title=\"Next\"   border=\"0\"  src=$ffname$mysrc  width=\"59\"  height=\"59\" > ";
			echo "</td>";
		echo "</tr>";
		echo "</Table>";

echo "<table width=\"80%\"  border=\"0\" cellpadding=\"6\"  id=\"table2\"  style=\"border-collapse: collapse; \" > ";
		echo "<tr>";
			echo "<td width=\"10%\"  height=\"60\" > ";

     			echo "</td>";

			echo "<td width=\"10%\"  height=\"60\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Books";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibraryBook.jpg";			
			echo "<img title=\"Books\" border=\"0\"  src=$ffname$mysrc  width=\"59\"  height=\"59\" > ";
			echo "</a>";
			//echo "<br>&nbsp&nbsp&nbsp&nbspBooks";
			echo "</td>";

			echo "<td width=\"10%\"  height=\"60\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Journals";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibraryJournals.jpg";
			echo "<img title=\"Journals\"  border=\"0\"  src=$ffname$mysrc  width=\"59\"  height=\"59\" > ";
			echo "</a>\n";
			//echo "<br>&nbsp&nbspjournals";
			echo "</td>";

			echo "<td width=\"10%\"  height=\"60\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Magazines";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibraryMargazine.jpg";
			echo "<img title=\"Magazines\"  border=\"0\"  src=$ffname$mysrc  width=\"59\"  height=\"59\" > ";
			echo "</a>\n";
			//echo "<br>&nbsp&nbspMagazines";			
			echo "</td>";

			echo "<td width=\"10%\"  height=\"60\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Audios";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibraryAudio.jpg";			
			echo "<img title=\"Audios\"  border=\"0\"  src=$ffname$mysrc  width=\"59\"  height=\"59\" > ";
			echo "</a>\n";
			//echo "<br>&nbsp&nbsp&nbsp&nbspAudios";			
			echo "</td>";

			echo "<td width=\"10%\"  height=\"60\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Videos";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibraryVideo.jpg";		
			echo "<img title=\"Videos\"  border=\"0\"  src=$ffname$mysrc  width=\"59\"  height=\"59\" > ";
			echo "</a>\n";
			//echo "<br>&nbsp&nbsp&nbsp&nbspVideos";			
			echo "</td>";

			echo "<td width=\"10%\"  height=\"60\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Photos";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibraryPhoto.jpg";		
			echo "<img title=\"Photos\"  border=\"0\"  src=\"$ffname$mysrc\"  width=\"59\"  height=\"59\" > ";
			echo "</a>\n";
			//echo "<br>&nbsp&nbsp&nbsp&nbspPhotos";			
			echo "</td>";

			echo "<td width=\"10%\"  height=\"60\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=Slides";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibrarySlide.jpg";		
			echo "<img title=\"Slides\"  border=\"0\"  src=\"$ffname$mysrc\"  width=\"59\"  height=\"59\" > ";
			echo "</a>\n";
			//echo "<br>&nbsp&nbsp&nbsp&nbspSlides";			
			echo "</td>";

			echo "<td width=\"10%\"  height=\"60\" > ";
			$action2="/$forms/frmeLibrary/frmDisplayeLibrary.php?Collection=myDocument";	
			echo "<a href=\"$action2\">";
			$mysrc="$BuzzImages/eLibraryDocument.jpg";		
			echo "<img title=\"myDocument\"  border=\"0\"  src=$ffname$mysrc  width=\"59\"  height=\"59\" > ";
			echo "</a>\n";
			//echo "<br>myDocuments";			
			echo "</td>";

			echo "<td width=\"10%\"  height=\"60\" > ";

			echo "</td>";
		echo "</tr>";
		//echo "<tr>";
		//	echo "<td colspan=\"10\"  >";
		//	echo "<hr>";
		//	echo "</td>";
		//echo "</tr>";
		echo "</Table>";

echo "</form>\n";
//echo "</center>";

?>