var spez = 0 ;
var spezscrollbarwidth = 3 ;
var movok = 0 ;
var mov = 1 ;
var currentslide = 1 ;
var timeoutID1;
var timeoutID2;
var timeoutID3;
var timeoutID4;
$(document).ready(function() {
	initflashcontainer () ;
	$.preloadCssImages();
	matchHeight() ;
	
	
	$('.slideshow0').cycle({
		fx:    'scrollLeft', 
    	delay: -500, 
		easing: 'easeInOutQuad',
		/*prev:     '#prev1', 
		next:     '#next1', */
		timeout:   0,
		
		/*before:    onBefore ,    */
		/*after:     onAfter ,*/
		pause:     true
	});
	
   
	
	//timeoutID = window.setTimeout(slowAlert, 2000);
	
 	$('#goto0').mouseover(function() {
		
		if (movok) {
			setslide(0) ;
			if (mov == 1) {
				mov = 0 ;
			timeoutID1 = setTimeout(animateslide,250);
			}
		timeout = setTimeout(setMov,250);
		}
		movok = 1 ;
    return false; 
	});
	$('#goto1').mouseover(function() {
		if (movok) {
			setslide(1) ;
			if (mov == 1) {
				mov = 0 ;
			timeoutID1 = setTimeout(animateslide,250);
			}
		timeout = setTimeout(setMov,250);
		}
    return false; 
	});
	
	$('#goto2').mouseover(function() { 
		if (movok) {
			setslide(2) ;			   
			if (mov == 1) {
				mov = 0 ;
			timeoutID2 = setTimeout(animateslide,250);
			}
		timeout = setTimeout(setMov,250);
		}
    return false; 
	});
	$('#goto3').mouseover(function() {
		if (movok) {
			setslide(3) ;
			if (mov == 1) {
				mov = 0 ;
			timeoutID3 = setTimeout(animateslide,250);
			}
		timeout = setTimeout(setMov,250);
		}
    return false; 
	});
	$('#goto4').mouseover(function() {
		if (movok) {
			setslide(4) ;
			if (mov == 1) {
				mov = 0 ;
			timeoutID4 = setTimeout(animateslide,250);
			}
		timeout = setTimeout(setMov,250);
			}
    return false; 
	});
	
	// $("#newsticker").animate({backgroundColor: '#fff', color: '#000', marginLeft: '0'}, 1000);

});
 
function onBefore(curr,next,opts) {
	
	
}
 
function onAfter(curr,next,opts) {
	mov = 1;
	animateslide()
}

function setMov() {
	mov = 1;
}

function animateslide() {
	//alert("SLIDE 2 " + currentslide)
	$('.slideshow0').cycle(currentslide);
}
function setslide(slide) {
	currentslide = slide;
	//alert("SLIDE " + currentslide)
}

//match
 	matchHeight=function(){
         var divs,contDivs,maxHeight,divHeight,d;
         // get all <div> elements in the document
         divs=document.getElementsByTagName('div');
         contDivs=[];

         // initialize maximum height value
         maxHeight=100;
		 maximalHeight=100;
		 //maximalHeight=$(window).height()-260 ;
         // iterate over all <div> elements in the document
         for(var i=0;i<divs.length;i++){
              // make collection with <div> elements with class attribute 'container'
			   if(/\bcontainer\b/.test(divs[i].className)){
                    d=divs[i];
                    contDivs[contDivs.length]=d;
                    // determine height for <div> element
                    if(d.offsetHeight){
                         divHeight=d.offsetHeight;
                    }
                    else if(d.style.pixelHeight){
                         divHeight=d.style.pixelHeight;
                    }
                    // calculate maximum height
                    maxHeight=Math.max(maxHeight,divHeight);
              }

         }
		 
		 //maxHeight = maximalHeight + 40  ; 
		   //if (maxHeight < 100) {maxHeight = 140 ;}	
		   if (spez == 0 )  { maxHeight = 241 ;}
		   else {maxHeight = spez}
		  try {  document.getElementById('ccontent').style.height=maxHeight + 'px'; 
		 document.getElementById('pane4').style.height=maxHeight + 'px';
		 $('#pane4').parent().get(0).style.height=maxHeight + 'px';
		 document.getElementById('inhalt').style.height=maxHeight + 'px';
		 $('#pane4').jScrollPane( {scrollbarWidth:spezscrollbarwidth,bottomCapHeight:2, reinitialiseOnImageLoad: true} );
		 initflashcontainer () ;
		 }
		  catch(error){} 
    }

   
	
	jQuery.event.add(window, "resize", resizeFrame);

		function resizeFrame() 
		{
			matchHeight();
			//$('#pane3').jScrollPane( {reinitialiseOnImageLoad: false} );
		    $('#pane4').jScrollPane( {scrollbarWidth:spezscrollbarwidth, bottomCapHeight:2, reinitialiseOnImageLoad: true} );
			
		}
		


			reinitialiseScrollPane = function()
				{
					//$('#pane1').jScrollPane();
					 matchHeight();
					 //$('#pane3').jScrollPane({reinitialiseOnImageLoad: false});
					 $('#pane4').jScrollPane({bottomCapHeight:2, reinitialiseOnImageLoad: true});
					var pane4top = parseInt( $('#pane4').offset().top);
					var $pane4 = $('#pane4');
					$pane4[0].scrollTo(0);
				}
				

