jQuery(document).ready(function($) {

	jQuery.easing.def = "easeInOutExpo";
	//var windowWidth = $(window).width();
	var windowHeight = $(window).height();
	var docOffsetHeight = document.body.offsetHeight;
	var browserHeight = windowHeight + docOffsetHeight;
	var browserWidth = Math.round(browserHeight * 1.33333333);
	var img=1;
	
	window.resizeTo(browserWidth, browserHeight);
	//window.resizeTo($(document).width(), $(document).height());
	
	if(browserHeight>450)
	{
		$("body").css('overflow', 'hidden');	
	}
	
	//alert($(window).height());
	
	
	//hide sections to start
	if(!$.browser.msie)
	{
		$("#sections").css('opacity', '0');
	}
	else
	{
		$("#sections").hide();
	}
	
	//set vertical/horizontal position for preloader and left & right nav arrows and text-container
	verticalPos = ($(window).height()/2);
	horizontalPos = ($(window).width()/2);
	//$(".home-text").css('left',(horizontalPos-200) + "px");
	$(".about-text").css('left',(horizontalPos-200) + "px");
	$("#preloader").css('top',(verticalPos-22) + "px");
	$("#preloader").css('left',(horizontalPos-17) + "px");
	$(".prev").css('top',(verticalPos-15) + "px");
	$(".next").css('top',(verticalPos-15) + "px");
	
	my_slideshowActive = false;
	
	//$(".home-text").fadeIn('slow');
	
	//poistion arrows and preloader when window is resized
	$(window).resize(function() {
  		verticalPos = ($(document).height()/2);
		horizontalPos = ($(document).width()/2);
		//$(".home-text").css('left',(horizontalPos-200) + "px");
		$(".about-text").css('left',(horizontalPos-200) + "px");
		$("#preloader").css('top',(verticalPos-22) + "px");
		$("#preloader").css('left',(horizontalPos-17) + "px");
		$(".prev").css('top',(verticalPos-15) + "px");
		$(".next").css('top',(verticalPos-15) + "px");
		//$(".next").css('right', "-10px");
	});
	
	var navState=0; // 1 - navopen, 0 - nav closed
	
	//animate nav bg image, only fade sections in if not IE
	if(!$.browser.msie)
	{
		$('.nav-section-dropdown, a.nav-link').click(function(){
			if(navState==0)
			{
				$('#main-nav').stop().animate(
					{backgroundPosition:"(0 0)", height: "227px"}, 
					'duration:500', function() {
						$("#sections").show();
						$("#sections").animate({opacity:"1"}, 'duration:300');
					}
				);
				navState=1;
			}
			else if(navState==1)
			{
				$("#sections").animate({opacity:"0"}, 'duration:300', function() {
				$("#sections").hide();
				$('#main-nav').stop().animate({backgroundPosition:"(0 -148px)", height: "75px"}, 'duration:500')
				});
				navState=0;
			}
		});
	}
	else 
	{
		$('.nav-section-dropdown, a.nav-link').click(function(){
			if(navState==0)
			{
				$('#main-nav').stop().animate(
					{backgroundPosition:"(0 0)", height: "227px"}, 
					'duration:500', function() {
						$("#sections").show();
					}
				);
				navState=1;
			}
			else if(navState==1)
			{
				$("#sections").hide();
				$('#main-nav').stop().animate({backgroundPosition:"(0 -148px)", height: "75px"}, 'duration:500')
				navState=0;
			}
		});
	}
	
	
	
	//function to close nav
	function closeNav()
	{
		$("#sections").animate({opacity:"0"}, 'duration:200', function() {
			$('#main-nav').stop().animate({backgroundPosition:"(0 -148px)", height: "75px"}, 'duration:500')
  		});
		navState=0;
	}
	

	
	// fade in & out & move left & right nav if not IE
	if(!$.browser.msie)
	{
		$('.prev')
		.mouseover(function(){
			$(this).animate(
				{opacity:"1", left:"+=10"}, 
				{duration:500})
			})
		.mouseout(function(){
			$(this).animate(
				{opacity:"0.8", left:"-=10"}, 
				{duration:500})
		});
		
		$('.next')
		.mouseover(function(){
			$(this).animate(
				{opacity:"1", width:"30px"}, 
				{duration:500})
			})
		.mouseout(function(){
			$(this).animate(
				{opacity:"0.8", width:"20px"}, 
				{duration:500})
		});
	}
	
	//initial setup of superbgimage
	$(function() {
	
		// Options for SuperBGImage
		$.fn.superbgimage.options = {
			id: 'superbgimage', // id for the containter
			z_index: 0, // z-index for the container
			inlineMode: 0, // 0-resize to browser size, 1-do not resize to browser-size
			showimage: 1, // number of first image to display
			vertical_center: 1, // 0-align top, 1-center vertical
			transition: 1, // 0-none, 1-fade, 2-slide down, 3-slide left, 4-slide top, 5-slide right, 6-blind horizontal, 7-blind vertical, 90-slide right/left, 91-slide top/down
			transitionout: 1, // 0-no transition for previous image, 1-transition for previous image
			randomtransition: 0, // 0-none, 1-use random transition (0-7)
			showtitle: 0, // 0-none, 1-show title
			slideshow: 0, // 0-none, 1-autostart slideshow
			slide_interval: 5000, // interval for the slideshow
			randomimage: 0, // 0-none, 1-random image
			speed: 'slow', // animation speed
			preload: 1, // 0-none, 1-preload images
			onShow: superbgimage_show, // function-callback show image
			onClick: superbgimage_click, // function-callback click image
			onHide: superbgimage_hide, // function-callback hide image
			onMouseenter: superbgimage_mouseenter, // function-callback mouseenter
			onMouseleave: superbgimage_mouseleave, // function-callback mouseleave
			onMousemove: superbgimage_mousemove // function-callback mousemove
		};
	
		// initialize SuperBGImage
		$('#thumbs1').superbgimage();
	
	});
	
	
	//function to chexk if slides have started animating (moving or faded in if new section) to hide preloder
	var t;
	function checkAnimation() {
		clearTimeout(timer);
		var slidePos = $('.activeslide').css('left');
		//alert("slideOpacity: " + slideOpacity);
		if(slidePos=="0px")
		{
			$('#preloader').fadeIn('slow');
			t=setTimeout(checkAnimation, 100);
		}
		else
		{
			//alert("in else");
			$('#preloader').css('display', 'none');
			clearTimeout(t);
		}
	}
	
	var timer;
	// function callback on hiding image
	function superbgimage_hide(img) {
		//delay animation check incase it's about to start
		timer=setTimeout(checkAnimation, 100);
		//$('#showtitle').hide();
	}
	
	// function callback on showing image
	// get title and display it
	function superbgimage_show(img) {
		
		$('#superbgimage').css('background', 'none');
		$('#preloader').css('display', 'none');
		//$('#superbgimage').append($('#showtitle'));
		$('#showtitle p.imagecount').html(img + '/' + $.superbg_imgIndex);
		
		if(currentSection==1) {
			$('#showtitle p.title').html($('#thumbs1 a' + "[rel='" + img + "']").attr('title'));
		} 
		else if(currentSection==2) {
			$('#showtitle p.title').html($('#thumbs2 a' + "[rel='" + img + "']").attr('title'));
		}
		else if(currentSection==3) {
			$('#showtitle p.title').html($('#thumbs3 a' + "[rel='" + img + "']").attr('title'));
		}
		else if(currentSection==4) {
			$('#showtitle p.title').html($('#thumbs4 a' + "[rel='" + img + "']").attr('title'));
		}
		else if(currentSection==5) {
			$('#showtitle p.title').html($('#thumbs5 a' + "[rel='" + img + "']").attr('title'));
		}
		
		if(currentSection==5 && img==1)
		{
			$(".project-text").fadeIn("slow");
		}
		
		if (currentSection!=7)
		{ 
			$('#showtitle').show();
		}
	}
	
	// function callback on clicking image, show next slide
	function superbgimage_click(img) {
		update_superbgTransition(3);
		if(currentSection!=7)
		{
			
			$('#thumbs').nextSlide();
		}
		
		if(currentSection==5 && img==1)
		{
			$(".project-text").fadeOut("slow");
		}
	}
	
	// function callback onmouseenter, stop slideshow, show pause-indicator
	function superbgimage_mouseenter(img) {
		if ($.superbg_slideshowActive) {
			my_slideshowActive = true;
			if ($('#pause').length == 0) { 
				$('body').prepend('<div id="pause"><img src="pause.png" \/><\/div>');
			}
			$('#pause').css('position', 'absolute').css('z-index', 3).show();
			return $('#thumbs').stopSlideShow();
		}
	}
	
	// function callback onmouseleave, start slideshow, hide pause-indicator
	function superbgimage_mouseleave(img) {
		if (my_slideshowActive && ($('#pause').length > 0) && ($('#pause').css('display') == 'block'))  { 
			$('#pause').hide();
			return $('#thumbs').startSlideShow();
		}	
	}
	
	// function callback onmousemove, show and move pause-indicator
	function superbgimage_mousemove(img, e) {
		if (my_slideshowActive && ($('#pause').length > 0)) { 
			$("#pause").css("top",(e.pageY + 20) + "px").css("left",(e.pageX + 20) + "px").show();
		}
	}


	// update superbgimage options
	function update_superbgOptions() {	
		
		// 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
		};
	
	}
	
	
	
	//updates transition (vertical or horizontal slide in); used when next or prev slide clicked or when section changed
	function update_superbgTransition(newTransition) {
		// update transition options
		$.fn.superbgimage.options = { 
			transition: parseInt(newTransition)
		};
	
	}


	// hide options
	$("#options").css('height','15px').css('padding', '0px').addClass('hidden').children().hide();
	$("#options .legend").show();
	
	// hide set 2
	$("#thumbs2").hide().addClass('hidden');
	
	// fade overlay with controls, fade container to display titles
	//$('#overlay').fadeTo('slow', 0.99);
	//$('.btn-info').fadeTo('slow', 0.90);
	//$('.imagecount').fadeTo('slow', 0.90);
	
	$('.btn-info').hover(
		function () {
			$(this).fadeTo('slow', 1.00);
		},
		function () {
			$(this).fadeTo('slow',1.00);
		}
	);
	
	
	///////slideshow controls
	
	// prev slide
	$('a.prev').click(function() {
		update_superbgTransition(5);
		
		if(currentSection==5 && img==1)
		{
			$(".project-text").fadeOut("slow");
		}
		
		return $('#thumbs').prevSlide();
	});

	// next slide
	$('a.next').click(function() {
		update_superbgTransition(3);
		
		if(currentSection==5 && img==1)
		{
			$(".project-text").fadeOut("slow");
		}
		
		return $('#thumbs').nextSlide();
	});

	// start slideshow
	$('a.start').click(function() {
		update_superbgOptions();
		return $('#thumbs').startSlideShow();
	});

	// stop slideshow
	$('a.stop').click(function() {
		my_slideshowActive = false;
		return $('#thumbs').stopSlideShow();
	});
	
	var currentSection=1;
	
	$('#showtitle').hide();
	
	// load image set 1
	$('a#section1').click(function(){
		if(currentSection!=1)
		{
			//$(".home-text").hide();
			$(".about-text").hide();
			$(".project-text").hide();
			$('.prev').show();
			$('.next').show();
			$('#thumbs1').stopSlideShow();
			$('#thumbs2').stopSlideShow();
			$('#thumbs3').stopSlideShow();
			$('#thumbs4').stopSlideShow();
			$('#thumbs5').stopSlideShow();
			$('#thumbs6').stopSlideShow();
			$('#thumbs7').stopSlideShow();
			my_slideshowActive = false;
			$('#showtitle').hide();
			$('#thumbs2').hide().addClass('hidden');
			$('#thumbs3').hide().addClass('hidden');
			$('#thumbs4').hide().addClass('hidden');
			$('#thumbs5').hide().addClass('hidden');
			$('#thumbs6').hide().addClass('hidden');
			$('#thumbs7').hide().addClass('hidden');
			update_superbgTransition(1);
			currentSection=1;
			
			//fade out current section title, change src and fade in
			if(!$.browser.msie)
			{
				$('#current-section').fadeOut('fast', function() {
					$(this).css('background-image', 'url(assets/images/nav-music.png)');
					$(this).fadeIn('slow');
				});
			}
			else
			{
				$('#current-section').hide() 
				$('#current-section').css('background-image', 'url(assets/images/nav-music.png)');
				$('#current-section').show();
			}
			
			$('#superbgimage').fadeOut('fast', function() {
    			$('#thumbs1').superbgimage({ reload: true });
				//$('#thumbs1').superbgimage({ reload: true }).show().removeClass('hidden');
				$('#preloader').fadeIn('slow');
				//checkNewSectionLoaded();
				return false;
  			});
		}
	});

	// load image set 2
	$('a#section2').click(function(){
		if(currentSection!=2)
		{
			$(".home-text").hide();
			$(".about-text").hide();
			$(".project-text").hide();
			$('.prev').show();
			$('.next').show();
			$('#thumbs1').stopSlideShow();
			$('#thumbs2').stopSlideShow();
			$('#thumbs3').stopSlideShow();
			$('#thumbs4').stopSlideShow();
			$('#thumbs5').stopSlideShow();
			$('#thumbs6').stopSlideShow();
			$('#thumbs7').stopSlideShow();
			my_slideshowActive = false;
			$('#showtitle').hide();
			$('#thumbs1').hide().addClass('hidden');
			$('#thumbs3').hide().addClass('hidden');
			$('#thumbs4').hide().addClass('hidden');
			$('#thumbs5').hide().addClass('hidden');
			$('#thumbs6').hide().addClass('hidden');
			$('#thumbs7').hide().addClass('hidden');
			update_superbgTransition(1);
			currentSection=2;
			
			//fade out current section title, change src and fade in
			if(!$.browser.msie)
			{
				$('#current-section').fadeOut('fast', function() {
					$(this).css('background-image', 'url(assets/images/nav-advertising1.png)');
					$(this).fadeIn('slow');
				});
			}
			else
			{
				alert("load section2 2");
				$('#current-section').hide() 
				$('#current-section').css('background-image', 'url(assets/images/nav-advertising1.png)');
				$('#current-section').show();
			}
			
			$('#superbgimage').fadeOut('fast', function() {
				
    			$('#thumbs2').superbgimage({ reload: true });
				$('#preloader').fadeIn('slow');
				
				//checkNewSectionLoaded();
				return false;
  			});	
		}
	});	
	
	// load image set 3
	$('a#section3').click(function(){
		if(currentSection!=3)
		{
			//$(".home-text").hide();
			$(".about-text").hide();
			$(".project-text").hide();
			$('.prev').show();
			$('.next').show();
			$('#thumbs1').stopSlideShow();
			$('#thumbs2').stopSlideShow();
			$('#thumbs3').stopSlideShow();
			$('#thumbs4').stopSlideShow();
			$('#thumbs5').stopSlideShow();
			$('#thumbs6').stopSlideShow();
			$('#thumbs7').stopSlideShow();
			my_slideshowActive = false;
			$('#showtitle').hide();
			$('#thumbs1').hide().addClass('hidden');
			$('#thumbs2').hide().addClass('hidden');
			$('#thumbs4').hide().addClass('hidden');
			$('#thumbs5').hide().addClass('hidden');
			$('#thumbs6').hide().addClass('hidden');
			$('#thumbs7').hide().addClass('hidden');
			update_superbgTransition(1);
			currentSection=3;
			
			//fade out current section title, change src and fade in
			if(!$.browser.msie)
			{
				$('#current-section').fadeOut('fast', function() {
					$(this).css('background-image', 'url(assets/images/nav-advertising2.png)');
					$(this).fadeIn('slow');
				});
			}
			else
			{
				$('#current-section').hide()
				$('#current-section').css('background-image', 'url(assets/images/nav-advertising2.png)');
				$('#current-section').show();
			}
			
			$('#superbgimage').fadeOut('fast', function() {
    			$('#thumbs3').superbgimage({ reload: true });
				//$('#thumbs1').superbgimage({ reload: true }).show().removeClass('hidden');
				$('#preloader').fadeIn('slow');
				//checkNewSectionLoaded();
				return false;
  			});
		}
	});
	
	// load image set 4
	$('a#section4').click(function(){
		if(currentSection!=4)
		{
			//$(".home-text").hide();
			$(".about-text").hide();
			$(".project-text").hide();
			$('.prev').show();
			$('.next').show();
			$('#thumbs1').stopSlideShow();
			$('#thumbs2').stopSlideShow();
			$('#thumbs3').stopSlideShow();
			$('#thumbs4').stopSlideShow();
			$('#thumbs5').stopSlideShow();
			$('#thumbs6').stopSlideShow();
			$('#thumbs7').stopSlideShow();
			my_slideshowActive = false;
			$('#showtitle').hide();
			$('#thumbs1').hide().addClass('hidden');
			$('#thumbs2').hide().addClass('hidden');
			$('#thumbs3').hide().addClass('hidden');
			$('#thumbs5').hide().addClass('hidden');
			$('#thumbs6').hide().addClass('hidden');
			$('#thumbs7').hide().addClass('hidden');
			update_superbgTransition(1);
			currentSection=4;
			
			//fade out current section title, change src and fade in
			if(!$.browser.msie)
			{
				$('#current-section').fadeOut('fast', function() {
					$(this).css('background-image', 'url(assets/images/nav-fashion.png)');
					$(this).fadeIn('slow');
				});
			}
			else
			{
				$('#current-section').hide()
				$('#current-section').css('background-image', 'url(assets/images/nav-fashion.png)');
				$('#current-section').show();
			}
			
			$('#superbgimage').fadeOut('fast', function() {
    			$('#thumbs4').superbgimage({ reload: true });
				//$('#thumbs1').superbgimage({ reload: true }).show().removeClass('hidden');
				$('#preloader').fadeIn('slow');
				//checkNewSectionLoaded();
				return false;
  			});
		}
	});
	
	// load image set 5
	$('a#section5').click(function(){
		if(currentSection!=5)
		{
			//$(".home-text").hide();
			$(".about-text").hide();
			//$(".project-text").fadeIn("slow");
			$('.prev').show();
			$('.next').show();
			$('#thumbs1').stopSlideShow();
			$('#thumbs2').stopSlideShow();
			$('#thumbs3').stopSlideShow();
			$('#thumbs4').stopSlideShow();
			$('#thumbs5').stopSlideShow();
			$('#thumbs6').stopSlideShow();
			$('#thumbs7').stopSlideShow();
			my_slideshowActive = false;
			$('#showtitle').hide();
			$('#thumbs1').hide().addClass('hidden');
			$('#thumbs2').hide().addClass('hidden');
			$('#thumbs3').hide().addClass('hidden');
			$('#thumbs4').hide().addClass('hidden');
			$('#thumbs6').hide().addClass('hidden');
			$('#thumbs7').hide().addClass('hidden');
			update_superbgTransition(1);
			currentSection=5;
			
			//fade out current section title, change src and fade in
			if(!$.browser.msie)
			{
				$('#current-section').fadeOut('fast', function() {
					$(this).css('background-image', 'url(assets/images/nav-projects.png)');
					$(this).fadeIn('slow');
				});
			}
			else
			{
				$('#current-section').hide()
				$('#current-section').css('background-image', 'url(assets/images/nav-projects.png)');
				$('#current-section').show();
			}
			
			$('#superbgimage').fadeOut('fast', function() {
    			$('#thumbs5').superbgimage({ reload: true });
				//$('#thumbs1').superbgimage({ reload: true }).show().removeClass('hidden');
				$('#preloader').fadeIn('slow');
				//checkNewSectionLoaded();
				return false;
  			});
		}
	});
	
	// load image set 6
	/*$('a#section6').click(function(){
		if(currentSection!=6)
		{
			//$(".home-text").hide();
			$(".about-text").hide();
			$('.prev').show();
			$('.next').show();
			$('#thumbs1').stopSlideShow();
			$('#thumbs2').stopSlideShow();
			$('#thumbs3').stopSlideShow();
			$('#thumbs4').stopSlideShow();
			$('#thumbs5').stopSlideShow();
			$('#thumbs6').stopSlideShow();
			$('#thumbs7').stopSlideShow();
			my_slideshowActive = false;
			$('#showtitle').hide();
			$('#thumbs1').hide().addClass('hidden');
			$('#thumbs2').hide().addClass('hidden');
			$('#thumbs3').hide().addClass('hidden');
			$('#thumbs4').hide().addClass('hidden');
			$('#thumbs5').hide().addClass('hidden');
			$('#thumbs7').hide().addClass('hidden');
			update_superbgTransition(1);
			currentSection=6;
			
			//fade out current section title, change src and fade in
			if(!$.browser.msie)
			{
				$('#current-section').fadeOut('fast', function() {
					$(this).css('background-image', 'url(assets/images/nav-projects.png)');
					$(this).fadeIn('slow');
					return false;
				});
			}
			else
			{
				$('#current-section').hide()
				$('#current-section').css('background-image', 'url(assets/images/nav-projects.png)');
				$('#current-section').show();
				return false;
			}
			
			$('#superbgimage').fadeOut('fast', function() {
    			$('#thumbs6').superbgimage({ reload: true });
				//$('#thumbs1').superbgimage({ reload: true }).show().removeClass('hidden');
				$('#preloader').fadeIn('slow');
				//checkNewSectionLoaded();
				return false;
  			});
		}
	});*/
	
	// load image set 7
	$('a#section7').click(function(){
		if(currentSection!=7)
		{
			//$(".home-text").hide();
			$(".project-text").hide();
			$('.prev').hide();
			$('.next').hide();
			$('#thumbs1').stopSlideShow();
			$('#thumbs2').stopSlideShow();
			$('#thumbs3').stopSlideShow();
			$('#thumbs4').stopSlideShow();
			$('#thumbs5').stopSlideShow();
			$('#thumbs6').stopSlideShow();
			$('#thumbs7').stopSlideShow();
			my_slideshowActive = false;
			$('#showtitle').hide();
			$('#thumbs1').hide().addClass('hidden');
			$('#thumbs2').hide().addClass('hidden');
			$('#thumbs3').hide().addClass('hidden');
			$('#thumbs4').hide().addClass('hidden');
			$('#thumbs5').hide().addClass('hidden');
			$('#thumbs6').hide().addClass('hidden');
			update_superbgTransition(1);
			currentSection=7;
			
			//fade out current section title, change src and fade in
			if(!$.browser.msie)
			{
				$('#current-section').fadeOut('fast', function() {
					$(this).css('background-image', 'url(assets/images/nav-about.png)');
					$(this).fadeIn('slow');
					$(".about-text").fadeIn('slow');
				});
			}
			else
			{
				$('#current-section').hide()
				$('#current-section').css('background-image', 'url(assets/images/nav-about.png)');
				$('#current-section').show();
				$(".about-text").show();
			}
			
			$('#superbgimage').fadeOut('fast', function() {
    			$('#thumbs7').superbgimage({ reload: true });
				//$('#thumbs1').superbgimage({ reload: true }).show().removeClass('hidden');
				$('#preloader').fadeIn('slow');
				//checkNewSectionLoaded();
				return false;
  			});
		}
	});
	
	
	
	//check if new section image has loaded and hide preloader //not used
	function checkNewSectionLoaded() {
		//var slideVisible = $('.activeslide').attr("src");
		var slideOpacity = $('.activeslide').css('opacity');
		//alert("checkNewSectionLoaded");
		if(slideOpacity==0)
		{
			t=setTimeout(checkNewSectionLoaded, 200);
		}
		else
		{
			//alert("in else");
			$('#preloader').fadeOut('fast');
			clearTimeout(t);
		}
	}
	
	
	
	//show & hide image description items
	$('a.btn-info').click(function() {
		$(this).fadeOut(100, function() {
			$('div.title-container').show('fast');
		});	
		
	});
	
	$('a.close').click(function() {
		$('div.title-container').hide('fast', function() {
			$('a.btn-info').fadeIn('fast');
		});	
		
	});
	
	
	/* functions to chnage options from original checkboxes & other fields on original demo
	
	// change transition with selectbox
	$("#transition").change(function() {
		update_superbgOptions();
	});	

	// change option speed
	$("input[name='optspeed']").change(function() {
		update_superbgOptions();
	});		
	
	// change option slide_interval
	$("input[name='optinterval']").change(function() {
		update_superbgOptions();
	});		

	// change option transitionout
	$("input[name='opttransout']").click(function() {
		update_superbgOptions();
	});	
	
	// change option randomtransition
	$("input[name='optrandomtrans']").click(function() {
		update_superbgOptions();
	});
	
	// change option randomimage
	$("input[name='optrandom']").click(function() {
		update_superbgOptions();
	});	

	// change option onClick-callback
	$("input[name='optclick']").click(function() {
		update_superbgOptions();
	});	
	
	// change option onShow-callback
	$("input[name='optshow']").click(function() {
		update_superbgOptions();
	});		

	// toggle fieldsets
	$(".legend").click(function() {
		if ($(this).parent().hasClass('hidden')) {
			$(this).parent().css('height', 'auto').css('padding', '10px').removeClass('hidden').children().show();
			$(this).show().css('display', 'block');
		} else {
			$(this).parent().css('height','15px').css('padding', '0px').addClass('hidden').children().hide();
			$(this).show().css('display', 'block');
		}
	});	

	// toggle overlay
	$("h1 a").click(function() {
		$(this).blur();
		if ($("#overlay").hasClass('hidden')) {
			$("#overlay").css('height','auto').removeClass('hidden').children().show();
			if ($('#thumbs1').hasClass('hidden')) {
				$('#thumbs1').hide();
			}
			if ($('#thumbs2').hasClass('hidden')) {
				$('#thumbs2').hide();
			}
		} else {
			$("#overlay").css('height','100px').addClass('hidden').children().hide();
			$("h1").show();
		}
		return false;
	});	
	*/
	
});
