/*
*************************************************

SEBASTIAN NITU
jQuery Document & Image Ready Scripts

Created by Sebastian Nitu
http://www.sebnitu.com

*************************************************
*/

/*-------------------------------------------    
	When Document is Ready
---------------------------------------------*/
$(document).ready(function() {
	
	/**
	 * Gallery Scrolling
	 */
	$('.gallery').infiniteCarousel({
		effect : 'scroll',

		autoRotate : false,

		equalHeight : false,

		navContainer: false,

		leftRightNav : false,

		leftRightNavClass : 'nav-item',
		leftNavClass : 'nav-left',
		rightNavClass : 'nav-right',

		dotNav 		: true,
		dotNavClass : 'nav-dot'
	});
	$('.gallery .cloned a').attr('rel', '');
	
	/**
	 * Fancybox
	 */
	function formatTitle(title, currentArray, currentIndex, currentOpts) {
	    return '<div class="title clearfix">' + (title && title.length ? '<span class="text">' + title + '</span>' : '' ) + '<span class="count">Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '</span></div>';
	}
	
	$('.thumbnails a').fancybox({
		'overlayColor' : '#000',
		'overlayOpacity' : 0.8,
		'titlePosition' : 'inside',
		'titleFormat' : formatTitle
	});
	
	$('.action-portfolio a').fancybox({
		'overlayColor' : '#000',
		'overlayOpacity' : 0.8,
		'titleShow'		: false
	});
	
	/**
	 * Default Form Value
	 */
	$('#contactEmail').DefaultValue('Your email address');
	
	/**
	 * External Links
	 */
	$("a:not([href*=http://" + document.domain + "])").not("[href^=#]")
		.addClass("external") 
		.attr({ target: "_blank" });
		
});

/*-------------------------------------------    
	After Images are Loaded
---------------------------------------------*/

$(window).load(function() {

	$('.gallery .wrapper').animate({ opacity : 1 });
	$('.gallery .loader').fadeOut();

});

/*-------------------------------------------    
	Fin
---------------------------------------------*/
