slideshow = 1;
onslide = 0;

function chgstatusMain() {
	if (slideshow == 0) {
		slideshow = 1;
		document.getElementById('playID').style.display = "none";
		document.getElementById('pauseID').style.display = "block";
		SS = setTimeout("slideShow();", 7500);
	} else {
		clearTimeout(SS);
		slideshow = 0;
		document.getElementById('pauseID').style.display = "none";
		document.getElementById('playID').style.display = "block";
	}
}

function gotoMain(showthis) {
	if (onslide == 0) {
		var maxshowed = document.getElementById('maxshowed').value;
		showthis = parseInt(showed) + parseInt(showthis);
		if (showthis == maxshowed) { showthis = 0; }
		else if (showthis < 0) { showthis = parseInt(maxshowed) -1; }
		showMain(showthis);
	}
}

function showMain(showthis) {
	if (onslide == 0) {
		if (showed != showthis) {
			$('#number' + showed).css("border", "1px solid #FFFFFF");
			document.getElementById('thumb' + showed).style.display = "none";
			document.getElementById('content' + showed).style.display = "none";

			document.getElementById('number' + showthis).style.border = "1px solid #000000";
			document.getElementById('thumb' + showthis).style.display = "block";
			document.getElementById('thumb' + showthis).style.opacity = 1;
			document.getElementById('thumb' + showthis).style.MozOpacity = 1;
			document.getElementById('thumb' + showthis).style.KhtmlOpacity = 1;
			document.getElementById('thumb' + showthis).style.filter = 'alpha(opacity=' + 100 + ')';
			document.getElementById('content' + showthis).style.display = "block";
			document.getElementById('content' + showthis).style.opacity = 1;
			document.getElementById('content' + showthis).style.MozOpacity = 1;
			document.getElementById('content' + showthis).style.KhtmlOpacity = 1;
			document.getElementById('content' + showthis).style.filter = 'alpha(opacity=' + 100 + ')';
			showed = showthis;
			if (slideshow == 1) {
				clearTimeout(SS);
				slideshow = 0;
				document.getElementById('pauseID').style.display = "none";
				document.getElementById('playID').style.display = "block";
			}
		}
	}
}

function Slide(obj, o) {
	$(obj).css({
		'display': 'block',
		'opacity': (o / 100),
		'MozOpacity': (o / 100),
		'KhtmlOpacity': (o / 100),
		'filter': 'alpha(opacity=' + (o / 100) + ')'
	});
}

function borderSlide(obj, o) {
	$(obj).css('border', '1px solid ' + o);
}

function hidePic(obj) {
	$(obj).css('display', 'none');
}

function showPic(obj) {
	$(obj).css({
		'display': 'block',
		'opacity': 1,
		'MozOpacity': 1,
		'KhtmlOpacity': 1,
		'filter': 'alpha(opacity=' + 1 + ')'
	});
}

function slideShow() {
	if (slideshow == 1) {
		onslide = 1;
		var maxshowed = document.getElementById('maxshowed').value;
		if ((parseInt(showed) + 1) == maxshowed) { shownext = 0; } else { shownext = parseInt(showed) + 1; }
		timer = 750;
		i = 100;
		j = 0;

		var thisnumber = '#number' + showed;
		var nextnumber = '#number' + shownext;
		var thisthumb = '#thumb' + showed;
		var nextthumb = '#thumb' + shownext;
		var slideshowcontent = '#slideshowcontent';

		SS = setTimeout(function() {borderSlide(thisnumber, "#222222")}, (timer += 75));
//	  SS = setTimeout(function() {Slide(thisthumb, (i -= 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (i -= 10))}, timer);

		SS = setTimeout(function() {borderSlide(thisnumber, "#444444")}, (timer += 75));
//	  SS = setTimeout(function() {Slide(thisthumb, (i -= 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (i -= 10))}, timer);

		SS = setTimeout(function() {borderSlide(thisnumber, "#666666")}, (timer += 75));
//	  SS = setTimeout(function() {Slide(thisthumb, (i -= 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (i -= 10))}, timer);

		SS = setTimeout(function() {borderSlide(thisnumber, "#777777")}, (timer += 75));
//	  SS = setTimeout(function() {Slide(thisthumb, (i -= 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (i -= 10))}, timer);

		SS = setTimeout(function() {borderSlide(thisnumber, "#888888")}, (timer += 75));
//	  SS = setTimeout(function() {Slide(thisthumb, (i -= 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (i -= 10))}, timer);

		SS = setTimeout(function() {borderSlide(thisnumber, "#999999")}, (timer += 75));
//	  SS = setTimeout(function() {Slide(thisthumb, (i -= 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (i -= 10))}, timer);

		SS = setTimeout(function() {borderSlide(thisnumber, "#AAAAAA")}, (timer += 75));
//	  SS = setTimeout(function() {Slide(thisthumb, (i -= 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (i -= 10))}, timer);

		SS = setTimeout(function() {borderSlide(thisnumber, "#CCCCCC")}, (timer += 75));
//	  SS = setTimeout(function() {Slide(thisthumb, (i -= 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (i -= 10))}, timer);

		SS = setTimeout(function() {borderSlide(thisnumber, "#EEEEEE")}, (timer += 75));
//	  SS = setTimeout(function() {Slide(thisthumb, (i -= 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (i -= 10))}, timer);

		SS = setTimeout(function() {borderSlide(thisnumber, "#FFFFFF")}, (timer += 75));
		SS = setTimeout(function() {hidePic(thisthumb)}, timer += 10);
//		SS = setTimeout(function() {hidePic(slideshowcontent);}, timer);

//		SS = setTimeout(function() {showPic(nextcontent)}, timer += 10);
		SS = setTimeout(function() {showPic(nextthumb)}, (timer += 10));

		SS = setTimeout(function() {borderSlide(nextnumber, "#DDDDDD")}, (timer += 75));
//		SS = setTimeout(function() {Slide(nextthumb, (j += 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (j += 10))}, timer);

		SS = setTimeout(function() {borderSlide(nextnumber, "#BBBBBB")}, (timer += 75));
//		SS = setTimeout(function() {Slide(nextthumb, (j += 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (j += 10))}, timer);

		SS = setTimeout(function() {borderSlide(nextnumber, "#999999")}, (timer += 75));
//		SS = setTimeout(function() {Slide(nextthumb, (j += 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (j += 10))}, timer);

		SS = setTimeout(function() {borderSlide(nextnumber, "#888888")}, (timer += 75));
//		SS = setTimeout(function() {Slide(nextthumb, (j += 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (j += 10))}, timer);

		SS = setTimeout(function() {borderSlide(nextnumber, "#777777")}, (timer += 75));
//		SS = setTimeout(function() {Slide(nextthumb, (j += 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (j += 10))}, timer);

		SS = setTimeout(function() {borderSlide(nextnumber, "#666666")}, (timer += 75));
//		SS = setTimeout(function() {Slide(nextthumb, (j += 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (j += 10))}, timer);

		SS = setTimeout(function() {borderSlide(nextnumber, "#444444")}, (timer += 75));
//		SS = setTimeout(function() {Slide(nextthumb, (j += 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (j += 10))}, timer);

		SS = setTimeout(function() {borderSlide(nextnumber, "#222222")}, (timer += 75));
//		SS = setTimeout(function() {Slide(nextthumb, (j += 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (j += 10))}, timer);

		SS = setTimeout(function() {borderSlide(nextnumber, "#000000")}, (timer += 75));
//		SS = setTimeout(function() {Slide(nextthumb, (j += 10))}, timer);
		SS = setTimeout(function() {Slide(slideshowcontent, (j += 10))}, timer);

	    setTimeout(function() { onslide = 0; }, timer);

		if ((parseInt(showed) + 1) == maxshowed) { showed = 0; } else { showed++; }

		SS = setTimeout("slideShow();", timer += 7500);
	}
}

function roll() {
	if (!document.getElementById('thumb1')) {
		setTimeout("roll();", 500);
	} else {
		var maxshowed = $('#maxshowed').val();
		if (maxshowed > 1) {
	  		showed = 0;
  			SS = setTimeout("slideShow();", 7500);
	  	}
	}
}

roll();