/* This script was made as a quick workaround for the problem with incorrect handling of javascript snippets by RAD-editor.
Tags to be placed into the content situated inside RAD-editor (they provide dynamic variable for this script):
<span id="urlFlash" value="/NR/rdonlyres/BE05CAEB-4FA9-48D5-AFC1-C1600553142A/0/sitra_20080918.swf"></span>
<span id="urlVideo" value="/NR/rdonlyres/5CA4B6F7-8A8A-441D-B6A9-8F2ACF67385D/0/anu.flv"></span>
<span id="widthFlash" value="480"></span>
<span id="heightFlash" value="280"></span>
TODO: overcome current limitation with only 1 flash file possible on one page
*/

var urlFlash = document.getElementById("urlFlash");
if(urlFlash != null) urlFlash = urlFlash.getAttribute("value");

var urlVideo = document.getElementById("urlVideo");
if(urlVideo != null) urlVideo = urlVideo.getAttribute("value");

var widthFlash = document.getElementById("widthFlash");
if(widthFlash != null) widthFlash = widthFlash.getAttribute("value");

var heightFlash = document.getElementById("heightFlash");
if(heightFlash != null) heightFlash = heightFlash.getAttribute("value");

if( urlFlash == null ) {
	//alert("Please specify parameter urlFlash.");
} else {
  if( widthFlash == null ) widthFlash = "480";
  if( heightFlash == null ) heightFlash = "280";

  var so = new SWFObject(urlFlash, "sitra", widthFlash, heightFlash, "8", "#FFFFFF");
  so.useExpressInstall('/js/expressinstall.swf');
  if( urlVideo != null ) {
    so.addVariable("videoPath",urlVideo);
  }
  if( !isEditing() ) {
    so.write("flashcontent");
  }
}

function isEditing() {
  var wbcMode = gup("WBCMODE");
  if( wbcMode == null || wbcMode.Length == 0 ) return false;

  var pattern=/^authoring/i
  return pattern.test(wbcMode);
}

function gup(name) {  
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.href);
  if( results == null ) {
    return "";
  } else {
    return results[1];
  }
}

