// JavaScript Document
var xmlHttp
var xmlHttp2
var countryMenu =0; 
var typeMenu = 0;
function filterData(str,menuType,divName,page)
{ 
//alert("filter");
if(menuType =="country" && str !="nocountry")
{
countryMenu =1;
}

if(menuType =="type" && str !="notype")
{
typeMenu =1;
}

xmlHttp=GetXmlHttpObject();
 
if (xmlHttp==null)
{
 
 
alert ("Browser does not support HTTP Request");
 
 
return
 
 
}
 
var url=page;

url=url+"?q="+str+"&menu="+menuType+"&country="+countryMenu+"&type="+typeMenu+"&mode=Listing&Page=1&queryFilter=noQuery"; // mode= listing and page 1
																				// are added for paging
url=url+"&sid="+Math.random();

xmlHttp.onreadystatechange=function () {
           stateChanged(divName);
        };
xmlHttp.open("GET",url,true);
 
xmlHttp.send(null);
//fillCombobox(str,"cityDiv","fillComboBox.php");
}

// will create object from xmlHttpRequest
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;
}


// will fill the div with records from database
function stateChanged(div) 
{ 
if(xmlHttp.readyState == 3)  // Loading Request
{
document.getElementById(div).innerHTML = '<img src="../images/ajax-loader.gif" align="center" />';
 }

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById(div).innerHTML=xmlHttp.responseText;
 } 
}




// will poulate the combobox
function fillCombobox(str,type,divName,page)
 
{ 

//alert("combo");
xmlHttp2=GetXmlHttp2Object();

if(xmlHttp2==null)
{
alert ("Browser does not support HTTP Request");
 
return
}
 
var url=page;

url=url+"?combo="+str+"&type="+type;
url=url+"&sid="+Math.random();

xmlHttp2.onreadystatechange=function () {
           stateChanged2(divName);
        };
xmlHttp2.open("GET",url,true);

xmlHttp2.send(null);
 
} 
 
 

function GetXmlHttp2Object()
{
var xmlHttp2=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp2=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp2;
}


// will fill the div with records from database
function stateChanged2(div) 
{ 
if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
 { 
 document.getElementById(div).innerHTML=xmlHttp2.responseText;
 } 
}
