/*
* geo-location-javascript v0.4.2
* http://code.google.com/p/geo-location-javascript/
*
* Copyright (c) 2009 Stan Wiechers
* Licensed under the MIT licenses.
*
* Revision: $Rev: 66 $: 
* Author: $Author: whoisstan $:
* Date: $Date: 2010-01-10 08:27:48 -0500 (Sun, 10 Jan 2010) $:    
*/
var bb_successCallback;var bb_errorCallback;function handleBlackBerryLocation(){if(bb_successCallback&&bb_errorCallback){if(blackberry.location.latitude==0&&blackberry.location.longitude==0){bb_errorCallback({message:"Position unavailable",code:2})}else{var a=null;if(blackberry.location.timestamp){a=new Date(blackberry.location.timestamp)}bb_successCallback({timestamp:a,coords:{latitude:blackberry.location.latitude,longitude:blackberry.location.longitude}})}if(parseFloat(navigator.appVersion)>=4.6){blackberry.location.removeLocationUpdate(handleBlackBerryLocation)}bb_successCallback=null;bb_errorCallback=null}}var geo_position_js=function(){var b={};var a=null;b.getCurrentPosition=function(e,c,d){a.getCurrentPosition(e,c,d)};b.init=function(){try{if(typeof(geo_position_js_simulator)!="undefined"){a=geo_position_js_simulator}else{if(typeof(bondi)!="undefined"&&typeof(bondi.geolocation)!="undefined"){a=bondi.geolocation}else{if(typeof(window.google)!="undefined"&&typeof(window.google.gears)!="undefined"){a=google.gears.factory.create("beta.geolocation");b.getCurrentPosition=function(i,f,g){try{function d(e){if(typeof(e.latitude)!="undefined"){i({timestamp:e.timestamp,coords:{latitude:e.latitude,longitude:e.longitude}})}else{i(e)}}a.getCurrentPosition(d,f,g)}catch(h){f({message:h,code:1})}}}else{if(typeof(navigator.geolocation)!="undefined"){a=navigator.geolocation;b.getCurrentPosition=function(g,e,f){function d(h){if(typeof(h.latitude)!="undefined"){g({timestamp:h.timestamp,coords:{latitude:h.latitude,longitude:h.longitude}})}else{g(h)}}a.getCurrentPosition(d,e,f)};b.watchPosition=function(h,d,f){try{a.watchPosition(h,d,f);b.clearWatch=function(e){if(typeof(a.clearWatch)!="undefined"){a.clearWatch(e)}}}catch(g){d({message:g,code:1})}}}else{if(typeof(Mojo)!="undefined"&&typeof(Mojo.Service)!="undefined"&&typeof(Mojo.Service.Request)!="Mojo.Service.Request"){a=true;b.getCurrentPosition=function(f,d,e){parameters={};if(e){if(e.enableHighAccuracy&&e.enableHighAccuracy==true){parameters.accuracy=1}if(e.maximumAge){parameters.maximumAge=e.maximumAge}if(e.responseTime){if(e.responseTime<5){parameters.responseTime=1}else{if(e.responseTime<20){parameters.responseTime=2}else{parameters.timeout=3}}}}r=new Mojo.Service.Request("palm://com.palm.location",{method:"getCurrentPosition",parameters:parameters,onSuccess:function(g){f({timestamp:g.timestamp,coords:{latitude:g.latitude,longitude:g.longitude,heading:g.heading}})},onFailure:function(g){if(g.errorCode==1){d({code:3,message:"Timeout"})}else{if(g.errorCode==2){d({code:2,message:"Position Unavailable"})}else{d({code:0,message:"Unknown Error: webOS-code"+errorCode})}}}})}}else{if(typeof(device)!="undefined"&&typeof(device.getServiceObject)!="undefined"){a=device.getServiceObject("Service.Location","ILocation");b.getCurrentPosition=function(h,e,g){function f(j,k,i){if(k==4){e({message:"Position unavailable",code:2})}else{h({timestamp:null,coords:{latitude:i.ReturnValue.Latitude,longitude:i.ReturnValue.Longitude,altitude:i.ReturnValue.Altitude,heading:i.ReturnValue.Heading}})}}var d=new Object();d.LocationInformationClass="BasicLocationInformation";a.ILocation.GetLocation(d,f)}}else{if(typeof(window.blackberry)!="undefined"&&blackberry.location.GPSSupported){blackberry.location.setAidMode(2);b.getCurrentPosition=function(f,d,e){bb_successCallback=f;bb_errorCallback=d;if(parseFloat(navigator.appVersion)>=4.6){blackberry.location.onLocationUpdate(handleBlackBerryLocation)}else{blackberry.location.onLocationUpdate("handleBlackBerryLocation()")}blackberry.location.refreshLocation()};a=blackberry.location}}}}}}}}catch(c){if(typeof(console)!="undefined"){console.log(c)}}return a!=null};return b}();(function(){if(window.google&&google.gears){return}var a=null;if(typeof GearsFactory!="undefined"){a=new GearsFactory()}else{try{a=new ActiveXObject("Gears.Factory");if(a.getBuildInfo().indexOf("ie_mobile")!=-1){a.privateSetGlobalObject(this)}}catch(b){if((typeof navigator.mimeTypes!="undefined")&&navigator.mimeTypes["application/x-googlegears"]){a=document.createElement("object");a.style.display="none";a.width=0;a.height=0;a.type="application/x-googlegears";document.documentElement.appendChild(a)}}}if(!a){return}if(!window.google){google={}}if(!google.gears){google.gears={factory:a}}})();var MobileSearch=new function(){var i=false;var d=false;var b;var j;var l="(Radius Search)";function h(){d=true;b=document.getElementById("txtSearch");if(b!==null){j=b.getAttribute("title");if(b.value===""){b.value=j}}var m=document.getElementById("frmMobileSearch");if(m!==null){m.onsubmit=function(){c()}}}function a(m){try{var o=/^\d{1,2}\/\d{1,2}\/\d{4}$/;return o.test(m.value)}catch(n){}}function c(){try{var o=document.getElementById("hidSearchType");var m=document.getElementById("hidOpenHouseStartDtm");var p=document.getElementById("hidOpenHouseStopDtm");if(b!==null&&b.value==j){b.value=""}if(o!==null){o.value="radius";if(b!==null&&b.value.indexOf(l)<0){o.value=""}}if(m!==null&&!a(m)){m.value=""}if(p!==null&&!a(p)){p.value=""}}catch(n){}}function f(o){var n=o.coords.latitude.toFixed(2);var m=o.coords.longitude.toFixed(2);i=true;if(document.getElementById("hidLatitude")!==null){document.getElementById("hidLatitude").value=n}if(document.getElementById("hidLongitude")!==null){document.getElementById("hidLongitude").value=m}if(document.getElementById("hidSearchType")!==null){document.getElementById("hidSearchType").value="radius"}if(document.getElementById("liRadiusSearch")!==null){document.getElementById("liRadiusSearch").style.display="block"}if(document.getElementById("frmRadiusSearch")!=null){document.getElementById("frmRadiusSearch").submit()}}function k(n){if(typeof(n.message)!=="undefined"&&n.message!=null){var m=n.message.toString();if(m.length>0&&m.indexOf("permission")==-1){alert(m)}}}function g(){document.location.href="http://gears.google.com/?action=install&message=Welcome to Google Gears Installation&return="+document.location.href}function e(){if(!window.google||!google.gears){i=false;if(confirm("Google Gears required to search near your location:\nInstall?")){g()}}}this.setGeolocationAvailable=function(m){var n=document.getElementById("liRadiusSearch");if(n!==null){if(m){n.style.display="list-item"}else{n.style.display="none"}}};this.setOpenHouseDate=function(m){try{document.getElementById("hidSearchType").value="";var q=parseInt(m.options[m.selectedIndex].value);var n=new Date();n.setDate(n.getDate()+q);var p=(n.getMonth()+1)+"/"+n.getDate()+"/"+n.getFullYear();document.getElementById("hidOpenHouseStopDtm").value=p}catch(o){}};this.maskOff=function(){if(b!==null&&b.value==j){b.value=""}};this.changeSearchType=function(){if(b&&b.value.indexOf(l)<0&&document.getElementById("divRadius")){document.getElementById("divRadius").style.display="none"}if(b&&b.value==""){b.value=j}};this.initializeCurrentLocation=function(){if(geo_position_js.init()){geo_position_js.getCurrentPosition(f,k,{timeout:30000})}else{e()}};this.submitRadiusSearch=function(){this.initializeCurrentLocation()};if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);h()},false)}else{if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);h()}});if(document.documentElement.doScroll&&window==window.top){(function(){if(d){return}try{document.documentElement.doScroll("left")}catch(m){setTimeout(arguments.callee,0);return}h()})()}}}};