function beschreibung_wechsel(){
	if(document.getElementById('beschreibung2').style.display=="none"){
	//	document.getElementById('beschreibung1').style.display="block";
	//	document.getElementById('beschreibung2').style.display="block";
		Effect.BlindDown('beschreibung2');
	}else{
	//	document.getElementById('beschreibung1').style.display="none";
	//	document.getElementById('beschreibung2').style.display="none";
		Effect.BlindUp('beschreibung2');
	}
}


 function isDefined(variable)
{
return (!(!(document.getElementById(variable))))
}
 	var zxVideoAd = new Class({
 		Implements: Options,
 		options: {
 		},
 
 		initialize: function(name, options){
 			this.name = name;
 			this.container = ($(options.container)) ? $(options.container) : document.body;
 			this.container.addClass('zxContainer');
 
  		this.setOptions(options);
  		this.searchYoutube(this.options.keywords, 1, this.name+'.handleYoutube');
 		},
 		addScript: function(source, properties) {
 			properties = $extend({
					onload: $empty,
					document: document,
					check: $lambda(true)
				}, properties);
 
				var script = new Element('script', {'src': source+'&t=' + new Date().getMinutes(), 'type': 'text/javascript'});
 
				var load = properties.onload.bind(script), check = properties.check, doc = properties.document;
				delete properties.onload; delete properties.check; delete properties.document;
 
				script.addEvents({
					load: load,
					readystatechange: function(){
						if (['loaded', 'complete'].contains(this.readyState)) load();
					}
				}).setProperties(properties);
 
 
				if (Browser.Engine.webkit419) var checker = (function(){
					if (!$try(check)) return;
					$clear(checker);
					load();
				}).periodical(50);
 
				return script.inject(doc.head);
 		},
 
 		searchYoutube: function(q, items, callback) {
   	var url = 'http://gdata.youtube.com/feeds/base/videos?client=ytapi-youtube-search&alt=json-in-script&v=2';
   	if (items) url += '&max-results=' + items;
   	if (callback) url += '&callback=' + callback;
   	if (q) url += '&q=' + q;
   	this.addScript(url);
  	},
 
  	handleYoutube: function(data) {
  		var zxVideo = new Element('div', {
  			'class': 'zxVideo'
  		}).injectInside(this.container);     
   	var item = data.feed.entry[0];
   	//zxVideo.set('html', item.content.$t);  //hier wird das video von youtbe eingebunden    
   	var q = item.title.$t;
 
  		var version = '2009-02-01';
  		var adspace = null;
  		var region = 'de';
  		var programs = '660';
  		var category = null;
  		var page = '0';
  		var items = '10';
  		var minPrice = '0';
  		var maxPrice = '100000';
 
   	this.zxContextMatch(version, this.options.appId, adspace, region, programs, category, minPrice, maxPrice, 0, items, q, this.name+'.handleAds');
  	},
 
  	handleAds: function(data) {
  		if (data.productsResult) {
  			var productItems = data.productsResult.productItem;
  		    //alert(productItems.length);
  	//	 var h2_ads = new Element('h2', {'class':'zxAdHeader'}).set('text', 'Spannendes zu "###ueberschrift###"').injectInside(this.container);   
    	var zxAdList = new Element('ul', {
    		'class': 'zxAdList'
    	});
		var products_with_image = 0;
    	for (var i = 0; i < productItems.length; i++) {
    	//alert(i);
    		if(i==2){
  				var h2_ads = new Element('h2', {'class':'zxAdHeader'}).set('text', 'Spannendes zu "###ueberschrift###"').injectInside(this.container);
    		}  
			
			if(products_with_image==Number(this.options.items)) {
    			break;
    		}
     	var productItem = productItems[i];
     	var link = '';
     	if (productItem.url.adspace instanceof Array) {
      	// select tracking link related to the first Adspace
      	link = productItem.url.adspace[0].$;
     	} else {
      	link = productItem.url.adspace.$;
     	}
     	var content = productItem.name + ' bei ' + productItem.program.$ + ' für ' + productItem.price + ' ' + productItem.currency;
        
     	var li = new Element('li').injectInside(zxAdList);
     	var a = new Element('a', {
     		'href': link
     	}).injectInside(li);
     	var span_name = new Element('span', {
     		'class': 'zxProductName'
     	}).set('text', productItem.name);
     	
     	if(!productItem.currency){
		 	productItem.currency="";
		 }
		 if(!productItem.description){
		 	productItem.description="";
		 }
		 //productItem.description
     	var span_price = new Element('span', {
     		'class': 'zxProductPrice'
     	}).set('html', '');//Preis: '+'<em>'+productItem.currency + ' ' + productItem.price);     
     	//alert(productItem.description.length); 
     //	if(productItem.description.length!=0){
			 var span_info = new Element('span', {'class': 'zxProductInfo'}).set('html', productItem.description+'<span class=zxProductPrice>Preis: '+'<em> ' + productItem.price.toFixed(2)+productItem.currency+'</span>');
     	//};
     	
     	if(productItem.image)var image_url = (productItem.image.small) ? productItem.image.small : (productItem.image.medium) ? productItem.image.medium : '';
     	if(image_url!='') {
     		products_with_image++;
     		var image = new Element('span', {
     			'class': 'zxProductImage',
     			'styles': {
	     			'background': 'url('+image_url+') center'
 	    		}
  	   		}).injectInside(a);
   	  		
     	}
        a.adopt(span_name).adopt(span_info).adopt(span_price);
     	//alert(productItem.image.small);
    	}
    	zxAdList.injectInside(this.container);
   	}
  	},
 
  	zxContextMatch: function(version, applicationid, adspace, region, programs, category, minPrice, maxPrice, page, items, q, callback) {
   	var url = 'http://api.zanox.com/json/' + version + '/products?applicationid=' + applicationid;
   	if (adspace) url += '&adspace=' + adspace;
   	if (region) url += '&region=' + region;
   	if (programs) url += '&programs=' + programs;
   	if (category) url += '&category=' + category;
   	if (page) url += '&page=' + page;
   	if (items) url += '&items=' + items;
   	if (minPrice) url += '&minPrice=' + minPrice;
   	if (maxPrice) url += '&maxPrice=' + maxPrice;
   	if (callback) url += '&callback=' + callback;
   	if (q) url += '&q=' + q;
   	this.addScript(url);
  	}
 
		});
 
