// JavaScript Document
jQuery(document).ready(function($) {
 	var fadeDuration = 500; //time in milliseconds
	// find the div.fade elements and hook the hover event
	$('.PortfolioRow').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('.PortfolioRowRoll', this);
		fade.fadeIn(500);
	}, function() {
		var fade = $('.PortfolioRowRoll', this);
			fade.fadeOut(500);
	});
	$('.menu').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('.menuroll', this);
		fade.fadeIn(fadeDuration);
	}, function() {
		var fade = $('.menuroll', this);
			fade.fadeOut(fadeDuration);
	});
	
      
      $('div.NavBg ul li a').hover(function() {
        $(this).animate({ paddingLeft: '20px' }, fadeDuration);
       
      }, function() {
        $(this).animate({ paddingLeft: '7px' }, fadeDuration);
       
      });
	  $('.PortfolioRightPanel').hide();
	  $('.RightPanelBoxBorder').fadeOut('slow', function(){
		$('.RightPanelBoxBorder>div').hide();
		$banner = $('#HM').children('.img_banner').empty();
		$('.RightPanelTextPad div.Overflow').fadeOut('slow');
		$('div.NavBg ul').find('li:first-child>div.menu a').addClass('selected');
        // We're in the callback of the fadeOut()
		$('<img alt="" width="665" height="115" border="0"/>').load(function(){
			$banner.append($(this));
        	$('.RightPanelTextPad div.Overflow').load('ajaxcontent.php', 'pid=HM', function(){
				$('.RightPanelBoxBorder').fadeIn(1500, function(){
					$('.RightPanelTextPad div.Overflow').fadeOut('slow').fadeIn(2000);
					$('.loading').hide();								
					$('#HM').show();
				});
			});
        }).attr('src',"images/title_1.jpg");		
      });
	  
	  $('.menuroll a').bind('click',function(){
	  		$('.PortfolioRow').children('.LeftText').removeClass('selected');
			$('.PortfolioRow').children('.RightImage').removeClass('selectedRightImage');
			$('.PortfolioRightPanel').hide();
	  		//$('.PortfolioPagePad').removeClass('PortfolioPagePad').addClass('HomePagePad');					
	  		$('.menu a').removeClass('selected');
			$(this).parent().siblings('a').addClass('selected');
	  		id=$(this).attr("href").slice(1);
	  		$('.RightPanelBoxBorder').fadeOut('slow', function(){
				$('div.RightPanel').fadeIn(2000);  
				$('.loading').show();
				$('.RightPanelBoxBorder>div').hide();
				if(id=="HM")
				{
					$banner = $('#HM').children('.img_banner').empty();
					$('.RightPanelTextPad div.Overflow').fadeOut('slow');
					$('<img alt="" width="665" height="115" border="0"/>').load(function(){
						$banner.append($(this));
						$('.RightPanelTextPad div.Overflow').load('ajaxcontent.php', 'pid=HM', function(){
							// We're in the callback of the load()
							$('.RightPanelBoxBorder').fadeIn(1500, function(){
								$('.RightPanelTextPad div.Overflow').fadeIn(2000);
								$('.loading').hide();
								$('#HM').show();
							});
				
						});
					}).attr('src',"images/title_1.jpg");
				}
				else if(id=="AU")
				{
					$banner = $('#AU').children().children().children('.img_banner').empty();
					$('.AboutRightPanelTextPad div.Overflow div.Left, div.Right').fadeOut('slow');	
					$('<img alt="" width="123" height="294" border="0"/>').load(function(){
						$banner.append($(this));
						$('.AboutRightPanelTextPad div.Overflow div.Left').load('ajaxcontent.php', 'pid=AU', function(){
							$('.AboutRightPanelTextPad div.Overflow div.Right').load('ajaxcontent.php', 'pid=CU', function(){
								$('.RightPanelBoxBorder').fadeIn(1500, function(){
									$('.AboutRightPanelTextPad div.Overflow div.Left, div.Right').fadeIn(2000);
									$('.loading').hide();
									$('#AU').show();
								});
							});
				
						});
					}).attr('src',"images/reach.jpg");
				}
				else
				{	
					$banner = $('#DC').children('.img_banner').empty();			
					if(id=="ME"){
						$('.ServicesRightPanelTextPad div.Overflow').fadeOut('slow');					
						$('<img alt="" width="665" height="115" border="0"/>').load(function(){
							$banner.append($(this));
							$('.ServicesRightPanelTextPad div.Overflow').load('ajaxcontent.php', 'pid='+id, function(){			
								$('.RightPanelBoxBorder').fadeIn(1500, function(){							
									$('.ServicesRightPanelTextPad div.Overflow').fadeIn(2000);
									$('.loading').hide();
									$('#DC').show();
								});			
							});
						}).attr('src',"images/title_3.jpg");
					}
					else
					{
						$('.ServicesRightPanelTextPad div.Overflow').fadeOut('slow');
						$('<img alt="" width="665" height="115" border="0"/>').load(function(){
							$banner.append($(this));
							$('.ServicesRightPanelTextPad div.Overflow').load('ajaxcontent.php', 'pid='+id, function(){			
								$('.RightPanelBoxBorder').fadeIn('slow', function(){							
									$('.ServicesRightPanelTextPad div.Overflow').fadeIn(2000);
									$('.loading').hide();
									$('#DC').show();
								});			
							});
						}).attr('src',"images/title_2.jpg");
					}
				}
		  });
		  return false;		  
      });		
			
	 
});
