var player = null;
var oldCategory = '';

function playerReady(thePlayer) {
player = window.document[thePlayer.id];
var id = player.id;
}

function Reload(link) {
   var iLen = String(link).length;
   var fileType = String(link).substring(iLen, iLen - 3);
   //alert(fileType);
   
   if (fileType == 'flv')
    CreatePlayer(link);
   else if (fileType == 'swf')
    LoadSWF(link);
   else
    alert('Video files must be either swf or flv.');
   
   //player = document.getElementById(player.id);
   //player.sendEvent('STOP'); 
   //player.sendEvent('LOAD', link)
}

function LoadCategory(category) {
  var newLink;
  var oldLink;
  var a = 1;
  if (category != oldCategory) {
  for (a=1; 50 > a; a++) {
    newLink = document.getElementById(category+a);
    oldLink = document.getElementById(oldCategory+a);
    if (newLink)
     if (newLink.style.display != 'inline')
      newLink.style.display = 'inline';
    if (oldLink)
     if (oldLink.style.display != 'none')
      oldLink.style.display = 'none';
  }
  oldCategory = category;
  }
  document.getElementById('videoGuard1').style.display = 'inline';
  document.getElementById('videoGuard2').style.display = 'inline';
}

function CreatePlayer(link) {
	var flashvars = {
		file: link, 
		autostart:"true",
		playlistsize:"0",
        playlist:"none"
	}

	var params = {
		allowfullscreen:"true", 
		allowscriptaccess:"always"
	}

	var attributes = {
		id:"placeholder1",  
		name:"placeholder1"
	}

	swfobject.embedSWF("/swf/player-viral.swf", "placeholder1", "500", "400", "9", false, flashvars, params, attributes);
}

function LoadSWF(link) {
    var video = link;
    var params = {
        quality: "best",
        allowFullScreen: "true",
        scale: "showall",
        allowScriptAccess: "always",
        autostart: "false"
    }
    
    swfobject.embedSWF(video, "placeholder1", "500", "400", "9", "", "", params);
   }

var flashvars = {
	file: "/swf/What is Netsphere.flv", 
	autostart:"false",
	playlistsize:"0",
    playlist:"none"
}
swfobject.embedSWF("/swf/player-viral.swf", "placeholder1", "500", "400", "9", false, flashvars);