function onContent(f){//(C)webreflection.blogspot.com
var a=onContent,b=navigator.userAgent,d=document,w=window,c="onContent",e="addEventListener",o="opera",r="readyState",
s="<scr".concat("ipt defer src='//:' on",r,"change='if(this.",r,"==\"complete\"){this.parentNode.removeChild(this);",c,".",c,"()}'></scr","ipt>");
a[c]=(function(o){return function(){a[c]=function(){};for(a=arguments.callee;!a.done;a.done=1)f(o?o():o)}})(a[c]);
if(d[e])d[e]("DOMContentLoaded",a[c],false);
if(/WebKit|Khtml/i.test(b)||(w[o]&&parseInt(w[o].version())<9))(function(){/loaded|complete/.test(d[r])?a[c]():setTimeout(arguments.callee,1)})();
else if(/MSIE/i.test(b))d.write(s);
};

var opacity = 1;
var delay = 3;
var contentHeight = null;
var imgHeight = null;

function init(){
	startList();
	if($('ticker')) initTicker();
	
	if($('fadeOut')){ // ContentFading 
		imgHeight = $('fadeOut').getHeight()-40;
		new PeriodicalExecuter(function(pe){ new PeriodicalExecuter(fade, 0.05); pe.stop();}, delay);
		
		if(imgHeight < $('content').getHeight()){
		   contentHeight = $('content').getHeight();
		   $('content').style.height = imgHeight+'px';
		   $('content').style.overflow = 'hidden';
		   
		   new PeriodicalExecuter(function(pe){ new PeriodicalExecuter(expand, 0.1); pe.stop();}, delay);		
		}
		else{
			$('content').style.height = imgHeight+'px';
		}
	}
}

function fade(pe){
	opacity = opacity - 0.1;
	$('fadeOut').setOpacity(opacity);
	if(opacity <= 0.1){
		pe.stop();
		$('fadeOut').hide();	
		$('content').style.height = 'auto';
	}
}

function expand(pe){
	$('content').style.height = Math.ceil($('content').offsetHeight + (contentHeight - $('content').offsetHeight)/20)+'px';
	if($('content').offsetHeight >= contentHeight - 5){
		pe.stop();
		$('content').style.height = 'auto';	
        $('content').style.overflow = 'visible';		
	}
}

var pixel = 3;
var scrolled_pixel = 0;
var max_width = 0;
var displayed_width = 400;

function initTicker() {
	displayed_width = $("ticker_wrapper").offsetWidth;
	max_width = $("ticker").offsetWidth + displayed_width;
    show_ticker();
}

function show_ticker() {
    $("ticker").style.left = (displayed_width - scrolled_pixel) + "px";
    scrolled_pixel += pixel;
    if(scrolled_pixel > max_width+10)
    	scrolled_pixel = 0;
	window.setTimeout("show_ticker()",50);
}

function startList() {

	if (document.getElementById) {
		navRoot = document.getElementById("secondnav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() { 
					if(this.getElementsByTagName('ul').length > 0)
						this.getElementsByTagName('ul')[0].style.display="block";
					}
				node.onmouseout=function() { 
					if(this.getElementsByTagName('ul').length > 0)
						this.getElementsByTagName('ul')[0].style.display="none"; 
					}
			}
		 }
	}
}

onContent(init);