$(function() {
	$.fn.wait = function(time, type) {
		time = time || 1000;
		type = type || "fx";
		return this.queue(type, function() {
			var self = this;
			setTimeout(function() {
				$(self).dequeue();
			}, time);		
		});
	};
	
	$('.textField').focus(
		function(){
			$(this).val('');
		}
	);
	
	
	$('.textField').blur(
		function(){
			if ($(this).val() == '')
			{
				$(this).val('search our site');
			}
		}
	);

	if (currentPage == 'home')
	{
		$('#fortegallery').crossSlide({
		  sleep: 5,
		  fade: 1
		}, [
		  { src: 'images/forte5.jpg' },
		  { src: 'images/forte2.jpg' },
		  { src: 'images/forte3.jpg' },
		  { src: 'images/forte4.jpg' }
		]);
		
		$('.headlines a').hover(
			function(){
				$(this).siblings('img').attr('oldsrc', $(this).siblings('img').attr('src'));
				$(this).siblings('img').attr('src', 'images/headlines_readmore.jpg');
			},
			function(){
				$(this).siblings('img').attr('src', $(this).siblings('img').attr('oldsrc'));
			}
		);
	}
	else if (currentPage == 'clients')
	{
		if (location.hash)
		{
			$('.clientdetails').hide();
		
			$(location.hash).show();
			client_name = location.hash.slice(0, -1);
			$(client_name).addClass('selected');
		}
	
		$('ul.clients a').click(
			function(){
				if (!$(this).attr('id'))
				{
					return false;
				}			
			
				details = '#'+$(this).attr('id')+'d';
				
				if (!jQuery.browser.msie)
				{
					location.hash = details;
				}
				
				if ($(this).hasClass('selected'))
					return false;
				
				$('.clients').find('.selected').removeClass('selected');
				$(this).addClass('selected');
				
				$('.clientdetails').fadeOut(200);
				$(details).wait(210).fadeIn(200);
							
				return false;
			}
		);
	}
	else if (currentPage == 'expertise')
	{
		$('ul.expertise a').click(
			function() {
				$(this).siblings('p').slideToggle();
				
				return false;
			}
		);
		
		$('#seeall').click(
			function() {
				$('ul.expertise p').slideDown();
				
				return false;
			}
		);
		
	
	}
});
