var qs = document.location.search.substring(1);
var hasScreenReader = ( qs.indexOf('qsAccessible=1') == -1 )?false:true;

//write cookie to remember prefered player
createCookie("snipPlayer", mediaPlayerID, 365)

var agent = navigator.userAgent.toLowerCase();


function writeFlashPlayer() {
  
  var wmode = (hasScreenReader==true)?"window":"transparent";
    /*
	var oeTags = '<OBJECT ID="flashController" CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
			+ 'WIDTH="788" HEIGHT="433"'
			+ 'CODEBASE="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0">'
			+ '<PARAM NAME="MOVIE" VALUE="master.swf?qsPlayer=' + mediaPlayerID + '&' + qs + '&agent=' + agent + '">'
			+ '<PARAM NAME="PLAY" VALUE="true">'
			+ '<PARAM NAME="LOOP" VALUE="false">'
			+ '<PARAM NAME="QUALITY" VALUE="high">'
			+ '<param name="wmode" value="' + wmode + '">'
			+ '<PARAM NAME="MENU" VALUE="false">'
			+ '<EMBED swLiveConnect="true" NAME="flashController" SRC="master.swf?qsPlayer=' + mediaPlayerID + '&' + qs + '&agent=' + agent + '" '
			+ 'WIDTH="788" HEIGHT="433"'
			+ 'PLAY="true"'
			+ 'LOOP="false"'
			+ 'QUALITY="high"'
			+ 'MENU="false"'
			+ 'WMODE="' + wmode + '"'
			+ 'TYPE="application/x-shockwave-flash"'
			+ 'PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">'
			+ '<\/EMBED>'
			+ '<\/OBJECT>';
	// embed the Flash Movie
	
	oeTags += "<a href='javascript:changeAccessible();' target='_self' alt='link naar toegangkelijke pagina'>link naar toegangkelijke pagina</a>"
	
	document.getElementById("flashPlayerDIV").innerHTML = oeTags;
	//document.getElementById("flashContentDIV").innerHTML = oeTags;
  */
 
 //document.getElementById("flashPlayerDIV").innerHTML = "master.swf?qsPlayer=" + mediaPlayerID + "&" + qs + "&agent=" + agent;
 
 
  var so = new SWFObject("master.swf?qsPlayer=" + mediaPlayerID + "&" + qs + "&agent=" + agent , "flashController", "765", "433", "7", "#000000");  
  //so.addVariable("qsPlayer", mediaPlayerID);
  //so.addVariable("qs", qs);
  //so.addVariable("agent", agent);
  so.addParam("wmode", wmode);

  so.write("flashContentDIV");	
  
  
}


function changeStream(stream, streamtype, plugin) {  
      
  if(mediaPlayerID == "wmp"){
    window.open('wmpplayer.html?stream=' + stream + '&streamtype=' + streamtype + '&plugin=' + plugin, 'mediaPlayer');    
  } 
  
  else if(mediaPlayerID == "qt"){
    window.open('qtplayer.html?stream=' + stream + '&streamtype=' + streamtype + '&plugin=' + plugin, 'mediaPlayer');    
  } 
  
  else if(mediaPlayerID == "real"){
    window.open('realplayer.html?stream=' + stream + '&streamtype=' + streamtype + '&plugin=' + plugin, 'mediaPlayer');   
  }   
  
}


function changeVisibility(vis) {  
  document.getElementById("mediaPlayerDIV").style.visibility = "" + vis;
}

function changePosition(top, left) {  
  document.getElementById("mediaPlayerDIV").style.top= top + "px";
  document.getElementById("mediaPlayerDIV").style.left= left + "px";  
}

function changeAccessible(){
  var accessiblePage = "http://" + document.location.host.toString() + document.location.pathname.toString() + "?" + qs + "&qsAccessible=1"; 
  window.location.replace(accessiblePage);  
}

var resizeIntervalID = 0;
function resize(width, height){
  
  //ADJUST HEIGHT ACCORDING TO STATUS BAR HEIGHT
  var agent = navigator.userAgent.toLowerCase();
  if(agent.indexOf("firefox") != -1){
    statusHeight = 50;
  }
  else{
	var ie7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;
	if(ie7){
		statusHeight = 48;
	}
	else{
	    statusHeight = 23;
	}    
  }
  var heightWithStatus = parseInt(height) + statusHeight;
    
	try {
		window.resizeTo(width, heightWithStatus);
		//window.status = "resize: w=" + width + " h:" + height;
		if (resizeIntervalID != 0) {
			clearInterval(resizeIntervalID);
			resizeIntervalID = 0;
			//window.status = "clear!";
		}
	} catch (e) {
		if (resizeIntervalID == 0) {
			// RETRY
			resizeIntervalID = setInterval("resize("+width+","+height+")",100);
			//window.status = "retry: w=" + width + " h:" + height + " iID = " + resizeIntervalID;
		}
	}
}


function openLinkInBlankWindow(link_url){
  	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(link_url, '" + id + "', 'toolbar=1,scrollbars=1,location=1,status=1,statusbar=1,menubar=1,resizable=1');");	
}

