if(typeof(EVERYZING) == 'undefined') { EVERYZING = {}; }

// Collect full transcript text
var fullTranscriptText = "";

// actual clipping function
EVERYZING.clipText = function(obj,maxLen) {
	fullTranscriptText = obj.innerHTML;
	jQuery(obj).truncate(maxLen, {
        chars: / /,
        leave: false,
        trail: [true, "...\"", ""]
    });
}

EVERYZING.truncate_to = function(target, maxLen){
    maxLen = parseInt(maxLen);
    if (isNaN(maxLen) || maxLen <= 0){ return; }    
    var target = jQuery(target);    
    target.each(function(){
		EVERYZING.clipText(this,maxLen);
    });
};

// display or clip full transcript on media lander
EVERYZING.displayTranscript = function(tObj, tBtn, tClipLength) {
	tObj = document.getElementById(tObj);
	tBtn = document.getElementById(tBtn);
	if (tBtn.innerHTML == "+") { // expand
		tObj.innerHTML = fullTranscriptText;
		tObj.className = "ez-full";
		tBtn.innerHTML = "-";
	} else { // clip
		EVERYZING.clipText(tObj, tClipLength);
		tObj.className = "ez-clipped";
		tBtn.innerHTML = "+";
	}
}
