/* Mega menu configuration and functions */
var megaConfig = { interval: 20, sensitivity: 4, over: addMega, timeout: 50, out: removeMega };
function addMega(){
	$(this).find('div').stop().fadeTo('fast', 1).show(); //Find sub and fade it in
}
function removeMega(){
	$(this).find('div').stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
		$(this).hide();  //after fading, hide it
	});
}
/* Auto play the more example slideshows */
function showNextClient() {
	jQuery.prettyPhoto.changePage('next');
}
/* Do all the "on page load" stuff */
$(document).ready(function() {
	/* Activate hoverintent dropdown nav menu */
	$('ul#menu li.mega').hoverIntent(megaConfig);
	if($.browser.msie && $.browser.version.substr(0,1)<7) {
		$('ul#menu li').hover(function() {
			$(this).addClass('hover');
		}, function() {
			$(this).removeClass('hover');
		});
		$(document).pngFix();
	}
	/* Activate page font size changer */
	var bodySize = parseInt($('body').css('fontSize').replace('px', ''));
	$('.changefont').click(function() {
		thisSize = parseInt($(this).attr('id').replace('size_', '')) + bodySize;
		$('body').css('fontSize', thisSize+'px');
		return false;
	});
	/* Activate PrettyPhoto for images that need it */
	$("a[rel^='prettyPhoto']").prettyPhoto({theme: 'light_rounded', opacity: 1.0, allow_resize: false});
	/* Activate nivo slider for case study */
	$('.nivoSlider').nivoSlider({
		effect: 'random', //Specify sets like: 'fold,fade,sliceDown'
		slices: 15,
		animSpeed: 500, //Slide transition speed
		pauseTime: 4500,
		startSlide: 0, //Set starting Slide (0 index)
		directionNav: false, //Next & Prev
		directionNavHide: false, //Only show on hover
		controlNav: true, //1,2,3...
		controlNavThumbs: true, //Use thumbnails for Control Nav
		controlNavThumbsFromRel: false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '-thumb.jpg', //...this in thumb Image src
		keyboardNav: true, //Use left & right arrows
		pauseOnHover: true, //Stop animation while hovering
		manualAdvance: false, //Force manual transitions
		captionOpacity: 0.8, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){}, //Triggers after all slides have been shown
		lastSlide: function(){}, //Triggers when last slide is shown
		afterLoad: function(){} //Triggers when slider has loaded
   });
	/* Activate nivo slider for more examples */
	$('.nivoSliderAuto').nivoSlider({
		effect: 'random', //Specify sets like: 'fold,fade,sliceDown'
		slices: 15,
		animSpeed: 500, //Slide transition speed
		pauseTime: 4500,
		startSlide: 0, //Set starting Slide (0 index)
		directionNav: false, //Next & Prev
		directionNavHide: false, //Only show on hover
		controlNav: true, //1,2,3...
		controlNavThumbs: true, //Use thumbnails for Control Nav
		controlNavThumbsFromRel: false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '-thumb.jpg', //...this in thumb Image src
		keyboardNav: true, //Use left & right arrows
		pauseOnHover: true, //Stop animation while hovering
		manualAdvance: true, //Force manual transitions
		captionOpacity: 0.8, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){/*window.parent.showNextClient();*/}, //Triggers after all slides have been shown
		lastSlide: function(){}, //Triggers when last slide is shown
		afterLoad: function(){} //Triggers when slider has loaded
   });
	/* Stop/Start the Nivo slide when you click the pause/play button */
	$('.status').click(function() {
		$('.nivoSliderAuto').data('nivo:vars').stop = !$('.nivoSliderAuto').data('nivo:vars').stop;
	});
});
