var prodir={
	init:function(){
		
		//Preise
		var preisePopup=nPopup.newPopup({
				width:'auto',
				height:'auto',
				visible:false,
				scrollable:false,
				shadow:true,
				createInCertainDomEl:'content_main',
				top:'60px',
				left:'40px'
		});
		Event.observe(preisePopup.contentDiv, 'click', function(){
			this.hide();
		}.bindAsEventListener(preisePopup));
		
		$$('a.preis_link').each(function(l){
			Event.observe(l, 'click', function(event){
				preisePopup.clearContent();  
				preisePopup.addContent('Bitte warten...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br><br><br><br><br>');
				nUtils.setProgressState(preisePopup.contentDiv, true);
				if(this.href){
					var tpl;
					$A(this.href.substr(this.href.indexOf('?')+1, this.href.length).split('&')).each(function(el){
						var tmp=el.split("=");
						if(tmp[0]=='tpl' && tmp[1]){
							tpl=tmp[1];
						}
					});
					if(this.title){
						title=this.title;
					}else{
							title='';
					}
					if(tpl){
						new Ajax.Request('/tpl/sortiment/prodir_werbekugelschreiber/preise/'+tpl,{
							method:'get',
							onSuccess:function(t){
								nUtils.setProgressState(preisePopup.contentDiv, false);
								preisePopup.clearContent();  
								preisePopup.setTitle(title);
								preisePopup.addContent(t.responseText, true);
							}
						});
					}
					preisePopup.show();
					Event.stop(event);
				}
			}.bindAsEventListener(l));
		});
		
		$$('a.modell_link').each(function(l){
			Event.observe(l, 'click', function(event){
				if(!prodir.modellPopup){
					prodir.modellPopup=nPopup.newPopup({
							width:'auto',
							height:'auto',
							visible:false,
							scrollable:false,
							shadow:true,
							createInCertainDomEl:'content_main',
							top:'60px',
							left:'40px'
					});
					Event.observe(prodir.modellPopup.contentDiv, 'click', function(){
						this.hide();
					}.bindAsEventListener(prodir.modellPopup));
				}
				prodir.modellPopup.clearContent();  
				prodir.modellPopup.addContent('Bitte warten...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br><br><br><br><br>');
				nUtils.setProgressState(prodir.modellPopup.contentDiv, true);
				if(this.href){
					var tpl;
					$A(this.href.substr(this.href.indexOf('?')+1, this.href.length).split('&')).each(function(el){
						var tmp=el.split("=");
						if(tmp[0]=='tpl' && tmp[1]){
							tpl=tmp[1];
						}
					});
					if(this.title){
						title=this.title;
					}else{
							title='';
					}
					if(tpl){
						new Ajax.Request('/tpl/sortiment/prodir_werbekugelschreiber/modelle/'+tpl,{
							method:'get',
							onSuccess:function(t){
								nUtils.setProgressState(prodir.modellPopup.contentDiv, false);
								prodir.modellPopup.clearContent();  
								prodir.modellPopup.setTitle(title);
								prodir.modellPopup.addContent(t.responseText, true);
							}
						});
					}
					prodir.modellPopup.show();
					Event.stop(event);
				}
			}.bindAsEventListener(l));
		});
		
		//Gehäusefarben
		var farbenPopup=nPopup.newPopup({
				width:'auto',
				height:'auto',
				visible:false,
				scrollable:false,
				shadow:true,
				createInCertainDomEl:'content_main',
				top:'60px',
				left:'40px'
		});
		Event.observe(farbenPopup.contentDiv, 'click', function(){
			this.hide();
		}.bindAsEventListener(farbenPopup));
		
		$$('a.farben_link').each(function(l){
			Event.observe(l, 'click', function(event){
				farbenPopup.clearContent();  
				farbenPopup.addContent('Bitte warten...&nbsp;&nbsp;&nbsp;<br><br><br><br><br><br>');
				nUtils.setProgressState(farbenPopup.contentDiv, true);
				if(this.href){
					this.img=new Image();
					this.img.src=this.href;
					nUtils.preloadImg(this.img, function(){
						nUtils.setProgressState(farbenPopup.contentDiv, false);
						farbenPopup.clearContent();  
						farbenPopup.addContent('<img src="'+this.img.src+'" width="'+this.img.width+'" height="'+this.img.height+'">');
					}.bind(this));
					farbenPopup.show();
					Event.stop(event);
				}
			}.bindAsEventListener(l));
		});
		
		//Druckmöglichkeiten
		var druckPopup=nPopup.newPopup({
				width:'auto',
				height:'auto',
				visible:false,
				scrollable:false,
				shadow:true,
				createInCertainDomEl:'content_main',
				top:'60px',
				left:'40px'
		});
		Event.observe(druckPopup.contentDiv, 'click', function(){
			this.hide();
		}.bindAsEventListener(druckPopup));
		
		$$('a.druckmoeglichkeiten_link').each(function(l){
			Event.observe(l, 'click', function(event){
				druckPopup.clearContent();  
				druckPopup.addContent('Bitte warten...&nbsp;&nbsp;&nbsp;<br><br><br><br><br><br>');
				nUtils.setProgressState(druckPopup.contentDiv, true);
				if(this.href){
					this.img=new Image();
					this.img.src=this.href;
					nUtils.preloadImg(this.img, function(){
						nUtils.setProgressState(druckPopup.contentDiv, false);
						druckPopup.clearContent();  
						druckPopup.addContent('<img src="'+this.img.src+'" width="'+this.img.width+'" height="'+this.img.height+'">');
						//druckPopup.addContent(this.img);
					}.bind(this));
					
					druckPopup.show();
					Event.stop(event);
				}
			}.bindAsEventListener(l));
		});
		
	}
}
