(function($){
	$(document).ready(function(){
		
		if($.browser.msie) {
			$.ifixpng.pixel = '../media/graphics/pixel.gif';
			$('.fixme').ifixpng(); 
		}
		
		if(!$.browser.msie) {
			$('.release .images a').fancybox();
		}
		
		$('.logotype').css('z-index', '999');
		
	
		/* ////////////////////////// */
	
		function getColor(who) {
			var colors = new Array();
			colors.base = '#1a0045';
			colors.nav_about = '#6abd45';
			colors.nav_portfolio = '#efab1f';
			colors.nav_properties = '#1271a0';
			colors.nav_clients = '#e88424';
			colors.nav_services = '#dc5133';
			colors.nav_news = '#8e908f';
			return colors[who];
		}
		
		$('#nav_main li a').each(function(){
			$navelem = $(this);
			$(this).removeClass('active');
			if($('body').hasClass("category_"+$('span', this).text().toLowerCase())) {
				$navelem.addClass('active').css({
					backgroundColor: getColor($(this).parents('li').attr('id')),
					backgroundPosition: 'top right',
					height: '4em'
				});
			}
		});

		$('#nav_main li a').not('.active').each(function(){
			$(this).hover(function(){
				var $mycolor = getColor($(this).parent('li').attr('id'));
				$(this).stop().animate({
					backgroundColor: $mycolor,
					backgroundPosition: '(right top)',
					height: '4em'
				}, 'fast');
			}, function(){
				$(this).stop().animate({
					backgroundColor: getColor('base'),
					backgroundPosition: '(right -1em)',
					height: '3em'
				}, 'slow');
			});
		});
		
		if($('body').hasClass('section_advisory')) {
			$('#nav_advisory').addClass('active');
		} else if($('body').hasClass('page_tenant')) {
			$('#nav_tenantrep').addClass('active');
		} else if($('body').hasClass('page_landlord')) {
			$('#nav_landlordrep').addClass('active');
		} else {
			$('#nav_tenantrep').addClass('active');
		}
		
		$('#services_switch li').not('.active').each(function(){
			$('a', this).hover(function(){
				$(this).stop().animate({
					height: '7em',
					backgroundColor: '#8d908e'
				}, 'fast');
			}, function(){
				$(this).stop().animate({
					height: '6em',
					backgroundColor: '#dd502e'
				}, 'slow');
			});
		});
		
		$('#client_'+$('#client_name h2').attr('id')).addClass('active');
				
		$('#client_list').hover(function(){
			$('.jScrollPaneDrag', this).stop().animate({
				opacity: 1
			});
		}, function(){
			$('.jScrollPaneDrag', this).stop().animate({
				opacity: 0
			});
		});

		$('tr:odd', 'table').addClass('odd');
		$('tr:even', 'table').addClass('even');
		$('tr', 'table').each(function(){ 
			$('td:first-child', this).addClass('first');
			$('td:last-child', this).addClass('last');
		});
		
		$('#badge').glide({
			direction: "ll",
			dist1: 100,
			dist2: 100,
			speed: 1500,
			easing: "easeOutQuad"
		});

		if($('.category_clients #client_photos li').size() > 1) $('.category_clients #client_photos').cycle({
			next: $('.category_clients #client_photos'),
			timeout: 10000,
			speed: 500,
			easing: 'easeInOutQuad'
		}).css('cursor', 'pointer');
		
		$('#client_list li').hover(function(){
			$(this).addClass('hover');
		}, function(){
			$(this).removeClass('hover');
		});
	
		/* !MOSAIC */
		$('#mosaic .tile').hover(function(){
			$('img', this).stop().animate({
				opacity: .1
			}, 'slow', 'easeInOutQuad');
		}, function(){
			$('img', this).stop().animate({
				opacity: 1
			}, 'slow', 'easeInOutQuad');
		});
	
		/* ////////////////////////// */
		
		$('#stage').css('opacity', 0);
		$('#marquee_description').css('bottom', '-5em');
		$('#marquee_tagline span').css({
			display: 'block',
			opacity: 0
		});
		$('#marquee_tagline span').eq(1).css({
			top: '-3em'
		});
	});
	
	window.onload = function(){
		if(!$.browser.msie){
			$('#client_list').jScrollPane({
				reinitialiseOnImageLoad: true,
				showArrows: true,
				animateTo: true
			});
			$('#marquee_clients').jScrollPane({
				reinitialiseOnImageLoad: true,
				showArrows: true,
				animateTo: true
			});
			
			$('#marquee_clients')[0].scrollTo(parseInt($('#active_slide').offset().top - $('#marquee_clients').offset().top) - 70);
		}
		
		$('#news_releases li a').widont();
		
		$('#stage').css('opacity', 1);
	} /* end onload */
})(jQuery);