function imgSwap(oImg)
{
   var strOver  = "o_nav_" ;   // image to be used with mouse over
   var strOff = "nav_"  ;   // normal image
   var strImg = oImg.src;
   if (strImg.indexOf(strOver) != -1) 
      oImg.src = strImg.replace(strOver,strOff);
   else
      oImg.src = strImg.replace(strOff,strOver);
}

$(document).ready(function(){

	var zIndexNumber = 1000;
	$('div').each(function() {	$(this).css('z-index', zIndexNumber);zIndexNumber -= 10;});
	
	$("#bot-menu img").hover(
		function(){
			this.id == "img1" ? $("#sub-join").css('display','block') : $("#sub-join").css('display','none');
			this.id == "img2" ? $("#sub-tour").css('display','block') : $("#sub-tour").css('display','none');
			this.id == "img3" ? $("#sub-training").css('display','block') : $("#sub-training").css('display','none');
			this.id == "img4" ? $("#sub-services").css('display','block') : $("#sub-services").css('display','none');
			this.id == "img5" ? $("#sub-locations").css('display','block') : $("#sub-locations").css('display','none');
		}
	);
	
	$("#horizontal-nav img").hover(
		function(){
			var filename = $(this).attr('alt');
			$(this).attr('src','/media/images/o_'+filename);
		},
		function(){
			var filename = $(this).attr('alt');
			$(this).attr('src','/media/images/'+filename);
		}
		
	);
	/*
	$("#vertical-nav img").hover(
		function(){
			var filename = $(this).attr('alt');
			$(this).attr('src','/media/images/o_'+filename);
		},
		function(){
			var filename = $(this).attr('alt');
			$(this).attr('src','/media/images/'+filename);
		}
		
	);
	*/

	$("#sub-join").hover(null,	function(){	$("#sub-join").css('display','none');});
	$("#sub-tour").hover(null,	function(){	$("#sub-tour").css('display','none');});
	$("#sub-training").hover(null,	function(){	$("#sub-training").css('display','none');});
	$("#sub-services").hover(null,	function(){	$("#sub-services").css('display','none');});
	$("#sub-locations").hover(null,	function(){	$("#sub-locations").css('display','none');});
	
	$("#JoinBtn").click(function(){
		var error = [];
		var out = "";
	
		$("#join-form input").each(function(){
			if($(this).val() == "" && this.alt == 'req' ){
				error.push(this.name);
			}
		});
		
		if(error.length)
		{
			for(x = 0; x < error.length; x++){
				out += "Please fill: \t" + $.trim(error[x]) + "\n" ;
			}
			alert(out);
			return false;
		}
		else{
			$("#join-form").submit();
		}
	});

});