


	// gmail code
	var isIE=(window.attachEvent && !window.opera);
	var Ka=navigator.userAgent.toLowerCase();
	var rt=Ka.indexOf("opera")!=-1;
	var r=Ka.indexOf("msie")!=-1&&(document.all&&!rt);
	var jsmenu = null;
	
	function myAttachEvent(a,b,c){if(r){a.attachEvent("on"+b,c)}else{a.addEventListener(b,c,false)}}


function getXCoord(el) {
	x = 0;
	while(el){
		x += el.offsetLeft;
		el = el.offsetParent;
	}
	return x;
}

function getYCoord(el) {
	y = 0;
	while(el){
		y += el.offsetTop;
		el = el.offsetParent;
	}
	return y;
}


function initJsMenu() {
	
	
	jsmenu={
	
		menu_container_id:'menu_container',
		delay:500,
		
		
		
		
		delaytimer:null,
		
		over:function(obj,direction){
			this.obj=obj;
			/* direction */
			this.direction=direction;
			
			this.clearhidemenu();
	
			
			
			/* obj event */
			/*myAttachEvent(obj,"mousemove",jsmenu.clearhidemenu);*/
			myAttachEvent(obj,"mouseout",jsmenu.out);
			/* ============= */
					
			/* show menu */
			jsmenu.show(obj);
			
			obj.blur();
			return false;
			
	
		},
		
		out:function(){
			jsmenu.hide();
		},
		
		container_over:function(){
			jsmenu.clearhidemenu();
		},
		
		
		
		
		show:function(obj){
		
			
			if($(this.menu_container_id)){
				container_obj=$(this.menu_container_id);
			}else{
				var container_obj = document.createElement('div');
				container_obj.id = this.menu_container_id;
				document.body.appendChild(container_obj);
				this.container=container_obj;	
			}
			
			
			
			/* container_obj event */
			myAttachEvent(container_obj,"mouseover",jsmenu.container_over);
			myAttachEvent(container_obj,"mouseout",jsmenu.out);
			myAttachEvent(container_obj,"click",jsmenu.out);
			/* ============= */
			
			
			
			
			
			/* content */
			content_obj=$(obj.id+'_content');
			container_obj.innerHTML=content_obj.innerHTML;
			container_obj.style.display = '';
			container_obj.style.position = 'absolute';
			container_obj.style.zIndex = "1";
			container_obj.style.left = 0 +'px';
			container_obj.style.top = 0 +'px';
			
	
			/*document.title=getXCoord(obj)+ " " +container_obj.offsetWidth;*/
	
			/* fix firefox "a img" problem */
			if(obj.tagName.toLowerCase()=='a' && obj.getElementsByTagName("img")[0]){
				obj=obj.getElementsByTagName("img")[0];
			}
	
	
	
	
			if(this.direction=='right'){
				container_obj.style.left = getXCoord(obj)+obj.offsetWidth+'px';
				container_obj.style.top  = getYCoord(obj)+'px';	
			}else if(this.direction=='left'){
	
				container_obj.style.left = getXCoord(obj)-container_obj.offsetWidth+'px';
				container_obj.style.top  = getYCoord(obj)+'px';	
				
				
			}else if(this.direction=='up'){
			
	
				container_obj.style.left = getXCoord(obj)+'px';
				container_obj.style.top  = getYCoord(obj)-container_obj.offsetHeight+'px';	
			}else{
			
	
				container_obj.style.left = getXCoord(obj)+'px';
				container_obj.style.top  = getYCoord(obj)+obj.offsetHeight+'px';	
			}
			
			/* ============= */
	
			
		
			/*document.title=document.title+'.';*/
		},
		
		
		
		hide:function(){
	/*		document.title="hide..";*/
			clearTimeout(this.delaytimer);
			this.delaytimer=setTimeout(function(){
			/*alert("timer");*/
				$(jsmenu.menu_container_id).style.display = 'none';
				
			},this.delay);
			
			/*alert("a"+this.delaytimer);*/
	
			//hide menu	;
		},
		
		
		clearhidemenu:function(){
	
		/*clearTimeout(this.delaytimer);
			*/if (this.delaytimer!=null){
				/*document.title="clear";*/
				/*alert("clear "+this.delaytimer);*/
				clearTimeout(this.delaytimer);
			}
		}	
		
	}
}
/*
jsmenu.jsmenu();
*/
