// JavaScript Document


var click_type = 0; /* 0=auto, 10=roll over a specific picture, 20=next, 30=back , 40=pause*/

function show_body(n) /*The body has two main blocks. Body1 is the main body, body2 is the pop-up blowups of the pictures*/
{
	/*hide the big image if you are going back to the main body*/
		if (n == 1) 
		{
			document.getElementById('BigPicId').src = big_path+"bigpicholder.jpg";
		}

	/* first, make sure all the body blocks are hidden */
	for (i=1; i<=2; i++) 
	{
		document.getElementById("body" + i).style.display = 'none';
	}
	/* now show the body block you want */
	document.getElementById("body" + n).style.display = 'block';
}

function hide_captions ()
{
	for (i=1; i<=PICS.length; i++) 
	{
		if(document.getElementById("tab_" + i) != null) /* This IF checks to see if the object exists*/
		{
		document.getElementById("tab_" + i).style.display = 'none';	/* hide captions for slide show */
		document.getElementById("tab_" + i+"b").style.display = 'none';	/* hide captions for blow ups */
		}
	}
}
function show_sets ()
{
	for (i=1; i<=num_sets; i++) 
	{  
	    if(document.getElementById("set" + i) != null) /* This IF checks to see if the object exists*/
		{
		document.getElementById("set" + i).style.display = 'none';
		/* change all set links to normal*/
		document.getElementById('set_link'+i).className = '';
		}
	}
	/* show the current set of thumbnails*/
	document.getElementById("set" + current_set).style.display = 'block';
	/* hihglight the link for the current set*/
	document.getElementById('set_link'+current_set).className = 'tab_active';
	
}
function my_reset()
{
	clearTimeout ( RotateTimerId );
	clearTimeout ( FadeTimerID );
	fade_level = 100;
	rotate_pic();
}
function swap_pic(n)
{
	document.getElementById('bigback').src = "images/goback"+n+".gif";
}
function set_big_pic(n)
{
	document.getElementById('BigPicId').src = big_path+n+"b.jpg";
}
function rotate_pic() 
{
	if (click_type == 30)/* they clicked back, go backwards */
	{
		current_pic = current_pic - 1;
		if (current_pic == first_pic-1) current_pic=last_pic;
	}
	if (click_type == 0 | click_type == 10 | click_type == 20) 
	/* it's on auto (0), or they rolled over a specific picture (10), or they clicked next(20)*/
	{   
		current_pic++;
		if (current_pic > last_pic) current_pic=first_pic; 
	}
	/* If click_type = 3, they clicked pause so we just stay on the current picture*/
	document.getElementById('rotating_pic_back').src = pic_path + PICS[current_pic-1];
	do_fade();
	do_link_color(); /* this sets the color of the bar under the thumbnails*/
	if (click_type == 10) 
	{
		/* They rolled over a specific picture (10) so pause */
		RotateTimerId = setTimeout('rotate_pic();', 6000);
	}
	if (click_type == 0 | click_type == 20 | click_type == 30) 
	{
		/* Hold the picture for the normal shorter amount of time*/
		RotateTimerId = setTimeout('rotate_pic();', 4000);
	}
	click_type=0;/* reset the click type */
	hide_captions(); /*clear all the captions before showing the one you want*/
	document.getElementById("tab_" + current_pic).style.display = 'block';	/*show captions for slide show */
	document.getElementById("tab_" + current_pic+"b").style.display = 'block';	/* show captions for blow ups */
}
function do_link_color()
{
	/* reset the links to black */
	for (i=1;i<=PICS.length;i++)
	{   
	    if(document.getElementById('link'+i) != null) /* This IF checks to see if the object exists*/
		{
			document.getElementById('link'+i).style.borderBottom = '4px solid #bababa';
		}
	}
	document.getElementById('link'+current_pic).style.borderBottom = '4px solid #fe8b01';
}
var fade_level = 100;
function do_fade() 
{
	if (fade_level == 0) 
	{
		fade_level = 100;
		document.getElementById('rotating_pic_front').src = document.getElementById('rotating_pic_back').src
		setOpacity(document.getElementById('rotating_pic_front'), 100);
	}
	else 
	{
	fade_level-=2;
	setOpacity(document.getElementById('rotating_pic_front'), fade_level);
	FadeTimerID = setTimeout('do_fade();',10);
	}
}
function setOpacity(e, v) 
{
	e.style.opacity = (v / 100);
	e.style.MozOpacity = (v / 100);
	e.style.filter = (v == 100 ? '' : 'alpha(opacity=' + v + ');');
}
