//GTAPSP.com JavaScript
//©2011 Neil Christie
//First revision: 21 August 2011

//Do the below when the document is ready
$(document).ready(function(){
 
	//hide all the menus, we will open the right one later
	$(".gameNav ul").hide();

 
	//get the URL of the page the user is on 
 	var url = location.href;
 	var hideall = 1;
 	
 	if (url.match("=") == "=")
 	{
 	var hideall = 0;
 	}
 	else
 	{
 	var hideall = 1;
 	}
 	

 	if (hideall == 0)
 	{
 	
 		//cut the url down so it only includes the part after ?page=
 		var page = url.split('=', 2);
 	
 		//so now we have something that looks like /chw/main in variable page
 		//get the first 4 characters of this
 		var game = page[1].substring(0,4);
	 	 	
	 	if (game == "/chw" || game == "chw/")
 		{
 			$(".gameNav#cwNav ul").show();
 		}
 		else if (game == "/vcs" || game == "vcs/")
 		{
 			$(".gameNav#vcsNav ul").show();
 		}
 		else if (game == "/lcs" || game == "lcs/")
 		{
 			$(".gameNav#lcsNav ul").show();
 		} 	
}
else if (hideall == 1) //if we are on a page that doesn't contain =
{
	$(".gameNav ul").hide();
}
 	
 	
      		
   		$(".gameNav h1").click(function(){
   		var menuClicked = $(this).parent().attr("id");
   		$(".gameNav#" + menuClicked + " ul").slideToggle('slow');
   			});
 	});
