/**************** Quick Search ********************/
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
		catch (e)
		  {
		  // Internet Explorer
		  try
			{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
		  catch (e)
			{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		  }
	return xmlHttp;
} //end of GetXmlHttpObject
	

function stateChangedTop() 
{ 	
	stURLTop	= siteurl;

	if (xmlHttp.readyState==4)
	{ 
		 var result	= xmlHttp.responseText;
		 //alert('resulr...'+result);
		// document.getElementById("search_product").value	= result;
		 document.frmsearch.action= stURLTop+"/search.php";			// change static url to http://www.ikartit.com
		 document.frmsearch.submit();		
	}	
} // end of stateChanged

var AdminResponseSc = "";
function parseResponseS()
{
var nMessage = document.getElementById('searchresultbox');
nMessage.style.display = '';
	if(AdminResponseS == "Match Not Found")
	{	
		document.getElementById("searchresultbox").style.display = "block";
		document.getElementById('searchresultcontain').innerHTML = AdminResponseS;
	}
	else if(AdminResponseS == "")
	{
		document.getElementById("searchresultbox").style.display = "block";
		document.getElementById('searchresultcontain').innerHTML = "Match Not Found";
	}
	else
	{	
		document.getElementById("searchresultbox").style.display = "block";
		document.getElementById('searchresultcontain').innerHTML = AdminResponseS;
	}
}

function registerUserS()
{
 var AdminRequestS  = GetXmlHttpObject();
 AdminRequestS.onreadystatechange = function()
 {
	
	myDiv	= document.getElementById("searchresultcontain");
	if(AdminRequestS.readyState == 1 || AdminRequestS.readyState == 2 || AdminRequestS.readyState == 3)
	{
		document.getElementById("searchresultbox").style.display = "block";
	}
	
	if (AdminRequestS.readyState == 4)
	{
		if (AdminRequestS.status == 200)
		{
		AdminResponseS = AdminRequestS.responseText;
		parseResponseS();
		}
	}
}
var nForm = document.frmsearch;
var infoStr = "keyword=" + nForm.txtSearch.value;
AdminRequestS.open("POST", siteurl+"/searchAvailable.php", true);
AdminRequestS.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
AdminRequestS.send(infoStr);
}


function CheckSearch(nForm){
document.getElementById('searchresultbox').style.display = 'block';
myDiv	= document.getElementById("searchresultcontain");
myDiv.innerHTML = " <img src='"+nForm+"/images/ajax-red-circle.gif' border='0' align='texttop'> <b><span class='headingBold'>Please wait. Loading...</span></b>";
setTimeout("registerUserS()", 1000);
//registerUserS();
}

function parseResponseSc()
{
   //alert(AdminResponseSc);
	if(AdminResponseSc == "Please Enter Keyword")
	{
		document.getElementById('searchresultbox').style.display="block";
		document.getElementById('searchresultbox').innerHTML=AdminResponseSc;
	}
	else
	{
		document.frmsearch.action=siteurl+"/search.php";
		document.frmsearch.submit();
	}
}


function registerUserSc(){

var AdminRequestSc = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
AdminRequestSc.onreadystatechange = function()
{
	if (AdminRequestSc.readyState == 4)
	{
		//alert(AdminRequestSc.responseText);
		if (AdminRequestSc.status == 200)
		{
		AdminResponseSc = AdminRequestSc.responseText;
		parseResponseSc();
		}
	}
}

var nForm1 = document.frmsearch;
var infoStrs = "keyword=" + nForm1.txtSearch.value;
alert(infoStrs);
AdminRequestSc.open("POST", siteurl+"/searchValidation.php", true);
AdminRequestSc.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
AdminRequestSc.send(infoStrs);
}

function ValidationSearch(nForm)
{
	document.frmsearch.action=siteurl+"/search.php";
	document.frmsearch.submit();
}

function  hideSearchDiv()
{
	document.getElementById("searchresultbox").style.display = "none";
}


function searchkeywordTop(objStUrl,objPageNum,objPerPageCnt)
{
	var keyword    = document.getElementById('txtSearch').value;
	
	var pageNum	   = objPageNum;
	var PerPageCnt = objPerPageCnt;
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}

/*	var url=objStUrl+"/searchProducts.php?txtSearchAd="+keyword+"&pageNumsend="+ pageNum+"&PerPageCntSend="+PerPageCnt;
	 //stateChangedTop;
	xmlHttp.onreadystatechange = function()
	{
		    if (xmlHttp.readyState==4)
			{ 
				 var result	= xmlHttp.responseText;*/
				 //alert('resulr...'+result);
				// document.getElementById("search_product").value	= result;
				 document.frmsearch.action= siteurl+"/search.php";			// change static url to http://www.ikartit.com
				 document.frmsearch.submit();		
		/*	}	
	}
	xmlHttp.open("POST",url, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.send(null);*/
					
} // end of function ratePhoto

/**************************************************/
