/*------------------------------------------------------------------------
# AJAX Functions (javascript)
# ------------------------------------------------------------------------
# Author : Amirreza Ghods
# Email : ar.ghods@yahoo.com
# Web Site : http://www.shahkey.com
# Date  : 2006/10/9  15:32
-------------------------------------------------------------------------*/
	
	
function beload(Location,Destination)
{
	
// load results in div

isiusjs = false;if (window.XMLHttpRequest)

{
	
isiusjs = new XMLHttpRequest();if (isiusjs.overrideMimeType)
	
{
	
isiusjs.overrideMimeType("text/xml");

}

}
else if (window.ActiveXObject)
	
	{
		
		try
{
	
isiusjs = new ActiveXObject("Msxml2.XMLHTTP");

}

catch (e){try

{
isiusjs = new ActiveXObject("Microsoft.XMLHTTP");

}
catch(e){}}}if (!isiusjs)

{
alert("Connect Failure"); return false;

}
imageloading(Destination);

isiusjs.onreadystatechange = AJ;

shah = Destination;

isiusjs.open("GET", Location, true);
isiusjs.send(null);}function AJ()
{

if (isiusjs.readyState == 4){
	
	if (isiusjs.status == 200)
		
{

DOMz(isiusjs.responseText);

}

}
}

function DOMz(shahkey)
{
	
	document.getElementById(shah).innerHTML = shahkey
		
}
function imageloading(loading)

{
// insert loading image
	document.getElementById(loading).innerHTML = '<br><br><center><br><img src="img/ghafaseh/loading.gif"><br>...در حال جستجو</center><br><br>';
}




function request_result()
{
	// get result from check.php
	var i = document.getElementById('word').value;
	
	if (i != "")
		
	{
		
	var request_url = 'categorise.php?word='+i;
	
	
	beload(request_url,'result');
	
	}
	
	
	else
		
	{
		
		alert("!لطفا کلمه مورد نظر خود را وارد کنيد");
			
			
	}
	
}





function request_resultsearch()
{
	// get result from check.php
   /*
	var search = encodeURI(document.getElementById('T_search').value);
	var D_f = encodeURI(document.getElementById('D_f').value;
    var topic = encodeURI(document.getElementById('dhtmlgoodies_country').value);
	var category = encodeURI(document.getElementById('dhtmlgoodies_city').value);
    var subcategory = encodeURI(document.getElementById('dhtmlgoodies_sub').value);
	var D_irkh = encodeURI(document.getElementById('D_irkh').value);
   	var oritem = encodeURI(document.getElementById('oritem').value);
	var itemsearch = encodeURI(document.getElementById('itemsearch').value);
    var notitem = encodeURI(document.getElementById('notitem').value);
	var itemsearch = encodeURI(document.getElementById('itemsearch').value);

var request_urls = 'fmbook.php?searchitems=yes&search='+search+'&D_f='+D_f+'&D_topic='+topic+'&D_category='+category+'&D_subcategory='+subcategory+'&D_irkh='+D_irkh+'&oritem='+oritem+'&itemsearch='+itemsearch+'&notitem='+notitem+'itemsearch='+itemsearch;

*/
encodeURI( document.getElementById("T_search").value )
		

var request_urls = 'fmbook.php?searchitems=yes&search='+encodeURI( document.getElementById("T_search").value )+'&D_f='+encodeURI( document.getElementById("D_f").value )+'&D_topic='+encodeURI( document.getElementById("dhtmlgoodies_country").value )+'&D_category='+encodeURI( document.getElementById("dhtmlgoodies_city").value )+'&D_subcategory='+encodeURI( document.getElementById("dhtmlgoodies_sub").value )+'&D_irkh='+encodeURI( document.getElementById("D_irkh").value )+'&oritem='+encodeURI( document.getElementById("oritem").value )+'&itemsearch='+encodeURI( document.getElementById("itemsearch").value )+'&notitem='+encodeURI( document.getElementById("notitem").value )+'&itemsearch='+encodeURI( document.getElementById("itemsearch").value )+'&D_format='+encodeURI( document.getElementById("D_format").value );

		

	beload(request_urls,'resultnewbook');
	

	
}















function hotkey(eventkey)
{
	// Enter KEY On KeyBoard
	if (eventkey.keyCode == 13)
		
		
	{
		
		request_result()
			
	}
	
}

function putinfield(word)
{
	// put the text to the field
	document.getElementById('word').value = word;
	
	
}

/* End of the mainjs.js*/

