google.load("maps","2",{other_params:"sensor=false"});CalBrowseLink=Class.create();CalBrowseLink.prototype={form:null,geocoder:null,controller:"/calendar",initialize:function(a){this.form=$(a);this.form.observe("submit",this.getGeoLocation.bindAsEventListener(this));this.geocoder=new google.maps.ClientGeocoder();if(google.loader.ClientLocation){this.clientLocation=google.loader.ClientLocation}this.eventType=$$("a.a_eventType");this.eventType.each(function(b){Event.observe(b,"click",this.changeEventType.bindAsEventListener(this))}.bind(this));if($("button_filter")){$("button_filter").observe("click",this.getGeoLocation.bindAsEventListener(this))}if($("a_homeLocation")){$("a_homeLocation").observe("click",this.processHomeLocation.bindAsEventListener(this))}},changeEventType:function(b){Event.stop(b);var e=$("calType").value;var h=Event.element(b).name;var l=$("location").value;var a=$("hidden_longitude").value;var i=$("hidden_latitude").value;var c=this.controller+"/"+e+"/"+h+"/?location="+l;if($("start").value){var f=Date.parse($("start").value);var k=new Date(f);var j=k.getFullYear();var d=k.getMonth();var g=k.getDate();c+="&year="+j+"&month="+d+"&day="+g}if(a&&i){c+="&lon="+a+"&lat="+i+"&loc="+$("form_location").value.strip()}window.location=c},changeLocation:function(b){Event.stop(b);var e=$("calType").value;var h=$("categoryUrl").value;var l=Event.element(b).name;var a=$("hidden_longitude").value;var i=$("hidden_latitude").value;var c=this.controller+"/"+e+"/"+h+"/?location="+l;if($("start").value){var f=Date.parse($("start").value);var k=new Date(f);var j=k.getFullYear();var d=k.getMonth();var g=k.getDate();c+="&year="+j+"&month="+d+"&day="+g}if(a&&i){c+="&lon="+a+"&lat="+i+"&loc="+$("form_location").value.strip()}window.location=c},processHomeLocation:function(a){Event.stop(a);new Ajax.Request("/calendarajax/gethomelocation",{method:"get",onComplete:function(d){var b=d.responseText;$("form_location").value=b;var c=$("a_homeLocation").href;window.location=c}})},getGeoLocation:function(b){Event.stop(b);var a=$("form_location").value.strip();if(a.length==0){return}this.geocoder.getLocations(a,this.createPoint.bind(this))},createPoint:function(k){if(k.Status.code!=G_GEO_SUCCESS){var f="";switch(k.Status.code){case G_GEO_BAD_REQUEST:f="Unable to parse request";break;case G_GEO_MISSING_QUERY:f="Query not specified";break;case G_GEO_UNKNOWN_ADDRESS:f="Unable to find address";break;case G_GEO_UNAVAILABLE_ADDRESS:f="Forbidden address";break;case G_GEO_BAD_KEY:f="Invalid API key";break;case G_GEO_TOO_MANY_QUERIES:f="Too many geocoder queries";break;case G_GEO_SERVER_ERROR:default:f="Unknown server error occurred"}alert(f);return}var h=k.Placemark[0].AddressDetails.Accuracy;if(h<4){alert('The location you entered is too general.\n Please enter a more specific location, i.e. "Brooklyn, New York".');return}var j=k.Placemark[0];var p=j.address;var m=j.Point.coordinates[1];var a=j.Point.coordinates[0];$("hidden_address").value=p;$("hidden_longitude").value=a;$("hidden_latitude").value=m;var q=new Hash();q.lon=parseFloat(a);q.lat=parseFloat(m);q.loc=p.toString();this.setCookie("y3loc",q.toJSON());var e=$("calType").value;var i=$("categoryUrl").value;var o="other";var b=this.controller+"/"+e+"/"+i+"/?location="+o;if($("start").value){var d=Date.parse($("start").value);var n=new Date(d);var l=n.getFullYear();var c=n.getMonth();var g=n.getDate();b+="&year="+l+"&month="+c+"&day="+g}b+="&lon="+a+"&lat="+m+"&loc="+p;window.location=b},setCookie:function(b,c){var a=30;var d=new Date();d.setDate(d.getDate()+a);document.cookie=b+"="+encodeURI(c)+";domain=yehoodi.com;path="+this.controller+((a==null)?"":";expires="+d.toGMTString())}};
