function soundObject()
{
	this.playOnOpen = true;
	this.enabled = false;
	this.hidden = true;
	//Тип плеера: ActiveX или Flash
	this.type = 'ActiveX';

	this.fileExtension = 'mp3';
	this.filePath = 'sound/';
	this.url = '';
	this.holderId = 'sound_holder';
	this.playerId = 'sound_player';
	this.playlist = new Array;
	this.state = 'stop';

	this.open = function open(url)
	{		stat.sound.open++;
		url = this.filePath + url + '.' + this.fileExtension;
		this.playlist.push(url);
		//Если используется Flash-плеер
		if(this.type == 'Flash')
		{			if(window[this.playerId+'1']){
				window.document[this.playerId+'1'].SetVariable("sound_name", ('../'+url));
				window.document[this.playerId+'1'].SetVariable("state_value", "open");
			}
			else if(document[this.playerId+'2']){
				document.getElementById(this.playerId+'2').SetVariable("sound_name", ('../'+url));
				document.getElementById(this.playerId+'2').SetVariable("state_value", "open");
			}
			if (this.playOnOpen) this.play();
		}
		else
		{			document.getElementById(this.holderId).innerHTML = this.codeActiveX(this.playlist[url]);
			if (this.playOnOpen) this.play();		};
	};

	this.play = function play()
	{		stat.sound.play++;
		if (this.enabled)
		{
			//Если используется Flash-плеер
			if(this.type == 'Flash')
			{
				if(window[this.playerId+'1'])
				{
					window.document[this.playerId+'1'].SetVariable("state_value", "play");
					this.state = 'play';
					//$('ib_sound').src = 'img/ctrls/sound_off_btn.gif';
				}
				else if(document[this.playerId+'2'])
				{
					document.getElementById(this.playerId+'2').SetVariable("state_value", "play");
					this.state = 'play';
					//$('ib_sound').src = 'img/ctrls/sound_off_btn.gif';
				};
			}
			else
			{				document.getElementById(this.holderId).innerHTML = this.codeActiveX(this.playlist[this.playlist.length-1]);
				this.state = 'play';
				//$('ib_sound').src = 'img/ctrls/sound_off_btn.gif';
			};
		};
	};

	this.stop = function stop()
	{
		stat.sound.stop++;
		//Если используется Flash-плеер
		if(this.type == 'Flash')
		{
			if(window[this.playerId+'1'])
			{
				window.document[this.playerId+'1'].SetVariable("state_value", "stop");
				this.state = 'stop';
				//$('ib_sound').src = 'img/ctrls/sound_on_btn.gif';
			}
			else if(document[this.playerId+'2'])
			{
				document.getElementById(this.playerId+'2').SetVariable("state_value", "stop");
				this.state = 'stop';
				//$('ib_sound').src = 'img/ctrls/sound_on_btn.gif';
			};
		}
        else
        {			stat.sound.stop++;
			if (document.getElementById(this.holderId)) document.getElementById(this.holderId).innerHTML = '';
				this.state = 'stop';
			//$('ib_sound').src = 'img/ctrls/sound_on_btn.gif';
        };
	};

	this.pause = function pause()
	{
		stat.sound.pause++;
		//Если используется Flash-плеер
		if(this.type == 'Flash')
		{
			if(window[this.playerId+'1'])
			{
				window.document[this.playerId+'1'].SetVariable("state_value", "pause");
				this.state = 'pause';
				//$('ib_sound').src = 'img/ctrls/sound_on_btn.gif';
			}
			else if(document[this.playerId+'2'])
			{
				document.getElementById(this.playerId+'2').SetVariable("state_value", "pause");
				this.state = 'pause';
				//$('ib_sound').src = 'img/ctrls/sound_on_btn.gif';
			};
		}
		else
		{			if (document.getElementById(this.playerId))
			{
				if (typeof(document.getElementById(this.playerId).Pause) != 'undefined')
				{
					document.getElementById(this.playerId).Pause();
					this.state = 'pause';
					//$('ib_sound').src = 'img/ctrls/sound_on_btn.gif';
				}
				else
				{
					document.getElementById(this.playerId).Stop();
					this.state = 'pause';
					//$('ib_sound').src = 'img/ctrls/sound_on_btn.gif';
				};
			};		};
	};

	this.unpause = function unpause()
	{
		stat.sound.unpause++;
		//Если используется Flash-плеер
		if(this.type == 'Flash')
		{
			if(window[this.playerId+'1'])
			{
				window.document[this.playerId+'1'].SetVariable("state_value", "unpause");
				this.state = 'play';
				//$('ib_sound').src = 'img/ctrls/sound_off_btn.gif';
			}
			else if(document[this.playerId+'2'])
			{
				document.getElementById(this.playerId+'2').SetVariable("state_value", "unpause");
				this.state = 'play';
				//$('ib_sound').src = 'img/ctrls/sound_off_btn.gif';
			};
		}
		else
		{			if (document.getElementById(this.playerId))
			{
				document.getElementById(this.playerId).Play()
				this.state = 'play';
				//$('ib_sound').src = 'img/ctrls/sound_off_btn.gif';
			};
		};
	};

	this.toggle = function toggle()
	{
		stat.sound.toggle++;
		if (this.state == 'play')
			this.pause();
		else if (this.state == 'pause')
			this.unpause();
		else if (this.state == 'stop')
			this.play();
	};

	this.init = function init()
	{
		stat.sound.init++;
		var d = document.createElement('div');
		var cssString = ((this.hidden)?'width: 0px; height: 0px; overflow: hidden; position: absolute; left: 0px; top: 0px;':'');
		d.style.cssText = cssString;
		d.setAttribute('style',cssString);
		d.id = this.holderId;
		d.setAttribute('id',this.holderId);
		//Если используется Flash-плеер
		if(this.type == 'Flash')
		{
			d.innerHTML = this.codeFlash('');
		}
		document.body.appendChild(d);
	};

	this.codeFlash = function codeFlash(id)
	{
		stat.sound.code++;
		return '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="" id="'+this.playerId+'1" '+((this.hidden)?'height="0" width="0"':'')+'><param name="movie" value="system/sound.swf" /><embed src="system/sound.swf" quality="high" '+((this.hidden)?'height="0" width="0"':'')+' name="'+this.playerId+'" id="'+this.playerId+'2" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" /></object>'
	};

	this.codeActiveX = function codeActiveX(id)
	{
		stat.sound.code++;
		return '<embed src="'+id+'" '+((this.hidden)?'height="0" width="0"':'')+' autoplay="true" id="'+this.playerId+'"></embed>';
	};

	this.setType = function setType()
	{
	    if(this.type == 'Flash')
	    {	    	this.type = 'ActiveX';
	    	document.getElementById(this.holderId).innerHTML = '';	    }
    	else
    	{
	    	this.type = 'Flash';
			document.getElementById(this.holderId).innerHTML = this.codeFlash('');
		};
    };
}
stat.sound = {open:0, play:0, stop:0, pause:0, unpause:0, toggle:0, init:0, code:0};
var sound = new soundObject();


