if (typeof RTS != 'object')
	var RTS = {};

RTS.head = {
	fixedHeight: function(o, h) {
		if (typeof o == 'string')
			o = document.getElementById(o);
		if (!o || typeof o != 'object') return;
		if (!h || typeof h != 'number') return;

		var ds = parseInt(o.style.fontSize) || parseInt(this.getStyle(o, 'font-size'));
		if (isNaN(ds) || ds <= 0) ds = 30;
		var s = ds;
		var cpt = 0;

		while (o.offsetHeight > h && s > 1 && cpt < 100) {
			o.style.fontSize = s + 'px';
			s--;
			cpt++;
		}

		if (s == 1 && o.offsetHeight > h)
			o.style.fontSize = ds;
	},
	formatCSS: function(o) {
		if (typeof o != 'object') return;
		o.style.display = 'block';
		o.style.height = 'auto';
	},
	getAttributes: function(o) {
		if (typeof o != 'object') return;
		var attr = {
			defaultHeight: o.attr('data-height'),
			height: null,
			defaultSize: parseInt(o.css('font-size')),
			size: null
		};
		attr.height = attr.defaultHeight;
		attr.size = attr.defaultSize;

		if (isNaN(attr.defaultSize) || attr.defaultSize == 0)
			attr.defaultSize = attr.size = 14;

		return (isNaN(attr.defaultHeight) || attr.defaultHeight == 0) ? null : attr;
	},
    // get the computed style of element (stackoverflow.com/questions/1955048)
    getStyle: function(el, styleProp) {
      var camelize = function (str) {
        return str.replace(/\-(\w)/g, function(str, letter){
          return letter.toUpperCase();
        });
      };

      if (el.currentStyle) {
        return el.currentStyle[camelize(styleProp)];
      } else if (document.defaultView && document.defaultView.getComputedStyle) {
        return document.defaultView.getComputedStyle(el,null)
                                   .getPropertyValue(styleProp);
      } else {
        return el.style[camelize(styleProp)]; 
      }
    },
	checkDisplay: function(o) {
		var me = this;
		if (typeof o != 'object') return;

		while(o.attr('nodeName') != 'HTML' && o.css('display') != 'none')
			o = o.parent();

		if (o.attr('nodeName') == 'HTML'
		 || o.attr('nodeName') == 'BODY') {
			var err = '[RTS.text] - error - object is ' + o.attr('nodeName');
			log(err);
			return null;
		}

		if (o.css('display') == 'none') {
			o.css('display', 'block');
			return o;
		} else
			return null;
	}
};

