function scrollBoard() {
	if(parseInt($('roller').style.top) > -350) {
		$('roller').style.top = (parseInt($('roller').style.top) - 1) + 'px';
	} else {
		$('roller').style.top = (parseInt($('roller').style.top) + 800) + 'px';
	}
}

function startScrollBoard() {
	setInterval("scrollBoard()", 40);
}


// Scroll a div to bottom and make it visible
function scrollDivBottom(id)
{
	var objDiv = $(id);
	objDiv.scrollTop = objDiv.scrollHeight;
	$(id).style.visibility = "visible";
}

// Append content of tempDiv to mainDiv
// Scroll mainDiv to bottom
// Blank tempDiv
function appendDiv(mainDiv, tempDiv)
{
	if ($(tempDiv).innerHTML != '')
	{
		$(mainDiv).innerHTML += $(tempDiv).innerHTML;
		scrollDivBottom(mainDiv);
		$(tempDiv).innerHTML = '';
	}
}

function dontdisplayElement(id)
{
	document.getElementById(id).style.display = "none";
	return true;
}

function displayElement(id)
{
	document.getElementById(id).style.display = "inline";
	return true;
}

// Close Div (ie: empty it and make display not visible)
function dontdisplayAndEmptyElement(id)
{
	if ($(id)) {
		dontdisplayElement(id);
		$(id).innerHTML = '';
	}
}

function hideElement(id)
{
	$(id).style.visibility = "hidden";
	return true;
}

function showElement(id)
{
	$(id).style.visibility = "visible";
	return true;
}

/* Show loading animation */
function showLA()
{
	if ($('loadingAnimation')) {
		$('loadingAnimation').style.visibility = "visible";
	}

	if ($('loadingAnimation')) {
		$('applicationHeader').style.opacity = 0.7;
		$('applicationHeader').style.filter = 'alpha(opacity=70)';
	}

	document.body.style.cursor = 'wait';

	// Hide popup div
	dontdisplayAndEmptyElement('popupZone');

	hideTooltip();
}

/* Show loading animation */
function hideLA()
{
	if ($('loadingAnimation')) {
		$('loadingAnimation').style.visibility = "hidden";
	}

	if ($('loadingAnimation')) {
		$('applicationHeader').style.opacity = 1;
		$('applicationHeader').style.filter = 'alpha(opacity=100)';
	}

	document.body.style.cursor = 'default';
}

// Show div is box is unchecked - hide it if not
function hideshowId(box, id)
{
	if(box.checked == false) {
		displayElement(id);
	}
	else {
		dontdisplayElement(id);
	}
}

// Show div is box is checked - hide it if not
function showhideId(box, id)
{
	if(box.checked == true) {
		displayElement(id);
	}
	else {
		dontdisplayElement(id);
	}
}

/* Fill the given field with selected value */
function setFieldValue(id, value)
{
	var field = document.getElementById(id);

	/* Set value */
	field.value = value;

	/* Fire onChange event */
	if (typeof(field.onchange) == "function") field.onchange();
}

/* Fill the given field with selected value */
function setFieldValueIfEmpty(id, value)
{
	var field = document.getElementById(id);

	if (field.value == '') {
		field.value = value;
	}

	/* Fire onChange event */
	if (typeof(field.onchange) == "function") field.onchange();
}

// Return element position
function findElementPosition(obj) {
	var curleft = curtop = 0;

	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}


// Scroll to the top of the given object
function scrollTopElement(id) {

	var curtop = 0;
	var obj = $(id);

	if (obj.offsetParent) {
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curtop += obj.offsetTop
		}
	}

	scroll(0,curtop - 50);
}

// Return the current mouse position
function getMouseXY(e) {

	// Detect if the browser is IE or not.
	// If it is not IE, we assume that the browser is NS.
	var IE = document.all?true:false

	// If NS -- that is, !IE -- then set up for mouse capture
	// if (!IE) document.captureEvents(Event.MOUSEMOVE)

	// Temporary variables to hold mouse x-y pos.s
	var tempX = 0;
	var tempY = 0;

	if (IE) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft
		tempY = event.clientY + document.body.scrollTop
	} else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX
		tempY = e.pageY
	}
	// catch possible negative values in NS4
	if (tempX < 0){tempX = 0}
	if (tempY < 0){tempY = 0}

	return [ tempX, tempY];
}

// Return element size
function getElementSize(obj) {
	return [obj.style.width, obj.style.height];
}

// Move element close to targetElement
// when done make element visible

function moveCloseTo(elementId, targetElementId) {

	// Get position of the calling element
	targetElementPos = findElementPosition($(targetElementId));

	// Get width of target element
	targetElementHeight = $(targetElementId).getHeight();

	// Get style of element to move
	elementStyle = $(elementId).style;

	// Move the popup close to the calling element
	elementStyle.top = (targetElementPos[1] + targetElementHeight + 5) + 'px';
	elementStyle.left = (targetElementPos[0]) + 'px';

	// Make the popup visible
	elementStyle.visibility = 'visible';
}

// Get the document object of an iframe
function getIframeDocumentObj(IFrameObj)
{
	if (IFrameObj.contentDocument) {
		// For NS6
		return IFrameObj.contentDocument;
	} else if (IFrameObj.contentWindow) {
		// For IE5.5 and IE6
		return IFrameObj.contentWindow.document;
	} else if (IFrameObj.document) {
		// For IE5
		return IFrameObj.document;
	} else {
		return null;
	}
}

