//jQuery functions

$(document).ready(function(){
						   
//nav functions

    $(".navList").children("li").each(function() {
    var current =  "navList " + ($(this).attr("class")) + "On";
    var parentClass = $(".navList").attr("class");
    if (parentClass != current) {
        $(this).children("a").css({backgroundImage:"none"});
    }
	
	});

	attachNavEvents(".navList", "navLiving");
	attachNavEvents(".navList", "navHomes");
	attachNavEvents(".navList", "navTeam");
	attachNavEvents(".navList", "navListings");
	attachNavEvents(".navList", "navContact");
		
function attachNavEvents(parent, myClass) {
    $(parent + " ." + myClass).mouseover(function() {
        $(this).before('<div class="' + myClass + 'Effect"></div>');
        $("div." + myClass + "Effect").css({display:"none"}).fadeIn(300);
    }).mouseout(function() {
        $("div." + myClass + "Effect").fadeOut(300, function() {
            $(this).remove();
        });
    }).mousedown(function() {
        $("div." + myClass + "Effect").attr("class", myClass + "Click");
    }).mouseup(function() {
        $("div." + myClass + "Click").attr("class", myClass + "On");
    });
}

//image swaps

   $(".imgSwap").hover(function() {
     var urlString = $(this).attr("src");
	 var newURL = urlString.replace(/\.((?!\.)+(?!\/))/,"_on.");
	 $(this).attr("src",newURL);
   },function(){
	 var urlString = $(this).attr("src");
	 var newURL = urlString.replace(/_on\./,".");
	 $(this).attr("src",newURL);
   });

// Sign up form functions

    $("#signupForm").validate( {
		messages: {
			val_1: "Required",
			val_2: "Required",
			val_7: "Required",
			email: "Valid email required"
		}
	});
	
	$("#mastSignupForm").validate( {
		messages: {
			email: "A Valid email is required"
		}
	});
	
// Team functions

   $(".teamBio").css("display","none");
	 $(".teamWrapper").hover(function() {
     $(this).addClass("teamWrapperOn");
   },function(){
     $(this).removeClass("teamWrapperOn");
   });
   $(".teamWrapper").click(function() {
   	$(this).find(".teamBio").slideToggle("slow");
	$(this).find(".teamOpenBio").slideToggle("slow");
	$(this).find(".teamDescrip").slideToggle("slow");
   });
   
 // Homes Functions
 
    $(".homesWrapper").hover(function() {
     $(this).addClass("homesWrapperOn");
   },function(){
     $(this).removeClass("homesWrapperOn");
   });
   $(".homesWrapper").click(function(e) {
   	var homesLink = $(this).find("a").attr("href");
	 window.location=homesLink;
   });

});

// DW functions

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
