$(function() {

	// update superbgimage options
	function update_superbgOptions() {

		// speed
		var newspeed = 0;
		if (($("input[name='optspeed']").val() == 'slow') || ($("input[name='optspeed']").val() == 'normal') || ($("input[name='optspeed']").val() == 'fast')) {
			newspeed = $("input[name='optspeed']").val(); 
		} else {
			newspeed = parseInt($("input[name='optspeed']").val(), 10); 
			if (isNaN(newspeed)) {
				newspeed = 'slow';
				$("input[name='optspeed']").val('slow');
			}
		}
		
		// slidshow interval
		var newinterval = parseInt($("input[name='optinterval']").val(), 10); 
		if (isNaN(newinterval)) {
			newinterval = 5000;
			$("input[name='optinterval']").val(newinterval);
		}
		if ($.superbg_slideshowActive) { // restart slideshow
			clearInterval($.superbg_interval);
			return $('#thumbs').startSlideShow();
		}

		// transition out
		var newtransitionout = 0;
		if ($("input[name='opttransout']:checked").val() == 'on') {
			newtransitionout = 1;
		} else {
			newtransitionout = 0;
		}

		// random transition
		var newrandomtransition = 0;
		if ($("input[name='optrandomtrans']:checked").val() == 'on') {
			newrandomtransition = 1;
		} else {
			newrandomtransition = 0;
		}
		
		// random image
		var newrandomimage = 0;
		if ($("input[name='optrandom']:checked").val() == 'on') {
			newrandomimage = 1;
		} else {
			newrandomimage = 0;
		}

		// update options
		$.fn.superbgimage.options = { 
			transition: parseInt($("#transition").val(), 10),
			speed: newspeed,
			slide_interval: newinterval,
			transitionout: parseInt(newtransitionout, 10),
			randomtransition: parseInt(newrandomtransition, 10),
			randomimage: parseInt(newrandomimage, 10),
			onClick: onclickfunc,
			onShow: onshowfunc
		};
	
	}

	// hide set 2
	$("#thumbs2").hide().addClass('hidden');
	
	// fade overlay with controls, fade container to display titles
	//$("#about").delay(2400).animate({"right": "+=320px", "opacity": 0.8}, 800);
	//$("#about h1, #about p").delay(3600).fadeIn(800);
	
	//$("#service").delay(2400).animate({"bottom": "+=250px", "opacity": 0.8}, 1000);
	//$("#career").delay(2400).animate({"bottom": "+=300px", "opacity": 0.8}, 1000);
	//$("#tips").delay(2400).animate({"bottom": "+=470px", "opacity": 0.8}, 1000);
	
	//$("div.inner-b-left-col").delay(3600).animate({"width": 'toggle', "opacity": 1}, 500);
	//$("div.inner-b-left-col h1, div.inner-b-left-col ul").delay(4400).fadeIn(800);
	//$("div.inner-b-right-col").delay(4800).fadeIn(800);
	
	$('#right-col, #bottom-col, #full-col').fadeIn('slow');
	$('#overlay').fadeTo('slow', 0.9);
	$('#showtitle').fadeTo('slow', 0.7);
	$('#showtitle').hover(
		function () {
			$(this).fadeTo('1000', 1.00);
		},
		function () {
			$(this).fadeTo('1000', 0.70);
		}
	);
	/*$('#about, #service, #career, #tips, #products').hover(
		function () {
			$(this).fadeTo('1000', 1.00);
		},
		function () {
			$(this).fadeTo('1000', 0.80);
		}
	);*/

	// load image set 1
	$('.loadset1').hover(function(){
		if ($('#thumbs1').hasClass('hidden')) {
			$('#thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6').stopSlideShow();
			my_slideshowActive = false;
			$('#showtitle').hide();
			$('#thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6').hide().addClass('hidden');
			$('#thumbs1').superbgimage({ reload: true }).fadeIn(2000).removeClass('hidden');
			return false;
		}
	});

	// load image set 2
	$('.loadset2').hover(function(){
		if ($('#thumbs2').hasClass('hidden')) {								   
			$('#thumbs1, #thumbs3, #thumbs4, #thumbs5, #thumbs6').stopSlideShow();
			my_slideshowActive = false;
			$('#showtitle').hide();
			$('#thumbs1, #thumbs3, #thumbs4, #thumbs5, #thumbs6').hide().addClass('hidden');
			$('#thumbs2').superbgimage({ reload: true }).fadeIn(2000).removeClass('hidden');
			return false;
		}
	});
	
		// load image set 3
	$('.loadset3').hover(function(){
		if ($('#thumbs3').hasClass('hidden')) {								   
			$('#thumbs1, #thumbs2, #thumbs4, #thumbs5, #thumbs6').stopSlideShow();
			my_slideshowActive = false;
			$('#showtitle').hide();
			$('#thumbs1, #thumbs2, #thumbs4, #thumbs5, #thumbs6').hide().addClass('hidden');
			$('#thumbs3').superbgimage({ reload: true }).fadeIn(2000).removeClass('hidden');
			return false;
		}
	});
	
		// load image set 4
	$('.loadset4').hover(function(){
		if ($('#thumbs4').hasClass('hidden')) {								   
			$('#thumbs1, #thumbs2, #thumbs3, #thumbs5, #thumbs6').stopSlideShow();
			my_slideshowActive = false;
			$('#showtitle').hide();
			$('#thumbs1, #thumbs2, #thumbs3, #thumbs5, #thumbs6').hide().addClass('hidden');
			$('#thumbs4').superbgimage({ reload: true }).fadeIn(2000).removeClass('hidden');
			return false;
		}
	});
	
		// load image set 5
	$('.loadset5').hover(function(){
		if ($('#thumbs5').hasClass('hidden')) {									   
			$('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs6').stopSlideShow();
			my_slideshowActive = false;
			$('#showtitle').hide();
			$('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs6').hide().addClass('hidden');
			$('#thumbs5').superbgimage({ reload: true }).fadeIn(2000).removeClass('hidden');
			return false;
		}
	});

		// load image set 6
	$('.loadset6').hover(function(){
		if ($('#thumbs6').hasClass('hidden')) {									   
			$('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5').stopSlideShow();
			my_slideshowActive = false;
			$('#showtitle').hide();
			$('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5').hide().addClass('hidden');
			$('#thumbs6').superbgimage({ reload: true }).fadeIn(2000).removeClass('hidden');
			return false;
		}
	});	
	
	
	
});
