



function dohover(recid,e) {

q = "/ui/ajaxgetrow.aspx?recid=" + recid ;

var loader1 = new net.ContentLoader(q, sortoutpop,null,"GET","");	



d = document.getElementById("popup") ;
d.style.visibility = "visible";

setLyr2("r" + recid, "popup") ;
//d.style.left = (e.clientX + 100) + "px";
//d.style.top = (e.clientY - 50) + "px" ;
//alert(e.clientX);
setOpacity(25,"wholetable") ;

}



function handleOut() {
d = document.getElementById("popup") ;
d.style.visibility = "hidden";
d.style.left = "-650px";
}


function sortoutpop() {

alldata = new String(this.req.responseText) ;
ardata = alldata.split ("~") ;
var image = new String();
image = "";
for (i=0;i < ardata.length;i++) 
{
	if (ardata[i].indexOf("fullname=") > -1) {
		fullname = ardata[i].replace("fullname=","") ;
		
	}
	
		if (ardata[i].indexOf("specialty=") > -1) {
		specialty = ardata[i].replace("specialty=","") ;
		
	}
	if (ardata[i].indexOf("practicename=") > -1) {
		practicename = ardata[i].replace("practicename=","") ;
		
	}
	if (ardata[i].indexOf("address1=") > -1) {
		address1 = ardata[i].replace("address1=","") ;
		
	}
	if (ardata[i].indexOf("address2=") > -1) {
		address2 = ardata[i].replace("address2=","") ;
		
	}
	
	if (ardata[i].indexOf("city=") > -1) {
		city = ardata[i].replace("city=","") ;
		
	}
	if (ardata[i].indexOf("state=") > -1) {
		state = ardata[i].replace("state=","") ;
		
	}
	if (ardata[i].indexOf("zip=") > -1) {
		zip = ardata[i].replace("zip=","") ;
		
	}
	if (ardata[i].indexOf("phone=") > -1) {
		phone = ardata[i].replace("phone=","") ;
		
	}
	if (ardata[i].indexOf("fax=") > -1) {
		fax = ardata[i].replace("fax=","") ;
		
	}
	if (ardata[i].indexOf("language=") > -1) {
		languages = ardata[i].replace("language=","") ;
		
	}
	if (ardata[i].indexOf("dspec=") > -1) {
		secondaryspecialty = ardata[i].replace("dspec=","") ;
		
	}
	
	
	if (ardata[i].indexOf("image=") > -1) {
		image = ardata[i].replace("image=","") ;
		
	}
		

}
var strlocation = "";

if (practicename == "")
{

}
else
{
    strlocation = practicename + "<br>" ;
}

if (address1 == "")
{

}
else
{
strlocation = strlocation + address1 + "<br>" ;
}
if (address2 == "")
{

}
else
{
strlocation = strlocation + address2 + "<br>" ;

}

strlocation = strlocation + city + ", " + state + " " + zip ;

scontactinfo = phone + " (office)" ;
if (fax !== "")
{
    scontactinfo += "<br>" +  fax + " (fax)";
}


if (secondaryspecialty !== "")
{
    secondaryspecialty = "<br>" + secondaryspecialty + "<sup>*</sup>";
}

document.getElementById("fullnamespec").innerHTML =  fullname + "<br>" + specialty + secondaryspecialty;
document.getElementById("location").innerHTML =  strlocation ;
document.getElementById("contactinfo").innerHTML = scontactinfo ;
document.getElementById("blanguages").innerHTML = languages ;


if (image !== "")
{
    document.getElementById ("baseballphoto").style.display  = "inline" ;
	document.getElementById ("baseballphoto").src = "http://sitemanager.acsysinteractive.com/webservices/genImage.aspx?h=130&w=100&fil=/" + image.replace("http://extranet.acsysweb.com/","")  ;
}
else
{
	document.getElementById ("baseballphoto").style.display  = "None" ;
}






}
ex1 = new Animator({duration: 1000,interval: 40 }) ;
a = 1;
function showsearch() {
	td = document.getElementById ("searchpane") ;
	im = document.getElementById ("ss1");
	im2 = document.getElementById ("finddoctor") ;
//btn_refine_search_closed.gif
	
	//if (td.style.display == "none") {
	if (a == 0)
	{
	    if (browser.IsIE )
	    {
	      ex1.addSubject(new NumericalStyleSubject(td, 'height', 0, 160));
	      ex1.play();
	    }
	    else
	    {
	      td.style.display = "block";
	    }	    
	    im.src = "/images/images_people/btn_refine_search.gif" ;
		im2.src = "/images/images_people/btn_close.gif" ;
	   
	    a=1;
	}
	else
	{
	     if (browser.IsIE )
	    {
	     ex1.addSubject(new NumericalStyleSubject(td, 'height', 160, 0)); 
	     ex1.play();
	    }
	    else
	    {
	    td.style.display = "none";
	    }
	    
	    im.src = "/images/images_people/btn_refine_search_closed.gif" ;
		im2.src = "/images/images_people/btn_open.gif" ;
		
	    a=0;
	}	
		
		//td.style.display = "block" ;
		//im.src = "/images/images_people/btn_refine_search.gif" ;
		//im2.src = "/images/images_people/btn_close.gif" ;
		
	//}
	//else
	//{
		//td.style.display = "none" ;
		//im.src = "/images/images_people/btn_refine_search_closed.gif" ;
		//im2.src = "/images/images_people/btn_open.gif" ;
	
	//}

}


var pagenum = 0;
var sort = "" ;
var friendlysort = "";


function runsearch(num,sortstring) {
    //alert(sortstring);
pagenum = num ;
friendlysort = sortstring ;

f = document.forms[0];

acceptingvalue = "";
keywordvalue = "";
lnamevalue = "";
locvalue = "";
langvalue = "";
gendervalue = "";
specvalue = "";
zipvalue = "";
searchstring = "";
numd = 0;
var cookiestring = "";


if (sortstring == "Doctor Name")
{
    sort = "lastname asc";
    
}
else if (sortstring == "Location")
{
    sort = "(select top 1 city from virginiahosp_list_locations where recordid = (select top 1 relatedid from trelateditems where recordid = virginiahosp_list_doctors.recordid and masterlistid = 42 and relatedtablename = 'virginiahosp_list_locations' and relatedgroup = 'virginiahosp_list_locations'  order by primaryorder )) asc "
}
else if (sortstring == "Specialties")
{
    sort = "(select top 1 longname from toptions where optionid = (select top 1 relatedid from trelateditems where recordid = virginiahosp_list_doctors.recordid and masterlistid = 42 and relatedtablename = 'toptions' and relatedgroup = 'Specialty'  order by primaryorder )) asc " ;
}
else if (sortstring == "Gender")
{
    sort = "gender asc" ;
}
else if (sortstring == "Languages")
{
    sort = "(select top 1 longname from toptions where optionid = (select top 1 relatedid from trelateditems where recordid = virginiahosp_list_doctors.recordid and masterlistid = 42 and relatedtablename = 'toptions' and relatedgroup = 'Language'  order by primaryorder )) asc "
}
else
{

}

for (t=0;t < f.elements.length;t++) {
	
	var elid = new String(f.elements[t].id) ;
	 
	if (elid.indexOf ("specialty") > 0) {

	    var fe = document.getElementById(elid);
		if (fe.type != "select-one") {
		    continue;
		}
		specvalue = fe.options[fe.selectedIndex].value;	
		cookiestring = cookiestring + elid + "~" + specvalue + ";" ;
		
	}
	
	
	if (elid == "lname") {
		var fe = document.getElementById (elid) ;
		
		lnamevalue = fe.value ;
		cookiestring = cookiestring + elid + "~" +lnamevalue + ";" ;
	
	}
	
	if (elid.indexOf("language") >= 0) {
		var fe = document.getElementById (elid) ;
		
		langvalue = fe.options[fe.selectedIndex].value ;
		cookiestring = cookiestring + elid + "~" +langvalue + ";" ;
	
	}
	
	if (elid.indexOf ("radfemale") >= 0) {
	    var fe = document.getElementById (elid) ;
		if (fe.checked )
		{
		gendervalue = fe.value ;
		cookiestring = cookiestring + elid + "~" + gendervalue + ";" ;
		}	
	}
	
	if (elid.indexOf ("radmale") >= 0) {
	    var fe = document.getElementById (elid) ;
		if (fe.checked )
		{
		gendervalue = fe.value ;
		cookiestring = cookiestring + elid + "~" + gendervalue + ";" ;
		}	
	}
	
	if (elid.indexOf ("radnone") >= 0) {
	    var fe = document.getElementById (elid) ;
		if (fe.checked )
		{
		gendervalue = "" ;
		cookiestring = cookiestring + elid + "~" + gendervalue + ";" ;
		}	
	}
	
	if (elid.indexOf ("keyword") >= 0 ) {
	    var fe = document.getElementById (elid) ;
		
		keywordvalue = fe.value ;
		cookiestring = cookiestring + elid + "~" + keywordvalue + ";" ;
		
	}
	//if (elid.indexOf ("acceptingnew") >= 0 ) {
	//    var fe = document.getElementById (elid) ;
	//	if (fe.checked )
	//	{
	//	acceptingvalue = "Yes" ;
//		cookiestring = cookiestring + elid + "~" + acceptingvalue + ";" ;
//		}	
//	}
	if (elid.indexOf ("zip") >= 0) {
	    var fe = document.getElementById (elid) ;
		
		zipvalue = fe.value ;
		if (zipvalue.length == 5)
		{
		    var se = document.getElementById ("radius") ;
		
		    radiusvalue = se.options[se.selectedIndex].value ;
		    
		    cookiestring = cookiestring + elid + "~" + zipvalue + ";radius~" + radiusvalue  ;
		
		}
		else
		{
		    zipvalue = "";
		}		
		
	}
	
	
			
} // for next?




if (specvalue !== "") {
	// + "[specialties] like '**" + escape(specvalue) + "**' and " ;
	searchstring = searchstring + " recordid in (select recordid from trelateditems where relatedtablename = 'toptions' and (relatedgroup = 'Specialty' or relatedgroup = 'SecondarySpecialty' ) and masterlistid = 42 and relatedid in (select optionid from toptions where longname = '" + specvalue + "')) and " ;
}

if ((lnamevalue !== "") && (lnamevalue !== "Dr. Name")) {
   
    
	//searchstring = searchstring + "[lastname] like '" + lnamevalue.replace("'","''") + "%' and " ;
	searchstring = searchstring + " ( [lastname] like '" + lnamevalue.replace("'","''") + "%' or [firstname] like '" + lnamevalue.replace("'","''") + "%') and " ;
}

if (langvalue !== "") {
	//searchstring = searchstring + "[locations] like '**" + locvalue + "**' and " ;
	 searchstring = searchstring + " recordid in (select recordid from trelateditems where relatedtablename = 'toptions' and relatedgroup = 'Language' and masterlistid = 42 and relatedid in (select optionid from toptions where longname = '" + escape(langvalue) + "')) and " ;
}
if ((keywordvalue !== "") && (keywordvalue !== "Keyword"))
{
    searchstring = searchstring + "  ( [bio] like '%" + keywordvalue.replace("'","''") + "%' or [ClinicalInterest] like '%" + keywordvalue.replace("'","''") + "%' or [lastname] like '%" + keywordvalue.replace("'","''") + "%' or [firstname] like '%" + keywordvalue.replace("'","''") + "%' or  recordid in (select recordid from trelateditems where relatedtablename = 'toptions' and (relatedgroup = 'Specialty' or relatedgroup = 'SecondarySpecialty' ) and masterlistid = 42 and relatedid in (select optionid from toptions where longname = '" + keywordvalue.replace("'","''") + "')) ) and ";
    //[ClinicalInterest] like '%" + keywordvalue.replace("'","''") + "%'
    //or  recordid in (select recordid from trelateditems where relatedtablename = 'toptions' and (relatedgroup = 'Specialty' or relatedgroup = 'SecondarySpecialty' ) and masterlistid = 42 and relatedid in (select optionid from toptions where longname = '" + escape(keywordvalue) + "'))
    //or [lastname] like '%" + keywordvalue.replace("'","''") + "%' or [firstname] like '%" + keywordvalue.replace("'","''") + "%'
}
if (acceptingvalue !== "")
{
    searchstring = searchstring + "[acceptingnew] like '%Yes%' and " ;
}

if (gendervalue !== "")
{
    searchstring = searchstring + "[gender] = '" + gendervalue + "' and " ;
}


// and
searchstring = searchstring.substr(0,searchstring.length - 4) ;


//turn off cookie handling
//SetCookie ("s",cookiestring) ;



searchstring = encodeURIComponent(searchstring);
q = "/ui/ajaxgetrows.aspx?searchstring=" + searchstring + "&page=" + num + "&sort=" + sort;
//alert(q);

if (zipvalue !== "")
{
    q = q + "&zip=" + zipvalue + "&radius=" + radiusvalue ;   
}



var loader1 = new net.ContentLoader(q, searchaction,null,"GET","");	




} // end function


function searchaction ()
{


	var alldata = document.getElementById ("alltext") ;
	  // document.getElementById ("alltext").innerHTML = this.req.readyState ;
	  

	alldata.innerHTML = this.req.responseText ;	
	
	//sortables_init();	
	//alert(alldata.innerHTML);
//alert(this.req.responseText);
	dopages(pagenum) ;
}	

function dopages(pnum)
{

	//var nrecpages = document.getElementById ("numperpage") ;
	nperpage = 20 ;
    var newheight = 0 ;
    var filteredtotal = 0;


	beginslice = (pnum * nperpage) - nperpage + 1;
	endslice = (pnum * nperpage) ;

    if (document.getElementById("filteredrecs"))
	{
	filteredtotal = document.getElementById("filteredrecs").innerHTML ;
	
	}
    var trecs = document.getElementById ("trecs").innerHTML ;
    
	document.getElementById ("found").innerHTML =  filteredtotal + " of " + trecs + " doctors found";

	var tab = document.getElementById ("tableresults") ; //the all table
	var tbod = tab.getElementsByTagName("tbody");

	var trs = tbod[0].getElementsByTagName("tr") ;
	//var trs = tab.getElementsByTagName("tr") ;
		
	r=0;
	
	for (i=0;i < trs.length; i++) {
	
		// alternate rows here		
		if (i % 2 == 0)
		{
		trs[i].style.backgroundColor = "#edefe4";		
		}
		else
		{
		trs[i].style.backgroundColor = "#dcdec9";
		}
			
		r++;		
	} // for

	
		
// assume on first page
       
        newheight = nperpage * 53 ;
		if (nperpage == 5000) {
			
			newheight = 0;
			newheight = r * 55 ;
		}
        
        
		totalpages = Math.ceil (filteredtotal / nperpage)  ;
		
		// size adjust
		var alldata = document.getElementById ("alltext") ;
		//alldata.style.height = newheight + "px" ;
		alldata.style.height = "95%";
		
		if (totalpages > 1) {
			if ((pagenum - 1) == 0) 
			{
				strpages = "<a id='previous' href=# onclick='return false;' >&laquo; </a>"
			}
			else
			{
				strpages = "<a id='previous' href=# onclick=\"runsearch(" + (pagenum - 1) + ",'" + friendlysort + "');return false;\" >&laquo; </a>"
			}
		}
		else {
		strpages = "";
		}

		strpages = strpages + "&nbsp;pg&nbsp;" + pagenum + "&nbsp;of&nbsp;" + totalpages + "&nbsp;" ;


		if (totalpages > 1) 
		{
			if ((pagenum + 1) > totalpages)
			{
				strpages = strpages + "<a id='next' href='#' onclick = 'return false;' >&raquo;</a>";
			}
			else
			{
				strpages = strpages + "<a id='next' href='#' onclick = \"runsearch(" + (pagenum + 1) + ",'" + friendlysort + "'); return false;\" >&raquo;</a>";
			}
		}
       
		document.getElementById("pager").innerHTML = strpages;
        document.getElementById("pager2").innerHTML = strpages;
			
	

}




function setMyTimer(sAction, timeOut, timerID) {
		if (timerID) stopMyTimer(timerID);
		return (window.setTimeout(sAction, timeOut));
	}

	function stopMyTimer(timerID) {
		window.clearTimeout(timerID);
	}


var ftimerID = 0;
	var fadeRate = 10;
	var fadeStep = 10;

	function opacity_changeNset(targetOpacity,id) {
		var opacity = getOpacity(id);
		if (targetOpacity>opacity) {
			setOpacity(opacity += fadeStep,id);
			ftimerID = setMyTimer("opacity_changeNset(\""+targetOpacity+"\",\""+id+"\");",
					 fadeRate, ftimerID);
		} else
			stopMyTimer(ftimerID);
	}



function setOpacity(opacity, id) { 
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100); 
	object.MozOpacity = (opacity / 100); 
	object.KhtmlOpacity = (opacity / 100); 
	object.filter = "alpha(opacity=" + opacity + ")";
}

function getOpacity(id) {
	var object = document.getElementById(id).style; 
	if (object.opacity) return (object.opacity*100);
	return (100);
}


function closepopup() {

	document.getElementById ("popup").style.top = "-650px";
	//document.getElementById("numperpage").style.visibility = 'visible';
	setOpacity(100,"wholetable") ;
}


function setLyr(obj1,lyr)
{
	obj = document.getElementById (obj1) ;
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	
	var x = document.getElementById(lyr);
	x.style.top = (newY + 13) + 'px';
	x.style.left = newX + 'px';
	//x.style.backgroundColor = "whitesmoke";
	//window.setTimeout ("closerv();",8000);
	
	
	
}
function setLyr2(obj1,lyr)
{
	obj = document.getElementById (obj1) ;
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	
	var x = document.getElementById(lyr);
	x.style.top = (newY - 50) + 'px';
	x.style.left = (newX + 170) + 'px';
	//x.style.backgroundColor = "whitesmoke";
	//window.setTimeout ("closerv();",8000);
	
	
	//document.getElementById("numperpage").style.visibility = 'hidden';
}

function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }



function closerv() {
	var r = document.getElementById ("rv") ;
	r.style.left = "-600px";
	r.style.top = "-200px" ;
}



function doaddcompare(id) {
	var sfullname = "";
	tr = document.getElementById("r" + id) ;
	tds = tr.getElementsByTagName("td") ;
	if (browser.IsIE) {
		sfullname = tds[1].innerText ;
	}
	else
	{
		sfullname = tds[1].textContent ;
	}
	
	
	var strParams = "recid=" + id + "&sfullname=" + sfullname ;
	
    var loader2 = new net.ContentLoader("/UI/ajaxaddcompare.aspx?" + strParams, updatedisplay,null,"GET","");	
    

}
function doaddcompare2(id, sfullname) {

	var strParams = "recid=" + id + "&sfullname=" + sfullname ;
    var loader1 = new net.ContentLoader("/UI/ajaxaddcompare.aspx?" + strParams, updatedisplay,null,"POST","");	

}

function updatedisplay() {
	// change controls on other pages //ABOVE TO
    var d = document.getElementById("ctl00_ContentPlaceHolder1_FindDoctor1_compareto");
	
	d.innerHTML = this.req.responseText;
}

function SetCookie(sName, sValue)
{
  date = new Date()  ;
  var m = date.getMinutes ();
  m += 3;
  date.setMinutes (m);
  document.cookie = sName + "=" + escape(sValue) + "; expires=" + date.toGMTString();
  //alert(sValue);
}
function GetCookie(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}

function setSearchValues ()
{


        
		var wholevalue = new String() ;
		wholevalue = GetCookie("s");
		
		
		
		
		if (wholevalue !== null)
		{
			wholevalue = wholevalue.substring (0, wholevalue.length - 1) ; // last semi
			arwhole = wholevalue.split (";");
			
			for (i=0;i<arwhole.length;i++)
			{
				arval = arwhole[i].split("~") ;
				
				
				if (arval.length == 2)
				{
					field = arval[0] ;
					val = arval[1] ;
					
					el = document.getElementById(field) ;
					
					if (el.type == "select-one")
					{
							for (t=0;t<el.options.length;t++) 
							{
								
								if (el.options[t].value == val )
								{
									el.options[t].selected = true;
								}
								
							}
					}
					else if (el.type == "text")
					{
						el.value = val ;
					}
					else if (el.type == "checkbox")
					{
					    
						if (val=="Yes")
						{
							el.checked = true;
						}
						else
						{
							el.checked = false;
						}
						
						
					}
					else if (el.type == "radio")
					{
						if (val=="Male")
						{
							el.checked = true;
						}
						else if (val == "Female")
						{
						    el.checked = true ;
						}
						else
						{
							el.checked = true;
						}
					}
					else { 
					
				    }		
			
			    }
		
		    }
		
		}
		

		keyword = getQueryVariable("keyword") ;
			
		if (keyword !== "")
		{
		    document.getElementById("keyword").value = keyword ;
		}
		
		lname = getQueryVariable("lname") ;
		

		if(lname !== "")
		{
		    el = document.getElementById("lname")	;	    
		    el.value = unescape(lname) ;			
		    
		}
		
		gender = getQueryVariable("gender") ;
		
		if (gender !== "")
		{
		
		     if (gender == "Male")
		     {
		         el = document.getElementById("radmale");		    
		         el.checked = true;
		     }
		     else if (gender == "Female")
		     {
		        el = document.getElementById("radfemale") ;		    
		         el.checked = true;
		     }
		     else
		     {
		         el = document.getElementById("radnone") ;		    
		         el.checked = true;
		     }
		     
		    
		}
		
		
		//acceptingnew = getQueryVariable("accnew") ;
		//if (acceptingnew !== "")
		//{
		//    el = document.getElementById("acceptingnew") ;
		//    if (acceptingnew == "Yes")
		//    {
		 //       el.checked = true ;
		 //   }
		//}
		 val = getQueryVariable("specialty");
		
		if(val !== "")
		{
		    el = document.getElementById(findControl("specialty")) ;		 
		    if (val == "None")
		    {
		        val = "";
		    }
		   	for (t=0;t<el.options.length;t++) 
			{
				if (el.options[t].value == unescape(val) )
				{
			    	el.options[t].selected = true;
				}				
			}	    
		}
		
		
	//	radius = getQueryVariable("radius") ;
	//	if (radius !== "")
	//	{
	//	    el = document.getElementById("radius") ;		 
		    
	//	   	for (t=0;t<el.options.length;t++) 
	//		{
	//			if (el.options[t].value == unescape(val) )
	//			{
	//		    	el.options[t].selected = true;
	//			}				
	//		}
	//	}
		
		
		
		
}
