﻿$(document).ready(function(){
	
	$("body").bind("click", function(){
		clearMenu();
	});
	
});

function bindMenu(name){
	
	$("#nav_" + name).bind("mouseover", function(){
		clearMenu();
		$("#subnav_" + name).show().bind("mouseover", function(){
			var nav = $(this).attr("id");
			nav = nav.replace("subnav", "nav");
			$("#" + nav).addClass("open");
			g_menu_open = true;
		});
	});
	
	/**/
	//find position of menu 
	//var pos = $("#nav_" + name).position();
	var pos = $("#nav_" + name).parent().position();
	var left = pos.left;
	var top = 30;
	if(name!="info_about"){
		var pos = $("#nav_main").position();
		top = pos.top + 40;
		//left += 30;
	}
	
	//$("#subnav_" + name).css("top", top);
	$("#subnav_" + name).css("left", left);
	
	
}

function clearMenu(){
	$(".open").removeClass("open");
	$(".subnav").hide();
}

function isNumeric(strString){
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
	{
	strChar = strString.charAt(i);
	if (strValidChars.indexOf(strChar) == -1)
	   {
	   blnResult = false;
	   }
	}
      
   return blnResult;
}


