function search_all(){
	xPattern = document.getElementById('search_text').value;
	var AjaxSearchAll = new req('AjaxSearchAll');
	var xShowPhotosResults = new ShowPhotosResults();
	AjaxSearchAll.xmlhttpPost('ops.php', xShowPhotosResults,'op=SearchPhotos&pattern=' + xPattern);
	SubSearchBooks(xPattern);
	SubSearchUsers(xPattern);
}

function ShowPhotosResults(){
	this.callBackFunction = function(xTxt) 
	{
		HandlePhotosData(xTxt);
		if (GlPhotos == 0)
		{
			document.getElementById('ResPhotos').innerHTML = xTxt;
		}
		else
		{
			document.getElementById('ResPhotos').innerHTML = '';
			for(x=0; x < GlPhotos; x++)
			{
				xRatio = GetImageRatio(GlArrPhotos[x][6], GlArrPhotos[x][7]);
				xRow = document.createElement("div");
				xRow = DefineClass(xRow,'ResultElement');
				xInn = '<a href="index.php?op=showphoto&photoID=' + GlArrPhotos[x][0] + '&bookID=' + GlArrPhotos[x][1] + '"><img src="' + GlArrPhotos[x][4] + '" width="' + xRatio[0] + '" height="' + xRatio[1] +'"></a><br>';
				xInn = xInn + GlArrPhotos[x][2];
				xRow.innerHTML = xInn;
				document.getElementById('ResPhotos').appendChild(xRow);
			}
		}
	}
}

function SubSearchBooks(xPattern){
	var AjaxSearchBooks = new req('AjaxSearchBooks');
	var xShowBooksResults = new ShowBooksResults();
	AjaxSearchBooks.xmlhttpPost('ops.php', xShowBooksResults,'op=SearchBooks&pattern='+xPattern);
}

function ShowBooksResults(){
	this.callBackFunction = function(xTxt) 
	{
		HandleBooksData(xTxt);
		if (GlBooks == 0)
		{
			document.getElementById('ResBooks').innerHTML = xTxt;
		}
		else
		{
			document.getElementById('ResBooks').innerHTML = '';
			for(x=0; x < GlBooks ;x++)
			{
				xRow = document.createElement("div");
				xRow = DefineClass(xRow,'ResultElement');
				xInn = '<a href="index.php?op=showbook&bookID=' + GlArrBooks[x][0] + '"><img src="' + GlArrBooks[x][2] + '" width="100px"></a><br>';
				xInn = xInn + GlArrBooks[x][4];
				xRow.innerHTML = xInn;
				document.getElementById('ResBooks').appendChild(xRow);
			}
		}
	}
}

function SubSearchUsers(xPattern){
	var AjaxSearchUsers = new req('AjaxSearchUsers');
	var xShowUsersResults = new ShowUsersResults();
	AjaxSearchUsers.xmlhttpPost('ops.php', xShowUsersResults,'op=SearchUsers&pattern='+xPattern);
}

function ShowUsersResults(){
	this.callBackFunction = function(xTxt) 
	{
		xXML = xConvert(xTxt);
		xResults = xXML.length;
		if (xResults == 0)
		{
			document.getElementById('ResUsers').innerHTML = xTxt;
		}
		else
		{
			document.getElementById('ResUsers').innerHTML = '';
			for(x=0;x<xResults;x++)
			{
				xRow = document.createElement("div");
				xRow = DefineClass(xRow,'ResultElement');
				xInn = '<img src="' + xmlDoc.getElementsByTagName("user_img")[x].childNodes[0].nodeValue + '" width="100px"><br>';
				xInn = xInn + xmlDoc.getElementsByTagName("user_nick")[x].childNodes[0].nodeValue;
				xRow.innerHTML = xInn;
				document.getElementById('ResUsers').appendChild(xRow);
			}
		}
	}
}
