/**
* open dialog
*/
function bnn_open_player_popup(hash)
{
	// SET HASH VAR ON POPUP
	if (hash) $("#playerPopup").data('hash', hash);
	
	// OPEN POP-UP
	$("#playerPopup").dialog("open");

	return false;
}


/**
* ACTIVATE DIALOG
*/
$(document).ready(function(){

	$( "body" ).append('<div id="playerPopup" style="display:none;"><a href="#" id="playerPopupClose"><span style="display:none;">X</span></a></div>');
	
	// CONFIG
	$("#playerPopup").dialog({
		autoOpen: false,
		modal: true,
		closeText:'',
		show: 'fade',
		hide: 'fade',
		width: 685,
		//height: 394
		height: 500
	});
	
	
	//  CLOSE ON BUTTON
	$("#playerPopupClose").live("click", function() {
		$("#playerSwf" ).remove();
		$("#silverlightControlHost" ).remove();
		$("#playerContainer" ).remove();
		$("#playerPopup").dialog("close");
	});
	
	

	// CLOSE ON OVERLAY
	$(".ui-widget-overlay").live("click", function() {
		$("#playerSwf" ).remove();
		$("#playerContainer" ).remove();
		$("#playerPopup").dialog("close");
	});
	
	
	
	// BIND FINISH OPEN TO SWF PLACMENT
	$( "#playerPopup" ).bind( "dialogopen", function(event, ui) {
	
		// APPEND DIV TO CONTAINER
		$( "#playerPopup" ).append('<div id="playerContainer"></div>');

		if ($( "#playerPopup" ).data('hash')) { // PLACE FLASH PLAYER IN DIV
		var source = "http://www.bnn.nl/players/play/play.php?type=bnnhome"
		var container = "playerContainer";
		var width = 632;
		var height = 357;
		var flashVersion = "9";
		var altSWF = null;
		var vars = {
			swf_width:width,
			swf_height:height,
			hash:$( "#playerPopup" ).data('hash')
		}
		var params = {
			allowFullScreen:"true",
			wmode:"transparent"
		}
		var attribs = {
			id: "playerSwf"
		};
		swfobject.embedSWF(source, container, width, height, flashVersion,altSWF,vars,params,attribs);
		}

		else {


$( "#playerPopup" ).append('<div id="silverlightControlHost"><object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="632" height="357,366322"><param name="source" value="http://slplayer.nederland24.nl/xap/NPONL24.xap"/><param name="minRuntimeVersion" value="2.0.31005.0"/>		        <param name="autoUpgrade" value="true" />		        <param name="windowless" value="true"/>		        <param name="initParams" value="		                playerWidth=632,		                channelCode=101,		                viewMode=normal,		                showBackground=false,		                showPlayPause=true,		                showPreviousNextChannel=false,		                showViewModeMosaic=false,		                showList=true,		                showInfo=true,		                showRelated=true,		                muted=true,		                showVolume=true,		                showSettings=true,		                showViewModePIP=true,        		                showFullscreen=true,		                showSettingsQuality=true,		          showSettingsVideoRatio=true,       		                channelXmlUrl=../xml/channel.xml,		                programXmlUrl=http://slplayer.nederland24.nl/xml/program.xml,		                programXmlRefreshPeriod=60,		                mosaicRefreshPeriod=1,		                mosaicHeight=150,		                mosaicCols=3,		                mosaicRows=4,		                fullVersionUrl=http://portal.omroep.nl/ned4,		                brandingLogoUrl=http://www.omroep.nl		        "/>			  </object></div>');

		}
	});
});



