TSoundObj = function()
{ 
	var param =
	{
		AJAXsrc		: '/strona_v2/ajax/load_sound/'
	};
	 
	for (var i in arguments[0]) if (typeof(arguments[0][i]!= 'function')) param[i]=arguments[0][i];
	this.obj		= _c('div',param);

	this.obj.tablica = [];
	
	this.obj.rysuj = function(dane)
	{
		this.player = _c('audio',{parent:this,autoplay:'autoplay'});
		this.source1 = _c('source',{parent:this,type:'audio/ogg'});
		this.source2 = _c('source',{parent:this,type:'audio/mp3'});
		
//		this.player.apC(this.source1);
//		this.player.apC(this.source2);
		this.apC(this.player);

		if (dane != undefined){	this.update( dane ); }
	}
	
		
	this.obj.load = function( dane )
	{
		this.update( dane );
	}
	this.obj.update	= function( dane )
	{
		if(dane != undefined) {
			this.tablica = dane;
		}
	}
	
	this.obj.send = function(value)
	{
		setByAjax( '/strona_v2/ajax/set/', this.id,
				{'motyw' : encodeURI(value), 'id':this.id} );
	}
	
	this.obj.as_array = function()
	{
		return this.tablica;
	}
	this.obj.test = function()
	{
		return this.tablica;
	}	
//	this.obj.onGetByAjaxEnd = function(){
//		//alert('test aaa');
//	}
	this.obj.play = function( def )
	{
		//return false;
		
		var mp3 = this.tablica[def];
		mp3 = 'http://cache1.anonse.com/' + mp3;
	
		try {	console.log(mp3) }	catch(e){};

		if( mp3 == undefined ) return false;
		var test = /\.\./g;
		mp3 = mp3.replace(test,"");
		
		var testogg = /mp3/g;
		var ogg = mp3.replace(testogg,"ogg");
		try 
		{
			//-- HTML 5;
			if (typeof(this.player)!=undefined)
			if (typeof(this.player.play)=='function')
			{
				this.source1.src = ogg;
				this.source2.src = mp3;
				//this.player.src = mp3;
				//this.player.src = ogg;
				//console.log( ogg );
				
				
				this.player.apC(this.source1);
				this.player.apC(this.source2);
				
				this.player.play() ;
				return true;
			}
		
			//-- FLASH
			var snd = _get('small');
			if (typeof(snd)!=undefined)
			//if (typeof(snd.SetVariable)=='function')						
			{ 
				//var czas=123;
				snd.SetVariable("filename",mp3);
				snd.SetVariable("timeon",czas);//ustawienie lini czasy
					
				try{console.log(timeon)} catch(e) {}
				
				snd.grajAS();
				return true;
			}
		}
		catch(e){ }
		return false;
	}

	this.obj.rysuj();
	return this.obj;
}


TSoundCookie = function()
{
	this.obj	= new TSoundObj;
	this.obj.rysuj = function( dane )
	{
		this.player = _c('audio',{parent:this,autoplay:'autoplay',loop:'loops',volume:0.3});
	
		this.apC(this.player);
		if (dane != undefined){	this.update( dane ); }
	}
	
	this.obj.play = function(def)
	{
		//return false;
		//alert(def);
		var mp3 = this.tablica[def];
		mp3 = 'http://cache1.anonse.com/' + mp3;
	
		//try {	console.log(mp3) }	catch(e){};
		
		
		if (mp3 == undefined) 
			return false;
		var test = /\.\./g;
		mp3 = mp3.replace(test, "");
		
		var testogg = /mp3/g;
		var ogg = mp3.replace(testogg, "ogg");
		try {
			// -- HTML 5
			if (typeof(this.player) != undefined) 
				if (typeof(this.player.play) == 'function') {
//					try {
//						console.log('HTML 5 ' + this.player);
//						console.log(this.player.volume);
//					}
//					catch(e){}
					//alert('HTML 5 ' + this.player);
					//console.log( ogg );
					//console.log( mp3 );
					this.player.apC(this.source1);
					this.player.apC(this.source2);
					this.player.src = mp3;
					//this.player.play('32');
					this.player.play();
					return true;
				}
			
			//-- FLASH
			var snd = _get('small2');
			if (typeof(snd) != undefined)  //if (typeof(snd.SetVariable)=='function')						
			{
				//console.log('FLASH ' + snd);
				//alert('FLASH ' + snd);
				var czas = 123;
				snd.SetVariable("filename", mp3);
				//snd.SetVariable("file_name", mp3);
				snd.SetVariable("timeon", czas);//ustawienie lini czasu
				try {
					console.log(timeon)
				} 
				catch (e) {
				}
				
				snd.grajAS();
				return true;
			}
		} 
		catch (e) {
		}
	}
	this.obj.getSeek = function()
	{
		this.seek = this.player.currentTime;
		console.log(this.player.currentTime);
		return this.seek;
	}
		
	this.obj.setSeek = function()
	{
		this.player.currentTime = 6;
	}
	this.obj.setCookie = function()
	{
		var dt = new Date(2030, 12, 31);
		expire = dt.toGMTString();
		//console.log(expire);
       	document.cookie = mp_position + "=" + escape(this.getSeek()) + ((expire==null)?"" : ("; expires=" + expire.toGMTString()))
	}
	this.obj.getCookie = function()
	{
		toCookie = document.cookie.split("; ");
		console.log(toCookie);
	}
	
	this.obj.rysuj();
	return this.obj;	
}

	
function setmute()
{
	alert('mute');
	var mute = false;
	if(mute == false)
	{	
		mute = true
		_get('small').SetVariable("mute",true);
		_get('small').muteAS();
	}

}








