SoundObj = function() {

   this.playerUrl = "http://domiwitt.inspirationlabs.com/mp3player.swf";

   this.sendCommand = function(cmd,args) {
      if(!args) args = new Array();
      var flash = this.getFlashObj();
      for(var i = 0;i<args.length;i++) {
         flash.SetVariable("arg"+(i+1),args[i]);
      }
      flash.SetVariable("cmd",cmd);
   }

   this.play = function(url) {
      this.soundUrl = (url)?url:this.soundUrl;
      this.sendCommand("playMusic",new Array(this.soundUrl));
      this.isOn = true;
   }

   this.stop = function() {
      if(this.isOn) {
         this.sendCommand("stopMusic");
         this.isOn = false;
      }
   }

   this.toggle = function(url) {
      if(this.isOn) {
         if(!url || url == this.soundUrl) this.stop();
         else this.play(url);
      } else this.play(url);
   }

   this.callback = function(command,args) {
      if(command == "return") {
         //alert(args);
      } else if(command == "event") {
         //alert(args);
      } else {

      }
   }

   this.getFlashObj = function() {
      if(!this.flash) {
         evalCode = "this.flash = document."+this.id+";\n";
         eval(evalCode);
      }
      return this.flash;
   }

   this.constructor = function(args) { //soundUrl[,playerUrl]
      //determine object properties
         if(args[0]) this.soundUrl = args[0];
         if(args[1]) this.playerUrl = args[1];
         this.id = "soundObj"+Math.round(Math.random()*1000000000);
         this.ie = (navigator.appName.indexOf("Microsoft") != -1);
      //build up client side coding
         var srcCode = "";
         var evalCode = "";
         if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
           srcCode  += '<SCRIPT LANGUAGE=VBScript\>\n';
           srcCode  += 'on error resume next \n';
           srcCode  += 'Sub '+this.id+'_FSCommand(ByVal command, ByVal args)\n';
           srcCode  += ' call '+this.id+'_DoFSCommand(command, args)\n';
           srcCode  += 'end sub\n';
           srcCode  += '</SCRIPT\> \n';
         } else {
           evalCode += "window."+this.id+"_FSCommand = this.callback;";
         }
         evalCode += "window."+this.id+"_DoFSCommand = this.callback;";
         srcCode  += '<div>\n<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" id="'+this.id+'" height="0" width="0">\n';
         srcCode  += '<param name="movie" value="'+this.playerUrl+'?referrer='+location.href+'" />\n';
         srcCode  += '<param name="AllowScriptAccess" value="always" />\n';
         srcCode  += '<embed height="0" width="0" src="'+this.playerUrl+'?referrer='+location.href+'" quality="high" AllowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" name="'+this.id+'" swLiveConnect="true"></embed>\n';
         srcCode  += '</object>\n</div>\n';
         evalCode += "this.flash = document."+this.id+";";
      //print client side coding
         document.writeln(srcCode);
      //attach objects
         eval(evalCode);
   };this.constructor(arguments);
}

function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
   d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

self.hideDiv = function(id) {
   if(document.getElementById) {
     var obj = document.getElementById(id);
     if(obj != null) {
        if(obj.style != null) {
          if(obj.style.visibility != null) obj.style.visibility='hidden';
        }
     }
   }
}

self.mailTo = function(url,title) {
   location.href = "mailto:?subject=Have%20a%20look%20at%20"+title+"&body="+title+": "+url;
}

self.addToFavorite = function(url,title) {
    if ((navigator.appName == "Microsoft Internet Explorer") &&
          (parseInt(navigator.appVersion) >= 4))
    {
        window.external.AddFavorite(url,title)
    }
    else
    {
        var FavText;
        if(navigator.appName == "Netscape")
        {
           FavText = "Please use STRG+D to add '"+title+"' to your favorites";
        } else {
           FavText = "Please add '"+title+"' manually to your favorites";
        }
        alert(FavText);
    }
}

self.addEntry = function() {
   var a = document.getElementsByTagName("link");
   if(a) {
      var blogId = a[a.length-3].href.split("blogID=")[1];
      location.href = "http://www.blogger.com/app/blog.pyra?blogID="+blogId;
   }
}

self.showPicture = function(img) {
   var win = window.open('http://domiwitt.inspirationlabs.com/showImage.php?image='+img,'ShowImage','dependent=yes,resizable=yes,menubar=no,location=no,scrollbars=no,status=no,toolbar=no,height=50,width=200');
   win.focus();
}

self.showPictureUrl = function(url) {
   var win = window.open('http://domiwitt.inspirationlabs.com/showImage.php?url='+url,'ShowImage','dependent=yes,resizable=yes,menubar=no,location=no,scrollbars=no,status=no,toolbar=no,height=50,width=200');
   win.focus();
}

self.downloadMusic = function(url) {
   location.href = url;
}

self.startCorrectScrolling = function() {
   var pres = document.getElementsByTagName("pre");
   if(pres) {
      for(var i = 0;i<pres.length;i++) {
         if(!pres[i].scrollingCorrected) {
            pres[i].scrollingCorrected = true;
            if(pres[i].offsetHeight) {
               var height = pres[i].offsetHeight;
               pres[i].style.height = height + 7;
            }
         }
      }
   }
}

self.stopCorrectScrolling = function() {
   clearInterval(this.scroll);
   self.startCorrectScrolling();
}

this.scroll = setInterval("self.startCorrectScrolling();",100);
onload = self.stopCorrectScrolling;