﻿$(document).ready(function() {

    var primarySection = jQuery.url.segment(0);
    var primaryPage = jQuery.url.segment(1);

    var secondarySection = jQuery.url.segment(1);
    var secondaryPage = jQuery.url.segment(2);

    /** MAKE DIVS CLICKABLE **/
    $("#mnFind").click(function() {
			window.location = $(this).find("a").attr("href");
			return false;
		}
    );

    $("#mnExperience").click(function() {
			window.location = $(this).find("a").attr("href");
			return false;
		}
    );

    $("#mnInvesting").click(function() {
			window.location = $(this).find("a").attr("href");
			return false;
		}
    );

    $("#mnLeasing").click(function() {
			window.location = $(this).find("a").attr("href");
			return false;
		}
    );

    $("#mnFeatured").click(function() {
			window.location = $(this).find("a").attr("href");
			return false;
		}
    );

    $("#mnPartners").click(function() {
			window.location = $(this).find("a").attr("href");
			return false;
		}
    );

    /** subnav divs clickable **/
    $(".secondary").click(function() {
			window.location = $(this).find("a").attr("href");
			return false;
		}
    );

    /** ROLLOVERS **/
    if (primarySection == "experience") {
        $("#mnExperience").addClass("active");

        var bio = $.query.get("id");
        if (bio != null) {
            if ($("div[name=" + bio + "]")) {
                $("div[name=" + bio + "]").addClass("selected");
                $("a[href$=experience/people/bio.aspx?id=" + bio + "]").addClass("selected");
            }
        }

        /** leftnav divs clickable **/
        $(".tertiaryLinkHolder").click(function() {
				window.location = $(this).find("a").attr("href");
				return false;
	        }
	    );
    }

    if (primarySection == "find") {
        $("#mnFind").addClass("active");
    }

    if (primarySection == "leasing") {
        $("#mnLeasing").addClass("active");
    }

    if (primarySection == "investing") {
        $("#mnInvesting").addClass("active");
    }

    if (primarySection == "development") {
        $("#mnFeatured").addClass("active");
    }

    if (primarySection == "partners") {
        $("#mnPartners").addClass("active");
    }

    $("#overviewMenu").hover(function() {
			$("#overviewMenu").addClass("hover");
		},
        function() {
            $("#overviewMenu").removeClass("hover");
        }
    );

    $("#peopleMenu").hover(function() {
			$("#peopleMenu").addClass("hover");
		},
        function() {
            $("#peopleMenu").removeClass("hover");
        }
    );

    $("#newsMenu").hover(function() {
			$("#newsMenu").addClass("hover");
		},
        function() {
            $("#newsMenu").removeClass("hover");
        }
    );

    $("#socialMenu").hover(function() {
			$("#socialMenu").addClass("hover");
		},
        function() {
            $("#socialMenu").removeClass("hover");
        }
    );

    $("#tourismMenu").hover(function() {
			$("#tourismMenu").addClass("hover");
		},
        function() {
            $("#tourismMenu").removeClass("hover");
        }
	);

    $("#boardMenu").hover(function() {
			$("#boardMenu").addClass("hover");
		},
        function() {
            $("#boardMenu").removeClass("hover");
        }
    );
    
    $("#execMenu").hover(function() {
			$("#execMenu").addClass("hover");
		},
        function() {
            $("#execMenu").removeClass("hover");
        }
    );

    $("#seniorMenu").hover(function() {
			$("#seniorMenu").addClass("hover");
		},
        function() {
            $("#seniorMenu").removeClass("hover");
        }
    );

    $("#socialMenu").hover(function() {
			$("#socialMenu").addClass("hover");
		},
        function() {
            $("#socialMenu").removeClass("hover");
        }
	);
});