$(document).ready(function(){
	setSection();
	setActive();
	setSubsectionActive();
	
	$("ul#topnav li").hover(function() { //Hover over event on list item
		setInActive();
		$(this).find("span").show(); //Show the subnav
	} , function() { //on hover out...
		
		$(this).find("span").hide(); //Hide the subnav
		setActive();
});
	
	$(window).resize(function() {
		centerScreen.center();
	});
});



var centerScreen = {
	center: function() {
    	var obj = $(".logo-link");
        obj.css('left', $(window).width()/2-obj.width()/2);
    }
}

function setActive() {
	$("ul#topnav li." + section).find("span").show(); //Show the subnav
} 

function setInActive() {
	$("ul#topnav li." + section).find("span").hide(); //Hide the subnav
}

function setSubsectionActive() {
	$("ul#topnav li." + section + " span a." + subsection).css({fontWeight:"bold"});
}

function setSection() {
		
		var url = document.URL;
		var index = 3;
		if(url.indexOf("designinmotion") != -1) {
			index = 3;
		}
		url = url.split("/");
		url = url[index];
		url = url.replace(".php","");
		
		subsection = url;	

		
	switch(url) {
		
		/* the mount nevis hotel */
		case "about-the-hotel":
			section = "nevis-hotel";		
			break;
		case "room-rate-and-info":
			section = "nevis-hotel";
			break;
		case "amenities":
			section = "nevis-hotel";
			break;
		case "dining":
			section = "nevis-hotel";
			break;
		case "faq":
			section = "nevis-hotel";
			break;
		case "mount-nevis-beach-club":
			section = "nevis-hotel";
			break;
		/* nevis island */
		case "about-the-island":
			section = "island";
			break;
		case "how-to-get-to-nevis":
			section = "island";
			break;
		case "amenities":
			break;
		
		/* deals */
		case "wedding":
			section = "deals";
			subsection = "wedding";
			break;
		case "deals":
			section = "deals";
			subsection = "deal";
			break;
		case "packages":
			section = "deals";
			break;
		/* reservation */
		case "make-a-reservation":;
			section = "make-a-reservation";
			break;
		case "mount-nevis-estate":;
			section = "mount-nevis-estate";
			break;
		default:break;
	}
}