$(document).ready(function(){  
    $('#fader').css('display','inline');
      
	$('a').not('.email').click(function(){
		var url = $(this).attr('href');
		if(url!="#" && url!="" && url.indexOf('.jpg') < 0 && url.indexOf('.gif') < 0 && url.indexOf('.png') < 0) {
			$("#fader").css({'display' : 'block'});
			$("#fader").fadeTo(800, 1, function(){
			   window.location.href = url;
			});
		} else {
			//window.location.href = url;
		}
	});
	
	$('#fader').fadeTo(500, 0, function(){
	   $('#fader').css({'display' : 'none'});
	});

	$('#navigation ul.primary li').click(function() {
	    // hide secondary nav
	    $('ul.secondary').hide();
		$('#navigation ul li > a').removeClass('active');
		$(this).find('a').addClass('active');

		var activeTab = $(this).find('a').attr('href').replace('#','');        
		var tUrl ="service/projects/?category_id=" + activeTab;
		var tTarget = "#content";
		
		$(activeTab).fadeIn();
        $.ajax({
            type: "GET", 
            url: tUrl, 
            cache: false,
            success:
            function(html){
                $(tTarget).html(html);
            }
        });		
	});
	
	// active state for secondary navs
	// $('#navigation ul.secondary li').click(function() {
	//    $('#navigation ul li > a').removeClass('active');
	//    $(this).find('a').addClass('active');
	// })

    // hide clients and contacts on load
    // $('#body .clients, #body .contact').hide();
	
	// show secondary nav again if clicked on about
	// $('#navigation ul.primary li.about').click(function() {
	//    $('ul.secondary').fadeIn();
	// });
    
    // change background colors
//    $('li.communications a, li.identities a, li.literature a, li.packaging a, li.exhibitions a, li.retail a').click(function(){
//          $('body').animate({ backgroundColor: '#ffffff' }, 700)
//    });             
//    $('li.about a').click(function(){
//          $('body').animate({ backgroundColor: '#6dbe2d' }, 700)
//    });
//    $('li.clients a').click(function(){
//          $('body').animate({ backgroundColor: '#ff005f' }, 700)        
//    });              
//    $('li.contact a').click(function(){
//          $('body').animate({ backgroundColor: '#00c9ff' }, 700)
//    });        
    
    // split client list into 3 columns   
    $('#content .clients ul').makeacolumnlists({
        cols: 3,
        colWidth: 270,
        equalHeight: false,
        startN: 1
    }); 
});

function loadAssets(tUrl, tTarget){
   $.ajax({type:"GET", url:tUrl, success:
       function(html){
           $(tTarget).html(html);
       }
   });
}
