$(document).ready(function()
{
	var this_id = '';
	$('.menu_item').hoverIntent({
		sensitivity: 7,
		interval: 200,
		over: function(){
			this_id = $(this).attr('id');
			$('#submenu_'+this_id.substring(5)).fadeIn('fast');
		},
		timeout: 199,
		out: function(){
			$('#submenu_'+this_id.substring(5)).fadeOut('fast');
		}
	});

	$('#main_slide').cycle({
		fx:			'scrollUp', 
		timeout: 	5000
	});

	// Case Studies transition function
	$('.menu_case_item').click(function(){
		$('.menu_case_item').css('font-weight', 'normal').css('cursor', 'pointer').css('color', '#477446');
		$(this).css('font-weight', 'bold').css('cursor', 'default').css('color', '#000');
		var width = $('#case_study').width();
		var height = $('#case_study').height();

		if( height > 0 )
		{
			$('#case_study').width(width);
			$('#case_study').height(height);
		}

		$('#case_study').html('<center><img src="/images/ajax-loader.gif" /></center>');
		$.post('/includes/get_page.php', { page: $(this).attr('id'), type: 'case_studies' },
			function(data) {
				$('#main_container').css('background-image', 'none');
				$('#case_study').animate({opacity:0}, function(){
					$('#case_study').html(data);
					$('#case_study').css('height', 'auto').css('visibility', 'visible');
				}).animate({opacity:1}, function(){
					window.location.hash="case_list";
				});
			}
		);
	});

	// Clients transition function
	$('.menu_client_item').click(function(){
		$('.menu_client_item').css('font-weight', 'normal').css('cursor', 'pointer').css('color', '#477446');
		$(this).css('font-weight', 'bold').css('cursor', 'default').css('color', '#000');
		var width = $('#clients').width();
		var height = $('#clients').height();

		if( height > 0 )
		{
			$('#clients').width(width);
			$('#clients').height(height);
		}

		$('#clients').html('<center><img src="/images/ajax-loader.gif" /></center>');
		$.post('/includes/get_page.php', { page: $(this).attr('id'), type: 'clients' },
			function(data) {
				$('#clients').animate({opacity:0}, function(){
					$('#clients').html(data);
					$('#clients').css('height', 'auto').css('visibility', 'visible');
				}).animate({opacity:1}, function(){
					window.location.hash="client_list";
				});
			}
		);
	});

	// Client image hover enlarge effect
	$('#client_collage > img').live('mouseover', function()
    {
		$(this).hoverIntent
		(
			function()
			{
				// mouseover logic
				var imglink = $(this).attr('alt');
				$('#client_collage_large').html('<img src="' + imglink + '" />').css('display', 'none').fadeIn();
			},
			function()
			{
				// mouseout logic
				$('#client_collage_large').fadeOut();
			}
		);
		$(this).trigger('mouseover');
    });

});

