var desc="";
var prev_eid="";
var prev_arrow="";
var catbox="";
var cid2="";
var catbox2="";
var catbox2_prev="";
var cat_home_page="";
var state="";
var state_page="";
var flag="";
var state_name_c="";

//////////////////////////////////////////////////////////////////////////////
function show_state(state,state_name){
var page_jump="http://usaseniorhousing.com/senior_living/" + state + "_senior_housing.html";
window.location=page_jump;
}
//////////////////////////////////////////////////////////////////////////////
function show_map(state,state_name){
document.getElementById('msg_box').innerHTML="";
document.getElementById('map_copy').innerHTML="";

page_header="<table width=749 border=0><tr>";

state_name_c = state_name;
flag="<img src='http://usaseniorhousing.com/img/flags/" + state + ".gif'>";
usa_map = "<a href='http://usaseniorhousing.com/'><img src='http://usaseniorhousing.com/img/map/usa_map136w.gif' border='0' style='float:right;'></a>";

page_header_end="</table>";

//document.getElementById('map_title').innerHTML=flag + state_name_c + "<div style='float:right;'><a href='http://usaseniorhousing.com'><img src='http://usaseniorhousing.com/img/map/usa_map136w.gif' border='0'></a></div>";

document.getElementById('page_desc').innerHTML = "";


document.getElementById('map_title').innerHTML =
 page_header +
 "<td valign='top'>" +
 flag + "</td><td valign='top' style='font-size:22pt;width:500px;color:#000077; padding-top:5px;'>" +
 state_name_c + "</td><td>" +
 usa_map + "</td></tr>" +
 page_header_end;

document.getElementById('boxcontent').style.width="100%";
document.getElementById('map_box').style.visibility="hidden";
document.getElementById('map_box').innerHTML=" ";
}
//////////////////////////////////////////////////////////////////////////////
function show_listing(state,state_name){
show_map(state,state_name);
t_url="http://usaseniorhousing.com/cgi-bin/map.pl?state_name=";
t_url += state_name;
t_url += "&state_sel=";
t_url += state;
t_url += "&action=get_listing";
loadXMLDoc(t_url,"get_listing");
}
//////////////////////////////////////////////////////////////////////////////
function loadXMLDoc(url,tid,param1){
vtid=tid;
if(vtid == "get_ads"){
    t_url="http://usaseniorhousing.com/cgi-bin/housing_admin.pl?action=get_zoned_ads&state_sel=";
    t_url += param1;
    url=t_url;
    }

	var xmlHttp;
	try{xmlHttp=new XMLHttpRequest();}
		catch (e){
	try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
	catch (e){
		try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
		catch (e){alert("Your browser does not support AJAX!");
        	return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        if(vtid == "get_cities" && xmlHttp.readyState==4){
            //document.getElementById('map_copy').innerHTML=xmlHttp.responseText;
            document.getElementById('map_title').innerHTML=flag + state_name_c + "<div style='float:right;'><img src='http://usaseniorhousing.com/img/map/usa_map136w.gif'></div>";
            document.getElementById('map_copy').innerHTML=xmlHttp.responseText;
            }
        if(vtid == "get_listing" && xmlHttp.readyState==4){
            //document.getElementById('sh_listing').innerHTML=xmlHttp.responseText;
            var results=xmlHttp.responseText;
            var mySplitResult = results.split("||");
            document.getElementById('map_area').innerHTML=mySplitResult[0];
            document.getElementById('zoned_ads').innerHTML=mySplitResult[1];
            }
        if(vtid == "get_listing_state" && xmlHttp.readyState==4){
            //document.getElementById('sh_listing').innerHTML=xmlHttp.responseText;
            var results=xmlHttp.responseText;
            var mySplitResult = results.split("||");
            document.getElementById('property_list').innerHTML=mySplitResult[0];
            //document.getElementById('zoned_ads').innerHTML=mySplitResult[1];
            }


        if(vtid == "get_ads" && xmlHttp.readyState==4){
            document.getElementById('zoned_ads').innerHTML=xmlHttp.responseText;
            }
        }
        }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

////////////////////////////////////////////////////////////////////////////////////////////
function fixH(one,two) {
if (document.getElementById(one)) {
    var lh=document.getElementById(one).offsetHeight;
    var rh=document.getElementById(two).offsetHeight;
    var nh = Math.max(lh, rh);
    var nh2 = Math.max(580, nh);
    document.getElementById(one).style.height=nh2+"px";
    document.getElementById(two).style.height=nh2+"px";
    }
}
//////////////////////////////////////////////////////////////////////////////
function SetCookie(name,value,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 path="/";
 secure="false";

 document.cookie = name+"="+escape(value)
                 + ";expires="+expire.toGMTString()
                 + ";path=/";


}
////////////////////////////////////////////////////////////////////////////////////////////
