function slidediv(divElemId, chkboxToToggle, addword) {	
	var divElem = document.getElementById(divElemId);
	var chkElem = document.getElementById(chkboxToToggle);
	var extElem = document.getElementById(addword);  
  if (chkElem.checked) {
  	Element.removeClassName(divElemId+'-panel');
  	Effect.BlindDown(divElemId,  {duration: 1});
  } else {
    Element.addClassName(divElem, divElemId+'-panel');
  	Effect.Squish(divElemId, {duration: 1});
  }
  
	if (extElem != null) {
		if (chkElem.checked && extElem.style.display == 'none') {
			extElem.style.display = 'inline';
		} else {
			extElem.style.display = 'none';
		}		
	}	  
}
function sb_accordion(el) {
	if (Element.hasClassName(el.parentNode.id+'-body','visible')){
		var elopened = el.parentNode.id+'-body';
		var elopenedtitle = el.parentNode.id+'-title';
		new Effect.SlideUp(elopened);
		Element.removeClassName(elopened, 'visible');
		Element.removeClassName(elopenedtitle, 'selectedPanel');
		return;
	}
  	var eldown = el.parentNode.id+'-body';
	var eldowntitle = el.parentNode.id+'-title';
	var apanels = document.getElementsByClassName('panelBody',el.parentNode.parentNode);
  	for (var i=0;i<apanels.length;i++){
		if (Element.hasClassName(apanels[i].parentNode.id+'-body','visible')
			&& el.parentNode.parentNode.id == apanels[i].parentNode.parentNode.id ){
			var elup = apanels[i].parentNode.id+'-body';
			var eluptitle = apanels[i].parentNode.id+'-title';
		}
		// if there is no element opened
	}	
	if (!elup) {
		new Effect.SlideDown(eldown);
		Element.addClassName(eldown, 'visible');
		Element.addClassName(eldowntitle, 'selectedPanel');
		return;
	}
	new Effect.Parallel([ new Effect.SlideUp(elup), new Effect.SlideDown(eldown) ], {duration: 0.75});
	Element.removeClassName(elup,'visible');
	Element.addClassName(eldown,'visible');
	Element.addClassName(eldowntitle,'selectedPanel');
	Element.removeClassName(eluptitle, 'selectedPanel');    
}
// similar to toggle_accordion with differences in the title class.
function toggle_slide(el) {
	if (Element.hasClassName(el.parentNode.id+'-body','visible')){
		var elopened = el.parentNode.id+'-body';
		var elopenedtitle = el.parentNode.id+'-title';
		new Effect.SlideUp(elopened, {duration: 1});
		Element.removeClassName(elopened, 'visible');
		Element.removeClassName(elopenedtitle, 'slidedPanel');
		Element.addClassName(elopenedtitle,'unslidedPanel');
		return;
	} else {
		var elclosed = el.parentNode.id+'-body';
		var elclosedtitle = el.parentNode.id+'-title';
		new Effect.SlideDown(elclosed, {duration: 1});
		Element.addClassName(elclosed,'visible');
		Element.addClassName(elclosedtitle,'slidedPanel');
		Element.removeClassName(elclosedtitle, 'unslidedPanel');
		return;
	}
}
function open_close(elopened,elclosed) {
		new Effect.Appear(elclosed, {duration: 0.5});
		Element.addClassName(elclosed,'visible');
		new Effect.Fade(elopened, {duration: 0.5});
		Element.removeClassName(elopened, 'visible');
		return;
}
function togglehide(el) {
		if (Element.hasClassName(el, 'visible')) {
			new Effect.Fade(el, {duration: 0.5});
			Element.removeClassName(el, 'visible');			
		} else {
			new Effect.Appear(el, {duration: 0.5});
			Element.addClassName(el,'visible');
		}
		return;
}
function toggle2hide(elopened,elclosed) {
		if (Element.hasClassName(elopened, 'visible')) {
			new Effect.Fade(elopened, {duration: 0.5});
			Element.removeClassName(elopened, 'visible');			
			new Effect.Appear(elclosed, {duration: 0.5});
			Element.addClassName(elclosed,'visible');
		} else {
			new Effect.Appear(elopened, {duration: 0.5});
			Element.addClassName(elopened,'visible');
			new Effect.Fade(elclosed, {duration: 0.5});
			Element.removeClassName(elclosed, 'visible');			
		}
		return;
}
function sb_accordion_init(id) {
    var apanels = document.getElementsByClassName('panelBody',id);
    for (var i=0;i<apanels.length;i++){
        apanels[i].style.display = 'none';
    }
    var velems = document.getElementsByClassName('visible');
    for (var i=0;i<velems.length;i++){
        $(velems[i]).style.display = 'block';
    }
}
function startExpand(e,element)
{
	var fromElement = e.relatedTarget || e.fromElement;
	while (fromElement && fromElement != element && fromElement.nodeName != 'BODY')
		fromElement = fromElement.parentNode
	if (fromElement == element)
		return;
	
	var tableElement = element;
	var imgElement = tableElement.firstChild.firstChild.firstChild.firstChild.firstChild;
	
	if(!imgElement.inited)
		init(imgElement);

	if (tableElement.nextSibling != null) {
		tableElement.nextSibling.width = tableElement.offsetWidth;
		tableElement.nextSibling.height = tableElement.offsetHeight+1;
	}
	tableElement.className = "icon_expanded";
	tableElement.parentNode.style.zIndex = 1;
	window.clearTimeout(imgElement.imgDelayID);
	imgElement.imgDelayID = window.setTimeout(imgElement.expand,300);
}
function endExpand(e,element)
{

	var toElement = e.relatedTarget || e.toElement;
	while(toElement && toElement != element && toElement.nodeName != 'BODY')
		toElement = toElement.parentNode;
	if(toElement == element)
		return;

	var tableElement = element;
	var imgElement = tableElement.firstChild.firstChild.firstChild.firstChild.firstChild;
	window.clearTimeout(imgElement.imgDelayID);
	hideElements(tableElement);
	imgElement.contract();
}	
function hideElements(element)
{
	var trElements = element.firstChild.childNodes;
	if(trElements[1].nodeName != "SCRIPT")
	{
		if(trElements[1].firstChild.firstChild.nodeName == "SCRIPT")
			trElements[1].firstChild.childNodes[1].style.height = "30px";
		else
			trElements[1].firstChild.firstChild.style.height = "30px";
	}

	for(var i=0;i<trElements.length;i++)
	{
		if(trElements[i].getAttribute("hideexp") == "1")
			trElements[i].style.display = "";

		if(trElements[i].rehide)
			trElements[i].style.display = "none";
	}
}	
function init(imgElement)
{
	imgElement.originalHeight = imgElement.height;
	imgElement.originalWidth = imgElement.width;
	
	imgElement.expand = function() 
	{
		var factor = Math.round(imgElement.height*0.06);
		if(imgElement.width + factor < imgElement.originalWidth*2)
		{
			imgElement.width += factor;
			imgElement.height += factor;
			imgElement.imgDelayID = window.setTimeout(imgElement.expand,18);
		}
		else
		{
			imgElement.width = imgElement.originalWidth*2;
			imgElement.height = imgElement.originalHeight*2;
			var tableElement = imgElement.parentNode.parentNode.parentNode.parentNode.parentNode;
			showElements(tableElement);
			if(tableElement.getAttribute("pushdown") == "1")
				tableElement.nextSibling.height = tableElement.offsetHeight+1;
		}
	};
	imgElement.contract = function() 
	{
		var factor = Math.round(imgElement.height*0.08);
		if(imgElement.width - factor > imgElement.originalWidth)
		{
			imgElement.width -= factor;
			imgElement.height -= factor;
			imgElement.imgDelayID = window.setTimeout(imgElement.contract,15);
		}
		else
		{
			imgElement.width = imgElement.originalWidth;
			imgElement.height = imgElement.originalHeight;
			
			var parentTable = imgElement.parentNode.parentNode.parentNode.parentNode.parentNode;
			parentTable.className = "icon_expandable";
			parentTable.parentNode.style.zIndex = 0;
			if (parentTable.nextSibling != null) {
				parentTable.nextSibling.height = "1";
				parentTable.nextSibling.width = "1";
				}
		}
	};
	
	imgElement.inited = true;
}
function showElements(element)
{
	var trElements = element.firstChild.childNodes;
	if(trElements[1].nodeName != "SCRIPT")
	{
		if(trElements[1].firstChild.firstChild.nodeName == "SCRIPT")
			trElements[1].firstChild.childNodes[1].style.height = "";
		else
			trElements[1].firstChild.firstChild.style.height = "";
	}
	
	for(var i=0;i<trElements.length;i++)
	{
		if(trElements[i].getAttribute("hideexp") == "1")
			trElements[i].style.display = "none";
		else
		{
			if(trElements[i].style.display == "none")
			{
				trElements[i].style.display = "";
				trElements[i].rehide = true;
			}
		}
	}
}
function open_window(url,name,w,h) {
  var newWindow= window.open(url, name, 'width=' + w + ',height=' + h +',resizable=yes,scrollbars=yes');
  if (newWindow)
  	newWindow.focus();
  //setTimeout('self.close()', 120000);
}
function setTickerWidth(elementId, minWidth, usedWidth) {
  var theWidth = minWidth;
  if( 'number' == typeof(window.innerWidth) ) { // Mozilla
    theWidth = window.innerWidth - 40 - usedWidth; // subtract scrollbar width
  } else if( document.body && 'number' == typeof(document.body.clientWidth) ) { // IE 4+
      theWidth = document.body.clientWidth - 20 - usedWidth;    // subtract scrollbar width
      //theWidth = document.body.offsetWidth - 40;
      
  }
  if (theWidth < minWidth) theWidth = minWidth;
  var t = document.getElementById (elementId);
  t.style.width = theWidth;
  return;
}
function setAllTickersWidth(minWidth, usedWidth) {
  var theWidth = minWidth;
  if( 'number' == typeof(window.innerWidth) ) { // Mozilla
    theWidth = window.innerWidth - 40 - usedWidth; // subtract scrollbar width
  } else if( document.body && 'number' == typeof(document.body.clientWidth) ) { // IE 4+
      theWidth = document.body.clientWidth - 20 - usedWidth;    // subtract scrollbar width
      //theWidth = document.body.offsetWidth - 40;
      
  }
  if (theWidth < minWidth) theWidth = minWidth;
  var t = document.getElementById ('TICKER');
  var t2 = document.getElementById ('TICKER2');
  t.style.width = theWidth;
  t2.style.width= theWidth;
  return;
}