var requiredMajorVersion = 9;
var requiredMinorVersion = 0;
var requiredRevision = 115;

var id = 1;
var isAndroid = navigator.userAgent.toLowerCase().indexOf("android") > -1;

function showVideoButton(video)
{
  showVideoButton1(video, 'SOMVideoButton', 74, 17);
}


function showEntireButton(video)
{
  showVideoButton1(video, 'SOMEntireButton', 142, 48);
}


function showVideoButton1(video, swf, width, height)
{
   var pngName;
   if (swf == "SOMVideoButton")
     pngName = "video.png";
   else
     pngName = "fullprotocol.png";
    

   if (isAndroid)
     document.write('<a href="SOMVideoPlayer://video=' + toAbsURL(video) + '.flv"><img style="border-style: none" src="/dnn/som/protocols/library/' + pngName + '"></a>');
   else
   {
	document.write('<span id="VideoButtonSpan' + id + '" style="display:inline; vertical-align:middle">');
	AC_FL_RunContent(
		'codebase','//fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab',
		'width', width,
		'height', height,
		'wmode', 'window',
                'id', 'VideoButton' + id,
                'name', 'VideoButton' + id,
		'src','/dnn/som/player/' + swf,
		'allowscriptaccess','all',
		'pluginspage','//www.macromedia.com/go/getflashplayer',
		'flashvars','video=' + toAbsURL(video) + '.flv'
	);
	id += 1;
	document.write('</span>');
   }
}

function showEmbeddedPlayer(video, w, h)
{
  w = typeof(w) != 'undefined' ? w : 800;
  h = typeof(h) != 'undefined' ? h : 600;
  id += 1;
  var windowName = 'wEmbeddedPlayer' + id;
  var newWindow = window.open('/dnn/som/player/VideoPlayer.html', windowName, 'height=' + h + ',width=' + w + ',location=no,directories=no,scrollbars=no,status=no,titlebar=no,toolbar=no,menubar=no,resizable=yes'); 

  doc = newWindow.document;
  doc.write('<html><head><title>Science of Massage Video Player</title></head><body style="margin: 0">');
	AC_FL_RunContent(
		'codebase','//fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab',
		'width', '100%',
		'height', '100%',
		'wmode', 'window',
                'id', windowName,
                'name', windowName,
		'src','/dnn/som/player/SOMEmbeddedPlayer',
		'allowscriptaccess','all',
		'pluginspage','//www.macromedia.com/go/getflashplayer',
		'flashvars','video=' + toAbsURL(video) + '.flv'
	);
  doc.write('</body></html>');

}

function resizeStage(id)
{
  document.getElementsByName(id)[0].height = '150px';
  document.getElementsByName(id)[0].width = '220px';
}

function toAbsURL(s) 
{ 
  var l = location, h, p, f, i; 
  if (/^\w+:/.test(s)) { 
    return s; 
  } 


  h = l.protocol + '//' + l.host; 
  if (s.indexOf('/') == 0) { 
    return h + s; 
  } 

  p = l.pathname.replace(/\/[^\/]*$/, ''); 
  f = s.match(/\.\.\//g); 
  if (f) { 
    s = s.substring(f.length * 3); 
    for (i = f.length; i--;) { 
      p = p.substring(0, p.lastIndexOf('/')); 
    } 
  } 


  return h + p + '/' + s; 
} 

function refresh()
{
  window.location = window.location;
}

