function getHTTPObject()
{
	// code for Mozilla, etc.
	if (window.XMLHttpRequest)
  	{
  		xmlhttp=new XMLHttpRequest()
  	}
// code for IE
	else if (window.ActiveXObject)
  	{
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  	}
	return xmlhttp;
}
var http = getHTTPObject();

function dictionary_search(f)
{
	if(Trim(f.vTitle.value) == "")
	{
		alert("Please enter keyword for search.");
    	f.vTitle.focus();
		return false;
	}
	if(document.getElementById("showLoading"))
	{
		document.getElementById("showLoading").style.display ='';
	}
	var url = SITE_URL+"ajax_file/ajax_dictionary_search.php";
	url = url + "?title="+ escape(f.vTitle.value);
	http.open("GET", url, true);
	http.onreadystatechange = handleHttpResponse_status;
  	http.send(null);
}
function dictionarysearch(f)
{
	if(document.getElementById("showLoading"))
	{
		document.getElementById("showLoading").style.display ='';
	}
	var url = SITE_URL+"ajax_file/ajax_dictionary_search.php";
	url = url + "?title="+ escape(f);
	http.open("GET", url, true);
	http.onreadystatechange = handleHttpResponse_status;
  	http.send(null);
}

function handleHttpResponse_status() 
{ 
	if (http.readyState == 4) 
	{	
      	isWorking = false;
    	if (http.responseText.indexOf('invalid') == -1) 
		{
			var xmlDocument = http.responseXML; 
			var totrec = xmlDocument.getElementsByTagName('total').item(0).firstChild.data;
			var html;
			html = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
			if(parseInt(totrec)>0)
			{
				var str, dummy_str, cnt, cc, bgcolor;
				cnt = 1;
				for(j=0;j<parseInt(totrec);j++)				// Display data
				{
					var addclass;
					if(j+1 != parseInt(totrec)) addclass = 'style="font:11px Verdana, Arial, Helvetica, sans-serif; color:#333333; padding-top:12px; padding-bottom:12px; line-height:18px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #dadada "';
					else addclass = 'style="font:11px Verdana, Arial, Helvetica, sans-serif; color:#333333; padding-top:12px;"'; 	
					html += '<tr><td align="left" '+addclass+'><p style="font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 14px;font-weight: bold;color: #333333;text-decoration: none;margin: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 2px;padding-left: 0px;">';
					html += xmlDocument.getElementsByTagName('title').item(j).firstChild.data;
					html += '</p><p>';
					html += xmlDocument.getElementsByTagName('description').item(j).firstChild.data;
					html += '</p></td></tr>';
					cnt++;
				}
				//document.getElementById("totrecord").innerHTML = '<p>'+parseInt(totrec)+' Search Result </p>';
				//document.getElementById("records").style.display ='';
			}
			else
			{
				html += '<tr><td valign="bottom" height="30px" align="center">Sorry, no conditions were found to match your criteria.</td></tr>';
				//document.getElementById("records").style.display ='none';
			}
			html += '</table>';
			document.getElementById("listing").innerHTML = html;
			isWorking = false;
			if(document.getElementById("showLoading"))
			{
				document.getElementById("showLoading").style.display ='none';
			}
		}
  	}
}