// JavaScript Document


$(document).ready(function(){
						currentPage();
						//function controls slider on homepage set to auto play
						
						
						
						//function controls tool tip on community images on homepage
						$("#properties1").tooltip({ 
												 
												 
									effect: 'slide',
									position: ['top', 'center'],
									offset: [60,0]	
										
										});
						
						$("#properties2").tooltip({ 
												 
												 
									effect: 'slide',
									position: ['top', 'center'],
									offset: [60,0]	
										
										});
						
						$("#properties3").tooltip({ 
												 
												 
									effect: 'slide',
									position: ['top', 'center'],
									offset: [60,0]	
										
										});
						$("#properties4").tooltip({ 
												 
												 
									effect: 'slide',
									position: ['top', 'center'],
									offset: [60,0]	
										
										});
					
						$(".scrollable").scrollable({circular: true}).navigator().autoscroll(6000);
						//function controls tab navigation on apartment pages: Interior Photos, Floor Plan, Exterior
						$("ul.tabs").tabs("div.panes > div");
						
						//function opens pop up for larger images on apartment pages
						$(".panes img").click(function(e){
										
										add_overlay();
										
										var imageL = $(this).attr("title");
										var lightboxPosY = e.pageY - 250;
						
										openLightBox(lightboxPosY, imageL);
											  
											  
						});
						  
						$(".menulink").mouseover(function(){
										
									var menulink = $(this).position();
									$(".dmenu").css({"left" : menulink.left, "top" : menulink.top + 44}).show();				  
									
													  });
						$(".menulink").mouseout(function(){
														$(".dmenu").mouseover(function(){
																	$(this).show();
																	$(".menulink").addClass("active");
																	$(this).mouseout(function(){
																							  
																					$(this).hide();
																					$(".menulink").removeClass("active");
																							  });
																					   });
														  	$(".dmenu").hide();
													  	});
						
});


function add_overlay(){
	
	$('<div id="overlay"></div>')
	.css('opacity', '0')
	.animate({'opacity': '0.5'}, 'fast')
	.appendTo('body');
	
	
}

function remove_overlay(){
	
	$("#overlay").remove();	
	
}

function openLightBox( LBheight, imgTitle){
					
					$("#lightbox img").attr("src" , "images/" + imgTitle + ".jpg");
					
						
					$("#lightbox").css({'top':LBheight}).fadeIn('slow');
				
					$(".close_lightbox").click(function(){
																	  
								$("#lightbox").hide('fast');
								remove_overlay();
								$("#lightbox img").attr("src" , "");
																	  
					});
	
	
}

function currentPage(){	

						var identifier = window.location.pathname;
						
  						switch(identifier)
        				{
            			case "http://www.global-icon.com/clients/Fidelity/test_site/index.asp":
            			//edit proper tag's css
            			$('.nav a').eq(0).addClass("active");
            			break;
						
            			case 'http://www.global-icon.com/clients/Fidelity/test_site/communities.asp':
           				 //edit proper tag's css
            			$('.nav a').eq(1).addClass("active");
           				 break;
						 
						 case 'http://www.global-icon.com/clients/Fidelity/test_site/applications.asp':
           				 //edit proper tag's css
            			$('.nav a').eq(2).addClass("active");
           				 break;
						 
						 case 'http://www.global-icon.com/clients/Fidelity/test_site/about-us.asp':
           				 //edit proper tag's css
            			$('.nav a').eq(3).addClass("active");
           				 break;
						 
						 case 'http://www.global-icon.com/clients/Fidelity/test_site/links.asp':
           				 //edit proper tag's css
            			$('.nav a').eq(4).addClass("active");
           				 break;
						 
						  
        				}
				}
