/**
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 * 
 * jQuery UI
 * http://docs.jquery.com/UI
 */
(function(a,d){a.ui=a.ui||{};if(a.ui.version){return}a.extend(a.ui,{version:"@VERSION",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});a.fn.extend({_focus:a.fn.focus,focus:function(e,f){return typeof e==="number"?this.each(function(){var g=this;setTimeout(function(){a(g).focus();if(f){f.call(g)}},e)}):this._focus.apply(this,arguments)},scrollParent:function(){var e;if((a.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){e=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(a.curCSS(this,"position",1))&&(/(auto|scroll)/).test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0)}else{e=this.parents().filter(function(){return(/(auto|scroll)/).test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!e.length?a(document):e},zIndex:function(h){if(h!==d){return this.css("zIndex",h)}if(this.length){var f=a(this[0]),e,g;while(f.length&&f[0]!==document){e=f.css("position");if(e==="absolute"||e==="relative"||e==="fixed"){g=parseInt(f.css("zIndex"),10);if(!isNaN(g)&&g!==0){return g}}f=f.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});a.each(["Width","Height"],function(g,e){var f=e==="Width"?["Left","Right"]:["Top","Bottom"],h=e.toLowerCase(),k={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};function j(m,l,i,n){a.each(f,function(){l-=parseFloat(a.curCSS(m,"padding"+this,true))||0;if(i){l-=parseFloat(a.curCSS(m,"border"+this+"Width",true))||0}if(n){l-=parseFloat(a.curCSS(m,"margin"+this,true))||0}});return l}a.fn["inner"+e]=function(i){if(i===d){return k["inner"+e].call(this)}return this.each(function(){a(this).css(h,j(this,i)+"px")})};a.fn["outer"+e]=function(i,l){if(typeof i!=="number"){return k["outer"+e].call(this,i)}return this.each(function(){a(this).css(h,j(this,i,true,l)+"px")})}});function c(g,e){var j=g.nodeName.toLowerCase();if("area"===j){var i=g.parentNode,h=i.name,f;if(!g.href||!h||i.nodeName.toLowerCase()!=="map"){return false}f=a("img[usemap=#"+h+"]")[0];return !!f&&b(f)}return(/input|select|textarea|button|object/.test(j)?!g.disabled:"a"==j?g.href||e:e)&&b(g)}function b(e){return !a(e).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}a.extend(a.expr[":"],{data:function(g,f,e){return !!a.data(g,e[3])},focusable:function(e){return c(e,!isNaN(a.attr(e,"tabindex")))},tabbable:function(g){var e=a.attr(g,"tabindex"),f=isNaN(e);return(f||e>=0)&&c(g,!f)}});a(function(){var f=document.createElement("div");f.style.borderWidth="1px";f.style.borderStyle="solid";f.style.borderTopColor="red";f.style.borderRightColor="green";f.style.position="absolute";f.style.top="-999px";if(a.browser.msie&&parseInt(a.browser.version,10)<8){f.className="ui-icon"}else{f.style.backgroundImage="url(data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAEBMgA7)"}a(document.body).append(f);var e=a.curCSS(f,"backgroundImage");a.support.highContrast=(a.curCSS(f,"borderTopColor")==a.curCSS(f,"borderRightColor"))||(e!=null&&(e=="none"||e=="url(invalid-url:)"));if(a.support.highContrast){a("body").addClass("ui-helper-highcontrast")}if(a.browser.msie){f.outerHTML=""}else{document.body.removeChild(f)}});a(function(){var e=document.body,f=e.appendChild(f=document.createElement("div"));a.extend(f.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});a.support.minHeight=f.offsetHeight===100;a.support.selectstart="onselectstart" in f;e.removeChild(f).style.display="none"});a.extend(a.ui,{plugin:{add:function(f,g,j){var h=a.ui[f].prototype;for(var e in j){h.plugins[e]=h.plugins[e]||[];h.plugins[e].push([g,j[e]])}},call:function(e,g,f){var j=e.plugins[g];if(!j||!e.element[0].parentNode){return}for(var h=0;h<j.length;h++){if(e.options[j[h][0]]){j[h][1].apply(e.element,f)}}}},contains:a.contains,hasScroll:function(h,f){if(a(h).css("overflow")==="hidden"){return false}var e=(f&&f==="left")?"scrollLeft":"scrollTop",g=false;if(h[e]>0){return true}h[e]=1;g=(h[e]>0);h[e]=0;return g},isOverAxis:function(f,e,g){return(f>e)&&(f<(e+g))},isOver:function(j,f,i,h,e,g){return a.ui.isOverAxis(j,i,e)&&a.ui.isOverAxis(f,h,g)}})})(jQuery);(function(f,c){f.ui=f.ui||{};var e=/left|center|right/,h=/top|center|bottom/,b=/[+-]\d+%?/,i=/^\w+/,d=/%$/,a="center",g=f.fn.position;f.position={scrollbarWidth:function(){var k,j,m=f("<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),l=m.children()[0];f("body").append(m);k=l.offsetWidth;m.css("overflow","scroll");j=l.offsetWidth;if(k===j){j=m[0].clientWidth}m.remove();return k-j},getScrollInfo:function(j){var n=j[0],l=j.height()<n.scrollHeight,k=j.width()<n.scrollWidth,m=f.position.scrollbarWidth();return{height:l?m:0,width:k?m:0}}};f.fn.position=function(r){if(!r||!r.of){return g.apply(this,arguments)}r=f.extend({},r);var n=f(r.of),k=f(r.within||window),o=n[0],q=(r.collision||"flip").split(" "),j={},s,p,m,l;if(o.nodeType===9){p=n.width();m=n.height();l={top:0,left:0}}else{if(f.isWindow(o)){p=n.width();m=n.height();l={top:n.scrollTop(),left:n.scrollLeft()}}else{if(o.preventDefault){r.at="left top";p=m=0;l={top:r.of.pageY,left:r.of.pageX}}else{p=n.outerWidth();m=n.outerHeight();l=n.offset()}}}f.each(["my","at"],function(){var v=(r[this]||"").split(" "),u,t;if(v.length===1){v=e.test(v[0])?v.concat([a]):h.test(v[0])?[a].concat(v):[a,a]}v[0]=e.test(v[0])?v[0]:a;v[1]=h.test(v[1])?v[1]:a;u=b.exec(v[0]);t=b.exec(v[1]);j[this]=[u?u[0]:0,t?t[0]:0];r[this]=[i.exec(v[0])[0],i.exec(v[1])[0]]});if(q.length===1){q[1]=q[0]}if(r.at[0]==="right"){l.left+=p}else{if(r.at[0]===a){l.left+=p/2}}if(r.at[1]==="bottom"){l.top+=m}else{if(r.at[1]===a){l.top+=m/2}}s=[parseInt(j.at[0],10)*(d.test(j.at[0])?p/100:1),parseInt(j.at[1],10)*(d.test(j.at[1])?m/100:1)];l.left+=s[0];l.top+=s[1];return this.each(function(){var x=f(this),z=x.outerWidth(),v=x.outerHeight(),y=parseInt(f.curCSS(this,"marginLeft",true))||0,u=parseInt(f.curCSS(this,"marginTop",true))||0,w=f.position.getScrollInfo(k),C=z+y+(parseInt(f.curCSS(this,"marginRight",true))||0)+w.width,D=v+u+(parseInt(f.curCSS(this,"marginBottom",true))||0)+w.height,A=f.extend({},l),B=[parseInt(j.my[0],10)*(d.test(j.my[0])?x.outerWidth()/100:1),parseInt(j.my[1],10)*(d.test(j.my[1])?x.outerHeight()/100:1)],t;if(r.my[0]==="right"){A.left-=z}else{if(r.my[0]===a){A.left-=z/2}}if(r.my[1]==="bottom"){A.top-=v}else{if(r.my[1]===a){A.top-=v/2}}A.left+=B[0];A.top+=B[1];A.left=Math.round(A.left);A.top=Math.round(A.top);t={left:A.left-y,top:A.top-u};f.each(["left","top"],function(F,E){if(f.ui.position[q[F]]){f.ui.position[q[F]][E](A,{targetWidth:p,targetHeight:m,elemWidth:z,elemHeight:v,collisionPosition:t,collisionWidth:C,collisionHeight:D,offset:[s[0]+B[0],s[1]+B[1]],my:r.my,at:r.at,within:k})}});if(f.fn.bgiframe){x.bgiframe()}x.offset(f.extend(A,{using:r.using}))})};f.ui.position={fit:{left:function(n,m){var l=m.within,o=f(window),k=f.isWindow(m.within[0]),p=k?o.scrollLeft():l.offset().left,r=k?o.width():l.outerWidth(),q=p-m.collisionPosition.left,j=m.collisionPosition.left+m.collisionWidth-r-p;if(m.collisionWidth>r||q>0){n.left+=q}else{if(j>0){n.left-=j}else{n.left=Math.max(n.left-m.collisionPosition.left,n.left)}}},top:function(m,l){var k=l.within,o=f(window),j=f.isWindow(l.within[0]),q=j?o.scrollTop():k.offset().top,r=j?o.height():k.outerHeight(),p=q-l.collisionPosition.top,n=l.collisionPosition.top+l.collisionHeight-r-q;if(l.collisionHeight>r||p>0){m.top+=p}else{if(n>0){m.top-=n}else{m.top=Math.max(m.top-l.collisionPosition.top,m.top)}}}},flip:{left:function(p,o){if(o.at[0]===a){return}var n=o.within,q=f(window),k=f.isWindow(o.within[0]),s=k?0:n.offset().left,v=k?n.width():n.outerWidth(),t=o.collisionPosition.left-s,j=o.collisionPosition.left+o.collisionWidth-v-s,l=o.my[0]==="left",r=o.my[0]==="left"?-o.elemWidth:o.my[0]==="right"?o.elemWidth:0,u=o.at[0]==="left"?o.targetWidth:-o.targetWidth,m=-2*o.offset[0];if(t<0||j>0){p.left+=r+u+m}},top:function(n,m){if(m.at[1]===a){return}var l=m.within,p=f(window),j=f.isWindow(m.within[0]),t=j?0:l.offset().top,u=j?l.height():l.outerHeight(),r=m.collisionPosition.top-t,o=m.collisionPosition.top+m.collisionHeight-u-t,s=m.my[1]==="top",q=s?-m.elemHeight:m.my[1]==="bottom"?m.elemHeight:0,v=m.at[1]==="top"?m.targetHeight:-m.targetHeight,k=-2*m.offset[1];if(r<0||o>0){n.top+=q+v+k}}}};if(f.uiBackCompat!==false){(function(k){var j=k.fn.position;k.fn.position=function(m){if(!m||!m.offset){return j.call(this,m)}var n=m.offset.split(" "),l=m.at.split(" ");if(n.length===1){n[1]=n[0]}if(/^\d/.test(n[0])){n[0]="+"+n[0]}if(/^\d/.test(n[1])){n[1]="+"+n[1]}if(l.length===1){if(/left|center|right/.test(l[0])){l[1]="center"}else{l[1]=l[0];l[0]="center"}}return j.call(this,k.extend(m,{at:l[0]+n[0]+" "+l[1]+n[1],offset:c}))}}(jQuery))}}(jQuery));
/**
 * jQuery UI Widget
 * http://docs.jquery.com/UI/Widget
 */
(function(a,d){var c=Array.prototype.slice;var b=a.cleanData;a.cleanData=function(e){for(var f=0,g;(g=e[f])!=null;f++){a(g).triggerHandler("remove")}b(e)};a.widget=function(f,h,e){var g=f.split(".")[0],j;f=f.split(".")[1];j=g+"-"+f;if(!e){e=h;h=a.Widget}a.expr[":"][j]=function(k){return !!a.data(k,f)};a[g]=a[g]||{};a[g][f]=a.extend(function(k,l){if(!this._createWidget){return new a[g][f](k,l)}if(arguments.length){this._createWidget(k,l)}},a[g][f],{version:e.version});var i=new h();i.options=a.widget.extend({},i.options);a.each(e,function(l,k){if(a.isFunction(k)){e[l]=(function(){var m=function(o){return h.prototype[o].apply(this,c.call(arguments,1))};var n=function(p,o){return h.prototype[p].apply(this,o)};return function(){var q=this._super,o=this._superApply,p;this._super=m;this._superApply=n;p=k.apply(this,arguments);this._super=q;this._superApply=o;return p}}())}});a[g][f].prototype=a.widget.extend(i,{namespace:g,widgetName:f,widgetEventPrefix:f,widgetBaseClass:j},e);a.widget.bridge(f,a[g][f])};a.widget.extend=function(j){var f=c.call(arguments,1),i=0,e=f.length,g,h;for(;i<e;i++){for(g in f[i]){h=f[i][g];if(f[i].hasOwnProperty(g)&&h!==d){j[g]=a.isPlainObject(h)?a.widget.extend({},j[g],h):h}}}return j};a.widget.bridge=function(f,e){a.fn[f]=function(i){var g=typeof i==="string",h=c.call(arguments,1),j=this;i=!g&&h.length?a.widget.extend.apply(null,[i].concat(h)):i;if(g){this.each(function(){var k=a.data(this,f);if(!k){return a.error("cannot call methods on "+f+" prior to initialization; attempted to call method '"+i+"'")}if(!a.isFunction(k[i])||i.charAt(0)==="_"){return a.error("no such method '"+i+"' for "+f+" widget instance")}var l=k[i].apply(k,h);if(l!==k&&l!==d){j=l&&l.jquery?j.pushStack(l.get()):l;return false}})}else{this.each(function(){var k=a.data(this,f);if(k){k.option(i||{})._init()}else{e(i,this)}})}return j}};a.Widget=function(e,f){if(!this._createWidget){return new a[namespace][name](e,f)}if(arguments.length){this._createWidget(e,f)}};a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:false,create:null},_createWidget:function(e,f){f=a(f||this.defaultElement||this)[0];this.element=a(f);this.options=a.widget.extend({},this.options,this._getCreateOptions(),e);this.bindings=a();this.hoverable=a();this.focusable=a();if(f!==this){a.data(f,this.widgetName,this);this._bind({remove:"destroy"})}this._create();this._trigger("create");this._init()},_getCreateOptions:a.noop,_create:a.noop,_init:a.noop,destroy:function(){this._destroy();this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled");this.bindings.unbind("."+this.widgetName);this.hoverable.removeClass("ui-state-hover");this.focusable.removeClass("ui-state-focus")},_destroy:a.noop,widget:function(){return this.element},option:function(h,j){var e=h,k,g,f;if(arguments.length===0){return a.widget.extend({},this.options)}if(typeof h==="string"){e={};k=h.split(".");h=k.shift();if(k.length){g=e[h]=a.widget.extend({},this.options[h]);for(f=0;f<k.length-1;f++){g[k[f]]=g[k[f]]||{};g=g[k[f]]}h=k.pop();if(j===d){return g[h]===d?null:g[h]}g[h]=j}else{if(j===d){return this.options[h]===d?null:this.options[h]}e[h]=j}}this._setOptions(e);return this},_setOptions:function(f){var e=this;a.each(f,function(g,h){e._setOption(g,h)});return this},_setOption:function(e,f){this.options[e]=f;if(e==="disabled"){this.widget().toggleClass(this.widgetBaseClass+"-disabled ui-state-disabled",!!f).attr("aria-disabled",f);this.hoverable.removeClass("ui-state-hover");this.focusable.removeClass("ui-state-focus")}return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_bind:function(g,f){if(!f){f=g;g=this.element}else{g=a(g);this.bindings=this.bindings.add(g)}var e=this;a.each(f,function(i,h){g.bind(i+"."+e.widgetName,function(){if(e.options.disabled===true||a(this).hasClass("ui-state-disabled")){return}return(typeof h==="string"?e[h]:h).apply(e,arguments)})})},_hoverable:function(e){this.hoverable=this.hoverable.add(e);this._bind(e,{mouseenter:function(f){a(f.currentTarget).addClass("ui-state-hover")},mouseleave:function(f){a(f.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e);this._bind(e,{focusin:function(f){a(f.currentTarget).addClass("ui-state-focus")},focusout:function(f){a(f.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(g,h,j){var l=this.options[g],e;h=a.Event(h);h.type=(g===this.widgetEventPrefix?g:this.widgetEventPrefix+g).toLowerCase();j=j||{};if(h.originalEvent){for(var f=a.event.props.length,k;f;){k=a.event.props[--f];h[k]=h.originalEvent[k]}}this.element.trigger(h,j);e=a.isArray(j)?[h].concat(j):[h,j];return !(a.isFunction(l)&&l.apply(this.element[0],e)===false||h.isDefaultPrevented())}};a.each({show:"fadeIn",hide:"fadeOut"},function(f,e){a.Widget.prototype["_"+f]=function(i,h,k){if(typeof h==="string"){h={effect:h}}var j,g=!h?f:h===true||typeof h==="number"?e:h.effect||e;h=h||{};if(typeof h==="number"){h={duration:h}}j=!a.isEmptyObject(h);h.complete=k;if(h.delay){i.delay(h.delay)}if(j&&a.effects&&(a.effects.effect[g]||a.uiBackCompat!==false&&a.effects[g])){i[f](h)}else{if(g!==f&&i[g]){i[g](h.duration,h.easing,k)}else{i.queue(function(l){a(this)[f]();if(k){k.call(i[0])}l()})}}}});if(a.uiBackCompat!==false){a.Widget.prototype._getCreateOptions=function(){return a.metadata&&a.metadata.get(this.element[0])[this.widgetName]}}})(jQuery);
/**
 * Frameweld Toolkit
 * 
 * Dependancies: jQuery 1.5.1+ 
 * Included : jquery.ui.core, jquery.ui.position, jquery.ui.widget
 * ---------------------------------------------------------------------------------
 * 
 * @version 1.0
 * @since 08.31.2011
 * @author Omar D. Ellis
 */
FWTK.modules = {};
FWTK.modules.dom = function(b){
  b.cookie = _COOKIE;
};
FWTK.modules.events = function(b){
  b.form = {}; 
  b.form.error = function(options){
    var opts = options||{}, list = $((opts.id||'#errors_list')).val();
    if(list) {
		$.each((list.split(',')), function(id){
			$('#req__'+this+'_message').show();
			if((opts.is_change_color||false)) {
				$('#'+this).css({'background-color':(opts.color||'#FFF0F5')});
			}
		});
    }
  };
  b.form.success = function(options){
	var opts=options||{},id=opts.id||'.success';
	$(id).show();
	if((opts.is_fade||true)) {
		setTimeout(function(){ $(id).fadeOut(); }, (opts.fade_speed||5000));
	}
  };
  b.form.clear = function(id){
	$(':input', id)
	.not(':button, :submit, :reset, :hidden')
	.val('')
	.removeAttr('checked')
	.removeAttr('selected');	  
  };
}
FWTK.modules.components = function(b){
	b.components = function (){
		var comp = FWTK.slice(arguments).begin;
		for(var i = 0; i < comp.length; i++) {
			switch(comp[i]){
			case 'fileupload': b.fileuploader = _FILE_UPLOAD; break;
			case 'calendar': b.calendar = _CALENDAR; break
			case 'carousel': b.carousel = _CAROUSEL; break;
			case 'modal': b.modal = _MODAL; break;
			case 'menu': b.menu = _MENU; break;
			case 'autocomplete': 
				b.autoComplete = ($.fn.autocomplete)?function (id,config) {
				    var defaults = {
				        init_val: $(id).attr('value'),
				        source:'/autocomplete/',
				        minLength:2, 
				        delimiter: /(,|;)\s*/, /** regex or character */
				        width:300,
				        zIndex: 9999,
				        delay: 0, /** miliseconds */
				        noCache: false, /** default is false, set to true to disable caching */
				        select: function(event, ui){}
				    }
				    var opts = $.extend({}, defaults, (config||{})), obj = $(id);
				    obj.focus(function () {
				      if (obj.val() == opts.init_val) {
				        obj.val('');
				      }
				    });
				    obj.blur(function(){
				      if(b.isNull(obj.val())){
				        obj.val(opts.init_val);
				      }
				    });
				    obj.autocomplete(opts);
				}:null;
				break;
			}
		}
	};
}

FWTK.modules.utilities = function(b){
  b.json = {};
  b.json.stringify = (function(){
	  if (typeof JSON == 'object' && typeof JSON.stringify == 'function') {
		    return JSON.stringify;
		  }
		  return function (obj) {
		      var t = typeof (obj),dq='"',str='string';
		      if (t != 'object' || obj === null) {
		          if (t == str) { obj = dq+obj+dq; }
		          return String(obj);
		      } else {
		          var n, v, json = [], arr = (obj && obj.constructor == Array);
		          for (n in obj) {
		              v = obj[n]; t = typeof(v);
		              if (t == str){ v = dq+v+dq; }
		              else if (t == 'object' && v !== null){ v = arguments.callee(v); }
		              json.push((arr ? "" : '"' + n + '":') + String(v));
		          }
		          return (arr ? '[' : '{') + String(json) + (arr ? ']' : '}');
		      }
		  }
  })();
  b.inputBar = function (id) {
    var init_val = $(id).attr('value')
    $(id).focus(function () {
      if ($(this).val() == init_val) {
        $(this).val('');
      }
    });
    $(id).blur(function(){
      if(b.isNull($(this).val())){
        $(this).val(init_val);
      }
    });
  };
  b.animate = function (where, speed) { $("html,body").animate({ scrollTop: $(where).offset().top }, speed); }
  b.in_array = function(needle, haystack) {
	    for(var i = 0, l = haystack.length; i < l; i++) {
	        if(haystack[i] == needle) {
	            return true;
	        }
	    }
	    return false;
  };
  b.isAlphaChar = function (string){ return /^([a-zA-Z])+$/.test(string);};
  b.isDate = function (sDate){ return /^(\d){2}[/](\d){2}[/](\d){4}$/.test( sDate ); };
  b.isDecimal = function(sDecimal){ return /^\d+$|^\d+\.\d{2}$/.test(sDecimal); };
  b.isEmail = function (sEmail){ return /^[\w\.-]+@[\w\.-]+\.[a-z]{2,3}|[A-Z]{2,3}$/.test(sEmail); };
  b.isExist = function (string, sValue){ return (arguments[2] == true || arguments[2] == null) ? (string.toUpperCase().match(/sValue.toUpperCase()/) != -1) ? true : false  : (string.match(/sValue/) != -1); };
  b.isPhoneNumber = function (sPhoneNumber){ return (sPhoneNumber.indexOf("(")) ? /^[((](\d){3}[))](\d){3}[-|\s]{1}(\d){4}$/.test(sPhoneNumber) : /^(\d){3}[-|\s]{1}(\d){3}[-|\s]{1}(\d){4}$/.test(sPhoneNumber); };
  b.isSsn = function(sSSN){ return (sSSN.indexOf("-")) ? /^(\d){3}[-](\d){2}[-](\d){4}$/.test( sSSN ) : /^(\d){3}[-|\s](\d){2}[-|\s](\d){4}$/.test( sSSN ); };
  b.isTime = function (sTime){ return /^(\d){1,2}[:](\d){2}$/.test( sTime ); };
  b.isUsaCurrency = function (sCurrency){ return /^(\d){1,}[.](\d){2,}$/.test( sCurrency ); };
  b.isUsaZipcode = function (sZipCode){ return /^(\d){5}([-](\d){4})?$/.test(sZipCode); };
  b.isYear = function (sYear){ return /^(\d){4}$/.test( sYear ); };
  b.isNull = function (string){ return (string==null) ? true : false; };
  b.isNullOrEmpty = function (string){ return (string==null||string=="") ? true : false; };
  b.isNumeric = function (string){ return /^(\d){1,}$/.test(string); };
  b.isSpecialChar = function (string){ return /^([^a-zA-Z\d])+$/.test(string); };
  b.isUrl = function(string) { return /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/.test(string); };
}
FWTK.modules.ajax = function(b){
  var defaults = {
    url:'/',
    type:'POST',
    data:'',
    data_type:'json'
  };
  b.makeRequest = function(data,succ,err){
    /**
	 * Ajax call cannot be done without at least a url.
	 */
    if(typeof data != 'object') {
      b.log('Data can not be empty!');
      return b;
    }
    /**
	 * Extend ajax defaults.
	 */
    var o = $.extend({}, defaults, (data||{}));
    /**
	 * Make ajax request. If success and/or error function are declared they
	 * will be called; otherwise the defaults listed below will be used.
	 */
    return $.ajax({
			      type: o.type,
			      url: o.url,
			      data: o.data,
			      dataType: o.data_type,
			      success: (typeof succ == 'function') ? function(obj){succ(obj)} : {},
			      error: (typeof err == 'function')? function(request, status, error){ err(request, status, error)} : function(request, status, error) {
			        b.log('An unexpected error occured. ERROR: ' + error);
			      }
		   });
  };
}
/** 
 * Modules can be passed as an array or as individual parameters. 
 * 
 */
FWTK.slice = function(args) {
	  args = Array.prototype.slice.call(args), end = (args.length>0&&typeof args[(args.length-1)]=='function')?args.pop():null,
	  begin = (args[0] && typeof args[0] === "string") ? args : args[0];
	  return {'begin':begin,'end':end};
};

function FWTK() {
  var args = FWTK.slice(arguments),
  	  callback = args.end,
      modules = args.begin;
  /** Make sure the function is called as a constructor. */
  if (!(this instanceof FWTK)) {
    return new FWTK(modules, callback);
  }
  var fw = this, i,
      init = function() {
      /** Make sure JQuery library has loaded. */
      if ((typeof $ === 'undefined')){
        setTimeout(function(){
          init();
        }, 100);
        return;
      }
      /**
		 * Add modules to the core `this` object. "*" means "use all modules"
		 */ 
      if (modules === '*') {
        modules = [];
        for (i in FWTK.modules) {
          if (FWTK.modules.hasOwnProperty(i)) {
            modules.push(i);
          }
        }
      } else if (!modules) {
    	  modules = [];
      }
      /** Initialize the required modules. */
      for (i = 0; i < modules.length; i++) {
    	  try{
    		  FWTK.modules[modules[i]](fw);
    	  } catch(e){
    		  throw('message: ' + e.message + ', type: ' + (e.name?e.name:'Error') +', MODULE ERROR: ' + modules[i]);
    	  }
      }
      /** Make sure the document is ready before calling the callback function. */
      $(document).ready(function(){
        callback(fw);
      });
  }
  init();
}
FWTK.prototype = {
  getName: function(){ return 'Frameweld Toolkit Framework'; },
  getVersion: function(){ return '1.0'; },
  log: function(m){
	  	if(typeof console != 'undefined') {
		    console.log(m);
	  	} else {
	  		alert(m);
	  	}
  },
  isNull: function(o){ return o==''||o==null; }
};

