$(document).ready(function() {
	
	// get current page name
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	var bClass = $("body").attr("class");
	
	//set current page nav state
	var cPage = "";
	
	switch(bClass) {
		case "home":
			$("#btnHome").animate(
				{backgroundPosition: "0 -27px"}, 100
			);
			cPage = "home";
		break;
		case "scholarship":
			$("#btnScholarship").animate(
				{backgroundPosition: "0 -27px"}, 100
			);
			cPage = "scholarship";
		break;
		case "membership":
			$("#btnMembership").animate(
				{backgroundPosition: "0 -27px"}, 100
			);
			cPage = "membership";
		break;
		case "contact":
			$("#btnContact").animate(
				{backgroundPosition: "0 -27px"}, 100
			);
			cPage = "contact";
		break;
		case "events":
			$("#btnEvents").animate(
				{backgroundPosition: "0 -27px"}, 100
			);
			cPage = "events";
		break;
	}
	
	// main nav event bindings
	// Home
	if (cPage != "home") {
		$("#btnHome").click(function() {
			document.location.href = '/index.php';
		});
		$("#btnHome").bind("mouseover", function() {
			$(this).stop().css({backgroundPosition: "0 0"}).animate(
				{backgroundPosition: "0 -27px"}, 
				{duration: 100}
			);
		});
		$("#btnHome").bind("mouseout", function() {
			$(this).stop().animate(
				{backgroundPosition: "0 0"}, 
				{duration: 100}
			);
		});
	}
	// Scholarship
	if (cPage != "scholarship") {
		$("#btnScholarship").click(function() {
			document.location.href = '/scholarship.php';
		});
		$("#btnScholarship").bind("mouseover", function() {
			$(this).stop().css({backgroundPosition: "0 0"}).animate(
				{backgroundPosition: "0 -27px"}, 
				{duration: 100}
			);
		});
		$("#btnScholarship").bind("mouseout", function() {
			$(this).stop().animate(
				{backgroundPosition: "0 0"}, 
				{duration: 100}
			);
		});
	}
	// Membership
	if (cPage != "membership") {
		$("#btnMembership").click(function() {
			document.location.href = '/membership.php';
		});
		$("#btnMembership").bind("mouseover", function() {
			$(this).stop().css({backgroundPosition: "0 0"}).animate(
				{backgroundPosition: "0 -27px"}, 
				{duration: 100}
			);
		});
		$("#btnMembership").bind("mouseout", function() {
			$(this).stop().animate(
				{backgroundPosition: "0 0"}, 
				{duration: 100}
			);
		});
	}
	// Contact
	if (cPage != "contact") {
		$("#btnContact").click(function() {
			document.location.href = '/contact.php';
		});
		$("#btnContact").bind("mouseover", function() {
			$(this).stop().css({backgroundPosition: "0 0"}).animate(
				{backgroundPosition: "0 -27px"}, 
				{duration: 100}
			);
		});
		$("#btnContact").bind("mouseout", function() {
			$(this).stop().animate(
				{backgroundPosition: "0 0"}, 
				{duration: 100}
			);
		});
	}
	// Events
	if (cPage != "events") {
		$("#btnEvents").click(function() {
			document.location.href = '/events.php';
		});
		$("#btnEvents").bind("mouseover", function() {
			$(this).stop().css({backgroundPosition: "0 0"}).animate(
				{backgroundPosition: "0 -27px"}, 
				{duration: 100}
			);
		});
		$("#btnEvents").bind("mouseout", function() {
			$(this).stop().animate(
				{backgroundPosition: "0 0"}, 
				{duration: 100}
			);
		});
	}
	
	
	
	
	// Check Us Out Bar
	$("#flickr").bind("click", function() {
		var linkUrl = "http://www.flickr.com/photos/wsaa/";
		MM_openBrWindow(linkUrl,'newwin','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600');
	});
	$("#flickr").hover(
		function() {
			// over
			$(this).css("backgroundPosition", "0 -19px");
		},
		function() {
			// out
			$(this).css("backgroundPosition", "0 0");
		}
	);
	
	$("#facebook").bind("click", function() {
		var linkUrl = "http://www.facebook.com/home.php#/group.php?gid=55141098835";
		MM_openBrWindow(linkUrl,'newwin','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600');
	});
	$("#facebook").hover(
		function() {
			// over
			$(this).css("backgroundPosition", "0 -21px");
		},
		function() {
			// out
			$(this).css("backgroundPosition", "0 0");
		}
	);
	
	
	
});


function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}
