var agent = navigator.userAgent.toLowerCase();

function agentContains(text)
{
  return agent.indexOf(text) >= 0;
}

function isNetscapeCompatible()
{
  return !(agentContains('konqueror') ||
           agentContains('safari') ||
           agentContains('omniweb') ||
           agentContains('opera') ||
           agentContains('webtv') ||
           agentContains('icab') ||
           agentContains('msie'));
}

function getElement(theId)
{
  if(isNetscapeCompatible())
  {
    return document.getElementById(theId);
  }
  else
  {
    for(i = 0; i < document.all.length; ++i)
    {
      if(document.all(i).id == theId)
      	return document.all(i);
    }
  }
  
  return null;
}

function setCookie(name, value, days, path)
{
    if(!days) days = -1;
    if(!path) path = '/';

    var expire = new Date();
    expire.setTime(expire.getTime() + 86400000 * days);

    document.cookie = name + "=" + escape(value)
    +  "; expires=" + expire.toGMTString() + ";"
    + path;
}

function sendMail(first, second)
{
	location.href = "mailto:" + first + "@" + second;
}

function sendMailSubject(first, second, subject)
{
	location.href = "mailto:" + first + "@" + second + "?subject=" + subject;
}

function togglePane(id, path) {
	var div  = document.getElementById("pane_" + id);
	if (!div) return;
	var hide = (div.style.display == 'block' || div.style.display == '');
	if (hide) {
		hidePane(id, path);
	}
	else {
		showPane(id, path);
	}
}

function showPane(id, path) {
	var div = document.getElementById("pane_" + id);
	var img = document.getElementById("icon_" + id);
	if (div) div.style.display = 'block';
	if (img) img.src           = path + '/img/collapse.gif';
}

function hidePane(id, path) {
	var div = document.getElementById("pane_" + id);
	var img = document.getElementById("icon_" + id);
	if (div) div.style.display = 'none';
	if (img) img.src           = path + '/img/expand.gif';
}

function setPane(id, path, on)
{
	if(on)
	{
		showPane(id, path);
  }
	else
	{
		hidePane(id, path);
	}
}

function overTpHead(el) {
	el.style.backgroundColor = "#CDCFD5";  // #C4D1D7";
	el.style.color = "";
}

function outTpHead(el) {	
	el.style.backgroundColor = "";
	el.style.color = "";
}

function overTc(el) {
	el.style.backgroundColor = "#E6E6E6";
	el.style.color = "";
}

function outTc(el) {	
	el.style.backgroundColor = "";
	el.style.color = "";
}

