var contentmaskCoords = new Object();
var searching = false;
var pseudobuttonMorph, pseudobuttonTween,textfieldMorph,coords,myScroller;

function setStartCoordinates()
{
	playfieldTop = $('Content').getCoordinates().top;
	playfieldLeft = $('Content').getCoordinates().left;
	contentmaskCoords = $(TextMask).getStyles('top', 'left', 'height', 'width');
	contentmaskCoords.top = contentmaskCoords.top.toInt();
	contentmaskCoords.left = contentmaskCoords.left.toInt();
	contentmaskCoords.height = contentmaskCoords.height.toInt();
	contentmaskCoords.width = contentmaskCoords.width.toInt();
	contentmaskCoords = checkTextmaskMaxMin(contentmaskCoords);
	coords = $(TextMask).getCoordinates();
	coords = checkTextmaskMaxMin(coords);
}

function displayTextfield()
{
	$(TextMask).setStyles( {'top':contentmaskCoords.top, 'left':contentmaskCoords.left,  'height': contentmaskCoords.height, 'overflow': 'hidden'});
	
	if($(TextContainer).innerHTML.clean().length == 0)
	{
		$(TextMask).setStyle('visibility', 'hidden');
	}
}


function initScroller()
{
	myScroller = new ScrollControl($(TextContainer), {'htmlElementPrefix': '', 'controlOffset': 0}, $(TextMask),$('Scroller'),$('ScrollTrack'), $('ScrollKnob'), $('ScrollUpBtn'), $('ScrollDownBtn'))
	showScrolling();
}

function adjustScrolling()
{
	myScroller.adjustScroller();
}

function showScrolling()
{
	myScroller.showScroller();
}
function hideScrolling()
{

	myScroller.hideScroller();
}


function checkTextmaskMaxMin(obj)
{
	if((obj.top + obj.height) > textmaskMaxHeight || obj.top < textmaskMinTop)
		obj.top = textmaskMinTop;
	if((obj.top + obj.height) > textmaskMaxHeight)
		obj.height = textmaskMaxHeight;
	if((obj.left + obj.width) > textmaskMaxWidth || obj.left < textmaskMinLeft)
		obj.left = textmaskMinLeft;
	if((obj.left + obj.width) > textmaskMaxWidth)
		obj.width = textmaskMaxWidth;
	return obj;
}

