var tinymceParamsLinkOnly = {
  theme: 'advanced',
  width: '480',
  height: '120',
  convert_urls: false,
  theme_advanced_buttons1 : 'link,unlink',
  theme_advanced_buttons2 : '',
  theme_advanced_buttons3 : '',
  theme_advanced_toolbar_location : 'top',
  theme_advanced_toolbar_align : 'left',
  body_class : 'markupText',
  content_css : '/stylesheets/markup-text.css'
};

var tinymceParamsListAndLink = {
  theme: 'advanced',
  width: '480',
  height: '120',
  convert_urls: false,
  theme_advanced_buttons1 : 'bullist,numlist,|,link,unlink',
  theme_advanced_buttons2 : '',
  theme_advanced_buttons3 : '',
  theme_advanced_toolbar_location : 'top',
  theme_advanced_toolbar_align : 'left',
  body_class : 'markupText',
  content_css : '/stylesheets/markup-text.css'
};

var tinymceParamsCompact = {
  theme: 'advanced',
  width: '480',
  height: '120',
  convert_urls: false,
  theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,bullist,numlist,|,forecolor,backcolor,|,link,unlink,|,undo,redo,|,code',
  theme_advanced_buttons2 : '',
  theme_advanced_buttons3 : '',
  theme_advanced_toolbar_location : 'top',
  theme_advanced_toolbar_align : 'left',
  body_class : 'markupText',
  content_css : '/stylesheets/markup-text.css'
};

var tinymceParamsFull = {
  theme: 'advanced',
  width: '480',
  height: '120',
  convert_urls: false,
  theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,bullist,numlist,|,forecolor,backcolor,|,link,unlink,|,justifyleft,justifycenter,justifyright,fontsizeselect,|,undo,redo,|,code',
  theme_advanced_buttons2 : '',
  theme_advanced_buttons3 : '',
  theme_advanced_toolbar_location : 'top',
  theme_advanced_toolbar_align : 'left',
  body_class : 'markupText',
  content_css : '/stylesheets/markup-text.css'
};


Array.contains = function(array, v) {
  for (var i in array){
    if (array.hasOwnProperty(i) && array[i] === v) {
      return true;
    }
  }
  return false;
};

String.prototype.strip = function() {
  return this.replace(/^[\s　]+/, '').replace(/[\s　]+$/, '');
};


String.prototype.truncate = function(length, suffix) {
  if (length >= this.length) {
    return this;
  }
  return substring(0, length) + suffix;
};

String.isBlank = function(s) {
  return (s == null || s.match( /^[\s　]*$/ ));
};

// http://www.optimalworks.net/blog/2007/web-development/javascript/array-detection
function isArray(array) { 
  return !!(array && array.constructor == Array);
}

function _T(template, params) {
  var replace = function(str, match) {
    return typeof params[match] === 'string'
        || typeof params[match] === 'number' ? params[match] : str;
  };
  return template.replace(/#\{([^{}]*)}/g, replace);
}

