
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
    }
jQuery.noConflict();
jQuery(document).ready(function($) {
		$(window).load(function() {
								
			$('#news li').each(function(i){
			$(this).attr('id', 'art' + i);
		})


var total = $('#layout06 img').length;
var rand = Math.floor(Math.random()*total);

	$('#layout08').nivoSlider({
        effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
        slices:1,
        animSpeed:1500, //Slide transition speed
        pauseTime:4000,
        startSlide:rand, //Set starting Slide (0 index)
        directionNav:false, //Next & Prev
        directionNavHide:false, //Only show on hover
        controlNav:true, //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, //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

		});
	});	
});

/*
 * PARAMETERS:
 * ----------------
 * iDelay: Duration for interval in ms -> Example 5000
 * iFadeDelay: Duration for fading in ms -> Example 1000
 * iCountImages: Count of the images in integer  -> Example 6
*/

jQuery.noConflict();
jQuery(document).ready(function($) {


		var theIntHomeLayout = null;
		
		var iDelayHomeLayout = 6000;
		var iFadeDelayHomeLayout = 2000;
		var bRandomStartHomeLayout = true;
		var bNextButtonClick = true;
		var aktivIDHomeLayout = 0;
		var previousIDHomeLayout = 4;
		var iCountImagesHomeLayout = 5;
		
		var aktivIDHomeLayout2 = 4;
		var previousIDHomeLayout2 = 3;
		
		var idHeaderHomeLayout = $("#headerhomeLayout");	
		var idHeaderImagesHomeLayout = $("#headerhomeLayoutImages");
		var idHeaderThumbsHomeLayout = $("#headerhomeLayoutThumbs");
				
		randomFXHomeLayout = function(X) {
			return Math.floor(X * (Math.random() % 1));
		}
		
		fadeshowHomeLayout = function(oldID,newID,bStart){
			clearInterval(theIntHomeLayout);
			
			idHeaderThumbsHomeLayout.find("#headerhomeLayoutThumbi"+oldID).show();
			idHeaderImagesHomeLayout.find("#headerhomeLayoutImage"+newID).stop(true, true).fadeIn(iFadeDelayHomeLayout);
			idHeaderImagesHomeLayout.find("#headerhomeLayoutImage"+oldID).stop(true, true).fadeOut(iFadeDelayHomeLayout);
			idHeaderThumbsHomeLayout.find("#headerhomeLayoutThumbi"+newID).hide();
			
			aktivIDHomeLayout2 = aktivIDHomeLayout;
			previousIDHomeLayout2 = previousIDHomeLayout;
			
			previousIDHomeLayout = newID;
										
			theIntHomeLayout = setInterval(function(){
				if(bNextButtonClick){									
					aktivIDHomeLayout++;
					if( aktivIDHomeLayout == iCountImagesHomeLayout ) aktivIDHomeLayout = 0;
				}else{
					aktivIDHomeLayout--;
					if( aktivIDHomeLayout < 0 ) aktivIDHomeLayout = iCountImagesHomeLayout - 1;
				}
				$("#headerhomeLayoutThumbs .headerhomeLayoutThumbInactive").eq(aktivIDHomeLayout).trigger('click');
			}, iDelayHomeLayout);
		}
								
		$("#headerhomeLayoutImages").each(function(i) {
			idHeaderImagesHomeLayout.children().fadeOut(0, 0);
			
			if(bRandomStartHomeLayout==true){
				aktivIDHomeLayout = randomFXHomeLayout(iCountImagesHomeLayout);
				
				var c = readCookie("techmoteum");
				if (c){
					aktivIDHomeLayout = parseInt(c) + 1;
					if (aktivIDHomeLayout >= iCountImagesHomeLayout){ 
						aktivIDHomeLayout = 0; 
					}
				}
				
				if(aktivIDHomeLayout == 0) { 
					previousIDHomeLayout = iCountImagesHomeLayout-1;
				}else{
					previousIDHomeLayout = aktivIDHomeLayout-1;
				}
				createCookie("techmoteum", aktivIDHomeLayout, 365);
				
			}
			idHeaderImagesHomeLayout.find("#headerhomeLayoutImage"+aktivIDHomeLayout).fadeIn(0, 1);
			fadeshowHomeLayout(previousIDHomeLayout,aktivIDHomeLayout);
		});
		
		$("#headerhomeLayoutThumbs .headerhomeLayoutThumbInactive").click(function() {
			var currentId = $(this).attr('id'); 
			var newID = currentId.substr(currentId.length-2, 2);
			if(newID.substr(0, 1) == 'i') newID = currentId.substr(currentId.length-1, 1);
			var oldID = previousIDHomeLayout;
			
			aktivIDHomeLayout = newID;
			fadeshowHomeLayout(oldID,newID,false);
		});

		function createCookie(name,value,days){
			if (days){
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
			}
			else var expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
		}
		
		function readCookie(name){
			var nameEQ = name + "=";
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++){
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
			return null;
		}
		
		function eraseCookie(name){
			createCookie(name,"",-1);
		}
	});
