jQuery.noConflict();

jQuery(function($){
	//Jolkona.loginDialog.show();

	// Bind My Jolkona tab in site header
	jQuery('#nav li.account a').bind('click', function(){
		if (jQuery(this).text() == 'Sign In / Join Now') {
			Jolkona.loginDialog.show(function(){
				document.location = Jolkona.baseUrl + 'members';
			});
			return false;
		}
	});
	
	jQuery('#checkboxIcons p #inline').bind('click', function(){
		 
			Jolkona.linkDialog.show(function(){
				document.location = Jolkona.baseUrl + 'social_linking';
			});
			return false; 
	});
	
	
	// Bind require login links
	jQuery('a.requireLogin').bind('click', function(){
		if (!Jolkona.isUserLoggedIn) {
			var url = jQuery(this).attr('href');
			Jolkona.loginDialog.show(function(){
				document.location = url;
			});	
			return false;
		}
	});

	// Bind homepage box link
	jQuery('#home li.first a').bind('click', function(){
		if ((this).getElementsByTagName('img')[0].getAttribute('src') == 'img/home/become-a-jolkona-member.gif') {
			Jolkona.loginDialog.show(function(){
				document.location = Jolkona.baseUrl + 'members';
			});
			return false;
		}
	});
		
	// Bind master footer links
	jQuery('#masterFooter a.dialog').bind('click', function(){
		Jolkona.showDialog(jQuery(this).attr('href'));
		return false;
	});
	
	// Wire-up "hint" text fields
	jQuery('input.hint').each(function(){
		var value = jQuery(this).val();
		jQuery(this).bind('focus', function(){
			if (jQuery(this).val() == value) jQuery(this).val('').removeClass('hint');
		});
		jQuery(this).bind('blur', function(){
			if (!jQuery(this).val()) jQuery(this).val(value).addClass('hint');
		});		
	});
		
	// Bind print links
	jQuery('a.printLink').bind('click', function(){
		var printDialog = window.open(jQuery(this).attr('href'),'printdialog','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=740,height=700,screenX=200,screenY=200,top=100,left=100');
		return false;
	});

}); 
	

Jolkona = {
	isUserLoggedIn: false,
	baseUrl: '',
	giveDialogCache: [],
	showDialog: function(options) {
	
		$ = jQuery;

		var url = null;
		var content = null;
		
		if (typeof options == 'object') {
			if (options.content) content = options.content;
		} else if (typeof options == 'string') {
			url = options;
		} else {
			return false;
		}
						
		if (!jQuery('#generalDialog').length) {
			jQuery('body').append('<div id="generalDialog" class="dialog"><div class="hd"><div class="m">&nbsp;</div><div class="l">&nbsp;</div><div class="r">&nbsp;</div><div class="clear">&nbsp;</div></div><div class="bd"><div class="m"></div><div class="l">&nbsp;</div><div class="r">&nbsp;</div><div class="clear">&nbsp;</div></div><div class="ft"><div class="m">&nbsp;</div><div class="l">&nbsp;</div><div class="r">&nbsp;</div><div class="clear">&nbsp;</div></div></div>');
		}
		
		// Initalize YUI dialog widget
		var dialog = new YAHOO.widget.Dialog('generalDialog', {
			fixedcenter: false,
			draggable: false,
			modal: true,
			underlay: 'none',
			visible: false,
			zindex: 100,
		});	
		
		// Render and show dialog
		dialog.render();			
		dialog.show();
		
		if (content) {
			jQuery('#generalDialog .bd .m').html(content);
			onContentLoaded();
		} else {
			jQuery('#generalDialog').addClass('dialogLoading');
			// Clear existing content so it doesn't display while new content is being loaded
			jQuery('#generalDialog .bd .m').html('');
			jQuery('#generalDialog .bd .m').load(url + ' #content', function(response, status, xhr){
				jQuery('#generalDialog .bd').css('height', jQuery('#generalDialog #content').height());
				jQuery('#generalDialog').removeClass('dialogLoading');
				onContentLoaded();
			});
		}
		
		function onContentLoaded() {
			if (options.width) jQuery('#generalDialog .hd').css('width', options.width);
			if (options.width) jQuery('#generalDialog .ft').css('width', options.width);
			if (options.width) jQuery('#generalDialog .bd').css('width', options.width);
			if (options.height) jQuery('#generalDialog .bd').css('height', options.height);
			dialog.center();
		}
							
	},
	showGiveDialog: function(id){
		
		$ = jQuery;

		if (!jQuery('#giveDialog').length) {
			jQuery('body').append('<div id="giveDialog" class="dialog"><div class="hd"><div class="m">&nbsp;</div><div class="l">&nbsp;</div><div class="r">&nbsp;</div><div class="clear">&nbsp;</div></div><div class="bd"><div class="m"></div><div class="l">&nbsp;</div><div class="r">&nbsp;</div><div class="clear">&nbsp;</div></div><div class="ft"><div class="m">&nbsp;</div><div class="l">&nbsp;</div><div class="r">&nbsp;</div><div class="clear">&nbsp;</div></div></div>');
		}
		
		// Initalize YUI dialog widget
		var dialog = new YAHOO.widget.Dialog('giveDialog', {
			fixedcenter: false,
			draggable: false,
			modal: true,
			underlay: 'none',
			visible: false,
			zindex: 1000
		});
		
		// Render and show dialog
		dialog.render();
		dialog.show();
		
		// Load content
		if (typeof Jolkona.giveDialogCache[id] == 'undefined') {
			jQuery('#giveDialog').addClass('dialogLoading');
			// Clear existing content so it doesn't display while new content is being loaded
			jQuery('#giveDialog .bd .m').html('');
			jQuery('#giveDialog .bd .m').load(Jolkona.baseUrl + 'projects/' + id + '/?context=givedialog', function(response, status, xhr){
				Jolkona.giveDialogCache[id] = response;
				jQuery('#giveDialog').removeClass('dialogLoading');
				initDialog();
			});
		} else {
			jQuery('#giveDialog .bd .m').html(Jolkona.giveDialogCache[id]);
			initDialog();
		}
		
		function initDialog() {
			jQuery('#giveDialog .bd').css('height', jQuery('#projectGiveDialog').height() + 30);
			dialog.center();
			jQuery('#projectGiveDialog input[name="price[]"]').bind('keyup', updateSubtotals);
			jQuery('#projectGiveDialog select[name="quantity[]"]').bind('change', updateSubtotals);
			jQuery('#projectGiveDialog select[name="quantity[]"]').eq(0).trigger('change');
			jQuery('#projectGiveDialog a.give').bind('click', function(){
				// Make sure the user has selected at least one item
				/*
				var isQuantitySelected = false;
				var quantities = jQuery('#projectGiveDialog select[name="quantity[]"]');
				quantities.each(function(){
					if (jQuery(this).val() != 0) isQuantitySelected = true;
				});
				if (!isQuantitySelected) {
					alert('You must select a quantity for at least one gift.');
					return false;
				}
				*/
				if (calculateTotal() == 0) {
					alert('Please make a selection.');
					return false;
				}
				jQuery('#projectGiveDialog a.give, #projectGiveDialog a.cancel').hide();
				jQuery('#projectGiveDialog').append('Processing...');
				jQuery('#projectGiveDialog [name="quantity[]"]').each(function(index){
					if (jQuery(this).val() > 0) {
						// Get quantity and product price
						var quantity = jQuery(this).val();
						var price = getPrice(index);
						// Only submit if both quantity and price are greater than zero
						if (quantity > 0 && price > 0) jQuery.ajax({async: false, type: 'post', url: Jolkona.baseUrl + 'carts/add/' + jQuery(this).parents('tr').find('input[name="product_id[]"]').eq(0).val() + '/0/' + quantity + '/0/0/' + price});
					}
				});
				document.location = Jolkona.baseUrl + 'members/giftbasket';
			});
			jQuery('#projectGiveDialog a.cancel').bind('click', function(){
				dialog.hide();
			});
		}
				
		function updateSubtotals() {
			jQuery('#projectGiveDialog [name="quantity[]"]').each(function(index){
				var subtotal = 0;
				var quantity = jQuery(this).val();
				var price = getPrice(index);
				if (price > 0 && quantity > 0) subtotal = quantity * price;
				jQuery('#projectGiveDialog td.subtotal span').eq(index).html(subtotal.toFixed(2))
			});
		}

		function calculateTotal() {
			updateSubtotals();
			var total = 0;
			jQuery('#projectGiveDialog td.subtotal span').each(function(){
				total += parseFloat(jQuery(this).html());
			});
			return total;
		}

		function getPrice(index) {
			var price = jQuery('#projectGiveDialog input[name="price[]"]').eq(index).val();
			price = new Number(price.replace(/[^0-9\.]+/g, ''));
			if (price == 'NaN') price = 0;
			return price;
		}

		return false;
	},
	loginDialog: {
		initalized: false,
		dialog: null,
		onAuthenticate: null,
		show: function(onAuthenticateCallback) {
		
			if (!this.initalized) this.init();
			
			this.onAuthenticate = onAuthenticateCallback;
			
			// Show dialog
			this.dialog.show();
			
		},
		init: function(){
		
			$ = jQuery;

			jQuery('body').append('<div id="loginDialog" class="dialog dialogLoading"><div class="hd"><div class="m">&nbsp;</div><div class="l">&nbsp;</div><div class="r">&nbsp;</div><div class="clear">&nbsp;</div></div><div class="bd"><div class="m"></div><div class="l">&nbsp;</div><div class="r">&nbsp;</div><div class="clear">&nbsp;</div></div><div class="ft"><div class="m">&nbsp;</div><div class="l">&nbsp;</div><div class="r">&nbsp;</div><div class="clear">&nbsp;</div></div></div>');
			
			// Initalize YUI dialog widget
			var dialog = new YAHOO.widget.Dialog('loginDialog', {
				close: true,
				fixedcenter: false,
				draggable: false,
				modal: true,
				underlay: 'none',
				zIndex: 10000,
				visible: false
			});	

			jQuery('#loginDialog .bd .m').load(Jolkona.baseUrl + 'members/loginregister/?nocache=' + Math.random(), function(response, status){
				jQuery('#loginDialog').removeClass('dialogLoading');				
				initEvents();
			});
			
			// Render dialog
			dialog.render();
			dialog.center();
			
			// Assign to loginDialog object for probing
			this.dialog = dialog;
			
			function initEvents() {
				if (jQuery('#captcha').get(0)) jQuery('#captcha').get(0).src = Jolkona.baseUrl + 'members/captcha/' + Math.random();
				jQuery('#loginDialog .captchaRow .instructions a').attr('id', 'refreshCaptcha').attr('onclick', '');
				jQuery('#refreshCaptcha').bind('click', function(){
					jQuery('#captcha').get(0).src = Jolkona.baseUrl + 'members/captcha/' + Math.random();
					return false;
				});
				jQuery('#userLogin, #userRegistration').bind('submit', function(){
					jQuery.post(jQuery(this).attr('action'), jQuery(this).serialize(), function(response, status){
						if (jQuery(response).find('input[name="isUserLoggedIn"]').val() == 1) {
							Jolkona.loginDialog.dialog.hide();
							if (jQuery.isFunction(Jolkona.loginDialog.onAuthenticate)) Jolkona.loginDialog.onAuthenticate();
						} else {					
							jQuery('#loginDialog .bd .m').html(response);
							jQuery('#loginDialog .bd').css('height', jQuery('#loginRegister').height());						
							initEvents();
						}
					});
					return false;
				});			
			}				
		}	
	},linkDialog: {
		initalized: false,
		dialog: null,
		onAuthenticate: null,
		show: function(onAuthenticateCallback) {
		
			if (!this.initalized) this.init();
			
			this.onAuthenticate = onAuthenticateCallback;
			
			// Show dialog
			this.dialog.show();
			
		},
		init: function(){
		
			jQuery('body').append('<div id="loginDialog" class="dialog dialogLoading"><div class="hd"><div class="m">&nbsp;</div><div class="l">&nbsp;</div><div class="r">&nbsp;</div><div class="clear">&nbsp;</div></div><div class="bd"><div class="m"></div><div class="l">&nbsp;</div><div class="r">&nbsp;</div><div class="clear">&nbsp;</div></div><div class="ft"><div class="m">&nbsp;</div><div class="l">&nbsp;</div><div class="r">&nbsp;</div><div class="clear">&nbsp;</div></div></div>');
			
			// Initalize YUI dialog widget
			var dialog = new YAHOO.widget.Dialog('loginDialog', {
				close: true,
				fixedcenter: false,
				draggable: false,
				draggable: false,
				modal: true,
				underlay: 'none',
				zIndex: 10000,
				visible: false
			});	

			jQuery('#loginDialog .bd .m').load(Jolkona.baseUrl + 'social_linking/?ajax=1', function(response, status){
				jQuery('#loginDialog').removeClass('dialogLoading');				
				initEvents();
			});
			
			// Render dialog
			dialog.render();
			dialog.center();
			
			// Assign to loginDialog object for probing
			this.dialog = dialog;
			
			function initEvents() { 			
			}				
		}	
	},
	inviteFriendsDialog: {
		initalized: false,
		dialog: null,
		redirect: null,
		campaignId: null,
		requireLogin: true,
		message: null,
		show: function(o) {
		
			var inviteFriendsDialog = this;
			
			if (this.requireLogin && Jolkona.isUserLoggedIn == false) {
				Jolkona.loginDialog.show(function(){
					doShow();
				});
			} else {
				doShow();
			}
				
			function doShow() {
			
				if (typeof o == 'object') {
					if (o.redirect) inviteFriendsDialog.redirect = o.redirect;
					if (o.message) inviteFriendsDialog.message = o.message;
				} else if (typeof o == 'string') {
					inviteFriendsDialog.redirect = o;
				}
				
				if (!inviteFriendsDialog.initalized) inviteFriendsDialog.init();
				
				inviteFriendsDialog.dialog.center();
				
				// Show dialog
				inviteFriendsDialog.dialog.show();
			}
			
		},
		init: function() {

			$ = jQuery;

			var inviteFriendsDialog = this;
			
			jQuery('body').append('<div id="inviteFriendsDialog" class="dialog dialogLoading"><div class="hd"><div class="m">&nbsp;</div><div class="l">&nbsp;</div><div class="r">&nbsp;</div><div class="clear">&nbsp;</div></div><div class="bd"><div class="m"></div><div class="l">&nbsp;</div><div class="r">&nbsp;</div><div class="clear">&nbsp;</div></div><div class="ft"><div class="m">&nbsp;</div><div class="l">&nbsp;</div><div class="r">&nbsp;</div><div class="clear">&nbsp;</div></div></div>');
			
			// Initalize YUI dialog widget
			var dialog = new YAHOO.widget.Dialog('inviteFriendsDialog', {
				close: true,
				fixedcenter: false,
				draggable: false,
				modal: true,
				underlay: 'none',
				visible: false,
				hideaftersubmit: false,
				postmethod: 'form',
				zindex: 1000,			
			});	
			
			dialog.render();
			
			jQuery('#inviteFriendsDialog .bd .m').load(Jolkona.baseUrl + 'members/invitefriends/?nocache=' + Math.random(), function(response, status){
				jQuery('#inviteFriendsDialog').removeClass('dialogLoading');
				jQuery('#inviteFriends input[name="redirect"]').val(this.redirect);
				jQuery('#inviteFriends textarea').val(inviteFriendsDialog.message);			
				Jolkona.inviteFriendsDialog.resize();
				Jolkona.inviteFriendsDialog.dialog.center();
				inviteFriendsDialog.setCampaignId(inviteFriendsDialog.campaignId);
			});			
			
			// Assign to inviteFriendsDialog object for probing
			this.dialog = dialog;
			
			// Flag as initalized
			this.initalized = true;
								
		},
		resize: function() {
			$ = jQuery;
			jQuery('#inviteFriendsDialog .bd').eq(0).css('height', jQuery('#inviteFriends').height());
		},
		setCampaignId: function(id) {
			$ = jQuery;
			this.campaignId = id;
			jQuery('#inviteFriends input[name="data[Campaign][id]"]').val(id);
		},
		setMessage: function(message) {
			$ = jQuery;
			this.message = message;
			jQuery('#inviteFriends textarea').val(message);			
		}		
	}
}
 
JolkonaSocial={
	googlelogin:function(key,callback){ 
			window.open('https://accounts.google.com/o/oauth2/auth?client_id='+key+'&scope=https://www.google.com/m8/feeds/&redirect_uri='+callback+'&response_type=code',"","toolbar=no,width=500,height=500,left=100,top=100");
		},
	livelogin:function(key,callback){
			window.open('https://oauth.live.com/authorize?client_id='+key+'&display=popup&locale=en&redirect_uri='+callback+'&response_type=token&scope=wl.signin,wl.emails,wl.birthday,wl.basic&state=display%3Dpopup%26request_ts%3D1313595788562%26response_type%3Dtoken',"","toolbar=no,width=500,height=300,left=100,top=100");
		},
	fblogin:function(key,callback){
			window.open("https://www.facebook.com/dialog/oauth?client_id="+key+"&display=popup&redirect_uri="+callback+"&scope=publish_stream,email,offline_access,user_location,user_website,user_birthday","","toolbar=no,width=500,height=300,left=100,top=100");
		},	
	twitterlogin:function(key,callback){  
			window.open(callback,"","toolbar=no,width=500,height=300,left=100,top=100");
		}
}


function isValidEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

/**
 * Minified version of jquery.cookie.js.
 */
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};

/**
 * Minified version of http://www.JSON.org/json2.js
 */
var JSON=JSON||{};(function(){function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return this.valueOf()?this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}}());

/**
 * Minified version of jquery.maxlength.js from http://remysharp.com/2008/06/30/maxlength-plugin/
 */
(function($){jQuery.fn.maxlength=function(settings){if(typeof settings=='string'){settings={feedback:settings};}
settings=jQuery.extend({},jQuery.fn.maxlength.defaults,settings);function length(el){var parts=el.value;if(settings.words)
parts=el.value.length?parts.split(/\s+/):{length:0};return parts.length;}
return this.each(function(){var field=this,$field=jQuery(field),$form=jQuery(field.form),limit=settings.useInput?$form.find('input[name=maxlength]').val():$field.attr('maxlength'),$charsLeft=$form.find(settings.feedback);function limitCheck(event){var len=length(this),exceeded=len>=limit,code=event.keyCode;if(!exceeded)
return;switch(code){case 8:case 9:case 17:case 36:case 35:case 37:case 38:case 39:case 40:case 46:case 65:return;default:return settings.words&&code!=32&&code!=13&&len==limit;}}
var updateCount=function(){var len=length(field),diff=limit-len;$charsLeft.html(diff||"0");if(settings.hardLimit&&diff<0){field.value=settings.words?field.value.split(/(\s+)/,(limit*2)-1).join(''):field.value.substr(0,limit);updateCount();}};$field.keyup(updateCount).change(updateCount);if(settings.hardLimit){$field.keydown(limitCheck);}
updateCount();});};jQuery.fn.maxlength.defaults={useInput:false,hardLimit:true,feedback:'.charsLeft',words:false};})(jQuery);
