var menuTimer = null;
var menuTimer2 = null;
var menuTimer3 = null;
var menuTimer4 = null;
var menuTimer5 = null;
var menuTimer6 = null;
var leftTo = 8;
var topTo = -20;
var fo_shadows=new Array();
function showmenu(obj1, obj2, state, location, iframeId){ 
    var btn=document.getElementById(obj1);
    var obj=document.getElementById(obj2);
    var h=btn.offsetHeight;
    var w=btn.offsetWidth;
    var x=btn.offsetLeft;
    var y=btn.offsetTop;
    
    obj.onmouseover =function(){
        showmenu(obj1, obj2, 'show', location, iframeId);
    }
    obj.onmouseout =function(){
        showmenu(obj1, obj2, 'hide', location, iframeId);
    }
    
    while(btn=btn.offsetParent){ y+=btn.offsetTop; x+=btn.offsetLeft; }
    
    var hh=obj.offsetHeight;
    var ww=obj.offsetWidth;
    var xx=obj.offsetLeft;//style.left;
    var yy=obj.offsetTop;//style.top;
    var obj2state=state.toLowerCase();
    var obj2location=location.toLowerCase();
    
    var showx,showy;

    if(obj2location=="left" || obj2location=="l" || obj2location=="top" || obj2location=="t" || obj2location=="u" || obj2location=="b" || obj2location=="r" || obj2location=="up" || obj2location=="right" || obj2location=="bottom"){
        if(obj2location=="left" || obj2location=="l"){showx=x-ww;showy=y;}
        if(obj2location=="top" || obj2location=="t" || obj2location=="u"){showx=x;showy=y-hh;}
        if(obj2location=="right" || obj2location=="r"){showx=x+w;showy=y;}
        if(obj2location=="bottom" || obj2location=="b"){showx=x+topTo;showy=y+h+leftTo;}
    }else{ 
        showx=xx; showy=yy;
    }
    obj.style.left = showx + "px";
    obj.style.top = showy + "px";
    if(state=="hide"){
		switch(obj2){
			case "mdiv":
			menuTimer = setTimeout("hiddenmenu('" + obj2 + "', '" + iframeId + "')", 300);
			break;
			case "mdiv2":
			menuTimer2 = setTimeout("hiddenmenu('" + obj2 + "', '" + iframeId + "')", 300);
			break;
			case "mdiv3":
			menuTimer3 = setTimeout("hiddenmenu('" + obj2 + "', '" + iframeId + "')", 300);
			break;
			case "mdiv4":
			menuTimer4 = setTimeout("hiddenmenu('" + obj2 + "', '" + iframeId + "')", 300);
			break;
			case "mdiv5":
			menuTimer5 = setTimeout("hiddenmenu('" + obj2 + "', '" + iframeId + "')", 300);
			break;
			case "mdiv6":
			menuTimer6 = setTimeout("hiddenmenu('" + obj2 + "', '" + iframeId + "')", 300);
			break;
		}
		//hiddenmenu(obj2, iframeId);
    }else{
		switch(obj2){
			case "mdiv":
				clearTimeout(menuTimer);
			break;
			case "mdiv2":
				clearTimeout(menuTimer2);
			break;
			case "mdiv3":
				clearTimeout(menuTimer3);
			break;
			case "mdiv4":
				clearTimeout(menuTimer4);
			break;
			case "mdiv5":
				clearTimeout(menuTimer5);
			break;
			case "mdiv6":
				clearTimeout(menuTimer6);
			break;
		}
        obj.style.visibility ="visible";
		topDiv(obj2, iframeId, state);
		//ie_dropshadow(obj, "#666", 1);
    }
}
function ie_dropshadow(el, color, size)
{
	try{
		var i;
		for (i=size; i>0; i--)
		{
			var rect = document.createElement('div');
			var rs = rect.style;
			rs.position = 'absolute';
			rs.left = (el.style.posLeft + i) + 'px';
			rs.top = (el.style.posTop + i) + 'px';
			rs.width = el.offsetWidth + 'px';
			rs.height = el.offsetHeight + 'px';
			rs.zIndex = el.style.zIndex - i;
			rs.backgroundColor = color;
			var opacity = 1 - i / (i + 1);
			rs.filter = 'alpha(opacity=' + (100 * opacity) + ')';
			el.insertAdjacentElement('afterEnd', rect);
			fo_shadows[fo_shadows.length] = rect;
		}
	}
	catch(e){}
}
function ie_clearshadow()
{
	try{
		for(var i=0;i<fo_shadows.length;i++)
		{
			if (fo_shadows[i])
				fo_shadows[i].style.display="none" ;
		}
	}
	catch(e){}
	fo_shadows=new Array();
}
function hiddenmenu(psObjId, iframeId){
    document.getElementById(psObjId).style.visibility ="hidden";
	topDiv(psObjId, iframeId, "hide");
	//ie_clearshadow();
}
//用iframe挡住select, 使div不被select挡住
function topDiv(divId, iframeId, state)
{
	var DivRef = document.getElementById(divId);
	var IfrRef = document.getElementById(iframeId);
	if(state=="show")
	{
		//DivRef.style.display = "block";
		IfrRef.style.width = DivRef.offsetWidth;
		IfrRef.style.height = DivRef.offsetHeight;
		IfrRef.style.top = DivRef.style.top;
		IfrRef.style.left = DivRef.style.left;
		IfrRef.style.zIndex = DivRef.style.zIndex - 1;
		IfrRef.style.display = "block";
	}
	else
	{
		//DivRef.style.display = "none";
		IfrRef.style.display = "none";
	}
}