version=0; if (navigator.appVersion.indexOf("MSIE")!=-1){ temp=navigator.appVersion.split("MSIE"); version=parseFloat(temp[1]); } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } // preload images function preload() { if (document.images) { preload_image_object = new Image(); var images = new Array(); images.push("/images/SubNav.bottomcap.png"); images.push("/images/SubNav.bg.png"); images.push("/images/SubNav.bg.hover.png"); images.push("/images/InfoWindow-Map.btm.png"); images.push("/images/InfoWindow-Map-Area.btm.png"); images.push("/images/infoWindow.Map-top.png"); images.push("/images/InfoWindow-Map-Area.png"); images.push("/images/InfoWindow-Map.top.png"); images.push("/images/InfoWindow-Map-Area.top.png"); images.push("/images/loading.gif"); for(i=0; i< images.length; i++) { preload_image_object.src = images[i]; } } } // basic functions for general use function rand ( n ) { return ( Math.floor ( Math.random ( ) * n + 1 ) ); } function byte2Hex(n) { var nybHexString = "0123456789ABCDEF"; return String(nybHexString.substr((n >> 4) & 0x0F,1)) + nybHexString.substr(n & 0x0F,1); } function RGB2Color(r,g,b) { return '#' + byte2Hex(r) + byte2Hex(g) + byte2Hex(b); } // function to strip slashes function stripslashes( str ) { return str.replace('/\0/g', '0').replace('/\(.)/g', '$1'); } // function to add commas function addCommas(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } function addSelectOption(field,text,value,id,selected) { var elOptNew = document.createElement('option'); elOptNew.text = text; elOptNew.value = value; elOptNew.id = id; if(selected) { elOptNew.selected = selected; } try { document.getElementById(field).add(elOptNew, null); } catch(ex) { document.getElementById(field).add(elOptNew); } } // Feature Property Scroller functions for movement. var Timer = []; function stopScroll() { if(Timer) { for(var i = 0; i < Timer.length; i++) { clearInterval(Timer[i]); } } } function featureScrollLeft() { Timer.push(setInterval("$('FeatureScroller').scrollLeft -= 2", 15)); } function featureScrollRight() { Timer.push(setInterval("$('FeatureScroller').scrollLeft += 2", 15)); } // filter subdivision / city dropdowns function filterDiv(subdiv,formID) { if(subdiv == 'undefined') { var subdiv = false; } if(formID) { var subdivField = formID + "_subdiv"; var id = document.getElementById(formID + "_city").value; } else if(document.getElementById("Content-Residential").style.display != 'none') { var subdivField = "Residential_Search_subdiv"; var id = document.getElementById("Residential_Search_city").value; } else if(document.getElementById("Content-Land").style.display != 'none') { var subdivField = "Land_Search_subdiv"; var id = document.getElementById("Land_Search_city").value; } if(subdiv) { var subdivFields = ['Residential_Search_subdiv','Land_Search_subdiv']; } var opt = { method: 'post', postBody: "id=" + id, onSuccess: function(t) { if(subdiv) { for(var i = 0; i < subdivFields.length; i++) { populateSubdivFields(subdivFields[i],t.responseText,subdiv); } } else { populateSubdivFields(subdivField,t.responseText); } if(subdiv) { trackChanges(); } } } if(id != '') { new Ajax.Request('/call/dropdown.php', opt); } else { if(subdiv) { for(var i = 0; i < subdivFields.length; i++) { populateSubdivFields(subdivFields[i],"clear"); } } else { populateSubdivFields(subdivField,"clear"); } } } function populateSubdivFields(subdivField,data,subdiv) { $(subdivField).length = 0; if(data != 'clear') { var fetchedValues = eval(data); } if(fetchedValues && fetchedValues.length > 0) { addSelectOption(subdivField,"-- Any --","","",true) for(var si = 0; si < fetchedValues.length;si++) { var selValue = fetchedValues[si]; if(subdiv && subdiv == selValue.Name) { var selected = true; } else { var selected = false; } addSelectOption(subdivField,selValue.Title,selValue.Name,selValue.ID,selected) } } else if(data == "clear") { $(subdivField).length = 0; addSelectOption(subdivField,"-- Any --","","",true) } else { $(subdivField).length = 0; addSelectOption(subdivField,"-- None Found --","","",true) } } function switchTab(id) { var e = $('li-' + id).parentNode.childNodes; var liCount = 0; var liCountlength = 0; for (var i = 0; i < e.length; i++) { if(e[i].nodeName == 'LI') { liCountlength++; } } for (var i = 0; i < e.length; i++) { var el = e[i]; if(el.nodeName == 'LI') { if(el.id == "li-" + id) { if(liCount == 0) { var extraClass = " first-child"; } else if(liCount == liCountlength-1) { var extraClass = " last-child"; } else { var extraClass = ""; } } if (el.className == 'SelectedTab' || el.className == "SelectedTab first-child" || el.className == "SelectedTab last-child") { el.className = ''; if(liCount == 0) { el.className = "first"; } var name = el.id.replace("li-",""); $('Content-' + name).style.display = 'none'; } liCount++; } } $('li-' + id).className = 'SelectedTab' + extraClass; $('Content-' + id).style.display = ''; } function getObUpperLeft(obj) { var curLeft = curTop = 0; if (obj.offsetParent) { curLeft = obj.offsetLeft curTop = obj.offsetTop while (obj = obj.offsetParent) { curLeft += obj.offsetLeft curTop += obj.offsetTop } } return [curLeft,curTop]; } function wWidth() { var windowWidth= 0; if( typeof( window.innerWidth ) == 'number' ) { windowWidth = window.innerWidth; } else if( document.documentElement && ( document.documentElement.clientWidth ) ) { windowWidth = document.documentElement.clientWidth; } else if( document.body && ( document.body.clientWidth ) ) { windowWidth = document.body.clientWidth; } return windowWidth; } function wHeight() { var windowHeight = 0; if( typeof( window.innerWidth ) == 'number' ) { windowHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { windowHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { windowHeight = document.body.clientHeight; } return windowHeight; } function getYOffset() { var pageY; if(typeof(window.pageYOffset)=='number') { pageY=window.pageYOffset; } else { pageY=document.documentElement.scrollTop; } return pageY; } // login & signup screen function to show hide var openScreen = ''; function showScreen(div,id,gray) { if(openScreen) { var div = openScreen; } else { openScreen = div; } var windowWidth = wWidth(); var divLeft = (windowWidth / 2) - (Element.getWidth(div) / 2); var divTop = (wHeight() / 2) - (Element.getHeight(div) / 2) + getYOffset(); $(div).setStyle({ 'left': divLeft + "px", 'top': divTop + "px", 'display': 'block' }); $('GrayScreen').setStyle({ 'height': '100%', 'top': getYOffset() + "px", 'display': 'block' }); if(document.getElementById(div + "-iFrame")) { var divTag = document.getElementById(div); var iFrameTag = document.getElementById(div + "-iFrame"); iFrameTag.style.left = 0; iFrameTag.style.top = 0; iFrameTag.style.width = Element.getWidth(div); iFrameTag.style.height = Element.getHeight(div); iFrameTag.style.zIndex = divTag.style.zIndex-1; } Event.observe(window,'scroll', showScreen); } function hideScreen(div,gray) { document.getElementById(div).style.display = 'none'; var gray = true; if(gray) { document.getElementById("GrayScreen").style.display = 'none'; } Event.stopObserving(window, "scroll", showScreen); openScreen = null; } // signup form validation function echeck(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false } if (str.indexOf(at,(lat+1))!=-1){ return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false } if (str.indexOf(dot,(lat+2))==-1){ return false } if (str.indexOf(" ")!=-1){ return false } return true } function verifyAccountForm(id,notRequired) { var errors = 0; if ((document.getElementById(id + '-email').value != '' || notRequired != true) && echeck(document.getElementById(id + '-email').value) == false){ addError(id + '-email','Email Address'); errors = 1; } else { removeError(id + '-email'); } if (notRequired != true && document.getElementById(id + '-pass').value == ''){ addError(id + '-pass','Password'); errors = 1; } else if(document.getElementById(id + '-pass').value != '' && document.getElementById(id + '-pass').value.length < 4){ addError(id + '-pass','Password',null,1); errors = 1; } else { removeError(id + '-pass'); } if (document.getElementById(id + '-pass').value != '' && document.getElementById(id + '-verifyPass').value !== document.getElementById(id + '-pass').value){ addError(id + '-verifyPass','Password',1); errors = 1; } else { removeError(id + '-verifyPass','Password'); } if(notRequired != true) { if (document.getElementById(id + '-user').value == ''){ addError(id + '-user','Username'); errors = 1; } else if(document.getElementById(id + '-user').value.length < 3){ addError(id + '-user','Username',null,1); errors = 1; } else { removeError(id + '-user'); } } else { if (document.getElementById(id + '-oldPass').value== '' && document.getElementById(id + '-pass').value != ''){ addError(id + '-oldPass','Password'); errors = 1; } } if(errors == 0) { return true; } else { return false; } } function addError(id,value,passVerify,length) { document.getElementById("Error-" + id).style.display = 'block'; if(passVerify) { var text = "Your passwords do not match."; } else if(length) { var text = value + " must be 3 characters or more."; } else { var text = "Please enter a valid " + value; } Element.update("Error-" + id,text); } function removeError(id) { document.getElementById("Error-" + id).style.display = 'none'; } // function to show hide lists function showHideList(id) { if(document.getElementById(id).style.display != 'none') { document.getElementById(id).style.display = 'none'; Element.update("SH-" + id,"[+]"); } else { document.getElementById(id).style.display = 'block'; Element.update("SH-" + id,"[-]"); } } // Account functions function deleteSearch(id) { var opt = { method: 'post', postBody: "ID=" + id, onSuccess: function(t) { eval(t.responseText); Element.remove("Search-" + id); } } new Ajax.Request('/call/deleteSearch.php', opt); } function deleteProp(id) { var opt = { method: 'post', postBody: "ID=" + id, onSuccess: function(t) { eval(t.responseText); Element.remove("Prop-" + id); } } new Ajax.Request('/call/deleteProperty.php', opt); } // Zestimate API Call function getZestimate() { var street = document.getElementById("zestimate_street").value; var citystatezip = ''; if(document.getElementById("zestimate_city").value != '' && document.getElementById("zestimate_state").value != '') { citystatezip += document.getElementById("zestimate_city").value + ", " + document.getElementById("zestimate_state").value; } if(document.getElementById("zestimate_zip").value != '') { citystatezip += ", " + document.getElementById("zestimate_zip").value; } if(street != '' && citystatezip != '') { var opt = { method: 'post', postBody: "address=" + encodeURI(street) + "&citystatezip=" + encodeURI(citystatezip), asynchronous:true } new Ajax.Updater("ZestimateContent", '/call/getZestimate.php', opt); } else { Element.update("ZestimateContent","You must enter at least an Address & City to search for."); } } // Property List functions function switchPage(ListIdentifier,Page,Direction,Sort,Paginate,Content,ListCount,UpdateResultsNumberText,LoadImages) { if(!Paginate || Paginate == null || Paginate == undefined) { var Paginate = true; } var ListContent = 'ListContent_' + ListIdentifier; var Paginator = 'ListPaginator_' + ListIdentifier; var PaginatorPages = 'Pages_' + ListIdentifier; var PaginatorForm = 'PageList_' + ListIdentifier; var ListSortableHeader = 'PropertyListHead_' + ListIdentifier; var ListPopulated = document.getElementById('PropertyListPopulated_' + ListIdentifier).value; var ListOffset = document.getElementById('PropertyListOffset_' + ListIdentifier).value; var ListResults = document.getElementById('PropertyListResults_' + ListIdentifier).value; var ListPage = document.getElementById('PropertyListPages_' + ListIdentifier).value; var SortBy = document.getElementById('PropertyListSortBy_' + ListIdentifier).value; var Query = document.getElementById('PropertyListQuery_' + ListIdentifier).value; var OrderBy = document.getElementById('PropertyListOrderBy_' + ListIdentifier).value; document.getElementById(ListContent).scrollTop = 0; if(!ListResults) { var ListNumResults = 100; } else { var ListNumResults = ListResults; } var MaximumResultsPerPage = 100; if(ListPopulated == '1') { var ListResult = ''; if(!Page) { Page = 0; } if(Page == 0 && ListResults > MaximumResultsPerPage) { PageBegin = 0; PageLength = MaximumResultsPerPage; } else if(ListResults < 100) { PageBegin = 0; PageLength = ListResults; } else { PageBegin = Page * 100; if((PageBegin + 100) > ListResults) { PageLength = ListResults; } else { PageLength = PageBegin + 100; } } if(Direction) { var PageValue = parseFloat(document.getElementById(PaginatorPages).value); if(Direction == 1) { if((PageValue * MaximumResultsPerPage) > ListResults) { var NewPage = 0; } else { var NewPage = PageValue + 1; } } else if(Direction == 2) { if((PageValue - 1) >= 0) { var NewPage = PageValue - 1; } else { var NewPage = document.getElementById(PaginatorPages).length - 1; } } } else if(ListPopulated == '1' && Page) { var PageValue = Page; if((PageValue * MaximumResultsPerPage) > ListResults) { var select = document.PaginatorForm.page; var NewPage = select.options[select.length - 1].value; } else { NewPage = PageValue; } } document.getElementById('PropertyListPages_' + ListIdentifier).value = NewPage; document.getElementById('PropertyListOffset_' + ListIdentifier).value = NewPage * MaximumResultsPerPage; ListPages = NewPage; ListOffset = NewPage * MaximumResultsPerPage; document.getElementById(PaginatorPages).value = NewPage; } else if(!ListOffset) { ListOffset = '0'; } if(Sort) { document.getElementById('PropertyListPopulated_' + ListIdentifier).value = '0'; document.getElementById('PropertyListSortBy_' + ListIdentifier).value = Sort; if(SortBy == Sort && OrderBy == 'ASC') { var NewOrder = 'DESC'; } else { var NewOrder = 'ASC'; } SortBy = Sort; var sortables = document.getElementById(ListSortableHeader).lastChild.firstChild.childNodes; for(var i = 0; i < sortables.length; i++) { if(sortables[i].nodeName == "TD" && document.getElementById(sortables[i].id).getAttribute('class') == 'Sorted' && sortables[i].id != Sort) { sortables[i].className = ''; } else if(sortables[i].id == Sort) { sortables[i].className = 'Sorted';} } document.getElementById('PropertyListOrderBy_' + ListIdentifier).value = NewOrder; OrderBy = NewOrder; } if(!Content) { Element.update(ListContent,'