
function getFlvPlayerLibPath(){	return '/awp/foren/Europa-Forum_Bayern/videos/'; }

/**
* execute when the DOM is loaded
* @author ctietze
*/
$(document).ready(function(){
  var imgLinks = $("a[rel^='lightbox']");

  if (imgLinks.length > 0) {
	imgLinks.prettyPhoto();
	}
});




//////////////////////////////////////////////////////////////////////////
// Author: mkalmes
// Date: 1.10.2009
// Synopsis: creates a generic jquery dialog with iframe
//
function doGenericDialog( height,width,title,lang,href )
{
	var html = '';
	html += '<div id="dialogDivGeneric" style=margin: 0px; padding: 0px;">';
	if(href && typeof(href) != "undefined" )
	{
		html += '<iframe src="'+href+'" width="100%" height="100%" frameborder="0" align="center"/></iframe>';
	}
	html += '</div>';

	$("body").append(html);
	
	dialogDiv = $("#dialogDivGeneric");
	
	var heightL = parseInt(height);
	if(isNaN(heightL))
	{
		heightL = 570;
	}
	var widthL = parseInt(width);
	if(isNaN(widthL))
	{
		widthL = 600;
	}
	
	var closeTxt = "Schlie\u00DFen";
	if(lang != "de" )
	{
		closeTxt = "Close";
	}
	
	// way to pass variable text to button title
	var buttons = {};
	buttons[closeTxt] = function(){$(this).dialog('destroy').remove(); }

	// create dialog
	dialogDiv.dialog(
	{
		autoOpen: false,
		close: function(){$(this).dialog('destroy').remove();},
		height: eval(heightL),
		width: eval(widthL),
		title: title,
		modal: true,
		bgiframe:false,
		overlay: {	background: "gray",opacity: 0.5	},
		buttons: buttons
	});
	dialogDiv.dialog("open");
}

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// create method to create swf-player to play core swf files
//
function embedSwfObject(divId, flv_url, sWidth, sHeight, pAutostart) 
{
	if( swfobject )
	{
		var v_width = "520";
		var v_height= "336";
		var v_as = "false";
				
		if( isNaN(parseInt(sWidth)) == false )
		{
			v_width = sWidth + "";
		}
		if( isNaN(parseInt(sHeight)) == false )
		{
			v_height = sHeight + "";
		}
		if( pAutostart == true )
		{
			v_as = "true";
		}
		
		// if(swfobject.hasFlashPlayerVersion("8")) ???
		var att = { data: flv_url, width: v_width, height: v_height };
		var par = { menu:"false", autostart: v_as };
		var myFlashContent = swfobject.createSWF(att, par, divId);
	}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// create method to create flowplayer flv player
//
function createFlvPlayer( divId, flv_url, autostart) 
{
		var params = "";
		if( flv_url != null || typeof flv_url != "undefined" )
		{
			if( flv_url.toLowerCase().indexOf(".swf") > -1 )
			{
				// swf files to play in flv player
				// no controls autoplay true and duration infinity to prevent showing reply button
				params = 
				{
					plugins: { controls: null },					
			    clip : 
		  	  {  
		    	    autoPlay: true, 
		      	  autoBuffering: true, 
		        	url: flv_url,
 		        	loop: false,		        	
		        	duration: 10000000
		    	},
		    	play: { replayLabel: '' }
				}
			}
			else
			{
				// ordinary flv files			
				if( typeof autostart == "undefined" || autostart == null )
				{
					autostart = true;
				}
				params = 
				{
					plugins:
					{
						controls:
						{
	            url: getFlvPlayerLibPath()+'flowplayer.controls-tube-3.1.4.swf',
							autoHide: 'always',
							hideDelay:	4000,
							stop: true,
							progressColor: '#015B7A',
							bufferColor: '#6c9cbc',
							buttonOverColor: '#92B2BD',
							volumeSliderColor: '#6c9cbc',
							volumeBarHeightRatio: 0.3
						}
					},
			    clip : 
		  	  {  
		    	    autoPlay: autostart, 
		      	  autoBuffering: true, 
 		        	loop: false,
		        	url: flv_url
		    	},
		    	play: { replayLabel: '' }
				}
			}
		}
		flowplayer(divId, getFlvPlayerLibPath()+"flowplayer-3.1.4.swf",params);
}

//////////////////////////////////////////////////////////////////////////
// from mkalmes
//
function embedVideo(divId, videoUrl, autostart)
{
	createFlvPlayer(divId,videoUrl,autostart);
}

//////////////////////////////////////////////////////////////////////////
// from jarek
//
function showVideoDialog(videoUrl,title, sWidth, sHeight, pAutostart) 
{
	if( !title || typeof title == "undefined" )
	{
		title = "Video Dialog";
	}
	
	var dialogDiv = document.getElementById("#div_video");
	
	if(dialogDiv != null)
	{
		document.body.removeChild(dialogDiv);
	}

	var v_width = "520";
	var v_height= "336";
	var v_as = "false";

	if( isNaN(parseInt(sWidth)) == false )
	{
		v_width = sWidth + "";
	}
	if( isNaN(parseInt(sHeight)) == false )
	{
		v_height = sHeight + "";
	}
	if( pAutostart == true )
	{
		v_as = "true";
	}
	if (dialogDiv == null)
	{
		var style = "width="+v_width+"px; height: "+v_height+"px;";
		$("body").append('<div id="div_video"><div id="replaced" style="'+style+'"></div></div>');
	}
	
	dialogDiv = $("#div_video");
	
	// create dialog
	dialogDiv.dialog(
	{
		autoOpen: false
		,close: function(){$(this).dialog('destroy').remove();}
		,height: (parseInt(v_height)+50)
		,title: ""
		,width: (parseInt(v_width)+30)
		,title: title
		,modal: true
		,bgiframe:true
		,overlay: {	background: "gray",opacity: 0.5	}
	});
	
	if( videoUrl.toLowerCase().indexOf(".swf") > -1 )
	{
		embedSwfObject('replaced', videoUrl, v_width, v_height, true);
	}
	else
	{
		createFlvPlayer('replaced',videoUrl);		
	}
		
	$("#div_video").dialog("open");
}


