// JavaScript Document
// this file contains navigation functions

// show css popup menu when mouseover trigger point
function showGalleryMenu() {
	var trigger = document.getElementById("gallery_name");
	trigger.onmouseover = function() {
	  menuShowMenu('MenuContainer', 'menuSelectGallery',-2,0,'floating_r6_c13');
	}
	trigger.onmouseout = function() {
	  menuStartTimeout(100);
	}
}
addLoadEvent(showGalleryMenu);

//TODO: refactor repetitive elements between back & forward button functions
// handle events for forward and back buttons for main image and thumbnails
function backButtonMain() {
  var button = document.getElementById("back_button_main");
  button.onmouseover = function() {
	  MM_nbGroup('over','back_button_main','../images/navigation/btn_back_over.jpg','../images/navigation/btn_back_down.jpg',1);
  }
  button.onmouseout = function() {
	  MM_nbGroup('over','back_button_main','../images/navigation/btn_back_normal.jpg','../images/navigation/btn_back_normal.jpg',1);
  }
  button.onclick = function() {
	  MM_nbGroup('down','navbar1','back_button_main','../images/navigation/btn_back_down.jpg',1); rotateBigImageBackward('big_image','',big_img[current_big_img],1);
  }
}
addLoadEvent(backButtonMain);

function forwardButtonMain() {
	var button = document.getElementById("forward_button_main");
	button.onmouseover = function() {
		MM_nbGroup('over','forward_button_main','../images/navigation/btn_forward_over.jpg','../images/navigation/btn_forward_down.jpg',1);
	}
	button.onmouseout = function() {
		MM_nbGroup('over','forward_button_main','../images/navigation/btn_forward_normal.jpg','../images/navigation/btn_forward_normal.jpg',1);
	}
	button.onclick = function() {
		MM_nbGroup('down','navbar1','forward_button_main','../images/navigation/btn_forward_over.jpg',1); rotateBigImageForward('big_image','',big_img[current_big_img],1);
	}
}
addLoadEvent(forwardButtonMain);

function backButtonThumbs() {
	var button = document.getElementById("back_button_thumbs");
	button.onmouseover = function() {
		MM_nbGroup('over','back_button_thumbs','../images/navigation/btn_back_over.jpg','../images/navigation/btn_back_down.jpg',1);
	}
	button.onmouseout = function() {
		MM_nbGroup('over','back_button_thumbs','../images/navigation/btn_back_normal.jpg','../images/navigation/btn_back_normal.jpg',1);
	}
	button.onclick = function() {
		MM_nbGroup('down','navbar1','back_button_thumbs','../images/navigation/btn_back_over.jpg',1); rotateSmallImageBackward('thumb0','',small_img[current_small_img],1);
	}
}
 addLoadEvent(backButtonThumbs);

function forwardButtonThumbs() {
	var button = document.getElementById("forward_button_thumbs");
	button.onmouseover = function() {
		MM_nbGroup('over','forward_button_thumbs','../images/navigation/btn_forward_over.jpg','../images/navigation/btn_forward_down.jpg',1);
	}
	button.onmouseout = function() {
		MM_nbGroup('over','forward_button_thumbs','../images/navigation/btn_forward_normal.jpg','../images/navigation/btn_forward_normal.jpg',1);
	}
	button.onclick = function() {
		MM_nbGroup('down','navbar1','forward_button_thumbs','../images/navigation/btn_forward_over.jpg',1); rotateSmallImageForward('thumb0','',small_img[current_small_img],1);
	}
}
 addLoadEvent(forwardButtonThumbs);

//TODO: refactor these functions!!
// show big image from thumbnails
function showBigImageFromThumbA() {
	var image = document.getElementById("thumb0");
		image.onclick = function() {
		    showBigImage('big_image','',small_img[current_small_img],0);
		    return false;
	    }
	}

addLoadEvent(showBigImageFromThumbA);

function showBigImageFromThumbB() {
	var image = document.getElementById("thumb1");
	image.onclick = function() {
		showBigImage('big_image','',small_img[current_small_img],1);
		return false;
	}
}
addLoadEvent(showBigImageFromThumbB);

function showBigImageFromThumbC() {
	var image = document.getElementById("thumb2");
	image.onclick = function() {
		showBigImage('big_image','',small_img[current_small_img],2);
		return false;
	}
}
addLoadEvent(showBigImageFromThumbC);

