$(document).ready(function() {
	if($.browser.mozilla) $("html").css("overflow","-moz-scrollbars-vertical"); 
	if(($.browser.safari || $.browser.opera) || ($.browser.msie && parent.frames.length>0)) {$("html").css("height","100.1%");} //msie wenn von renatekaiser.de
});

function initNavi2()
{ 
    var el = document.getElementById('naviunten').firstChild.firstChild.childNodes;
    for (var i=0;i<el.length;i++) {;
        el[i].onmouseover = mover;
        el[i].onmouseout = mout;
        el[i].onclick = function () {changeContent(this.id);}
    }
    var thetag = document.getElementsByTagName("img");
    for(var i=0;i<thetag.length;i++) {
        if(thetag[i].className == 'blank') {
            thetag[i].onmouseover = startScrolling;
            thetag[i].onmouseout = stopScrolling;
        }
        if(thetag[i].className == 'arrowLeft') {
            thetag[i].onclick = skipLeft;
        }
        if(thetag[i].className == 'arrowRight') {
            thetag[i].onclick = skipRight;
        }
    }
    document.getElementById('scrolldiv').scrollLeft = 0;
    //actButton = el[0].id;
    changeContent(el[0].nextSibling.id);

}

function skipLeft()
{
	if(actButton) {
		var node = getPrevious(document.getElementById(actButton));
		if(node.id) {changeContent(node.id);}
	}
}

function skipRight()
{
	if(actButton) {
		var node = getNext(document.getElementById(actButton));
		if(node.id) {changeContent(node.id);}
	}
}

function getPrevious(node)
{
	if(node.previousSibling.nodeType==3) return getPrevious(node.previousSibling);
	return node.previousSibling;
}
function getNext(node)
{
	if(node.nextSibling.nodeType==3) return getNext(node.nextSibling);
	return node.nextSibling;
}
function initNavi1(){
    var thetag = document.getElementsByTagName("img");
    for(var i=0;i<thetag.length;i++) {
        if(thetag[i].className == 'iOut') {
            thetag[i].onmouseover = function () {this.className = 'iOver';}
            thetag[i].onmouseout = function () {this.className = 'iOut';}
        }
    }
}
var scrollTimeout;
var scrollPos = 0;
function startScrolling()
{
    
   if(this.id=='lscroll') var f = "doScrolling(-5)";
   else var f = "doScrolling(5)";
   scrollTimeout = window.setInterval(f,40);
}
function doScrolling(x)
{
    var scrollto = scrollPos + x;
    if(scrollto >= 0 && scrollto <= (tableWidth-700)) {
        document.getElementById('scrolldiv').scrollLeft = scrollto;
        scrollPos = scrollto;
    } else {
        stopScrolling();
    }
}
function stopScrolling()
{
    window.clearInterval(scrollTimeout);
}
var actButton, actDescr, timeout;
function changeContent_bu(id)
{
	if(document.getElementById(actButton)) document.getElementById(actButton).style.borderColor = 'rgb(167,164,140)';
	actButton = id;
	actDescr = eval('naviText.t' + id.replace(/\.htm/,""));
	document.getElementById(actButton).style.borderColor = 'rgb(242,242,222)';
	document.getElementById('navirahmen').firstChild.data = actDescr;
	$("#ttdiv").animate({ height: 'hide' }, 'slow', function() {
                timeout = window.setTimeout(function(){$("#waiting").show()}, 600);
		$("#ttdiv").load(id, function(){
			var imgs = new Array();
			$("#ttdiv img").each(function(i) {
				imgs.push(this.src);
			});
			var imgloader = new ImagePreloader(imgs, checkLoaded);
		});
		
	});


}
function changeContent(id)
{
	if(document.getElementById(actButton)) document.getElementById(actButton).style.borderColor = 'rgb(167,164,140)';
	actButton = id;
	actDescr = naviText['t'+id];
	
	document.getElementById(actButton).style.borderColor = 'rgb(242,242,222)';
	document.getElementById('navirahmen').firstChild.data = actDescr;
	var url = '/cat/views/gallery.php?ctrl=File&action=getTemplate&id='+id.replace(/td/,"");
	$("#ttdiv").animate({ height: 'hide' }, 'slow', function() {
                timeout = window.setTimeout(function(){$("#waiting").show()}, 600);
		$("#ttdiv").load(url, function(){
			var imgs = new Array();
			$("#ttdiv img").each(function(i) {
				imgs.push(this.src);
			});
			var imgloader = new ImagePreloader(imgs, checkLoaded);
		});
		
	});


}

function checkLoaded()
{
	window.clearTimeout(timeout);
	$("#waiting").hide();
	setTimeout(function(){$("#ttdiv").animate({ height: 'show'}, 'slow');},200);
}

function mover()
{
    if(this.id!=actButton) {
        this.style.borderColor = 'rgb(217,214,190)'; 
        this.style.cursor = 'pointer'; 
        var newid = eval('naviText.t' + this.id.replace(/\.htm/,""));
        document.getElementById('navirahmen').firstChild.data = newid;
    }
}

function mout()
{
    if(this.id!=actButton) {
        this.style.borderColor = 'rgb(167,164,140)'; 
        this.style.cursor = 'default'; 
        document.getElementById('navirahmen').firstChild.data = actDescr;
    }
}