$(document).ready(function() {
  $('#nav_about').hover(function(){
  	$(this).addClass('hover');
    $('#nav_about .link_line, #company_profile_link, #philosophy_link').attr("style", "display:block;");
	},function(){
    $(this).removeClass('hover');
    if( $('#company_profile_page, #philosophy_page').length == 0 ){
   		$('#nav_about .link_line, #company_profile_link, #philosophy_link').attr("style", "display:none;");
		}
	});

  $('#about_menu').hover(function(){
	$('#company_profile_link, #philosophy_link').attr("style", "display:block;");
  }, function(){
	  if( $('#company_profile_page, #philosophy_page').length == 0 ){
   		$('#company_profile_link, #philosophy_link').attr("style", "display:none;");
		}
  });

  $('#services_menu').hover(function(){
	$('#asset_management_link, #underwriting_link').attr("style", "display:block;");
  }, function(){
		if( $('#asset_management_page, #underwriting_page').length == 0 ){
  		$('#asset_management_link, #underwriting_link').attr("style", "display:none;");
		}
  });

  $('#clients_menu').hover(function(){
	$('#commercial_lenders_link, #private_investors_link').attr("style", "display:block;");
  }, function(){
  	if( $('#commercial_lenders_page, #private_investors_page').length == 0 ){
			$('#commercial_lenders_link, #private_investors_link').attr("style", "display:none;");
		}	
  });

  $('#nav_services').hover(function(){
	  $('#nav_services .link_line, #asset_management_link, #underwriting_link').attr("style", "display:block;");
  	$(this).addClass('hover');
	},function(){
    $(this).removeClass('hover');
		if( $('#asset_management_page, #underwriting_page').length == 0 ){
	  	$('#nav_services .link_line, #asset_management_link, #underwriting_link').attr("style", "display:none;");
		}
	});

  $('#nav_clients').hover(function(){
  	$(this).addClass('hover');
	  $('#nav_clients .link_line, #commercial_lenders_link, #private_investors_link').attr("style", "display:block;");
	},function(){
    $(this).removeClass('hover');
		if( $('#commercial_lenders_page, #private_investors_page').length == 0 ){
	  	$('#nav_clients .link_line, #commercial_lenders_link, #private_investors_link').attr("style", "display:none;");
		}
	});
	
	$('#nav_contact').hover(function(){
	  $('#nav_contact .link_line').attr("style", "display:block;");
	$(this).addClass('hover');
	},function(){
  $(this).removeClass('hover');
	  $('#nav_contact .link_line').attr("style", "display:none;");
	});
	$('#nav_home').hover(function(){
	  $('#nav_home .link_line').attr("style", "display:block;");
	$(this).addClass('hover');
	},function(){
  $(this).removeClass('hover');
	  $('#nav_home .link_line').attr("style", "display:none;");
	});
	
  if( $('#company_profile_page').length != 0){
	  $('#company_profile_link').addClass('selected');
	  $('#about_menu a').attr("style", "display:block;");
	  $('#company_profile_link').attr('style', "background-position:-25px -246px; display:block;");
	}
	if( $('#philosophy_page').length != 0){
	  $('#philosophy_link').addClass('selected');
		$('#about_menu a').attr("style", "display:block;");
		$('#philosophy_link').attr('style', "background-position:-25px -276px; display:block;");
	}
	if( $('#asset_management_page').length != 0){
		$('#asset_management_link').addClass('selected');
		$('#services_menu a').attr("style", "display:block;");
		$('#asset_management_link').attr('style', "background-position:-215px -246px; display:block;");
	}
	if( $('#underwriting_page').length != 0){
		$('#underwriting_link').addClass('selected');
		$('#services_menu a').attr("style", "display:block;");
		$('#underwriting_link').attr('style', "background-position:-215px -276px; display:block;");
	}
	if( $('#commercial_lenders_page').length != 0){
		$('#commercial_lenders_link').addClass('selected');
		$('#clients_menu a').attr("style", "display:block;");
		$('#commercial_lenders_link').attr('style', "background-position:-416px -246px; display:block;");
	}
	if( $('#private_investors_page').length != 0){
		$('#private_investors_link').addClass('selected');
		$('#clients_menu a').attr("style", "display:block;");
		$('#private_investors_link').attr('style', "background-position:-416px -276px; display:block;");
	}
});

