/*
** Unobtrusive Ajax support library for jQuery
** Copyright (C) Microsoft Corporation. All rights reserved.
*/
(function(a){var e="unobtrusiveAjaxClick",f="unobtrusiveValidation";function g(k,j){var l=window,m=(k||"").split(".");while(l&&m.length){l=l[m.shift()]}if(typeof(l)==="function"){return l}j.push(k);return Function.constructor.apply(null,j)}function h(j){return j==="GET"||j==="POST"}function b(k,j){if(!h(j)){k.setRequestHeader("X-HTTP-Method-Override",j)}}function c(l,k,j){var m;if(j.indexOf("application/x-javascript")!==-1){return}m=(l.getAttribute("data-ajax-mode")||"").toUpperCase();a(l.getAttribute("data-ajax-update")).each(function(n,p){var o;switch(m){case"BEFORE":o=p.firstChild;a("<div />").html(k).contents().each(function(){p.insertBefore(this,o)});break;case"AFTER":a("<div />").html(k).contents().each(function(){p.appendChild(this)});break;default:a(p).html(k);break}})}function d(l,o){var j,m,n,k;j=l.getAttribute("data-ajax-confirm");if(j&&!window.confirm(j)){return}m=a(l.getAttribute("data-ajax-loading"));k=l.getAttribute("data-ajax-loading-duration")||0;a.extend(o,{type:l.getAttribute("data-ajax-method")||undefined,url:l.getAttribute("data-ajax-url")||undefined,beforeSend:function(q){var p;b(q,n);p=g(l.getAttribute("data-ajax-begin"),["xhr"]).apply(this,arguments);if(p!==false){m.show(k)}return p},complete:function(){m.hide(k);g(l.getAttribute("data-ajax-complete"),["xhr","status"]).apply(this,arguments)},success:function(p,q,r){c(l,p,r.getResponseHeader("Content-Type")||"text/html");g(l.getAttribute("data-ajax-success"),["data","status","xhr"]).apply(this,arguments)},error:g(l.getAttribute("data-ajax-failure"),["xhr","status","error"])});o.data.push({name:"X-Requested-With",value:"XMLHttpRequest"});n=o.type.toUpperCase();if(!h(n)){o.type="POST";o.data.push({name:"X-HTTP-Method-Override",value:n})}a.ajax(o)}function i(j){var k=a(j).data(f);return !k||!k.validate||k.validate()}a("a[data-ajax=true]").live("click",function(j){j.preventDefault();d(this,{url:this.href,type:"GET",data:[]})});a("form[data-ajax=true] input[type=image]").live("click",function(k){var m=k.target.name,j=a(k.target),l=j.parents("form")[0],n=j.offset();a(l).data(e,[{name:m+".x",value:Math.round(k.pageX-n.left)},{name:m+".y",value:Math.round(k.pageY-n.top)}]);setTimeout(function(){a(l).removeData(e)},0)});a("form[data-ajax=true]").find("submit").live("click",function(j){var l=j.target.name,k=a(j.target).parents("form")[0];a(k).data(e,l?[{name:l,value:j.target.value}]:[]);setTimeout(function(){a(k).removeData(e)},0)});a("form[data-ajax=true]").live("submit",function(k){var j=a(this).data(e)||[];k.preventDefault();if(!i(this)){return}d(this,{url:this.action,type:this.method||"GET",data:j.concat(a(this).serializeArray())})})}(jQuery));
