
// declare a global  XMLHTTP Request object
var XmlHttpObj, XmlHttpObjSidebar;

// create an instance of XMLHTTPRequest Object, varies with browser type, try for IE first then Mozilla
function CreateXmlHttpObj()
{
	// try creating for IE (note: we don't know the user's browser type here, just attempting IE first.)
	try
	{
		XmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpObj = null;
		}
	}
	// if unable to create using IE specific code then try creating for Mozilla (FireFox)
	if(!XmlHttpObj && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpObj = new XMLHttpRequest();
	}
	
	//for sidebar filter
	// try creating for IE (note: we don't know the user's browser type here, just attempting IE first.)
	try
	{
		XmlHttpObjSidebar = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpObjSidebar = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpObjSidebar = null;
		}
	}
	// if unable to create using IE specific code then try creating for Mozilla (FireFox)
	if(!XmlHttpObjSidebar && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpObjSidebar = new XMLHttpRequest();
	}
}



// called from onChange or onClick event of the continent dropdown list

function filter_ret_result(job_type_id,fav_result,page_num,description)
{
	
	document.getElementById("dvAjaxLoaderImage").style.display = "block";
	document.getElementById("dvContentResult").style.display = "none";

	var variables_string ;
	var main_search_text;
	var main_search_text_string;
	var job_type_id_string;
	var fav_result_string;
	var page_num_string;
	var category_dropdown;
	var description_string;
	//for dropdown category value
	//var category_dropdown = document.getElementById('category').value;
	//main_search_category = "&category=" +category_dropdown;
	// for main search form date
	main_search_text = document.getElementById('txtSearchBox').value;
	if (main_search_text == 'Job Title')
	    main_search_text = '';
	main_search_text_string = "txtSearchBox=" +main_search_text;
	job_type_id_string = "&JobTypeId="+ job_type_id;
	fav_result_string = "&FavResult="+ fav_result;
	page_num_string = "&page=" +page_num;
	
	if(typeof(description) != "undefined" && description !=null ) description_string = "&Description2=0";

	// url of page that will send xml data back to client browser
	var requestUrl = "http://www.zealtypia.com/recruiter/users/ajax_search_results.php?" + main_search_text_string + job_type_id_string + fav_result_string + page_num_string + description_string; //+main_search_category;

	//alert(requestUrl);
	CreateXmlHttpObj();
	//XmlHttpObj =1;

	// verify XmlHttpObj variable was successfully initialized
	if(XmlHttpObj)
	{
		// assign the StateChangeHandler function ( defined below in this file)
		// to be called when the state of the XmlHttpObj changes
		// receiving data back from the server is one such change
		XmlHttpObj.onreadystatechange = StateChangeHandler;

		// define the iteraction with the server -- true for as asynchronous.
		XmlHttpObj.open("POST", requestUrl,  true);
		// send request to server, null arg  when using "GET"
		XmlHttpObj.send(null);
	}
	
	
	
	

	
}


// this function called when state of  XmlHttpObj changes
// we're interested in the state that indicates data has been
// received from the server
function StateChangeHandler()
{
	//alert(XmlHttpObj);
	// state ==4 indicates receiving response data from server is completed
	if(XmlHttpObj.readyState == 4)
	{

		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpObj.status == 200)
		{

			PopulateCountryList(XmlHttpObj.responseText);
		}
		else
		{
		}
	}
	
}
// this function called when state of  XmlHttpObj changes
// we're interested in the state that indicates data has been
// received from the server


// populate the contents of the country dropdown list
function PopulateCountryList(countryNode)
{


    document.getElementById("dvContentResult").innerHTML = countryNode
    + '<script type="text/javascript">if(isMoble()) var myScroll = new iScroll("dvContentResult", { scrollbarClass: ' + "'" + 'myScrollbar' + "'" + ' });</script>';
	document.getElementById("dvAjaxLoaderImage").style.display = "none";
	document.getElementById("dvContentResult").style.display = "block";


}



	function changeActive(){
		document.getElementById("liAllJobs").setAttribute("class","active");
		document.getElementById("liFullJobs").setAttribute("class","");
		document.getElementById("liFreelanceJobs").setAttribute("class","");
		document.getElementById("liFavorites").setAttribute("class","");
	
	}
	
	function changeActive1(){
		document.getElementById("liAllJobs").setAttribute("class","");
		document.getElementById("liFullJobs").setAttribute("class","active");
		document.getElementById("liFreelanceJobs").setAttribute("class","");
		document.getElementById("liFavorites").setAttribute("class","");
	
	}
	
	function changeActive2(){
		document.getElementById("liAllJobs").setAttribute("class","");
		document.getElementById("liFullJobs").setAttribute("class","");
		document.getElementById("liFreelanceJobs").setAttribute("class","active");
		document.getElementById("liFavorites").setAttribute("class","");
	
	}
	
	function changeActive3(){
		document.getElementById("liAllJobs").setAttribute("class","");
		document.getElementById("liFullJobs").setAttribute("class","");
		document.getElementById("liFreelanceJobs").setAttribute("class","");
		document.getElementById("liFavorites").setAttribute("class","active");
	
	}

