
$(document).ready( function(){
	if ( $("ul.simple-fade").length > 0 ) {
		$('#gallery ul.simple-fade li').fadeIn(1500);
		$('#gallery ul.simple-fade').innerfade({ speed: 1000, timeout: 5000, type: 'sequence', containerheight: '375px' });
	};
	
	if ( $("#gallery .project").length > 0 ) {
		$('#gallery .project').addClass('gallery'); // adds new class name to maintain degradability
		$('ul.gallery').galleria({
			history   : true, // activates the history object for bookmarking, back-button etc.
			clickNext : true, // helper for making the image clickable
			insert    : '#main_image', // the containing selector for our main image
			onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes

				// fade in the image & caption
				image.css('display','none').fadeIn(800);
				caption.css('display','none').fadeIn(800);

				// fetch the thumbnail container
				var _li = thumb.parents('li');

				// fade out inactive thumbnail
				_li.siblings().children('img.selected').fadeTo(500,0.6);

				// fade in active thumbnail
				thumb.fadeTo('fast',1).addClass('selected');

				// add a title for the clickable image
				image.attr('title','Next image >>');
			},
			onThumb : function(thumb) { // thumbnail effects goes here

				// fetch the thumbnail container
				var _li = thumb.parents('li');

				// if thumbnail is active, fade all the way.
				var _fadeTo = _li.is('.active') ? '1' : '0.6';

				// fade in the thumbnail when finnished loading
				thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);

				// hover effects
				thumb.hover(
					function() { thumb.fadeTo('fast',1); },
					function() { _li.not('.active').children('img').fadeTo('fast',0.6); } // don't fade out if the parent is active
				)
			}
		});
		var getWidth = $('#gallery .project li').width() + 8;
		var getAmount = $('#gallery .project').find('li').size();;
		$('.galleria').css('width', getWidth * getAmount - 8);
		$('#gallery .project li:last').css('margin', '0 0 8px 0')
		if ($('#gallery .project li').length == 8 ) { $('.galleria').addClass('eight'); }
	}	
});

/* CSS Browser Selector v0.2.9 Rafael Lima (http://rafael.adm.br)
------------------------------------------------------- */
var css_browser_selector = function() {var ua=navigator.userAgent.toLowerCase(),is=function(t){return ua.indexOf(t) != -1;},h=document.getElementsByTagName('html')[0],b=(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?'gecko ff2':is('firefox/3')?'gecko ff3':is('gecko/')?'gecko':is('opera/9')?'opera opera9':/opera\s(\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('chrome')?'chrome webkit safari':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';var c=b+os+' js'; h.className += h.className?' '+c:c;}();


$(function(){ 
    $('a[rel=external]').click(function(e){ 
        open(this.href); 
        e.preventDefault(); 
    }); 
});