//   CONFIGURATION

// If you want to SHOW other menus type FALSE
var hideMenus = true;

// If you want to SHOW all the submenus on startup it should be TRUE
var showMenu = false;

//set this to TRUE top move the content DOWN
var destination = false;

//speed of moving the news the DEFAULT is 35

var newsSpeed = 41;

// END OF CONFIGURATION
// !!!!!!!!!!!!!!!!!
// DO NOT EDIT BELOW
// DO NOT EDIT BELOW
// DO NOT EDIT BELOW

var intDown;
var intUp;
var appearing;

function showAllMenus(){
	var allMenus = document.getElementsByTagName('ul');
	if(showMenu) {
		for(i=0; i<allMenus.length;i++){
			allMenus[i].style.display = 'block';
			allMenus[i].parentNode.className = 'minus';
		}
	}
}
function blurAll() {
	var allATags = document.getElementsByTagName('a');
	for(i=0; i<allATags.length; i++) {
		allATags[i].onclick = function() {
			this.blur();
		}
	}

}

function expandMenu(tova) {
	var rows;
	var uls = tova.parentNode.parentNode.getElementsByTagName('ul');
	if(tova.parentNode.getElementsByTagName('ul')[0].style.display == 'block') {
		var showIt = false;
	}
	else {
		var showIt = true;
	}
	for(i=0;i<uls.length;i++) {
		uls[i].style.display = 'none';
		rows = uls[i].getElementsByTagName('li');
	}
	if(showIt) {
		tova.parentNode.getElementsByTagName('ul')[0].style.display = 'block';
	}
	tova.blur();
}

function newsReader() {
	if(document.getElementById('news_container')){
	var news = document.getElementById('news_container');
	var field = document.getElementById('news_middle');
	news.style.position = 'absolute';
	moveDown = function() {
		if(news.offsetTop > field.offsetHeight) {
			news.style.top = -news.offsetHeight + 'px';
		}
		news.style.top = news.offsetTop + 1 + 'px';
	}
	moveUp = function() {
		if(news.offsetTop < -news.offsetHeight) {
			news.style.top = field.offsetHeight + 'px';
		}
		news.style.top = news.offsetTop - 1 + 'px';
	}
	if(destination) {
		news.style.top = field.offsetTop - news.offsetHeight + 'px';
		intDown = setInterval('moveDown()', newsSpeed);
		field.onmouseover = function() {
			if(intDown){
				clearInterval(intDown);
			}
		}
		field.onmouseout = function() {
			intDown = setInterval('moveDown()', newsSpeed);
		}
	}
	else {
		news.style.top = field.offsetHeight + 'px';
		intUp = window.setInterval('moveUp()', newsSpeed);
		field.onmouseover = function() {
			if(intUp){
				clearInterval(intUp);
			}
		}
		field.onmouseout = function() {
			intUp = setInterval('moveUp()', newsSpeed);
		}
	}
	}
}
function relPage() {
	window.location = window.location;
}

// function for dragging elements
function startDrag(that, isHeld) {
	that.parentNode.style.position = 'absolute';
	firstX = that.parentNode.offsetLeft;
	firstY = that.parentNode.offsetTop;
	var firstPosX = false;
	var firstPosY = false;
	
	document.onmousemove = function(e) {
		if (document.all) {
			positionX = event.clientX + document.body.scrollLeft;
			positionY = event.clientY + document.body.scrollTop;
		}
		else {
			document.captureEvents(Event.MOUSEMOVE)
			positionX = e.pageX;
			positionY = e.pageY;
		}  
		if (positionX < 0){positionX = 0;}
		if (positionY < 0){positionY = 0;}  
		
		if(!firstPosX || !firstPosY) {
			firstPosX = positionX;
			firstPosY = positionY;
		}
		document.onmouseup = function() {
			isHeld = false;
			firstPosX = false;
			firstPosY = false;
		}
		
		if(isHeld) {
			that.parentNode.style.top = positionY + firstY - firstPosY + 'px';
			that.parentNode.style.left = positionX + firstX - firstPosX + 'px';
		}
	}
}

window.onload = function() {
	newsReader();
//	blurAll();
	showAllMenus();
}
function confirmDel(page, id, message) {
	var msg = confirm(message);
	if (msg){
		window.location = page + id;
	}
	else {
		return false;
	}
}