window.OOS=window.OOS||{};document.observe("dom:loaded",function(){$$("a.matilde").invoke("observe","click",manageContact);$$("a.taste").invoke("observe","click",manageContact);$$(".opinion-actions .opinion").invoke("observe","click",showOpinionForm);$$("form[action*=unlogged], #liveopinion").invoke("observe","submit",validate);});OOS.LoginMsg={save:_("necesitas estar registrado para añadir servicios a tu agenda"),relationship:_("necesitas estar registrado para añadir contactos"),liveOpinion:_("por favor, identifícate para añadir tu opinión"),like:_("por favor, identifícate para expresar que te gusta esa opinión"),addComment:_("por favor, identifícate para comentar algo sobre esa opinión")};function showOpinionForm(evt){evt.stop();var formTpl=new Template('<form action="#{action}" method="post">'+'<input type="hidden" name="userServiceId" value="#{suId}" />'+'<textarea name="commentText"></textarea>'+'<label><input type="checkbox" name="followComment" />'+_("recibir por e-mail los comentario nuevos sobre esta opinión")+'</label><p><input type="submit" value="#{submitText}" /><a href="#" class="action cancel">#{cancelLink}</a></p></form>');var opAc=this.up(".opinion-actions");var form=opAc.down("form");if(form){if(form.visible()){form.hide();opAc.down(".opinion").removeClassName("current");}else{form.show();opAc.down(".opinion").addClassName("current");}return false;}else{var params=this.href.toQueryParams();opAc.insert(formTpl.evaluate({submitText:_("añadir comentario"),suId:params.userServiceId,action:"/services/unlogged-addComment",cancelLink:_("cancelar")}));opAc.down(".opinion").addClassName("current");form=opAc.down("form");form.down("textarea").focus();form.observe("submit",validate);form.down(".cancel").observe("click",function(e){e.stop();opAc.down(".opinion").removeClassName("current");e.element().up("form").remove();}.bind(opAc));var taste=opAc.down(".taste");form.setStyle({marginLeft:((taste)?taste.getWidth():0)+"px"});}}function validate(evt){var form=evt.element();form.select(".error").invoke("remove");var text=form.down("textarea").getValue();if(!text.blank()){manageContact(evt);}else{evt.stop();var error=new Element("p",{className:"error"});error.update(_("¿un comentario vacío?"));form.select("textarea").first().insert({before:error});}}function manageContact(evt){evt.stop();var el=evt.element();if(el.tagName.toLowerCase()==="img"){el=el.up();}var url=el.href?el.href:el.action;var header=_("necesitas estar registrado");if(url.indexOf("save-pro")>-1){header=OOS.LoginMsg.save;}else{if(url.indexOf("manage-relationship")>-1){header=OOS.LoginMsg.relationship;}else{if(url.indexOf("ilikeit")>-1){header=OOS.LoginMsg.like;}else{if(url.indexOf("liveopinion")>-1){header=OOS.LoginMsg.liveOpinion;}else{if(url.indexOf("addComment")>-1){header=OOS.LoginMsg.addComment;}}}}}var container=new ResizableBox("box-login");container.resize([550]);var html=new Array();var post=OOS.postActivationAction.initialize(el,url);var pars=post.toParams(true);var parsForFacebook=post.toParams(false);html.push('<div id="login-box" class="ajax-controls clearfix">');html.push("<h2>");html.push(header);html.push("</h2>");html.push('<div id="qLogin" class="door">');if(window.location.hostname){html.push('<form action="https://'+window.location.hostname+'/login" method="post">');}else{html.push('<form action="/login" method="post">');}html.push('<input type="hidden" name="referer" value="');html.push(url);html.push('" />');html.push('<input type="hidden" name="origin" value="');html.push(window.location.href);html.push('"/><p class="error" id="error-login-ajax" style="display:none;">');html.push(_("los datos de acceso son incorrectos"));html.push("</p>");html.push('<label for="email">');html.push(_("e-mail:"));html.push('</label><input type="text" class="text" id="email" name="email" />');html.push('<label for="password">');html.push(_("contraseña:"));html.push('</label><input type="password" class="text" id="password" name="password"  />');html.push('<p><a href="/remember" id="password-recover">');html.push(_("¿olvidaste la contraseña?"));html.push("</a></p>");html.push('<p class="button"><input type="submit" value="');html.push(_("entrar"));html.push('" id="submit" />');html.push('<span id="submitting" style="display:none;">');html.push('<img src="/static/imgs/ajax_activity_indicator.gif" />');html.push(_("un momento..."));html.push("</span>");html.push("</p>");html.push("</form>");html.push("</div>");html.push('<div id="qSignup" class="door">');html.push('<h3 style="text-align:center;font-size:15px">');html.push(_("¿primera vez en 11870.com?"));html.push("</h3>");html.push("<p>");html.push(_("crea tu cuenta para añadir opiniones, fotos, vídeos, valoraciones..."));html.push("</p>");var dest="/signup-choice";if(pars.length>0){dest="/signup"+pars;}html.push('<p style="text-align:center"><a href="'+dest+'" id="signup-choice-link" class="action">');html.push(_("alta en 11870.com"));html.push("</a></p>");html.push('<p style="text-align:center;margin-top:20px"><span style="display:block;font-size:11px">');html.push(_("si usas Facebook.com puedes darte de alta"));html.push("</span>");html.push('<a href="/login?facebook-login'+parsForFacebook+'" id="fb-link" class="fb">');html.push(_("entrar usando facebook"));html.push("</a>");html.push("</p>");html.push("</div>");html.push("</div>");$("box-login").update(html.join(""));container.contentLoaded();}OOS.postActivationAction={action:"",objectId:"",type:"",params:new Object(),initialize:function(obj,url){if(url.indexOf("ilikeit")>-1){this.type="ilikeit";this.action=0;this.objectId=url.substr(url.indexOf("?")).toQueryParams()["userServiceId"];}else{if(url.indexOf("liveopinion")>-1){this.params=obj.serialize(true);this.action=1;this.type="liveOpinion";this.objectId=this.params["sId"];var matilde_post=new Ajax.Request("/services/unlogged-liveopinion",{method:"post",parameters:this.params,onSuccess:function(transport){try{pageTracker._trackPageview("/services/liveopinion");}catch(e){}}});}else{if(url.indexOf("addComment")>-1){this.params=obj.serialize(true);this.action=2;this.type="commentsOnComments";this.objectId=this.params["userServiceId"];var matilde_post=new Ajax.Request("/services/unlogged-addComment",{method:"post",parameters:this.params,onSuccess:function(transport){}});}}}return this;},toParams:function(isFirst){if(isNaN(this.action)||!(this.objectId.length>0)){return"";}return(isFirst?"?":"&")+"a="+this.action+"&oId="+this.objectId;}};