
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;
}
//Map Functions
$(document).ready(function(){
    $("#trigger").click(function () {
        $sd = $("div#curtain");
        if($sd.is(":visible"))
        {
            $sd.slideUp("slow");
        }else
            $sd.slideDown("slow", function(){
                centerMap();
            });
    });
    //initialize();
});

var geocoder;
var map;
var llPoint;
function initialize() {
    if($("#map_canvas").length != 0){
        geocoder = new google.maps.Geocoder();
        var myOptions = {
          zoom: 11,
          //center: latlng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
        codeAddress();
    }
}

function codeAddress() {
    if (geocoder) {
      geocoder.geocode( { 'address': address}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            llPoint = results[0].geometry.location;
          map.setCenter(llPoint);
          var marker = new google.maps.Marker({
              map: map,
              size: new google.maps.Size(300, 286),
              position: results[0].geometry.location
          });
        } else {
          alert("Geocode was not successful for the following reason: " + status);
        }
      });
    }
}

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();
                    }
                }        
            });
		});
       
       $(".emailForm2").formfocus();
        //hide popup search results when clicked outside
        $(document).ready(function(){
		});

       $(".emailForm3").formfocus();
        //hide popup search results when clicked outside
        $(document).ready(function(){
		});
    
		
		//convert richtext popup full size images to fancybox images
		$(".intContent 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
        $(".intContent 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
    
	
		
		
	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'
	});
	
	//Home Fader
	$('#features').jshowoff({ 
		controls: false,
		links: true,
		hoverPause: false,
		changeSpeed: 1200,
		speed: 5000
	});

  	//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');
	});*/
	
});
