var ns = document.layers ? true : false;
var ie = document.all && !window.opera ? true : false;;    // IEs
var dom = document.getElementById && !ie ? true : false;  // DOM-Browser
var toggleOpen = new Array;

var gbloading = "<img src='images/loading_small2.gif' hspace='20' vspace='20' /><br />";

function warenkorbPos() {
/*	$('warenkorb_overlay').clonePosition($('warenkorb_position'));
	posy = parseInt($('warenkorb_overlay').style.top.replace("px",""));
	posx = parseInt($('warenkorb_overlay').style.left.replace("px",""));
	posx+=84;
	posy+=111;
	$('warenkorb_overlay').style.top = posy+"px";
	$('warenkorb_overlay').style.left = posx+"px";
	$('warenkorb_overlay').show();
	*/
}
function myScrollTo(container, element)
{
	container = $(container);
	element = $(element);
	var o=container.positionedOffset();
	var z=element.positionedOffset();
//	o1=o[1];
//	z1=z[1];
//	alert(o1 + " - " + z1 + typeof z);
//	alert(container.scrollTop+ ' new: ' +(parseInt(z[1])-parseInt(o[1])));
	
	container.scrollTop=(parseInt(z[1])-parseInt(o[1]));
	//alert(container.positionedOffset());
	//alert(element.positionedOffset());
	
	/*
	var x = element.x ? element.x : element.offsetLeft,
			y = element.y ? element.y : element.offsetTop;
	container.scrollLeft=x-(document.all?0:container.offsetLeft );
	container.scrollTop=y-(document.all?0:container.offsetTop);
	return element;*/
}
function changeFilter(eid,wert,pk){
	new Ajax.Request("ajax/changefilter.php?eid="+eid+"&wert="+escape(wert)+"&pk="+pk+"&search="+escape($('filter_search').value), {
		method: "get",
		onSuccess: function(t) {
			if($('hiddenDiv')) $('hiddenDiv').update(t.responseText);
		},
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		},
		evalScript: true,
		asynchronous: true
		}
	);
}
var prdOpen=false;
function togglePrdIndex(){
	nd(); // overlib ausblenden
	
	if(prdOpen) {
		//$('search_invisible').clonePosition($('search'),true,true,false,false);
		Effect.toggle('prdIndex','blind',{
					  afterFinish: showSelect
					  }); //,{duration:1.0, scaleX: true, scaleY: false, scaleFrom:100,scaleTo:0, scaleContent: true});
		/*$('search').toggle();
		$('search_invisible').toggle();*/
		//$('togglePrdi').update="&raquo;";
		prdOpen = false;
		var ph=$('inhalt_scroll').getHeight();
		$('prdIndex').setStyle({height:ph+'px'});
	} else {
		//$('search').clonePosition($('search_invisible'),true,true,false,false);
		//$('search').toggle();
		if(ie){
			$('prdIndex').setStyle({top:'153px',width:'950px'});
			$('prdIndex').show();
		}else{
		Effect.toggle('prdIndex','blind',{
					  beforeStart: hideSelect
					  }); //,{duration:1.0, scaleX: true, scaleY: false, scaleFrom:0,scaleTo:100, scaleContent: true});
		}
		prdOpen = true;
		var ph=$('inhalt_scroll').getHeight();
		$('prdIndex').setStyle({height:ph+'px'});
		
		/*$('search').toggle();
		$('search_invisible').toggle();*/
		//$('togglePrdi').update="&laquo;";
		//$('search_toggle_arrows').src="images/arrows_left.png";
		
	}	
}

function toggleHorizontal() {
	if(toggleHorizontal.arguments.length>0){
		var _l=toggleHorizontal.arguments[0];
		// herausfinden ob layer eingeblendet, oder nicht...
		//if($(_l)){
		if(toggleOpen[_l] === 'undefined') toggleOpen[_l]
		if(searchOpen) {
			//$('search_invisible').clonePosition($('search'),true,true,false,false);
			Effect.toggle('search','blindHor'); //,{duration:1.0, scaleX: true, scaleY: false, scaleFrom:100,scaleTo:0, scaleContent: true});
			/*$('search').toggle();
			$('search_invisible').toggle();*/
			$('search_toggle_arrows').src="images/arrows_right.png";
			searchOpen = false;
		} else {
			//$('search').clonePosition($('search_invisible'),true,true,false,false);
			//$('search').toggle();
			Effect.toggle('search','blindhor'); //,{duration:1.0, scaleX: true, scaleY: false, scaleFrom:0,scaleTo:100, scaleContent: true});
			searchOpen = true;
			/*$('search').toggle();
			$('search_invisible').toggle();*/
			$('search_toggle_arrows').src="images/arrows_left.png";
			
		}
	}
}

function openWK(step){
	window.location.href="?kat=14&step="+step;	
}

function loginPos() {
	var pos = $('image_right').positionedOffset();
	$('login_layer').style.top = pos[1]+84+"px";
	$('login_layer').style.left = pos[0]+100+"px";
}

function languagePos() {
	var lnpos = $('language_td').positionedOffset();
	var spos = $('language_layer').positionedOffset();
	$('language_div').style.top = lnpos[1]+spos[1]+18+"px";
	$('language_div').style.left = lnpos[0]+spos[0]+12+"px";
	$('language_div').style.width = $('language_td').getWidth()+"px";
	
}

function filterPos() {
	if($('filter_a') && $('filter_div')){
	var fpos = $('filter_a').positionedOffset();
	$('filter_div').style.top = fpos[1]+20+"px";
	$('filter_div').style.left = fpos[0]+"px";
	}
}

function sucheNavi() {
	horpos = $('horbar').positionedOffset();
	$('suche_navi').style.top = horpos[1]+"px";
	$('suche_navi').style.left = horpos[0]+$('horbar').getWidth()+"px";
}

function callOnLoad() {
	callOnResize();
}

function to_session(k,v){
	request('get','ajax/to_session.php?'+k+'='+v,'hiddenDiv');
}

function switchFH(id){
	if($("fhhead"+id)){
		ns=($("fhhead"+id).className.indexOf('off')>0?"on":"off");
		$("fhhead"+id).className="fhclass_"+ns;
		// hier könnte man noch was mit slide-effekten machen...
		if(ns=="on") $("fhdiv"+id).show();
		else $("fhdiv"+id).hide();
		to_session("fh_classes_"+id,ns);
	}
}

function callOnResize() {
	
	$('language_layer').setStyle({top:'40px',left:'458px'});
	$('language_layer').show();
	
	spos = $('search_pos').positionedOffset();
	if(ie && navigator.appVersion.search('MSIE 6')>0) spos[1]-=101;
	else spos[1]-=1;
	
	spos[0]-=264; // einrutschen

	$('suche_layer').setStyle({top:spos[1]+25+'px',left:spos[0]+'px'});
	$('suche_layer').show();
	scrollContent();
	languagePos();
	filterPos();
	if($('userdata')){
		var user_pos=$('navi2').cumulativeOffset();
		$('userdata').style.left=Math.floor(user_pos[0]+586)+"px";
		$('userdata').style.top =Math.floor(user_pos[1]-10)+"px";
	}
		
}

function scrollContent(){
	if($('inhalt_scroll')){
		var pgSz=getPageSize();
		var fspacer=185;
		
		pgs = (pgSz[3]-fspacer);
$('outer_scroll').style.height=pgs+"px";
		$('inhalt_scroll').style.height=pgs+"px";
		var sh=$('inhalt_scroll').getHeight();
		var sw=$('inhalt_scroll').getWidth();
		if(ie) var cor=67;
		else var cor=66;
		pscroll=true;
		if($('headerTabelle')){
			pscroll=false;
		}
	    if($('product_scroll')){
			if(pscroll){
				$('product_scroll').setStyle({height:(parseInt(sh)-cor)+'px',width:(parseInt(sw)-0)+'px'});
			}else{
				$('product_scroll').setStyle({height:'auto'});
			}
			
			if($('maincontent')){
				$('maincontent').setStyle({paddingLeft:'0px',width:'950px',paddingTop:'0px',paddingBottom:'0px'});	
			}
			if($('inhalt_scroll')){
				$('inhalt_scroll').setStyle({paddingLeft:'0px',width:'950px'});
			}
			if(pscroll){
				if(!ie)	$('product_scroll').setStyle({overflowY:'auto',overflowX:'hidden'});
				else $('product_scroll').setStyle({overflow:'auto'});
				$('maincontent').setStyle({overflow:'hidden'});
				
				$('inhalt_scroll').setStyle({overflow:'hidden'});
				
			}else{

				if(ie) $('product_scroll').setStyle({overflowY:'hidden',overflowX:'hidden',width:(parseInt(sw)-0)+'px'});
				else $('product_scroll').setStyle({overflow:'hidden',width:(parseInt(sw)-0)+'px'});

				$('maincontent').setStyle({overflow:'hidden'});
			
				if(!ie) $('inhalt_scroll').setStyle({overflow:'auto',overflowX:'hidden'});
				else  $('inhalt_scroll').setStyle({overflow:'auto'});
			}
		} else if($('service_div')) {
			if($('maincontent')) $('maincontent').setStyle({overflow:'hidden',paddingLeft:'70px',width:'880px',paddingTop:'10px',paddingBottom:'0px'});

			if(!ie) if($('inhalt_scroll')) $('inhalt_scroll').setStyle({overflowY:'auto',overflowX:'hidden',paddingLeft:'0px',width:'950px'});
			else if($('inhalt_scroll')) $('inhalt_scroll').setStyle({overflow:'hidden',paddingLeft:'0px',width:'950px'});

		} else if($('rollvorhang_div')) {
			if($('maincontent')) $('maincontent').setStyle({overflow:'hidden',paddingLeft:'60px',width:'890px',paddingTop:'0px',paddingBottom:'0px'});

			if(!ie) if($('inhalt_scroll')) $('inhalt_scroll').setStyle({overflowY:'none',overflowX:'hidden',paddingLeft:'0px',width:'950px'});
			else if($('inhalt_scroll')) $('inhalt_scroll').setStyle({overflow:'hidden',paddingLeft:'0px',width:'950px'});

		} else if($('news_div')) {
			var dHeight = document.viewport.getHeight();
			if($('maincontent')) $('maincontent').setStyle({overflow:'hidden',paddingLeft:'60px',width:'890px',paddingTop:'0px',paddingBottom:'0px'});

			if(!ie) if($('inhalt_scroll') && dHeight < 825 ) $('inhalt_scroll').setStyle({overflowY:'none',overflowX:'hidden',paddingLeft:'0px',width:'950px'});
			else if($('inhalt_scroll') && dHeight < 825 ) $('inhalt_scroll').setStyle({overflow:'hidden',paddingLeft:'0px',width:'950px'});

		} else{
			if(!ie){
				if($('maincontent')) $('maincontent').setStyle({overflowY:'auto',overflowX:'hidden',paddingLeft:'70px',width:'860px',paddingTop:'10px',paddingBottom:'10px'});
			} else {
				if($('maincontent')) $('maincontent').setStyle({overflow:'hidden',paddingLeft:'70px',width:'860px',paddingTop:'10px',paddingBottom:'10px'});
			}
			if(!ie){
				if($('inhalt_scroll')) $('inhalt_scroll').setStyle({overflowY:'auto',overflowX:'hidden',width:'950px'});
			}else{
				if($('inhalt_scroll')) $('inhalt_scroll').setStyle({overflow:'scroll',width:'950px'});
			}
		}
	}
}

function request(method,url,ziel,postform,loadingani,newserialize){
	if($(loadingani)) $(loadingani).show();
	if(method=='post' || method=='POST'){
		//alert(postform);
		if(newserialize) var pbody=$(postform).serialize(true);
		var pbody=$(postform).serialize();
	}else var pbody="";
	new Ajax.Request(url, {
		method: method,
		postBody: pbody,
		onSuccess: function(t) {
			$(ziel).update(t.responseText);
			if($(loadingani)) $(loadingani).hide();
			$('loading_overlay').hide();
			showSelect();
		},
		onFailure: function(t) {
			$(ziel).update('Error ' + t.status + ' -- ' + t.statusText);
			if($(loadingani)) $(loadingani).hide();
			$('loading_overlay').hide();
			showSelect();
		},
		evalScript: true,
		asynchronous: true
		}
	);
	window.setTimeout("callOnLoad();",500);
}

function doAjax(method,url,ziel,postform,loadingani,newserialize){
	
	if($(loadingani)) {
	 
	} else {
		if(ziel == "maincontent") lziel = "inhalt_scroll";
		else lziel = ziel;
		
		var posmc1 = $(lziel).positionedOffset();
		var wmc1 = $(lziel).getWidth();
		var hmc1 = $(lziel).getHeight();
		
		
		$('loading_overlay').style.left = posmc1[0]+'px';
		$('loading_overlay').style.top = posmc1[1]+'px';
		$('loading_overlay').style.width = wmc1+'px';
		$('loading_overlay').style.height = hmc1+'px';
		$('loading_overlay').show();
		
		hideSelect();
	}
	
	if(prdOpen == true) {
		togglePrdIndex();
	}
	
//alert("request('"+method+"','"+url+"','"+ziel+"','"+postform+"',"+newserialize+")");
	var ajaxString=escapeTxt("request('"+method+"','"+url+"','"+ziel+"','"+postform+"','"+loadingani+"',"+newserialize+")");
	if($('hiddenFrame')){
		$('hiddenFrame').src='history.php?request='+ajaxString;
		//alert("OK");
	}
/*
	if(method=='post' || method=='POST'){
		if(newserialize) var pbody=postform.serialize(true);
		var pbody=postform.serialize();
	}else var pbody="";
	new Ajax.Request(url, {
		method: method,
		postBody: pbody,
		onSuccess: function(t) {
			$(ziel).update(t.responseText);
		},
		onFailure: function(t) {
			$(ziel).update('Error ' + t.status + ' -- ' + t.statusText);
		},
		evalScript: true,
		asynchronous: true
		}
	);
	*/
}

var lastElement1;
var lastElement2;
var intV;
var curX;
/*function clipIntervalRtL(element1,element2,cur){
	//alert(clipIntervalRtL.arguments[3]);
	lastElement1=element1;
	lastElement2=element2;
	if(cur<element1.getWidth() && element2){
		element2.makeClipping().setStyle({width:cur+'px'});
		var newLeft=parseInt(element1.getWidth())-parseInt(cur);
		element2.setStyle({left:newLeft+'px'});
		$('positioner').update(cur);
		//alert(newLeft);
		// var pos=parseInt(element1.getStyle('left'));
		window.setTimeout("clipIntervalRtL(lastElement1,lastElement2,"+parseInt(cur+5)+");",1);
	}else if(element2) {
		element1.update(element2.innerHTML);
		element2.hide();
		element2.undoClipping();
		element2.update("");
	}
		
}

function flipLayers(element1,element2){
	if(element1 && element2){
		element1.absolutize();
		element2.absolutize();
		element2.clonePosition(element1,true,true,true,true);
		element2.makeClipping().setStyle({width:'0px',height:'100%'});
		element2.show();
		clipIntervalRtL(element1,element2,0);
//$('search_invisible').clonePosition($('search'),true,true,false,false);
	}
}
*/
function products(kat){
	if(products.arguments.length>1) var pst="&sub="+products.arguments[1];
	else var pst="";
	if(products.arguments.length>2) var highlight="&highlightno="+products.arguments[2];
	else var highlight="";
	//Effect.toggle('maincontent','blind');
	
	if($('maincontent')){
		doAjax('get','ajax/products.php?kat='+kat+pst+highlight,'maincontent','',false,false);
		
	}
	
	nd();
	/*
	var posmc1 = $('maincontent').positionedOffset();
	var wmc1 = $('maincontent').getWidth();
	var hmc1 = $('maincontent').getHeight();
	
	
	$('maincontent3').style.left = posmc1[0]+'px';
	$('maincontent3').style.top = posmc1[1]+'px';
	$('maincontent3').style.width = wmc1+'px';
	$('maincontent3').style.height = hmc1+'px';
	
	 new Effect.Opacity('maincontent3', {duration:3, from:0.0, to:0.99,
						beforeStart: function() {
							$('maincontent3').show();	
						}});
	 */
	/*
	$('maincontent2').style.left = wmc1+'px';
	
	$('maincontent3').show();
	
	
	
	$('maincontent3').makeClipping().setStyle({width: 800+'px', height: 500+'px'});
	
	new Effect.Move('maincontent2', {x: wmc1*(-1), y: 0, mode: 'relative', duration: 3,
											  afterFinish: function() {
												$('maincontent3').undoClipping(); 
												//$('maincontent3').style.overflow = 'auto';
												$('maincontent3').style.width = wmc1+'px';
												$('maincontent3').style.height = hmc1+'px';
											  }});
	*/
	
	//flipLayers($('maincontent'),$('maincontent2'));
	//$('maincontent2').show();
//	$('maincontent2').morph('width:100%;');
	//$('maincontent2').SlideRightIntoView();
	
	//Effect.BlindUpFromRight('maincontent2');
		//Effect.toggle('maincontent2','blindr');
	//Effect.BlindDownFromRight('maincontent');

//	new Effect.ReSize($('maincontent2'), {direction:'hor', amount:-150});
	
	//$('maincontent').update($('maincontent2').innerHTML);
	//$('maincontent2').hide();
	//$('maincontent2').update("");
	//$('maincontent2').setStyle({left:$('maincontent').getWidth()});
	//$('maincontent2').show();
	//$('maincontent2').Scale(100);
/*	for(var s=0;s<101;s++){
		$('maincontent2').makeClipping().setStyle({width: s+'%'});	
	}
	//Effect.BlindRight('maincontent2');
	$('maincontent').update($('maincontent2').innerHTML);
	$('maincontent2').hide();
	$('maincontent2').update("");
	$('maincontent2').makeClipping().setStyle({width:'0%'});*/
}

function getWinSize(){
    win = window;
    var pos = {x:0,y:0};
    if(typeof win.innerWidth != 'undefined'){
        pos.w = win.innerWidth;
        pos.h = win.innerHeight;
    }else if(win.document.body){
       pos.w = parseInt(win.document.body.clientWidth);
       pos.h = parseInt(win.document.body.clientHeight);
    }
    return pos;
}
var winSize=getWinSize();

function escapeTxt(os){
var ns='';
var t;
var chr='';
var cc='';
var tn='';
for(i=0;i<256;i++){
tn=i.toString(16);
if(tn.length<2)tn="0"+tn;
cc+=tn;
chr+=unescape('%'+tn);
}
cc=cc.toUpperCase();
os.replace(String.fromCharCode(13)+'',"%13");
for(q=0;q<os.length;q++){
t=os.substr(q,1);
for(i=0;i<chr.length;i++){
if(t==chr.substr(i,1)){
t=t.replace(chr.substr(i,1),"%"+cc.substr(i*2,2));
i=chr.length;
}}
ns+=t;
}
return ns;
}

function getArt(gid){
	if(gid>0){
		var pBody=$('eigform'+gid).serialize();
		if($('eig2form'+gid)) pBody=pBody+"&"+$('eig2form'+gid).serialize();
		if($('eig3form'+gid)) pBody=pBody+"&"+$('eig3form'+gid).serialize();
		pBody=pBody+"&gid="+gid;
	}
	else var pBody="";
	new Ajax.Request('../ajax/eigenschaften2art.php',
	{
		method: 'post',
		postBody: pBody,
		asynchronous: true,
		evalScript: true,
		onComplete: function(t) {
		  // $('loading'+gid).hide();	
		   $('ajaxlayer').update(t.responseText);
		  // alert(t.responseText);
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}		
	}
	);	
}

function updateImage(targetImage,fileRequest,w,h){
	if(targetImage){
		//
		// loadingLayer > cloneposition von targetImage
		// laden anzeigen
		// wenn bild da ist, ersetzen und laden ausblenden
		// wenn nicht, fehler?
		if($('loadingLayer')){
			with($('loadingLayer')){
				clonePosition(targetImage);
				update("<img src='images/loading.gif'><img src='images/loading_font.gif'>");
				show();
			}
		}
		new Ajax.Request('../ajax/makeThumb.php?f='+fileRequest+'&w='+w+'&h='+h,
		{
			method: 'get',
			asynchronous: true,
			evalScript: true,
			onComplete: function(t) {
			  // $('loading'+gid).hide();	
			   targetImage.src=t.responseText;
			   $('loadingLayer').hide();
			  // alert(t.responseText);
			},
			// Handle other errors
			onFailure: function(t) {
				alert('Error ' + t.status + ' -- ' + t.statusText);
				$('loadingLayer').hide();
			}		
		}
		);	
	}
}
function add2wk(form){
	new Ajax.Request('ajax/warenkorb.php',
		{
			method: 'post',
			postBody: 'action=add&'+form.serialize(),
			asynchronous: true,
			evalScript: true,
			onComplete: function(t) {
			//alert(t.responseText);
			   userdata(t.responseText);
			   //alert(t.responseText);
			},
			// Handle other errors
			onFailure: function(t) {
				alert('Error ' + t.status + ' -- ' + t.statusText);
			}		
		}
	);
}
function number_format (zahl,decimal_num,dec_point,mill_sep) {
  var sign = '';
  if(zahl < 0) {sign = '-';}
  zahl = Math.abs(zahl);
  var divisor = 1;
  for(var i = 0; i < decimal_num; i++) {zahl *= 10; divisor *= 10;}
  zahl = Math.floor(zahl);
  var decimals= zahl % divisor;
  decimals = '' + decimals;
  for(var i = 0; i < decimal_num; i++) {zahl /= 10;}
  zahl = Math.floor(zahl);
  zahl = '' + zahl;
  zahl_grp = '';
  
  while(zahl.length > 3) {
    zahl_grp = mill_sep + zahl.substr(zahl.length-3,3) + zahl_grp;
    zahl = zahl.substr(0,zahl.length-3);
  }
  var str = zahl + zahl_grp;
  if(decimal_num > 0) {
    str = str + dec_point;
	//alert(decimals.length + " - " + decimal_num);
    //while(decimals.length != decimal_num) {decimals= decimals+ '0';}
	while(decimals.length < decimal_num) {decimals+='0';}
    str = str + decimals
  }
  return sign + str;
}
function openLogin() {
	showGrayBox();
	$('gray_box_content').update(gbloading);
	new Ajax.Request('modules_gb/login.php',
	{
		method: 'get',
		asynchronous: true,
		evalScript: true,
		onComplete: function(t) {	
		   $('gray_box_content').update(t.responseText);
		   center('gray_box');
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}		
	}
	);
}

function myaccount() {
	showGrayBox();
	$('gray_box_content').update(gbloading);
	new Ajax.Request('modules_gb/myaccount.php',
	{
		method: 'get',
		asynchronous: true,
		evalScript: true,
		onComplete: function(t) {	
		   $('gray_box_content').update(t.responseText);
		   center('gray_box');
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}		
	}
	);
}


function logout(){
	userdata("&logout=true");	
}

function userdata(){
	var typus = "";
	if($('userdata')){
		if(userdata.arguments.length>0){
			var pBody="&message="+userdata.arguments[0];
		}
		else if($('loginform')){
			var pBody=$('loginform').serialize();
			typus = "login";
		}	else if(userdata.arguments[0]) {
			var pBody="highlight="+userdata.arguments[0];
		}
		
		else var pBody="";
		new Ajax.Request('ajax/userdata.php',
		{
			method: 'post',
			postBody: pBody,
			asynchronous: true,
			evalScript: true,
			onComplete: function(t) {
				if(typus == "login") $('login_result').update(t.responseText);
				else $('userdata').update(t.responseText);
			},
			onFailure: function(t) {
				$('userdata').update('Error '+t.status+' -- '+t.statusText);
			}
		}
		);	
	}
}
var udatatimeout;
function userdata_message(msg){
	//alert(msg);
	if(udatatimeout) window.clearTimeout(udatatimeout);
	var ud_pos=$('userdata').cumulativeOffset();
	//alert(ud_pos);
	$('userdata_message').style.top=Math.floor(ud_pos[1]+37)+"px";
	$('userdata_message').style.left=ud_pos[0]+"px";
	var oldBorder=$('userdata').style.borderBottom;
	//alert(oldBorder);
	$('userdata').style.borderBottomStyle='none';
	//$('userdata_message').style.width=$('userdata').getWidth()+"px";o
	//$('userdata_message').clonePosition($('userdata'), true, true, false, 21);
	//alert($('userdata_message').cumulativeOffset());
	
	//$('userdata_message').show();
	//var or_pos=$('wkimg'+art).cumulativeOffset();
	//$('wkbox'+art).style.left=(or_pos[0]-158)+"px";
	
	//
	// effect slide funzt nicht...position TOP ok...
	//
	
	//$('userdata_message').show();
	//alert($('userdata_message') + '\n' + $('userdata_message').style.display)
	$('userdata_message').update("<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr><td align='left'><div>"+Base64.decode(msg)+"</div></td></tr></table>");
	//Effect.toggle('userdata_message');
	Effect.SlideDown('userdata_message',{
	 duration:1,
	 afterFinish: function(){ 
	 udatatimeout=window.setTimeout("userdata_messageUP();",5000);
	 udataborder=window.setTimeout("$('userdata').style.borderBottom='"+oldBorder+"';",6000);
	 
	 }
	 }
	 );
}
function userdata_messageUP(){
	//Effect.toggle('userdata_message');
	Effect.SlideUp('userdata_message');
}

function openLanguageLayer() {
	showLanguage();
}

var languageAktiv = false;
var languageTimeout;
/*
function showLanguage() {	

	//$('language_div').setStyle({position:'absolute',zIndex:'200',top:'80px',left:'500px'});
		
	if(languageAktiv == false) {
		window.clearTimeout(languageTimeout);
		$('language_div').show();
		Effect.toggle('language_inner','slide', {duration: 0.5});
		languageTimeout=window.setTimeout("language_inner = true;",500);
	} else {
		window.clearTimeout(languageTimeout);
		Effect.toggle('language_inner','slide', {duration: 0.5, afterFinish: language_inner});
		languageTimeout=window.setTimeout("language_inner = false;",500);
	}
}

function hideLanguage() {
	$('language_div').hide();
}
*/
function openSucheLayer() {
	showSuche();
}

function searchSite(offset) {
	if(searchSite.arguments.length==1) fx=true;
	else fx=false;
	
	doAjax('get','modinclude.php?kat=28&offset='+offset+'&search='+Base64.encode($('search').value),'maincontent');
	if(offset == -1) {
		if(fx){
			Effect.toggle('suche_inner','slide', {duration: 0.5, afterFinish: hideSuche});
			sucheAktiv = false;
		}
	}
	
	/*
	new Ajax.Request('ajax/searchToSession.php?search='+Base64.encode($('search').value),
	{
		method: 'get',
		asynchronous: true,
		evalScript: true,
		onComplete: function(t) {	
		   //loadModule(10, '&offset='+offset);
		   doAjax('get','modinclude.php?kat=28&offset='+offset,'maincontent');
		   $('maincontent').update(t.responseText);
			if(offset == -1) {
				if(fx){
					Effect.toggle('suche_inner','slide', {duration: 0.5, afterFinish: hideSuche});
					sucheAktiv = false;
				}
			}
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}		
	}
	);
	*/
	
}

var sucheAktiv = false;
var sucheTimeout;

function showSuche() {	
	if(sucheAktiv == false) {
		window.clearTimeout(sucheTimeout);
		$('suche_layer').show();
		Effect.toggle('suche_inner','slide', {duration: 0.5});
		sucheTimeout=window.setTimeout("sucheAktiv = true;",500);
	} else {
		window.clearTimeout(sucheTimeout);
		Effect.toggle('suche_inner','slide', {duration: 0.5, afterFinish: hideSuche});
		sucheTimeout=window.setTimeout("sucheAktiv = false;",500);
	}
}

function hideSuche() {
	$('suche_layer').hide();
}

function pwVergessen() {
	$('gray_box_content').innerHTML = gbloading;
	new Ajax.Request('modules_gb/lostpw.php',
	{
		method: 'get',
		asynchronous: true,
		evalScript: true,
		onComplete: function(t) {	
		   $('gray_box_content').update(t.responseText);
		   center('gray_box');
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}		
	}
	);
}

function changepw() {
	$('gray_box_content').innerHTML = gbloading;
	new Ajax.Request('modules_gb/changepw.php',
	{
		method: 'get',
		asynchronous: true,
		evalScript: true,
		onComplete: function(t) {	
		   $('gray_box_content').update(t.responseText);
		   window.setTimeout("center('gray_box');", 100);
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}		
	}
	);
}

function openLanguageLayer() {
	showLanguage();
}

var languageAktiv = false;
var languageTimeout;

function showLanguage() {	
if(ie) $('language_div').setStyle({position:'absolute',zIndex:'200',top:'55px',left:'480px'});
		
	if(languageAktiv == false) {
		window.clearTimeout(languageTimeout);
		$('language_div').show();
		Effect.toggle('language_inner','slide', {duration: 0.5});
		//languageTimeout=window.setTimeout("language_inner = true;",500);
		languageTimeout=window.setTimeout("languageAktiv = true;",500);
	} else {
		window.clearTimeout(languageTimeout);
		Effect.toggle('language_inner','slide', {duration: 0.5, afterFinish: hideLanguage});
		//languageTimeout=window.setTimeout("language_inner = false;",500);
		languageTimeout=window.setTimeout("languageAktiv = false;",500);
	}
}

function hideLanguage() {
	$('language_div').hide();
}

function openFilterLayer() {
	showFilter();
}

var filterAktiv = false;
var filterTimeout;

function showFilter() {	
	if(filterAktiv == false) {
		window.clearTimeout(filterTimeout);
		$('filter_div').show();
		Effect.toggle('filter_inner','slide', {duration: 0.5});
		//languageTimeout=window.setTimeout("language_inner = true;",500);
		filterTimeout=window.setTimeout("filterAktiv = true;",500);
	} else {
		window.clearTimeout(filterTimeout);
		Effect.toggle('filter_inner','slide', {duration: 0.5, afterFinish: hideFilter});
		//languageTimeout=window.setTimeout("language_inner = false;",500);
		filterTimeout=window.setTimeout("filterAktiv = false;",500);
	}
}

function hideFilter() {
	$('filter_div').hide();
}

function swap(id) {
	if($('p_'+id).visible()) {
		$('p_'+id).hide();
		$('i_'+id).show();	
	} else {
		$('i_'+id).hide();
		$('p_'+id).show();
	}
}

function hideLanguageSuche() {
	if(languageAktiv == true) openLanguageLayer();
	if(sucheAktiv == true) openSucheLayer();
	if(filterAktiv == true) openFilterLayer();
}

function selectAdienst(id,m) {
	if(m == "out") {
		$('adienst_'+id).setStyle({backgroundColor: '#b9c5dd',color: '#2c2c2c'});
	} else {
		$('adienst_'+id).setStyle({backgroundColor: '#738bbb',color: 'white'});
	}
}

function loadFilter(id) {
	new Ajax.Request('ajax/filter_content.php?id='+id,
	{
		method: 'get',
		asynchronous: true,
		evalScript: true,
		onComplete: function(t) {	
		   $('filter_content').update(t.responseText);
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}		
	}
	);
}

function saveFilter(id) {
	new Ajax.Request('ajax/artikel_filtern.php?id='+id,
	{
		method: 'post',
		asynchronous: true,
		evalScript: true,
		postBody: $('form_filter').serialize(),
		onComplete: function(t) {	
		   $('filter_result').update(t.responseText);
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}		
	}
	);	
}

function deleteFilter(id) {
	new Ajax.Request('ajax/artikel_filtern.php?id='+id+'&delete=true',
	{
		method: 'get',
		asynchronous: true,
		evalScript: true,
		onComplete: function(t) {	
		   $('filter_result').update(t.responseText);
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}		
	}
	);	
}

function produktTipp(artikel) {
	showGrayBox();
	$('gray_box_content').innerHTML = "<div align='center'>"+gbloading+"</div>";
	new Ajax.Request('modules_gb/produkt_tipp.php?artikel='+artikel,
	{
		method: 'get',
		asynchronous: true,
		evalScript: true,
		onComplete: function(t) {	
		   $('gray_box_content').update(t.responseText);
		   center('gray_box');
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}		
	}
	);
}

function updateGBTitle(title){
	var url = "../ajax/gb_title.php?text="+title;
	new Ajax.Request(url,
		{
			method: 'get',
			asynchronous: true,
			evalScript: true,
			onComplete: function(t) {	
			   $('title').update(t.responseText);
			},
			// Handle other errors
			onFailure: function(t) {
				alert('Error ' + t.status + ' -- ' + t.statusText);
			}		
		}
		);
}

function showNewsDetails(nid,title){
	if(title == undefined) title = "News";
	var url = "../modules_gb/news.php?id="+nid;
	new Ajax.Request(url,
		{
			method: 'get',
			asynchronous: true,
			evalScript: true,
			onComplete: function(t) {	
			   $('gb_content').update(t.responseText);
			   updateGBTitle(title);
			   showGBv();
			},
			// Handle other errors
			onFailure: function(t) {
				alert('Error ' + t.status + ' -- ' + t.statusText);
			}		
		}
		);
}


function checkland(e){
	if(e.value == "DE") $('bundesland').show();
	else $('bundesland').hide();
}

function startVoting(step){
	var opengb = (step == undefined) ? true : false;
	var step = ((step == undefined) ? "0" : step );
	var form = "form_"+step;
	var url = '../modules_gb/vote.php?step='+step;
	if(step == "0"){
		new Ajax.Request(url,
		{
			method: 'get',
			asynchronous: true,
			evalScript: true,
			onComplete: function(t) {	
			   $('gb_content').update(t.responseText);
			   updateGBTitle("kundenumfrage")
			   if(opengb) showGBv();
			},
			// Handle other errors
			onFailure: function(t) {
				alert('Error ' + t.status + ' -- ' + t.statusText);
			}		
		}
		);
	}else{
		new Ajax.Request(url,
		{
			method: 'post',
			asynchronous: true,
			evalScript: true,
			postBody: $(form).serialize(),
			onComplete: function(t) {
			   	$('gb_content').update(t.responseText);
			   	//center('gb');
			},
			// Handle other errors
			onFailure: function(t) {
				alert('Error ' + t.status + ' -- ' + t.statusText);
			}		
		}
		);
	}
}
function voteBack(step){
	var st = step - 1;
	var url = '../modules_gb/vote.php?step='+st;
	new Ajax.Request(url,
		{
			method: 'post',
			asynchronous: true,
			evalScript: true,
			pBody: 'form_'+step+1,
			onComplete: function(t) {	
			   $('gb_content').update(t.responseText);
			   //center('gb');
			  // showGBv();
			},
			// Handle other errors
			onFailure: function(t) {
				alert('Error ' + t.status + ' -- ' + t.statusText);
			}		
		}
		);
}