// schaltet sichtbare elemente aus und unsichtbare ein, sofern js aktiviert ist
function toggleSidebox(elementID, sidebarClick) {

	// var elements = document.getElementsByName("clickbox");
	
	//ie fix
	var elements =(getElementsByName_iefix("div", "clickbox"));
	for (var i = 0; i < elements.length; i++) {
		
		if ((elements[i].id) != elementID) {
			elements[i].style.display = "none";
		}		
	}

	var elem = document.getElementById(elementID);
	
	if(elem.style.display == "none") {
		elem.style.display = "block";
	}
	else {
		elem.style.display = "none";
	}
		
	// wenn Klick auf Bildervorschau, Box offenhalten
	if (!sidebarClick) {
		elem.style.display = "block";
	}

}

function getElementsByName_iefix(tag, name) {
     
     var elem = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute("name");
          if(att == name) {
               arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}


function toggleThis(elementID) {

	var elem = document.getElementById(elementID);
	
	if(elem.style.display == "none") {
		elem.style.display = "block";
	}
	else {
		elem.style.display = "none";
	}
		
	

}

function changePicture(pic) {
	document.pictureView.src = pic;
	toggleSidebox('boxPictureView', 0);
}

function hoverPicture(element) {
	element.src = element.src.split('.jpg').join('-hover.jpg');
}
function resetPicture(element) {
	element.src = element.src.split('-hover.jpg').join('.jpg');
}

function randomPicture(pictureNumber) {
	var pictureUrl = document.pictureView.src;
	
	var pictureUrlNew = pictureUrl.slice(0, pictureUrl.indexOf('-big.jpg')-2) + getRandom(1, pictureNumber) + '-big.jpg';
	
	
	document.pictureView.src = pictureUrlNew;
	setTimeout('randomPicture(' + pictureNumber + ');', 5000);
}

function getRandom( min, max ) {
	if (min > max) {
		return(1);
	}
	if(min == max) {
		return(min);
	}
    var randomValue = ( min + parseInt( Math.random() * ( max-min+1 ) ) );
	if (randomValue < 10) {
		return ('0' + randomValue);
	} else {
		return (randomValue);	
	}
}

function TextScroll(scrollname, div_name, up_name, down_name, elements)
{
    this.div_name = div_name;
    this.name = scrollname;
    this.scrollCursor = 0;
    this.speed = 8;
    this.timeoutID = 0;
    this.div_obj = null;
    this.up_name = up_name;
    this.dn_name = down_name;

{
        if (document.getElementById) {
            var div_obj = document.getElementById(this.div_name);
            if (div_obj) {
                this.div_obj = div_obj;
                this.div_obj.style.overflow = 'hidden';
                
				
            	div_obj = document.getElementById('boxScrollContent').style.width = (elements * 82 - 7) + 'px';
            }
            var div_up_obj = document.getElementById(this.up_name);
            var div_dn_obj = document.getElementById(this.dn_name);
            if (div_up_obj && div_dn_obj) {
                
				/*
				div_up_obj.setAttribute("onmouseover", scrollname + ".scrollUp();")
                div_up_obj.setAttribute("onmouseout", scrollname + ".stopScroll();")

				div_dn_obj.setAttribute("onmouseover", scrollname + ".scrollDown();")
                div_dn_obj.setAttribute("onmouseout", scrollname + ".stopScroll();")
				*/
				
				div_up_obj.onmouseover = function() { eval(scrollname + ".scrollUp();") };
				div_up_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };
				
				div_dn_obj.onmouseover = function() { eval(scrollname + ".scrollDown();") };
				div_dn_obj.onmouseout = function() { eval(scrollname + ".stopScroll();") };
            }
        }
    }

this.stopScroll = function() {
        clearTimeout(this.timeoutID);
    }

this.scrollUp = function() {
        if (this.div_obj) {
            this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
            this.div_obj.scrollLeft = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
        }
    }

this.scrollDown = function() {
        if (this.div_obj) {
            this.scrollCursor += this.speed;
            this.div_obj.scrollLeft = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
        }
    }

this.resetScroll = function() {
        if (this.div_obj) {
            this.div_obj.scrollTop = 0;
            this.scrollCursor = 0;
        }
    }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
