
var homeGalleryStop = false;
function simple_tooltip(target_items, name){
 $(target_items).each(function(i){
		$("body").append("<div class='"+name+"' id='"+name+i+"'><p>"+$(this).attr('title')+"</p></div>");
		var my_tooltip = $("#"+name+i);

		$(this).removeAttr("title").mouseover(function(){
				my_tooltip.css({opacity:0.8, display:"none"}).fadeIn(400);
		}).mousemove(function(kmouse){
				my_tooltip.css({left:kmouse.pageX+15, top:kmouse.pageY+15});
		}).mouseout(function(){
				my_tooltip.fadeOut(400);
		});
	});
}

function goTo(page){
	window.location = page;
}

function centerMap()
{
    if($("#map_canvas").length != 0){
        if(map == null || map == undefined)
            initialize();
        else{
            google.maps.event.trigger(map, 'resize');
            map.setCenter(llPoint);
        }
    }
}

$(document).ready(   
function()
    {	
       $(".emailForm").formfocus();
        //hide popup search results when clicked outside
        $(document).ready(function(){
            $(document).click(function(event) {
                if($(event.target).parents().index($('.search_results')) == -1) {
                    if($('.search_results').is(":visible")) {
                        $('.search_results').hide();
                    }
                }        
            });
		});
    
    	$("#aNav" + pageName).addClass("navBG");
		$("#aNav" + pageName).children(".navL").addClass("navLOn");
		$("#aNav" + pageName).children(".navR").addClass("navROn");
		
		//convert richtext popup full size images to fancybox images
		$(".intRightContent img").each(function(){
		    if(!$(this).parent().is("a"))
		        $(this).wrap("<a class='single_image' href='" + $(this).attr("src") + "'></a>");
        });
        //end convert richtext popup full size images to fancybox images
		
        //convert richtext popup thumb images to fancybox images
        $(".intRightContent a").each(function(){
            var href = $(this).attr("href");
           if(href != undefined){
                var index = href.indexOf("viewImage");
                if(index > -1){
                   href = href.replace("javascript:viewImage('", "");
                   href = href.replace("')","");
                   $(this).attr("href", href);
                   $(this).addClass("single_image"); 
                }
            }
        });
        $("a.single_image").fancybox();
        //end convert richtext popup images to fancybox images
    
        //left align all menus
        $(".aNavName").each(function(){
            var left = $(this).position().left-0;
		    $(this).children(".menus").stop().css({'padding':'0 40px','left': -left});
        });
        
        //show current menu on page load
        $("#aNav" + pageName).children(".menus").stop().css({'display':'block', 'top':'42px'}).animate(
        {
            opacity: 1
            //children hover
        }, "fast");
        
        
        //first level hover
	    $('.aNavName').hover(
	        function()
	        {
	        	$('.menus').css('height','auto');
	            if($(this).attr("id") != "aNav" + pageName)
	        	{
	        	    $(this).children(".navL").addClass("navLOn");
	        	    $(this).children(".navR").addClass("navROn");
	        	    $(this).children(".navText").addClass("navBG");
		            $(this).children(".menus").stop().css({'display':'block', 'top':'42px'}).animate(
		            {
			            opacity: 1
			            //children hover
		            }, "fast");
                    //end children hover
                    
                    //hide current menu
                    $("#aNav" + pageName).children(".menus").stop().css({opacity: 0, top: -1000});
                }
	        },
	        //first level hover out
	        function(){
	        	$('.menus').css('height','37px');
	        	if($(this).attr("id") != "aNav" + pageName)
	        	{
	        	    //return to current menu
		            $("#aNav" + pageName).children(".menus").stop().css({'display':'block', 'top':'42px'}).animate(
		            {
			            opacity: 1
			            //children hover
		            }, "fast");
	        	
	        	
		        	$(this).children(".navL").removeClass("navLOn");
		        	$(this).children(".navR").removeClass("navROn");
		        	$(this).children(".navText").removeClass("navBG");
		        	$(this).children(".menus").stop().animate({
			            opacity: 0
		            }, "fast").animate({
			            top: -1000
		            }, 2);
		        }
	        }
	        //end first level hover out
	    );
	    //end first level hover	
	
		//NAVAGATION ADD 2 CORNERS	
		$('#navHolder .aNavName').hover(function(){
			$(this).find('.aNavName').css('color','#ccc09b')
		}, function(){
			$(this).find('.aNavName').css('color','#fff')
		});
		
		
	simple_tooltip(".tip","tooltip");
	//TABLE
	$('#propertyTax table tr:eq(0)').addClass('tt_header');
	$('#propertyTax table tr:odd').addClass('odd');
		
	//Remove Img if it's empty
	$('#bg .siteContainer .content .contentLeft img').each(function(){
		var imgSrc = $(this).attr("src");
		if(imgSrc == "")
			$(this).remove();
	});
	
	$("#various1").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
	});
	$("#listingVideo").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
	});
	
			
	$("#wdlMls").fancybox({
				'width'				: 636,
				'height'			: 1000,
		        'autoScale'     	: false,
		        'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
	});
	$("#wdlMls2").fancybox({
				'width'				: 636,
				'height'			: 1000,
		        'autoScale'     	: false,
		        'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
	});
	$("#houMls").fancybox({
				'width'				: 990,
				'height'			: 1000,
		        'autoScale'     	: false,
		        'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
	});
	$("#allTestimonials").fancybox({
				'width'				: 600,
				'height'			: 600,
		        'autoScale'     	: false,
		        'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
	});
	$("#PrivacyPolicy").fancybox({
		'width'				: 575,
		'height'			: 600,
        'autoScale'     	: false,
        'transitionIn'		: 'elastic',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});

	$("#siteMapPop").fancybox({
		'width'				: 500,
		'height'			: 300,
        'autoScale'     	: false,
        'transitionIn'		: 'elastic',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
	
  	//ACCORDION
	$('.accordionButton').click(function() {
		$('.accordionButton').removeClass('on');
	 	$('.accordionContent').slideUp('fast');
		if($(this).next().is(':hidden') == true) {
			$(this).addClass('on');
			$(this).next().slideDown('normal');
		 } 
	 });
	  
	$('.accordionButton').mouseover(function() {
		$(this).addClass('over');
	}).mouseout(function() {
		$(this).removeClass('over');										
	});
	$('.accordionContent').hide();
	
	$('.video_side .videoThumb a img').each(function(){
		var imgSrc = $(this).attr("src");
		if(imgSrc == "")
			$(this).attr("src", "/site/user/images/No_VideoThumb.jpg");
	});
	

	/*$('#greenMenu').hover(function(){
		$(this).slideDown('fast');
	});
	$('#hideNav').click(function() {
		if($('.menus').css('height') == "37px")
		    $('.menus').css('height','auto');
		else		    		
		    $('.menus').css('height','37px');
	});*/
	
});
