
// --------------------------------------------------
// Allgemeine JS-Funktionen
// --------------------------------------------------


function navihide(nid) {

	var objre = $('nav'+nid) ;
	objre.style.visibility = "hidden" ;
}


function naviset(nid) {

	var objre = $('nav'+nid) ;
	objre.style.visibility = "visible" ;
}


function navijump(link) {

	if ( link ) {

		location.href = link ;
	}
}


function wopen(link,wi,he) {
	
	var width = wi ;  
	var height = he ;
	var l = (screen.availWidth-width)/2 ;
	var t = (screen.availHeight-height)/2 ;
    wincom = window.open(link ,"oswin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width="+wi+",height="+he+",screenX="+l+",screenY="+t+",left="+l+",top="+t);
    
    if (wincom) {
    	wincom.focus() ;
	} else {
		alert(statustext) ;
	}
}


function wopencheck(link,wi,he) {

	var width=wi; var height=he;
	var l=(screen.availWidth-width)/2;
	var t=(screen.availHeight-height)/2;
    
    wincom=window.open(link ,"oswin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width="+wi+",height="+he+",screenX="+l+",screenY="+t+",left="+l+",top="+t);

	if (wincom) { 
		
		wincom.focus() 
	}
	
	return false ;
}


function dellink(link,btext) {

	Check = confirm(btext);

	if(Check == false) {
		
		return ;
		
	} else {
		
		window.open(link,'_self') ;
	}
}


function getcontentform(btext) {

     Check = confirm(btext) ;

	if( Check == false ) {
		
		return false ;
		
	} else {
		
		return true ;
	}

}


function getwebcam(link,btext) {

	var wi = 950 ; 
	var he = 500 ;
	var l  = (screen.availWidth-wi)/2 ;
	var t  = (screen.availHeight-he)/2 ;
    
   	wincom=window.open(link ,"oswin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+wi+",height="+he+",screenX="+l+",screenY="+t+",left="+l+",top="+t);

	if (wincom) { 
		
		wincom.focus() 
	}
}


function fielddel(f) {

	if ( f.value == f.defaultValue ) {
	
		f.value = "" ;
	}
}


function fieldset(f) {

	if ( f.value == "" ) {
		
		f.value = f.defaultValue ;
	}
}


function fieldemp(f) {

	if ( f.sbeg.value == f.sbeg.defaultValue ) {
		
		f.sbeg.value = "" ;
	}
}


function tabbgcolor(tabid,hrefid) {

	if ( $(tabid) ) {
		
		$(tabid).className = 'top_naviA'
	}
	
	if ( $(hrefid) ) {
	
		$(hrefid).className = 'os_head_navi2_active' ;
	}
} 



// --------------------------------------------------
// Suchboxen
// --------------------------------------------------


function nav_search (boxid,amount) {
	
	for ( var i=1 ; i<=amount ; i++ ) {

		var objre1 = $('searchl'+i) ;
		var objre2 = $('searchd'+i) ;
				
		if ( i == boxid ) {

			objre2.style.display = "block" ;
			objre1.style.background = "#A20607" ;
			objre1.setStyle({ backgroundColor:'#A20607',marginBottom:'0px',borderBottom:'2px solid #A20607' }); 
			
		} else {
			
			objre2.style.display = "none" ;
			objre1.style.background = "#B41819" ;
			objre1.setStyle({ backgroundColor:'#808080',marginBottom:'2px',marginRight:'2px',borderBottom:'0px' }); 
		}
	}
}


function nav_online(boxid,amount) {
	
	for ( var i=1 ; i<=amount ; i++ ) {

		var objre1 = $('onlinel'+i) ;
		var objre2 = $('onlined'+i) ;
				
		if ( i == boxid ) {

			objre2.style.display = "block" ;
			objre1.style.background = "#A20607" ;
			objre1.setStyle({ backgroundColor:'#A20607',marginBottom:'0px',borderBottom:'2px solid #A20607' }); 
			
		} else {
			
			objre2.style.display = "none" ;
			objre1.style.background = "#B41819" ;
			objre1.setStyle({ backgroundColor:'#808080',marginBottom:'2px',marginRight:'2px',borderBottom:'0px' }); 
		}
	}
}


function nav_preview(boxid,amount) {
	
	for ( var i=1 ; i<=amount ; i++ ) {

		var objre1 = $('previewl'+i) ;
		var objre2 = $('previewd'+i) ;
				
		if ( i == boxid ) {

			objre2.style.display = "block" ;
			objre1.style.background = "#A20607" ;
			objre1.setStyle({ backgroundColor:'#A20607',marginBottom:'0px',borderBottom:'2px solid #A20607' }); 
			
		} else {
			
			objre2.style.display = "none" ;
			objre1.style.background = "#B41819" ;
			objre1.setStyle({ backgroundColor:'#808080',marginBottom:'2px',marginRight:'2px',borderBottom:'0px' }); 
		}
	}
}



// --------------------------------------------------
// Image-Popup-Funktionen
// --------------------------------------------------


function ImageTrailShow(lpicid,thumbx,thumby,width,height,file) {

	if ( $('trailimageid') ) {
	
		var xyimg  = Element.cumulativeOffset($(lpicid)) ;
		var xcoord = xyimg[0] + thumbx + 10 ;
		var ycoord = xyimg[1] - ( ( height - thumby ) / 2 ) ;
	
		$('trailimageid').style.visibility = "visible" ;
		$('trailimageid').style.width  = width + "px" ;
		$('trailimageid').style.height = height +"px" ;
		$('trailimageid').style.left   = xcoord + "px" ;
		$('trailimageid').style.top    = ycoord + "px" ;
		
		$('ttimg').src = file ;
	}
}


function ImageTrailHide() {
	
	if ( $('trailimageid') ) {
	
		$('ttimg').src = $('ttimg').rel ;
		$('trailimageid').style.visibility = "hidden" ;
		$('trailimageid').style.left = -1000 ;
		$('trailimageid').style.top  = 0 ;
	}
}



// --------------------------------------------------
// DIV-Tab-Funktionen (Detailansicht)
// --------------------------------------------------


var TabDiv = Class.create() ;

TabDiv.prototype = {
	
	initialize: function( sDiv ) {	
		
		this.selDiv = sDiv ;
		this.actDiv = 'os_detail_content' + sDiv ;
		
		if ( !document.getElementsByTagName ){ return ; }
		
		var anchors = document.getElementsByTagName('a') ;

		for ( var i=0 ; i < anchors.length ; i++ ){
			
			var anchor = anchors[i] ;
			var relAttribute = String(anchor.getAttribute('rel')) ;

			if ( relAttribute.match('os_detail_content') ){

				anchor.onclick = function () { myTabDiv.change(this) ; return false ; }
				var divClassName = relAttribute ;
				
				if ( $(divClassName) ) {
					
					if ( divClassName == 'os_detail_content' + this.selDiv ) {

						$(divClassName).style.display = 'block' ;
					
					} else {
				
						$(divClassName).style.display = 'none' ;
					}
				}
			}
		}
	} ,
	
	change: function ( cDiv )  {
		
		var changeDivObj = cDiv ;
		var divClassName = String(changeDivObj.getAttribute('rel')) ;
		
		if ( $(this.actDiv) ) {
		
			$(this.actDiv).style.display = 'none' ;
		}
		
		if ( $(divClassName) ) {
			
			$(divClassName).style.display = 'block' ;
			this.actDiv = divClassName ;
		}
	}
}



// --------------------------------------------------
// DIV-Popupup-Funktionen
// --------------------------------------------------


var PopupDiv = {
	
	popupid: null ,

	show: function( divid , tiframe , url ) {
		
		if ( url ) {
			
			if ( tiframe ) {
				
				$(tiframe).src = imgpath + 'trenner.gif' ;
				$(tiframe).src = url ;
				
			} else {
				
				new Ajax.Updater(PopupDiv.popupid,url,{encoding:'iso-8859-1'}) ;
			}
		}
		
		var arrayPageSize = PopupDivGetPageSize();
		$('PopupDivBG').style.height = arrayPageSize[1] + 'px' ;
		Effect.Appear('PopupDivBG',{ duration:0.5,to:0.6 })

		PopupDiv.popupid = divid ;		
		var popup = $(PopupDiv.popupid) ;
		
		popup.scrollTop = 0 ;
		PopupDivCenter(popup) ;
		Element.hide(PopupDiv.popupid) ;
		Effect.Appear(PopupDiv.popupid,{duration:0.1}) ;
		
		window.onresize = PopupDivResize ;
		window.onscroll = PopupDivResize ;
	} ,

	close: function( tiframe , url ) {

		if ( tiframe && url ) {
				
			$(tiframe).src = url ;
		}
		
		Effect.Fade(PopupDiv.popupid,{duration:0.1}) ;
		Effect.Fade('PopupDivBG',{duration:0.1}) ;
	} 
}


function PopupDivCenter(popupid) {
	
	popupid.style.visibility = 'hidden' ;
	popupid.style.display    = 'block' ;
	
	var divh = PopupDivGetPageScroll() - popupid.getHeight() / 2 ;
	var divw = 0 - popupid.getWidth() / 2 ;
	
	popupid.style.display    = 'none';
	popupid.style.visibility = '';
	popupid.style.marginTop  = divh + 'px' ;
	popupid.style.marginLeft = divw + 'px' ;
}


function PopupDivResize() {
	
	var arrayPageSize = PopupDivGetPageSize();
	PopupDivResizeCenter($(PopupDiv.popupid));
	$('PopupDivBG').style.height = arrayPageSize[1] + 'px' ;
}


function PopupDivResizeCenter(popupid) {
	
	var divh = PopupDivGetPageScroll() - popupid.getHeight() / 2 ;
	var divw = 0 - popupid.getWidth() / 2 ;
	
	popupid.style.marginTop  = divh + 'px' ;
	popupid.style.marginLeft = divw + 'px'  ;
}


function PopupDivGetPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


function PopupDivGetPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	return yScroll ;
}



// --------------------------------------------------
// END
// --------------------------------------------------
