var nettvCookieName='nettvType';
var nettvCookieVal='unsupported';
var nettvmms = 'mms://WMS.dr.dk/storage';
var nettvhttp = '';
var nettvdomain = '';
 
function DRnettv(subsite,video,videoTitle,options) {
	options=( typeof(options)!='undefined' ) ? options : '';
	subsite  =  (typeof subsite != 'undefined') ? subsite : 'nyheder';
	video  = (typeof video != 'undefined') ? video : '';
	videoTitle  = (typeof videoTitle != 'undefined') ? videoTitle : ''; 
	var url;
	if (/^(http:|mms:)/.test(video)	)
		url=video;
	else if (/(\.wmv|\.wma)$/.test(video) )
		url=nettvmms+video;
	else	// .asx and .wvx
		url=nettvhttp+video;
	if ( redirectToMediaFile() ) {
		location.href=url;
	}
	else {
		popup=pop(nettvdomain+'/player/detect.asp?subsite='+subsite+'&video='+video+'&videoTitle='+videoTitle+options, '');
	}
}

function DRnyheder(id,name,otherURL,options) {
    options=( typeof(options)!='undefined' ) ? options : '';
	name=( typeof(name)!='undefined' ) ? name : '';
	
	
	if ( redirectToMediaFile() && /^\d+$/.test(id) ) {
		location.href=nettvdomain+'/extention/playWindowsMediaNyheder.aframe?id='+id+'&ListType=nyheder'+options;
	}
	else if( redirectToMediaFile() && otherURL )
		location.href=otherURL;		
	else {
		pop(nettvdomain+'/player/detect.asp?subsite=nyheder&id='+id+'&name='+name+options);
	}
}

function Odp(id,uniqueid,nyheder) {
    
	id         = id?id:'216870';
	uniqueid = uniqueid?uniqueid:'DR1200606082100'; //
  nyheder = nyheder?nyheder:'nyheder';
  var Udsendelse;
  if (nyheder=='nyheder') Udsendelse='TVAvisen' 
  else  Udsendelse='Deadline';
	var startup= 'http://www.dr.dk/odp/check.html?uniqueid='+id+'&mt=newstab&st=news_'+Udsendelse+'&furl=http%3A//www.dr.dk/odp/default.aspx%3Ftemplate%3Dnyhed%26guid%3D'+uniqueid+'%26autoplay%3D0%26back%3Ddefault.aspx%253ftemplate%253d'+nyheder+'%2526day%253d0'; 

	//alert (startup);
 window.open(startup, 'player', 'resizable=false,statusbar=false,width=818,height=508').focus();

}


 

function DRung(id,ListType, otherURL,options) {
    options=( typeof(options)!='undefined' ) ? options : '';
	ListType=( typeof(ListType)!='undefined' ) ? ListType : 'BoogieListen';
	if ( redirectToMediaFile() && /^\d+$/.test(id) ) {
		location.href=nettvdomain+'/extention/playWindowsMediaboogie.aframe?id='+id+'&ListType=Boogie'+options;
	}
	else if( redirectToMediaFile() && otherURL )
		location.href=otherURL;		
	else {
		pop( nettvdomain+'/player/detect.asp?subsite=Boogie&id='+id+'&ListType='+ListType+options);
	}
}


function pop(u,n)
{
 var args='scrollbars=no,toolbars=no,location=no,status=no,directories=no,resizable=yes,height=491,width=708';
 if(typeof (n)!='string') n='';
 var uWin;
 uWin = window.open(u,n,args);
	
 if (uWin != null) {
  if (uWin.opener == null) {
    uWin.opener = self;
  }
 }
 if(uWin.focus) { uWin.focus(); }
}

function getCookie(cName) {
	var str = unescape(document.cookie);	// if cookie exist, then read the cookie
	var cookies= str.split('; ');
	var pair;
	var re= new RegExp('^'+cName+'$'); // match exact cookieName
	for (var i=0;i<cookies.length;i++)
	{
		pair=cookies[i].split('=');
		if( pair[0].match(re) )
			return pair[1];
	}
	return false;
}


function redirectToMediaFile() {
	var cookie=getCookie(nettvCookieName);
	//alert('redirecting? Only if two bottom lines are similar\n'+document.cookie+'\n'+cookie+'\n'+nettvCookieVal);
	if (cookie==nettvCookieVal)
		 return true;
	else return false;
}


	/* ODP start */
function ODPplayer(template,guid,skin)
{
	template = template ? template : 'se_seneste';
	guid = guid ? guid : 'tvavisen';
	if(!skin)
		skin = "default";
		
	re = new RegExp('webudv|stageol','ig');
	var startup = '/odp/default.aspx?skin='+skin+'&template='+template+'&guid='+guid;
	if (!re.test(location.href)) startup='http://www.dr.dk'+startup;
	
	window.open(startup, 'player', getODPWindowParams(skin)).focus();
	
	return void(0);
}

function ODPplayerAdv(mt,st,fUrl,sUrl,skin)
{
	mt = mt ? mt : 'frontpagetab';
	st = st ? st : 'frontpageTab_0';

	re = new RegExp('webudv|stageol','ig');
	var startup = '/odp/check.html?st='+st+'&mt='+mt+'&fUrl='+fUrl+'&sUrl='+sUrl;
	if (!re.test(location.href)) startup='http://www.dr.dk'+startup;
	
	window.open(startup, 'player', getODPWindowParams(skin)).focus();
	
	return void(0);
}

/* ny funktion der centralt har vinduesstr. på div. skins */
function getODPWindowParams(skin)
{
	if(skin == "oline")
	{	
		var w=window.screen.width;
		var h=window.screen.height;
		return "width="+w+",height="+h+",left=0,top=0";
	}

	else if(skin == "barracuda")
		return "width=440,height=460,resizable=false,statusbar=false";
	else
		return "resizable=false,statusbar=false,width=818,height=508";
}
function ODPlive(kanal)
{	var selectKanal = kanal==null ? 'DR1' : kanal
	var Kanal_no = selectKanal=='DR1' ? '0' : '1'
	
	re = new RegExp('webudv|stageol','ig');
	var startup='/odp/player.aspx?uniqueid=&mt=livetab&st=liveTab_'+Kanal_no+'&furl=/odp/live/live_'+selectKanal+'.html%3Fintermissionbg%3Danbefalede.jpg%23c0&surl=http%3A//simulcast.dr.dk/index.php%3Furl%3Dmms%3A//drcluster.jay.net/'+selectKanal;
	if (!re.test(location.href)) startup='http://www.dr.dk'+startup;	

  window.open(startup, 'player', 'resizable=false,statusbar=false,width=818,height=508').focus();
  //return false;
}
/* ODP end */
/* 
http://www.dr.dk/odp/player.aspx?uniqueid=&mt=livetab&st=liveTab_0&furl=http%3A//www.dr.dk/odp/live/live_dr1.html%3Fintermissionbg%3Danbefalede.jpg%23c0&surl=http%3A//simulcast.dr.dk/index.php%3Furl%3Dmms%3A//drcluster.jay.net/dr1
http://webudv01/odp/check.html?
http://wmi01/odp/player.aspx?uniqueid=&mt=livetab&st=liveTab_0&furl=http%3A//wmi01/odp/live/live_dr1.html%3Fintermissionbg%3Danbefalede.jpg%23c0&surl=http%3A//simulcast.dr.dk/index.php%3Furl%3Dmms%3A//drcluster.jay.net/dr2

 javascript:ODPplayerAdv('livetab','livetab_0','/odp/live/live_dr1.html%3Fintermissionbg%3Danbefalede.jpg','http%3A//simulcast.dr.dk/index.php%3Furl%3Dmms%3A//drcluster.jay.net/dr1')
&mt=livetab
&st=liveTab_0
&furl=http%3A//webudv01/odp/live/live_dr1.html%3Fintermissionbg%3Danbefalede.jpg%23c0
&surl=http%3A//simulcast.dr.dk/index.php%3Furl%3Dmms%3A//drcluster.jay.net/dr1 
&mt=livetab
&st=liveTab_1
&furl=http%3A//webudv01/odp/live/live_dr2.html%3Fintermissionbg%3Danbefalede.jpg%23c0
&surl=http%3A//simulcast.dr.dk/index.php%3Furl%3Dmms%3A//drcluster.jay.net/dr2

*/


