// JavaScript Document
////////////////////////////////////////////////////
////////////////////////////////////////////////////
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.delayHide=vm_delayHide
	this.clearHide=vm_clearHide
	this.left=100
	this.top=0
	this.height=10
	this.width=210
	//check browser
	this.offsetTop=20	
	this.offsetLeft=-2
	this.overBgColor='#000000';
	this.outBgColor='#7EA5C3';
	this.divId='parent_div'+objName
	this.delay=50
	this.delayObj=0
	this.parent=0
	this.childs=new Array()
	this.harr = new Array()
	this.harr[1] = 22;
	this.harr[2] = 28;
	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+'; z-index:1000;" onMouseOver="onOver(\''+objName+'\')"></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 calc_height(str,width){
	var h = Math.floor((str.length*7)/width)+1;
	return h;
}

function vm_show(obj) {
	vm_hideAll();
	this.clearHide()
	var divobj=document.getElementById?document.getElementById(this.divId):document.all?document.all[this.divId]:eval(this.divId)
	var tmpStr='<table id="vmenu_main_'+divobj.name+'" border=0 cellpadding=0 cellspacing=0 width="100%" bgcolor="#3E67AE" >';
	if (this.childs.length > 0){
		for(i=0;i<this.childs.length;i++) {			
			tmpStr+='<tr id="tr_main2_'+this.childs[i].objName+'" height=3><td colspan="2" height="3" ></td></tr>'
			hh = calc_height(this.childs[i].name,this.width);
			tmpStr+='<tr id="tr_main_'+this.childs[i].objName+'" wordsize="'+hh+'">'
			if (this.childs[i].childObj) {
				tmpStr+='<td align="left" width="7"  height="11">&nbsp;</td><td  class="mainMenu" onmouseover="'+this.childs[i].childObj.objName+'.showChilds(\''+i+'\');dd=document.getElementById(\'tr_main_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#6A8ECA\';dd=document.getElementById(\'tr_main2_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#6A8ECA\';dd=document.getElementById(\'tr_main3_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#6A8ECA\'" onmouseout="'+this.childs[i].childObj.objName+'.delayHide();dd=document.getElementById(\'tr_main_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#3E67AE\';dd=document.getElementById(\'tr_main2_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#3E67AE\';dd=document.getElementById(\'tr_main3_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#3E67AE\'"><a href="'+this.childs[i].link_url+'" class="mainMenu">'+this.childs[i].name+'</a></td>'
			} else {
				tmpStr+='<td align="left" width="7" height="11">&nbsp;</td><td  class="mainMenu" onmouseover="_showHideSelect(\''+this.divId+'\');dd=document.getElementById(\'tr_main_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#6A8ECA\';dd=document.getElementById(\'tr_main2_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#6A8ECA\';dd=document.getElementById(\'tr_main3_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#6A8ECA\'" onmouseout="dd=document.getElementById(\'tr_main_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#3E67AE\';dd=document.getElementById(\'tr_main2_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#3E67AE\';dd=document.getElementById(\'tr_main3_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#3E67AE\'"><a href="'+this.childs[i].link_url+'"  class="mainMenu">'+this.childs[i].name+'</a></td>'
			}
			tmpStr+='</tr>'
			tmpStr+='<tr><td colspan=2 height=3 id="tr_main3_'+this.childs[i].objName+'"></td></tr>'			
			if (i!=this.childs.length-1) tmpStr+='<tr><td bgcolor="#FFFFFF" colspan=2><img src="/img/spacer.gif"  height="1"></td></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)
	}

	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";
	}
	Vmenu_showHideSelect(divobj);

}
function vm_showChilds(pos) {
	var divobj=document.getElementById?document.getElementById(this.divId):document.all?document.all[this.divId]:eval(this.divId)
	_showHideSelect(this.divId);	
	
	//this.offsetTop = pos*(this.parent.height-5);
	sum=0;
	
	for (i=0;i<pos;i++){
		//alert(document.getElementById('tr_main_421'));
		sum = sum+vm_parseInt(this.harr[document.getElementById('tr_main_'+this.parent.childs[i].objName).wordsize]);
		sum = sum+vm_parseInt(document.getElementById('tr_main2_'+this.parent.childs[i].objName).height);
	}
	
	this.parent.clearHide()
	this.clearHide()

	var tmpStr='<table border=0 cellpadding=0 cellspacing=0 width=100% class="vmenu_table" >'
	if (this.childs)
		for(i=0;i<this.childs.length;i++) {
			tmpStr+='<tr id="tr_smain2_'+this.childs[i].objName+'"><td colspan=2 height=3></td></tr>'
			tmpStr+='<tr id="tr_smain_'+this.childs[i].objName+'">'
			if (this.childs[i].childObj) {
				tmpStr+='<td align="left" width="7" height="11">&nbsp;</td><td  onmouseover="'+this.childs[i].childObj.objName+'.showChilds(\''+i+'\');dd=document.getElementById(\'tr_smain_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#6A8ECA\';dd=document.getElementById(\'tr_smain2_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#6A8ECA\';dd=document.getElementById(\'tr_smain3_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#3E67AE\'" onmouseout="'+this.childs[i].childObj.objName+'.delayHide();dd=document.getElementById(\'tr_smain_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#7EA5C3\';dd=document.getElementById(\'tr_smain2_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#7EA5C3\';dd=document.getElementById(\'tr_smain3_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#7CA1E7\'"><a href="'+this.childs[i].link_url+'" class="mainMenu" >'+this.childs[i].name+'</a></td>'
			} else {
				tmpStr+='<td align="left" width="7" height="11">&nbsp;</td><td  onmouseover="_showHideSelect(\''+this.divId+'\');dd=document.getElementById(\'tr_smain_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#6A8ECA\';dd=document.getElementById(\'tr_smain2_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#6A8ECA\';dd=document.getElementById(\'tr_smain3_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#6A8ECA\'" onmouseout="dd=document.getElementById(\'tr_smain_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#3E67AE\';dd=document.getElementById(\'tr_smain2_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#3E67AE\';dd=document.getElementById(\'tr_smain3_'+this.childs[i].objName+'\');dd.style.backgroundColor=\'#3E67AE\'"><a href="'+this.childs[i].link_url+'" class="mainMenu">'+this.childs[i].name+'</a></td>'
			}
			tmpStr+='</tr>'
			tmpStr+='<tr><td colspan=2 height=3 id="tr_smain3_'+this.childs[i].objName+'"></td></tr>'
			if (i!=this.childs.length-1) tmpStr+='<tr><td bgcolor="#FFFFFF" colspan=2><img src="/img/spacer.gif"  height="1"></td></tr>'			
		}
	tmpStr+='</table>'
	// child menu level <2 width set here
	divobj.style.width=250;
	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)
		//this.top=vm_getOffset(obj.offsetParent,'top')+vm_parseInt(obj.offsetTop)+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)
		
	}
	//alert(event.clientY);
	//
	var addoffsetLeft = 20
	if(navigator.appName == 'Netscape'){
		addoffsetLeft=-21*pos
	}else{
		addoffsetLeft=+4*pos
	}
	//+sum
	//this.top = document.body.scrollTop+this.parent.top-addoffsetLeft;
	//this.top = document.body.scrollTop+this.parent.top+100
	this.top = sum+this.parent.top-addoffsetLeft;
	overBottom = document.body.clientHeight-(this.top+this.childs.length*this.parent.height);
	if (overBottom < 0) this.top=this.top+overBottom;

	if(divobj.style.top==0) divobj.style.top=vm_parseInt(this.top)+"px"
	divobj.style.left=vm_parseInt(this.left)+"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";
	Vmenu_showHideSelect(divobj);
	
}
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"
	if (this.childs) onOut(this.objName);
	Vmenu_showHideSelect(divobj, 'hide');

	if (divobjp) Vmenu_showHideSelect(divobjp);

}

function vm_delayHide(e,objName) {
	var obj;
	if (typeof(objName)!="undefined")
		obj=eval(objName)
	else
		obj=this
	_showHideSelect(obj.divId); 

	
	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.delayHide=vm_delayHide
	this.clearHide=vm_clearHide
	this.left=0
	this.top=-1
	this.height=15
	this.width=160
	this.offsetLeft=0
	this.offsetTop=1000
	this.overBgColor2='#FFFFFF';
	this.outBgColor2='#FFFFFF';
	this.divId='childs_div'+objName
	this.delay=200
	this.delayObj=0
	this.childs=new Array()
	this.harr = new Array()
	this.harr[1] = 22;
	this.harr[2] = 28;	
	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+';z-index:1000;"></div>')
}

function vMenuItem(objName,name,link_url,hasChilds) {
	this.name=name
	this.link_url = link_url
	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();
	}
}
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)
 Vmenu_showHideSelect(divobj)	

}
function Vmenu_showHideSelect(element, action) {
		function getStyleProp(obj, style){
			var value = obj.style[style];
			if (!value) {
				if (document.defaultView && typeof (document.defaultView.getComputedStyle) == "function") { // Gecko, W3C
					value = document.defaultView.
						getComputedStyle(obj, "").getPropertyValue(style);
				} else if (obj.currentStyle) { // IE
					value = obj.currentStyle[style];
				} else {
					value = obj.style[style];
				}
			}
			return value;
		};

		var tags = new Array("applet", "select");
		var el = element;
	
		var p = vmenu_getAbsolutePos(el);
		var EX1 = p.x;
		var EX2 = el.offsetWidth + EX1;
		var EY1 = p.y;
		var EY2 = el.offsetHeight + EY1;
		
		for (var k = tags.length; k > 0; ) {
			var ar = document.getElementsByTagName(tags[--k]);
			var cc = null;
	
			for (var i = ar.length; i > 0;) {
				cc = ar[--i];
				if (cc.name == 'months' || cc.name == 'years') continue;
				
				p = vmenu_getAbsolutePos(cc);
				var CX1 = p.x;
				var CX2 = cc.offsetWidth + CX1;
				var CY1 = p.y;
				var CY2 = cc.offsetHeight + CY1;
				//alert(CX1+'>'+EX2+' '+CX2+'<'+EX1+' '+CY1+'>'+EY2+' '+CY2+'<'+EY1);
	      
				if (action == 'hide' || (CX1 > EX2) || (CX2 < EX1) || (CY1 > EY2) || (CY2 < EY1)) {
					
					if (!cc.__msh_save_visibility) {
						cc.__msh_save_visibility = getStyleProp(cc, "visibility");
					}
					cc.style.visibility = cc.__msh_save_visibility;
					//alert(cc.style.visibility);
				} else {

					if (!cc.__msh_save_visibility) {
						cc.__msh_save_visibility = getStyleProp(cc, "visibility");
					}
					cc.style.visibility = "hidden";
				}
			}
		}

	}
	
	function vmenu_getAbsolutePos(el) {
		var r = { x: el.offsetLeft, y: el.offsetTop };
		if (el.offsetParent) {
			var tmp = vmenu_getAbsolutePos(el.offsetParent);
			r.x += tmp.x;
			r.y += tmp.y;
		}
		return r;
	}