var xmlHtp;

//browse by alphabets and no.... str - alphabet, typ = categories / keywords

function alphaBrowse(str,type) {

var xmlHtp=GetXmlHttpObject();

  if (xmlHtp==null)
  {
  	alert ("Your browser does not support AJAX!");
  	return;
  }

var url="browse.htm";
url=url+"?q="+str;
url=url+"&type="+type;
url=url+"&sid="+Math.random();

xmlHtp.onreadystatechange= function ()
{
if (xmlHtp.readyState==4)
{
document.getElementById("existing").innerHTML=xmlHtp.responseText;
}
}
xmlHtp.open("POST",url,true);
xmlHtp.send(null);
}

function displayState()
{
if (xmlHtp.readyState==4)
{
document.getElementById("existing").innerHTML=xmlHtp.responseText;
}
}

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

//when selecting the drop down menu it will change and get records from the selected index.

function Change(dropdown,typ)
{
	
    var myindex  = dropdown.selectedIndex
    var SelValue = dropdown.options[myindex].value

	getRecords(SelValue,typ);

    return true;
}
 
//get records by the id, str = id and typ = categories/keywords

function getRecords(str,typ)
{

document.getElementById("new").innerHTML ="";

xmlHtp=GetXmlHttpObject();
if (xmlHtp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="getdetails.htm";
url=url+"?cid="+str;
url=url+"&typ="+typ;

xmlHtp.onreadystatechange=displayState;
xmlHtp.open("POST",url,true);
xmlHtp.send(null);
}


function getCity(str) 
{

xmlHtp=GetXmlHttpObject();
if (xmlHtp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="getstatecity.htm";
url=url+"?sid="+str;

xmlHtp.onreadystatechange=function () { 
      if (xmlHtp.readyState==4)    {
                        document.getElementById("city_fld").innerHTML= xmlHtp.responseText;
                }
            };
xmlHtp.open("POST",url,true);
xmlHtp.send(null);
}


//getting keywords according to the categoriesID

function getKeywords(str,typ) { 

xmlHtp=GetXmlHttpObject();
if (xmlHtp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }

var catid = document.getElementById('categories').value;
var altid = document.getElementById('altcategories').value;
var url="getkeyword.htm";
url=url+"?catid="+catid;
if(catid !=altid) { 
	url=url+"&altid="+altid;
}
else { 
		url=url+"&altid=";
}
url=url+"&typ="+typ;

xmlHtp.onreadystatechange=function (){ 
				if (xmlHtp.readyState==4)    {
						document.getElementById("dis_key").innerHTML= xmlHtp.responseText;
				}
			};
xmlHtp.open("POST",url,true);
xmlHtp.send(null);
}



function getsearchKeywords() {

xmlHtp=GetXmlHttpObject();
if (xmlHtp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }

var catid = document.getElementById('categories').value;
var altid = '';
var url="getkeyword.htm";
url=url+"?catid="+catid;
//url=url+"&altid="+altid;

xmlHtp.onreadystatechange=function (){
                if (xmlHtp.readyState==4)    {
                        document.getElementById("dis_key").innerHTML= xmlHtp.responseText;
                }
            };
xmlHtp.open("POST",url,true);
xmlHtp.send(null);
}


//function setKeywords() { }
