function getPersistentAdmin(){if(readCookie("simplissime_ns301")){var a=readCookie("simplissime_ns301");return a}return!1}function logMe(a){getPersistentAdmin()?$.post("/admin/login",{c_key:getPersistentAdmin(),locale:a},function b(b){b=="false"?promptForLogin(a):document.location.href="/edit"}):promptForLogin(a)}function promptForLogin(a){$("#log_div").length==0&&$("body").append("<div id='log_div'></div>"),$("#log_mask").length==0&&$("body").append("<div id='log_mask'></div>"),$("#log_div").show(),$("#log_mask").fadeIn(),parseFloat(navigator.appVersion.split("MSIE")[1])<7?login_target="/admin/login/"+a+"/noie6":login_target="/admin/login/"+a,$.post(login_target,{token:window._token},function(a){$("#log_div").html(a)})}function closeLogin(){$("#log_mask").fadeOut(),$("#log_div").hide()}function closeModal(a){return $("#s_overlay").fadeOut(),$("#"+a).hide(),!1}function modalContact(a,b){$("#contact_div").length==0&&$("body").append("<div id='contact_div'></div>"),$("#s_overlay").length==0&&$("body").append("<div id='s_overlay'></div>"),$("#contact_div").show(),$("#s_overlay").fadeIn(),$.post("/contact/show_modal_contact",{locale:a,token:b},function(a){$("#contact_div").html(a)})}function createCookie(a,b,c){if(c){var d=new Date;d.setTime(d.getTime()+c*24*60*60*1e3);var e="; expires="+d.toGMTString()}else var e="";document.cookie=a+"="+b+e+"; path=/"}function readCookie(a){var b=a+"=",c=document.cookie.split(";");for(var d=0;d<c.length;d++){var e=c[d];while(e.charAt(0)==" ")e=e.substring(1,e.length);if(e.indexOf(b)==0)return this_value=unescapeSpaces(e.substring(b.length,e.length)),this_value}return null}function eraseCookie(a){createCookie(a,"",-1)}function unescapeSpaces(a){return new_string=unescape(a).replace("+"," "),new_string}function getCommentSpin(a){if(readCookie("simplissime_ns709")){var b=readCookie("simplissime_ns709");$("#"+a).val(b)}$("#save_comment").click(function(){$.post("/blog/"+$("#locale").val()+"/new",{name:$("#comment_name").val(),email:$("#comment_email").val(),website:$("#comment_website").val(),speech:$("#comment_speech").val(),id:$("#comment_id").val(),auth_token:$("#comment_auth_token").val(),spin:$("#"+a).val(),user_name:$("#user_name").val()},function(a){$("#new_comment").html(a)})})}function pullCommentForm(a,b){$.post("/blog/"+a+"/comment",{id:b},function(a){$("#new_comment").html(a)})}function loadGmap(map_locations,map_params){this_locations_array=map_locations.split("||"),this_params=map_params.split("|");var this_locations=[];for(i=0;i<this_locations_array.length;i++)this_targets_array=this_locations_array[i].split("|"),this_locations.push(this_targets_array[0]);var map_geocoding=new google.maps.Geocoder;map_geocoding.geocode({address:this_params[1]},function(results,status){var map_center=new google.maps.LatLng(results[0].geometry.location.lat(),results[0].geometry.location.lng()),zoom_level=Math.round(this_params[0]/14);switch(this_params[2]){case"ROADMAP":var optionsCarte={zoom:eval(zoom_level),center:map_center,mapTypeId:google.maps.MapTypeId.ROADMAP};break;case"SATELLITE":var optionsCarte={zoom:eval(zoom_level),center:map_center,mapTypeId:google.maps.MapTypeId.SATELLITE};break;case"HYBRID":var optionsCarte={zoom:eval(zoom_level),center:map_center,mapTypeId:google.maps.MapTypeId.HYBRID}}this_map=new google.maps.Map(document.getElementById("map_canvas"),optionsCarte)});for(i=0;i<this_locations.length;i++)this_place=this_locations[i],map_geocoding.geocode({address:this_locations[i]},function(a,b){var c=new google.maps.Marker({map:this_map,draggable:!0,animation:google.maps.Animation.DROP,position:new google.maps.LatLng(a[0].geometry.location.lat(),a[0].geometry.location.lng())})})}(function(a,b){var c;a.rails=c={linkClickSelector:"a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]",inputChangeSelector:"select[data-remote], input[data-remote], textarea[data-remote]",formSubmitSelector:"form",formInputClickSelector:"form input[type=submit], form input[type=image], form button[type=submit], form button:not(button[type])",disableSelector:"input[data-disable-with], button[data-disable-with], textarea[data-disable-with]",enableSelector:"input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled",requiredInputSelector:"input[name][required]:not([disabled]),textarea[name][required]:not([disabled])",fileInputSelector:"input:file",linkDisableSelector:"a[data-disable-with]",CSRFProtection:function(b){var c=a('meta[name="csrf-token"]').attr("content");c&&b.setRequestHeader("X-CSRF-Token",c)},fire:function(b,c,d){var e=a.Event(c);return b.trigger(e,d),e.result!==!1},confirm:function(a){return confirm(a)},ajax:function(b){return a.ajax(b)},handleRemote:function(d){var e,f,g,h=d.data("cross-domain")||null,i=d.data("type")||a.ajaxSettings&&a.ajaxSettings.dataType,j;if(c.fire(d,"ajax:before")){if(d.is("form")){e=d.attr("method"),f=d.attr("action"),g=d.serializeArray();var k=d.data("ujs:submit-button");k&&(g.push(k),d.data("ujs:submit-button",null))}else d.is(c.inputChangeSelector)?(e=d.data("method"),f=d.data("url"),g=d.serialize(),d.data("params")&&(g=g+"&"+d.data("params"))):(e=d.data("method"),f=d.attr("href"),g=d.data("params")||null);j={type:e||"GET",data:g,dataType:i,crossDomain:h,beforeSend:function(a,e){return e.dataType===b&&a.setRequestHeader("accept","*/*;q=0.5, "+e.accepts.script),c.fire(d,"ajax:beforeSend",[a,e])},success:function(a,b,c){d.trigger("ajax:success",[a,b,c])},complete:function(a,b){d.trigger("ajax:complete",[a,b])},error:function(a,b,c){d.trigger("ajax:error",[a,b,c])}},f&&(j.url=f),c.ajax(j)}},handleMethod:function(c){var d=c.attr("href"),e=c.data("method"),f=c.attr("target"),g=a("meta[name=csrf-token]").attr("content"),h=a("meta[name=csrf-param]").attr("content"),i=a('<form method="post" action="'+d+'"></form>'),j='<input name="_method" value="'+e+'" type="hidden" />';h!==b&&g!==b&&(j+='<input name="'+h+'" value="'+g+'" type="hidden" />'),f&&i.attr("target",f),i.hide().append(j).appendTo("body"),i.submit()},disableFormElements:function(b){b.find(c.disableSelector).each(function(){var b=a(this),c=b.is("button")?"html":"val";b.data("ujs:enable-with",b[c]()),b[c](b.data("disable-with")),b.prop("disabled",!0)})},enableFormElements:function(b){b.find(c.enableSelector).each(function(){var b=a(this),c=b.is("button")?"html":"val";b.data("ujs:enable-with")&&b[c](b.data("ujs:enable-with")),b.prop("disabled",!1)})},allowAction:function(a){var b=a.data("confirm"),d=!1,e;return b?(c.fire(a,"confirm")&&(d=c.confirm(b),e=c.fire(a,"confirm:complete",[d])),d&&e):!0},blankInputs:function(b,c,d){var e=a(),f,g=c||"input,textarea";return b.find(g).each(function(){f=a(this);if(d?f.val():!f.val())e=e.add(f)}),e.length?e:!1},nonBlankInputs:function(a,b){return c.blankInputs(a,b,!0)},stopEverything:function(b){return a(b.target).trigger("ujs:everythingStopped"),b.stopImmediatePropagation(),!1},callFormSubmitBindings:function(c){var d=c.data("events"),e=!0;return d!==b&&d.submit!==b&&a.each(d.submit,function(a,b){if(typeof b.handler=="function")return e=b.handler(b.data)}),e},disableElement:function(a){a.data("ujs:enable-with",a.html()),a.html(a.data("disable-with")),a.bind("click.railsDisable",function(a){return c.stopEverything(a)})},enableElement:function(a){a.data("ujs:enable-with")!==b&&(a.html(a.data("ujs:enable-with")),a.data("ujs:enable-with",!1)),a.unbind("click.railsDisable")}},a.ajaxPrefilter(function(a,b,d){a.crossDomain||c.CSRFProtection(d)}),a(c.linkDisableSelector).live("ajax:complete",function(){c.enableElement(a(this))}),a(c.linkClickSelector).live("click.rails",function(d){var e=a(this),f=e.data("method"),g=e.data("params");if(!c.allowAction(e))return c.stopEverything(d);e.is(c.linkDisableSelector)&&c.disableElement(e);if(e.data("remote")!==b)return(d.metaKey||d.ctrlKey)&&(!f||f==="GET")&&!g?!0:(c.handleRemote(e),!1);if(e.data("method"))return c.handleMethod(e),!1}),a(c.inputChangeSelector).live("change.rails",function(b){var d=a(this);return c.allowAction(d)?(c.handleRemote(d),!1):c.stopEverything(b)}),a(c.formSubmitSelector).live("submit.rails",function(d){var e=a(this),f=e.data("remote")!==b,g=c.blankInputs(e,c.requiredInputSelector),h=c.nonBlankInputs(e,c.fileInputSelector);if(!c.allowAction(e))return c.stopEverything(d);if(g&&e.attr("novalidate")==b&&c.fire(e,"ajax:aborted:required",[g]))return c.stopEverything(d);if(f)return h?c.fire(e,"ajax:aborted:file",[h]):!a.support.submitBubbles&&c.callFormSubmitBindings(e)===!1?c.stopEverything(d):(c.handleRemote(e),!1);setTimeout(function(){c.disableFormElements(e)},13)}),a(c.formInputClickSelector).live("click.rails",function(b){var d=a(this);if(!c.allowAction(d))return c.stopEverything(b);var e=d.attr("name"),f=e?{name:e,value:d.val()}:null;d.closest("form").data("ujs:submit-button",f)}),a(c.formSubmitSelector).live("ajax:beforeSend.rails",function(b){this==b.target&&c.disableFormElements(a(this))}),a(c.formSubmitSelector).live("ajax:complete.rails",function(b){this==b.target&&c.enableFormElements(a(this))})})(jQuery),function(){var a;$(function(){$("#link_to_log_me").show(),$("#link_to_log_me").click(function(){return logMe("fr")}),$(".editable").dblclick(function(){return document.location.href="/admin/contents/edit/"+this.id.split("_")[1]}),$(".category").hover(function(){return $(".cover",this).slideToggle("slow")}),$("#top_search_from").click(function(){return $(this).val("")}),$("#current_locale").click(function(){return $("#locale_switcher").slideToggle("fast",function(){return $("#current_locale").attr("class")==="locales_down"?$("#current_locale").removeClass("locales_down").addClass("locales_up"):$("#current_locale").removeClass("locales_up").addClass("locales_down")})}),$(".locale_reset").click(function(){return document.location.href="/setlocale/"+$(this).attr("rel")}),$("a[href^='http://']").attr("target","_blank");if($("#spacer").length>0)return a()}),window.isValidEmail=function(a){var b;return b=new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i),b.test(a)},a=function(){var a,b,c,d;c=$("#spacer").offset(),a=$("#bottom").height(),d=$(window).height(),b=d-(c.top+a);if(b>0)return $("#spacer").css({height:b+"px"})}}.call(this),$(function(){return $(".comment_form").focus(function(){return $(this).css({"background-color":"#fff"})}),$("#submit_new_comment").click(function(){var a;return $("#comment_name").val()===""?($("#comment_name").css({"background-color":"#fff159"}),alert(I18n.front_please_fill_lastname),!1):window.isValidEmail($("#comment_email").val())?$("#speech").val()===""?($("#speech").css({"background-color":"#fff159"}),alert(I18n.front_please_enter_your_comment),!1):($("#comment_inputs").hide(),$("#comment_progress").fadeIn("slow"),$.post("/blog/comment/pull",{user_name:$("#user_name").val()},a=function(b){var c;if(!b.spam)return c="/blog/comment/add/"+b.token,$.post(""+c+"",{user_name:$("#user_name").val(),post_id:$("#post_id").val(),comment_name:$("#comment_name").val(),comment_email:$("#comment_email").val(),comment_website:$("#comment_website").val(),comment_speech:$("#speech").val()},a=function(a){return $("#comment_progress").hide(),$("#comment_inputs").show(),a.posted==="success"?($("#comment_name").val(""),$("#comment_email").val(""),$("#comment_website").val(""),$("#speech").val(""),alert(I18n[a.message]),document.location.reload()):alert("Error while saving comment, please try again later...")})})):($("#comment_email").css({"background-color":"#fff159"}),alert(I18n.front_please_fill_valid_email),!1)})}),$(function(){return $(".contact_form").focus(function(){return $(this).css({"background-color":"#fff"})}),$("#send_contact").click(function(){var a;return $("#name").val()===""?($("#name").css({"background-color":"#fff159"}),alert(I18n.front_please_fill_lastname),!1):window.isValidEmail($("#email").val())?$("#subject").val()===""?($("#subject").css({"background-color":"#fff159"}),alert(I18n.front_please_fill_subject),!1):$("#message").val()===""?($("#message").css({"background-color":"#fff159"}),alert(I18n.front_please_fill_email_body),!1):($("#contact_inputs").hide(),$("#contact_progress").fadeIn("slow"),$.post("/contact",{user_name:$("#user_name").val(),name:$("#name").val(),email:$("#email").val(),subject:$("#subject").val(),message:$("#message").val()},a=function(b){var c;if(!b.spam)return c="/contact/"+b.token,$.post(""+c+"",{user_name:$("#user_name").val(),name:$("#name").val(),email:$("#email").val(),subject:$("#subject").val(),message:$("#message").val()},a=function(a){return $("#contact_progress").hide(),$(".contact_form").val(""),$("#contact_inputs").show(),alert(I18n.front_your_message_has_been_sent)})})):($("#email").css({"background-color":"#fff159"}),alert(I18n.front_please_fill_valid_email),!1)}),$(".modal_contact_trigger").click(function(){var a;return $("body").append("<div id='global_overlay'></div>"),$("body").append("<div id='contact_div'></div>"),$("#global_overlay").fadeIn("slow"),$("#contact_div").show(),$.post("/contact/pull_modal",{dataType:"html"},a=function(a){return $("#contact_div").append(a)}),$("#contact_div").delegate("a","click",function(a){return $("#contact_div").remove(),$("#global_overlay").fadeOut("slow")}),$("#contact_div").delegate(".modal_input","focus",function(a){return $(this).css({"background-color":"#fff"})}),$("#contact_div").delegate("#send_modal_email","click",function(b){return $("#modal_name").val()===""?($("#modal_name").css({"background-color":"#fff159"}),alert(I18n.front_please_fill_lastname),!1):window.isValidEmail($("#modal_email").val())?$("#modal_subject").val()===""?($("#modal_subject").css({"background-color":"#fff159"}),alert(I18n.front_please_fill_subject),!1):$("#modal_message").val()===""?($("#modal_message").css({"background-color":"#fff159"}),alert(I18n.front_please_fill_email_body),!1):($("#main_modal_contact_form").hide(),$("#modal_contact_progress").show(),$.post("/contact/send_mail_modal",{modal_token:$("#modal_token").val(),user_name:$("#user_name").val(),name:$("#modal_name").val(),email:$("#modal_email").val(),subject:$("#modal_subject").val(),message:$("#modal_message").val()},a=function(a){return $("#contact_div").remove(),$("#global_overlay").fadeOut("slow"),alert(I18n.front_your_message_has_been_sent)})):($("#modal_email").css({"background-color":"#fff159"}),alert(I18n.front_please_fill_valid_email),!1)})})})
