/*
 * jQuery Tools 1.2.0 - The missing UI library for the Web
 * 
 * [validator]
 * 
 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 * 
 * http://flowplayer.org/tools/
 * 
 * File generated: Sat May 08 06:18:14 GMT 2010
 */
(function(c){function u(b,a,g){var e=g.relative?b.position().top:b.offset().top,h=g.relative?b.position().left:b.offset().left,i=g.position.split(/,?\s+/),f=i[0];i=i[1];e-=a.outerHeight()-g.offset[0];h+=b.outerWidth()+g.offset[1];g=a.outerHeight()+b.outerHeight();if(f=="center")e+=g/2;if(f=="bottom")e+=g;b=b.outerWidth();if(i=="center")h-=(b+a.outerWidth())/2;if(i=="left")h-=b;return{top:e,left:h}}function v(b){function a(){return this.getAttribute("type")==b}a.key="[type="+b+"]";return a}function w(b,
a){function g(f,d,k){if(!(!a.grouped&&f.length)){var j;if(k===false||c.isArray(k)){j=l.messages[d.key||d]||l.messages["*"];j=j[a.lang]||l.messages["*"].en;(d=j.match(/\$\d/g))&&c.isArray(k)&&c.each(d,function(n){j=j.replace(this,k[n])})}else j=k[a.lang]||k;f.push(j)}}var e=this,h=b.add(e),i=b.find(":input");if(!i.length){i=b.filter(":input").data("validator",e);b=i.eq(0).closest("form")}i=i.not(":button, :image, :reset, :submit");if(!i.length)throw"Validator: no input fields supplied";c.extend(e,
{getConf:function(){return a},getForm:function(){return b},getInputs:function(){return i},invalidate:function(f,d){if(!d){var k=[];c.each(f,function(j,n){j=i.filter("[name="+j+"]");if(j.length){j.trigger("oninvalid",[n]);k.push({input:j,messages:[n]})}});f=k;d=c.Event()}d.type="onFail";h.trigger(d,[f]);d.isDefaultPrevented()||q[a.effect][0].call(e,f,d);return e},checkValidity:function(f,d){f=f||i;f=f.not(":disabled");if(!f.length)return true;d=d||c.Event();d.type="onBeforeValidate";h.trigger(d,[f]);
if(d.isDefaultPrevented())return d.result;var k=[],j=a.errorInputEvent+".v";f.each(function(){var p=[],m=c(this).unbind(j).data("messages",p);c.each(s,function(){var o=this,r=o[0];if(m.filter(r).length){o=o[1].call(e,m,m.val());if(o!==true){d.type="onBeforeFail";h.trigger(d,[m,r]);if(d.isDefaultPrevented())return false;var t=m.attr(a.messageAttr);if(t){p=[t];return false}else g(p,r,o)}}});if(p.length){k.push({input:m,messages:p});m.trigger("oninvalid",[p]);a.errorInputEvent&&m.bind(j,function(o){e.checkValidity(m,
o)})}if(a.singleError&&k.length)return false});var n=q[a.effect];if(!n)throw'Validator: cannot find effect "'+a.effect+'"';if(k.length){e.invalidate(k,d);return false}else{n[1].call(e,f,d);d.type="onSuccess";h.trigger(d,[f]);f.unbind(j)}return true}});c.each("onBeforeValidate,onBeforeFail,onFail,onSuccess".split(","),function(f,d){c.isFunction(a[d])&&c(e).bind(d,a[d]);e[d]=function(k){c(e).bind(d,k);return e}});a.formEvent&&b.bind(a.formEvent,function(f){if(!e.checkValidity(null,f))return f.preventDefault()});
b[0].checkValidity=e.checkValidity;a.inputEvent&&i.bind(a.inputEvent,function(f){e.checkValidity(c(this),f)});i.filter("[oninvalid]").each(function(){c(this).oninvalid(function(){c.globalEval(c(this).attr("oninvalid"))})})}c.tools=c.tools||{version:"1.2.0"};var x=/\[type=([a-z]+)\]/,y=/^-?[0-9]*(\.[0-9]+)?$/,z=/^([a-z0-9_\.\-]+)@([\da-z\.\-]+)\.([a-z\.]{2,6})$/i,A=/^(https?:\/\/)?([\da-z\.\-]+)\.([a-z\.]{2,6})([\/\w \.\-]*)*\/?$/i,l;l=c.tools.validator={conf:{grouped:false,effect:"default",errorClass:"invalid",
inputEvent:null,errorInputEvent:"keyup",formEvent:"submit",lang:"en",message:"<div/>",messageAttr:"data-message",messageClass:"error",offset:[0,0],position:"center right",relative:false,singleError:false,speed:"normal"},messages:{"*":{en:"Please correct this value"}},localize:function(b,a){c.each(a,function(g,e){l.messages[g][b]=e})},localizeFn:function(b,a){l.messages[b]=l.messages[b]||{};c.extend(l.messages[b],a)},fn:function(b,a,g){if(c.isFunction(a))g=a;else{if(typeof a=="string")a={en:a};this.messages[b.key||
b]=a}if(a=x.exec(b))b=v(a[1]);s.push([b,g])},addEffect:function(b,a,g){q[b]=[a,g]}};var s=[],q={"default":[function(b){var a=this.getConf();c.each(b,function(g,e){g=e.input;g.addClass(a.errorClass);var h=g.data("msg.el");if(!h){h=c(a.message).addClass(a.messageClass).appendTo(document.body);g.data("msg.el",h)}h.css({visibility:"hidden"}).find("span").remove();c.each(e.messages,function(i,f){c("<span/>").html(f).appendTo(h)});h.outerWidth()==h.parent().width()&&h.add(h.find("p")).css({display:"inline"});
e=u(g,h,a);h.css({visibility:"visible",position:"absolute",top:e.top,left:e.left}).fadeIn(a.speed)})},function(b){var a=this.getConf();b.removeClass(a.errorClass).each(function(){var g=c(this).data("msg.el");g&&g.css({visibility:"hidden"})})}]};c.each("email,url,number".split(","),function(b,a){c.expr[":"][a]=function(g){return g.getAttribute("type")===a}});c.fn.oninvalid=function(b){return this[b?"bind":"trigger"]("oninvalid",b)};l.fn(":email","Plase enter a valid email address",function(b,a){return!a||
z.test(a)});l.fn(":url","Please enter a valid URL",function(b,a){return!a||A.test(a)});l.fn(":number","Please enter a numeric value.",function(b,a){return y.test(a)});l.fn("[max]","Please enter a value smaller than $1",function(b,a){b=b.attr("max");return parseFloat(a)<=parseFloat(b)?true:[b]});l.fn("[min]","Please enter a value larger than $1",function(b,a){b=b.attr("min");return parseFloat(a)>=parseFloat(b)?true:[b]});l.fn("[required]","Please complete this mandatory field.",function(b,a){return!!a});
l.fn("[pattern]",function(b){var a=new RegExp("^"+b.attr("pattern")+"$");return a.test(b.val())});c.fn.validator=function(b){if(this.data("validator"))return this;b=c.extend(true,{},l.conf,b);return this.each(function(){var a=new w(c(this),b);c(this).data("validator",a)})}})(jQuery);

