////////////////////////////////////////////////////
////////////////////////////////////////////////////
var vm_menu=new Array();
function vMenu(objName,expandDir) {
	this.objName=objName
	vm_menu[vm_menu.length]=objName
	this.show=vm_show
	this.addItem=vm_addItem
	this.showChilds=vm_showChilds
	this.hide=vm_hide
	this.hide_c=vm_hide_clear
	this.delayHide=vm_delayHide
	this.clearHide=vm_clearHide
	this.left=0
	this.top=0
	this.height=15
	this.width=160
	this.offsetLeft=-11
	this.offsetTop=34
	this.overBgColor='#FFFFFF';
	this.outBgColor='#FFFFFF';
	this.divId='parent_div'+objName
	this.delay=200
	this.delayObj=0
	this.parent=0
	this.childs=new Array()
	if (expandDir)
		this.expandDir=expandDir
	else
		this.expandDir='right'
	var st_str=""
	if (this.width)
		st_str+="width:"+vm_parseInt(this.width)+"px;"
	if (this.heigth)
		st_str+="height:"+vm_parseInt(this.height)+"px;"
	document.write('<div id="'+this.divId+'" name="'+this.divId+'" class="vmenu_div" style="'+st_str+'"></div>')
}
function vm_addItem(item) {
	this.childs[this.childs.length]=item
	item.parent=this
	if (item.childObj) {
		item.childObj.parent=this
		item.childObj.expandDir=this.expandDir
	}
}
function vm_show(obj) {
	vm_hideAll();
	var divobj=document.getElementById?document.getElementById(this.divId):document.all?document.all[this.divId]:eval(this.divId)
	this.clearHide()	
	var tmpStr='<table id="vmenu_main" border=0 cellpadding=0 cellspacing=0   width="100%">'
	if (this.childs)
		for(i=0;i<this.childs.length;i++) {
			tmpStr+='<tr ><td>'
			if (this.childs[i].childObj) {
				tmpStr+='<table onclick="document.location.reload(\''+this.childs[i].link+'\');" cellspacing=2 cellpadding=0 width="100%" id="vmenu_main" onmouseover="this.bgColor=\'#A0A4AD\'" onmouseout="this.bgColor=\'#E6E9EE\'" style="cursor: hand;"><tr><td width="2">&nbsp;</td><td onmouseover="'+this.childs[i].childObj.objName+'.showChilds(\''+i+'\')" onmouseout="'+this.childs[i].childObj.objName+'.delayHide()"><a href="'+this.childs[i].link+'" class="vmenu_p_link">'+this.childs[i].name+'</a></td></tr></table>'
			} else {
				tmpStr+='<table onclick="document.location.reload(\''+this.childs[i].link+'\');" cellspacing=2 cellpadding=0 width="100%" id="vmenu_main" onmouseover="this.bgColor=\'#A0A4AD\'" onmouseout="this.bgColor=\'#E6E9EE\'" style="cursor: hand;"><tr"><td width="5">&nbsp;</td><td><a href="'+this.childs[i].link+'" class="vmenu_link">'+this.childs[i].name+'</a></td></tr></table>'
			}
			tmpStr+='</td></tr>'
			if(i < this.childs.length-1){
			  tmpStr+='<tr bgcolor="#FFFFFF">'
              tmpStr+='<td colspan=3 width="10" height=1></td>';
              tmpStr+='</tr>'
			}
		}
	tmpStr+='</table>'
	divobj.innerHTML=tmpStr
	if (this.expandDir=='right') {
		this.left=vm_getOffset(obj.offsetParent,'left')+vm_parseInt(obj.offsetLeft)+vm_parseInt(this.offsetLeft)
		this.top=vm_getOffset(obj.offsetParent,'top')+vm_parseInt(obj.offsetTop)+vm_parseInt(this.offsetTop)
	} else if (this.expandDir=='left') {
		this.left=vm_getOffset(obj.offsetParent,'left')+vm_parseInt(obj.offsetLeft)-vm_parseInt(this.offsetLeft)-vm_parseInt(this.width)+vm_parseInt(obj.offsetWidth)
		this.top=vm_getOffset(obj.offsetParent,'top')+vm_parseInt(obj.offsetTop)+vm_parseInt(this.offsetTop)
	}
	
	//this.top = document.body.scrollTop+event.clientY-20;
	divobj.style.left=vm_parseInt(this.left)+"px"
	divobj.style.top=vm_parseInt(this.top)+"px"
	var ouover,ouout,oclick;
	onover=eval("new Function('e','vm_clearHide(e,\""+this.objName+"\")')");
	onout=eval("new Function('e','vm_delayHide(e,\""+this.objName+"\")')");
	oclick=eval("new Function('e','vm_delayHide(e,\""+this.objName+"\")')");
	if (divobj.attachEvent) {
		divobj.attachEvent("onmouseover",onover)
		divobj.attachEvent("onmouseout",onout)
		divobj.attachEvent("onclick",oclick)
	} else if (divobj.addEventListener) {
		divobj.addEventListener("mouseover",onover,false)
		divobj.addEventListener("mouseout",onout,false)
		divobj.addEventListener("click",oclick,false)
	}		
   
	divobj.style.visibility="visible";	
	
}

function vm_showChilds(pos) {
	var divobj=document.getElementById?document.getElementById(this.divId):document.all?document.all[this.divId]:eval(this.divId)	
	this.offsetTop = pos*(this.parent.height-2);

	this.parent.clearHide()
	this.clearHide()
	var tmpStr='<table   border=0 cellpadding=0 cellspacing=0 width=100% class="vmenu_table">'
	var longStr=0;
	if (this.childs)
		for(i=0;i<this.childs.length;i++) {
			tmpStr+='<tr onmouseover="this.bgColor=\'#FFFDF1\'" onmouseout="this.bgColor=\'\'">'
			if (this.childs[i].childObj) {
				tmpStr+='<td  class="vmenu_p_c_td" width=10><img src="/i/bullet_03.gif" border=0 hspace=5 vspace=4></td><td onmouseover="'+this.childs[i].childObj.objName+'.showChilds(\''+i+'\')" onmouseout="'+this.childs[i].childObj.objName+'.delayHide()"><a href="'+this.childs[i].link+'" class="vmenu_p_c_link" >'+this.childs[i].name+'</a></td>'
			} else {
				tmpStr+='<td   class="vmenu_c_td"><img src="/i/bullet_03.gif" border=0 hspace=5 vspace=4></td><td  onmouseover="_showHideSelect(\''+this.divId+'\')" ><a href="'+this.childs[i].link+'" class="vmenu_c_link">'+this.childs[i].name+'</a></td>'
			}
			tmpStr+='</tr>'
			if (this.childs[i].name.length>24) longStr++;
		}
	tmpStr+='</table>'
	divobj.innerHTML=tmpStr 
	
	margin_left = vm_parseInt(this.parent.left)+2*vm_parseInt(this.parent.width)+vm_parseInt(this.offsetLeft)
	if ( (document.body.clientWidth < margin_left)|| (this.parent.expandDir=='left')) this.expandDir='left';
	
	margin_right = vm_parseInt(this.parent.left)-vm_parseInt(this.parent.width)-vm_parseInt(this.offsetLeft)
	if ( (0 > margin_right)&& (this.expandDir=='left')) this.expandDir='right';
	
	//alert('margin_left='+margin_left+' '+document.body.clientWidth);
	if (this.expandDir=='right') {
		this.left=vm_parseInt(this.parent.left)+vm_parseInt(this.parent.width)+vm_parseInt(this.offsetLeft)
		//this.top=vm_parseInt(this.parent.top)+vm_parseInt(this.offsetTop)
		
	} else if (this.expandDir=='left') {
		this.left=vm_parseInt(this.parent.left)-vm_parseInt(this.parent.width)-vm_parseInt(this.offsetLeft)
		//this.top=vm_parseInt(this.parent.top)+vm_parseInt(this.offsetTop)
		
	}
	
	this.top = document.body.scrollTop+event.clientY-20;
	overBottom = document.body.clientHeight-(this.top+(this.childs.length-longStr)*this.parent.height+longStr*2*this.parent.height);
	
	if (overBottom < 0) {this.top=this.top+overBottom;}

	divobj.style.left=vm_parseInt(this.left)+"px"
	divobj.style.top=vm_parseInt(this.top)+"px"
	var ouover,ouout,oclick;
	onover=eval("new Function('e','vm_clearHide(e,\""+this.objName+"\")')");
	onout=eval("new Function('e','vm_delayHide(e,\""+this.objName+"\")')");
	oclick=eval("new Function('e','vm_delayHide(e,\""+this.objName+"\")')");
	if (divobj.attachEvent) {
		divobj.attachEvent("onmouseover",onover)
		divobj.attachEvent("onmouseout",onout)
		divobj.attachEvent("onclick",oclick)
	} else if (divobj.addEventListener) {
		divobj.addEventListener("mouseover",onover,false)
		divobj.addEventListener("mouseout",onout,false)
		divobj.addEventListener("click",oclick,false)
	}
	 
	divobj.style.visibility="visible";
	
	
}
function vm_hide() {
	var divobj=document.getElementById?document.getElementById(this.divId):document.all?document.all[this.divId]:eval(this.divId)
	var divobjp=document.getElementById?document.getElementById(this.parent.divId):document.all?document.all[this.parent.divId]:eval(this.parent.divId)
	divobj.style.visibility="hidden"
	
}

function vm_hide_clear() {
	var divobj=document.getElementById?document.getElementById(this.divId):document.all?document.all[this.divId]:eval(this.divId)    
	var divobjp=document.getElementById?document.getElementById(this.parent.divId):document.all?document.all[this.parent.divId]:eval(this.parent.divId)	
	
	divobj.style.visibility="hidden"

}
function vm_delayHide(e,objName) {
	var obj;
	if (typeof(objName)!="undefined")
		obj=eval(objName)
	else
		obj=this
	
	if (obj.parent)
		obj.parent.delayHide()
	if (!obj.delayObj)
		obj.delayObj=setTimeout(obj.objName+".hide()",obj.delay)
	
	else {
		clearTimeout(obj.delayObj)
		obj.delayObj=setTimeout(obj.objName+".hide()",obj.delay)
	}
	if(e&&(typeof(e)!="undefined")&&e.stopPropagation)
		e.stopPropagation()
		
}
function vm_clearHide(e,objName) {
	var obj;
	if (typeof(objName)!="undefined")
		obj=eval(objName)
	else
		obj=this
	
	if (obj.delayObj) {
		clearTimeout(obj.delayObj)
		obj.delayObj=0
	}
	if (obj.parent) {
		obj.parent.clearHide()
	}
	if(e&&(typeof(e)!="undefined")&&e.stopPropagation)
		e.stopPropagation()
	
}
function vSubMenu(objName) {
	this.objName=objName
	vm_menu[vm_menu.length]=objName
	this.addItem=vm_addItem
	this.showChilds=vm_showChilds
	this.hide=vm_hide
	this.hide_c=vm_hide_clear
	this.delayHide=vm_delayHide
	this.clearHide=vm_clearHide
	this.left=0
	this.top=0
	this.height=15
	this.width=160
	this.offsetLeft=0
	this.offsetTop=0
	this.overBgColor2='#ffffff';
	this.outBgColor2='#ffffff';
	this.divId='childs_div'+objName
	this.delay=100
	this.delayObj=0
	this.childs=new Array()
	this.parent=0
	this.expandDir='right'
	eval(objName+"=this;")
	var st_str=""
	if (this.width)
		st_str+="width:"+vm_parseInt(this.width)+"px;"
	if (this.heigth)
		st_str+="height:"+vm_parseInt(this.height)+"px;"
	document.write('<div id="'+this.divId+'" name="'+this.divId+'" class="vmenu_div" style="'+st_str+'"></div>')
}

function vMenuItem(objName,name,link,hasChilds) {
	this.name=name
	this.link=link
	this.objName=objName
	this.childObj=0
	this.parent=0
	this.childs=0
	if (hasChilds) {
		this.childObj=new vSubMenu(objName)
	}
}
function vm_parseInt(num) {
	var t=parseInt(num);
	if (t&&!isNaN(t)) {
		return t;
	}
	return 0;
}
function vm_hideAll() {
	for(i=0;i<vm_menu.length;i++) {
		var tmp=eval(vm_menu[i])
		tmp.hide_c();
	}
	
	
}
function vm_getOffset(parent,which) {
	var ret_val=0;
	while(parent) {
		ret_val+=(which=='left'?vm_parseInt(parent.offsetLeft):vm_parseInt(parent.offsetTop));
		parent=parent.offsetParent
		
	}
	return ret_val;
}



function _showHideSelect(divId) {
 var divobj=document.getElementById?document.getElementById(divId):document.all?document.all[divId]:eval(divId)

}
