/*
author:vapour
email:dovapour@gmail.com
website:http://www.dovapour.com.cn/
qq:362380046
*/

function $d(element){
	if(arguments.length>1){
		for(var i=0,elements=[],length=arguments.length;i<length;i++)
			elements.push($d(arguments[i]));
		return elements;
	}
	if(typeof element=="string")
		return document.getElementById(element);
	else
		return element;
}

var Class={
	create:function(){
		return function(){
			this.initialize.apply(this,arguments);
		}	
	}
}

function addClassName(obj,className){
	obj.className+=" "+className;
}
function removeClassName(obj,className){
	var reg=new RegExp(" "+className,"g");
	obj.className=obj.className.replace(reg,"");
}
var listMenu=Class.create();
listMenu.prototype={
	initialize:function(nav,context,current){
		var flag=null;
		nav=$d(nav);
		context=$d(context);
		
		nav.onmouseover=function(){
			clearTimeout(flag);
			//context.style.display="block";
			$(context).slideDown("fast"); 
			$(nav).css("background","url(images/dhbg-2.jpg) no-repeat center top;");
			
			addClassName(nav,current);
		}
		nav.onmouseout=function(){
			flag=setTimeout(function(){
				removeClassName(nav,current);
				context.style.display="none";
				$(context).slideUp("fast"); 
				$(nav).css("background","url(images/dhbg-1.jpg) no-repeat center top;");
			},300);
		}
		context.onmouseover=function(){
			clearTimeout(flag);
			addClassName(nav,current);
			//context.style.display="block";
       $(context).slideDown("fast"); 
}
		context.onmouseout=function(){
			flag=setTimeout(function(){
				removeClassName(nav,current);
				//context.style.display="none";
				$(context).slideUp("fast"); 
				$(nav).css("background","url(images/dhbg-1.jpg) no-repeat center top;");
				
			},300);
		}
	}
}
new listMenu("main1","list1","current");
new listMenu("main2","list2","current");
new listMenu("main3","list3","current");
new listMenu("main4","list4","current");
new listMenu("main5","list5","current");
new listMenu("main6","list6","current");



