


	// 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);
	
	
	function myAttachEvent(a,b,c){if(r){a.attachEvent("on"+b,c)}else{a.addEventListener(b,c,false)}}
	

/*   valueT += element.scrollTop  || 0;
      valueL += element.scrollLeft || 0;
*/
function getXCoord(el) {
	x = 0;
	var element=el;
	
	
	while(el){
		x += el.offsetLeft;
		x += el.scrollLeft;
		el = el.offsetParent;
	}
	

	/* for scroll element */
    var valueT = 0, valueL = 0;
    do {
      valueT += element.scrollTop  || 0;
      valueL += element.scrollLeft || 0;
      element = element.parentNode;
    } while (element)

	x=x-valueL;
	
		
	return x;
}

function getYCoord(el) {
	y = 0;
	var element=el;
	
	while(el){
		
		y += el.offsetTop;
		y += el.scrollTop;
		el = el.offsetParent;

	}

	/* for scroll element */
    var valueT = 0, valueL = 0;
    do {
            
      if(element.scrollTop && element.tagName.toLowerCase()!="html"){
		if(isIE){
			valueT += (element.scrollTop*2)  || 0;
		}else{
			valueT += (element.scrollTop)  || 0;
		}
		
      }
	//temp=document.title+=element.tagName+" "+element.scrollTop+"\n";
      element = element.parentNode;
    } while (element)
  //  alert(temp);
    
 
   
   //document.title=document.body.scrollTop+"  x "+y+"   "+valueT;
	y=y-valueT;
	
	return y;
}

/*
function $(id) {
	return document.getElementById(id);
}

*/


var jsmenu={

	menu_container_id:'menu_container',
	delay:0,
	
	
	
	
	container_obj:null,
	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)){
			this.container_obj=$(this.menu_container_id);
		}else{
			this.container_obj = document.createElement('div');
			this.container_obj.id = this.menu_container_id;
			document.body.appendChild(this.container_obj);
			this.container=this.container_obj;	
		}
		*/
		

	
		if( this.container_obj){
		 this.container_obj.style.display = 'none'; 
		 
		 
		 	/* this.container_obj event */
			myAttachEvent(this.container_obj,"mouseover",jsmenu.container_over);
			myAttachEvent(this.container_obj,"mouseout",jsmenu.out);
			myAttachEvent(this.container_obj,"click",jsmenu.out);
			/* ============= */
		}
		/* content */
		
		content_obj=$(obj.id+'_content');
		/*this.container_obj.innerHTML=content_obj.innerHTML;*/
		this.container_obj=$(obj.id+'_content');
		this.container_obj.style.display = '';
		this.container_obj.style.position = 'absolute';
		this.container_obj.style.zIndex = "1";
		this.container_obj.style.left = 0 +'px';
		this.container_obj.style.top = 0 +'px';
		

		/*document.title=getXCoord(obj)+ " " +this.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'){
			this.container_obj.style.left = getXCoord(obj)+obj.offsetWidth+'px';
			this.container_obj.style.top  = getYCoord(obj)+'px';	
		//	document.title=getYCoord(obj)+'.';
		}else if(this.direction=='left'){

			this.container_obj.style.left = getXCoord(obj)-this.container_obj.offsetWidth+'px';
			this.container_obj.style.top  = getYCoord(obj)+'px';	
			
			
		}else if(this.direction=='up'){
		

			this.container_obj.style.left = getXCoord(obj)+'px';
			this.container_obj.style.top  = getYCoord(obj)-this.container_obj.offsetHeight+'px';	
		}else{
		

			this.container_obj.style.left = getXCoord(obj)+'px';
			this.container_obj.style.top  = getYCoord(obj)+obj.offsetHeight+'px';	
		}
		
		/* ============= */

		
	
		
	},
	
	
	
	hide:function(){
/*		document.title="hide..";*/
		clearTimeout(this.delaytimer);
		this.delaytimer=setTimeout(function(){
		jsmenu.container_obj.style.display = 'none';

			/*$(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();
*/
