function openPlayer(path, title)
{
	window.open('/sound_player.php?path=/lib/audio/' + path + '&title=' + title, 'player', 'width=300,height=100,left=300,top=200,x=300,y=200,toolbars=false,status=false,scrollbars=false');
}

function hilight(elem, state, over, out)
{
	var row = document.getElementById(elem);
	var bg = row.style.backgroundColor;
	
	if (state) {
		if (bg != over) {
			row.style.backgroundColor = over;
		}
	} else {
		if (bg != '' && bg != over && bg != out) {
			row.style.backgroundColor = bg;
		} else {
			row.style.backgroundColor = out;
		}
	}
}
		
function hilightToggle(elem, over, out)
{
	var row = document.getElementById(elem);
	var bg = row.style.backgroundColor;
	
	if (bg == over) {
		row.style.backgroundColor = out;
	} else {
		row.style.backgroundColor = over;
	}
}

function getWindowHeight() {
	var windowHeight = 0;
	
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		} else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	
	return windowHeight;
}

function getWindowWidth() {
	var windowWidth = 0;
	
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	} else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		} else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	
	return windowWidth;
}

function centerLayerOnPage(layer_id, vertical_shift)
{
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		var windowWidth = getWindowWidth();
		
		if (windowHeight > 0) {
			var contentElement = document.getElementById(layer_id);
			var contentHeight = contentElement.offsetHeight;
			var contentWidth = contentElement.offsetWidth;
			var contentLeft = contentElement.offsetLeft;
			
			if (windowHeight - contentHeight > 0) {
				top = ((windowHeight/2) - (contentHeight/2));
				left = ((windowWidth/2) - (contentWidth/2));
				
				if (vertical_shift && vertical_shift != undefined) {
					top += vertical_shift;
				}
				
				contentElement.style.position = 'absolute';
				contentElement.style.top = Math.floor(top) + 'px';
				contentElement.style.left = Math.floor(left) + 'px';
			} else {
				contentElement.style.position = 'static';
			}
		}
	}
}