﻿var timeout = 10;

ie5  = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById && !window.opera);
opera = (window.opera ||(window.opera && window.getSelection));

opac = 0;
current_menu = "";

function show_hide(div_id){
	if ((current_menu != "") && (div_id != current_menu))
	{
		document.getElementById(current_menu).style.display = "none";
	}
	opac = 0;

	show_hide_aux(div_id);
}

function show_hide_aux(div_id){		
	if (current_menu != div_id)
	{
		id = document.getElementById(div_id);
		opac = 0;
		if (!opera){fade_in(div_id);}
		if (opera && window.getSelection){id.style.opacity = 1;}
		id.style.display = "block";
	}
	current_menu = div_id;
}

function fade_in(div_id) {
	if(opac < 100){
		opac += 5;
		if(ie5) {document.getElementById(div_id).filters.alpha.opacity = opac;}
		if(ns6) {document.getElementById(div_id).style.MozOpacity = opac/100;}
		setTimeout('fade_in("' + div_id + '")', timeout);
	}
}

function show_current(div_id)
{	
		id = document.getElementById(div_id);
		if (id)
		{	
			opac = 100;
			if (!opera){
				if(ie5) {id.filters.alpha.opacity = opac;}
				if(ns6) {id.style.MozOpacity = opac/100;}
			}
			if (opera && window.getSelection){id.style.opacity = 1;}
			id.style.display = "block";
			current_menu = div_id;
		}
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

var scroll_timer = null;

function scroll_stop()
{
	clearTimeout(scroll_timer);
}
function scroll_start(el, delta) {
  e = document.getElementById(el)
  e.scrollTop += delta;
  scroll_timer = setTimeout("scroll_start('" + el + "'," + delta + ")", 40);
}
function scroll_top(el)
{
	e = document.getElementById(el).scrollTop = 0;
}
function check_height(div_flow, height, div_controls)
{
	var e1 = document.getElementById(div_flow);
	var e2 = document.getElementById(div_controls);
	if (e1 && e2)
	if (e1.offsetHeight > height)
	{
		e1.style.height = height + "px";
		e2.style.display = 'block';
	}
}
function set_flow(e)
{
	var flow = document.getElementById(e);
	if (flow)
	{
		flow.style.overflow = 'hidden';
		flow.style.height = 'auto';
	}
}