// Custom jQuery actions - handwritten by Zarino Zappia, 2008

$(document).ready(
	function(){
		
		// SIMPLE STUFF
		
		$('#java-warning').hide();
		
		$('#overlay').wrap('<div id="overlay-wrapper"></div>');
		
		$('.scroll-pane').jScrollPane();
		
		
		// CONTACT PAGE STUFF
		
	/*	
		$('#nav').children('.contact').hide().siblings('.schedule').children().css({paddingRight: '0'});
	*/
		
		
		// LOW LEVEL EMAIL OBFUSCATION 
		// To reduce spam, don't put email links like this <a href="info@mordeleteethatunites.com">info@mordeleteethatunites.com</a> into the website's HTML
		// Instead, write this <a class="emaillink">any text you want except your email address</a>
		
		var obfuscatedEmailAddress = "info@mordeleteethatunites.com";  // Your email address with the word 'delete' randomly inserted
		var emailAddress = obfuscatedEmailAddress.replace("delete", "");
	/*	$('#footer').append('<li class="email"><a href="mailto:' + emailAddress + '" title="Email More That Unites">' + emailAddress + '</a></li>');  */
		$('a.emaillink').empty().text(emailAddress).attr({ 
          href: "mailto:" + emailAddress,
          title: "Email More That Unites"
        });
		
		
		// GALLERY STUFF
	
		$('body.gallery').ready(
			function(){
				
				$('body.gallery').append('<div class="hidden"><img src="../img/gallery-slideout-white.png" alt="" /></div>');
				
				$('body.gallery #overlay').attr('style', 'background-position: -499px 0px').parent('#overlay-wrapper').append("<a href='#' id='slideout' title='Click here to hide thumbnails'></a>").children('a#slideout').click(
					function(){ 
						$('#overlay-wrapper').animate({left: '800px'}, 500).children('#overlay').animate({backgroundPosition: '-810px 0'}, 500);
						return false;
					}
				);
						
				$('.mtu-gallery').addClass('gallery_demo');  // adds new class name to maintain degradability
				
				$('ul.gallery_demo').galleria(
					{
					history   : false,  // deactivates the history object for bookmarking, back-button etc.
					clickNext : false,  // helper for making the image clickable. Let's not have that in this example.
					insert    : '#picture',  // the containing selector for our main image. 
										     // If not found or undefined (like here), galleria will create a container 
										     // before the ul with the class .galleria_container (see CSS)
					onImage   : function(image,caption,thumb){ },
					onThumb	  : function(thumb){ }
					}
				);
				
				$('ul.gallery_demo li').each(
					function(){
						var path = $(this).children('img').attr('src');
						var newpath = path.replace(/.jpg/, "-overlay.jpg");
						$('div.hidden').append('<img src="' + newpath + '" \/>');  // Preloads the '-overlay.jpg' images to avoid flicker on image swap
					}
				);
				
				$('body.gallery #picture').hover(
					function(){
						$('#overlay-wrapper').animate({left: '490px'}, 500).children('#overlay').animate({backgroundPosition: '-499px 0'}, 500);
					}, function (){
						$('#overlay-wrapper').animate({left: '800px'}, 500).children('#overlay').animate({backgroundPosition: '-810px 0'}, 500);
					}
				);

			}
		);
		
		
		
		
       	$(document).pngFix();
		
		

	}
);