// JavaScript Document

window.multiMenu = new Object();

window.multiMenu.add = function( id, linkHref, decoration, parentItem ){
	window.multiMenu[id] = new Object();
	window.multiMenu[id].linkHref = linkHref;
	window.multiMenu[id].decoration = decoration;
	window.multiMenu[id].parentItem = parentItem;
	
	
}

function loadContent( href, itemId ){
	
	//alert( href );
	//window.location.href = href + "&bid="+itemId;
	
	request_content( href, "pageContent", update_content );
}

function menu_press( itemId ){

	loadContent(window.multiMenu[itemId].linkHref, itemId);
	
	if( window.selectedMenuItem ) {
		decorate_item(  window.selectedMenuItem, "clear" );
	}
	
	decorate_item(  "LI_" + itemId, "underline" );
	
	
	window.selectedMenuItem = "LI_" + itemId;	
	
}	

function highlight_menu( itemId ){

	decorate_item(  itemId, "underline" );
	alert( window.selectedMenuItem );	
	decorate_item( window.selectedMenuItem, "clear" );

	window.selectedMenuItem = itemId;
	
	alert( window.selectedMenuItem );

}


function menu_over( itemId ){


	decorate_item( "LI_" + itemId, "underline" )

}


function menu_out( itemId ){

	decorate_item( "LI_" + itemId, "none" )
	
}

function decorate_item( menuId, decoration ){

	if( !decoration ){
		decoration = "underline";
	}
	
	var menuItem = document.getElementById( menuId );

	if( menuItem ){

		if( menuId == window.selectedMenuItem  && decoration != "clear"){

				return;

		}
		
		if( decoration == "underline" ){
			
			menuItem.style.backgroundImage = "url("+window.rootPath+"Design/menuMark_pixel.gif)";
		} else {
			menuItem.style.backgroundImage = "";
		}
		
	}	
}


/*************************************
*	Side Menu Handlers
*************************************/

window.cleanSource = window.rootPath+"Design/artMenu_clear.gif";
window.markSource = window.rootPath+"Design/artMenu_line.gif";

window.sideMenuCurrent = null;

function sideMenu_press( itemId, categoryId ){
	
	
	request_content( "vrArtWorks.php?cid="+categoryId+"&action=" + window.currentAction , "categoryContent", update_artBox );
	
	sideMenu_mark( itemId );	
}

function sideMenu_mark( itemId ){
	
	var image = document.getElementById( "Marker_" + itemId );
	
	if( image ){
		image.src = window.markSource;
		
		if( window.sideMenuCurrent && image.id !=  window.sideMenuCurrent.id ){
			window.sideMenuCurrent.src = window.cleanSource;
		}
		
		window.sideMenuCurrent = image;
		
	}
}

function sideMenu_over( itemId ){
	var image = document.getElementById( "Marker_" + itemId );
	
	if( window.sideMenuCurrent && window.sideMenuCurrent.id == image.id ){
		return;	
	}
	
	if( image ){
		image.src = window.markSource;	
	}
}

function sideMenu_out( itemId ){
	var image = document.getElementById( "Marker_" + itemId );
	
	if( window.sideMenuCurrent && window.sideMenuCurrent.id == image.id ){
		return;	
	}
	
	if( image ){
		image.src = window.cleanSource;	
	}
}



function loadSlide( categoryId, slideId ){
	request_content( "vrArtWorks.php?cid="+categoryId+"&sf="+slideId+"&action=" + window.currentAction , "categoryContent", update_artBox );	
}


function loadWork( categoryId, workId ){
	request_content( "vrArtWorks.php?cid="+categoryId+"&wid="+workId+"&action=" + window.currentAction , "workContent", update_artBox );	
}


/************************
*	Exhibitions
************************/
function exhibitionMenu_press( itemId, exhibitionId ){
	
	
	request_content( "vrArtExhibitions.php?eid="+exhibitionId+"&action=" + window.currentAction , "exhibitionContent", update_exhibitionBox );
	
	sideMenu_mark( itemId );	
}


function loadExhibition( exhibitionId, workId ){
	request_content( "vrArtExhibitions.php?eid="+exhibitionId+"&wid="+workId+"&action=" + window.currentAction , "exWorkContent", update_exhibitionBox );	
}

function loadExhibitionSlide( exhibitionId,slideId ){
	//alert( slideId );
	request_content( "vrArtExhibitions.php?eid="+exhibitionId+"&sf="+slideId+"&action=" + window.currentAction , "exhibitionPreview", update_exPreview );	
	request_content( "vrArtExhibitions.php?eid="+exhibitionId+"&sf="+slideId+"&action=" + window.currentAction , "exhibitionButtons", update_exButtons );	
}



/************************
*	Remove Handlers
*************************/

function remove_work(){
	var form = document.getElementById("workForm");
	
	if( form ){
		form.action = "Engine/removeDynamicWork.php";	
		form.submit();
	}
}

function remove_exWork(){
	var form = document.getElementById("workForm");
	
	if( form ){
		form.action = "Engine/removeDynamicExhibitionWork.php";	
		form.submit();
	}
}


function remove_category(){
	var form = document.getElementById("categoryForm");
	
	if( form ){
		form.action = "Engine/removeDynamicCategory.php";	
		form.submit();
	}
}
/************************
*	Big Image Display
*************************/

function show_bigImage(){
	var box = document.getElementById( "bigDisplay" );
	
	if( box ){
		box.style.visibility = "visible";	
	}
}

function hide_bigImage(){
	var box = document.getElementById( "bigDisplay" );
	
	if( box ){
		box.style.visibility = "hidden";	
	}
}


function show_exBigImage(){
	var box = document.getElementById( "exBigDisplay" );
	
	if( box ){
		box.style.visibility = "visible";	
	}
}

function hide_exBigImage(){
	var box = document.getElementById( "exBigDisplay" );
	
	if( box ){
		box.style.visibility = "hidden";	
	}
}


