Event.observe(window, "load", function(){
	channelNavi = new Navi("#kanalNavi");
	FaqNavi.start();
	extrNavi = new Navi("#extraNavi");
	if($("miniSuchform"))$("miniSuchform").observe("submit", function(e){
		if( $F("liveSuche") == "" ) 
		e.stop()
		return false
	})
	$$("body")[0].addClassName("loaded")
})

FilterNavi = function(listenfilter){
		$$("#"+listenfilter+" > ul > li").each(function(el){
			el.observe("mouseover",function(e){
				$$("#"+listenfilter+" > ul > li > div").invoke("hide")
				if(window.filterNaviTimer) window.clearTimeout(window.filterNaviTimer)
				 el.down("div").show()
			})
			el.observe("mouseout",function(e){
				div = el.down("div")
				window.filterNaviTimer = Element.hide.delay(0.2,div);
			})
		})
	}	
Navi = function(id){
	$$( id + " > ol > li").each(
		function(el){
			if(! el.down("strong")) {
				el.observe("mouseover", function(e){
					$$( id + " > ol > li > a").invoke("addClassName", "nonactive")
					var ich = $$( id + " > ol > li > a");
					if(ich[0]){
						var nachbar = ich[0].next("ol")
						if(nachbar){
							nachbar.hide()
						}
					}
				})
				el.observe("mouseout", function(e){
					$$( id + " > ol > li > a").invoke("removeClassName", "nonactive")
					var ich = $$( id + " > ol > li > a");
					if(ich[0]){
						var nachbar = ich[0].next("ol")
						if(nachbar){
							nachbar.setStyle({display:"block"})
						}
					}
				})
			}
		}
	)
}
FaqNavi = new Object();
FaqNavi.start = function(){

	$$("#faq > ol > li, #faq > ol > li > a, #faq > ol > li > div").each(
		
		function(el){
			var li,div,a;
			if(el.nodeName == "LI"){
				li = el
			}
			else{ 
				li = el.up("li")
			}
			div = li.down("div")
			a = li.down("a")

			var showme = function(){
				div.show()
				
			}
			var hideme = function(){
				div.hide()
				
			}
			timer = false;
			el.observe("mouseover", function(e){
				window.clearTimeout(timer)
				li.addClassName("open")
				timer = showme.delay(0.3)
			})
			el.observe("mouseout", function(e){
				window.clearTimeout(timer)
				li.removeClassName("open")
				timer = hideme.delay(0.3);
			})
		})
}

function carousel(carouselListId, carouselClipRegionId, carouselSpinnerId){
	var self 		= this;
	var wait		= false;
	var stop		= false;
	var slowdown	= true;
	var pointerPos  = 0;
	var framesPerSecond = 20; //affects significantly cpu-load on some hardware
	var width		= $(carouselListId).immediateDescendants().first().getWidth()
	var delta 		= 300;
	var totalWidth	= 0;

  var slowVelocity = 0.05
	var velocity	  = slowVelocity
	var innerWidth	= $$('body')[0].getWidth()
	var clipRegion	= $(carouselClipRegionId)
	
	
	this.isSlow = function(){
		var center = innerWidth/2
		var p = pointerPos - center
		return !(( p < - delta - 60 ) || ( p >  delta + 60 ))
	}

	this.slowdown = function(event) {
		slowdown = true;
	}

	this.stop = function() {
		stop = true;
	}

	this.interact = function(event) {
		pointerPos = event.pointerX()
		//innerWidth	= $$('body')[0].getWidth()
		slowdown = false
		//stop = false;
		//self.move()
	}

	this.move = function(){
		
		if(!wait){
		 	if(!slowdown) {
	
				var center = innerWidth/2
				var p = pointerPos - center
			
				if( p < - delta ) { 
					self.goOn()
					velocity =   ( ( -( p + delta ) / (center - delta) ) + velocity ) / 4				
				} else if ( p >  delta ) { 
					self.goOn()
					velocity =   ( ( -( p - delta ) / (center - delta) ) + velocity ) / 4			
				} else {
					self.stop()
					self.move.delay(0.25)
					return
				}

			} else {
				if ( Math.abs(velocity) >  slowVelocity ){
					velocity =  velocity  - velocity/4
				}else {
					velocity = velocity > 0 ? slowVelocity : -slowVelocity
				}
			}
			self.moveCarousel()
		} else {
			self.move.delay(0.25)
		}
	}
  this.afterMove = function(){
		wait = false
		self.move()
	}
	this.moveCarousel = function()  {
		wait = true
		if (!stop) {
			if (clipRegion.offsetLeft <= -(totalWidth-innerWidth-width) ) {
				new Effect.MoveBy(carouselClipRegionId, 0, (totalWidth/2),{
					transition: Effect.Transitions.linear,
					duration: 0.0});
			}else if (clipRegion.offsetLeft >= -width) {
				new Effect.MoveBy(carouselClipRegionId, 0, -totalWidth/2,{
					transition: Effect.Transitions.linear,
					duration: 0.0});
			}
			new Effect.MoveBy(carouselClipRegionId, 0, 100*velocity,
				{afterFinish: self.afterMove, 
				fps: framesPerSecond, 
				transition: Effect.Transitions.linear,
				duration: 0.25});
	   } else {
	   	  self.afterMove.delay(0.25)
	   }
	}
		
	this.goOn = function(){
		stop = false
	}
	this.goOnSlow = function(){
		self.slowdown()
		stop = false
	}

	$(carouselListId).immediateDescendants().each(function(li){

		totalWidth += li.getWidth()
		
		var playButton = $(li).down(".playButton")
		
		var showFunction = function(event){
			if (playButton && self.isSlow() && !playButton.visible()) {
				//playButton.appear({ duration: 0.5 });
				playButton.show()
			}
		}
		
		var hideFunction = function(event){
			if(playButton){
				playButton.hide()
			}
		}
		
		li.observe("mouseover", showFunction)
					
		li.observe("mouseout",  hideFunction)
		
	})
	
	new Effect.MoveBy(carouselClipRegionId, 0, -width,{
	transition: Effect.Transitions.linear,
	fps:framesPerSecond,
	duration: 0.0});
	
	self.move()
	
	$(carouselClipRegionId).observe("mousemove", self.interact)
	$(carouselClipRegionId).observe("mouseover", self.interact)

	$(carouselClipRegionId).observe("mouseout" , self.goOnSlow)

	//Event.observe(window,"mouseout",self.stop)
	//Event.observe(window,"mouseover",self.goOnSlow)
}

function moviePlayer(basePath, flashdiv) {
	var mama = this
	this.width = 230
	this.height = 337
	this.vorhang = $('Vorhang')
	this.flashdiv = flashdiv
	this.zvv = false

	var timeout = false;
	//$(flashdiv).clonePosition(this.vorhang)

	$$(".playButton").each(
		function(el){
			el.observe("click", function(e){
				mama.play(el.getAttribute("id"));
				e.stop();
			})
	})
	
	this.hideVideo = function(){
		Effect.BlindDown(mama.vorhang)
		$(mama.flashdiv).hide();
	}
	this.play = function(filename){
		var flashPath = "js-lib/mediaplayer.swf"
		this.zvv = new SWFObject(flashPath, "flashVideo", "239", "334", "8", "#ffffff");
		this.zvv.addParam("wmode", "transparent");
		this.zvv.addParam('allowscriptaccess','always');
		this.zvv.addParam('allowfullscreen','true');
		this.zvv.addVariable('file','http://media.zoomoviewer.com/video/jungstil/' + filename + '.flv');
		this.zvv.addVariable("showdigits","false");
		this.zvv.addVariable("screencolor","0x8B8C87");
		this.zvv.addVariable("enablejs","true");
		this.zvv.addVariable("javascriptid","zvvideo1");
		this.zvv.addVariable("autostart","true");
		this.zvv.addVariable("width","239");
		this.zvv.addVariable("height","334");
		this.zvv.write(mama.flashdiv);
			
		$(mama.flashdiv).show();
		Effect.BlindUp(mama.vorhang)
	}

};

function ticker(tickerListId){
	var self = this
	var totalWidth = 0
	this.isRunning = true;
	var liIndex = 0;
	var mover = null;
	this.update = null;
	$(tickerListId).immediateDescendants().each(function(li){
//		if (liIndex++ % 3 == 0){
//			li.immediateDescendants().first().setStyle('text-decoration: line-through;')
//		} 
		
		totalWidth += li.getWidth()
	})
	
	this.move = function(){

			mover = new Effect.Move(tickerListId, {
				x: -totalWidth / 2,
				y: 0,
				mode: 'relative',
				transition: Effect.Transitions.linear,
				afterFinish: self.reset,
				fps: 15,
				duration: 180.0
			})
	}
	
	this.stop = function(){
		if (this.isRunning) {
			this.update = mover.update
			mover.update = function(){
			}
			this.isRunning = false;
		}
	}

	this.start = function(){
		if (!this.isRunning) {
			mover.update = this.update
			this.isRunning = true		}
	}

	this.reset = function(){
			mover = new Effect.Move(tickerListId, {
				x: totalWidth / 2,
				y: 0,
				mode: 'relative',
				fps: 23,
				transition: Effect.Transitions.linear,
				afterFinish: self.move,
				duration: 0.0
			})
	}
	
	self.move()
//	Event.observe(window,"mouseout",this.stop.bind(this))
//	Event.observe(window,"mouseover",this.start.bind(this))
//	Event.observe(window,"blur",this.stop.bind(this))
//	Event.observe(window,"focus",this.start.bind(this))
}

function registerErrorHighlighter(id, elementWithErrorStyle, errorDivStyle){
	Event.observe(window,'load', function(){
		// Bugfix für Links in Fehler-Bubbles: ausführen bei onmousedown, also bevor blur-Event der Formularfelder zündet
	  $$('#dateneingabe .eingabeFehler a').invoke('observe', 'mousedown', function(e){location=this.href})
		var firstWrongElement = true;
		$$('#'+id+' input,select').each(function(element){
			
			var errorDiv = $$('#'+element.id.replace(".","_") + '_error .eingabeFehler')[0]
	
			if (errorDiv){
	    		if (!errorDiv.empty()) {
					element.setStyle(elementWithErrorStyle)
					
					var showFunction = function(event){
						element.select()
						errorDiv.setStyle(errorDivStyle)
						errorDiv.appear({
							duration: 0.3,
							queue: 'front'
						})
					}
					
					var hideFunction = function(event){
						errorDiv.fade({
							duration: 0.1,
							queue: 'end'
						})
					}
					
					element.observe("focus", showFunction)
					
					element.observe("blur", hideFunction)
					
					if (firstWrongElement) {
						element.focus()
						firstWrongElement = false
					}
				}
				else {
					errorDiv.hide()
				}
			}
		})
	})
}

ShopFilterSort = new Object();
ShopFilterSort.resetFilterFormForSize = function(field){
					if (field == "ssz") {
						$('sco').value = ""
						$('sss').value = ""
						$('sma').value = ""
						$('spr').value = ""
					}
}

SimpleSort = function(){
	return {
		initialize:function(){
		},
		switchBox: function(field, theValue, theTrack){
//					ShopFilterSort.resetFilterFormForSize(field)
        	$(field).value=theValue;
        	if(theValue == '') {
        		var pos = $("directLandmarkP").value.indexOf("," + theTrack);
        		var length = theTrack.length + 1;
        		if(pos == -1) {
        			pos = $("directLandmarkP").value.indexOf(theTrack + ",");
            		length = theTrack.length + 1;
        		}
        		if(pos > -1) {
        			$("directLandmarkP").value = $("directLandmarkP").value.substring(0, pos)
        				+ $("directLandmarkP").value.substring(pos + length, $("directLandmarkP").value.length);
        		}
        		else if($("directLandmarkP").value == "wert=" + theTrack) {
        			$("directLandmarkP").value = "";
        		}
        		
        	}
        	else {
	        	if($("directLandmarkP").value != "wert=")
	        		$("directLandmarkP").value = $("directLandmarkP").value + ",";
	        	$("directLandmarkP").value = $("directLandmarkP").value + theTrack;
        	}
        	if($("spr").value != "" || $("ssz").value != "" || $("sco").value != "" || $("sss").value != "" || $("sma").value != "") {
        		$("fb").value="0";
        	}
        	$("shopfilter").submit();
        }
	}
}
EffectSort = function(){
    var container = $('article_list');
    var elems = $(container).select('li');
    
    var elem_ids = elems.collect(function(elem){
        return elem.id
    })
    var item_height = $(elem_ids[0]).getHeight()
    var rand = function(max){
        return (Math.floor(Math.random() * max + 1))
    };
    var $elems = function(array){
        return array.collect(function(elem){
            return $(elem)
        })
    }
    var result_elems;

    return {
    	initialize: function(){
            this.positionize();
            result_elems = elems;
        },
        run: function(para_elems){
            result_elems = $elems(para_elems)

        	var no_result_elems = elems.reject(function(elem){
                return result_elems.member(elem)
            })
            no_result_elems.invoke('hide')
            result_elems.each(function(elem, index){
				if (!elem.visible()) {
                    elem.appear({
                        duration: 0.8,
                        direction: 'top-left',
                        queue: "parallel"
                    })
                }
                return new Effect.Move(elem, {
                    y: sort.positions[index].top,
                    x: sort.positions[index].left,
                    mode: 'absolute',
                    queue: "parallel"
                })
            })
            this.set_container_height(result_elems)
        },
        set_container_height: function(result_set){
            if(result_set.length > 0){
            	pro_zeile = Math.round( $(container).getWidth() / $(result_set[0]).getWidth() );
            }
            outer_height = Math.ceil(result_set.size() / pro_zeile) * item_height
            $(container).setStyle({
                height: outer_height + "px"
            })
        },
        positionize: function(){
            this.set_container_height(elems);
            this.positions = elems.invoke('positionedOffset');
            elems.each(function(elem){
            	leftPos = eval(elem.positionedOffset()[0])+ "px"; 
            	topPos =  eval(elem.positionedOffset()[1])+ "px" ;
            	return elem.setStyle({left: leftPos, top: topPos});
            })
            elems.invoke('setStyle', {
                position: 'absolute'
            })
        },
        switchBox: function(field, theValue, theTrack){
// 					ShopFilterSort.resetFilterFormForSize(field)
        	$(field).value=theValue;
        	if(theValue == '') {
        		var pos = $("directLandmarkP").value.indexOf("," + theTrack);
        		var length = theTrack.length + 1;
        		if(pos == -1) {
        			pos = $("directLandmarkP").value.indexOf(theTrack + ",");
            		length = theTrack.length + 1;
        		}
        		if(pos > -1) {
        			$("directLandmarkP").value = $("directLandmarkP").value.substring(0, pos)
        				+ $("directLandmarkP").value.substring(pos + length, $("directLandmarkP").value.length);
        		}
        		else if($("directLandmarkP").value == theTrack) {
        			$("directLandmarkP").value = "";
        		}
        		
        	}
        	else {
	        	if($("directLandmarkP").value != "wert=")
	        		$("directLandmarkP").value = $("directLandmarkP").value + ",";
	        	$("directLandmarkP").value = $("directLandmarkP").value + theTrack;
        	}
        	if($("spr").value != "" || $("ssz").value != "" || $("sco").value != "" || $("sss").value != "" || $("sma").value != "") {
        		$("fb").value="0";
        	}
        	$("shopfilter").request({
	        	onSuccess: function(response){
	        		$("listenfilter").replace(response.responseText);
		       	}
        	})
        }
    }
}

Reviews = new Object();

Reviews.commitReview = function(){
	var f = document.forms['fartikel'];
	vali = new FormValidator('fartikel');
	vali.setErrorType(FormValidator.ERROR_TYPE_BUBBLE_ID)
	vali.validateWithFunction("rating", function(a){ return a > 0 }, $("fehlerReviewRating"))
	//vali.validateFormatOf("customerInputEmail", /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/, $("fehlerReviewEmail"))
	vali.validatePresenceOf("customerInputEmail", $("fehlerReviewEmail"))
	vali.validatePresenceOf("customerInputFirstName", $("fehlerReviewVorname"))
	vali.validatePresenceOf("customerInputLastName", $("fehlerReviewNachname"))
	vali.validatePresenceOf("customerInputHeadline", $("fehlerReviewHeadline"))
	vali.validatePresenceOf("customerInputText", $("fehlerReviewText"))
	
	
	if(vali.isValid()) {
		var sessionId = window.sessionId;
		var styleId = f.elements['st'].value;
		var rating = f.elements['rating'].value;
		var headline = encodeURIComponent(f.elements['customerInputHeadline'].value);
		var text = encodeURIComponent(f.elements['customerInputText'].value);
		var firstname = encodeURIComponent(f.elements['customerInputFirstName'].value);
		var lastname = encodeURIComponent(f.elements['customerInputLastName'].value);
		var email = encodeURIComponent(f.elements['customerInputEmail'].value);

		var url = 'addReview.htm';
		var pars = 'id=' + sessionId + '&st=' + styleId + '&rating=' + rating + '&customerInputHeadline=' + headline+ '&customerInputText=' + text;
		if (firstname != null) pars += "&customerInputFirstName=" + firstname;
		if (lastname != null) pars += "&customerInputLastName=" + lastname;
		if (email != null) pars += "&customerInputEmail=" + email;
		var myAjax = new Ajax.Updater(
						'bewertungAbgeben',
						url,
						{method: 'post', parameters: pars, evalScripts: true}
					);
		}
	return false;
}

Reviews.hoverRating = function(stars){
	for(i=1;i<=5;i++){
		if(i<=stars) {
			$('ratingStar'+i).src = $('ratingStar'+i).src.replace("grau","aktiv");
		}
		else {
			$('ratingStar'+i).src = $('ratingStar'+i).src.replace("aktiv","grau");
		}
	}
	Reviews.hideAllStarDescs();
	$("StarDesc"+stars).show();
	$('ratingStar1').src = $('ratingStar1').src.replace("grau","aktiv");
}

Reviews.resetRating = function(){
	stars = $("rating").value;
	for(i=1;i<=5;i++){
		if(i<=stars) {
			if($('ratingStar'+i)){
				$('ratingStar'+i).src = $('ratingStar'+i).src.replace("grau","aktiv");
			}
		}
		else {
			if($('ratingStar'+i)){
				$('ratingStar'+i).src = $('ratingStar'+i).src.replace("aktiv","grau");
			}
		}
		
	}
	Reviews.hideAllStarDescs();
	if($("StarDesc"+stars))$("StarDesc"+stars).show();
}

Reviews.hideAllStarDescs = function(){
	for(i=0;i<=5;i++){
		if($("StarDesc"+i))$("StarDesc"+i).hide();
	}
}

Reviews.setRating = function(stars){
	for(i=1;i<=5;i++){
		if(i<=stars) {
			$('ratingStar'+i).className = 'ratingStar activeStar';
		}
		else {
			$('ratingStar'+i).className = 'ratingStar inactiveStar';
		}
	}
	$("rating").value=stars;
	
}

Reviews.giveFeedback = function(id, gut){
	var good = gut ? 1 : 0;
	new Ajax.Updater("rezFb_"+id, "giveFeedback.htm",{
			parameters: {
			revFb: good, revFbRev: id },onSuccess:function(){
		new Effect.Highlight("rezFb_"+id, {startcolor:'#ffbf00', endcolor:'#ffffff'})
	}});
	
	return false;
}

Detail = new Object();
Detail.bestellen = function(){
	$("fartikel").submit();
}

function html_entities_to_Character(text){
	return text.replace("&nbsp;"," ").replace("&euro;",unescape("%u20AC")).replace("&pound;", unescape("%u00A3")) ;
}
window.clickAllowed = true;
window.oldSize = "";
var detailAnsicht = {
	checkSouldOut: function() {
    	var f = document.fartikel;
    	var anzahl = parseInt(f.pAnz.value);

    	if (isNaN(anzahl) || (anzahl == 0)) {
    		f.pAnz.value = 1;
    	}

    	if (f.pGr) { // Array mit ausverkauften Groessen existiert
    		var s = "";
    		if (f.pGr.options)
    			s = f.pGr.options[f.pGr.selectedIndex].text;
    		else if ($("preisausverkft") != null)
    			s = $("preisausverkft").innerHTML;
    		if(TEMP_AUSVERKAUFT.length > 0 && s.indexOf(TEMP_AUSVERKAUFT) > -1) {
    			detailAnsicht.showStockInfo(LEIDER_TEMP_AUSVERKAUFT);
    			return false;
    		} else if (AUSVERKAUFT.length > 0 && s.indexOf(AUSVERKAUFT) >= 0) {
    			detailAnsicht.showStockInfo(LEIDER_AUSVERKAUFT);
    			return false;
    		}
    	} else {
    		if (f.pAusw) { // Array mit ausverkauften Farben existiert
    			var s = "";
    			if (f.pAusw.options)
    				s = f.pAusw.options[f.pAusw.selectedIndex].text;
    			else if ($("preisausverkft") != null)
    				s = $("preisausverkft").innerHTML;
        		
    			if(TEMP_AUSVERKAUFT.length > 0 && s.indexOf(TEMP_AUSVERKAUFT) > -1) {
    				detailAnsicht.showStockInfo(LEIDER_TEMP_AUSVERKAUFT);
    				return false;
    			} else if (AUSVERKAUFT.length > 0 && s.indexOf(AUSVERKAUFT) > -1) {
    				detailAnsicht.showStockInfo(LEIDER_AUSVERKAUFT);
    				return false;
    			}
    		}
    	}
		return true;
	},
	
	putBundleToWishList: function(dialog) {
	   if (detailAnsicht.checkSouldOut()) {
		  new Ajax.Request("addToWishlist.htm?id=" + window.sessionId,{parameters: Form.serialize($("fartikel"),true),
			onSuccess: function(transport){
				$(dialog.getDialog()).down(".overlayInner").replace(transport.responseText)
				dialog.positionAndShow();
			}
		})
	   }	   
	},
	
	closeWishlistLayer: function() {
	   $("wishlistBundleLayer").hide();
	},
	
	putBundleToWishListIsExist: function() {
	   if (detailAnsicht.checkSouldOut()) {
	  	 document.fartikel.wpageOrder.value = "1";
	   	 document.fartikel.action = "mywishlist.htm?#sid()";
	   	 document.fartikel.submit();
	   }	 
	}
}
	detailAnsicht.initial = false;
		
	detailAnsicht.pruefeGroessenBoxInitial=function(initial) {			
		detailAnsicht.initial=true;
		detailAnsicht.pruefeGroessenBox();
	}
	detailAnsicht.registerObservers = function(){
		if($("sbox"))$("sbox").observe("change", detailAnsicht.pruefeGroessenBox);
		if($("pGr"))$("pGr").observe("change", detailAnsicht.pruefeGr);
		
	}
	detailAnsicht.selectedGroessenBox=function() {
		var pGr = eval("document.fartikel.pGr");
		if (pGr.selectedIndex != null){
			if(pGr.selectedIndex == -1 
				|| !detailAnsicht.checkGroessenAvailability(pGr.options[pGr.selectedIndex].text)) {
				for(var i = 0; i < pGr.options.length; i++) {
					if(detailAnsicht.checkGroessenAvailability(pGr.options[i].text)) {
						pGr.options[i].selected = true;
						break;
					}
				}
			}
		}
	}
	
	detailAnsicht.checkGroessenAvailability=function(text) {
		if(text.indexOf(AUSVERKAUFT) == -1 
	        	&& (TEMP_AUSVERKAUFT.length == 0 || text.indexOf(TEMP_AUSVERKAUFT) == -1)) {
	        return true;
	    }
	    else {
	    	return false;
	   	}
	}
	
	detailAnsicht.pruefeGroessenBox=function() {
	  
	  if (groessen) {
		var f = $("fartikel");
		detailAnsicht.aendereGroessenBox(f.pAusw.selectedIndex);
		var artnr = f.pAusw.options[f.pAusw.selectedIndex].value.match(/[0-9]+[A-Z]*/);
		cleverImage.findAndShowArtikelBild(artnr);
	  }

	}

	detailAnsicht.boxBreiter=function(id, width, tooBig ) {
		if (tooBig)	 
			 $(id).style.width = width;	
		if ($(id).offsetWidth == width && $(id).options.selectedIndex == -1)	 
		     $(id).options.selectedIndex = 0;
	}


    detailAnsicht.aendereGroessenBox = function(farbIdx){
        var f = document.fartikel;
        var val = "";
        if (f.pAusw[farbIdx]) {
            val = f.pAusw[farbIdx].value;
        }
        else {
            if (f.pAusw.value) {
                val = f.pAusw.value;
            }
        }
		
        var anfang = val.indexOf("{[B]") + 4;
        var ende = val.indexOf("}", anfang);
        var artnr = val.substring(anfang, ende);
        var selgesetzt = 0;
        if (f.pGr.options) {
            if (groessen[artnr].length > f.pGr.length) {
                for (var i = 0; i <= groessen[artnr].length - f.pGr.length; i++) {
                    neu = new Option('', '', false, false);
                    f.pGr.options[f.pGr.length] = neu;
                }
            }
            else 
                if (groessen[artnr].length < f.pGr.length) {
                    for (var i = 0; i <= f.pGr.length - groessen[artnr].length; i++) {
                        f.pGr.options[f.pGr.length - 1] = null;
                    }
                }
            for (var i = 0; i < groessen[artnr].length; i++) {
                if (f.pGr.options[i] != null) {
                    f.pGr.options[i].innerHTML = groessen[artnr][i].bez;
                    f.pGr.options[i].value = groessen[artnr][i].val;
                }
                if (selgesetzt == 0) {
                    if (groessen[artnr][i].bez.indexOf(AUSVERKAUFT) == -1 &&
                    (TEMP_AUSVERKAUFT.length == 0 || groessen[artnr][i].bez.indexOf(TEMP_AUSVERKAUFT) == -1)) {
                        // cut string after currency
                        posCurrency = f.pGr.options[f.pGr.selectedIndex].text.indexOf(WAEHRUNGS_EINHEIT) + WAEHRUNGS_EINHEIT.length;
                        selectBoxText = f.pGr.options[f.pGr.selectedIndex].text.substring(0, posCurrency);
                        posCurrency = oldSize.indexOf(WAEHRUNGS_EINHEIT) + WAEHRUNGS_EINHEIT.length;
                        oldSizeText = oldSize.substring(0, posCurrency);
                        //++++++++++++++++++++++++++
                        if (selectBoxText == oldSizeText) {
                            f.pGr.options[f.pGr.selectedIndex].selected = true;
                        }
                        else {
                            f.pGr.options[i].selected = true;
                        }
                        selgesetzt = 1;
                    }
                }
            }
        }
        else 
            if (f.pGr.value && detailAnsicht.hasKey(artnr)) {
                f.pGr.value = groessen[artnr][0].val;
                $("preisausverkft").innerHTML = groessen[artnr][0].bez;
            }
    }
	
	detailAnsicht.hasKey = function(key) {
	  return groessen && groessen[key] && groessen[key][0]
	    && groessen[key][0].val;
	}
	
	detailAnsicht.pruefeGr = function(){
		 if (document.fartikel.pGr.selectedIndex!=-1)
			oldSize= document.fartikel.pGr.options[document.fartikel.pGr.selectedIndex].text;
	}


	detailAnsicht.jRefillSizeSel = function()
	  {
	    if ( groessen ) {
		  var f = eval( "document.fartikel");
	      detailAnsicht.detailAnsicht.fillSizeSel( f.pAusw.selectedIndex );
		  }
	  }

	detailAnsicht.fillSizeSel = function( farbIdx ) {
	  var f = document.fartikel;
	  var val = "";
	if ( f.pAusw[ farbIdx ] )  {
	    val = f.pAusw[ farbIdx ].value;}
	  else
	    if ( f.pAusw.value )
	      val = f.pAusw.value;
	    var anfang = val.indexOf( "{[B]" ) + 4;
	    var ende = val.indexOf( "}", anfang );
	    var artnr = val.substring( anfang, ende );
	    for ( var i = 0; i < groessen[artnr].length; i++ ) {
	      f.pGr.options[i].text = groessen[artnr][i];
	    }
	}

	detailAnsicht.bestellen=function(typ) {

      if (!detailAnsicht.checkSouldOut())
		return;
      
	  if (clickAllowed) {
		var f = document.fartikel;
	    clickAllowed = false;
	    if (typ=='bestellen') {
	      if (isSpringtime)
		    newWin('bestellen','orderPopup.htm?id='+f.id.value,'425','225','scrollbars=no');
		  else
		    newWin('bestellen',pk+'.bs_popup?pwkorbid='+wk,'425','225','scrollbars=no');
		}
	    f.submit();
	    setTimeout("clickAllowed=true;",5000);
	  }

	}	

	detailAnsicht.showStockInfo=function(stockInfo) {
		var addDialog = new Dialog('addLineItemDialog');
		addDialog.positionAndShow();
	}

	detailAnsicht.bestellenSt=function(typ) {

		if (!detailAnsicht.checkSouldOut())
			return;
		
	    if (clickAllowed) {
	    	var f = document.fartikel;
	        clickAllowed = false;
	        if (typ=='bestellen') {
	            f.submit();
	        }
	        setTimeout("clickAllowed=true;",5000);
	    }
	}
	nothingWasClicked = true;
	
	function onlyFirstClick() {
	   if (nothingWasClicked) {
	       nothingWasClicked = false;
	       window.setTimeout("nothingWasClicked=true", 5000);
	       return true;
	     }
       return false;
    }
	
    detailAnsicht.winOpenXXLIntelligent = function(url,nb) {
   	    var fensterbreite;
		var fensterhoehe;
		fensterbreite = screen.width;
		fensterhoehe = screen.height;
		var strnb = "";
		for (var i = 0; i < nb.length; i++) {
			strnb += "&nb" + (i + 1) + "=" + nb[i];
		}
   	    var xxl = "http://jungstil.zoomoviewer.com/html/xxl_jungstil/xxl_fallback.php?imgurl="+url+"&width="+fensterbreite+"&height="+fensterhoehe+"&lang="+pk + strnb;
        window.open(xxl,"XXL","toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+ fensterbreite +",height="+ fensterhoehe +",left = 0,top = 0");
   }
  
detailAnsicht.zeigebild = function(pUrl) {
    var h = 600;
	if (screen.height >= 768) {
		h = 700;
	}
	fenster=window.open(pUrl,"Zoom","scrollbars=1,toolbar=0,location=0,directories=0,status=0,resizable=1,width=750,height=" + h);
	if (fenster.focus) fenster.focus();
}

/*Clever Images*/
var cleverImage = new Object();
	cleverImage.showAsMainImage = function(image) {
		mainImage = $$("#detailBild img")[0]
		if($(mainImage)){
			var zielSrc = $(mainImage).src;
			var src = $(image).src;
			var url = "";
			var bundleKleinUrl = "/aknbilder/bundles/variante_mittel/"
			var bundleGrossUrl = "/aknbilder/bundles/7er/gross/"
			var artikelKleinUrl = "/aknbilder/artikelklein/7er/klein/"
			var artikelGrossUrl = "/aknbilder/artikelklein/7er/gross/"
			
			if(src.match(bundleKleinUrl)){
				url = src.replace(bundleKleinUrl,bundleGrossUrl);
			} 
			else if(src.match(artikelKleinUrl)){
				url = src.replace(artikelKleinUrl,artikelGrossUrl);
				cleverImage.selectColor(image)
			}
			
			if(zielSrc.match(bundleGrossUrl)){
				zielUrl = zielSrc.replace(bundleGrossUrl, bundleKleinUrl);
			} 
			else if(zielSrc.match(artikelGrossUrl)){
				zielUrl = zielSrc.replace(artikelGrossUrl, artikelKleinUrl);
				cleverImage.selectColor(image)
			}
			
			this.switchImage(mainImage, url);
			this.switchImage(image, zielUrl);
			var erg1 = /(\/var)([0-9]{1})/.exec(url);
			varPathNumber = erg1[2];
		
			var erg2 = /([0-9]{2}\/[0-9]{1}\/[0-9]{4,})(\.jpg)/.exec(url);
			orderItemImageName = erg2? erg2[1]:"";
		}
	}
	cleverImage.findeArtikelBild=function(artnr){
		return $$("#detailRelated img").find(function(img){ return img.src.match(artnr) });
	}
	cleverImage.findAndShowArtikelBild=function(artnr){
		artnr = artnr +""
		img = cleverImage.findeArtikelBild(artnr)
		if(img){
			cleverImage.showAsMainImage(img);
		}
	}
	cleverImage.showAsZoomImage = function(image){
		var src = $(image).src;
		var url = "";
		if(src.match(/\/variante_gross\//)){
			url = src.replace(/\/variante_gross\//,"/artikel_gross/");
		}
		else if(src.match(/\/klein\//)){
			url = src.replace(/\/klein\//,"/429x600/");
		}
		else {
			return false;
		}
		
		this.switchImage("zoomMain", url);
	}
	cleverImage.videoIsRunning = function(){
	  return ( $('showImageButtonContainer').visible() && !$('showVideoButtonContainer').visible()) 
	}
	
	cleverImage.switchImage = function(id, url){
		var tmp = new Image();
		tmp.src = url;
    var fadeOutDur = 0.3		
		if (this.videoIsRunning()) {
			vPlayer.hideVideo()
		  fadeOutDur = 0		
		}	
		new Effect.Opacity(id,
		    { duration: fadeOutDur, from: 1.0, to: 0.0, afterFinish: callback });

		new Effect.Opacity(id,
		    { duration: 0.3, from: 0.0, to: 1.0, queue: 'end' });
		
		function callback(){
			$(id).src = url;
		};
	}
	
	cleverImage.selectColor = function(image){
		var artnr = image.src.match(/[0-9]{8}/);
		if ($("sbox")) {
			for (var a = 0; a < $("sbox").options.length; a++) {
				if ($("sbox").options[a].value.match(/[0-9]+[A-Z]*/)[0] == artnr) {
					$("sbox").options[a].selected = true;
					detailAnsicht.aendereGroessenBox(a);
				}
			}
		}
	}
		

	cleverImage.markImage = function(artnr){
//		$$("#colorsBox img").each(cleverImage.unmark);
//		if($("orderItem_"+artnr)) {
//			$("orderItem_"+artnr).className = "highLight";
//			if(detailAnsicht.initial==false)
//				cleverImage.showAsMainImage($("orderItem_"+artnr));
//		detailAnsicht.initial=false;	
//		}		
	}

	cleverImage.unmark = function(node, index){
		node.className = "";
	}
/* End Clever Images*/

Tags = {
	showTagCloud: function(){
		var li = $("tagcloud")
		if (!li.hasClassName("selected")) {
			li.up("ol").select("li").invoke("removeClassName", "selected");
			li.addClassName("selected");
			$("tagHinzufuegen").removeClassName("selected");
			$("tagsAnzeigen").addClassName("selected");
			if($("style")){
				new Ajax.Updater("tagsAnzeigen", "tagcloud.htm", {
					parameters: {
						id: window.sessionId,
						st: $F("style")
					}
				})
			}
		}
	},
	showTagForm: function(){
		var li = $("tagform")
		
			li.up("ol").select("li").invoke("removeClassName", "selected");
			li.addClassName("selected");
			$("tagsAnzeigen").removeClassName("selected");
			$("tagHinzufuegen").addClassName("selected");

	},
	createNewTagOnStyleAndReload: function (styleId, customerId, styleTagElement, allTagsElement, sessionId) {
		var newTag = $F('tagName');
		var url = 'styleTag.htm';
		var pars = 'id=' + sessionId + '&st=' + styleId + '&tag=' + newTag + '&cu=' + customerId + '&allTags=0';
		if (newTag && newTag != '' && Tags.checkTagText(newTag)) {
			var myAjax = new Ajax.Updater(
							{success: styleTagElement},
							url,
							{method: 'post', parameters: pars, evalScripts: true}
						);
			$('tagName').value = '';
		}
	},
	checkTagText: function (tagText) {
		if(tagText.match(/[\s<>#%&?,;:\'\"\.\+\(\)\[\]]+/) || tagText.match(/^\d.*/)) {
			alert("Ein Tag-Name darf nicht mit einer Ziffer beginnen und darf keine Sonder- oder Leerzeichen beinhalten. ");
			return false;
		}
	    return true;
	}
}

function showPopup(url){
	window.open(url,'','width=600,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0');
}

var Dialog = function(id, url){
	this.dialog = $(id)
	var index = -1
	var me = this;
	
	
	this.getWindowWidth= function(){
		return (self.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || 0);
	}
	this.getWindowHeight= function(){
		return (self.innerHeight ||  document.documentElement.clientHeight || document.body.clientHeight || 0);
	}


	this.getDialog = function(){
		return id;
	}
	this.close =  function(){
		me.dialog.hide()
		return false
	}
	this.updateContent = function(text){
		this.dialog.down(".overlayInner").replace(text)
	}
	this.show = function(removeIndex) {
		index = removeIndex
		
		this.positionAndShow()
		return false
	}
	this.submit = function() {
		this.dialog.hide()
		var wunschzettel = ""
		var wunschInput = $('zuWunschzettelHinzufuegen')
		if (wunschInput && wunschInput.checked) wunschzettel = "&wldid=1"
		window.location.href = url + index + wunschzettel 
		return false
	}
	this.confirmRequest = function(request){
		this.dialog.down(".overlaySubmitLeft").observe("click",function(e){me.close()})
		this.dialog.down(".overlaySubmitRight").observe("click",function(e){window.location.href = request;})
		
		this.positionAndShow()
		return false
	}
	this.confirmFunction = function(f){
		this.dialog.down(".overlaySubmitLeft").observe("click",function(e){me.close()})
		this.dialog.down(".overlaySubmitRight").observe("click",f)

		this.positionAndShow()
		return false
	}
	if(this.dialog.down(".cancel")){
		this.dialog.down(".cancel").observe("click", this.close);
	}
	this.dialog.down(".overlayClose").observe("click", this.close);

		
}
Dialog.prototype.positionAndShow = function(){
		this.dialog.show()
		var outer = this.dialog.down(".overlayOuter")
		var overlay = this.dialog.down(".overlay")
		var x = document.viewport.getHeight() / 2 - overlay.getHeight() / 2
		var y = document.viewport.getWidth() / 2 - overlay.getWidth() / 2
		overlay.setStyle({
			position: "absolute",
			top: x+"px",
			left: y+"px"
		})
		
	}
	
var vPlayer = {
	showVideo: function(file){
		if (file > 0) {
			var flashPath = "js-lib/mediaplayer.swf"
			var zvv = new SWFObject(flashPath, "flashVideo", "239", "334", "8", "#ffffff");
			zvv.addParam("wmode", "transparent");
			zvv.addParam('allowscriptaccess', 'always');
			zvv.addParam('allowfullscreen', 'true');
			zvv.addVariable('file', 'http://media.zoomoviewer.com/video/jungstil/' + file + '.flv');
			zvv.addVariable("showdigits", "false");
			zvv.addVariable("screencolor", "0x8B8C87");
			zvv.addVariable("enablejs", "true");
			zvv.addVariable("javascriptid", "zvvideo1");
			zvv.addVariable("autostart", "true");
			zvv.addVariable("width", "239");
			zvv.addVariable("height", "334");
			zvv.write("videoProxy");
			$("showVideoButtonContainer").hide();
			$("showImageButtonContainer").show();
			$$("div#videoProxy")[0].show();
		}
	},
	hideVideo: function(){
		if ($("showVideoButtonContainer") && $("showImageButtonContainer") && $("videoProxy")) {
			Element.show("showVideoButtonContainer");
			Element.hide("showImageButtonContainer");
			Element.fade($$("div#videoProxy")[0], {duration: 0.15});
			if ($('flashVideo')) $('flashVideo').sendEvent('stop');
		}
	}

}
function zvVideo(file) {
	var flashPath = "js-lib/mediaplayer.swf"
	var zvv = new SWFObject(flashPath, "videoProxy", "238", "335", "8", "#ffffff");
	zvv.addParam("wmode", "transparent");
	zvv.addParam('allowscriptaccess','always');
    zvv.addParam('allowfullscreen','true');
	zvv.addVariable('file','http://media.zoomoviewer.com/video/' + file + '.flv');
	zvv.addVariable("showdigits","false");
	zvv.addVariable("screencolor","0x8B8C87");
	zvv.addVariable("enablejs","true");
	zvv.addVariable("javascriptid","zvvideo1");
	zvv.addVariable("autostart","true");
	zvv.write("videoProxy");
}



function getUpdate(typ,pr1,pr2) {
	if (typ == 'time' && pr2 == 0 && pr1 != pr2) {
		vPlayer.hideVideo();
		if(player) player.hideVideo();
	}	
};

function getCookie(name){
   var i=0  //Suchposition im Cookie
   var suche = name+"="
   while (i<document.cookie.length){
      if (document.cookie.substring(i, i+suche.length)==suche){
         var ende = document.cookie.indexOf(";", i+suche.length)
         ende = (ende>-1) ? ende : document.cookie.length
         var cook = document.cookie.substring(i+suche.length, ende)
         return unescape(cook)
      }
      i++
   }
   return null
}

var wishList= {
	addToBasket: function(counter){
		$("fartikel"+counter).request({onComplete:function(response){
			var basketDialog = new Dialog('toBasketDialog')
			basketDialog.updateContent(response.responseText)
			basketDialog.positionAndShow();
		}})
	},
	sendByMail: function(){
		if(sendFormValidator.isValid())
		$('wishlistShare').request({onComplete:function(response){
			var sendDialog = new Dialog('sendDialog')
			sendDialog.updateContent(response.responseText)
			sendDialog.positionAndShow();
		}})
		$$('#wishlistShare input[type = "text"],#wishlistShare textarea').each(function(el){el.clear()})
	}
}
cleverForms = {
	initialize: function(){
		textInputs = $$("input[type=text],textarea")
		textInputs.each(function(tf){
			tf.isNotEmpty = function(){
				return this.value != this.getAttribute("default") && this.value.length > 0
			}
				
			defaultvalue = tf.getAttribute("default")
			if (defaultvalue && tf.value == "") {
				tf.value = defaultvalue
				tf.observe("focus", cleverForms.makeEmptyIfDefault)
				tf.observe("blur", cleverForms.makeDefaultIfEmpty)
			}
		})
		buttons = $$("input[type=submit]")
		buttons.each(function(button){
			button.observe("click", cleverForms.makeEmptyIfDefaultForWholeFormHandler)
			
		})
	},
	makeEmptyIfDefault: function(e){
		var ele = Event.element(e)
		if (ele.hasAttribute("default")) {
			if (ele.value == ele.getAttribute("default")){ 
				ele.value = ""
			}
		}
	},
	makeDefaultIfEmpty: function(e){
		var ele = Event.element(e)
		if (ele.hasAttribute("default")) {
			if (ele.value == ""){ 
				ele.value = ele.getAttribute("default")
			}
		}
	},
	makeEmptyIfDefaultForWholeFormHandler: function(e){
		var ele = Event.element(e)
		cleverForms.makeEmptyIfDefaultForWholeForm(ele)
	},
	makeEmptyIfDefaultForWholeForm: function(ele) {
		var textFields = $(ele).up("form").select("input[type=text],textarea")
		textFields.each(function(tf){
			var defaultvalue = tf.getAttribute("default")
			if ( defaultvalue && tf.value == defaultvalue) 
				tf.value = ""
		})
	}
}
function FormValidator(name){
	FormValidator.ERROR_TYPE_BUBBLE = 1;
	FormValidator.ERROR_TYPE_BUBBLE_ID = 2;
	this.errorType = 0;
	var me = this;
	this.formName = name;
	var myForm = document.forms[me.formName]
	this.errorPostfix = "Error";
	this.requiredFields = new Array();
	this.specialFormatFields = new Array();
	this.repeatingFields = new Array();
	this.customFields = new Array();
	
	valueOf = function(field){
		return myForm.elements[field].value
	}
	
	this.registerEventHandler=function(){
		$(myForm).observe("submit",me.checkAndSubmit)
	}
	
	this.setErrorPostfix = function(errorPostfix){
		me.errorPostfix = errorPostfix;
	}
	
	this.setErrorType = function(t){
		if(t == FormValidator.ERROR_TYPE_BUBBLE){
			me.showErrorFor = me.showErrorBubble
		}
		if(t == FormValidator.ERROR_TYPE_BUBBLE_ID){
			me.showErrorFor = me.showErrorBubbleWithId
		}
	}
	
	this.setRequiredFields = function(){
		l = me.requiredFields.length
		for( i = l; i < arguments.length; i++){
			me.requiredFields[i] = new Array(2)
			me.requiredFields[i][0] = arguments[i];
		}
	}
	
	this.validatePresenceOf = function(name,errorMsg){
		l = me.requiredFields.length
		me.requiredFields[l] = new Array(2);
		me.requiredFields[l][0] = name;
		me.requiredFields[l][1] = errorMsg;
	}
	
	this.validateEquality = function(id, idWdh, errorMsg){
		l = me.repeatingFields.length
		me.repeatingFields[l] = new Array(3);
		me.repeatingFields[l][0] = id;
		me.repeatingFields[l][1] = idWdh;
		me.repeatingFields[l][2] = errorMsg;
	}
	
	this.validateWithFunction = function(name, funct, errorMsg){
		l = me.customFields.length
		me.customFields[l] = new Array(3);
		me.customFields[l][0] = name;
		me.customFields[l][1] = funct;
		me.customFields[l][2] = errorMsg;
	}
	
	this.validateNumerical = function(name, errorMsg){
		me.validateFormatOf(name, /^[0-9]+$/, errorMsg)
	},

	this.validateLengthOf = function(id, min, max, errorMsg){
		if(max){
			regexstring = "^.{" + min + ","+ max + "}$";
		}
		else{
			regexstring = ".{" + min + ",}";
		}
		var regex = new RegExp(regexstring)
		me.validateFormatOf(id, regex, errorMsg)
	}
	
	this.validateFormatOf = function(id, regex, errorMsg){
		l = me.specialFormatFields.length;
		me.specialFormatFields[l] = new Array(3);
		me.specialFormatFields[l][0] = id;
		me.specialFormatFields[l][1] = regex;
		me.specialFormatFields[l][2] = errorMsg;
	}
	
	this.showErrorFor = function(id){
		myForm[id[0]].focus();
		alert(id[id.length-1]);
	}
	
	this.showErrorBubbleWithId = function(entry){
		$(myForm).select(".eingabeFehler").invoke("hide")
		var bubble = $(entry[entry.length-1]).show();
		if(typeof layerProtect == "function"){
			layerProtect(bubble);
			var parentTd = bubble.up("td");
			if(parentTd) 
				parentTd.setStyle({zIndex:100})
		}
	}
	
	this.showErrorBubble = function(id){
		$(myForm).select(".eingabeFehler").invoke("hide")
		var field = myForm[id[0]]
		field.focus();
		var bubble = $(field).next(".eingabeFehler").show();
		if(typeof layerProtect == "function"){
			layerProtect(bubble);
			var parentTd = bubble.up("td");
			if(parentTd) 
				parentTd.setStyle({zIndex:100})
		}
	}
	
	this.checkRequiredFields = function(){
		for(i = 0; i < me.requiredFields.length; i++){
			entry = me.requiredFields[i]
            field = document.forms[me.formName][entry[0]]
                                                
			if( ( typeof field.isNotEmpty != "function" && $F(field).length == 0) || !field.isNotEmpty() ){
				me.showErrorFor(entry)
				return false;
			}
		}
		return true;
		
	}
	
	this.checkFieldFormats = function(){

		for(i = 0; i < me.specialFormatFields.length;i++){
			if(!valueOf(me.specialFormatFields[i][0]).match(me.specialFormatFields[i][1])){
				me.showErrorFor(me.specialFormatFields[i])
				return false;
			}
		}
		return true;
	}
	
	this.checkRepeatingFields = function(){
		for(i = 0; i < me.repeatingFields.length;i++){
			if(valueOf(me.repeatingFields[i][0]) != valueOf(me.repeatingFields[i][1])) {
				me.showErrorFor( me.repeatingFields[i] )
				return false;
			}
		}
		return true;
	}
	
	this.checkCustomFields = function(){
		for(i = 0; i < me.customFields.length;i++){
			funct = me.customFields[i][1];
			if(! funct(valueOf(me.customFields[i][0]))){
				me.showErrorFor(me.customFields[i]);
				return false;
			}
		}
		return true
	}
	this.isValid = function(){
		return me.checkRequiredFields() && me.checkFieldFormats() && me.checkRepeatingFields() && me.checkCustomFields()
	}
	this.checkAndSubmit = function(){
		//$$(".loginerror").invoke("hide");
		if(me.isValid()){
			myForm.submit();
		}
	}
}

/*
	ZoomoViewer Object
	
*/

ZoomoViewer = function () {
}
ZoomoViewer.prototype = {
	_plugIns: [],
	_images: [],
	_params: [],
	width: 450,
	height: 500,
	clientID: '',
	serverName: 'http://asp.zoomoviewer.com',
	appPath: '/html/zoomapp/',
	plugInPath: '/html/zoomapp/plugins/',
	servletPath: '/servlet/ImageData',
	// bp only:
//	language: pk.substr(1, pk.lastIndexOf("/") - 1),
	
	addImage: function (img, url) {
		if (url == undefined) url = "";
		this._images.push({name: img, url: url});
	},
	
	addPlugIn: function (plug){
		this._plugIns.push(plug);
	},
	
	addParam: function(name, value){
		// compatible to prototype
		this._params[name] = {value: value, zv: true};
	},
	
	start: function () {
		var imageURL = this.serverName + this.servletPath +'?clientId='+this.clientID;
		imageURL += this._getImages();
		
		var zvParameter = 'imageURL='+escape(imageURL)
		var itsme = "&referrer=" + encodeURIComponent(document.referrer);
		zvParameter += escape( itsme );
		zvParameter += this._getPlugIns() + this._getParams(); 
		zvParameter += '&lang=' + this.language;
		
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+this.width+'" height="'+this.height+'" id="zoomo_main" align="middle">');
		document.write('<param name="movie" value="' + this.serverName + this.appPath + 'zoomo07.swf?'+ zvParameter +'" />');
		document.write('<embed src="' + this.serverName + this.appPath + 'zoomo07.swf?'+zvParameter+'" quality="high" width="'+this.width+'" height="'+this.height+'" name="zoomo_main" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		document.write('</object>');
	},
	
	_getImages: function () {
		var str = "";
		for (var i = 0; i < this._images.length; i++) {
			str += "&image=" + this._images[i].name;
			str += "&url=" + this._images[i].url;
		}
		return str;
	},
	
	_getPlugIns: function () {
		var str = "&plugIns=";
		for (var i = 0; i < this._plugIns.length; i++) {
			str += this.serverName + this.plugInPath + this._plugIns[i] + "|";
		}
		return str.substring(0, str.length - 1);
	},
	
	_getParams: function () {
		var str = "";
		for (var p in this._params) {
			if (this._params[p].zv) 
				str += "&" + p + "=" + this._params[p].value;
		}
		return str;
	},
	
	startSWFObject: function (divID) {
		var imageURL = this.serverName + this.servletPath +'?clientId='+this.clientID;
		imageURL += this._getImages();
		
		var zvParameter = 'imageURL='+escape(imageURL)
		zvParameter += this._getPlugIns() + this._getParams();
	
		var so = new SWFObject(this.serverName + this.appPath + "zoomo07.swf?" + zvParameter, "ZoomoViewer", this.width, this.height, "6", "#FFFFFF");
		so.write(divID);
	}
}
landmark = {
	call: function(url){
		if(url && url.length > 0){
			new Ajax.Request(url);
		}
		return false;
	}
}

// newletter
var newsletter = {
	
	openNewsletter:function(error_element) {
	   if ( this.checkEmail( $('ns_entry_email').value ) ) {
	      var addDialog = new Dialog('newsletterDialog');
   	      addDialog.positionAndShow();
          $('nsemail').innerHTML = $('ns_entry_email').value;
          return false;
	   } else {
		  $(error_element).show();
		  return false;
	   }
    },
		
	anmelden:function() {
		  $('nserror').hide(); 

		  var info = "";
		  if ("anmelden" == this.checkradio(document.newsletterForm.nsauswahl)) {
			 if ($('nsvorname').value.length > 1) {
			   info = $('ns_entry_email').value + "," + this.selectWert(document.newsletterForm.nsanrede) + "," + $('nsvorname').value + "," + $('nsnachname').value + ",0";
			 } else {
			   $('nsvorname').style.backgroundColor="#FFDDDD";
			   return false;
		     }
		  } else {
			  info = $('ns_entry_email').value + ",_,_,_,1";
		  }
		  
		  new Ajax.Request('/akn/ajaxNewsletterCall.htm?ns_values=' + info);     
		  
		  var ns_register_Dialog = new Dialog('newsletterRegisterDialog')
		  var ns_delete_Dialog = new Dialog('newsletterDeleteDialog')

		  var addDialog = new Dialog('newsletterDialog');
    	  $('nsemail').innerHTML='';
		  $('ns_entry_email').value='';
 		  $('nsvorname').value = ''; 
 		  $('nsnachname').value = '';
  		  addDialog.close();
		  
  		  if ("anmelden" == this.checkradio(document.newsletterForm.nsauswahl)) {
  			  ns_register_Dialog.positionAndShow();
  	  		  setTimeout(function(){ns_register_Dialog.close()}, 8000);
		  } else {
			  ns_delete_Dialog.positionAndShow();  
  	  		  setTimeout(function(){ns_delete_Dialog.close()}, 8000);
		  }
  		  return false;
	},
	close_timeout:function(elem) {
		alert(elem);
	},
	close_err:function(feld, elem) {
		$(feld).hide();
		if (elem.value == 'Email Adresse') {
			elem.value = '';
		}
		return false;
	},

	checkradio:function(feld) {
		for (i=0; i<feld.length; i++){
				if(feld[i].checked == true){
					return feld[i].value;
				}
		}
	},
	
	selectWert: function(feld) {
	    for (var i=0; i<feld.length; i++) if (feld[i].selected) return feld[i].value;
	},
	
	checkEmail:function(emailStr) {
	  var checkTLD=0;
	  // TLDs Liste
	  var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	  // user@domain format
	  var emailPat=/^(.+)@(.+)$/;
	  // Liste zeichen ( ) < > @ , ; : \ " . [ ]
	  var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	  var validChars="\[^\\s" + specialChars + "\]";
	  // in Anfuehrungszeichen? (dann sind special charakters erlaubt)
	  var quotedUser="(\"[^\"]*\")";
	  // domains mit IP addressen
	  var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	  var atom=validChars + '+';
	  var word="(" + atom + "|" + quotedUser + ")";
	  var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	  var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	  var matchArray=emailStr.match(emailPat);
	  if (matchArray==null) {
	     return false;
	  }
	  var user=matchArray[1];
	  var domain=matchArray[2];
	  // test gueltige ASCII characters (0-127).
	  for (i=0; i<user.length; i++) {
	     if (user.charCodeAt(i)>127) {
	        return false;
	     }
	  }
      for (i=0; i<domain.length; i++) {
         if (domain.charCodeAt(i)>127) {
            return false;
         }
      }
      if (user.match(userPat)==null) {       
         // user nicht OK
         return false;
      }
      // IP addresse OK
      var IPArray=domain.match(ipDomainPat);
      if (IPArray!=null) {
         // es handelt sich um eine IP-Adresse
         for (var i=1;i<=4;i++) {
	         if (IPArray[i]>255) {
	            return false;
	         }
	     }
	     return true;
	  }
      // Domain ist ein "symbolic name",  gueltig ?
      var atomPat=new RegExp("^" + atom + "$");
      var domArr=domain.split(".");
      var len=domArr.length;
      for (i=0;i<len;i++) {
          if (domArr[i].search(atomPat)==-1) {
             return false;
          }
      }
      /*
        domain name valid, testen bekannte top-level domain
        hostname vorangestellt ?
      */
      if (checkTLD && domArr[domArr.length-1].length!=2 &&
          domArr[domArr.length-1].search(knownDomsPat)==-1) {
         return false;
      }
      // hostname vorangestellt ?
      if (len<2) {
         return false;
      }
      return true;
   }
}
//construktiv GmbH // trafficmaxx
//(c) 2006 construktiv GmbH

function tm_tracker() {
	var pageTitle = document.title;
	var pageUrl = document.URL;

	var page="http"+(document.URL.indexOf('https:')==0?'s':'')+'://s2.trafficmaxx.de/thx.php?sid='+tm_sid+"\x26java=y";
	var tm_ref = escape(parent==self?document.referrer:top.document.referrer);
	tm_ref = (typeof(top.document)=="object")?top.document.referrer:tm_ref;
	var tm_lang = navigator.userLanguage?navigator.userLanguage:navigator.language;

	if (typeof(tm_pageCategory)=="undefined") tm_pageCategory = "";  if (typeof(tm_conversionName)=="undefined") tm_conversionName = "";  if (typeof(tm_campaignName)=="undefined")  tm_campaignName = "";
	
	tm="\x26swidth="+swidth;
	tm+="\x26sheight="+sheight;
	tm+="\x26scolor="+scolor;
	tm+="\x26la="+escape(tm_lang.toLowerCase());
	tm+="\x26pageTitle="+escape(pageTitle);
	tm+="\x26pageUrl="+escape(pageUrl.toLowerCase());
	tm+="\x26pageCategory="+escape(tm_pageCategory);
	tm+="\x26campaignName="+escape(tm_campaignName);
	tm+="\x26ref="+escape(tm_ref.toLowerCase());
	tm+="\x26conversionName="+escape(tm_conversionName);
	pq = new Image();
	pq.src = page+tm;
}