var QC = {
		
	config : {
	
		ticker : 'http://ir3.quartalflife.com/data/qcells2/qcells_ticker_d.php',
		txtFormErr : 'Bitte füllen Sie alle Pflichtfelder aus.',
		fileTypesNewWindow : ['PDF', 'MOV', 'MP3', 'WMV', 'WMA', 'JPG']
	},
	
	configExtendedEN : {
		ticker : 'http://ir2.flife.de/data/qcells2/qcells_ticker_e.php',
		txtFormErr : 'Please fill all mandatory fields.'
	},
		
	init : function () {
		
	
		// set locale variable with name of first folder of the url
		if (location.href.match("\/([a-zA-Z_\-\d]+)\/")) {
			QC.config.locale = RegExp.$1;	
		}
		
		switch (QC.config.locale) {
			case 'en':
			case 'english':
				$.extend(QC.config, QC.configExtendedEN);
				break;
		}	
		
		QC.download.removeDash();
		
		// init navigation
		QC.nav.init();
		
		// style drop downs
		QC.form.init();
		
		// init search
		QC.search.init();
		
		// init FAQ
		QC.faq.init();

		// init Table Layout
		QC.table.init();		
		
		// complete li element should be clickable
		QC.clickComplete($('.kb_nescefe .lastUnit .list li'));
		
		// complete modules on overview pages should be clickable
		$('.csc-frame-grid11in21 .csc-textpic-background').each(function () {
			QC.clickComplete($(this), $(this).parent().next());	
		});
		
		// google maps extension locator
		QC.maps.init();
		
		// accordion
		QC.accordion.init();		

		// downloads
		QC.download.init();
		
		// login
		QC.login.init();
		
		// news
		QC.news.paging.init();
		QC.news.ajaxLoading.init();
		QC.news.newsCatMenu.init();
		
		// footer
		QC.footer.init();
		
		// stage fix for ie7
		QC.stage.init();
		
		// history slider
		QC.slider.init();
		
		// tooltips
		QC.tooltip.init();
		
		// gallery
		QC.gallery.init();
		
		// video player
		QC.html5videoplayer.init();
		
		// colorbox
		QC.colorbox.init();
		
		// external links in new window
		$('a.external-link').attr('target', '_blank');
		
		// internal links in tabs
		$('.internal-link-in-tab').click(function() {
			window.location = $(this).attr("href");
			location.reload();
		});
		
		
		QC.download.removeDash();
		
		// tabs
		QC.tabs.init();
		
	},
	
	gallery : {
		
		optionsSmall : {	
			transition_interval:0,
			transition_speed:1000,
			easing:0,
			pause_on_hover:false,
			show_panels:true,
			panel_width:300,
			panel_height:350,
			panel_animation:'crossfade',
			overlay_opacity:0.7,
			overlay_position:'bottom',
			panel_scale:'crop',
			show_panel_nav:false,
			show_overlays:false,
			show_filmstrip:true,
			frame_width:65,
			frame_height:65,
			start_frame:1,
			filmstrip_size:2,
			frame_opacity:0.5,
			filmstrip_style: 'scroll',
			filmstrip_position:'bottom',
			show_filmstrip_nav:true,
			frame_gap:12,
			frame_scale:'crop',
			show_captions:false,
			pointer_size:0,
			animate_pointer:true
		},
							
		optionsLarge43 : {	
			animate_pointer:true,
			easing:0,
			filmstrip_position:"bottom",
			filmstrip_size:5,
			filmstrip_style:"scroll",
			frame_gap:14,
			frame_height:65,
			frame_opacity:0.5,
			frame_scale:"crop",
			frame_width:65,
			overlay_opacity:0.7,
			overlay_position:"bottom",
			panel_animation:"crossfade",
			panel_height:405,
			panel_scale:"crop",
			panel_width:540,
			pause_on_hover:false,
			pointer_size:0,
			show_captions:false,
			show_filmstrip:true,
			show_filmstrip_nav:true,
			show_overlays:false,
			show_panel_nav:false,
			show_panels:true,
			start_frame:1,
			transition_interval:0,
			transition_speed:1000
		},

		optionsLarge21 : {	
			animate_pointer:true,
			easing:0,
			filmstrip_position:"bottom",
			filmstrip_size:5,
			filmstrip_style:"scroll",
			frame_gap:14,
			frame_height:65,
			frame_opacity:0.5,
			frame_scale:"crop",
			frame_width:65,
			overlay_opacity:0.7,
			overlay_position:"bottom",
			panel_animation:"crossfade",
			panel_height:270,
			panel_scale:"crop",
			panel_width:540,
			pause_on_hover:false,
			pointer_size:0,
			show_captions:false,
			show_filmstrip:true,
			show_filmstrip_nav:true,
			show_overlays:false,
			show_panel_nav:false,
			show_panels:true,
			start_frame:1,
			transition_interval:0,
			transition_speed:1000
		},							
		
		
		init : function() {
			// Get visible gallery-Listes on pageLoad
			var objGalleries = $('ul[id*="yag-galleryView-"]:visible');
			if(objGalleries.length > 0) {
				QC.gallery.show(objGalleries);
			}
			
			// re-init colorbox
			QC.colorbox.init();
		},
		
		show : function (objGalleries) {
			
			if(objGalleries.length > 0) {
				for(var i = 0; i < objGalleries.length; i++) {
					if( objGalleries.eq(i).closest(".unit").hasClass("size2of3") ) { 
						if( objGalleries.eq(i).parent().hasClass("csc-frame-yag21") ) {
							objGalleries.eq(i).galleryView(QC.gallery.optionsLarge21);
						} else {
							objGalleries.eq(i).galleryView(QC.gallery.optionsLarge43);	
						}
					} else {
						objGalleries.eq(i).galleryView(QC.gallery.optionsSmall);	
					}
				}
			}
		}		
	},	
	
	nav : {
		init : function () {
			// add background of .header only on mouseover
			$(".navigationFirstLevelMenu ul.level1 li").hover(
			  function () {
				  $('.header').css('background','url("/fileadmin/default/templates/images/menu_divider_top.jpg") no-repeat scroll center bottom #FFFFFF');
			  }, 
			  function () {
				  $('.header').css('background','#ffffff');
			  }
			);
		
			$('li.level2').click(function(){
				$(this).parent().find('.active').removeClass("active");
				$(this).find('div.dialogContent').addClass("active");
			});
				
			$('.dialog .dialogLevel1 .csc-frame-button, .dialog .dialogLevel2 .csc-frame-button').each(function () {
				
				$(this).parent().data('title', $(this).parent().attr('title'));
				$(this).parent().attr('title', '');
				
				$(this).click(function () {
					if ($(this).parent().hasClass('dialogLevel1')) {
						$(this).parent().parent().addClass('act');
					}
					$(this).parent().parents('ul.level2').addClass('active');
					$(this).parent().parent().find('li').removeClass('active').find('>.csc-frame-button').removeClass('active');
					$(this).parent().addClass('active').find('>.csc-frame-button').addClass('active');
					$(this).parent().parents('.dialog').css({'background': 'url("'+$(this).parent().data('title')+'") no-repeat 0 0'});
					return false;
				});
			});
			
			// enable a second line in buttons
			$('.navigationFirstLevelMenu li.dialogLevel1 .csc-frame-button a').each(function () {
				if ($(this).text().length > 26) {
				    $(this).css({
				        'height': '33px',
				        'padding': '4px 0 0 0'
				    });
				}
			});
			
		}
	
	},
	
	login : {
		
		init: function () {
		
		}
		
	},
	
	
	accordion : {
		
		init : function () {
			$('h3.ui-helper-reset').removeClass('ui-helper-reset');
		}
		
	},
	
	html5videoplayer : {
		init : function () {
			if ($('.video-js-box').length > 0) {
			
				var videoHeight = $('video').attr('height');			
			
				if (videoHeight > 280) {
				
					$('.html5videoplayer').height(280);
				
							
					var v = document.createElement('video');
					if (v.canPlayType) {
						/* && v.canPlayType('video/mp4').replace(/no/, '')) {*/
						
						$('.video-js-box').height(280);
						
						
						VideoJS.player.newBehavior("fullscreenToggle", function(element){
						    _V_.addListener(element, "click", this.onFullscreenToggleClick.context(this));
						  },{
						    // When the user clicks on the fullscreen button, update fullscreen setting
						    onFullscreenToggleClick: function(event){
						      if (!this.videoIsFullScreen) {
						        this.enterFullScreen();
						        $('.header').css('z-index','0');
								$('.video-js-box').css("height", "auto" );
						      } else {
						        this.exitFullScreen();
						        $('.header').css('z-index','80');
						        $('.video-js-box').height(videoHeight);
						      }
						    },
	
						    fullscreenOnWindowResize: function(event){ // Removeable
						      this.positionControlBars();
						    },
						    // Create listener for esc key while in full screen mode
						    fullscreenOnEscKey: function(event){ // Removeable
						      if (event.keyCode == 27) {
						        this.exitFullScreen();
						        $('.header').css('z-index','80');
						        $('.video-js-box').height(videoHeight);
						      }
						    }
						  }
						);
					
						
						VideoJS.player.newBehavior("playButton", function(element){
							_V_.addListener(element, "click", this.onPlayButtonClick.context(this));
							},{
								onPlayButtonClick: function(event){
							  		$('.vjs-big-play-button').css('display','none');
								
									$('.html5videoplayer').animate({height:$("video").attr("height")},400);
							  		$('.video-js').animate({marginTop:'0px'},400);
							  		
							  		var videoObj = this;
							  		
							  		$('.video-js-box').height( videoHeight ).delay(1200).queue(function() {
							  			videoObj.play();
							  		});
							  
						  		}
						  	}
						); // end new behavior
					} else {
						var fileref=document.createElement('script')
						  fileref.setAttribute("type","text/javascript")
						  fileref.setAttribute("src", "/fileadmin/default/templates/js/swfobject/swfobject.js");
						document.getElementsByTagName("head")[0].appendChild(fileref);					
						$('.html5videoplayer').append('<div id="clickArea"><div class="vjs-big-play-button" style="display: block; "><span></span></div></div>')
						$('#clickArea').css("top", -$('video').attr('height') );
						$('#clickArea').height(280);
				   		$('#clickArea').css("background-image", "url(/"+$('video').attr('poster')+")");
						$("#clickArea").click(function(e) {
							$('.html5videoplayer').animate({height:videoHeight},400);
							$('#clickArea').animate({height:videoHeight},400);
						//	$('video.video-js').animate({marginTop:'0px'},400);  
							$('#clickArea').delay(400).animate({opacity: 0},400);  
					   		if ($('.video-js-box').length > 0) {
					   			$('.video-js-box object').remove();
							    var params = {
							    };							 
							    params.allowfullscreen = true;
							    params.wmode = 'opaque';
							    var flashvars = {
							    		config: "{'clip': { 'url': 'http://"+window.location.hostname+"/"+$('source').first().attr('src')+"', 'scaling': 'orig' } }"
							    };
					    		//$('body').delay(2000);
							    swfobject.embedSWF('http://releases.flowplayer.org/swf/flowplayer-3.2.7.swf', $('video').attr('id'), '900', $('video').attr('height'), '9.0.0', '/fileadmin/default/templates/js/swfobject/expressInstall.swf', flashvars, params); 
					   		}
					   	 	
					   	 	
						    $('#clickArea').delay(400).remove();
						  
					   	});
					} // else end v.canPlayType
					
				}
			}
		}
	},
	
	tabs : {
		
		init : function () {
		
			/*
			
			$maxheight = 0;	
		
			$('.csc-frame-tabs-small .ui-tabs-nav li').siblings().each(function () {
				var oThis = $(this);
				if ($maxheight < $(oThis).height() ) {
					$maxheight = $(oThis).height();
				}
			});	
			$('.csc-frame-tabs-small .ui-tabs-nav li a').css('height', $maxheight-10);
			
			*/
				
			// open tab, if url has hash 
			var hash = location.href.match(/#(c){0,1}(\d+)/);
			var tabNo = RegExp.$2;
			if (hash) {
				var hash2 = $('#c'+tabNo).parent().attr('id').match(/jfmulticontent_(.+)/);
				if (hash2) {
					var tabId = RegExp.$1;
					var aTabId = tabId.split("-");
					QC.tabs.openTab(aTabId[0], aTabId[1]-1);	
				}
			}
			
			// .csc-frame-tabs-small .ui-tabs-nav
			$('.csc-frame-tabs-small li.ui-state-active').append('<span class="hideBorder">'+$('.csc-frame-tabs-small li.ui-state-active h3 a').html()+'</span>');
			
			// bugfix for slider in unopend tabs
			// replace span with a
			
			$('.ui-tabs-nav li a').click(function (event) {
				$('.csc-frame-tabs-small li.ui-state-active').append('<span class="hideBorder">'+$('.csc-frame-tabs-small li.ui-state-active h3 a').html()+'</span>');

					$('span.internal-link').each(function () {
						var oThis = $(this);
						oThis.before('<a href="'+oThis.attr('href')+'" class="'+oThis.className+'">'+oThis.text()+'</a>');
						oThis.remove();
					});	
				
					
					
					var thisDiv = $(this).attr('href').substr(1);
					var childObj = $('div#'+thisDiv).children();
					href = window.location.href.split("#")
					
					if (window.location.href.match(childObj.attr('id').substring(1))) {
					//	alert(childObj.attr('id').substring(1));
						
						var hash = location.href.match(/#(c){0,1}(\d+)/);
						var tabNo = RegExp.$2;
						
						if (hash) {
							var hash2 = $('#c'+tabNo).parent().attr('id').match(/jfmulticontent_(.+)/);
							if (hash2) {
								var tabId = RegExp.$1;
								var aTabId = tabId.split("-");
								QC.tabs.openTab(aTabId[0], aTabId[1]-1);	
							}
						}
					}
					
					window.location = href[0] += '#'+childObj.attr('id').substring(1);
					// Is there an uninitialized gallery in this div?
					
					if ($('.gv-loader').length > 0 ) {
						$('.gv-loader').remove();						
					}
					
					QC.gallery.init();
					QC.table.init();
			});
			
		},
		
		openTab : function (id, item) {
			$('html, body').scrollTop(0);
			
			jQuery('#jfmulticontent_'+id).tabs({
				selected: item
			});
			if (location.host == "dev-app01-qcells.unbelievable-machine.net") {
				//alert("OPEN VIA URL");	
			}
			QC.gallery.init();
			QC.table.init();
		}
	},
	
	download : {
		
		init : function () {
		
			QC.download.removeDash();
			
			// opend some filetypes in a new window
			for (var i=0; i<QC.config.fileTypesNewWindow.length; i++) {
				$('.type'+QC.config.fileTypesNewWindow[i]+' a').attr('target', '_blank');
			}
								
			// replace table headlines
			if (typeof aTxtDownload !== 'undefined' && typeof aTxtDownload['id'] !== 'undefined' && typeof aTxtDownload['head'] !== 'undefined' && aTxtDownload['head'].length > 0) {
				for (var tab=0; tab<aTxtDownload['head'].length; tab++) {
					QC.download.setHeadlines(tab);	
				}
			}
		
		},
		
		setHeadlines : function (tab) {
			
			if (typeof tab == 'undefined' || typeof aTxtDownload['head'][tab] == 'undefined') {
				return false;
			}
			
			$('#jfmulticontent_'+aTxtDownload['id']+'-'+ (tab+1) + ' .downloads').each(function () {
			  var  d=0;
			  var oThis = $(this);
			  oThis.find('th div').each(function () {
				  $(this).text(aTxtDownload['head'][tab][d]);
				  d++;
			  });
			});			
			
		},
		
		removeDash : function () {
			$('.downloads .image').each(function () {
				if ($(this).text() == '-') {
					$(this).hide();
				}
			});
		}
		
	},
	
	news : {
		
		paging : {
			
			init : function () {
			
				// add browse class to paging list
				$('.paging').each(function () {
					
					$(this).find('li:eq(0)').addClass('browse first');
					$(this).find('li:eq(1)').addClass('browse prev');
					var n = $(this).find('li').length-2;
					$(this).find('li:eq('+n+')').addClass('browse next');
					$(this).find('li:last').addClass('browse last');
					
				});
				
				$('.paging .browse a, .paging .browse.disable').wrapInner('<span></span>');
				
				// add hash to paging links, if paging is within tabs
				$('.ui-tabs .ui-tabs-panel').each(function () {
				  var tabId = $(this).find('>div').attr('id');
				  $(this).find('.paging a').each(function () {
				    $(this).attr('href', $(this).attr('href')+'#'+tabId);
				  });
				});
				
				$('.news-list-browse a').click(function(e) {
					e.preventDefault()
				    $('.news-list-container').load(this.href+'?type=198 .news-list-container', function(response, status, xhr) {
				    	if (status == "success") {
				    		QC.news.paging.init();
				    		$('html, body').animate({scrollTop:0}, 500);  		
			        	}
			        });
					return false;
				});
			}
		},
		
		newsCatMenu : {
			
			init : function () {	
			if ( location.href.match("q_cells_news") || location.href.match("qcells_news") || location.href.match("unternehmensmeldungen") || location.href.match("corporate_news") ) {
				var html = '<form><select>';
				
				html += '<option value="/' + $('.news-catmenu>a').attr('href') + '">' + $('.news-catmenu>a').text() + '</option>';
				
				$('.news-catmenu .level1 div').each(function(){
					if ( $('a',this).text().match(/\bshow\b/) ) {

					} else {
						html += '<option value="/' + $('a',this).attr('href') + '"';
					}
					if($(this).hasClass('news-catmenu-ACT')){
						html += ' selected="selected"';
						$('input:reset').css('display', 'block');
					}
					if ( $('a',this).text().match(/\bPressemitteilung\b/) ) {
						html += '>Pressemitteilung</option>';
					} else if ( $('a',this).text().match(/\bAd-hoc\b/) ) {
						html += '>Ad-hoc-Meldung</option>';
					} else if ( $('a',this).text().match(/\bPress release\b/) ) {
						html += '>Press release</option>';
					} else if ( $('a',this).text().match(/\bAd hoc\b/) ) {
						html += '>Ad hoc release</option>';
					} else if ( $('a',this).text().match(/\bshow\b/) ) {
					//	html += '>Ad hoc release</option>';
					} else {
						html += '>' + $('a',this).text() + '</option>';
					}
				});
					
				html += '</select></form>';
				$('.news-catmenu').html('');
				$('.news-catmenu').prepend(html);
				$('.news-catmenu select').selectmenu({style: 'dropdown', width: 135});
				
				$('.news-catmenu select').change(function(){
					document.location = $(this).val();
				});
			}
			}
		},
		
					
		ajaxLoading : {
			
			init : function () {		
			
				if ( location.href.match("qcells_news") || location.href.match("unternehmensmeldungen") || location.href.match("corporate_news") ) {
					
					var getYear = location.href.match(/tx_ttnews\[year\]\=(\d+){0,4}/);
					var getYear = RegExp.$1;
					var getMonth = location.href.match(/tx_ttnews\[month\]\=(\d+){0,2}/);
					var getMonth = RegExp.$1;
			 		var getCat = location.href.match(/tx_ttnews\[cat\]\=(\d+){0,1}/gi);
	
			 		// PIDs of Year and List View
			 		var newsListYearPid = 1162;
			 		var newsListMonthPid = 1163;
			
					$('#newsList').load('index.php?id='+newsListMonthPid+'&type=198 .news-list-container');
					$('input:reset').css('display', 'none');
					$('#amenuDropdown .ui-selectmenu-dropdown').each(function () {
						if ($(this).attr('id') == 'Y'+getYear+'-button') {
							$(this).css('display', 'inline');
						}  
					});
					$('.selectMonth').focus(function() {
						$('#Y'+getYear+' option:selected').each(function () {
							$(this).selected(false);
							});
						});
					$('.selectMonth').change(function() {
						jumpToURL = $(this).val();
					    $('.news-list-container').load('index.php?'+jumpToURL+'&id='+newsListMonthPid+'&type=198 .news-list-container', function(response, status, xhr) {
					    	if (status == "success") {
					    		QC.news.paging.init();
					       	}
					   	});
					});
					$('#selectYear').change(function() {
						$('input:reset').css('display', 'block');
					    var $selctedYear = 0;
					    $("#selectYear option:selected").each(function () {
					      selectedYear = $(this).text();
					    });
					    $('#amenuDropdown .ui-selectmenu-dropdown').each(function () {
					    $("#selectYear option:selected").each(function () {
					    	var getCat = location.href.match(/tx_ttnews\%5Bcat\%5D\=(\d+){0,1}/gi);
					        jumpToURL = $(this).val();
					        if (getCat != null) {
					        	jumpToURL = jumpToURL+'&'+getCat;
					        }
					      });
					      if ($(this).attr('id') == 'Y'+selectedYear+'-button' || $(this).attr('id') == 'selectYear-button') {
					        $(this).css('display', 'block');
					        $('input').css('display', 'block');
					        $('input:submit').css('float', 'left');
					      } else {
					    	  $(this).css('display', 'none');
					      }
					   });
					    $('.news-list-container').load('index.php?'+jumpToURL+'&id='+newsListYearPid+'&type=198 .news-list-container', function(response, status, xhr) {
					    if (status == "success") {
				        		QC.news.paging.init();
				        	}
				        });
					});
				}
			}
		}
	},
	
	form : {
		
		categories : [],
		
		init : function () {
		
			if ($("#amenuDropdown select").length > 0) {
				$("#amenuDropdown select.selectMonth").selectmenu({style: 'dropdown', width: 175});
				$("#selectYear").selectmenu({style: 'dropdown', width: 80});
			} else if ($("select").length > 0) {
				$("select").selectmenu({style: 'dropdown', width: 353, maxHeight: 200});
			}
			
			
			$('#locator-submit').click(function () {
				QC.form.checkForm('tx_locator_pi1_city');
			});
			
			$('#locator .category input').click(function () {
				QC.form.categorySelect($(this).attr('id'));
			});
			
		},
		
		checkField : function (id) {
			if ($('#'+id).val() == '') {
				return false;
			}
		},
		
		checkForm : function (fields) {
			var aFields = fields.split(",");
			var e = 0;
			for (var i=0; i<aFields.length; i++) {
				if (QC.form.checkField($.trim(aFields[i])) === false ) {
					e++;
				}
			}
			if (e>0) {
				alert(QC.config.txtFormErr);
			} else {
				$('#'+ $.trim(aFields[0])).parents('form').submit();
			}
		},
		
		categorySelect : function (uid) {
			uid.match(/cat_(\d+)/);
			var iUid = RegExp.$1;
			if ($('#' + uid).hasClass('selectedCategory')) {
				$('#' + uid).removeClass("selectedCategory");
				for (var i=0; i<QC.form.categories.length; i++) {
				    if (QC.form.categories[i] == iUid) {
				    	QC.form.categories.splice(i,1);
				    }
				}
			} else {
				$('#' + uid).addClass("selectedCategory");
				QC.form.categories.push(iUid);
			}
			$('#tx_locator_pi1_categories').val(QC.form.categories);
		} 
		
	},
	
	maps : {
		
		init : function () {
		
			$('.tx-locator-pi1 .poiTable .entry').each(function () {
				$(this).click(function () {
					$(this).attr('class').match(/res(\d+)/);
					var iResult = RegExp.$1;
					openInfoWindow(iResult);
					return false;
				});
			});
			
			// header fix
			if ( location.href.match("\/bezugsquellen\/") || location.href.match("\/our_trade_partners\/") ) {
				if ($.browser.msie && parseInt($.browser.version, 10) < 8) {
					$('.mainContent').prepend($('#locator'));
					$('#locator').addClass('tx-locator-pi1').css({'position': 'absolute', 'top': '20px', 'width': '930px', 'left': '0'});	
				} else {
					$('.csc-frame-contentHeader ').css({'position': 'inherit'});		
				}
			}
		
		}
		
	},
	
	
	search : {
		
		init : function () {
		
			// move search box in from of results
			if ($('.tx-indexedsearch-res').length > 0) {
				$('.tx-indexedsearch-res:eq(0)').before($('.tx-indexedsearch-searchbox'));	
			}
			
			// style paging
			QC.search.paging.init();
			
		},
		
		paging : {
			
			init : function () {
			
				$('.browsebox:eq(0)').remove();
				$('.browsebox').show();
			
				// add browse class to browsebox list
				if ($('.browsebox li:eq(0)').text().substr(0,1) == '<') {
					$('.browsebox li:eq(0)').addClass('browse prev').find('a').wrapInner('<span></span>');
				}
				$('.browsebox li:last').addClass('browse next').find('a').wrapInner('<span></span>');
				
			}
			
		}
		
	},
	
	clickComplete : function (o, target) {
		
		if (typeof target == 'object') {
			
			var l = target.find('a:eq(0)').attr('href');
			if (typeof l !== 'undefined') {
				o.css({'cursor': 'pointer'});
				o.click(function () {
					var link = target.find('a:eq(0)').attr('href');
					if (link.substr(0, 1) !== '/' && link.substr(0, 4) !== 'http') {
						link = '/' + link;
					}
					location.href = link;
				});	
			}
			
		} else {
			if (o.length > 0) {
				o.each(function () {
					$(this).click(function () {
						var link = $(this).find('a:eq(0)').attr('href');
						if (link.substr(0, 1) !== '/' && link.substr(0, 4) !== 'http') {
							link = '/' + link;
						}
						location.href = link;
					});	
				});	
			}	
		}
		
	},
	
	faq : {
		
		init : function () {
			
			if ($('.tx-irfaq-pi1 dt').length > 0) {
				$('.tx-irfaq-pi1 dt')
				.addClass("close")
				.click(function () {
					
					if ($(this).hasClass('close')) {
						$(this).removeClass('close').addClass('open');	
					} else {
						$(this).removeClass('open').addClass('close');
					}
					
				});	
			}
		
		}
		
	},
	
	table : {
		
		init : function () {
			$('.downloads tr').each(function () {
				$(this).find('.bl').css('height',  $(this).height() - 30 + 'px');
			})
			
		}
		
	},
	
	footer : {
		
		init : function () {
		
			// inject iframe, to keep valid code
			if ($('.servicePanel span').length > 0 ) {
				
				if (location.href.match('investor_relations')) {
					$('.servicePanel span').after('<iframe src="'+QC.config.ticker+'" width="460" height="16" name="ticker" allowtransparency="true" scrolling="no" frameborder="no"></iframe>');	
				} else {
					$('.servicePanel span').remove();	
				}
				
			}
			
			// disable gradienbar on homepage
			if (location.href.match('home.html$|app01-qcells.unbelievable-machine.net/$|q-cells.com/$')) {
				$('.footer .footerFrame').css({'background': 'none'});
				$('.footerContent .csc-default').css({'margin': '20px 0 0 0'});
			}
			
		}
		
	},
	
	colorbox : {
		
		init : function () {
			
			// trigger lightbox on "lightbox"-class
			if ($('.lightbox').length > 0) {
				$('.lightbox').colorbox();	
			}			
		
			// gallery images with prevent from reinit
			var lb=0;
			if (typeof $('.gv-gallery:eq(0)').data('lightBoxAmount') === 'number') {
				lb = $('.gv-gallery:eq(0)').data('lightBoxAmount');
			}
			$('.gv-gallery').each(function () {
				
				if ($(this).hasClass('lightboxInit') === false) {
					
					$(this).find('.gv-panel img').each(function () {
						var imgUrl = $(this).attr("src");
						$(this).wrap('<a href="'+imgUrl+'" rel="lightbox'+lb+'"></a>');
					});
					
					switch (QC.config.locale) {
						case 'en':
						case 'english':
							var tCurrent = "image {current} of {total}";					
							break;
						default:
							var tCurrent = "Bild {current} von {total}";
					}
					
					$("a[rel='lightbox"+lb+"']").colorbox({
						current: tCurrent 
					});
					
					$(this).addClass('lightboxInit');
					lb++;
					
				}

			});
			$('.gv-gallery:eq(0)').data('lightBoxAmount', lb);
		
			// order layer
			if ($('a.openOrderLayer').length > 0) {
	
				switch (QC.config.locale) {
					case 'en':
					case 'english':
						var urlLayer = '/index.php?id=621&type=198&L=1';
						break;
					default:
						var urlLayer = '/index.php?id=621&type=198';
				}
				
			 	$('a.openOrderLayer').colorbox({
				    href: urlLayer,
				    close: "",
				    inline: false,
				    width: "600px",
				    height: "550px",
				    opacity: '0.85',
				    fixed: 'true',
				    onOpen: function () {
				      $('#orderList').show();
				    },
				    onComplete: function () {
				      $('#cboxContent').css({'height': '388px'});
				      $('#cboxClose').css({'top': '-480px'});
				    },
				    onClosed: function () {
				      $('#orderList').hide();
				    }
				  });
			
			}
		
		}
		
	},
	
	stage : {
		
		init : function () {
			/*
			if ($.browser.msie) {
				$('.tx-t3sjslidernews-pi1 .lof-item a').click(function () {
					location.href = $(this).attr("href");
				});
			}
			*/
	
			if ($('.lof-title a').length > 0) {
				$('.lof-main-wapper').find('.lof-title a').each(function () {
					$(this).html($(this).html().replace('|','<br>'));
				});
	
				$(".lof-title a").removeAttr("title");			}			

				if ($('span.openMessestand a').length > 0) {
					
					$('span.openMessestand').click(function(e) {
						if(e.preventDefault){ e.preventDefault()}
					    else{e.stop()};
					    e.returnValue = false;
					    e.stopPropagation();    
						if (location.href.match('/en/')) {
							jQuery.fn.colorbox({
								href:"/fileadmin/redaktion/videos/virtueller_messestand_en/",
								close: "",
								inline: false,
								width: "960px",
								height: "770px",
								opacity: '0.65',
								overlayClose: true,
								fixed: 'true',
								iframe:'true'
							});
						} else {
							jQuery.fn.colorbox({
								href:"/fileadmin/redaktion/videos/virtueller_messestand_de/",
								close: "",
								inline: false,
								width: "960px",
								height: "770px",
								opacity: '0.65',
								overlayClose: true,
								fixed: 'true',
								iframe:'true'
							});
						}
						return false;
					});
					
					/*
					$('span.openMessestand').colorbox({
						href:"/fileadmin/redaktion/videos/virtueller_messestand_de/",
						close: "",
						inline: false,
						width: "960px",
						height: "770px",
						opacity: '0.65',
						overlayClose: true,
						fixed: 'true',
						iframe:'true'
					});
					*/
				}	
			
			
		}
		
	},
	
	slider : {
		
		aMap : [], // map array
		liMarker : "",
		curStart : 0,
		
		options : {
			url : "/index.php?type=198&id=", // unternehmen - geschichten und fakten - historie (only content)
			maxItems : 5 // max number of schown items
		},
		
		init : function () {
		
			if ($("#slider").length > 0) {
				
				// get PID for content
				QC.slider.options.url = QC.slider.options.url + $('#slider').text();
				$('#slider').text("");
				
				// get all content
				// and add it to the data object
				var aData = [];
				var aHead = [];
				var i=0;
				$.ajax({
					url: QC.slider.options.url,
					type: 'get',
					dataType : 'html',
					success: function(html) {
						$(html).find('.list li').each(function () {
							var head = $.trim($(this).find('.csc-header').text());
							aHead[i] = head;
							aData[i] = {"head": head, "content": $.trim($(this).find('.csc-textpic').html())};
							i++;
					    });
						$('#slider').data('data', aData);
						
					  },
					  complete : function () {
						
						QC.slider.mapSliderValues(); 
						
						// init slider
						$("#slider").slider({
							min: 0,
							max: 6,
							value: 5,
							step: 1,
							animate: true,
							change: function(event, ui) {
								// disable last item
								if ($("#slider").slider("value") > 5) {
									$("#slider").slider("value", 5);
								}
								// disable first item
								if ($("#slider").slider("value") < 1) {
									$("#slider").slider("value", 1);
								}
								QC.slider.setActiveContent();
							},
							create: function(event, ui) {
								// build slidergrid (item marker, buttons)
								$('#slider').append('<div class="slidergrid"><ul class="marker">'+QC.slider.liMarker+'</ul></div>');
								if ($('#slider').data('data').length > 5 ) {
									$('.slidergrid').append('<div class="btnLeft"></div><div class="btnRight"></div>');
								}								
								$('#slider .markerItem'+$("#slider").slider("value")).addClass('active');
								$('#slider .marker li').css({'width': 900/$('#slider').slider("option", "max") + "px"}); 
								
								// write active item to dom
								$('#slider').before('<div class="sliderContent">'+$('#slider').data('data')[0]['content']+'</div>');
								
								// show/hide left/right buttons
								QC.slider.btnToggle();
								
								// add events to buttons
								$('.btnLeft').click(function () {
									QC.slider.curStart += 5;
									if (QC.slider.curStart >= $('#slider').data('data').length-5) {
										QC.slider.curStart =  $('#slider').data('data').length-5;
									}
									QC.slider.resetSlider();
								});
								$('.btnRight').click(function () {
									QC.slider.curStart -= 5;
									if (QC.slider.curStart <= 0) {
										QC.slider.curStart =  0;
									}
									QC.slider.resetSlider(1);
								});
							}
						});							  
						  
					  }
					});
			}
		},
		
		
		// map slider values with data-array
		mapSliderValues : function () {
			
			QC.slider.liMarker = "";
			
			for (var s=0; s < QC.slider.options.maxItems; s++) {
				
				if (typeof $('#slider').data('data')[s+QC.slider.curStart] == 'object') {
					QC.slider.aMap[QC.slider.options.maxItems-s] = $('#slider').data('data')[s+QC.slider.curStart]['content'];
					
					// add headline to marker
					QC.slider.liMarker += '<li class="markerItem'+(QC.slider.options.maxItems-s)+'"><span>'+$('#slider').data('data')[s+QC.slider.curStart]['head']+'</span></li>';
				}
			}	
		},
		
		setActiveContent : function () {
			$('.sliderContent').html(QC.slider.aMap[$("#slider").slider("value")]);
			$('#slider .marker li').removeClass('active');
			$('#slider .markerItem'+$("#slider").slider("value")).addClass('active');
		},
		
		btnToggle : function () {
			if (QC.slider.curStart == 0 || $('#slider').data('data').length < 5) {
				$('.btnRight').hide();
			} else {
				$('.btnRight').show();
			}
			if (QC.slider.curStart == $('#slider').data('data').length-5 || $('#slider').data('data').length < 5) {
				$('.btnLeft').hide();
			} else {
				$('.btnLeft').show();
			}
		},
		
		resetSlider : function (val) {
			if (typeof val == 'undefined') {
				val = 5;
			}
			QC.slider.mapSliderValues();
			$('.slidergrid .marker').html(QC.slider.liMarker);
			$("#slider").slider("value", val);
			QC.slider.btnToggle();
			QC.slider.setActiveContent();
		}
		
	},
	
	tooltip : {
		
		init : function () {
		
			$('.grid12 .lastUnit .csc-textpic img').tooltip({ 
			    track: true, 
			    delay: 0, 
			    showURL: false
			});

		}

	}	

}


$(document).ready(function(){
	QC.init();	
});

