function writeSWFtag (strSWFFile, intWidth, intHeight) {
    document.write('<object type="application/x-shockwave-flash" data="' + strSWFFile + '" ');
    document.write('width="' + intWidth + '" height="' + intHeight + '">');
    document.write('<param name="movie" value="' + strSWFFile + '"></object>');
}



var imgWait = new Image();
imgWait.src='/images/layout/waiting.gif';

function openWizardPreview(reqParms, name, width, height)
{
    if ((width == null) | (width.length == 0))
    {
        width = 569;
    }
    if ((height == null) | (height.length == 0))
    {
        height = 375;
    }
    
    document.getElementById('WizardPreviewContent').innerHTML='';
    document.getElementById('WizardPreviewContent').style.textAlign='center';
    document.getElementById('WizardPreviewContent').appendChild(imgWait);
    document.getElementById('wizardPreviewBackground').style.visibility='visible';
    document.getElementById('wizardPreviewBackground').style.display='block';
    
    
    
    var divHeight = xDocHeight(); //2740;
    document.getElementById('wizardPreviewBackground').style.height=divHeight+'px';
    
    var so = new SWFObject("/Video/videoplayer.swf", "sotester", width, height, "9", "#ffffff");
	so.addParam("base", ".");
	so.addParam("allowFullScreen", "true");
	so.addParam("allowScriptAccess", "sameDomain");

	so.addVariable("playlist","/Video/playlist.xml");
	so.addVariable("movieid","1");


	var strContent = so.getSWFHTML();
                    
    ChangeContent('WizardPreviewContent', strContent);
    
    document.getElementById('wizardPreviewPane').style.visibility='visible';
    document.getElementById('wizardPreviewPane').style.display='block';
    document.getElementById('wizardPreviewName').innerHTML=name;       
}

var type = "IE";        

function ChangeContent(id, str) { 

BrowserSniffer(); 

 if (type=="IE") {
         document.all[id].innerHTML = str;         
 } 
 if (type=="NN") { 
         document.layers[id].document.open(); 
         document.layers[id].document.write(str); 
         document.layers[id].document.close();          
 }
 if (type=="MO" || type=="OP") { 
         document.getElementById(id).innerHTML = str;          
 } 
} 

 
function BrowserSniffer() { 
 if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";         
 else if (document.all) type="IE";                                                                                                  
 else if (document.layers) type="NN";                                                                                        
 else if (!document.all && document.getElementById) type="MO";                                               
 else type = "IE";              
}

function closeWizardPreview()
{
    document.getElementById('wizardPreviewBackground').style.visibility='hidden';
    document.getElementById('wizardPreviewPane').style.visibility='hidden';
    document.getElementById('wizardPreviewBackground').style.display='none';
    document.getElementById('wizardPreviewPane').style.display='none';
    ChangeContent('WizardPreviewContent', '');
}



// xDocSize r1, Copyright 2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL
function xDocHeight()
{
  var b=document.body;
  var e=document.documentElement;
  var esh=0;
  var eoh=0;
  var bsh=0;
  var boh=0;
  if (e) {
    esh = e.scrollHeight;
    eoh = e.offsetHeight;
  }
  if (b) {
    bsh = b.scrollHeight;
    boh = b.offsetHeight;
  }
//  alert('compatMode: ' + document.compatMode + '\n\ndocumentElement.scrollHeight: ' + esh + '\ndocumentElement.offsetHeight: ' + eoh + '\nbody.scrollHeight: ' + bsh + '\nbody.offsetHeight: ' + boh + '\n\ndocumentElement.scrollWidth: ' + esw + '\ndocumentElement.offsetWidth: ' + eow + '\nbody.scrollWidth: ' + bsw + '\nbody.offsetWidth: ' + bow);
  return Math.max(esh,eoh,bsh,boh);
}



function xDocSize()
{
  var b=document.body, e=document.documentElement;
  var esw=0, eow=0, bsw=0, bow=0, esh=0, eoh=0, bsh=0, boh=0;
  if (e) {
    esw = e.scrollWidth;
    eow = e.offsetWidth;
    esh = e.scrollHeight;
    eoh = e.offsetHeight;
  }
  if (b) {
    bsw = b.scrollWidth;
    bow = b.offsetWidth;
    bsh = b.scrollHeight;
    boh = b.offsetHeight;
  }
//  alert('compatMode: ' + document.compatMode + '\n\ndocumentElement.scrollHeight: ' + esh + '\ndocumentElement.offsetHeight: ' + eoh + '\nbody.scrollHeight: ' + bsh + '\nbody.offsetHeight: ' + boh + '\n\ndocumentElement.scrollWidth: ' + esw + '\ndocumentElement.offsetWidth: ' + eow + '\nbody.scrollWidth: ' + bsw + '\nbody.offsetWidth: ' + bow);
  return {w:Math.max(esw,eow,bsw,bow),h:Math.max(esh,eoh,bsh,boh)};
}
