
var currentgalnum = 0;
var stacknumber = 1;
var new_opacity = 0;
var curr_gallery;
var prev_gallery = -1;
var gallery_Array;
var begin_IntervalId;
var gal_length;
var gal_ready = true;
var loadcontrols = true;

function showgallery(galnum)
{
	if(gal_ready == true)
	{
		gal_ready = false;
		gallery_Array = new Array("Anne_et_Valentin", "Beausoleil", "Cutler_and_Gross", "Gold_and_Wood", "Lafont", "LA_Eyeworks", "Lindberg", "Mykita", "Oliver_Goldsmith", "Oliver_Peoples", "Paul_Smith", "RetroSpecs", "Sama", "Tag_Heuer");

		gal_length = gallery_Array.length - 1;
		
		if(galnum == 'left')
		{
			if(currentgalnum == 0)
			{
				currentgalnum = gal_length;
			}
			else
			{
				currentgalnum = currentgalnum - 1;
			}
		}
		else if(galnum == 'right')
		{
			if(currentgalnum == gal_length)
			{
				currentgalnum = 0
			}
			else
			{
				currentgalnum = currentgalnum + 1;
			}
		}
		else
		{
			currentgalnum = galnum;
		}
		
		stacknumber = stacknumber + 1;
		curr_gallery = document.getElementById(gallery_Array[currentgalnum]);
		curr_gallery.style.zIndex = stacknumber;
		
		
		var linkarray = Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n");
		for(a=0; a<linkarray.length; a++)
		{
			document.getElementById(linkarray[a]).style.color = "#b6d0da";
			document.getElementById(linkarray[a]).style.fontWeight = "normal"; 
		}			
				
		document.getElementById(linkarray[currentgalnum]).style.color = "#ffffff";
		document.getElementById(linkarray[currentgalnum]).style.fontWeight = "bold"; 


		if(prev_gallery == currentgalnum)
		{
			opacity = 100;
			new_opacity = 100;
		}
		else
		{
			opacity = 0;
			
			if(currentgalnum == 0)
			{	
				A_a.restartSlideShow();
				A_b.restartSlideShow();
				A_c.restartSlideShow();
			}
			else if(currentgalnum == 1)
			{
				B_a.restartSlideShow();
				B_b.restartSlideShow();
				B_c.restartSlideShow();
			}
			else if(currentgalnum == 2)
			{
				C_a.restartSlideShow();
				C_b.restartSlideShow();
				C_c.restartSlideShow();
			}
			else if(currentgalnum == 3)
			{
				D_a.restartSlideShow();
				D_b.restartSlideShow();
				D_c.restartSlideShow();
			}
			else if(currentgalnum == 4)
			{
				E_a.restartSlideShow();
				E_b.restartSlideShow();
				E_c.restartSlideShow();
			}	
			else if(currentgalnum == 5)
			{
				F_a.restartSlideShow();
				F_b.restartSlideShow();
				F_c.restartSlideShow();
			}	
			else if(currentgalnum == 6)
			{
				G_a.restartSlideShow();
				G_b.restartSlideShow();
				G_c.restartSlideShow();
			}				
			else if(currentgalnum == 7)
			{
				H_a.restartSlideShow();
				H_b.restartSlideShow();
				H_c.restartSlideShow();
			}			
			else if(currentgalnum == 8)
			{
				I_a.restartSlideShow();
				I_b.restartSlideShow();
				I_c.restartSlideShow();
			}					
			else if(currentgalnum == 9)
			{
				J_a.restartSlideShow();
				J_b.restartSlideShow();
				J_c.restartSlideShow();
			}					
			else if(currentgalnum == 10)
			{
				K_a.restartSlideShow();
				K_b.restartSlideShow();
				K_c.restartSlideShow();
			}						
			else if(currentgalnum == 11)
			{
				L_a.restartSlideShow();
				L_b.restartSlideShow();
				L_c.restartSlideShow();
			}								
			else if(currentgalnum == 12)
			{
				M_a.restartSlideShow();
				M_b.restartSlideShow();
				M_c.restartSlideShow();
			}							
			else if(currentgalnum == 13)
			{
				N_a.restartSlideShow();
				N_b.restartSlideShow();
				N_c.restartSlideShow();
			}							


			if(prev_gallery == 0)
			{	
				A_a.stopcompleteSlideShow();
				A_b.stopcompleteSlideShow();
				A_c.stopcompleteSlideShow();
			}
			else if(prev_gallery == 1)
			{
				B_a.stopcompleteSlideShow();
				B_b.stopcompleteSlideShow();
				B_c.stopcompleteSlideShow();	
			}
			else if(prev_gallery == 2)
			{
				C_a.stopcompleteSlideShow();
				C_b.stopcompleteSlideShow();
				C_c.stopcompleteSlideShow();
			}
			else if(prev_gallery == 3)
			{
				D_a.stopcompleteSlideShow();
				D_b.stopcompleteSlideShow();
				D_c.stopcompleteSlideShow();
			}			
			else if(prev_gallery == 4)
			{
				E_a.stopcompleteSlideShow();
				E_b.stopcompleteSlideShow();
				E_c.stopcompleteSlideShow();
			}	
			else if(prev_gallery == 5)
			{
				F_a.stopcompleteSlideShow();
				F_b.stopcompleteSlideShow();
				F_c.stopcompleteSlideShow();
			}
			else if(prev_gallery == 6)
			{
				G_a.stopcompleteSlideShow();
				G_b.stopcompleteSlideShow();
				G_c.stopcompleteSlideShow();
			}
			else if(prev_gallery == 7)
			{
				H_a.stopcompleteSlideShow();
				H_b.stopcompleteSlideShow();
				H_c.stopcompleteSlideShow();
			}
			else if(prev_gallery == 8)
			{
				I_a.stopcompleteSlideShow();
				I_b.stopcompleteSlideShow();
				I_c.stopcompleteSlideShow();
			}
			else if(prev_gallery == 9)
			{
				J_a.stopcompleteSlideShow();
				J_b.stopcompleteSlideShow();
				J_c.stopcompleteSlideShow();
			}	
			else if(prev_gallery == 10)
			{
				K_a.stopcompleteSlideShow();
				K_b.stopcompleteSlideShow();
				K_c.stopcompleteSlideShow();
			}		
			else if(prev_gallery == 11)
			{
				L_a.stopcompleteSlideShow();
				L_b.stopcompleteSlideShow();
				L_c.stopcompleteSlideShow();
			}
			else if(prev_gallery == 12)
			{
				M_a.stopcompleteSlideShow();
				M_b.stopcompleteSlideShow();
				M_c.stopcompleteSlideShow();
			}			
			else if(prev_gallery == 13)
			{
				N_a.stopcompleteSlideShow();
				N_b.stopcompleteSlideShow();
				N_c.stopcompleteSlideShow();
			}			
	}
	
		curr_gallery.style.filter = 'alpha(opacity = ' + opacity + ')';
		curr_gallery.style.MozOpacity=opacity/100;
		curr_gallery.style.opacity=opacity/100;
		curr_gallery.style.khtmlOpacity=opacity/100;
		curr_gallery.style.display = "block";
		begin_IntervalId = setInterval("fadein()", 50);
		
		prev_gallery = currentgalnum;
	}
}

function fadein()
{
	new_opacity = new_opacity + 5;
	curr_gallery = document.getElementById(gallery_Array[currentgalnum]);
	curr_gallery.style.filter = 'alpha(opacity = ' + new_opacity + ')';
	curr_gallery.style.MozOpacity=new_opacity/100;
	curr_gallery.style.opacity=new_opacity/100;
	curr_gallery.style.khtmlOpacity=new_opacity/100;
	
	if(loadcontrols == true)
	{	
		var controls = document.getElementById("controls");
		controls.style.filter = 'alpha(opacity = ' + new_opacity + ')';
		controls.style.MozOpacity=new_opacity/100;
		controls.style.opacity=new_opacity/100;
		controls.style.khtmlOpacity=new_opacity/100;
	
		if(new_opacity >= 100)
		{
			loadcontrols = false;
		}
	}
	
	if(new_opacity >= 100)
	{
		gal_ready = true;
		new_opacity = 0;
		clearInterval(begin_IntervalId);
	}
}

