
/*	JS Core Functions
	Breath-e Digital - London Digital Creative Agency
	http://www.breath-e.com  */

(function($) { // Ready

	$(document).ready(function() {

		init_settings();

		hover_events();

		click_events();

		init_other();

		init_lightbox();

	});

this.init_other = function () {

	var posts_navigation = $('#posts-navigation');

	if ( posts_navigation.children().length == 0 ) { posts_navigation.css('visibility', 'hidden'); }

}

this.init_settings = function () {

	D_SETTINGS = {
		overlayOpacity: $('.overlay span').css('opacity'),
		singlePortfolioPage: $('#single-portfolio-page').length
	};

}

this.hover_events = function () {

	if ( NOT_IE && ! D_SETTINGS.singlePortfolioPage) {

		$('.overlay span').hover(function() {
			$(this).stop().animate({opacity: 1}, 300);
		}, function() {
			$(this).stop().animate({opacity: D_SETTINGS.overlayOpacity},200);
		});

	}

}

this.click_events = function () {

	$('#footer .back-to-top a').click(function() {
		var duration = 800;
		var easing = 'easeInOutSine';
		if ( $.browser.msie ) {$('html').animate({scrollTop:0}, duration);return false;}
		if ( !$.browser.opera ) {$('html,body').animate({scrollTop:0}, {duration: duration, easing: easing});}
		else {$('html').animate({scrollTop:0}, {duration: duration,	easing: easing});}
		return false;
	});

}

this.init_lightbox = function() {

	// Setup Gallery lightboxes prior to initialization

	$("a[rel^='lightbox']").prettyPhoto({
		animation_speed: 'normal', /* fast/slow/normal */
		slideshow: false, /* false OR interval time in ms */
		autoplay_slideshow: false, /* true/false */
		opacity: 0.5, /* Value between 0 and 1 */
		show_title: true, /* true/false */
		allow_resize: true, /* Resize the photos bigger than viewport. true/false */
		default_width: 500,
		default_height: 344,
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'light_square', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
		hideflash: true, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
		wmode: 'opaque', /* Set the flash wmode attribute */
		autoplay: true, /* Automatically start videos: True/False */
		modal: false, /* If set to true, only the close button will close the window */
		overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
		keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
		changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
		callback: function(){} /* Called when prettyPhoto is closed */

	});

}

})(jQuery);
