if(typeof console == 'undefined') {
	console = {
		assert: function() {},
		count: function() {},
		debug: function() {},
		dir: function() {},
		dirxml: function() {},
		error: function() {},
		groupEnd: function() {},
		group: function() {},
		info: function() {},
		log: function() {},
		profileEnd: function() {},
		profile: function() {},
		timeEnd: function() {}, 
		time: function() {},
		trace: function() {},
		warn: function() {}
	}
}

luehr=function(){
	var SLIDESHOW_MOVIE = '/fileadmin/templates/swf/luehr_slideshow.swf';
	var FLASH_VERSION = '9';
	var FLASH_DOWNLOAD_URL = 'http://www.macromedia.com/go/getflashplayer';

	var fontSizes = [ '80%', '90%', '100%', '110%', '120%' ];
	var currFontsize = 2;

	function initIeFixes() {
		$('a button.shopButton').click(function() {
			$(this).parents('a')[0].click();
		});
	}

	function initFontsize() {
		$("#fontEnlarge").click(function() {
			if(currFontsize < fontSizes.length - 1) {
				currFontsize++;
				$("#wrapper").css('fontSize', fontSizes[currFontsize]);
				this.blur();
			}
			return false;
		});

		$("#fontDeminish").click(function() {
			if(currFontsize > 0) {
				currFontsize--;
				$("#wrapper").css('fontSize', fontSizes[currFontsize]);
				this.blur();
			}
			return false;
		});
	}

	function initSlideshow() {
		var attributes = null;
		var slideshow = $('div.slideshow');
		var id = slideshow.attr('id');
		var width = slideshow.find('.sl-master-image img').width();
		var height = slideshow.find('.sl-master-image img').height();
		var zoomfactor = $('#slideshow_zoomfactor').val();
		var zoomtime = $('#slideshow_zoomtime').val();
		var fadetime = $('#slideshow_fadetime').val();
		if(typeof zoomfactor == 'undefined' || zoomfactor == '' || zoomfactor < 100) {
			zoomfactor = 120;
		}
		if(typeof zoomtime == 'undefined' || zoomtime == '' || zoomtime < 1) {
			zoomtime = 5;
		}
		if(typeof fadetime == 'undefined' || fadetime == '' || fadetime < 1) {
			fadetime = 1;
		}

		var xml = '<set zt="' + zoomtime +'" zf="' + zoomfactor + '" tt="' + fadetime + '">';
		slideshow.find('.slideshow-images img').each(function(i, val) {
			var src = $(val).attr('src');
			var url = $(val).parent('a').attr('href');
			if(typeof url == 'undefined') {
				url = '#';
			}
			xml += '<img src="' + src + '" url="' + url + '" />';
		})
		xml += '</set>';

		if($.browser.msie) {
			xml = xml.replace(/"/g, '&quot;');
		}

		swfobject.embedSWF(SLIDESHOW_MOVIE,
		                   id,
		                   width,
		                   height,
                                   FLASH_VERSION,
		                   FLASH_DOWNLOAD_URL,
		                   {
			                   s_width: width,
			                   s_height: height,
			                   ss_xml: xml
                                   },
                                   {
				           play: 'true',
				           quality: 'high',
				           loop: 'true',
				           scale: 'showall',
				           wmode: 'window',
				           menu: 'true',
				           devicefont: 'false',
				           salign: '',
			                   bgcolor: '#000000',
				           allowscriptaccess: 'sameDomain',
				           allowfullscreen: 'false'
				   },
                                   {
				           align: 'middle'
			           }
		);
	}

	function initShopImages() {
		$('.smallImages img').mouseover(function() {
			$('.tx-slnanoshop-pi1-singleViewField-bigImage').hide();
			$($(this).parents('.tx-slnanoshop-pi1-singleViewField-smallImage').attr('id').replace(/smallImage/, '#bigImage')).show();
		});
	}

	function initPrintButton() {
		$('#printButton').click(function() {
			window.print();
		});
	}

	function init() {
		initIeFixes();
		initFontsize();
		initSlideshow();
		initShopImages();
		initPrintButton();
	}

	return {
		init: init
	};
}();

$(luehr.init);

