var first = "true";

window.addEvent('domready', function() {
	change();
});


function initmenu(){

	
	
		
	var arrowlink = new Fx.Tween('arrowlink', {duration: 1000,onComplete:function(){arrowfadein();}}); 
	
	arrowlink.start('opacity','1','0.45');
	
	
	var allmenu = $('menu').getElements('li');
	allmenu.each(function(li) {
		
		li.addEvent('mouseenter',function(e) {
			//console.log(li.style.backgroundColor);
			
			try{
			var hreftxt = li.childNodes[0];
			hreftxt.style.color = "#ffffff";
			}catch(ex){}
			
			
			if(li.style.backgroundColor!="rgb(185, 173, 145)" && li.style.backgroundColor!="#b9ad91"){
			li.morph({backgroundColor: "#C4B99F"});
			}
			
				  	
	 	});

		li.addEvent('mouseleave',function(e) {

			/*
			var hreftxt = li.childNodes[0];
			
			hreftxt.morph({color: "#484747"});*/
			var hreftxt = li.childNodes[0];
			
			if(li.style.backgroundColor!="rgb(185, 173, 145)" && li.style.backgroundColor!="#b9ad91"){
			li.morph({backgroundColor: "#FFFFFF"});
			try{
			hreftxt.style.color = "#666666";
			}catch(ex){}
			}
			

			
		});

	});

}

function arrowfadein(){
	var arrowlink = new Fx.Tween('arrowlink', {duration: 1000,onComplete:function(){arrowfadeout();}}); 
	
	arrowlink.start('opacity','0.45','1');
}

function arrowfadeout(){
	
	
	var arrowlink = new Fx.Tween('arrowlink', {duration: 1000,onComplete:function(){arrowfadein();}}); 
	
	arrowlink.start('opacity','1','0.45');
}





shuffle = function(o){ //v1.0
	for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
	return o;
};

var picarray = new Array(pfad+'images/headpics/1.jpg',pfad+'images/headpics/2.jpg',pfad+'images/headpics/3.jpg',pfad+'images/headpics/4.jpg',pfad+'images/headpics/5.jpg');



picarray = shuffle(picarray);



var first = "true";
var pickey = 0;
var mainchange = 1;

function numcheck() {
	if ((picarray.length - 1) > pickey) pickey++;
	else pickey = 0;
}

function change() {
	
	if(first == "true"){
		$('pic1').src=picarray[0];
		first="false";
		newchange();
		
		

	}else{
		numcheck();
		
		if (mainchange == 1) {
			$('pic2').set('opacity',0);
			$('pic2').src=picarray[pickey];
			
			
			var myFx1 = new Fx.Tween('pic1', {duration: 5000}); 
	
			myFx1.start('opacity','1','0');
				
			
			var myFx2 = new Fx.Tween('pic2', {duration: 5000,onComplete:function(){newchange();}}); 
		
			myFx2.start('opacity','0','1');
			
			
			mainchange = 2;
		} else {
			$('pic1').set('opacity',0);
			$('pic1').src=picarray[pickey];
			
			
			var myFx3 = new Fx.Tween('pic2', {duration: 5000}); 
	
			myFx3.start('opacity','1','0');
				
			
			var myFx4 = new Fx.Tween('pic1', {duration: 5000,onComplete:function(){newchange();}}); 
		
			myFx4.start('opacity','0','1');
			
		
			mainchange = 1;
		}
		
	}
}




function newchange() {
	
	setTimeout(change, 8000);
}











var allimg;





var sortcounter =0;

function sortimenthighlighter(){
	allimg = $('contenthold').getElements('img');
	
	
	allimg.each(function(img) {
		if(img.className!="sortimentimghighlight"&&img.src.indexOf(".gif")==-1){
			img.className="sortimentimg";
		}
		
		
		
		img.addEvent('mouseenter',function(e) {
			if(img.src.indexOf(".gif")==-1){
				img.className="sortimentimghighlight";
				//img.morph({width: 73, height: 102});
			}
		});
		
		img.addEvent('mouseleave',function(e) {	
			if(img.src.indexOf(".gif")==-1){
				img.className="sortimentimg";
				//img.morph({width: 70, height: 98});
			}
		});
		
		
	});
	
	if(sortcounter == allimg.length){
		sortcounter=0;
	}
	
	
	if($('contenthold').getElements('img')[sortcounter].src.indexOf(".gif")==-1){
		$('contenthold').getElements('img')[sortcounter].className="sortimentimghighlightauto";
		//console.log(sortcounter+"---"+$('contenthold').getElements('img')[sortcounter].className);
		sortcounter++;
		newsort(3000);
		
		
	}else{
		sortcounter++;
		newsort(1);
	}
	
	
	
}

function newsort(time){
	 setTimeout(sortimenthighlighter,time);
}


function formwidth(){
	
var allforms = document.forms.length;
for(var i=0;i<=allforms;i++){
	
  try{
  	
    	var formD = eval("document."+document.forms[i].name);    
	var count=formD.length-1;
	for (var x=0; x<count;x++){
		
      		
      		formD.elements[x].style.width ="200px";
        		
      		
	}  
  }catch (ex) {}	
}
}




