//
// The Frank Peters Show
// Wimpy Player code and other routines
//
//
function wimpyPopPlayer(pathToMyWimpyHTML,wimpyID,dimensions) {
  window.open(pathToMyWimpyHTML,wimpyID,dimensions);
}

function writePlayer(urlFile, urlImage)
{
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="180" height="135" id="wasp12365" name="wasp12365" align="middle">' +
               '<param name="allowScriptAccess" value="sameDomain" />' +
               '<param name="movie" value="http://www.theFrankPetersShow.com/podcasts/wasp/wasp.swf?theFile=' + urlFile + '&defaultImage=' + urlImage + '&startPlayingOnload=no&bufferSeconds=5&videoSmoothing=yes" />' +
               '<param name="loop" value="false" />' +
               '<param name="menu" value="false" />' +
               '<param name="quality" value="high" />' +
               '<param name="scale" value="noscale" />' +
               '<param name="salign" value="lt" />' +
               '<param name="bgcolor" value="#000000" />' +
               '<embed src="http://www.theFrankPetersShow.com/podcasts/wasp/wasp.swf?theFile=" + urlFile + "&defaultImage=" + urlImage + "&startPlayingOnload=no&bufferSeconds=5&videoSmoothing=yes" loop="false" menu="false" quality="high" scale="noscale" salign="lt" width="180" height="135" name="wasp12365" align="middle" bgcolor="#000000" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
               '</object>');
}

function writePlayerFF(videoFile, stillImage, Width, Height)
{
	// var Width = '180'
	// var Height = '135'
	
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+Width+'" height="'+Height+'" id="wasp25617" name="wasp25617" align="middle">' +
	'<param name="allowScriptAccess" value="sameDomain" />' +
	'<param name="movie" value="http://www.theFrankPetersShow.com/podcasts/wasp/wasp.swf" />' +
	'<param name="loop" value="false" />' +
	'<param name="menu" value="false" />' +
	'<param name="quality" value="high" />' +
	'<param name="scale" value="noscale" />' +
	'<param name="salign" value="lt" />' +
	'<param name="bgcolor" value="#000000" />' +
	'<param name="flashvars" value="theFile='+videoFile+'&defaultImage='+stillImage+'&startPlayingOnload=no&bufferSeconds=5&videoSmoothing=yes" />' +
	'<embed src="http://www.theFrankPetersShow.com/podcasts/wasp/wasp.swf" flashvars="theFile='+videoFile+'&defaultImage='+stillImage+'&startPlayingOnload=no&bufferSeconds=5&videoSmoothing=yes" loop="false" menu="false" quality="high" scale="noscale" salign="lt" width='+Width+' height='+Height+'  name="wasp25617" align="middle" bgcolor="#000000" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
               '</object>');
}


///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
//                                                      ///////
//                        Wasp                          ///////
//                     Version 2.0                      ///////
//       (Formerly known as: Wimpy AV Single Play)      ///////
//                                                      ///////
//         by Mike Gieson <info@wimpyplayer.com>        ///////
//                                                      ///////
//        Available at http://www.wimpyplayer.com       ///////
//                 ©2002-2006 plaino                    ///////
//                                                      ///////
///////////////////////////////////////////////////////////////
//
// This product includes software developed by Macromedia, Inc.
// 
// Macromedia(r) Flash(r) JavaScript Integration Kit
// Portions noted as part of the JavaScript Integration Kit
// are Copyright (c) 2005 Macromedia, inc. All rights reserved.
// http://www.macromedia.com/go/flashjavascript/
// 
// Macromedia(r) Flash(r) JavaScript Integration Kit Created by:
// 
// Christian Cantrell
// http://weblogs.macromedia.com/cantrell/
// mailto:cantrell@macromedia.com
// 
// Mike Chambers
// http://weblogs.macromedia.com/mesh/
// mailto:mesh@macromedia.com
// 
// Macromedia
// 
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
////////////                                     ////////////
////////////              OPTIONS                ////////////
////////////                                     ////////////
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
//
// Set locations of files:
// 
// waspSWFfilename
// You can change the name of the wasp.swf file here.
// Obviously, if you change the name here, then you will have to 
// change the name of the actual file in your wasp folder too.
waspSWFfilename = "http://www.theFrankPetersShow.com/podcasts/wasp/wasp.swf";
//
// Default Image:
// 
// defaultImage
// Allows you to set a default graphic if the player is does not 
// startOnLoad automatically. Also, if the player is not set to 
// loop, the image defined here will show up once the video is complete.
// 
// The graphic will automatically be size to the same dimensions as the video window.
// When the image is clicked the video current video (if defined) will start to play.
//
defaultImage = "http://www.theFrankPetersShow.com/podcasts/fp.jpg";
//
// waspHTMLtemplateFilename
// This is the page that is used when a pop up window is called. 
// This file should be located in the wasp installation folder.
// You can change the name of the waspTemplate.html file here.
// Obviously, if you change the name here, then you will have to 
// change the name of the actual file in your wasp folder too.
// 
// I'm not using a pop-up player
waspHTMLtemplateFilename = "waspPopup.html";
//
// startPlayingOnload
// Setting this to "yes" will start to play automatically.
// Setting this to "no" will force the user to click the 
// "play" button to start playing the video
startPlayingOnload = "no";
// startPlayingOnload = "yes";
//
// transparentBkgd 
// This will anable you to "see through" the player and display 
// the HTML (or table) background image or color.
transparentBkgd = "yes";
//
// bkgdColor
// If not using a transparent background, this will be the 
// background color of the video window.
bkgdColor = "#000000";
//
// popUpHelp
// Setting this to "yes" will display little yellow "help" 
// boxes when the user hoovers over the control functions.
// Setting this to "no" will disable this feature.
popUpHelp = "yes";
//
// loopTrack
// Setting thei to "yes" will cause the video to repeat 
// once it has reached the end, and continue to loop 
// until the user clicks stop.
// Setting this to "no" will cause the video to 
// disappear once it has finished. 
loopTrack = "no";
//
// theVolume
// You can controll the initial volume setting when 
// the player loads. The range is 0-100, where 0 is 
// no sound and 100 is full volume
theVolume = "100";
//
// controllocation
// You can place the playback controls above or below 
// the video. To place the controls above the video, 
// set this to "top" - to place the controls below the video, 
// set this to "bottom"
//controllocation = "top";
controllocation = "bottom";
//
// bufferSeconds
// Causes the video to load for a certain number of seconds 
// before starting to play. A higher value can minimize the 
// "stutter" effect users might have with slower connections, 
// or larger files.
bufferSeconds = 3;
//
// videoSmoothing
// Specifies whether the video should be smoothed 
// (interpolated) when it is scaled.
//videoSmoothing = "yes";
videoSmoothing = "no";
//
// videoDeblocking
// Setting this to "yes" can degrade overall playback performance 
// for less powerful PCs. Leave at "" to allow the end user's 
// system to manage the filter automatically.
//videoDeblocking = "yes";
//videoDeblocking = "no";
videoDeblocking = "";
//
//
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
////////////                                     ////////////
////////////   NO FURTHER CONFIGURATION NEEDED   ////////////
////////////                                     ////////////
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
////////////                                     ////////////
////////////     IN OTHER WORDS, DON'T EDIT      ////////////
////////////     ANYTHING BELOW HERE UNLESS      ////////////
////////////   YOU'RE FAMILIAR WITH JAVASCRIPT   ////////////
////////////                                     ////////////
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
//
function waspEmbed(theFileIN, defaultImage, theWidthIN, theHeightIN){
	var fileSWFsend = waspSWFfilename;
	var fileINsend = theFileIN;
	writeSWFcode(fileSWFsend, fileINsend, defaultImage, theWidthIN, theHeightIN);
}

function writeSWFcode(fileSWF, fileIN, defaultImage, theWidth, theHeight){
	//
	myuid = new Date().getTime();
	myuid = "wasp" + myuid
	flashProxy = new FlashProxy(myuid, waspSWFfilename);
	//
	var perpix = new String(theHeight);
	if(perpix.indexOf("%") > (-1)){
		var padControls = theHeight;
	} else {
		var padControls = theHeight+15;
	}
	var queryString = '';
	queryString += "theFile="+fileIN;
	//
	js2wasp_param = '<param name="flashvars" value="lcId='+myuid+'"/>';
	js2wasp_embed = 'flashvars="lcId='+myuid+'" ';
	//
	if(transparentBkgd == "yes"){
		var tptBkgd_param = '<param name="wmode" value="transparent" />';
		var tptBkgd_embed = 'wmode="transparent" ';
	} else {
		var tptBkgd_param = "";
		var tptBkgd_embed = "";
	}
	if(startPlayingOnload == "yes"){
		queryString += '&startPlayingOnload='+startPlayingOnload;
	}
	if(popUpHelp == "no"){
		queryString += '&popUpHelp='+popUpHelp;
	}
	if(loopTrack == "yes"){
		queryString += '&loopTrack='+loopTrack;
	}
	if(controllocation == "top"){
		queryString += '&controllocation='+controllocation;
	}
	if(theVolume != 100 && theVolume > 0 && theVolume < 100){
		queryString += '&theVolume='+theVolume;
	}
	if(bufferSeconds > 3){
		queryString += '&bufferSeconds='+bufferSeconds;
	}
	if(defaultImage != ""){
		queryString += '&defaultImage='+defaultImage;
	}
	if(videoDeblocking == "yes" || videoDeblocking == "no"){
		queryString += "&videoDeblocking="+videoDeblocking;
	}
	if(videoSmoothing == "yes"){
		queryString += "&videoSmoothing="+videoSmoothing;
	}
	var flashCode = '';
	var newlineChar = "\n";
	flashCode += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab// - version=7,0,0,0" width="'+theWidth+'" height="'+padControls+'" name="'+myuid+'" id="'+myuid+'">'+newlineChar;
	flashCode += '<param name="movie" value="'+fileSWF+'?'+queryString+'" />'+newlineChar;
	flashCode += '<param name="loop" value="false" />'+newlineChar;
	flashCode += '<param name="menu" value="false" />'+newlineChar;
	flashCode += '<param name="quality" value="high" />'+newlineChar;
	flashCode += '<param name="scale" value="noscale" />'+newlineChar;
	flashCode += '<param name="salign" value="lt" />'+newlineChar;
	flashCode += '<param name="bgcolor" value="'+bkgdColor+'" />'+newlineChar;
	flashCode += tptBkgd_param;
	flashCode += js2wasp_param;
	flashCode += '<embed src="'+fileSWF+'?'+queryString+'" width="'+theWidth+'" height="'+padControls+'" bgcolor="'+bkgdColor+'" loop="false" menu="false" quality="high" scale="noscale" salign="lt" id="'+myuid+'" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" '+tptBkgd_embed+js2wasp_embed+'/></object>'+newlineChar;
	// To reveal the source HTML, uncomment below:
	//document.write('<br><textarea name="textarea" cols="40" rows="10">'+flashCode+'</textarea><br>')+newlineChar;
	document.write(flashCode);
}



function waspPopup (filename, width, height){
	var rnum = (Math.round((Math.random()*1000000)+1));
	var padControls = height+15
	var theURL = waspHTMLtemplateFilename+'?theFile='+filename+'&wW='+width+'&wH='+padControls;
	var winName = 'wasp'+rnum;
	var extras = 'width='+width+',height='+padControls
	window.open(theURL,winName,extras);
}
function wasp(){
	startPlayingOnload = "yes";
	var qsParm = new Array();
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	for (var i=0; i<parms.length; i++) {
		var pos = parms[i].indexOf('=');
		if (pos > 0) {
			var key = parms[i].substring(0,pos);
			var val = parms[i].substring(pos+1);
			qsParm[key] = val;
		}
	}
	var fileSWFsend = waspSWFfilename;
	var fileINsend = qsParm['theFile'];
	writeSWFcode(fileSWFsend, fileINsend, "100%", "100%");
}
function wasp_loadAndPlay(theFileIN){
	flashProxy.call('js_wasp_loadAndPlay', theFileIN);
}
/*
The following code is part of the Flash / JavaScript Integration Kit:
http://www.macromedia.com/go/flashjavascript/
*/
function Exception(name, message){
    if (name)
        this.name = name;
    if (message)
        this.message = message;
}
Exception.prototype.setName = function(name){
    this.name = name;
}
Exception.prototype.getName = function(){
    return this.name;
}
Exception.prototype.setMessage = function(msg){
    this.message = msg;
}
Exception.prototype.getMessage = function(){
    return this.message;
}
function FlashProxy(uid, proxySwfName){
    this.uid = uid;
    this.proxySwfName = proxySwfName;
    this.flashSerializer = new FlashSerializer(false);
}
FlashProxy.prototype.call = function(){
    if (arguments.length == 0)
    {
        throw new Exception("Flash Proxy Exception",
                            "The first argument should be the function name followed by any number of additional arguments.");
    }
    var qs = 'lcId=' + escape(this.uid) + '&functionName=' + escape(arguments[0]);
    if (arguments.length > 1)
    {
        var justArgs = new Array();
        for (var i = 1; i < arguments.length; ++i)
        {
            justArgs.push(arguments[i]);
        }
        qs += ('&' + this.flashSerializer.serialize(justArgs));
    }
    var divName = '_flash_proxy_' + this.uid;
    if(!document.getElementById(divName))
    {
        var newTarget = document.createElement("div");
        newTarget.id = divName;
        document.body.appendChild(newTarget);
    }
    var target = document.getElementById(divName);
    var ft = new FlashTag(this.proxySwfName, 1, 1);
    ft.setVersion('6,0,65,0');
    ft.setFlashvars(qs);
    target.innerHTML = ft.toString();
}
FlashProxy.callJS = function(){
    var functionToCall = eval(arguments[0]);
    var argArray = new Array();
    for (var i = 1; i < arguments.length; ++i)
    {
        argArray.push(arguments[i]);
    }
    functionToCall.apply(functionToCall, argArray);
}
function FlashSerializer(useCdata){
    this.useCdata = useCdata;
}
FlashSerializer.prototype.serialize = function(args){
    var qs = new String();

    for (var i = 0; i < args.length; ++i)
    {
        switch(typeof(args[i]))
        {
            case 'undefined':
                qs += 't'+(i)+'=undf';
                break;
            case 'string':
                qs += 't'+(i)+'=str&d'+(i)+'='+escape(args[i]);
                break;
            case 'number':
                qs += 't'+(i)+'=num&d'+(i)+'='+escape(args[i]);
                break;
            case 'boolean':
                qs += 't'+(i)+'=bool&d'+(i)+'='+escape(args[i]);
                break;
            case 'object':
                if (args[i] == null)
                {
                    qs += 't'+(i)+'=null';
                }
                else if (args[i] instanceof Date)
                {
                    qs += 't'+(i)+'=date&d'+(i)+'='+escape(args[i].getTime());
                }
                else // array or object
                {
                    try
                    {
                        qs += 't'+(i)+'=xser&d'+(i)+'='+escape(this._serializeXML(args[i]));
                    }
                    catch (exception)
                    {
                        throw new Exception("FlashSerializationException",
                                            "The following error occurred during complex object serialization: " + exception.getMessage());
                    }
                }
                break;
            default:
                throw new Exception("FlashSerializationException",
                                    "You can only serialize strings, numbers, booleans, dates, objects, arrays, nulls, and undefined.");
        }

        if (i != (args.length - 1))
        {
            qs += '&';
        }
    }

    return qs;
}
FlashSerializer.prototype._serializeXML = function(obj){
    var doc = new Object();
    doc.xml = '<fp>'; 
    this._serializeNode(obj, doc, null);
    doc.xml += '</fp>'; 
    return doc.xml;
}
FlashSerializer.prototype._serializeNode = function(obj, doc, name){
    switch(typeof(obj))
    {
        case 'undefined':
            doc.xml += '<undf'+this._addName(name)+'/>';
            break;
        case 'string':
            doc.xml += '<str'+this._addName(name)+'>'+this._escapeXml(obj)+'</str>';
            break;
        case 'number':
            doc.xml += '<num'+this._addName(name)+'>'+obj+'</num>';
            break;
        case 'boolean':
            doc.xml += '<bool'+this._addName(name)+' val="'+obj+'"/>';
            break;
        case 'object':
            if (obj == null)
            {
                doc.xml += '<null'+this._addName(name)+'/>';
            }
            else if (obj instanceof Date)
            {
                doc.xml += '<date'+this._addName(name)+'>'+obj.getTime()+'</date>';
            }
            else if (obj instanceof Array)
            {
                doc.xml += '<array'+this._addName(name)+'>';
                for (var i = 0; i < obj.length; ++i)
                {
                    this._serializeNode(obj[i], doc, null);
                }
                doc.xml += '</array>';
            }
            else
            {
                doc.xml += '<obj'+this._addName(name)+'>';
                for (var n in obj)
                {
                    if (typeof(obj[n]) == 'function')
                        continue;
                    this._serializeNode(obj[n], doc, n);
                }
                doc.xml += '</obj>';
            }
            break;
        default:
            throw new Exception("FlashSerializationException",
                                "You can only serialize strings, numbers, booleans, objects, dates, arrays, nulls and undefined");
            break;
    }
}
FlashSerializer.prototype._addName= function(name){
    if (name != null)
    {
        return ' name="'+name+'"';
    }
    return '';
}
FlashSerializer.prototype._escapeXml = function(str){
    if (this.useCdata)
        return '<![CDATA['+str+']]>';
    else
        return str.replace(/&/g,'&amp;').replace(/</g,'&lt;');
}
function FlashTag(src, width, height){
    this.src       = src;
    this.width     = width;
    this.height    = height;
    this.version   = '7,0,14,0';
    this.id        = null;
    this.bgcolor   = 'ffffff';
    this.flashVars = null;
}
FlashTag.prototype.setVersion = function(v){
    this.version = v;
}
FlashTag.prototype.setId = function(id){
    this.id = id;
}
FlashTag.prototype.setBgcolor = function(bgc){
    this.bgcolor = bgc;
}
FlashTag.prototype.setFlashvars = function(fv){
    this.flashVars = fv;
}
FlashTag.prototype.toString = function(){
    var ie = (navigator.appName.indexOf ("Microsoft") != -1) ? 1 : 0;
    var flashTag = new String();
    if (ie)
    {
        flashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
        if (this.id != null)
        {
            flashTag += 'id="'+this.id+'" ';
        }
        flashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this.version+'" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'">';
        flashTag += '<param name="movie" value="'+this.src+'"/>';
        flashTag += '<param name="quality" value="high"/>';
        flashTag += '<param name="bgcolor" value="#'+this.bgcolor+'"/>';
        if (this.flashVars != null)
        {
            flashTag += '<param name="flashvars" value="'+this.flashVars+'"/>';
        }
        flashTag += '</object>';
    }
    else
    {
        flashTag += '<embed src="'+this.src+'" ';
        flashTag += 'quality="high" '; 
        flashTag += 'bgcolor="#'+this.bgcolor+'" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'" ';
        flashTag += 'type="application/x-shockwave-flash" ';
        if (this.flashVars != null)
        {
            flashTag += 'flashvars="'+this.flashVars+'" ';
        }
        if (this.id != null)
        {
            flashTag += 'name="'+this.id+'" ';
        }
        flashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
        flashTag += '</embed>';
    }
    return flashTag;
}
FlashTag.prototype.write = function(doc){
    doc.write(this.toString());
}



// from AC_RunActiveContent.js provided by Wimpy
//
//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
//
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x){return(x<0||x>9?"":"0")+x}
function isDate(val,format){var date=getDateFromFormat(val,format);if(date==0){return false;}return true;}
function compareDates(date1,dateformat1,date2,dateformat2){var d1=getDateFromFormat(date1,dateformat1);var d2=getDateFromFormat(date2,dateformat2);if(d1==0 || d2==0){return -1;}else if(d1 > d2){return 1;}return 0;}
function formatDate(date,format){format=format+"";var result="";var i_format=0;var c="";var token="";var y=date.getYear()+"";var M=date.getMonth()+1;var d=date.getDate();var E=date.getDay();var H=date.getHours();var m=date.getMinutes();var s=date.getSeconds();var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;var value=new Object();if(y.length < 4){y=""+(y-0+1900);}value["y"]=""+y;value["yyyy"]=y;value["yy"]=y.substring(2,4);value["M"]=M;value["MM"]=LZ(M);value["MMM"]=MONTH_NAMES[M-1];value["NNN"]=MONTH_NAMES[M+11];value["d"]=d;value["dd"]=LZ(d);value["E"]=DAY_NAMES[E+7];value["EE"]=DAY_NAMES[E];value["H"]=H;value["HH"]=LZ(H);if(H==0){value["h"]=12;}else if(H>12){value["h"]=H-12;}else{value["h"]=H;}value["hh"]=LZ(value["h"]);if(H>11){value["K"]=H-12;}else{value["K"]=H;}value["k"]=H+1;value["KK"]=LZ(value["K"]);value["kk"]=LZ(value["k"]);if(H > 11){value["a"]="PM";}else{value["a"]="AM";}value["m"]=m;value["mm"]=LZ(m);value["s"]=s;value["ss"]=LZ(s);while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(value[token] != null){result=result + value[token];}else{result=result + token;}}return result;}
function _isInteger(val){var digits="1234567890";for(var i=0;i < val.length;i++){if(digits.indexOf(val.charAt(i))==-1){return false;}}return true;}
function _getInt(str,i,minlength,maxlength){for(var x=maxlength;x>=minlength;x--){var token=str.substring(i,i+x);if(token.length < minlength){return null;}if(_isInteger(token)){return token;}}return null;}
function getDateFromFormat(val,format){val=val+"";format=format+"";var i_val=0;var i_format=0;var c="";var token="";var token2="";var x,y;var now=new Date();var year=now.getYear();var month=now.getMonth()+1;var date=1;var hh=now.getHours();var mm=now.getMinutes();var ss=now.getSeconds();var ampm="";while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(token=="yyyy" || token=="yy" || token=="y"){if(token=="yyyy"){x=4;y=4;}if(token=="yy"){x=2;y=2;}if(token=="y"){x=2;y=4;}year=_getInt(val,i_val,x,y);if(year==null){return 0;}i_val += year.length;if(year.length==2){if(year > 70){year=1900+(year-0);}else{year=2000+(year-0);}}}else if(token=="MMM"||token=="NNN"){month=0;for(var i=0;i<MONTH_NAMES.length;i++){var month_name=MONTH_NAMES[i];if(val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()){if(token=="MMM"||(token=="NNN"&&i>11)){month=i+1;if(month>12){month -= 12;}i_val += month_name.length;break;}}}if((month < 1)||(month>12)){return 0;}}else if(token=="EE"||token=="E"){for(var i=0;i<DAY_NAMES.length;i++){var day_name=DAY_NAMES[i];if(val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()){i_val += day_name.length;break;}}}else if(token=="MM"||token=="M"){month=_getInt(val,i_val,token.length,2);if(month==null||(month<1)||(month>12)){return 0;}i_val+=month.length;}else if(token=="dd"||token=="d"){date=_getInt(val,i_val,token.length,2);if(date==null||(date<1)||(date>31)){return 0;}i_val+=date.length;}else if(token=="hh"||token=="h"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>12)){return 0;}i_val+=hh.length;}else if(token=="HH"||token=="H"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>23)){return 0;}i_val+=hh.length;}else if(token=="KK"||token=="K"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>11)){return 0;}i_val+=hh.length;}else if(token=="kk"||token=="k"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>24)){return 0;}i_val+=hh.length;hh--;}else if(token=="mm"||token=="m"){mm=_getInt(val,i_val,token.length,2);if(mm==null||(mm<0)||(mm>59)){return 0;}i_val+=mm.length;}else if(token=="ss"||token=="s"){ss=_getInt(val,i_val,token.length,2);if(ss==null||(ss<0)||(ss>59)){return 0;}i_val+=ss.length;}else if(token=="a"){if(val.substring(i_val,i_val+2).toLowerCase()=="am"){ampm="AM";}else if(val.substring(i_val,i_val+2).toLowerCase()=="pm"){ampm="PM";}else{return 0;}i_val+=2;}else{if(val.substring(i_val,i_val+token.length)!=token){return 0;}else{i_val+=token.length;}}}if(i_val != val.length){return 0;}if(month==2){if( ((year%4==0)&&(year%100 != 0) ) ||(year%400==0) ){if(date > 29){return 0;}}else{if(date > 28){return 0;}}}if((month==4)||(month==6)||(month==9)||(month==11)){if(date > 30){return 0;}}if(hh<12 && ampm=="PM"){hh=hh-0+12;}else if(hh>11 && ampm=="AM"){hh-=12;}var newdate=new Date(year,month-1,date,hh,mm,ss);return newdate.getTime();}
function parseDate(val){var preferEuro=(arguments.length==2)?arguments[1]:false;generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');var d=null;for(var i=0;i<checkList.length;i++){var l=window[checkList[i]];for(var j=0;j<l.length;j++){d=getDateFromFormat(val,l[j]);if(d!=0){return new Date(d);}}}return null;}

