﻿//Support function: checks to see if target
//element is an object or embed element
// Learn about this here http://pipwerks.com/lab/swfobject/load-onclick/2.0/index.html

function isObject(targetID){

   var isFound = false;
   var el = document.getElementById(targetID);
   
   if(el && (el.nodeName === "OBJECT" || el.nodeName === "EMBED")){
   
      isFound = true;
   
   }
   
   return isFound;
}

//Support function: creates an empty
//element to replace embedded SWF object

function replaceSwfWithEmptyDiv(targetID){

   var el = document.getElementById(targetID);
   
   if(el){
   
      var div = document.createElement("div");
      el.parentNode.insertBefore(div, el);
 
      //Remove the SWF
      swfobject.removeSWF(targetID);
   
      //Give the new DIV the old element's ID
      div.setAttribute("id", targetID);
      
   }
   
}


function loadSWF(url, targetID, flvfile){

   //Check for existing SWF
   if(isObject(targetID)){
   
      //replace object/element with a new div
      replaceSwfWithEmptyDiv(targetID);
      
   }
     
   //Embed SWF
   if (swfobject.hasFlashPlayerVersion("7")) {
      var myflashvars = "FLVFile=" + flvfile;     
      var attributes = { data: url, width:"350", height:"314" };
      var params = {
                    flashvars: myflashvars,
                    wmode: "transparent"
                   };
      var obj = swfobject.createSWF(attributes, params, targetID);
   
   }
   
}

