// page init
$(function(){
	initDropDown();
});

// drop init
function initDropDown(){
	var classHasDrop = 'has-drop-down';
	var classHasDropLink = 'has-drop-down-a';
	var classHover = 'hover';
	var duration = 250;
	
	$('#nav').each(function(){
		var nav = $(this);
		var list = $('>li', nav);
		
		list.each(function(){
			var holder = $(this);
			var drop = $('>ul', holder);
			
			if(drop.length){
				holder.addClass(classHasDrop);
				$('>a', holder).addClass(classHasDropLink);
				
				holder.hover(
					function(){
						_this = $(this);
						_this.addClass(classHover);
						if(!drop.is(':animated')){
							drop.hide().fadeIn(duration, function(){$(this).show();});
						}
					},
					function(){
						_this = $(this);
						_this.removeClass(classHover);
						drop.fadeOut(duration, function(){$(this).hide();});
						
						
					}
				);
				
			}
			
			
			
		});
	});



	/* var nav = document.getElementById("nav");
	if(nav) {
		var lis = nav.getElementsByTagName("li");
		for (var i=0; i<lis.length; i++) {
			if(lis[i].getElementsByTagName("ul").length > 0) {
				lis[i].className += " has-drop-down"
				lis[i].getElementsByTagName("a")[0].className += " has-drop-down-a"
			}
			lis[i].onmouseover = function()	{
				this.className += " hover";
			}
			lis[i].onmouseout = function() {
				this.className = this.className.replace(" hover", "");
			}
		}
	} */
}
