/**
* prüft, ob eine Variable definiert ist
*/
isDefined = function(variable){
  return this[variable] === undefined ? false : true;
};
//gRS=1;  // allow resize

var gLS="753948206";

/**
* insert the bg.swf applet-tag into site
* optional Global Vars:
* ------------
* gPC - PanoCardID which will be displayed after start
* gPN - Pano ID to start with
* gPS - Script ID to start with (combines with gPN)
* gCF - Config-ID from parmroot.xml which will be loaded
* gLY - path to an alternative layout
* gLS - seed for layout

* Parameter:
* ----------
* @param pw  - AppletWidth
* @param ph  - AppletHeight
* @param cf_ - config ID (optional), same as gCF but leading
* @return - HTML for SWF (already written to document)
*/
function insertApplet(pw,ph,cf_){
  var s="";
  var fv= "";
  var cf = cf_;
  if (isDefined("gPC") && gPC != null){
    fv+='PCID='+gPC;
  }
  if (isDefined("gPN")&& gPN != null){
    if (fv!="") fv += "&";
    fv+='PANO='+gPN;
  }
  if (isDefined("gPS")&& gPS != null){
    if (fv!="") fv += "&";
    fv+='SCRIPT='+gPS;
  }
  if (isDefined("gCF")&& gCF != null && cf == null){
    cf = gCF;
  }
  if (cf != null){
    if (fv!="") fv += "&";
    fv+='CONFIG='+cf;
  }
  if (isDefined("gLY")&& gLY != null){
    if (fv!="") fv += "&";
    fv+='LAYOUT='+gLY;
  }
  if (isDefined("gLS")&& gLS != null){
    if (fv!="") fv += "&";
    fv+='LAYSD='+gLS;
  }
  if (isDefined("gRS")&& gRS != null){
    if (fv!="") fv += "&";
    fv+='RESIZE=1';
  }

  s+='    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"\n';
  s+='      id="bgapplet" width="';
  s+= pw;
  s+=    '" height="';
  s+= ph;
  s+=    '" \n';
  s+='      codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">\n';
  switch (window.location.protocol) {
     case "http:":
          s+='      <param name="movie" value="bg.swf" />\n'; break;
     case "file:":
          s+='      <param name="movie" value="bgl.swf" />\n'; break;
     default: break;
  }  
  s+='      <param name="quality" value="high" />\n';
  s+='      <param name="bgcolor" value="#ffffff" />\n';
  s+='      <param name="allowNetworking" value="all" />\n';
  s+='      <param name="allowScriptAccess" value="always" />\n';
  s+='      <param name="allowFullScreen" value="true" />\n';
  s+='      <param name="wmode" value="gpu" />\n';
  if (fv != ""){
    s+='      <param name="flashVars" value="'+fv+'" />\n';
  }
  switch (window.location.protocol) {
     case "http:":
          s+='      <embed src="bg.swf" quality="high" bgcolor="#ffffff"\n'; break;
     case "file:":
          s+='      <embed src="bgl.swf" quality="high" bgcolor="#ffffff"\n'; break;
     default: break;
  }  
  s+='        width="';
  s+= pw;
  s+=    '" height="';
  s+= ph;
  s+=    '"';
  s+=' name="bgapplet" align="middle"\n';
  s+='        play="true"\n';
  s+='        loop="false"\n';
  s+='        quality="high"\n';
  s+='        allowNetworking="all"\n';
  s+='        allowScriptAccess="always"\n';
  s+='        allowFullScreen="true"\n';
  s+='        wmode="gpu"\n';
  if (fv != ""){
    s+='      flashVars="'+fv+'"\n';
  }
  s+='        type="application/x-shockwave-flash"\n';
  s+='        pluginspage="http://www.adobe.com/go/getflashplayer">\n';
  s+='      </embed>\n';
  s+='  </object>\n';
  document.write(s);
};

