/* ================================================================ 
This copyright notice must be untouched at all times.

The original version of this script and the associated (x)html
is available at http://www.stunicholls/gallery/left_right_click.html
Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.
This script and the associated (x)html may be modified in any 
way to fit your requirements.
=================================================================== */


clickMenu = function(gallery) {
	var getImg = document.getElementById(gallery).getElementsByTagName("IMG");
	var getLi = document.getElementById(gallery).getElementsByTagName("LI");

		
	for (var i=0;i<getImg.length ;i++ ){
		getImg[i].onclick=function(){
			
			
			if (this.className == 'next' || this.className == 'start'){
				document.getElementById('left-arrow').className  = 'left-arrow';
				for (var x=0;x<getLi.length ;x++ ){
					if (getLi[x].className.indexOf('chosen')<getLi.length){
						 						
						if (getLi[x].className == 'chosen' && x!=getLi.length-1){
							
							getLi[x+1].className = 'chosen';
							getLi[x].className = 'hide';
							
							x++;
							
						} 
					} 
					if (getLi[x].className == 'chosen' && x==getLi.length-1){
						document.getElementById('right-arrow').className  = 'right-arrow-off';
					} 
				}
			}
			
			if (this.className == 'right'){
				document.getElementById('left-arrow').className  = 'left-arrow';
				for (var x=0;x<getLi.length ;x++ ){
					if (getLi[x].className.indexOf('chosen')<getLi.length){
						if (getLi[x].className == 'chosen' && x!=getLi.length-1){
							
							getLi[x+1].className = 'chosen';
							getLi[x].className = 'hide';
																					
							x++;
							
						}
					} 

					if (getLi[x].className == 'chosen' && x==getLi.length-1){
						document.getElementById('right-arrow').className  = 'right-arrow-off';
					} 
				}
			}

			if (this.className == 'left'){
				document.getElementById('right-arrow').className  = 'right-arrow';
				
				for (var x=0;x<getLi.length ;x++ ){
					
					if (getLi[x].className == 'chosen' && x>0){
							
						getLi[x-1].className = 'chosen';
						getLi[x].className = 'hide';
						
					}
					//
					if (getLi[x].className.indexOf('chosen') == -1 && getLi[0].className.indexOf('chosen') == 0) {
						document.getElementById('left-arrow').className  = 'left-arrow-off';	
										
					}

					
				}
			}

		}
	}
	
}