strloadlist =  '<div align="center"><br /><br /><br />Loading Matching Listings<br /><br /><img src="http://www.holisticguidance.com/images/throb.gif"></div>';
function SetCat(pass) {
	var cid = document.getElementById("cid");
	if (cid.value != "") {
		ilinks=document.getElementsByName(cid.value);
		for (i=0;i<=ilinks.length-1;i++) ilinks[i].className='';
	}
	ilinks=document.getElementsByName(pass.name);
	for (i=0;i<=ilinks.length-1;i++) ilinks[i].className='CurrLink';
	cid.value = pass.name;
	url = 'http://www.holisticguidance.com/modules/categories/index.php?CatId='+pass.id.substr(1,pass.id.length-1);
	GoAjax(url);
	var trm = document.getElementById("trm");
	if (trm.value != "") {
		trmvalue=trm.value.replace(/"/g,'');
		ilinks=document.getElementsByName(trmvalue);
		for (i=0;i<=ilinks.length-1;i++) ilinks[i].className='';
	}
	trm.value=document.getElementById("otrm").value;
	ilen = pass.id.length-1;
	if (document.getElementById('L' + pass.id.substr(1,ilen))) {
		document.getElementById('L' + pass.id.substr(1,ilen)).innerHTML='<img src="http://www.holisticguidance.com/modules/categories/images/minus.png" width="16" height="16">';
	}
	LoadListings();
}
function SetPage(pass) {
	var pge = document.getElementById("pge");
	pge.value = pass;
	LoadListings();
}
function SetTrm(pass) {
	var cid = document.getElementById("cid");
	if (cid.value != "") {
		ilinks=document.getElementsByName(cid.value);
		for (i=0;i<=ilinks.length-1;i++) ilinks[i].className='';
	}
	cid.value=document.getElementById("ocid").value;
	var trm = document.getElementById("trm");
	if (trm.value != "") {
		trmvalue=trm.value.replace(/"/g,'');
		ilinks=document.getElementsByName(trmvalue);
		for (i=0;i<=ilinks.length-1;i++) ilinks[i].className='';
	}
	ilinks=document.getElementsByName(pass);
	for (i=0;i<=ilinks.length-1;i++) ilinks[i].className='CurrLink';
	trm.value = '"' +pass +'"';
	LoadListings();
}
function SetOrder(pass) {
	//alert(pass)
	var oby = document.getElementById("oby");
	if (oby.value == pass) oby.value = -1 * pass; else oby.value = pass;
	LoadListings();
}
function LoadListings(){
	var zip = document.getElementById("zip");
	var rng = document.getElementById("rng");
	var pge = document.getElementById("pge");
	var oby = document.getElementById("oby");
	var cid = document.getElementById("cid");
	var trm = document.getElementById("trm");
	var mode = document.getElementById("mode");
	var oreg = document.getElementById("oreg");
	var ost = document.getElementById("ost");
	url = 'searchresult.php?Z=' + zip.value;
	url = url + '&R=' + rng.value;
	url = url + '&P=' + pge.value;
	url = url + '&O=' + oby.value;
	url = url + '&C=' + cid.value;
	url = url + '&T=' + trm.value;
	url = url + '&M=' + mode.value;
	url = url + '&RG=' + oreg.value;
	url = url + '&S=' + ost.value;
	document.getElementById("xdir2-data").innerHTML = strloadlist;
	document.getElementById("xdir2-paging").innerHTML = '';
	//alert(url);
	GoAjax(url);
}
function PopListing(o,y) {
	//alert('asdasdasd');
	//alert(o+'---------------'+y)
	var pbody =  passhtml['PopListing'][y];
	//alert(pbody);
	delete passhtml['PopListing'][y];
	if (y>1) {
		document.getElementById("xdir2-data").innerHTML = pbody;
		setTimeout('SizeData();',300);
	}else{
		str = '<div align="center"><br /> No matching listings found.<br /><br />';
		str = str + 'Please change your search or <a href="index.php">browse our categories.</a><br /><br />';
		str = str + 'Remember to try your search again later.<br />';
		str = str + 'New practitioners are signing up every day.</div>';
		document.getElementById("xdir2-data").innerHTML = str;
	}
	slink = '<li><a href="javascript:void(0);" onclick="SetPage(';
	nohref = '<li class="current"><a nohref>';	
	var str='';
	var itop=0;
	var low=0;
	x = parseInt(y.split('.')[0]);
	y = parseInt(y.split('.')[1]);
	var p = x - 1;
	if (x>1){ str = str + slink + p +')"><img src="http://www.holisticguidance.com/images/prev-arrow.jpg" width="6" alt="" style="padding-top:2px;"; /></a> ';}else{
		str = str + '<li><a><img src="http://www.holisticguidance.com/images/prev-arrow.jpg" width="6" alt="" style="padding-top:2px;"; /></a> ';
		}
	if (x<5) low=1; else low=x-5;
	if (x<5) itop=10; else itop=x+5;
	if (low<1) low=1;
	if (itop>y) itop=y;
	for (var i=low;i<=itop;i++) {
		if (i != x) {
			str = str + slink + i +')">' + i + '</a> </li>';
		}else{
			str = str + nohref + i + ' </a> </li>';
		}
	}
	var n = x + 1;
	if (x<y){ str = str + slink + n +')"><img src="http://www.holisticguidance.com/images/next-arrow.jpg" width="6" alt="" style="padding-top:2px;"; 	 /></a> ';}else{
		str = str + '<li><a><img src="http://www.holisticguidance.com/images/next-arrow.jpg" width="6" alt="" style="padding-top:2px;"; 	 /></a> ';
	}
	/*str = '<table><tr><td width="50%">' + ' page ' + parseInt(x) + ' of ' + parseInt(y)  + '</td><td>'+ str;
	str = str + '</td></tr></table>';*/
	str = "<div class=\"pagingarea fr\"><div class=\"leftbg\"><div class=\"rightbg\"><div class=\"paging\"><div><ul>"+str+"</ul></div><div class=\"cl\"></div></div></div></div></div><div class='cl'></div>";
	
	
	document.getElementById("xdir2-paging").innerHTML = str;
        
	for(i=1;i<=3;i++){
		document.getElementById('sort-' + i).src = "http://www.holisticguidance.com/images/blank.gif";
	}

	if (o<0) {str="http://www.holisticguidance.com/images/sort_down.png";} else {str="http://www.holisticguidance.com/images/sort_up.png";}
        
	document.getElementById('sort-' + Math.abs(o)).src = str;
	
	if (document.getElementById("SearchParams")) {
		if (document.getElementById("SearchParams").innerHTML=='') {
			istart = pbody.indexOf('<!-- Search report');
			istart = istart + 18;        
			iend = pbody.indexOf('Search end -->');
			ilen = iend - istart;
			if (istart != -1) {
				str = '<strong><a href="index.php">Browse all Practice Areas</a></strong><br /><br />' + pbody.substr(istart,ilen);
				document.getElementById("SearchParams").innerHTML =  str;
			}
		}
	}
}
function SizeData(){
    DataHeight = document.getElementById("xdir2-data").scrollHeight;
    if (DataHeight > 0) {
            DataHeight = DataHeight + 15;
            document.getElementById("xdir2-tree").style.height=DataHeight  + 'px';
            DataHeight = DataHeight + 5;
            document.getElementById("xdir2-right").style.height=DataHeight  + 'px';
            document.getElementById("xdir2-left").style.height=DataHeight  + 'px';
            DataHeight = DataHeight + 40;
            //document.getElementById("xdir2-body").style.height=DataHeight  + 'px';
    } else {
            setTimeout('SizeData();',300);
    }
}