//>> Print link and recommendation link for footer nav
	//Adds the standard addControls to the footer navigation
	//When there's no print link on the page (e.g. contact page) no link will be constructed for the footer nav, too
	FooterAddControlHandler = $.extend(
		$.clone(LLObject),
		{
			create: function () {
				var o = LLObject.create.call(this);
				o.topAddControlShell = $('td.contentMainColumn div.topAddContrContainer');
				o.footerNaviPrintItem = $('#footerPrint');
				o.footerNaviRecomItem = $('#footerRecom');
				o.handlePrintInfo();
				o.handleRecomInfo();
				return o;
			},
			handlePrintInfo: function () {
				if (this.topAddControlShell.find('td.printButton a').length > 0) {
					var printLink = this.topAddControlShell.find('td.printButton a');
					this.footerNaviPrintItem.append(printLink);
				}
			},
			handleRecomInfo: function () {
				if (this.topAddControlShell.find('td.recomButton a').length > 0) {
					var recomLink = this.topAddControlShell.find('td.recomButton a');
					this.footerNaviRecomItem.append(recomLink);
				}
			}
		}
	);
//<<


// >> Selectbox to FlyoutList
	//el = element which contains the selectbox and is used for flyout handler
	
	SelectboxSpecLayout = $.extend(
		$.clone(LLObject),
		{
			create: function (el, title) {
				var o = LLObject.create.call(this);
				o.selectBoxOuter = $(el);
				o.itemsMax = 100;
				o.itemsAll = null;
				o.currScrollItem = 0;
				o.title = title || null;
				o.editSelectboxLayout();
				return o;
			},
			editSelectboxLayout: function () {
				var self = this;
				if (this.selectBoxOuter.find('select').length > 0) {
					this.setLayout();
					this.getSelectboxItemsAndTitle();
					this.selectBoxOuter.find('div.item div').bind('click', function (e) {
						self.handleOptions($(this));
						self.selectBoxOuter.find('div.selectBoxDes').removeClass('selectBoxDes_hover');
					});
					this.selectBoxOuter.find('div.item div').hover(
						function() {$(this).addClass('hover')},
						function() {$(this).removeClass('hover');}
					);
					this.selectBoxOuter.hover(
						function() {$(this).find('div.selectBoxDes').addClass('selectBoxDes_hover')},
						function() {$(this).find('div.selectBoxDes').removeClass('selectBoxDes_hover');}
					);
				}
			},
			layoutOuter: function () {
				var sty = '';
				if (this.title) {
					sty = " selectBoxHeaderWithText"
				}
				
				var layOuter = $(
					'<div class="selectBoxDes">' +
						'<div class="selectBoxHeader' + sty + '">' +
							'<div class="sbhDes1"></div>' +
						'</div>' +
						'<div class="selectBoxList">' +
							'<div class="sblDes1">' +
								'<div class="inner"></div>' +
							'</div>' +
						'</div>' +
					'</div>'
				);
				return layOuter;
			},
			layoutItem: function (mode, prompt) {
				var style, layItem;
				
				if (mode === "here") {
					style = "noLink"
				} else {
					style = "normal"
				}
				
				layItem = $('<div class="item"><div class="' + style + '"><span>' + prompt + '</span></div></div>');
				return layItem;
			},
			getSelectboxItemsAndTitle: function () {
				var url, prompt, mode, options, self=this, title;
				title = this.title;
				options = this.selectBoxOuter.find('select option');
				
				this.itemsAll = options.length;
				
				options.each(function (i) {
					prompt = $(this).text();
					if ($(this).attr('selected') === true) {
						mode = "here"
						title = $(this).text();
					} else {
						mode = "standard"
					}
					self.selectBoxOuter.find('div.selectBoxList div.inner').append(self.layoutItem(mode, prompt));
				});
				if (title) {
					this.selectBoxOuter.find('div.selectBoxHeader div.sbhDes1').text(title);
				}
			},
			setLayout: function () {
				this.selectBoxOuter.wrap('<div class="selectBoxOuterShell"></div>');
				this.selectBoxOuter.append(this.layoutOuter());
			},
			handleOptions: function (selectedItem) {
				var optName = $(selectedItem).text();
				this.selectBoxOuter.find('div.item div').attr('class', 'normal');
				this.selectBoxOuter.find('option').removeAttr('selected');
				$(selectedItem).attr('class', 'noLink');
				this.selectBoxOuter.find('option[text="' + optName + '"]').attr('selected', 'selected');
				this.selectBoxOuter.find('div.selectBoxHeader div.sbhDes1').text(optName);
			}
		}
	);
// <<


//>> Slideshow with preview images
	SlideshowHandler = $.extend(
		$.clone(LLObject),
		{
			create: function (options) {
				var o = LLObject.create.call(this);
				o.slideshowItems = $('td.contentMainColumn div.co_slideShow');
				o.slideshowTargetID = 'slideShowContainer';
				o.slideshowContainer = null;
				o.previews = [];
				o.details = [];
				o.defaults = {
					replaceCont: null,
					highlightDiffX: 0,
					highlightDiffY: 0,
					nextItem: 0,
					zIndex: 2
				};
				if (options) $.extend(o.defaults, options);
				for (var k in o.defaults) o[k] = o.defaults[k];
				o.make();
				return o;
			},
			make: function () {
				this.collectItems();
				this.setLayout();
				this.fillBoxShells();
				//this.handleDetails();
				this.handlePreviews();
			},
			collectItems: function () {
				var self = this;
				this.slideshowItems.each(function (i) {
					var detailURL = $(this).find('div.paraImgInner a').attr('href');
					self.previews.push($(this).find('div.paraImgInner a img'));
					self.details.push($('<img src="' + detailURL + '" alt="" />'));
				});
			},
			setLayout: function () {
				var layout;
				layout = '<div class="inner">' +
					'<div class="previewBox"><div class="inner"></div></div>' +
					'<div class="detailBox"><div class="inner"></div></div>' +
				'</div>';
				if ($('#' + this.slideshowTargetID).length > 0) {
					$('#' + this.slideshowTargetID).append(layout);
				} else {
					layout = $('<div id="' + this.slideshowTargetID + '">' + layout + '</div>');
					$('td.contentColumn div.contColDes5').append(layout);
				}
				this.slideshowContainer = $('#' + this.slideshowTargetID);
			},
			fillBoxShells: function () {
				var self = this;
				$(this.previews).each(function (i) {
					self.slideshowContainer.find('div.previewBox div.inner').append($(this));
				});
				$(this.details).each(function (i) {
					self.slideshowContainer.find('div.detailBox div.inner').append($(this));
				});
				if (this.replaceCont) {
					this.replaceCont.replaceWith(this.slideshowContainer);
				}
			},
			animateDetails: function (itemNr, animate) {
				var zindex, items, maxItems, item;
				items = this.slideshowContainer.find('div.detailBox img');
				maxItems = items.length - 1;
				
				if (itemNr == -1) {
					item = this.nextItem;
					this.nextItem++;
				} else {
					item = itemNr;
					if (item == maxItems) {
						this.nextItem = 0;
					} else {
						this.nextItem++;
					}
				}
				
				if (animate) {
					$(items[item]).fadeIn(2000).css("z-index", this.zIndex);
					// Negative number combined with "mod" results negative number.
					// Workaround: Handle the special items yourthis...
					$(items[item]).nextAll().css("z-index", 1);
					if ((item - 2) >= 0 ) {
						$(items[item - 2]).hide().css("z-index", 1);
					} else {
						$(items[items.length + item - 2]).hide().css("z-index", 1);
					}
				} else {
					$(items).hide().css("z-index", 1);
					$(items[item]).show().css("z-index", this.zIndex);
				}
			},
			animatePreviews: function (itemNr, animate) {
				var highlight, imgX, imgY, highlightX, highlighY, item;
				item = this.nextItem;
				if (itemNr > -1) item = itemNr;
				if ($('#slideShowHighlight').length === 0) {
					$('body').prepend(Utils.pixel().attr('id', 'slideShowHighlight'));
				}
				highlight = $('#slideShowHighlight');
				imgX = this.slideshowContainer.find('div.previewBox div.inner img').eq(item).offset().left;
				imgY = this.slideshowContainer.find('div.previewBox div.inner img').eq(item).offset().top;
				highlightX = imgX+this.highlightDiffX;
				highlightY = imgY+this.highlightDiffY;
				if (animate) {
					highlight.animate({'top': highlightY, 'left': highlightX}, 1000);
				} else {
					highlight.css({'top': highlightY, 'left': highlightX});
				}
			},
			handlePreviews: function () {
				var self = this, timer;
				this.animatePreviews(-1);
				this.animateDetails(-1);
				this.slideshowContainer.find('div.previewBox div.inner img').each(function (i) {
					$(this).bind('click', function (e) {
						(function(i) {
							clearInterval(timer);
							self.animatePreviews(i);
							self.animateDetails(i);
						}(i));
					});
				});
				timer = setInterval(function () {
					self.animatePreviews(self.nextItem, true);
					self.animateDetails(self.nextItem, true);
				}, 3000);
			}
		}
	);
//<<


//>> add special class for focused input fields to work with IE
	function handleInputFocus(el) {
		var searchPhrase = $('input:text, input:password');
		var searchPhraseTextarea = $('textarea');
		if (el) {
			searchPhrase = el.find('input:text, input:password');
			searchPhraseTextarea = el.find('textarea');
		}
		
		searchPhrase.wrap('<div class="specialInputField"><div class="sif_des1"><div class="sif_des2"></div></div></div>'
		).focus(
			function(e){$(this).parents('div.specialInputField').addClass('specialInputField_focus');}
		).blur(
			function(e){$(this).parents('div.specialInputField').removeClass('specialInputField_focus');}
		);
		
		searchPhraseTextarea.wrap('<div class="specialTextareaField"><div class="sif_des1"><div class="sif_des2"></div></div></div>'
		).focus(
			function(e){$(this).parents('div.specialTextareaField').addClass('specialTextareaField_focus');}
		).blur(
			function(e){$(this).parents('div.specialTextareaField').removeClass('specialTextareaField_focus');}
		);
	}
//<<


// >> contactForm handler
	contactFormHandler = $.extend(
		$.clone(LLObject),
		{
			create: function () {
				var o = LLObject.create.call(this);
				o.contactForm = $('div.contactForm');
				o.fieldPromptArray = [];
				o.handleFields();
				return o;
			},
			handleFields: function () {
				var self = this;
				
				SelectboxSpecLayout.create('div.contactForm div.selectBoxesShell div.selectOuter','Arbeitsgerät auswählen');
				//SelectboxSpecLayout.create('div.contactForm td.col2 div','Arbeitshöhe auswählen');
				//SelectboxSpecLayout.create('div.contactForm td.col3 div','Reichweite auswählen');
				
				this.contactForm.find('input:text, textarea').each(
					function (i) {
						$(this).attr('id', 'contactForm_' + $(this).attr('name'));;
						self.fieldPromptArray.push($(this).attr('id'));
					}
				);
				handleFieldPrompt(this.fieldPromptArray);
			}
		}
	);
//<<


//>> rent programm overview handler
	rentProgrammOvHandler = $.extend(
		$.clone(LLObject),
		{
			create: function () {
				var o = LLObject.create.call(this);
				o.ovItems = $('div.rentProgOvItem');
				o.handleItems();
				return o;
			},
			handleItems: function () {
				this.ovItems.each(function (i) {
					$(this)
					.mouseover(function () {$(this).addClass('rentProgOvItem_hover');})
					.mouseout(function () {$(this).removeClass('rentProgOvItem_hover');})
					.mousedown(function () {if ($(this).find('a').length > 0 ) $(this).addClass('rentProgOvItem_clicked')})
					.mouseup(function () {
						if ($(this).find('a').length > 0 ) {
							$(this).removeClass('rentProgOvItem_clicked');
							var itemUrl = $(this).find('a').eq(0).attr('href');
							window.location.href = itemUrl;
						}
					});
				});
				specialClickHandler.create(this.ovItems, 'td.icon img')
			}
		}
	);
//<<


//>> rent programm detail handler
	rentProgrammDetailHandler = $.extend(
		$.clone(LLObject),
		{
			create: function () {
				var o = LLObject.create.call(this);
				o.items = $('div.rentProgDetailItem');
				o.downloadItems = $('div.rentProgDownloadShell div.item');
				o.handleItems();
				return o;
			},
			handleItems: function () {
				this.downloadItems.each(function (i) {
					if ($(this).find('a').length > 0 ) {
						$(this)
						.mouseover(function (e) {$(this).addClass('item_hover');})
						.mouseout(function (e) {$(this).removeClass('item_hover');})
						.bind("click", function (e) {
							e.preventDefault();
							e.stopPropagation();
							$(this).removeClass('item_clicked');
							window.open($(this).find('a').eq(0).attr('href'));
						});
					}
				});
			}
		}
	);
//<<


//>> Special click handler for e.g. buttons (move background)
	specialClickHandler = $.extend(
		$.clone(LLObject),
		{
			create: function (items, img) {
				var o = LLObject.create.call(this);
				o.items = items || null;
				o.img = img || 'img';
				o.handleItems();
				return o;
			},
			handleItems: function () {
				var image, imgMarginTop, imgMarginBottom, self=this, cls;
				this.items.each(function (i) {
					$(this).bind('mousedown', function (e) {
						image = $(this).find(self.img);
						imgMarginTop = self.filterValues(image.css('margin-top'))+1;
						imgMarginBottom = self.filterValues(image.css('margin-bottom'))-1;
						image.css({'margin-top': imgMarginTop, 'margin-bottom': imgMarginBottom});
					});
					$(this).bind('mouseup', function (e) {
						image = $(this).find(self.img);
						imgMarginTop = self.filterValues(image.css('margin-top'))-1;
						imgMarginBottom = self.filterValues(image.css('margin-bottom'))+1;
						image.css({'margin-top': imgMarginTop, 'margin-bottom': imgMarginBottom});
					});
				});
			},
			filterValues: function (val) {
				val = parseInt(val);
				if (isNaN(val)){
					val = 0;
				}
				return val
			}
		}
	);
//<<


//>> Hidden shell handler
	hiddenShellHandler = $.extend(
		$.clone(LLObject),
		{
			create: function () {
				var o = LLObject.create.call(this);
				o.phraseLink = "hidden_link";
				o.phraseShell = "hidden_shell";
				o.handleHiddenItems();
				return o;
			},
			handleHiddenItems: function () {
				var hiddenLinks, linkSplitID, shellID, self=this;
				hiddenLinks = $('a[id*=' + this.phraseLink + ']');
				hiddenLinks.each(function (i) {
					$(this).bind('click', function (e) {
						e.preventDefault();
						linkSplitID = $(this).attr("id").split(self.phraseLink)[1];
						shellID = self.phraseShell + linkSplitID;
						$(this).hide();
						$('#' + shellID).show();
					});
				});
			}
		}
	);
//<<

