jQuery.noConflict();
var homeGalleryStop = false;
function simple_tooltip(target_items, name){
 jQuery(target_items).each(function(i){
		jQuery("body").append("<div class='"+name+"' id='"+name+i+"'><p>"+jQuery(this).attr('title')+"</p></div>");
		var my_tooltip = jQuery("#"+name+i);

		jQuery(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(jQuery("#map_canvas").length != 0){
        if(map == null || map == undefined)
            initialize();
        else{
            google.maps.event.trigger(map, 'resize');
            map.setCenter(llPoint);
        }
    }
}

jQuery(document).ready(   
function()
    {	
        //hide popup search results when clicked outside
        jQuery(document).ready(function(){
            jQuery(document).click(function(event) {
                if(jQuery(event.target).parents().index(jQuery('.search_results')) == -1) {
                    if(jQuery('.search_results').is(":visible")) {
                        jQuery('.search_results').hide();
                    }
                }        
            });
		});
    
    	jQuery("#aNav" + pageName).addClass("navBG");
		jQuery("#aNav" + pageName).children(".navL").addClass("navLOn");
		jQuery("#aNav" + pageName).children(".navR").addClass("navROn");
		
		//convert richtext popup full size images to fancybox images
		jQuery(".contentText img").each(function(){
		    if(!jQuery(this).parent().is("a"))
		        jQuery(this).wrap("<a class='single_image' href='" + jQuery(this).attr("src") + "'></a>");
        });
        //end convert richtext popup full size images to fancybox images
		
        //convert richtext popup thumb images to fancybox images
        jQuery(".content a").each(function(){
            var href = jQuery(this).attr("href");
           if(href != undefined){
                var index = href.indexOf("viewImage");
                if(index > -1){
                   href = href.replace("javascript:viewImage('", "");
                   href = href.replace("')","");
                   jQuery(this).attr("href", href);
                   jQuery(this).addClass("single_image"); 
                }
            }
        });
        jQuery("a.single_image").fancybox();
        //end convert richtext popup images to fancybox images
    
        //left align all menus
        jQuery(".aNavName").each(function(){
            var left = jQuery(this).position().left-0;
		    jQuery(this).children(".menus").stop().css({'padding':'0 40px','left': -left});
        });
        
        //show current menu on page load
        jQuery("#aNav" + pageName).children(".menus").stop().css({'display':'block', 'top':'42px'}).animate(
        {
            opacity: 1
            //children hover
        }, "fast");
        
        
        //first level hover
	    jQuery('.aNavName').hover(
	        function()
	        {
	        	jQuery('.menus').css('height','auto');
	            if(jQuery(this).attr("id") != "aNav" + pageName)
	        	{
	        	    jQuery(this).children(".navL").addClass("navLOn");
	        	    jQuery(this).children(".navR").addClass("navROn");
		            jQuery(this).children(".menus").stop().css({'display':'block', 'top':'42px'}).animate(
		            {
			            opacity: 1
			            //children hover
		            }, "fast");
                    //end children hover
                    
                    //hide current menu
                    jQuery("#aNav" + pageName).children(".menus").stop().css({opacity: 0, top: -1000});
                }
	        },
	        //first level hover out
	        function(){
	        	jQuery('.menus').css('height','37px');
	        	if(jQuery(this).attr("id") != "aNav" + pageName)
	        	{
	        	    //return to current menu
		            jQuery("#aNav" + pageName).children(".menus").stop().css({'display':'block', 'top':'42px'}).animate(
		            {
			            opacity: 1
			            //children hover
		            }, "fast");
	        	
	        	
		        	jQuery(this).children(".navL").removeClass("navLOn");
		        	jQuery(this).children(".navR").removeClass("navROn");
		        	jQuery(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	
		jQuery('#navHolder .aNavName').hover(function(){
			jQuery(this).find('.aNavName').css('color','#ccc09b')
		}, function(){
			jQuery(this).find('.aNavName').css('color','#fff')
		});
		
		
	simple_tooltip(".tip","tooltip");
	//TABLE
	jQuery('#propertyTax table tr:eq(0)').addClass('tt_header');
	jQuery('#propertyTax table tr:odd').addClass('odd');
		
	//Remove Img if it's empty
	jQuery('#bg .siteContainer .content .contentLeft img').each(function(){
		var imgSrc = jQuery(this).attr("src");
		if(imgSrc == "")
			jQuery(this).remove();
	});
	
	jQuery("#various1").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
	});
	jQuery("#listingVideo").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
	});
	
			
	jQuery("#wdlMls").fancybox({
				'width'				: 636,
				'height'			: 1000,
		        'autoScale'     	: false,
		        'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
	});
	jQuery("#wdlMls2").fancybox({
				'width'				: 636,
				'height'			: 1000,
		        'autoScale'     	: false,
		        'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
	});
	jQuery("#houMls").fancybox({
				'width'				: 990,
				'height'			: 1000,
		        'autoScale'     	: false,
		        'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
	});
	jQuery("#allTestimonials").fancybox({
				'width'				: 600,
				'height'			: 600,
		        'autoScale'     	: false,
		        'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
	});		
	
  	//ACCORDION
	jQuery('.accordionButton').click(function() {
		jQuery('.accordionButton').removeClass('on');
	 	jQuery('.accordionContent').slideUp('fast');
		if(jQuery(this).next().is(':hidden') == true) {
			jQuery(this).addClass('on');
			jQuery(this).next().slideDown('normal');
		 } 
	 });
	  
	jQuery('.accordionButton').mouseover(function() {
		jQuery(this).addClass('over');
	}).mouseout(function() {
		jQuery(this).removeClass('over');										
	});
	jQuery('.accordionContent').hide();
	
	jQuery('.video_side .videoThumb a img').each(function(){
		var imgSrc = jQuery(this).attr("src");
		if(imgSrc == "")
			jQuery(this).attr("src", "/site/user/images/No_VideoThumb.jpg");
	});
	

	/*jQuery('#greenMenu').hover(function(){
		jQuery(this).slideDown('fast');
	});
	jQuery('#hideNav').click(function() {
		if(jQuery('.menus').css('height') == "37px")
		    jQuery('.menus').css('height','auto');
		else		    		
		    jQuery('.menus').css('height','37px');
	});*/
	
		//When page loads...
	jQuery(".tab_content").hide(); //Hide all content
	jQuery("ul.tabs li:first").addClass("active").show(); //Activate first tab
	jQuery(".tab_content:first").show(); //Show first tab content

	//On Click Event
	jQuery("ul.tabs li").click(function() {

		jQuery("ul.tabs li").removeClass("active"); //Remove any "active" class
		jQuery(this).addClass("active"); //Add "active" class to selected tab
		jQuery(".tab_content").hide(); //Hide all tab content

		var activeTab = jQuery(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		jQuery(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
	
});
