
function loadVideoV2(path, img, plugins, mediaId, mediaGroup, trackId, trackDomain, width, height) {

	nWidth 	= width;
	nHeight = height;
	
	if (typeof (webtrekk) != undefined){
		//webtrekk.mediaPlayerId = 'video1';
		//webtrekk.mediaId = mediaId;
	} 

	var s1 = new SWFObject('/global/utils/player.swf','player',nWidth,nHeight,'8');
	s1.addParam('allowfullscreen','true');
	s1.addParam('allowscriptaccess','always');
	s1.addParam('flashvars','image=/files/smthumbnaildata/550x'+img+'&backcolor=ffffff&frontcolor=193647&autostart=false&file=' + path + '&plugins='+plugins+'&webtrekk.media_id='+mediaId+'&webtrekk.media_group='+mediaGroup+'&webtrekk.track_id='+trackId+'&webtrekk.track_domain='+trackDomain);
	s1.write('videocontent');
	
	windowG.center();
	windowG.show();
	
	//AddParam funktioniert nicht
	document.getElementById('player').style.width  = nWidth+'px';	
	document.getElementById('player').style.height = nHeight+'px';	
}

function goToVideoV2(id) {
	loadVideoV2(aVids[id]);
	actVid = id;
	
	if(actVid == 0)
		document.getElementById("prevbutton").style.display = "none";
	else	
		document.getElementById("prevbutton").style.display = "block";
		
	if(actVid == aVids.length - 1)
		document.getElementById("nextbutton").style.display = "none";
	else	
		document.getElementById("nextbutton").style.display = "block";
}

function positionVideoArrowV2( pk, image ) {
	
	if(document.getElementById('videoarrow' + pk)) {
		
		ar = document.getElementById('videoarrow' + pk);
	
		tp = image.height / 2 - 48 / 2;
		tp2 = image.width / 2 - 47 / 2;
		
		ar.style.position = "absolute";
		ar.style.top = parseInt (tp) + "px";
		ar.style.left = parseInt (tp2) + "px";
				
	}
	
}

function getLink(path, isBeginning) {
	if(isBeginning == 1){
		if(path.length > 0){
			return '<a href="'+path+'">';
		}
	}
	else{
		if(path.length > 0){
			return '</a>';
		}
	}
	return '';
}


function doVideoPopUpV2(path, img, title, bu, credit, flashwidth, flashheight, title_hires, img_hires, sBu_hires, link_hires, plugins, mediaId, mediaGroup, trackId, trackDomain) {

	if (windowG) {
		windowG.destroy();
	}
			
	nWidth 			= flashwidth || 557;
	nWinWidth 		= nWidth + 20;		
	nGalleryWidth 	= nWidth;	
	nHeight 		= flashheight || 314;
		
	if(credit.length)
		sPipe = " | ";
	else
		sPipe = "";

	sBu = bu + sPipe + credit;
	if(sBu.length)
		sBu = '<div class="description"><div class="caption clearfix"><div class="flr">'+ sBu +'</div>		</div>		</div>';
	else
		sBu = '';
	
	// PB / nbsp GmbH / 24.09.2010 / Flash-Detection installed
	// Globals
	// Major version of Flash required
	var requiredMajorVersion = 7;
	// Minor version of Flash required
	var requiredMinorVersion = 0;
	// Minor version of Flash required
	var requiredRevision = 0;

	// Version check based upon the values defined in globals
	var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	
	// Flash kann angezeigt werden
	if (hasReqestedVersion) {
		windowG = new Ext.Window({       
			renderTo: Ext.getBody(),
			resizable:false,
			draggable:false,
			width: nWinWidth,
			cls: 'gallerypopup videopopup profilepopup ma-gallery',		
	        minWidth: 300,
	        minHeight: 200,    
	        bodyStyle:'',
	        buttonAlign:'center',
	        items:	[{html:
						'	<div class="gallerypopup" style="width:'+nWidth+'px">'+
						'		<h1 style="margin:0px 0px 5px 0px; float: left;">'+ title +'</h1><br clear="all" />'+
						'		<div class="clearfix">'+
						'			<div id="videocontent"><img src="/files/smthumbnaildata/550x'+img+'" /></div>'+
						'			<div class="fullsize" style="width:'+nWidth+'px;">'+
									sBu +
						'			</div>'+
						'		</div>'+
						'	</div>'							
					}],
			plain:false,
		    floating:true,
		    modal:true,
		    title:'<a style="cursor:pointer" class="mysitegallerydestroy" onclick="windowG.destroy()"><span class="flr" style="font-size:11px !important;padding-right:5px; padding-top:1px; color:#FFFFFF !important;">Schlie&szlig;en</span></a>',
		    shadow:false
	    });
		
		windowG.center();
		windowG.show();	
		
		loadVideoV2(path, img, plugins, mediaId, mediaGroup, trackId, trackDomain, nWidth, nHeight);
		   

	// Flash nicht installiert
	} else {
		windowG = new Ext.Window({       
			renderTo: Ext.getBody(),
			resizable:false,
			draggable:false,
			width: nWinWidth,
			cls: 'gallerypopup videopopup profilepopup ma-gallery',		
	        minWidth: 300,
	        minHeight: 200,    
	        bodyStyle:'',
	        buttonAlign:'center',
	        items:	[{html:
						'	<div class="gallerypopup" style="width:'+nWidth+'px">'+
						'		<h1 style="margin:0px 0px 5px 0px; float: left;">'+ title_hires +'</h1><br clear="all" />'+
						'		<div class="clearfix">'+
									getLink(link_hires,1)+
						'			<img src="/files/smthumbnaildata/550x/'+img_hires+'" />'+
									getLink(link_hires,0)+
						'			<div class="fullsize" style="width:'+nWidth+'px;">'+
									sBu_hires +
						'			</div>'+
						'		</div>'+
						'	</div>'							
					}],
			plain:false,
		    floating:true,
		    modal:true,
		    title:'<a style="cursor:pointer" class="mysitegallerydestroy" onclick="windowG.destroy()"><span class="flr" style="font-size:11px !important;padding-right:5px; padding-top:1px; color:#FFFFFF !important;">Schlie&szlig;en</span></a>',
		    shadow:false
	    });
		
		windowG.center();
		windowG.show();	
		
	}
	
}

function doFlashPopUp(path, title, bu, credit, img, flashwidth, flashheight, title_hires, img_hires, sBu_hires, link_hires, plugins, mediaId, mediaGroup, trackId, trackDomain) {

	if (windowG) {
		windowG.destroy();
	}
			
	nWidth 			= flashwidth || 557;
	nWinWidth 		= nWidth + 20;	
	nGalleryWidth 	= nWidth;
	nHeight 		= flashheight || 314;
	
	if(nWidth == 557){
		sImgGroup = '550x';	
	}
	else{
		sImgGroup = 'original';
	}
	
	if(credit.length)
		sPipe = " | ";
	else
		sPipe = "";
	
	// PB / nbsp GmbH / 24.09.2010 / Flash-Detection installed
	// Globals
	// Major version of Flash required
	var requiredMajorVersion = 7;
	// Minor version of Flash required
	var requiredMinorVersion = 0;
	// Minor version of Flash required
	var requiredRevision = 0;

	// Version check based upon the values defined in globals
	var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	
	// Flash kann angezeigt werden
	if (hasReqestedVersion) {
		windowG = new Ext.Window({       
			renderTo: Ext.getBody(),
			resizable:false,
			draggable:false,
			width: nWinWidth,
			cls: 'gallerypopup videopopup profilepopup',		
	        minWidth: 300,
	        minHeight: 200,    
	        bodyStyle:'',
	        buttonAlign:'center',
	        items:	[{html:
	        	'	<div class="gallerypopup" style="width:'+nGalleryWidth+'px">'+
				'		<h1 style="margin:0px 0px 5px 0px; float: left;">'+ title +'</h1><br clear="all" />'+
				'		<div class="clearfix" id="videocontent">'+
		        '			<div id="videocontent"><img src="/files/smthumbnaildata/'+ sImgGroup + img +'" onclick="centerVideoGallery();"/></div>'+
				'			<div class="fullsize" style="width:'+nWidth+'px;"><div class="description"><div class="caption clearfix"><div class="flr">'+ bu + sPipe + credit +'</div>		</div>		</div></div>'+
				'		</div>'+
				'	</div>'		
										
					}],
			plain:false,
		    floating:true,
		    modal:true,
		    title:'<a style="cursor:pointer" class="mysitegallerydestroy" onclick="windowG.destroy()"><span class="flr" style="font-size:11px !important;padding-right:5px; padding-top:1px; color:#FFFFFF !important;">Schlie&szlig;en</span></a>',
		    shadow:false
	    });
		
		windowG.center();
		windowG.show();	
		
	// Flash nicht installiert
	} else {
		windowG = new Ext.Window({       
			renderTo: Ext.getBody(),
			resizable:false,
			draggable:false,
			width: nWinWidth,
			cls: 'gallerypopup videopopup profilepopup',		
	        minWidth: 300,
	        minHeight: 200,    
	        bodyStyle:'',
	        buttonAlign:'center',
	        items:	[{html:
	        	'	<div class="gallerypopup" style="width:'+nGalleryWidth+'px">'+
				'		<h1 style="margin:0px 0px 5px 0px; float: left;">'+ title_hires +'</h1><br clear="all" />'+
				'		<div class="clearfix" id="videocontent">'+
		        '			<div id="videocontent">'+
		         				getLink(link_hires,1)+	
		        '				<img src="/files/smthumbnaildata/'+ sImgGroup + img_hires +'" onclick="centerVideoGallery();"/>'+
		         				getLink(link_hires,0)+
		        '			</div>'+
				'			<div class="fullsize" style="width:'+nWidth+'px;"></div>'+
				'		</div>'+
				'	</div>'		
										
					}],
			plain:false,
		    floating:true,
		    modal:true,
		    title:'<a style="cursor:pointer" class="mysitegallerydestroy" onclick="windowG.destroy()"><span class="flr" style="font-size:11px !important;padding-right:5px; padding-top:1px; color:#FFFFFF !important;">Schlie&szlig;en</span></a>',
		    shadow:false
	    });
		
		windowG.center();
		windowG.show();	
		
	}

	if (typeof (webtrekk) != undefined){
		//webtrekk.mediaPlayerId = 'video1';
		//webtrekk.mediaId = mediaId;
	} 
	
	var s1 = new SWFObject(path,'player',nWidth,nHeight,'8');
	s1.addParam('allowfullscreen','true');
	s1.addParam('allowscriptaccess','always');
	s1.addParam('flashvars','plugins='+plugins+'&webtrekk.media_id='+mediaId+'&webtrekk.media_group='+mediaGroup+'&webtrekk.track_id='+trackId+'&webtrekk.track_domain='+trackDomain);
	s1.write('videocontent');
		
	windowG.center();
	windowG.show();	

	//AddParam funktioniert nicht
	document.getElementById('player').style.width  = nWidth+'px';	
	document.getElementById('player').style.height = nHeight+'px';
	
}

function doImagePopUp(path, title, bu, credit, width, pk, cid, p) {

	if (windowG) {
		windowG.destroy();
	}

	//nWidth = 550;
	//nWinWidth = 590;	
	nWidth = width || 550;
	
	nWinWidth = nWidth + 20;	
	
	if(pk == undefined) pk = 0;
	if(cid == undefined) cid = 0;
	if(p == undefined) p = 0;
	
	if(credit.length)
		sPipe = " | ";
	else
		sPipe = "";
	
	windowG = new Ext.Window({       
		renderTo: Ext.getBody(),
		resizable:false,
		draggable:false,
		width: nWinWidth,
		cls: 'gallerypopup videopopup profilepopup',		
        minWidth: 300,
        minHeight: 200,    
        bodyStyle:'',
        buttonAlign:'center',
        items:	[{html:new Ext.XTemplate(
        	    '<div class="gallerypopup" style="width:' + nWidth + 'px">'+
					'<tpl if="titlelength"><h1 class="gallerypopupheadline" style="margin:0px 0px 5px 0px; float: left;">'+ title +'</h1><br clear="all" /></tpl>'+
					'<div class="clearfix">'+
	        			'<img onLoad="centerVideoGallery()" src="'+ path +'" />'+
						'<div class="fullsize" style="width:'+nWidth+'px;">'+
							'<div class="description">'+
								'<div class="caption clearfix">'+
									'<div class="fll"><!--leer--></div>'+
									'<div class="flr">'+ credit +'</div>'+
								'</div>'+
								'<div class="line_dashed_blue"><!--leer--></div>'+
								'<div class="text">'+ bu +'</div>'+							
							'</div>'+
						'</div>'+
					'</div>'+
				'</div>').apply({titlelength:title.length})
				}],
		plain:false,
	    floating:true,
	    modal:true,
	    title:'<a style="cursor:pointer" class="mysitegallerydestroy" onclick="windowG.destroy()"><span class="flr" style="font-size:11px !important;padding-right:5px; padding-top:1px; color:#FFFFFF !important;">Schlie&szlig;en</span></a>',
	    shadow:false,
		listeners: {
			beforeshow: function(pThisStore, pRecords){			
				if(pk > 0 && cid > 0 && p > 0){
					Ext.Ajax.request({
						url: '/index.cfm?event=ajax.getWebtrekkCoding',
						params: {
							pk				: pk,
							cid				: cid,
							p				: p,
							sourceofrequest : 'imagepopup',
							datatransfer	: 'ajax'
						},
						success: function(pResponse, pOptions) {
											
							var cresponse=Ext.decode(pResponse.responseText);
							
							if(cresponse.success){
								try{
									wt_sendinfo(cresponse.webtrekk);
								}catch(e){						
								}
							}else{
								/// Exception occured
							}
							
						},
						scope: this
					});
				}
			 }
			}
    });
	//windowG.setPosition(200,75);

	windowG.show();	

}

function centerVideoGallery() {
	
	windowG.center();
	
	
	var Pos = windowG.getPosition();
	var x = Pos[0];
	var y = Pos[1];
		
	if (x < 0){
		x = 0;
	}
	
	if (y < 0){
		y = 0;
	}
	
	if (x==0 || y==0){
		windowG.setPosition(x,y);
	}
	windowG.show();
}
