function launchwin(sUrl,wide,high)
{
    launchwin(sUrl, wide, high, 'no');
}
function launchwin(sUrl, wide, high, scorllbar)
{
    window.open(sUrl, "tps_new_win", "width=" + wide + ",height=" + high + ",top=50,left=50,resizable=yes,scrollbars=" + scorllbar + ",status=no,menubar=no,toolbar=no,location=no");
}
var show_elem, show_sub;
var hide_ok = true, hide_sub = true;
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) + 'px';
		d.style.top = (posArray[1] + elem.scrollHeight) + 'px';
		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;
		elem.style['color'] = '#CCCCCC';
		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;

}

function dynamicRollover( elem ) {

      //var elem = document.getElementById( id );

     

      if( navigator.userAgent.indexOf('Mac') == -1 ) {

            elem.src = elem.src.replace('_off.jpg','_on.jpg');

      } else {

            try {

                  var target = tcSlider.locate( elem );

                  elem.src = elem.src.replace('_off.jpg', '_on.jpg');

                  genericRollover.style[ 'left' ] = target.x + 'px';

                  genericRollover.style[ 'top' ] = target.y + 'px';

                  genericRollover.style[ 'visibility' ] = 'visible';

            } catch (ex) { };

      };

};

 

function dynamicRestore( elem ) {

      //var elem = document.getElementById( id );

      if( navigator.userAgent.indexOf('Mac') == -1 ) {

          elem.src = elem.src.replace('_on.jpg', '_off.jpg');

      } else {

            try {

                elem.src = elem.src.replace('_on.jpg', '_off.jpg');

                  genericRollover.style[ 'visibility' ] = 'hidden';

            } catch (ex) { };

      };

};
