// JavaScript Document
winIEpass = ((navigator.appName.indexOf("Microsoft") != -1) && 
  (navigator.appVersion.indexOf("Windows") != -1)) && 
  (parseFloat(navigator.appVersion) >= 4) ? true : false;

NNpass = ((navigator.appName == "Netscape") && 
  (navigator.userAgent.indexOf("Mozilla") != -1) && 
  (parseFloat(navigator.appVersion) >= 4) && 
  (navigator.javaEnabled())) ? true : false;

  supportedBrowser = (winIEpass || NNpass) ? true : false;

// check for Flash Plug-in in Mac or Win Navigator. Get plug-in version.

minPlayer = 5;
var mySwf;

function Flash_checkForPlugIn() {
  var plugin = (navigator.mimeTypes &&
  navigator.mimeTypes["application/x-shockwave-flash"]) ?
  navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
  if (plugin) {
    var pluginversion = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) 
    if(pluginversion >= minPlayer) {return true;}
  }
  return false;
}

// vbscript check for Flash ActiveX control in windows IE
if(supportedBrowser && winIEpass) {
  document.write(
    '<script language=VBScript>' + '\n' +
    'Function Flash_checkForActiveX()' + '\n' +
    'Dim hasPlayer, playerversion' + '\n' +
    'hasPlayer = false' + '\n' +
    'playerversion = 10' + '\n' +
    'Do While playerversion >= minPlayer' + '\n' +
    'On Error Resume Next' + '\n' +
    'hasPlayer = (IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" & playerversion & \"\")))' + '\n' +
    'If hasPlayer = true Then Exit Do' + '\n' +
    'playerversion = playerversion - 1' + '\n' +
    'Loop' + '\n' +
    'Flash_checkForActiveX = hasPlayer' + '\n' +
    'End Function' + '\n' +
    '<\/script>'
  );
}

function Flash_checkForMinPlayer() {
  if(!supportedBrowser) return false;
  if(NNpass) return (Flash_checkForPlugIn());
  if(winIEpass) return (Flash_checkForActiveX());
}

function Flash_embedSWF(srcURL, id, hsize, vsize, swfbgColor, zindx) {

  if (!Flash_checkForMinPlayer()) return;
  var refarray = new Array();
	refarray['bil'] = "Billaan";
	//refarray['acceptcard'] = "acceptcard.swf"; // flash source file in array to support multiple conditional targeting
	for (var i in refarray) { if (document.referrer.indexOf(i) != -1) srcURL = "/upload/flash/" + refarray[i] + ".swf?eventTAG=" + document.domain + "/" + refarray[i] + "/";}
  var defaultColor = (document.bgColor != null) ? document.bgColor : "#ffffff";
  var bgcolor = (swfbgColor != null) ? swfbgColor : defaultColor;
  document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' +
	'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"' +
    'ID="' + id + '" width="' + hsize + '" height="' + vsize + '" style="z-index:' + zindx + ' !important; position:relative">' +
		'<param name="allowScriptAccess" value="sameDomain">' +
    '<param name="movie" value="' + srcURL + '">' + 
    '<param name="quality" value="high">' +
    '<param name="bgcolor" VALUE=' + bgcolor + '>' +
	'<param name="wmode" value="transparent" /> ' +
    '<embed style="z-index:' + zindx + ' !important; position:relative" src="' + srcURL + '" quality="high"' + 'bgcolor="' + 
    bgcolor + '"' + 'width="' + hsize + '" height="' + vsize + '"' +
    'type="application/x-shockwave-flash" name="' + id + '"' +
	'align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>');

  //eval('window.document.'+ id + '.Rewind()');
  // Ovenstående linie sørger for at .swf filen ikke starter automatisk
  return (eval('window.document.'+ id));
}

function Flash_embedSWFCmd(srcURL, id, hsize, vsize, swfbgColor, zindx) {

  if (!Flash_checkForMinPlayer()) return;
  var refarray = new Array();
	refarray['bil'] = "Billaan";
	//refarray['acceptcard'] = "acceptcard.swf"; // flash source file in array to support multiple conditional targeting
	for (var i in refarray) { if (document.referrer.indexOf(i) != -1) srcURL = "/upload/flash/" + refarray[i] + ".swf?eventTAG=" + document.domain + "/" + refarray[i] + "/";}
  var defaultColor = (document.bgColor != null) ? document.bgColor : "#ffffff";
  var bgcolor = (swfbgColor != null) ? swfbgColor : defaultColor;
  document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' +
	'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"' +
    'ID="' + id + '" width="' + hsize + '" height="' + vsize + '" style="z-index:' + zindx + ' !important; position:relative">' +
		'<param name="allowScriptAccess" value="sameDomain">' +
    '<param name="movie" value="' + srcURL + '">' + 
    '<param name="quality" value="high">' +
    '<param name="bgcolor" VALUE=' + bgcolor + '>' +
	'<param name="wmode" value="transparent" /> ' +
    '<embed style="z-index:' + zindx + ' !important; position:relative" src="' + srcURL + '" swLiveConnect="true" quality="high"' + 'bgcolor="' + 
    bgcolor + '"' + 'width="' + hsize + '" height="' + vsize + '"' +
    'type="application/x-shockwave-flash" name="' + id + '"' +
	'align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>');

  //eval('window.document.'+ id + '.Rewind()');
  // Ovenstående linie sørger for at .swf filen ikke starter automatisk
  return (eval('window.document.'+ id));
}

function sonified_flash(id, myFrame){
  if(!Flash_checkForMinPlayer()) {return;}
  mySwf = eval('window.document.' + id);
  if (mySwf.PercentLoaded()<100) return

  mySwf.GotoFrame(myFrame);
  mySwf.GotoFrame(0);
}

function Img_embed(srcURL, hsize, vsize) {
  var refarray = new Array();
  refarray['bil'] = "Billaan";
  //refarray['acceptcard'] = "AcceptCard"; // source in array to support multiple conditional targeting
  for (var i in refarray) { if (document.referrer.indexOf(i) != -1) srcURL = refarray[i];}
  document.write('<a ' + 
	'href="/' + srcURL + '"' +
	'title="http://' + document.domain + '/' + srcURL + '/"' + 
	'<img ' +
	'width="' + hsize + '"' +
	'height="' + vsize + '"' +
	'src="/upload/flash/' + srcURL + '.gif" ' + 
	'alt="http://' + document.domain + '/' + srcURL + '/"' + 
	'border="0"></a>');
  return;
}