/* ================================================================
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-20010 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, cordx)
	{

	var getImg = document.getElementById(gallery).getElementsByTagName("IMG");
	var getLi = document.getElementById(gallery).getElementsByTagName("LI");
	//var getSpan = document.getElementById(gallery).getElementsByTagName("SPAN");
	//alert(getImg.length)
	for (var i=0; i<getImg.length; i++) {
	if((i!=1)&&(i!=2)){
		//alert(getImg[i].src)
		getImg[i].onclick=function() {

			if ((this.className.indexOf('left')!=-1) ) {

				for (var x=getLi.length-1; x>=0; x--) {
					if ((getLi[x].className.indexOf('chosen'))!=-1)
						inicio = x+1;
					getLi[x].className='th'+(x+1);
				}

				var temp = inicio%10;

				if ((inicio-10)<0){
						inicio = getLi.length+10;
				}else{
					if ((inicio>=getLi.length)){
							if ((inicio==getLi.length)&&(temp==0))
								inicio = getLi.length;
							else
								inicio = getLi.length+(10-temp);
					}else{
						if ((inicio-10)==0){
							if((getLi.length%10==0))
								inicio = getLi.length+10;
							else
								inicio = getLi.length+20;

						}
					}
				}
				//alert(inicio)
				var temp = inicio%10;

				for (var x=getLi.length-1; x>=0; x--) {

					if((inicio-20-temp)>=0){
						//alert((inicio-20-temp))
						if ((x<inicio-20-temp)||(x>=inicio-10-temp)	){
							getLi[x].className='hide th'+(x+1);
						}
					}
				}

				if ((inicio-20)<0)
					getLi[getLi.length-1].className+=" chosen";
				else{
					var temp = inicio%10;
					if((inicio-11+temp)<getLi.length)
						getLi[inicio-11+temp].className+=" chosen";
					else
						getLi[getLi.length-1].className+=" chosen";
				}
			}



			if ((this.className.indexOf('right')!=-1) ) {
				for (var x=0; x<getLi.length; x++) {
					if ((getLi[x].className.indexOf('chosen'))!=-1)
						inicio = x+1;
					getLi[x].className='th'+(x+1);
				}

				if ((inicio)>=getLi.length)
					inicio = 0;

				for (var x=0; x<getLi.length; x++) {
					if ((x<=inicio-1)||(x>=inicio+10)	)
						getLi[x].className='hide th'+(x+1);
				}
				if ((inicio+9)>getLi.length)
					getLi[getLi.length-1].className+=" chosen";
				else
					getLi[inicio+9].className+=" chosen";
			}
		}
	}

	}

	if (cordx=='derecha')
	{
		for (var x=0; x<getLi.length; x++) {
			if ((getLi[x].className.indexOf('chosen'))!=-1)
				inicio = x+1;
			getLi[x].className='th'+(x+1);
		}

		if ((inicio)>=getLi.length)
			inicio = 0;

		for (var x=0; x<getLi.length; x++) {
			if ((x<=inicio-1)||(x>=inicio+10)	)
				getLi[x].className='hide th'+(x+1);
		}
		if ((inicio+9)>=getLi.length)
			getLi[getLi.length-1].className+=" chosen";
		else
			getLi[inicio+9].className+=" chosen";
	}

	if (cordx=='izquierda')
	{
				for (var x=getLi.length-1; x>=0; x--) {
					if ((getLi[x].className.indexOf('chosen'))!=-1)
						inicio = x+1;
					getLi[x].className='th'+(x+1);
				}

				var temp = inicio%10;

				if ((inicio-10)<0){
						inicio = getLi.length+10;
				}else{
					if ((inicio>=getLi.length)){
							if ((inicio==getLi.length)&&(temp==0))
								inicio = getLi.length;
							else
								inicio = getLi.length+(10-temp);
					}else{
						if ((inicio-10)==0){
							if((getLi.length%10==0))
								inicio = getLi.length+10;
							else
								inicio = getLi.length+20;

						}
					}
				}
				//alert(inicio)
				var temp = inicio%10;

				for (var x=getLi.length-1; x>=0; x--) {

					if((inicio-20-temp)>=0){
						//alert((inicio-20-temp))
						if ((x<inicio-20-temp)||(x>=inicio-10-temp)	){
							getLi[x].className='hide th'+(x+1);
						}
					}
				}

				if ((inicio-20)<0)
					getLi[getLi.length-1].className+=" chosen";
				else{
					var temp = inicio%10;
					if((inicio-11+temp)<getLi.length)
						getLi[inicio-11+temp].className+=" chosen";
					else
						getLi[getLi.length-1].className+=" chosen";
				}

	}


/*
		for (var i=0; i<getLi.length; i++) {
			getLi[i].onclick=function() {
				for (var x=0; x<getLi.length; x++) {
					if ((getLi[x].className.indexOf('chosen'))!=-1)	{
						getLi[x].className=getLi[x].className.replace("chosen", "");
					}
				}
			this.className+=" chosen";
			}
		}*/

	}
