$(document).ready(function() {


	//make current "+" in main navigation orange
	
	var plus = $('.current_page_item a');
	if(plus.html()){
	plus.html(plus.html().replace("+", '<span class=\"navActive\">+</span>'));
	}
	
	//last list item float right on main nav
	//$('#nav li:last').css('float','right');
	
	//make selected project orange
	$(function(){
		var path = location.href;
		if ( path )
		 $('.lcp_catlist li a[href$="' + path + '"]').addClass('selected');
	});
	
	//tabs
$(function () {
    var tabContainers = $('div.tabs > .tabBox ');
    //var tabAnimation = $('.tabBox > ul')
    
    $('div.tabs ul.tabNavigation a').click(function () {
	    //tabAnimation.hide();
        tabContainers.hide().filter(this.hash).slideDown(400);	
        //tabAnimation.slideDown(400);
        
        $('div.tabs ul.tabNavigation a').removeClass('selected').addClass('rollover');
        $(this).addClass('selected').removeClass('rollover');
        
		//$('.selected').child.src = this.src.replace("_off","_on");

        return false;
	});/* .filter(':first').click(); */
    	
    $('div.tabs ul.tabNavigation a').click(function () {
    
    	
    });
    
    //navigation selection
	$(function(){
		var path = location.pathname.substring(1);
		if ( path )
		 $('.lcp_catlist li a[href$="' + path + '"]').addClass('selected');
	});

	$(".rollover img").hover(
		function()
		{
			//$(".rollover img").src = $(".rollover img").src.replace("_on","_off");
			this.src = this.src.replace("_off","_on");
		},
		function()
		{
			this.src = this.src.replace("_on","_off");
			
		}
	);
});
		
		$('ul.gallery').addClass('gallery'); // adds new class name to maintain degradability
		
		$('ul.gallery').galleria({
			history   : 0, // activates the history object for bookmarking, back-button etc.
			clickNext : true, // helper for making the image clickable
			onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
				
				var max_height = 345;
				var cur_height = image.height();
				
				if(cur_height > max_height){
					image.attr('height',max_height);
				} 
				
				if (cur_height < max_height) {
					var marginTop = ((max_height - cur_height)/2);
					image.css('marginTop',marginTop);
				}
				
				// fade in the image & caption
				if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
					image.css('display','none').fadeIn(500);
				}
				caption.css('display','none').fadeIn(1000);
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// fade out inactive thumbnail
				_li.siblings().children('img.selected').fadeTo(500,0.5);
				
				// 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.3';
				
				// 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.3); } // don't fade out if the parent is active
				)
			}
		});
	


//fix images
/*
$(".entry").each(function () {
	$("img",this).wrap('<div class="imagetest"></div>');
});*/

 
});
