function boxxx(){
	var self=this;
	var category;
	var radio_id;
	var framewrk;
	this.openplayer=function(id){
		window.open('http://www.abradio.cz/player.php?kod='+id,'ABradio','width=650,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhiostory=no');
	}
	this.id_search=function(arr,ids){
		this.framewrk=framewrk;
		for(var i=0;i<=arr.length-1;i++){
			if(this.framewrk.key_search(ids,arr[i].id)){
				return true;
			}
		}
		return false;
	}
	this.selectbox=function(arr,firstoption){
		this.select=document.createElement('select');
		this.option=document.createElement('option');
		this.option.appendChild(document.createTextNode(firstoption));
		this.option.value="";
		this.select.appendChild(this.option);
		if(arr){
			for(var i=0;i<=arr.length-1;i++){
				this.option=document.createElement('option');
				this.option.appendChild(document.createTextNode(arr[i].jmeno));
				this.option.value=arr[i].id;this.select.appendChild(this.option);
			}
		}
		return this.select;
	}
	this.createRadiaCategory=function(){
		this.radioall=framewrk.jsonDecode(this.radiobox);
		this.selectedCategory=new Array();
		this.ids=this.radia.split(',');
		var r=0;
		for(var i=0;i<=this.radioall.length-1;i++){
			if(this.id_search(this.radioall[i].radia,this.ids)){
				this.selectedCategory[r++]=this.radioall[i];
			}
		}
		this.category=this.selectbox(this.selectedCategory,'Vyberte kategorii');
		return this.category;
	}
	this.createRadia=function(){
		if(category){
			this.radioall=framewrk.jsonDecode(this.radiobox);
			this.selectedRadia=new Array();
			this.ids=this.radia.split(',');
			var a=0;for(var i=0;i<=this.radioall.length-1;i++){
				if(category==this.radioall[i].id){
					this.radio=this.radioall[i].radia;
					for(var r=0;r<=this.radio.length-1;r++){
						if(this.framewrk.key_search(this.ids,this.radio[r].id)){
							this.selectedRadia[a++]=this.radio[r];
						}
					}
				}
			}
			return self.selectbox(this.selectedRadia,'vyberte radio');
		}
		return false;
	}
	this.init=function(){
		framewrk=new radioboxgenerator();
		if(!this.config.theme)this.config.theme=1;
		if(!this.radia)return false;
		if(!this.config.sirka)this.config.sirka=187;
		if(this.config.sirka<187)this.config.sirka=187;
		this.theme=new Array();
		this.theme[1]=new Array('bila','#FDFFFF');
		this.theme[2]=new Array('black','#050708');
		this.theme[3]=new Array('cernobila','#CCCCCC');
		this.theme[4]=new Array('cervena','#FEFEFE');
		this.theme[5]=new Array('modra','#FEFFFF');
		this.theme[6]=new Array('zelena','#BFDABE');
		this.theme[7]=new Array('radiotv','#F3F1F2');
		this.root=document.getElementById('radioboxroot');
		this.root.innerHTML="";
		this.div=document.createElement('div');
		this.div.style.width=this.config.sirka+'px';
		this.div.style.height='80px';
		this.div.style.padding='34px 0 0 0';
		this.div.style.backgroundColor=this.theme[this.config.theme][1];
		this.div.style.backgroundImage='url(http://radiobox.abradio.cz/external/images/abradio-box-'+this.theme[this.config.theme][0]+'.png)';
		this.div.style.backgroundPosition='top left';
		this.div.style.backgroundRepeat='no-repeat';
		this.root.appendChild(this.div);
		this.obl=document.createElement('div');
		this.obl.style.width='190px';
		this.obl.style.margin='0 auto';
		this.obl.style.id='center';
		this.div.appendChild(this.obl);
		this.flo=document.createElement('div');
		this.flo.style.cssFloat='left';
		this.flo.style.styleFloat='left';
		this.flo.style.margin='0 5px 0 0';
		this.obl.appendChild(this.flo);
		this.scc=document.createElement('div');
		this.scc.id='selectCategory';
		this.flo.appendChild(this.scc);
		this.scr=document.createElement('div');
		this.scr.style.width='130px';
		this.scr.id='selectRadio';
		this.flo.appendChild(this.scr);
		this.cat=this.createRadiaCategory();
		this.cat.style.width='130px';
		this.cat.style.margin='20px 0 0 5px';
		this.cat.onchange=function(){
			category=this[this.selectedIndex].value;self.scr.innerHTML="";
			this.rdo=self.createRadia();
			this.rdo.style.width='130px';
			this.rdo.style.margin='5px 0 0 5px';
			this.rdo.onchange=function(){
				radio_id=this[this.selectedIndex].value;
			}
			self.scr.appendChild(this.rdo);}
			this.scc.appendChild(this.cat);
			this.url=document.createElement('a');
			this.url.href='#';
			this.url.onclick=function(){
				if(!radio_id){
					alert("prosim zadejte pozadovane radio.");
					return false;
				}
				self.openplayer(radio_id);return false;
			}
			this.div.appendChild(this.url);
			this.img=document.createElement('img');
			this.img.src='http://radiobox.abradio.cz/external/images/abradio-play-'+this.theme[this.config.theme][0]+'.png';
			this.img.style.cssFloat='left';
			this.img.style.styleFloat='left';
			this.img.style.margin='20px 5px 0 0';
			this.img.style.border='0px';
			this.url.appendChild(this.img);
		}
	}
	document.write('<script type="text/javascript" src="http://radiobox.abradio.cz/external/radiobox.php?noCacheIE='+(new Date()).getTime()+'"></scr'+'ipt>');
	document.write('<script type="text/javascript" src="http://radiobox.abradio.cz/radioboxgenerator.js?noCacheIE='+(new Date()).getTime()+'"></scr'+'ipt>');
	document.write('<div id="radioboxroot" style="text-align:center;"><img src="http://radiobox.abradio.cz/images/icon_loading.gif" alt="loading" /><h4 stlye="margin:0px;">nahravam</h4></div>');
	window.onload=function(){
		var boxx=new boxxx();
		boxx.config=config;
		boxx.radia=radia+',';
		boxx.radiobox=radiobox;boxx.init();
	}
