			var videoBox=(function(){
			
				var _info={};
							
				var _g=function(id){
					return document.getElementById(id);
				};
				
				//update the wemf iframe for counting
				var _wemfCount=function(info,index){
					info.vid.find("#video_teaser_google").attr("src", "http://www.lessentiel.lu/videotv/newestVideo-count.html?channel="+escape(info.activeChannel)+"&vid="+info.videos[info.activeChannel][index].id);
					info.vid.find("#video_teaser_wemf").attr("src", "http://20min.wemfbox.ch/cgi-bin/ivw/CP/de/videotv?r="+escape(document.referrer)+"&d="+(new Date()).getTime() );
				};
				
				var _openVideoportal=function(info){
					_g("player"+info.playerId).set_pause(true);
				};
				
				var _showAllVidsImg=function(info){
					$(info.videos[info.activeChannel]).each(function(i,elem){
						elem.el.style.display='';
					});
				};
				
				var _destroyVideoObj=function(info){
					info.videos[ info.activeChannel ][ info.activeVideo ]
				}
				
				var _channelSwitch=function(info,channel,wemf){
					if (typeof info.videos[channel] !== "undefined") {
						info.activeChannel = channel;
						return _videoSwitch(info, 0, wemf); //load first video of this channel
					}
					else{
						//something went totaly wrong -> FUCK
					}
				};
				var	_videoSwitch=function(info,index,wemf){
					if (typeof wemf === "undefined" || wemf===true) {
						_wemfCount(info,index);
					}
					return _loadVideo(info,index);
				};
				
				var _loadVideo=function(vidBoxInfo, index){
					var info=vidBoxInfo.videos[vidBoxInfo.activeChannel][index];
					if (info!=="undefined") {
						//show all other images but hide this one
						_showAllVidsImg(vidBoxInfo);
						info.el.style.display = 'none';
						//set title
						vidBoxInfo.vid.find("#videoNewestTitle").text(info.title);
						
						//load video
						var conf=vidBoxInfo.videoConf[info.id];
						if (typeof conf !== "undefined") {
							
							vidBoxInfo.video=null;
							vidBoxInfo.video=new SWFObject(vidBoxInfo.swfPath, "player"+vidBoxInfo.playerId, 450, 274, "0", "#000000");
							vidBoxInfo.video.addVariable("browser", navigator.appVersion);
							vidBoxInfo.video.addVariable("player_id", vidBoxInfo.playerId);
							
							//load all vars and params
							$.each(conf.vars, function(key, value){
								vidBoxInfo.video.addVariable(key, value);
							});
							$.each(conf.param, function(key, value){
								vidBoxInfo.video.addParam(key, value);
							});
							
							if (vidBoxInfo.activeVideo!==null){
								vidBoxInfo.video.addVariable("autoStart", "true");
							}
							
							//loads the video and creates content
							vidBoxInfo.video.addVariable("file1", info.id);
							vidBoxInfo.video.write("flashcontentNewestVideos"+vidBoxInfo.playerId);
							
							//change "grossformat" link
							vidBoxInfo.vid.find("#showlarge").attr("href", "/videotv/?vid=" + info.id );
							
							vidBoxInfo.activeVideo=info.id;
							
							//everything perfect, return false to prevent link from working
							return false;
						}
						else{
							return true; //trigger to pop up the video in a new window
						}
					}
					else if (vidBoxInfo.videoSwitchKeep<=5){
						//we'll try to switch content for 5seconds -> 
						vidBoxInfo.videoSwitchKeep++;
						setTimeout( function(){_videoSwitch(vidBoxInfo,index);}, 1000 );
					}
					else{ //our script is far to slow in collecting information, so lets popopen a tab with the video
						vidBoxInfo.videoSwitchKeep=0;
						return true;
					}
				};
				
				return {
					init:function(tabBoxId, videoConf){
						var vidStoreId=tabBoxId;
						if (typeof _info[vidStoreId] !== "undefined") {
							vidStoreId = tabBoxId + Math.round( Math.random() * 1000000 );
						}
						
						var vidBox=$("#"+tabBoxId+":not(.vidBoxSetup)");
						vidBox.addClass("vidBoxSetup");
						
						//store videoBoxData
						_info[vidStoreId] = {
							vid:vidBox,
							activeChannel:null,
							activeVideo:null,
							videos:{},
							videoConf:null,
							playerId:(new Date()).getTime(),
							video:null,
							swfPath:"",
							videoSwitchKeep:0
						};
						var info=_info[vidStoreId];
							
						//create video swf object
						$.each(videoConf, function(i,elem){
							info.swfPath=elem.swfobj;
							return false;
						});
						
						vidBox.find("#flashcontentNewestVideos").attr("id", "flashcontentNewestVideos"+info.playerId );					
						
						//save videoConfiguration of every present video
						info.videoConf=videoConf;
						
						//scrable through html to collect the available videos
						var tabs=vidBox.find("ul.tabbey li a");
						if (typeof tabs !== "undefined") {
							tabs.each(function(i, elem){
								//collect information about all movies of this tab/channel
								info.videos[elem.innerHTML] = [];
								vidBox.find("div.content.tab_" + i + " div.more_video a").each(function(u, vids){
									info.videos[elem.innerHTML].push({
										id: vids.id,
										title: vids.title,
										el: vids
									});
									//bind videoSwitch to load other videos of same channel																
									$(vids).bind("click", function(e){
										return _videoSwitch(info, u, true);
									});
								});
								
								//bind channelSwitch to change video view														
								$(elem).bind("click", function(e){
									return _channelSwitch(info, elem.innerHTML, true);
								});
								
								if ($(elem).parent().hasClass("active")) { //set active tab to active channel and load first vid
									_channelSwitch(info, elem.innerHTML, false);
								}
							});
						}
						
						//set "playerImGrossformat" to a js event, to stop the vid, before opening the videotv portal
						vidBox.find("#showlarge").bind("click",function(e){
							_openVideoportal(info);
							return true;
						});
					}
				};
			})();
