getElement = function(id) {
return document.getElementById ? document.getElementById(id) : 
document.all ? document.all(id) : null;
}


var menuObject = false;
var menuTimer = false;

function menuIni(nameobj, type){
	menuObject = document.getElementById(nameobj);
	if(!menuObject) return false;
	var points = menuObject.getElementsByTagName('TD');
	for(var i = 0; i < points.length; i++){
		var cPoint = points[i];
		
		var mId = cPoint.getAttribute('menu');
		if(mId) cPoint.menuObj = document.getElementById('menu_' + mId);
		if(cPoint.menuObj){
			cPoint.menuObj.parent = cPoint;
			//cPoint.menuObj.className = 'popupMenu';

			cPoint.menuObj.ini = function(){
				cPoints = this.getElementsByTagName('table')
				//alert(cPoints.length);
				for(var i = 0; i < cPoints.length; i++){
					
					var cPointi = cPoints[i];
					
					//alert(cPoint.innerHTML);
					
					
					cPointi.onmouseover = function(){
						//
						if (this.className=='one')
						
						this.className = 'oneOn';
						clearTimeout(menuTimer);
						menuTimer = false;
					}
					cPointi.onmouseout = function(){
						if (this.className=='oneOn')
						this.className = 'one';
												
					}
				}
			}

			cPoint.menuObj.ini()

			cPoint.menuObj.show = function(){
				if (type=='horiz'){
				this.style.left = getOffsetLeft(this.parent);
				//this.style.left = -222;
				//alert(this.style.left);
				this.style.top = getOffsetTop(this.parent) + this.parent.offsetHeight;
				//this.style.top = this.parent.offsetHeight;
				
				//this.style.width = this.parent.offsetWidth;
				this.style.display = '';
				}
				else{
				this.style.left = getOffsetLeft(this.parent) + this.parent.offsetWidth;	
				this.style.top = 421; 
				this.style.display = '';
					
				}
				
			}

			cPoint.menuObj.hide = function(){
				this.style.display = 'none';
			}

			cPoint.menuObj.onmouseover = function(){
				clearTimeout(menuTimer);
				menuTimer = false;
			}

			cPoint.menuObj.onmouseout = function(){
				menuTimer = setTimeout('menuOff()', 2000)
			}
		}


		cPoint.on = function(){
			clearTimeout(menuTimer);
			menuTimer = false;
			//this.style.backgroundColor = '#CCCCCC';
			//this.style.backgroundImage = 'url(/images/menu-bg.gif)';
			if(this.menuObj) this.menuObj.show();

		}
		cPoint.off = function(){
			//this.style.backgroundImage = 'none';
			//this.style.backgroundColor = '';
			if(this.menuObj) this.menuObj.hide();
		}
		/*cPoint.onmouseout = function(){
			//menuTimer = setTimeout('menuOff()',1000)
		}*/
	}
}


function mShow(obj, nameobj, type){
//	alert(obj.getAttribute('menu'));
	//if(!menuObject) menuIni(nameobj, type);
	menuIni(nameobj, type, obj);
	if(!menuObject) return false;
	obj.className = 'on';
	
	var mId = obj.getAttribute('menu');
	if(menuObject.cObj && menuObject.cObj != obj){
		menuObject.cObj.off();
		menuObject.cObj.className = '';
		
	}
	
	obj.onmouseout = function(){
				obj.className = '';
			}

	menuObject.cObj = obj;
	obj.on();
}



function menuOff(){
	
	
	if(menuObject.cObj){
		menuObject.cObj.off();
	}
	menuObject.cObj = false
}


function getOffsetLeft(obj){
	var result = obj.offsetLeft;
	while((obj = obj.offsetParent) != null){
			result += obj.offsetLeft;
	}
	return result;
}

function getOffsetTop(obj){
	var result = obj.offsetTop;
	while((obj = obj.offsetParent) != null){
			result += obj.offsetTop;
	}
	return result;
}

openCombo = function(id)
{

//getElement(id).style.display = 'block';
getElement(id).selectedIndex=1;
//getElement(id).focus();
//getElement(id).click();
}

getElName = function(name) {
return document.GetElementByName ? document.GetElementByName(name) : 
document.all ? document.all(name) : null;
}

setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {

	document.cookie =

		escape(cookieName) + '=' + escape(cookieValue)

		+ (expires ? '; expires=' + expires.toGMTString() : '')

		+ (path ? '; path=' + path : '')

		+ (domain ? '; domain=' + domain : '')

		+ (secure ? '; secure' : '');
		
//alert(document.cookie);
}

getCookie = function(cookieName) {

	var cookieValue = '';

	var posName = document.cookie.indexOf(escape(cookieName) + '=');

	if (posName != -1) {

		var posValue = posName + (escape(cookieName) + '=').length;

		var endPos = document.cookie.indexOf(';', posValue);

		if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));

		else cookieValue = unescape(document.cookie.substring(posValue));

	}

	return (cookieValue);

};

open_submenu = function(_item, id) {
var is_cookie = true;
var sub_menu = getElement('menu_'+id);

if (sub_menu)
	{
		//alert(sub_menu.style.display);
		(sub_menu.style.display=='none' || !sub_menu.style.display)?sub_menu.style.display = 'block' : sub_menu.style.display='none';
		(_item.className=='menu_dot_2')?_item.className = 'menu_dot_1':_item.className = 'menu_dot_2';
		//if (is_cookie)
		
	}
}

div_show = function(divid){
	
if (document.getElementById(divid)) document.getElementById(divid).style.display='block';

	
}

div_hide = function(divid){
	
if (document.getElementById(divid)) document.getElementById(divid).style.display='none';

	
}
