﻿(function(a){a.fn.fancyDialog=function(d){var b={eventType:"click",title:"",showCloseButton:false,modal:true,autoDimensions:false};var c=a.extend(b,d);return this.each(function(){var e=a(this);e.bind(c.eventType,function(){jQuery.fancybox({showCloseButton:c.showCloseButton,title:c.title,titlePosition:"inside",modal:c.modal,autoDimensions:c.autoDimensions,width:500,height:"auto",scrolling:"no",transitionIn:"none",transitionOut:"none",href:(c.url||e.attr("href")),onComplete:function(){a.ajaxifyForm("#fancybox_form",d.successCallback)}});return false})})};a.ajaxifyForm=function(b,c){a("#fancybox_cancel").click(function(){ret=false;a.fancybox.close()});a(b).ajaxForm({beforeSubmit:function(){a.fancybox.showActivity()},success:function(d,e,g){var f=g.getResponseHeader("Content-Type");if(f=="application/json; charset=utf-8"){if(c){c(d)}jQuery.fancybox.close()}else{a(b).replaceWith(d);a.ajaxifyForm(b,c);a.fancybox.resize()}a.fancybox.hideActivity()}})};a.fn.useHint=function(b){return this.each(function(){var e=a(this);var f=e.next("input");var d=e.css("color");e.val(b);e.css("color","#aaa");f.attr("disabled","disabled");e.blur(function(){if(e.val()==""){e.val(b);e.css("color","#aaa");f.attr("disabled","disabled")}});e.focus(function(){if(e.val()==b){e.val("")}e.css("color",d);f.removeAttr("disabled")})})}})(jQuery);
