// JavaScript Document

	var scrollbarRechts;
	var scrollbarLinks;
	var oScrollbarNews;
	var scrollbarProd;
	var scrollbarPrice;

	$(window).load(function() {
		
		var total = $('#bgslid img').length;
		var rand = Math.floor(Math.random()*total);
		
		$('#bgslid').nivoSlider({
			effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
			slices:1,
			animSpeed:1000, //Slide transition speed
			pauseTime:10000,
			startSlide:rand, //Set starting Slide (0 index)
			directionNav:false, //Next & Prev
			directionNavHide:false, //Only show on hover
			controlNav:false, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
			controlNavThumbsFromRel:false, //Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', //Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
			keyboardNav:false, //Use left & right arrows
			pauseOnHover:false, //Stop animation while hovering
			manualAdvance:false, //Force manual transitions
			captionOpacity:0.8, //Universal caption opacity
			beforeChange: function(){},
			afterChange: function(){},
			slideshowEnd: function(){}, //Triggers after all slides have been shown
			lastSlide: function(){}, //Triggers when last slide is shown
			afterLoad: function(){} //Triggers when slider has loaded
		});
	});


	
//	function PreloadImg(){
//		$.ImagePreload("fileadmin/templates/CT2011/Images/bg/bg_1.png");
//		$.ImagePreload("fileadmin/templates/CT2011/Images/bg/bg_2.png");
//		$.ImagePreload("fileadmin/templates/CT2011/Images/bg/bg_3.png");
//	}
	$(document).ready(function(){
		//PreloadImg();
		//aktiv = window.setTimeout("bildwechsel()", 15000);
		
		// Fenster anzeigen
		
		
		
		if ( $(".brandBox").length > 0 ) aktiv = window.setTimeout("$('.brandBox').show('slow')", 1700);
		if ( $(".fullBox").length > 0 ) aktiv = window.setTimeout("$('.fullBox').show('slow')", 1700);
		if ( $(".fb_news").length > 0 ) aktiv = window.setTimeout("$('.fb_news').show('slow')", 3000);
		
		if ( $("#scrollbarRechts").length > 0 ) {
			scrollbarRechts = $('#scrollbarRechts');
			scrollbarRechts.tinyscrollbar({ size: 250 });
			aktiv = window.setTimeout("$('.halfBox_right').show('slow');scrollbarRechts.update()", 1600);
		}
		
		if ( $("#scrollbarNews").length > 0 ) {
			oScrollbarNews = $('#scrollbarNews');
			oScrollbarNews.tinyscrollbar({ size: 250 });
		}
		
		if ( $("#scrollbarLinks").length > 0 ) {
			scrollbarLinks = $('#scrollbarLinks');
			scrollbarLinks.tinyscrollbar({ size: 250 });
			aktiv = window.setTimeout("$('.halfBox_left').show('slow');scrollbarLinks.update()", 1500);
		}
		
		if ( $("#scrollbarProd").length > 0 ) {
			scrollbarProd = $('#scrollbarProd');
			scrollbarProd.tinyscrollbar({ size: 150 });
			
			scrollbarPrice = $('#scrollbarPrice');
			scrollbarPrice.tinyscrollbar({ size: 90 });
			
			aktiv = window.setTimeout("$('.quaterBox_left_top').show('slow');scrollbarProd.update()", 1600);
			aktiv = window.setTimeout("$('.quaterBox_right_top').show('slow');", 1500);
			
			aktiv = window.setTimeout("$('.quaterBox_left_bot').show('slow');", 1700);
			aktiv = window.setTimeout("$('.quaterBox_right_bot').show('slow');scrollbarPrice.update()", 1750);
		}		

	});
	
/*	addEvent(window, 'unload', fensterSchliessen);
	
	function fensterSchliessen(){
		$('.halfBox_left').hide('slow');
		$('.halfBox_right').hide('slow');
		$('.brandBox').hide('slow');
	}*/
	
//	function bildwechsel(){
//			$(".Slash").ImageSwitch({Type:"FadeIn",NewImage:"fileadmin/templates/CT2011/Images/bg/bg_"+ImgIdx+".png", speed: 6000});
//			ImgIdx++;
//			if(ImgIdx>3) ImgIdx = 1;
//			
//			aktiv = window.setTimeout("bildwechsel()", 15000);
//	
//	};
