function launchwin(sUrl,wide,high)
{
	window.open(sUrl,"tps_new_win","width="+wide+",height="+high+",top=50,left=50,resizable=yes,scrollbars=no,status=no,menubar=no,toolbar=no,location=no");
}
function buttonOver(elem)
{
    
}

function show(elem)
{
    var c_name = elem.id;
    var posArray = findPos(elem);
    var obj_name = c_name +'_container';
    var d = document.getElementById(obj_name);
    if(d)
    {
	
		hide_ok = false;
		d.style.left=  getPerfectFit(posArray[0], d.scrollWidth);
		d.style.top = posArray[1] + elem.scrollHeight;
		d.style.display='block';
		if((show_elem) && (show_elem != elem))
		    hide(show_elem);
		show_elem = elem;
    }
}
function hide(elem)
{
    var c_name = elem.id;
    var d = document.getElementById(c_name +'_container');
    if(d)
        d.style.display='NONE';
    else
	alert('not fount'+this.id+ ', ' +c_name);
}
function hideSub(elem)
{
	var d = document.getElementById(elem);
    if(d)
	{
        d.style.display='NONE';
	}
}
function hideparent(elem)
{
	var p = elem.parent;
	alert(p.id);
	if(p && p.id != show_elem)
	{
        	p.style.display='NONE';
		alert(p.id);
	}
	else
	{alert("p not found");
	}
}
function findPos(elem)
{
	var curleft = curtop = 0;
	if (elem.offsetParent) {
		curleft = elem.offsetLeft
		curtop = elem.offsetTop
		while (elem = elem.offsetParent) {
			curleft += elem.offsetLeft
			curtop += elem.offsetTop
		}
	}
	return [curleft,curtop];
}
function setOpacity(elem_id, value)
{
	var d = document.getElementById(elem_id);
	d.style.opacity = value/10;
	d.style.filter = 'alpha(opacity=' + value*10 + ')';
}
function locatefooter()
{
	var x, y
	var bottom = document.getElementById("bottom");
	if (bottom)
	{
		x = bottom.offsetleft;
		y = bottom.offsetTop;
	}
	//alert('x= ' + x + '\n y = ' + y);
}
function dynamicHide(elem)
{
		hide_ok = true;
		hide_sub = true;
		setTimeout('if(hide_sub) {hideSub(show_sub);}',1000);
		setTimeout('if(hide_ok) {hide(show_elem);}',1000);

}
function fadeout(elem)
{
	for (var i=10;i>0;i--)
	{
		setTimeout('setOpacity(\''+elem+'\','+i+')',50*i);
	}
}
function dynamicShow(elem)
{
	
	hide_ok = false;
    var posArray = findPos(elem);
	var sub_name = elem.id + "_subcontainer";
	var sub = document.getElementById(sub_name);
	if(sub)
	{
		if (show_sub != "" &&show_sub != sub_name)
			hideSub(show_sub);
		hide_sub = false;
		show_sub = sub_name;
		
		sub.style.left = getSubmenuPos(posArray[0], elem.scrollWidth);
		sub.style.top = posArray[1];
		sub.style.display='block';
	}
	else
	{
		var p = elem.offsetParent;
		while (p)
		{
			if(p.id == show_sub)
			{
					hide_sub = false;
					return;
			}
			p = p.offsetParent;
		}
	}
}
function getSubmenuPos(currPos, elemWidth)
{
	var maxWidth= document.body.clientWidth;
	if(maxWidth < (currPos + elemWidth*2))
		return currPos - elemWidth;
	else
		return currPos + elemWidth;
}
function getPerfectFit(currPos, elemWidth)
{
	var maxWidth= document.body.clientWidth;
	//alert(maxWidth +', ' +  (currPos + elemWidth) + ', ' + elemWidth);
	if(maxWidth < (currPos + elemWidth))
		return maxWidth - elemWidth - 2;
	else
		return currPos;
	
}