// JavaScript Document
_mSvgEnabled = true ;
_mSvgForced  = true ;

var center ;
var centerLat;
var centerLng;
var marker = [] ;
var line ;
var geocoder ;
var icon ;
var map;
var visi = 'visible';
var visi2 = 'visible';
var visic ='visible';
var visic2 ='visible';
var marcadores = new Array();
var availabilities = new Array();
var list;

var xmlobj = null;
var city_data = null;
var region_data = null;
var country_data = null;

var forward_page = '';
var forward_var1 = null;
var forward_var2 = null;
var found = true;
   


function initMap() {
	document.getElementById('region_select').options.length = 0;
	document.getElementById('region_select').options[0] = createDefaultOption('country first');
	document.getElementById('city_select').options.length = 0;
	document.getElementById('city_select').options[0] = createDefaultOption('region first');
				vals['country']=null;
     var latLng = new google.maps.LatLng(38.79999900, -97.76999700);
     var homeLatLng = new google.maps.LatLng(38.79999900,-97.76999700);

     var map = new google.maps.Map(document.getElementById('map_canvas'), {
       zoom: 2,
       center: latLng,
       mapTypeId: google.maps.MapTypeId.ROADMAP
     });
	var image = '/icons/orange.png';
	var letter = 150;
     //var marker = new MarkerWithLabel({
     //  position: homeLatLng,
     //  map: map,
	 //  icon: image,
    //   draggable: true,
    //   raiseOnDrag: true,
    //   labelContent: letter,
    //   labelAnchor: new google.maps.Point(11, 20),
    //   labelClass: "labels", // the CSS class for the label
    //   labelInBackground: false
    // });

    // var iw = new google.maps.InfoWindow({
       content: "Home For Sale"
    // });
   //  google.maps.event.addListener(marker, "mouseover", function (e) { iw.open(map, this); });
	 changeCountries();
   }
   function log(h) {
     document.getElementById("log").innerHTML += h + "<br />";
   }
   

function centerMapLL(lat, lon, zoom) {
    var myLatlng = new google.maps.LatLng(lat,lon);
    var myOptions = {
      zoom: zoom,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
    
  }
  
function loadMapLL(lat, lng,zoom)
{
 map = new GMap2(document.getElementById("map"));
 centerMapLL(lat,lng,zoom);
 //map.addControl(new GSmallMapControl());
 map.addControl(new GMapTypeControl());
 //map.addControl(new GScaleControl()) ;
 map.addControl(new GLargeMapControl3D()) ;
 icon = new GIcon();
 icon.iconSize = new GSize(25, 25);
 icon.shadowSize = new GSize(25, 25);
 icon.iconAnchor = new GPoint(6, 20);
 icon.infoWindowAnchor = new GPoint(11, 11);
 geocoder = new GClientGeocoder() ;
 marcadores = new Array();
 list = document.getElementById("aptbody");
}





var objs = [];
objs['city']=null;
objs['region']=null;
objs['country']=null;
var vals = [];
vals['city']=null;
vals['region']=null;
vals['country']=null;


// send http POST request with custom xmlobj
function sendRequest2(obj, doc, func, url_enc_param){
    if(objs[obj]!=null&&objs[obj].readyState!=0&&objs[obj].readyState!=4){
        objs[obj].abort();
    }
    try{
        objs[obj]=new XMLHttpRequest();
	//alert('standard mozilla ajax');

    }
    catch(e){
        try{
            objs[obj]=new ActiveXObject('Microsoft.XMLHTTP');
        }
        catch(e){
            objs[obj]=null;
            return false;
		//alert('no ajax');
        }
    }
    objs[obj].onreadystatechange=func;
    objs[obj].open('POST',doc,true);
	objs[obj].setRequestHeader('Content-Type','application/x-www-form-urlencoded');

    objs[obj].send(url_enc_param);
}




function cityHandler() {
    if(objs['city'].readyState==4){
        if(objs['city'].status==200){
			//alert(objs['city'].responseText);
			city_data = eval( objs['city'].responseText );
			if(city_json!=null){
				city_data = city_json;
				var sel = document.getElementById('city_select');
				sel.options.length = 0;
				sel.options[0] = createDefaultOption('city');
				for(var i=1; i <= city_data.cities.length; i++) {
					var option = document.createElement("OPTION");
					option.value = city_data.cities[i-1].id;
					option.text = city_data.cities[i-1].name;
					//alert(vals['city']);
					if(vals['city']!=null) {
						if(vals['city'] == option.value) {
							option.selected = 'selected';
							sel.selectedIndex = i-1;
						}
					}
					sel.options[i] = option;
				}
				vals['city']=null;
			}
        }
    }
}

function regionHandler() {
    if(objs['region'].readyState==4){
        if(objs['region'].status==200){
			//alert(objs['region'].responseText);
			region_data = eval( objs['region'].responseText );
			if(region_json!=null) {
				region_data = region_json;
				var sel = document.getElementById('region_select');
				sel.options.length = 0;
				sel.options[0] = createDefaultOption('region');
				for(var i=1; i <= region_data.regions.length; i++) {
					var option = document.createElement("OPTION");
					option.value = region_data.regions[i-1].id;
					option.text = region_data.regions[i-1].name;
					if(vals['region']!=null) {
						if(vals['region'] == option.value) {
							option.selected = 'selected';
							sel.selectedIndex = i-1;
						}
					}
					sel.options[i] = option;
				}
				document.getElementById('city_select').options.length = 0;
				document.getElementById('city_select').options[0] = createDefaultOption('region first');
				vals['region']=null;
			}
        }
    }
}

function countryHandler() {
    if(objs['country'].readyState==4){
        if(objs['country'].status==200){
			//alert(objs['country'].responseText);
			country_data = eval( objs['country'].responseText );
			if(country_json!=null) {
				country_data = country_json;
				var sel = document.getElementById('country_select');
				sel.options.length = 0;
				sel.options[0] = createDefaultOption('country');
				for(var i=1; i <= country_data.countries.length; i++) {
					var option = document.createElement("OPTION");
					option.value = country_data.countries[i-1].id;
					option.text = country_data.countries[i-1].name;
					if(vals['country']!=null) {
						if(vals['country'] == option.value){
							option.selected = 'selected';
							sel.selectedIndex = i-1;
						}
					}
					sel.options[i] = option;
				}
				document.getElementById('region_select').options.length = 0;
				document.getElementById('region_select').options[0] = createDefaultOption('country first');
				document.getElementById('city_select').options.length = 0;
				document.getElementById('city_select').options[0] = createDefaultOption('region first');
				vals['country']=null;
			}
        }
    }
}


function changeCountries() {
	//alert(world_id);
	sendRequest2('country', 'db_city_var.asp?type=COUNTRY&country_id=254', countryHandler, 'type=COUNTRY&country_id=254');
}

function changeRegions(country_id) {
	sendRequest2('region', 'db_city_var.asp?type=REGION&country_id='+country_id+'', regionHandler, 'type=REGION&country_id=254');
	if(country_id!=-1) {
		try {
			for(var i=0; i<country_data.countries.length;i++) {
				if(country_data.countries[i].id == country_id) {
					centerMapLL(country_data.countries[i].latitude,country_data.countries[i].longitude,3);
					break;
				}
			}
		}catch(e){}
	}
}

function changeCities(region_id) {
	sendRequest2('city', 'db_city_var.asp?type=CITY&region_id='+region_id+'', cityHandler, 'type=CITY&region_id=123');
    if(region_id!=-1) {
		try {
			for(var i=0; i<region_data.regions.length;i++) {
				if(region_data.regions[i].id == region_id) {
					centerMapLL(region_data.regions[i].latitude,region_data.regions[i].longitude,6);
					break;
				}
			}
		}catch(e){}
    }
}

function centerCity(city_id) {
	if(city_id !=-1) {
		for(var i=0; i<city_data.cities.length;i++) {
			if(city_data.cities[i].id == city_id) {
				document.mapsearch.city_file.value = city_data.cities[i].fname;
				//document.mapsearch.city_file.value = city_data.cities[i].fname.replace('homes-for-rent','cities');
				centerMapLL(city_data.cities[i].latitude,city_data.cities[i].longitude,10);
				break;
			}
		}
	}
}



function createDefaultOption(opt) {
	var option = document.createElement("OPTION");
	option.text = 'Select a '+opt;
	option.value = -1;
	return option;
}

function addCook() {

	var bed_min = document.getElementById("bed_min");
	var bed_min2 = bed_min.options[bed_min.selectedIndex].value;
	var bed_max = document.getElementById("bed_max");
	var bed_max2 = bed_max.options[bed_max.selectedIndex].value;
	var bath_min = document.getElementById("bath_min");
	var bath_min2 = bath_min.options[bath_min.selectedIndex].value;
	var bath_max = document.getElementById("bath_max");
	var bath_max2 = bath_max.options[bath_max.selectedIndex].value;
	var rate_min = document.getElementById("rate_min");
	var rate_min2 = rate_min.options[rate_min.selectedIndex].value;
	var rate_max = document.getElementById("rate_max");
	var rate_max2 = rate_max.options[rate_max.selectedIndex].value;
	var dist_min = '0';
	var dist_max = '6000';
	document.cookie = "bed_min=" + bed_min2; 
	document.cookie = "bed_max =" + bed_max2; 
	document.cookie = "bath_min=" + bath_min2; 
	document.cookie = "bath_max =" + bath_max2; 
	document.cookie = "rate_min=" + rate_min2; 
	document.cookie = "rate_max =" + rate_max2;
	document.cookie = "Dist_min=" + dist_min; 
	document.cookie = "Dist_max =" + dist_max;
    
}

function goto() {
	var cit_file = document.mapsearch.city_file.value;
	//var cit = document.getElementById("city_select");
    //var cit2= cit.options[cit.selectedIndex].text.replace(/ /g, "-");
    //var reg = document.getElementById("region_select");
    //var reg2= reg.options[reg.selectedIndex].text.replace(/ /g, "-");
   // var coun = document.getElementById("country_select");
    //var coun2= coun.options[coun.selectedIndex].text.replace(/ /g, "-");
	//var bed_min = document.getElementById("bed_min");
	//var bed_min2 = bed_min.options[bed_min.selectedIndex].value;
	//var bed_max = document.getElementById("bed_max");
	//var bed_max2 = bed_max.options[bed_max.selectedIndex].value;
	//var bath_min = document.getElementById("bath_min");
	//var bath_min2 = bath_min.options[bath_min.selectedIndex].value;
	//var bath_max = document.getElementById("bath_max");
	//var bath_max2 = bath_max.options[bath_max.selectedIndex].value;
	//var rate_min = document.getElementById("rate_min");
	//var rate_min2 = rate_min.options[rate_min.selectedIndex].value;
	//var rate_max = document.getElementById("rate_max");
	//var rate_max2 = rate_max.options[rate_max.selectedIndex].value;
	//document.cookie = "bed_min=" + bed_min2; 
	//document.cookie = "bed_max =" + bed_max2; 
	//document.cookie = "bath_min=" + bath_min2; 
	//document.cookie = "bath_max =" + bath_max2; 
	//document.cookie = "rate_min=" + rate_min2; 
	//document.cookie = "rate_max =" + rate_max2;
    
    //if(cit.options[cit.selectedIndex].value != -1) {

        window.location = cit_file;
	//}
	//else if (coun != null) {
	//	window.location = 'country.jsp?country_id='+coun.options[coun.selectedIndex].value;
	//}
}


function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);



eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('8 t(c,b,a){2.3=c;2.2g=c.33;2.7=T.1m("1J");2.7.4.R="11: 1B; 17: 24;";2.q=T.1m("1J");2.q.4.R=2.7.4.R;2.q.1W("2H","1z v;");2.q.1W("2s","1z v;");2.Q=t.J(b)}t.u=U 6.5.3e();t.J=8(b){s a;9(A t.J.1y==="B"){a=T.1m("2X");a.4.R="11: 1B; z-2P: 2N; L: 14;";a.4.1r="-2E";a.4.1x="-2C";a.2B=b;t.J.1y=a}1z t.J.1y};t.u.2v=8(){s g=2;s m=v;s c=v;s f;s j,1h;s p;s d;s h;s o;s n=20;s i="2l("+2.2g+")";s k=8(e){9(e.2h){e.2h()}e.3d=G;9(e.2f){e.2f()}};s l=8(){g.3.2d(35)};2.1b().2b.Y(2.7);2.1b().2Z.Y(2.q);9(A t.J.25==="B"){2.1b().2b.Y(2.Q);t.J.25=G}2.1k=[6.5.r.N(2.q,"22",8(e){9(g.3.P()||g.3.X()){2.4.16="1X";6.5.r.C(g.3,"22",e)}}),6.5.r.N(2.q,"1U",8(e){9((g.3.P()||g.3.X())&&!c){2.4.16=g.3.2J();6.5.r.C(g.3,"1U",e)}}),6.5.r.N(2.q,"1S",8(e){c=v;9(g.3.P()){m=G;2.4.16=i}9(g.3.P()||g.3.X()){6.5.r.C(g.3,"1S",e);k(e)}}),6.5.r.N(T,"1p",8(a){s b;9(m){m=v;g.q.4.16="1X";6.5.r.C(g.3,"1p",a)}9(c){9(d){b=g.Z().1v(g.3.K());b.y+=n;g.3.I(g.Z().1M(b));2A{g.3.2d(6.5.2x.2u);2t(l,2r)}2q(e){}}g.Q.4.L="14";g.3.V(f);p=G;c=v;a.H=g.3.K();6.5.r.C(g.3,"1I",a)}}),6.5.r.w(g.3.1i(),"2p",8(a){s b;9(m){9(c){a.H=U 6.5.2o(a.H.1g()-j,a.H.1f()-1h);b=g.Z().1v(a.H);9(d){g.Q.4.15=b.x+"E";g.Q.4.O=b.y+"E";g.Q.4.L="";b.y-=n}g.3.I(g.Z().1M(b));9(d){g.q.4.O=(b.y+n)+"E"}6.5.r.C(g.3,"1H",a)}W{j=a.H.1g()-g.3.K().1g();1h=a.H.1f()-g.3.K().1f();f=g.3.1d();h=g.3.K();o=g.3.1i().2n();d=g.3.F("12");c=G;g.3.V(1G);a.H=g.3.K();6.5.r.C(g.3,"1F",a)}}}),6.5.r.N(T,"2m",8(e){9(c){9(e.2k===27){d=v;g.3.I(h);g.3.1i().2j(o);6.5.r.C(T,"1p",e)}}}),6.5.r.N(2.q,"1E",8(e){9(g.3.P()||g.3.X()){9(p){p=v}W{6.5.r.C(g.3,"1E",e);k(e)}}}),6.5.r.N(2.q,"2i",8(e){9(g.3.P()||g.3.X()){6.5.r.C(g.3,"2i",e);k(e)}}),6.5.r.w(2.3,"1F",8(a){9(!c){d=2.F("12")}}),6.5.r.w(2.3,"1H",8(a){9(!c){9(d){g.I(n);g.7.4.M=1G+(2.F("1a")?-1:+1)}}}),6.5.r.w(2.3,"1I",8(a){9(!c){9(d){g.I(0)}}}),6.5.r.w(2.3,"3c",8(){g.I()}),6.5.r.w(2.3,"3b",8(){g.V()}),6.5.r.w(2.3,"3a",8(){g.19()}),6.5.r.w(2.3,"39",8(){g.19()}),6.5.r.w(2.3,"37",8(){g.1A()}),6.5.r.w(2.3,"36",8(){g.1j()}),6.5.r.w(2.3,"34",8(){g.1c()}),6.5.r.w(2.3,"32",8(){g.18()}),6.5.r.w(2.3,"31",8(){g.18()})]};t.u.30=8(){s i;2.7.29.28(2.7);2.q.29.28(2.q);1K(i=0;i<2.1k.2Y;i++){6.5.r.2W(2.1k[i])}};t.u.2V=8(){2.1j();2.1A();2.18()};t.u.1j=8(){s a=2.3.F("1l");9(A a.2U==="B"){2.7.13=a;2.q.13=2.7.13}W{2.7.13="";2.7.Y(a);a=a.2S(G);2.q.Y(a)}};t.u.1A=8(){2.q.2R=2.3.2Q()||""};t.u.18=8(){s i,D;2.7.1t=2.3.F("1s");2.q.1t=2.7.1t;2.7.4.R="";2.q.4.R="";D=2.3.F("D");1K(i 2O D){9(D.2M(i)){2.7.4[i]=D[i];2.q.4[i]=D[i]}}2.21()};t.u.21=8(){2.7.4.11="1B";2.7.4.17="24";9(A 2.7.4.S!=="B"&&2.7.4.S!==""){2.7.4.1Z="1Y(S="+(2.7.4.S*2L)+")"}2.q.4.11=2.7.4.11;2.q.4.17=2.7.4.17;2.q.4.S=0.2K;2.q.4.1Z="1Y(S=1)";2.1c();2.I();2.19()};t.u.1c=8(){s a=2.3.F("1q");2.7.4.1r=-a.x+"E";2.7.4.1x=-a.y+"E";2.q.4.1r=-a.x+"E";2.q.4.1x=-a.y+"E"};t.u.I=8(a){s b=2.Z().1v(2.3.K());9(A a==="B"){a=0}2.7.4.15=1V.1T(b.x)+"E";2.7.4.O=1V.1T(b.y-a)+"E";2.q.4.15=2.7.4.15;2.q.4.O=2.7.4.O;2.V()};t.u.V=8(){s a=(2.3.F("1a")?-1:+1);9(A 2.3.1d()==="B"){2.7.4.M=2I(2.7.4.O,10)+a;2.q.4.M=2.7.4.M}W{2.7.4.M=2.3.1d()+a;2.q.4.M=2.7.4.M}};t.u.19=8(){9(2.3.F("1u")){2.7.4.L=2.3.2G()?"2F":"14"}W{2.7.4.L="14"}2.q.4.L=2.7.4.L};8 1n(a){a=a||{};a.1l=a.1l||"";a.1q=a.1q||U 6.5.2D(0,0);a.1s=a.1s||"2T";a.D=a.D||{};a.1a=a.1a||v;9(A a.1u==="B"){a.1u=G}9(A a.12==="B"){a.12=G}9(A a.1R==="B"){a.1R=G}9(A a.23==="B"){a.23=v}9(A a.1o==="B"){a.1o=v}a.1w=a.1w||"1Q://5.1P.1O/1N/2a/26/2z.2y";a.1D=a.1D||"1Q://5.1P.1O/1N/2a/26/2w.38";a.1o=v;2.2e=U t(2,a.1w,a.1D);6.5.1e.2c(2,1L)}1n.u=U 6.5.1e();1n.u.1C=8(a){6.5.1e.u.1C.2c(2,1L);2.2e.1C(a)};',62,201,'||this|marker_|style|maps|google|labelDiv_|function|if|||||||||||||||||eventDiv_|event|var|MarkerLabel_|prototype|false|addListener||||typeof|undefined|trigger|labelStyle|px|get|true|latLng|setPosition|getSharedCross|getPosition|display|zIndex|addDomListener|top|getDraggable|crossDiv_|cssText|opacity|document|new|setZIndex|else|getClickable|appendChild|getProjection||position|raiseOnDrag|innerHTML|none|left|cursor|overflow|setStyles|setVisible|labelInBackground|getPanes|setAnchor|getZIndex|Marker|lng|lat|cLngOffset|getMap|setContent|listeners_|labelContent|createElement|MarkerWithLabel|optimized|mouseup|labelAnchor|marginLeft|labelClass|className|labelVisible|fromLatLngToDivPixel|crossImage|marginTop|crossDiv|return|setTitle|absolute|setMap|handCursor|click|dragstart|1000000|drag|dragend|div|for|arguments|fromDivPixelToLatLng|intl|com|gstatic|http|clickable|mousedown|round|mouseout|Math|setAttribute|pointer|alpha|filter||setMandatoryStyles|mouseover|draggable|hidden|processed|mapfiles||removeChild|parentNode|en_us|overlayImage|apply|setAnimation|label|stopPropagation|handCursorURL_|preventDefault|dblclick|setCenter|keyCode|url|keydown|getCenter|LatLng|mousemove|catch|1406|ondragstart|setTimeout|BOUNCE|onAdd|closedhand_8_8|Animation|png|drag_cross_67_16|try|src|9px|Point|8px|block|getVisible|onselectstart|parseInt|getCursor|01|100|hasOwnProperty|1000002|in|index|getTitle|title|cloneNode|markerLabels|nodeType|draw|removeListener|img|length|overlayMouseTarget|onRemove|labelstyle_changed|labelclass_changed|handCursorURL|labelanchor_changed|null|labelcontent_changed|title_changed|cur|labelvisible_changed|visible_changed|zindex_changed|position_changed|cancelBubble|OverlayView'.split('|'),0,{}))
