// Title: Abode Construction - javascript
// Author: Kalon Edser, http://www.kalonedser.com/
// Updated: 10 December 2008

jQuery(document).ready(function() {
	
	$('body').addClass('js');
	
	// global
	var fadespeed = 2500;
	
	// hide elements initially
	var loadElements = $('.slideshow, #intro #slogan-text'); /* .slideshow, */
	$(loadElements).hide();
	
	$('.slideshow').each(function(){
		$('#slogan').hide();
	});
		
	
	// fix png images with alpha channels
	$.ifixpng('../img/pixel.gif');
	$('.png, .gallery li').ifixpng();
	
	// open new window for external links
	$('A[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });

	// preload images
	$.preloadImages('../img/prettyPhoto/loader.gif');

	// inline photo viewer
	$("a[rel^='prettyOverlay'],a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		opacity: 0.35, /* Value betwee 0 and 1 */
		showTitle: false, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/' /* The separator for the gallery counter 1 "of" 2 */
	});

	// run events after all resources are loaded
	$(window).load(function() {
	
		// show hidden elements
		$(loadElements).fadeIn(fadespeed);
		
/*
		$('#intro #slogan-text').animate({ 
	        left: "10px"
	      }, fadespeed );
*/
	
		// slideshow + captions	
		function onBefore() {
			var thiscaption = $(this).attr('title');
			var halfspeed = fadespeed / 2; // half transition speed
			
			$('#slogan').fadeOut(halfspeed, function () {
				$('#slogan').text(thiscaption).fadeIn(halfspeed);
			}); 
		}
		
		$('.slideshow').cycle({ 
		    fx:    'fade', 
		    speed:  fadespeed,
			timeout:  2000,
			before:  onBefore
		});
			
	});

});
