
var IE6 = false;
if(navigator.appVersion.indexOf("MSIE 6.0")!=-1){
	IE6=true;	
}
function setBULH(){
//		hnew=$('#navSide > ul').height()+c.height();					
		hnew=$('#content').height()-168;				
		$('#navSide > ul').css({ height: hnew + 'px' });	
	}
function setBULH2 () {
      var hnew;
      hnew=document.getElementById('content').offsetHeight-168;                      
    	child = document.getElementById('navSide').childNodes;
		for (i in child){
			if (child[i].className=="clearFix"){
				child[i].style.height= hnew + 'px';
				break;
			}
		}
    }
function setWHeight(){
		if($('.hp').length>0 ){
		/* changed by alpin */
			headHei=0;				
			WHei=$('#wrap').height();
			tHei=$('#wrap2').height();
			if(IE6){			
				if($('.styled').length>0 ){
					$('#wrap2').css({height:(WHei-headHei-13)+"px"});
				}else{
					$('#wrap2').css({height:(WHei-headHei)+"px"});			
				}
			}else{
/*	changed by alpin			if($('.styled').length>0 ){
					document.getElementById("wrap2").style.minHeight=(WHei-headHei-13)+"px";
				}else{
					document.getElementById("wrap2").style.minHeight=(WHei-headHei)+"px";
				}*/				
			}
		}else{			
			if($('#content').length>0 && $("#products").length<=0 && $(".mass").length<=0){
				WHei=$('#wrap').height();
				if(IE6){							
					$('#content').css({height:(WHei-20)+"px"});
				}else{
					document.getElementById("content").style.minHeight=(WHei-20)+"px";				
				}
			}			
		}
	}

function tabclick(obj){
		child=obj.childNodes;		
		for(i in child){
			if (child[i].tagName=="SPAN"||child[i].tagName=="span"){	
				child=child[i].childNodes;
				break;
			}
		}			
		for(i in child){
				if (child[i].tagName=="IMG"||child[i].tagName=="img"){
					img=child[i].src;
					ePh=img.lastIndexOf("/");
					ePt=img.lastIndexOf(".");
					eUn=img.lastIndexOf("_");
					fPh=img.substring(0,ePh+1);
					id=img.substring(ePh+1,eUn+1);
					newSrc=id+"black.gif";
					newSrc=fPh+newSrc;
					child[i].src=newSrc;
					break;
				}
			}
	}	


function tabreset(obj){
	var sty=0;
	for(i=1; i<=6;i++){
		if(document.body.className.indexOf("style"+i)!=-1)	 {
			sty=i;
			break;
		}
	}

	switch(sty){
	case 6:
		sty="yellow";
		break;
	case 5:
		sty="green";
		break;
	case 4:
		sty="violet";
		break;
	case 3:
		sty="lightblue";
		break;
	case 2:
		sty="orange";
		break;
	case 1:
		sty="magenta";
		break;
	default:
		sty="blue";
	}	
	child=obj.childNodes;
	for(i in child){
		if (child[i].tagName=="LI"||child[i].tagName=="li"){		
		child2=child[i].childNodes;
				for(j in child2){
					if (child2[j].tagName=="A"||child2[j].tagName=="a"){	
						child2=child2[j].childNodes;
						break;
					}
				}					
				for(j in child2){
					if (child2[j].tagName=="SPAN"||child2[j].tagName=="span"){	
						child2=child2[j].childNodes;
						break;
					}
				}			
				for(j in child2){
						if (child2[j].tagName=="IMG"||child2[j].tagName=="img"){
							img=child2[j].src;
							ePh=img.lastIndexOf("/");
							ePt=img.lastIndexOf(".");
							eUn=img.lastIndexOf("_");
							fPh=img.substring(0,ePh+1);
							id=img.substring(ePh+1,eUn+1);
							newSrc=id+sty+".gif";
							newSrc=fPh+newSrc;
							child2[j].src=newSrc;
							break;
						}
					}		
		}
	}
	
}

function tabreset2(obj){
	var sty=0;
	for(i=1; i<=6;i++){
		if(document.body.className.indexOf("style"+i)!=-1)	 {
			sty=i;
			break;
		}
	}
	child=obj.childNodes;
	for(i in child){
		if (child[i].tagName=="LI"||child[i].tagName=="li"){		
		child2=child[i].childNodes;
				for(j in child2){
					if (child2[j].tagName=="A"||child2[j].tagName=="a"){	
						child2=child2[j].childNodes;
						break;
					}
				}					
				for(j in child2){
					if (child2[j].tagName=="SPAN"||child2[j].tagName=="span"){	
						child2=child2[j].childNodes;
						break;
					}
				}			
				for(j in child2){
						if (child2[j].tagName=="IMG"||child2[j].tagName=="img"){
							img=child2[j].src;
							ePh=img.lastIndexOf("-h");
							ePt=img.lastIndexOf(".");
							eUn=img.lastIndexOf("_");
							if(ePh!=-1){
								fPh=img.substring(0,ePh);
							}else{
								fPh=img.substring(0,ePt)+"-h";
							}
							newSrc=fPh+".gif";
							child2[j].src=newSrc;
							break;
						}
					}		
		}
	}
	
}
function overNext(obj){
	
	}
var api = {
	ptimer: null,
	init: function() {
		api.tabs('tabs1');
		api.tabs('tabs2');
		api.tabs('massTabs');
		api.news();
//		api.story();
		api.erlebnis();


		var objh = $('#navSide ul').height();
		var mainh = $('#wrap').height();
		var navh = $('#navSide').height();
		var hnew = objh + mainh - navh - 10;
		if ($('div.nav2').length > 0) {
			hnew -= 14;
		}
		if ($('#side div.boxTop').length > 0)
		{
			hnew -= $('#side div.boxTop').height() + 30;
		}
		if($('.hp #news').length > 0){
			hnew -=9;
			}		
		if($('#product div.variants p.expand').length > 0){
			hnew +=9;
			}
		if($('.presse').length > 0){			
			hnew -=4;
			}		
		if($('#ajaxsetbuilder').length > 0){			
			hnew +=10;
		}					
		$('#navSide > ul').css({ height: hnew + 'px' });		

			
		var ul = $('#navSide ul ul');
		if (ul.length > 0)
		{
			var hul = ul.height() + 40;
			var th  = $('#navSide ul li.active a').height()+8;
			$('#navSide .menu2M').css({ height: hul + 'px' });
			$('#navSide .menu2T').css({ top: th + 'px' });			
			$('#navSide .menu2M').css({ top: (th +10) + 'px' });
//			$('#navSide .menu2B').css({ top: (hul + 33 +th +10) + 'px' });

		}
		var fr = $('#navSide form.active');
		if (fr.length > 0)
		{

			var frh = fr.height() + 16;
			$('#navSide .menu2M').css({ height: frh + 'px' });
			$('#navSide .menu2B').css({ top: (frh) + 'px' });
		}		
		setWHeight();
		
/*		if($("#ajaxsetbuilder").length>0){

			$("#ajaxsetbuilder").bind("load",function(){
															$('#content').style.height="auto";														
															setWHeight();
														});	
		}		*/
		$('#navSide.empty A DIV.icon[title] ').bind('mouseover', function(){
			if (api.ptimer)
			{
				clearTimeout(api.ptimer);
				api.ptimer = null;
			}
			var p = $('#popup1.blue');
			if (p.length <= 0)
			{
				$(document.body).append('<div id="popup1"></div>');
				p = $('#popup1');
			}
			var pos = $(this).offset();
			wid=$(this).width()
			p.addClass('blue');
			p.css({ top: (pos.top - 16) + 'px', left: (pos.left + wid + 6) + 'px' });
			p.html("<div class='top'></div><div class='center'>"+this.title+"</div><div class='bottom'></div>");
			this.title="";
			p.show();
		}).bind('mouseleave', function(){
			try{					
			var matchTag = /<(?:.|\s)*?>/g;					
			var tit = $('#popup1').html().replace(matchTag, "");					
			this.title=tit;
			}catch(e){}

			api.ptimer = setTimeout(function(){
				$('#popup1').hide();
			}, 250);
		});
		
		$('#products span.note span[title], fieldset label a.help[title], #tabProduct1 p.price2[title], #tabProduct1 p.price3[title], .list3 li a.help[title], #navSide.non-empty A DIV.icon[title] ').bind('mouseover', function(){
			if (api.ptimer)
			{
				clearTimeout(api.ptimer);
				api.ptimer = null;
			}
			var p = $('#popup1');
			if (p.length <= 0)
			{
				$(document.body).append('<div id="popup1"></div>');
				p = $('#popup1');
			}
			var pos = $(this).offset();
			wid=$(this).width()
			if (this.className=="price2"||this.className=="price3"){
				wid=10;
			}
			p.css({ top: (pos.top - 16) + 'px', left: (pos.left + wid + 6) + 'px' });
			p.html("<div class='top'></div><div class='center'>"+this.title+"</div><div class='bottom'></div>");
			this.title="";
//			this.title="";
			p.show();
		});
		$('#products span.note span[title], fieldset label a.help[title], #tabProduct1 p.price2[title], #tabProduct1 p.price3[title], .list3 li a.help[title], #navSide.non-empty A DIV.icon[title] ').bind('mouseleave', function(){
			try{					
			var matchTag = /<(?:.|\s)*?>/g;					
			var tit = $('#popup1').html().replace(matchTag, "");					
			this.title=tit;
			}catch(e){}
			api.ptimer = setTimeout(function(a){
				$('#popup1').hide();		
			}, 250);
		});
		

		
		$('#setbuild p.prev a IMG').bind('mouseover', function(){
			src=this.src;
			ext=src.substring(src.lastIndexOf("."),src.length);
			src=src.substring(0,src.lastIndexOf("."));
			this.src=src+"_h"+ext;
		}).bind('mouseleave', function(){
			src=this.src;
			ext=src.substring(src.lastIndexOf("."),src.length);
			src=src.substring(0,src.lastIndexOf("_"));
			this.src=src+ext;
		});
		$('.carousel-prev IMG').bind('mouseover', function(){
			src=this.src;
			ext=src.substring(src.lastIndexOf("."),src.length);
			src=src.substring(0,src.lastIndexOf("."));
			this.src=src+"_h"+ext;
		}).bind('mouseleave', function(){
			src=this.src;
			ext=src.substring(src.lastIndexOf("."),src.length);
			src=src.substring(0,src.lastIndexOf("_"));
			this.src=src+ext;
		});
		$('.carousel-next IMG').bind('mouseover', function(){
			src=this.src;
			ext=src.substring(src.lastIndexOf("."),src.length);
			src=src.substring(0,src.lastIndexOf("."));
			this.src=src+"_h"+ext;
		}).bind('mouseleave', function(){
			src=this.src;
			ext=src.substring(src.lastIndexOf("."),src.length);
			src=src.substring(0,src.lastIndexOf("_"));
			this.src=src+ext;
		});		
		
		$('#setbuild #tabProduct1 p.next a IMG').bind('mouseover', function(){
			src=this.src;
			ext=src.substring(src.lastIndexOf("."),src.length);
			src=src.substring(0,src.lastIndexOf("."));
			this.src=src+"_h"+ext;
		}).bind('mouseleave', function(){
			src=this.src;
			ext=src.substring(src.lastIndexOf("."),src.length);
			src=src.substring(0,src.lastIndexOf("_"));
			this.src=src+ext;
		});

		$('#tabProduct1 p.more a').click(function(){
			var c = $('#product div.variants div.variantsContent');
			if (c.hasClass('hide'))
			{	
				c.removeClass('hide');			
				$('#product div.variants p.expand').addClass('expanded');
				hnew=$('#navSide > ul').height()+c.height();				
				$('#navSide > ul').css({ height: hnew + 'px' });
			}
				window.scroll(0, getBodySize()[1]);			
			return false;
		});
		
		$('#setbuild form input').click(function(){
			var c = $('#setbuild table tr');			
			if (c.hasClass('selected'))
			{	
				c.removeClass('selected');			
			}
			x= $(this).parents('tr')[0];						
			x.className="selected";			
			x=$(this).parents('td')[0];
			x=x.childNodes;
		});				
			
		$('#product div.variants p.expand a').click(function(){
			var c = $('#product div.variants div.variantsContent');
			if (c.hasClass('hide'))
			{
				c.removeClass('hide');			
				$('#product div.variants p.expand').addClass('expanded');				
				hnew=$('#navSide > ul').height()+c.height();				
				$('#navSide > ul').css({ height: hnew + 'px' });				
			}
			else
			{
				c.addClass('hide');
				$('#product div.variants p.expand:eq(0)').removeClass('expanded');				
				hnew=$('#navSide > ul').height()-c.height();				
				$('#navSide > ul').css({ height: hnew + 'px' });				
			}
			return false;
		});

		$('#order .expand a').click(function(){
			var c = $('#order .expandable');
			if (c.hasClass('hide'))
			{
				c.removeClass('hide');
				$('#order .expand').addClass('expanded');				
			}
			else
			{
				c.addClass('hide');
				$('#order .expand').removeClass('expanded');				
			}
			return false;
		});

		$('div.select a.open').click(function(){
			$('ul', this.parentNode).toggle();
			return false;
		});
		$('div.select li a').click(function(){
			$('span', this.parentNode.parentNode.parentNode).html(this.innerHTML);
			$(this.parentNode.parentNode).toggle();
			return false;
		});
	},
	tabs: function(id) {
		$('#' + id + ' > li > a').click(function(){
			var p = $(this).parents('ul')[0].parentNode;	
			if (id == 'massTabs') {
				$('div.main > div', p).addClass('hide');
			}
			else {
				if(id.toUpperCase()=="TABS1"){
					var tabsForClear=$(this).parents('ul')[0];
					tabreset(tabsForClear);
					tabclick(this);					
				}
				if(id.toUpperCase()=="TABS2"){
					var tabsForClear=$(this).parents('ul')[0];
					if($(this).parents('li')[0].className!="active"){
						tabreset2(tabsForClear);
					}
				}				
				$('>div', p).addClass('hide');
			}
			$('#' + this.className, p).removeClass('hide');
			$('#' + id + ' li').removeClass('active');
			$(this.parentNode).addClass('active');
			return false;
		}); 
	},
	news: function() {
		$('#news .list li a').bind('mouseenter', function(){
			if(!$(this).hasClass("active")){
				$('#news .detail > div').addClass('hide');
				var id = this.className;
				$('#news #' + id).removeClass('hide');
				$('#news .list li a').removeClass('active');
				$(this).addClass('active');
			}
		});
	},
/*	story: function() {
		$('#newsArchive ul li').bind('mouseenter', function(){												
			$('#wrap #content > div').addClass('hide');
			var id = this.className;
			$('#wrap #content #' + id).removeClass('hide');
			$('#newsArchive ul li').removeClass('active');
			$(this).addClass('active');
		});
	},*/
	erlebnis: function() {
		$('#box8 div.popmenu').bind('mouseenter', function(){												
			$('#box8 div.popmenu ul.list1pop').css({ top: (13) + 'px' });
		});
		$('#box8 div.popmenu').bind('mouseleave', function(){												
			$('#box8 div.popmenu ul.list1pop').css({ top: (-10000) + 'px' });
		});		
		
	}	

};
 
$(document).ready(api.init);


////////////////////////////////////////////////////
// Dockmenu for products						  //
////////////////////////////////////////////////////
var sizeval= new Array(); 		//image size
var maxx=80;  	//max size of images
var images=new Array();
var texts=new Array();
var numberofimages;
var distance= maxx - (sizeval/2);
var splitter=0;
var minposition=0;
var maxposition=0;
var XY = new Array();
var tempX = 0;
var tempY = 0;
var menugo=false;
var IE = (document.all?true:false);
if (!IE) document.captureEvents(Event.MOUSEMOVE);

function getPosL(bid) {
var curleft =0;
//obj=document.getElementById(bid);
obj=images[bid];

	if (obj.offsetParent) {
		curleft = obj.offsetLeft;		
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;			
		}
	}
return curleft;
}
function getL(bid) {
var curleft =0;
obj=document.getElementById(bid);
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;		
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;			
		}
	}
return curleft;
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function getPosT(bid) {
var curtop =0;
//obj=document.getElementById(bid);
obj=images[bid];

	if (obj.offsetParent) {
		curtop = obj.offsetTop;		
		while (obj = obj.offsetParent) {
			curtop += obj.offsetTop;			
		}
	}
return curtop;
}
function getMouseXY(e) {

  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
   
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0;}
  if (tempY < 0){tempY = 0;}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  XY[0]=tempX;
  XY[1]=tempY;
		if(menugo){		 
		  bar();
		}else{
		reset() ;
		}  
//  window.status=XY[0];
  return false;
}

function bar(){
	for(i=0;i<numberofimages;i++){
				
//		position1= getPosL(i)+ (document.getElementById(i).width/2);
//		positiont1=(document.getElementById(i).height/2);
		position1= getPosL(i)+ (images[i].width/2);
		positiont1=(images[i].height/2);
		
		if(i==0)minposition=position1;
		if(i==(numberofimages-1))maxposition=position1;

		
		qx=XY[0]-position1;
		xq=position1 - XY[0];
		
		qy=XY[1]-positiont1;
		yq=positiont1 - XY[1];		
		
		if(qx>xq){xxx=qx;}
		else	 {xxx=xq;}
						
		if(qy>yq){yyy=qy;}
		else	 {yyy=yq;}
	
		
		size=maxx-(xxx/2);
		size2=maxx-(yyy/2);
//		if(size>size2){size=size2;}
		if(size<sizeval[i])size=sizeval[i];


			if(splitter%2==0){


				if(XY[0]<maxposition+distance && XY[0]>minposition-distance) {

					
					images[i].style.height  = size+"px";
/*					if(parseInt(images[i].style.height)<40){
						images[i].style.height = "40px";
						}*/
			
//					images[i].style.height = "auto";//sizeh+"px";					
					if(xxx<(distance/2)){
						if(texts[i]!=""){
	  						  lab=document.getElementById("products2label");
							  lab.innerHTML= texts[i];
							  lab.style.top = "0px";
							  lab.style.left= (position1-(lab.offsetWidth/2)-getL("products2")+1)+"px";
		//  					  document.getElementById("products2label").style.width=(size[i]);
							  lab.style.display="";			
						}else{
							  lab.style.display="none";
						}
					
					}

				}
				else{	
					reset();
				}
			}
	}
	splitter++;
//	alert("xxx="+xxx+"\nyyy="+yyy+"\ndis="+distance);
	
}

function reset() {
document.getElementById("products2label").style.display="none";
	for(i=0;i<numberofimages;i++){
		images[i].style.height= "";
//		images[i].style.height= "auto";// sizeval[i]+"px";
/*		document.getElementById(i).style.width=  sizeval;
		document.getElementById(i).style.height= sizeval;*/
	}
}

function getBodySize(){

  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {

    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myWidth  = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	x= new Array(myWidth, myHeight)
	return x;
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function windowLoad(){
//finding the images
var liall=document.getElementById("products2").childNodes;
for (k=0; k<liall.length; k++){
	if(liall[k].tagName=="SPAN"||liall[k].tagName=="span"){
		imagesall=liall[k].childNodes;
		for (i=0; i<imagesall.length; i++){
			if(imagesall[i].tagName=="A"||imagesall[i].tagName=="a"){
					titl=imagesall[i].title;
					if(titl!=""){												
						texts.push(titl);
					}else{
						texts.push("");
					}

					temparr=imagesall[i].childNodes;
					for(j=0;j<temparr.length;j++){
						if(temparr[j].tagName=="IMG"||temparr[j].tagName=="img"){
							images.push(temparr[j]);
							sizeval.push(parseInt(temparr[j].height))
//							39;						
							break;
						}
					}
			
				}
			}
	}
}
///////////////////
//document.getElementById("products2").style.width=(getBodySize()[0]-30)+"px";
//document.getElementById("products2").style.left=((1030-getBodySize()[0])/2)+"px";
if(IE){
	document.getElementById("products2").onmousemove=getMouseXY;
}else{
	document.onmousemove=getMouseXY;	
}
document.getElementById("products2").onmouseover=function(){menugo=true;};
document.getElementById("products2").onmouseout=function(){
	obj=document.getElementById("products2container");
	if (obj.offsetParent) {
		curtop = obj.offsetTop;		
		curleft= obj.offsetLeft;		
		while (obj = obj.offsetParent) {
			curtop += obj.offsetTop;	
			curleft+= obj.offsetLeft;					
		}
	}
	curtop=curtop-getScrollXY()[1] ;	
	if(XY[0]>curleft+990 || XY[0]<curleft+20 || XY[1]<curtop || XY[1]>=(curtop+40)){
		menugo=false;	
		if(IE){
		reset();	
		}
	}
};
//document.onmousemove=function(){

numberofimages=images.length; 	//images count	

}

window.onload= function(){
	if(document.getElementById("products2")!=null){
			try{windowLoad();}
			catch(e){}
	}
	}


