// /*
//   @author: remy sharp / http://remysharp.com
//   @params:
//     feedback - the selector for the element that gives the user feedback. Note that this will be relative to the form the plugin is run against.
//     hardLimit - whether to stop the user being able to keep adding characters. Defaults to true.
//     useInput - whether to look for a hidden input named 'maxlength' instead of the maxlength attribute. Defaults to false.
//     words - limit by characters or words, set this to true to limit by words. Defaults to false.
//   @license: Creative Commons License - ShareAlike http://creativecommons.org/licenses/by-sa/3.0/
//   @version: 1.2
//   @changes: code tidy via Ariel Flesler and fix when pasting over limit and including \t or \n
// */
// (function(a){a.fn.maxlength=function(b){if(typeof b=="string"){b={feedback:b};}b=a.extend({},a.fn.maxlength.defaults,b);function c(d){var e=d.value;if(b.words){e=d.value.length?e.split(/\s+/):{length:0};}return e.length;}return this.each(function(){var i=this,h=a(i),g=a(i.form),f=b.useInput?g.find("input[name=maxlength]").val():h.attr("maxlength"),j=g.find(b.feedback);function e(m){var k=c(this),n=k>=f,l=m.keyCode;if(!n){return;}switch(l){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 b.words&&l!=32&&l!=13&&k==f;}}var d=function(){var k=c(i),l=f-k;j.html(l||"0");if(b.hardLimit&&l<0){i.value=b.words?i.value.split(/(\s+)/,(f*2)-1).join(""):i.value.substr(0,f);d();}};h.keyup(d).change(d);if(b.hardLimit){h.keydown(e);}d();});};a.fn.maxlength.defaults={useInput:false,hardLimit:true,feedback:".charsLeft",words:false};})(jQuery);
// 
// /*
//  * jQuery autoResize (textarea auto-resizer)
//  * @copyright James Padolsey http://james.padolsey.com
//  * @version 1.04
//  */
// (function(a){a.fn.autoResize=function(j){var b=a.extend({onResize:function(){},animate:true,animateDuration:150,animateCallback:function(){},extraSpace:20,limit:1000},j);this.filter('textarea').each(function(){var c=a(this).css({resize:'none','overflow-y':'hidden'}),k=c.height(),f=(function(){var l=['height','width','lineHeight','textDecoration','letterSpacing'],h={};a.each(l,function(d,e){h[e]=c.css(e)});return c.clone().removeAttr('id').removeAttr('name').css({position:'absolute',top:0,left:-9999}).css(h).attr('tabIndex','-1').insertBefore(c)})(),i=null,g=function(){f.height(0).val(a(this).val()).scrollTop(10000);var d=Math.max(f.scrollTop(),k)+b.extraSpace,e=a(this).add(f);if(i===d){return}i=d;if(d>=b.limit){a(this).css('overflow-y','');return}b.onResize.call(this);b.animate&&c.css('display')==='block'?e.stop().animate({height:d},b.animateDuration,b.animateCallback):e.height(d)};c.unbind('.dynSiz').bind('keyup.dynSiz',g).bind('keydown.dynSiz',g).bind('change.dynSiz',g)});return this}})(jQuery); 
// 
// 


//Author: Realazy
//http://realazy.org/blog/ (chinese)
jQuery.arrRemove=function(a,c){for(var b=0,d=0;b<a.length;++b){if(a[b]!=c){a[d++]=a[b];}}a.length--;};

// Delicious Style Tag Suggest
// usage: jQuery(from).tagTo(target, seperator)
// from contain the tags(use a links), target must be assigned and its type must be input type="text" or textarea
// seperator can be "-", "," and space etc, if not assign, the default seperator is ","
// tclass is the class name of the tag which is currently selected, if not assign, the default class name is "selected"
jQuery.fn.tagTo=function(d,b,a){if("string"==typeof d){d=jQuery(d);}b=arguments[1]||",";a=arguments[2]||"selected";var c="input";if(c=="input"||c=="textarea"){jQuery("a",this).click(function(){if(jQuery.trim(d.val())==""){d.val(jQuery(this).text());jQuery(this).addClass(a);}else{var f=d.val().split(b);var g=false;var e;for(var h=0,j=f.length;h<j;++h){if(jQuery.trim(f[h])==jQuery(this).text()){g=true;e=h;break;}}if(g==true){jQuery.arrRemove(f,f[e]);jQuery(this).removeClass(a);}else{f.push(jQuery(this).text());jQuery(this).addClass(a);}d.val(f.join(b));}return false;});}else{throw"target must be an text area";}};

$(document).ready(function(){

    // // =========================================================================
    // // Apply character entry limits.
    // // =========================================================================
    // 
    // $('#short_description').maxlength({
    //   'feedback' : '#short-limit span'
    // });
    // 
    // $('#description, #biography').maxlength({
    //   'feedback' : '#long-limit span',
    //   'words' : true,
    //   'useInput' : true
    // });
    // 
    // // =========================================================================
    // // Add auto expanding text areas
    // // =========================================================================
    // 
    // $('textarea').autoResize();

    // =========================================================================
    // Automagically add and remove tags
    // =========================================================================

    $("#tag_list").tagTo("#tags", " ");
    
});










