
function print_hdr(artc){
	itm(artc);
	document.write(''+
		'<div id="main_cnt">'+
		'<div id="hdr">'+
		'	<a id="logo" href="javascript:cle(\'N-\')"></a>'+
		'</div>'+
		'<div id="subcnt">'+
		'<div id="rcol">'+
		'');
}
var art;
function itm(artc){
	var src='573541C573S573542CL90PPV';
	artc=artc?artc:'0';
	art=artc;
	var matchval=new RegExp(/\/angebote\/$/i);
	var loc=window.location.href;
	if(loc.search(matchval)>0) artc='000';
	var ssl = "687474703A2F2F73736C2E68757272612E64652F547261636B4974";
	var adr = '';
	for(var i=0; i<ssl.length; i=i+2) adr+=String.fromCharCode(parseInt(ssl.substring(i,i+2),16));
	document.write('<img src="'+adr+'?tid='+src+'&pd='+artc+'&ref=[[' + document.referrer + ']]&src=[[' + document.location + ']]" alt="" border="0" width="1" height="1" style="position: absolute; top:-20; left: -20;">');
}

function print_ftr(){
	document.write(''+
	'</div>'+
	'<div id="lcol">'+
		'<ul>'+
		'<li><a href="javascript:cle(\'NV\')">Herren-Mode</a></li>'+
		'<li><a href="javascript:cle(\'NK\')">Damen-Mode</a></li>'+
		'<li><a href="javascript:cle(\'NP\')">Klepper-Shop</a></li>'+
		//'<li><a href="javascript:cle(\'NQ\')">Komplettangebote</a></li>'+
		'<li><a href="javascript:cle(\'NU\')">Reduzierte Angebote</a></li>'+
		'</ul>'+
		'<iframe frameborder="0" border="0" src="/angebote/x0ojmQ/direktbestellung.html" scrolling="no"></iframe>'+
		'<ul>'+
		'<li><a href="javascript:cle(\'NR\')">Service & Hilfe</a></li>'+
		'<li><a href="javascript:cle(\'NO\')">Kontakt</a></li>'+
		'<li><a href="javascript:cle(\'NT\')">Filialen & Hotelverkauf</a></li>'+
		'<li><a href="javascript:cle(\'NL\')">Über Walbusch</a></li>'+
		'</ul>'+
	'</div>'+
	'<div id="lcolbt"></div>'+
	'<div class="cl"></div>'+
	'</div>'+
	'<div id="footer">'+
		'<div id="bvh"></div>'+
		'<div id="ftr_lnks">'+
		'<a href="javascript:cle(\'NO\')">Kontakt</a> | '+
		'<a href="javascript:cle(\'NN\')">Newsletter</a> | '+
		'<a href="javascript:cle(\'NT\')">Filialen</a> | '+
		'<a href="javascript:cle(\'NW\')">Presse-Service</a> | '+
		'<a href="javascript:cle(\'NS\')">Impressum</a> | '+
		'<a href="javascript:cle(\'NX\')">AGB</a> | '+
		'<a href="javascript:cle(\'NM\')">Datenschutz</a> | '+
		'<a href="javascript:cle(\'NZ\')">Anbieterkennzeichnung</a> | '+
		'<a href="javascript:cle(\'NY\')">Seitenübersicht</a><br>'+
		'Preise inkl. gesetzlicher MwSt, zzgl. Versandkosten'+
		'</div>'+
		'<div id="ftr_sgn">'+
		'Walbusch Walter Busch GmbH & Co. KG, 42646 Solingen'+
		'</div>'+
	'</div>'+
	'</div>'+
	'');
}



function rdl(){
	var o = document.getElementById('e404go');
	if(o) {o.innerHTML = '<a href="javascript:cle(\'Ez\')">'+o.innerHTML+'</a>';}
}

function cl(par,ac,mc){
	var f = top.frames[0].document.forms[0];
	var o = top.frames[0].document.getElementById('2bV-');
	o.value = par;
	f.pd.value = ac;
	if(mc) f.mc.value = mc;
	f.submit();
}

function cle(par,mc){
	cl(par,dac,mc);
}

function rlnks(){
	var ims = document.images;
	for(var i=0; i<ims.length; i++){
		if(ims[i].id && ims[i].id.search(/rpit/)!==-1){
			var prs = ims[i].id.split('|');
			var lnk = 'javascript:cl(\''+prs[1]+'\',\''+prs[2]+'\''+(prs[3]?','+prs[3]:'')+')';
			ims[i].parentNode.href = lnk;
			ims[i-1].parentNode.href = lnk;
		}
		if(ims[i].id && ims[i].id.search(/bpit/)!==-1){
			var prs = ims[i].id.split('|');
			var lnk = 'javascript:cl(\''+prs[1]+'\',\''+prs[2]+'\''+(prs[3]?','+prs[3]:'')+')';
			ims[i].parentNode.href = lnk;
			ims[i-1].parentNode.href = lnk;
		}
	}
}
function init(){
	print_ftr();
	rlnks();
	fixImages();
	PSi.init();
	SFX.init();
	_SBox = new SBox();
	rdl();
}
function fixImages(){
	var pims = $$('.fmib');
	pims.each(function(i){i.addEvent('error',function(){this.src='/angebote/x0ojmQ/null.gif';});});
}
var PSi = new Object({
	options:{
		elems:'.price',
		excludeClasses:['price'],
		configs:{
			global:{hsep:'', dsep:',', nozeros:false, zeroprice:false,zeros:false,fillzeros:true}
		}
	},
	init:function(){
		this.getElems();
		this.processElems();
	},
	getElems:function(){
		this.elems = $$(this.options.elems);
		this.maxelem = this.elems.length;
	},
	processElems:function(){
		this.ci = 0;
		for(this.ci;this.ci<this.maxelem;this.ci++){ this.getCC(); }
	},
	combineOptions:function(){
		this.config = this.options.configs.global;
		if(this.options.configs[this.cecns]){ for(this.copti in this.options.configs[this.cecns]) this.config[this.copti] = this.options.configs[this.cecns][this.copti]; }
	},
	getCC:function(){
		this.cecns = this.elems[this.ci].className.replace(new RegExp('\\s?('+this.options.excludeClasses.join('|')+')\\s?','g'),'');
		this.combineOptions();
		this.ceprefix = this.elems[this.ci].getElements('.prefix');
		for(this.cepi=0;this.cepi<this.ceprefix.length;this.cepi++) this.ceprefix[this.cepi].parentNode.removeChild(this.ceprefix[this.cepi]);
		this.cesuffix = this.elems[this.ci].getElements('.suffix');
		for(this.cepi=0;this.cepi<this.cesuffix.length;this.cepi++) this.cesuffix[this.cepi].parentNode.removeChild(this.cesuffix[this.cepi]);
		this.ceprice = this.elems[this.ci].innerHTML;
		this.ceprice = this.ceprice.replace(/-/,'00').replace(/,/,'.').replace(/\s+/,'');
		this.cepparts = this.ceprice.split('.');
		if(!this.cepparts[1]) this.cepparts[1] = this.config.fillzeros ? '00'  : '';
		if(this.config.fillzeros && this.cepparts[1].length<2) this.cepparts[1] = parseInt(this.cepparts[1],10).toPrecision(2).toString().replace(/\.|,/,'');
		if(parseFloat(this.ceprice)==0){
			if(this.config.zeroprice){ this.elems[this.ci].innerHTML = this.config.zeroprice; return; }
			if(this.config.nozeros){ this.retNoZeros();	return; }
			if(this.config.zeros){ this.retZeros(); return; }
		}
		if(this.config.hsep && this.cepparts[0].length>3){
			while(this.cepparts[0].search(/^\d{4}/)>-1){ this.cepparts[0] = this.cepparts[0].replace(/(.*?)(\d{3}(?:$|,))/,"$1"+this.config.hsep+"$2"); }
		}
		if(!parseInt(this.cepparts[1]) && this.config.nozeros){ this.retNoZeros(); return; }
		if(!parseInt(this.cepparts[1]) && this.config.zeros){ this.retZeros(); return; }
		this.retDefault();
		return;
	},
	retNoZeros:function(){
		this.elems[this.ci].innerHTML = this.cepparts[0] + (!parseInt(this.cepparts[1]) ? '' : this.config.dsep + this.cepparts[1] );
		if(this.ceprefix[0]) this.elems[this.ci].insertBefore(this.ceprefix[0],this.elems[this.ci].firstChild);
		if(this.cesuffix[0]) this.elems[this.ci].appendChild(this.cesuffix[0]);
	},
	retZeros:function(){
		this.elems[this.ci].innerHTML = this.cepparts[0] + (!parseInt(this.cepparts[1]) ? this.config.zeros : this.config.dsep + this.cepparts[1] );
		if(this.ceprefix[0]) this.elems[this.ci].insertBefore(this.ceprefix[0],this.elems[this.ci].firstChild);
		if(this.cesuffix[0]) this.elems[this.ci].appendChild(this.cesuffix[0]);
	},
	retDefault:function(){
		this.elems[this.ci].innerHTML = this.cepparts[0] + this.config.dsep + this.cepparts[1];
		if(this.ceprefix[0]) this.elems[this.ci].insertBefore(this.ceprefix[0],this.elems[this.ci].firstChild);
		if(this.cesuffix[0]) this.elems[this.ci].appendChild(this.cesuffix[0]);
	}
});

var SFX = new Object({
	options:{
		elems:[
			{container: 'div#p40_container ul',stepby:2,rmifempty:false},
			{container: 'div#lrbp div.lrbpi',stepby:1,rmifempty:function(){if($('lrbp')){$('lrbp').getPrevious('.uni_hdr').dispose();$('lrbp').dispose();}}}
		]
	},
	init:function(){
		this.navi = [];
		this.checkSite();
	},
	checkSite:function(){
		for(this.cei=0;this.cei<this.options.elems.length;this.cei++){
			this.ce = $$(this.options.elems[this.cei].container);
			if(this.ce.length>0 && this.ce[0].getChildren().length) {this.ce = this.ce[0]; this.processCE();}
			else if(this.options.elems[this.cei].rmifempty && $type(this.options.elems[this.cei].rmifempty)=='function') this.options.elems[this.cei].rmifempty();
		}
	},
	processCE:function(){
		this.pushNavi();
		this.setDims();
		this.wrapElems();
	},
	pushNavi:function(){
		this.navi[this.cei] = {
			cpos: 0,
			prv: new Element('a',{href:'#',id:'SFX_nbtp_'+this.cei,'class':'SFX_navibtn SFX_prv SFX_disabled',events:{
				click:function(e){e.stop(); if(this.hasClass('SFX_enabled')) SFX.prv(parseInt(this.id.replace(/SFX_nbt(p|n)_/,'')));}
			}}),
			nxt: new Element('a',{href:'#',id:'SFX_nbtn_'+this.cei,'class':'SFX_navibtn SFX_nxt SFX_enabled',events:{
				click:function(e){e.stop(); if(this.hasClass('SFX_enabled')) SFX.nxt(parseInt(this.id.replace(/SFX_nbt(p|n)_/,'')));}
			}})
		};
		this.navi[this.cei].prv.inject(this.ce,'before');
		this.navi[this.cei].nxt.inject(this.ce,'before');
	},
	setDims:function(){
		this.navi[this.cei].slgt = (this.ce.getChildren()[0].getSize().x + this.ce.getChildren()[0].getStyle('margin-left').toInt() + this.ce.getChildren()[0].getStyle('margin-right').toInt())*this.options.elems[this.cei].stepby;
		this.navi[this.cei].msteps = (this.ce.getChildren().length / this.options.elems[this.cei].stepby).round();
	},
	wrapElems:function(){
		this.navi[this.cei].wrp = new Element('div',{'class':'SFX_icnt_wrp'});
		this.navi[this.cei].ce = this.ce;
		this.ce.setStyles({width:this.navi[this.cei].slgt*this.navi[this.cei].msteps});
		this.navi[this.cei].wrp.wraps(this.ce);
	},
	prv:function(sec){
		this.cnave = this.navi[sec];
		if(!this.cnave.cpos) return;
		this.cnave.cpos--;
		this.cnave.ce.morph({'margin-left':0-(this.cnave.cpos*this.cnave.slgt)});
		if(this.cnave.cpos==0){
			this.cnave.prv.removeClass('SFX_enabled');
			this.cnave.prv.addClass('SFX_disabled');
		}
		if(this.cnave.cpos==this.cnave.msteps-2){
			this.cnave.nxt.removeClass('SFX_disabled');
			this.cnave.nxt.addClass('SFX_enabled');
		}
	},
	nxt:function(sec){
		this.cnave = this.navi[sec];
		if((this.cnave.cpos+1)==this.cnave.msteps) return;
		this.cnave.cpos++;
		this.cnave.ce.morph({'margin-left':0-(this.cnave.cpos*this.cnave.slgt)});
		if(this.cnave.cpos==this.cnave.msteps-1){
			this.cnave.nxt.removeClass('SFX_enabled');
			this.cnave.nxt.addClass('SFX_disabled');
		}
		if(this.cnave.cpos==1){
			this.cnave.prv.removeClass('SFX_disabled');
			this.cnave.prv.addClass('SFX_enabled');
		}
	}
});

var SBox = new Class({
	Implements: Options,
	options:{
		SBtype:0 
	},
	initialize: function(options){
		this.setOptions(options);
		this.prnd;
		this.createSB();
	},
	createSB: function(){
	switch(this.options.SBtype){
		case 0:
			this.prnd = new Element('div',{id:'SBitCnt'});
			this.tmpic = new Element('div',{id:'SBitInnerCnt',html:'<div id="SBit_hdr">Suche im Online-Shop</div>'}).inject(this.prnd);			
			this.tmp = new Element('form',{name:'SBi_form'});
			this.tmpinput = new Element('input',{
				id:'SBit1_qti',
				type:'text',
				name:'query',
				value:this.getKwFR(),
				events:{
					focus:function(){
						if(this.value=='Suchbegriff oder Artikel-Nr.') this.value = '';
					},
					blur:function(){
						if(this.value=='') this.value='Suchbegriff oder Artikel-Nr.';
					}
				}
			});
			if(this.tmpinput.value=='') this.tmpinput.value='Suchbegriff oder Artikel-Nr.';
			this.tmpinput.inject(this.tmp);
			this.tmpbtn = new Element('button',{id:'SBit_sbb',html:'<span>suchen</span>'});
			this.tmpbtn.addEvent('click',function(e){
				e.stop();
				if($('SBit1_qti').value=='Suchbegriff oder Artikel-Nr.' || !$('SBit1_qti').value)
					alert('Bitte geben Sie einen Suchbegriff ein!');
				else top.frames[0].ssub($('SBit1_qti').value);
			});
			this.tmpbtn.inject(this.tmp);
			this.tmpbtnshadow = new Element('div',{id:'SBit_sbb_shadow'}).inject(this.tmp);
			this.tmp.addEvent('submit',function(e){
				e.stop();
				if($('SBit1_qti').value=='Suchbegriff oder Artikel-Nr.' || !$('SBit1_qti').value)
					alert('Bitte geben Sie einen Suchbegriff ein!');
				else top.frames[0].ssub($('SBit1_qti').value);
			});
			this.tmp.inject(this.tmpic);
			this.prnd.inject($('hdr'));
			new Element('div',{id:'SBitCntShadow'}).inject($('hdr'));
		break;
		}
	},
	getKwFR:function(){
		this.docref = document.referrer;
		if(this.docref.search(/^https?:\/\/(.*?)?google(syndication)?\./)>-1){
			this.refkw = this.docref.replace(/^.*(\?|\&)(q|as_q|as_epq|es_eq|as_oq|query|suchstr|ref)=/i,'').replace(/\&.*$/,'');
			this.convertKw();
			return this.refkw;
		}
		if(this.docref.search(/^https?:\/\/(.*?)?yahoo\./)>-1){
			this.refkw = this.docref.replace(/^.*(\?|\&)p=/,'').replace(/\&.*$/,'');
			this.convertKw();
			return this.refkw;
		}
		if(this.docref.search(/^https?:\/\/(.*?)?bing\./)>-1){
			this.refkw = this.docref.replace(/^.*(\?|\&)(q|mt)=/i,'').replace(/\&.*$/,'');
			this.convertKw();
			return this.refkw;
		}
		if(this.docref.search(/^https?:\/\/(.*?)?web\.de/)>-1){
			this.refkw = this.docref.replace(/^.*(\?|\&)(su)=/i,'').replace(/\&.*$/,'');
			this.convertKw();
			return this.refkw;
		}
		if(this.docref.search(/^https?:\/\/(.*?)?alltheweb\.com/)>-1){
			this.refkw = this.docref.replace(/^.*(\?|\&)(q|query)=/i,'').replace(/\&.*$/,'');
			this.convertKw();
			return this.refkw;
		}
		//try default ptterns
		this.refkw = this.docref.replace(/^.*(\?|\&)(q|query|keyword|keywords|qt|fq)=/i,'').replace(/\&.*$/,'');
		if(this.refkw.search(/^https?:\/\//i)===-1){
			this.convertKw();
			return this.refkw;
		}
		return '';
	},
	convertKw:function(){
		this.refkw = this.refkw.replace(/\+/g,' ');
		this.refkw = decodeURIComponent(this.refkw);
		this.refkw = unescape(this.refkw);
	}
});
