﻿// jQuery Functions

var currentMenu = null;
var currentTitle = null;
var timeout = 1;

$(document).ready(function() {

   $("#menu a").mouseover(function(){	
		if($(this).attr("rel")!=''){
			currentMenu = $("#"+$(this).attr("rel"));
		}else{
			currentMenu = null;
		}
		currentTitle = $(this);
		showMenu();
	}).mouseout(function(){
		currentMenu = null;
		currentTitle = null;
		setTimeout(hideMenus,timeout);
	});	


   $(".dropdown").mouseover(function(){
		currentTitle = $("#menu a[rel='"+$(this).attr("id")+"']");
		currentMenu = $(this);
		showMenu();
	}).mouseout(function(){
		currentMenu = null;
		currentTitle = null;
		setTimeout(hideMenus,timeout);
	});

	setTimeout(hideMenus,timeout);

	function showMenu(){
		$(".dropdown").hide();
		$("#menu a").removeClass("transparency20");
		currentTitle.addClass("transparency20");	
		 if (currentMenu.is(":hidden")) {
			 currentMenu.show();
		 }
		
	}
	function hideMenus(){
		if(currentMenu==null&&currentTitle==null){
			$(".dropdown").hide();
			$("#menu a").removeClass("transparency20");
		}
	}
	$(".additem").click(function(){
		$("#SID_"+this.id).submit();
	});
});
