$(window).load(function(){	
	$('.small_slider').anythingSlider({
		// Appearance
		theme				  : "custom",
		width               : 100,      // Override the default CSS width
		height              : 100,      // Override the default CSS height
		resizeContents      : false,      // If true, solitary images/objects in the panel will expand to fit the viewport
		showMultiple		  : 4,

		// Navigation
		startPanel          : 1,         // This sets the initial panel
		hashTags            : true,      // Should links change the hashtag in the URL?
		buildArrows         : true,      // If true, builds the forwards and backwards buttons
		buildNavigation     : false,      // If true, buildsa list of anchor links to link to each panel
		navigationFormatter : null,      // Details at the top of the file on this use (advanced use)

		// Slideshow options
		autoPlay            : false,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		startStopped        : false,     // If autoPlay is on, this can force it to start stopped
		pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
		resumeOnVideoEnd    : true,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video has completed
		stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page
		playRtl             : false,     // If true, the slideshow will move right-to-left
		animationTime       : 400,       // How long the slideshow transition takes (in milliseconds)
		easing              : "swing"    // Anything other than "linear" or "swing" requires the easing plugin	  
	});
	function fold(height, overlay, animate){
		if($('.anythingSlider-default > .arrow').css('display') != "none" && overlay == true){
			//$('#menu').append('<div class="overlay" style="position:absolute;z-index:1200;width:100%;height:100%;top:0;left:0;background-color:#000;filter:alpha(opacity=80);-moz-opacity:.8;opacity:.8;"></div>');
			$('#header').append('<div class="overlay" style="display:none;position:absolute;z-index:100;width:100%;height:100%;top:0;left:0;background-color:#000;"></div>');
			$('#header2').append('<div class="overlay" style="display:none;position:absolute;z-index:190;width:100%;height:100%;top:0;left:0;background-color:#000;"></div>');
			$('#body').append('<div class="overlay" style="display:none;position:absolute;z-index:100;width:100%;height:100%;top:0;left:0;background-color:#000;"></div>');
			$('#footer').append('<div class="overlay" style="display:none;position:absolute;z-index:100;width:100%;height:100%;top:0;left:0;background-color:#000;"></div>');
			$('.overlay').fadeTo(1000, 0.8);
			$('.anythingSlider-default > .arrow').css('display','none');
			$('.zoom').attr('src','/resources/images/slider/zoom_out_btn.gif');
		}else{
			$('.overlay').fadeTo(1000, 0, function(){
				$('div.overlay').remove();
			});
			
			$('.anythingSlider-default > .arrow').css('display','block');
			$('.zoom').attr('src','/resources/images/slider/zoom_in_btn.gif');
			$('.activePage .slider_img').css('background-image',window.org_img);
		}
		if(!animate){
			$('.anythingSlider:first').css('height',height);
			$('#main_slider').css('height',height);
			$('.panel').css('height',height);
			$('#slider_middle').css('height',height);
			$('.slider_right').css('height',height);
		}else{
			$('.anythingSlider:first').animate({
				height: height
			},1000)
			
			$('#slider_middle').animate({
				height: height
			},1000);
			$('.slider_right').animate({
				height: height
			},1000);
			$('.panel').animate({
				height: height
			},1000,function(){
				if($('.anythingSlider-default > .arrow').css('display') == "none"){
					$('#main_slider .hidden').css('display', 'block');
				}
			});			
			
			/*			
			$('#main_slider').animate({
				height: height
			},1000);
			*/
		}

		$('div.overlay').click(function() {
			var height = 0;

			$('#main_slider .hidden').css('display','none');
			height = 206;
			
			fold(height,true,true);
		});
	}
	$('img.zoom').click(function() {
		var height = 0;
		if($('.anythingSlider-default > .arrow').css('display') != "none"){
			$('#main_slider .hidden').css('display','block');
			height = $('.activePage .slider_right_inner').css('height');
			if(height < $('.activePage .slider_left').css('height')){
				height = $('.activePage .slider_left').css('height');
			}
			$('#main_slider .hidden').css('display','none');
		}else{
			$('#main_slider .hidden').css('display','none');
			height = 206;
		}
		fold(height,true,true);
	});
	$('.gallery_image').click(function(){
		var url = $(this).attr('longdesc');
		$('.activePage .slider_img').css('background-image','url(' + url + ')');
	});
	
	$('#expand_top').click(function() {
		$('#top_content').slideToggle('fast');
	});
	window.org_img = $('.activePage .slider_img').css('background-image');
	fold(206, false, false);
});
