var timer;
var menu_last_id = -1;
var menu_timer_id = null;

function menuOver( mid ){
	if (menu_last_id != -1 && menu_last_id != mid)
		menuOutImmediate( menu_last_id );
	if (menu_timer_id != null)
	{	
		clearTimeout( menu_timer_id );
		menu_timer_id = null;
	}
	menu_last_id = mid;
	
	setDivProperty( 'subMenuItem' + mid , 'left', getImageX('alignmentImage' + mid ) + 135);
	setDivProperty( 'subMenuItem' + mid , 'top', getImageY( 'alignmentImage' + mid ) - 6);
	setDivProperty( 'subMenuItem' + mid , 'zIndex' , 2000 );
	setDivProperty( 'subMenuItem' + mid , 'visibility', 'visible');

}


function menuOutImmediate( mid )
{
	setDivProperty( 'subMenuItem' + mid , 'zIndex' , -1 );
	setDivProperty( 'subMenuItem' + mid, 'visibility', 'hidden' );
	
	if (menu_last_id == mid)
		menu_last_id = -1;
}

function moveOut( mid ){
	menu_timer_id = setTimeout( 'menuOutImmediate( ' + mid + ' )', 750 );
}

function menuMouseOver(td) {
	if (document.getElementById) {
		td.style.backgroundColor="#DDDDDD";
	}
}

function menuMouseOut(td) {
	if (document.getElementById) {
		td.style.backgroundColor="white";
	}
}

var sub_menu_last_id = -1;
var sub_menu_timer_id = null;

function subMenuOver( mid ){
	if (sub_menu_last_id != -1 && sub_menu_last_id != mid)
		subMenuOutImmediate( sub_menu_last_id );
	if (sub_menu_timer_id != null)
	{	
		clearTimeout( sub_menu_timer_id );
		sub_menu_timer_id = null;
	}
	sub_menu_last_id = mid;
	
	setDivProperty( 'subMenuItem2' + mid , 'left', getImageX( 'subalignmentImage' + mid ) + 1);
	setDivProperty( 'subMenuItem2' + mid , 'top', getImageY( 'subalignmentImage' + mid ) - 5);
	setDivProperty( 'subMenuItem2' + mid , 'zIndex' , 2000 );
	setDivProperty( 'subMenuItem2' + mid , 'visibility', 'visible');

}


function subMenuOutImmediate( mid )
{
	setDivProperty( 'subMenuItem2' + mid , 'zIndex' , -1 );
	setDivProperty( 'subMenuItem2' + mid, 'visibility', 'hidden' );
	
	if (sub_menu_last_id == mid)
		sub_menu_last_id = -1;
}

function subMoveOut( mid ){
	sub_menu_timer_id = setTimeout( 'subMenuOutImmediate( ' + mid + ' )', 750 );
}

var third_menu_last_id = -1;
var third_menu_timer_id = null;

function thirdMenuOver( mid ){
	if (third_menu_last_id != -1 && third_menu_last_id != mid)
		thirdMenuOutImmediate( third_menu_last_id );
	if (third_menu_timer_id != null)
	{	
		clearTimeout( third_menu_timer_id );
		third_menu_timer_id = null;
	}
	third_menu_last_id = mid;
	
	setDivProperty( 'subMenuItem3' + mid , 'left', getImageX( 'subalignmentImage2' + mid ) + 1);
	setDivProperty( 'subMenuItem3' + mid , 'top', getImageY( 'subalignmentImage2' + mid ) - 5);
	setDivProperty( 'subMenuItem3' + mid , 'zIndex' , 2000 );
	setDivProperty( 'subMenuItem3' + mid , 'visibility', 'visible');

}


function thirdMenuOutImmediate( mid )
{
	setDivProperty( 'subMenuItem3' + mid , 'zIndex' , -1 );
	setDivProperty( 'subMenuItem3' + mid, 'visibility', 'hidden' );
	
	if (third_menu_last_id == mid)
		third_menu_last_id = -1;
}

function thirdMoveOut( mid ){
	third_menu_timer_id = setTimeout( 'thirdMenuOutImmediate( ' + mid + ' )', 750 );
}

function menuMouseOver(imgName) {
	setImageSrc(imgName , '/images/general/menu_over.gif');
}

function menuMouseOut(imgName) {
	setImageSrc(imgName , '/images/general/menu.gif');
}

//this is the other stuff

function doOnload( sectionName ) {
	if ((sectionName == null) || (sectionName == ""))
		return;
	
	if(window.parent.top_frame.windowLoaded) {
		window.parent.top_frame.document.images['right'].src = '/images/general/' + sectionName + '_right.jpg'; 
	} else {
		setTimeout( 'doOnload(\'' + sectionName + '\')', 500 );
	}
}

function show(num) {
	if(timer != null) {
		clearTimeout(timer);
	}
	setDivProperty('asdf', 'visibility', 'visible');
}

function hide(num) {
	clearTimeout(timer);
	timer = null;
	setDivProperty('asdf', 'visibility', 'hidden');
}

function startHideTimeout() {
	timer = setTimeout("hide('asdf')", 1000);
}		

function qlink(page)
{
	if (page != null)
	{
		window.open( page, '_self' );
	}
}

function checkFrames() {
	if(window.name != "content_frame") {
		var currentPage = window.location.href;
		window.location.href = "/index.jsp?content_frame=" + currentPage.replace( "&", "%26" ).replace( ":", "%3A" );
	}
}
