function _set_search_form(t,tt){
  
  var b,f;
  
  try {
    f = document.createElement('<input type="text" value="" name="mwsearch" size="10" id="searchfield" autocomplete="off" />');
    b = document.createElement('<input type="submit" value="' + t + '" title="' + tt + '" id="searchbutton" />');
    
  } catch (e) {
    f = document.createElement("input");
    f.setAttribute("type", "text");
    f.setAttribute("name", "mwsearch");
    f.setAttribute("value", "");
    f.setAttribute("size", "10");
    f.setAttribute("id", "searchfield");
    f.setAttribute("autocomplete", "off");
    
    b = document.createElement("input");
    b.setAttribute("type", "submit");
    b.setAttribute("value", t);
    b.setAttribute("title", tt);
    b.setAttribute("id", "searchbutton");
   
  }
  
  var p = document.getElementById('search_form');
  
 if(p && f && b){ 
    p.appendChild(f);
    p.appendChild(b);
  }
}

function _set_custom_focus(){
 var f = document.getElementById('searchfield');
 
 if(f){
   f.focus();	
 }
}

function open_player(address)
{	
	window.open(address + 'player','mp3_web_player', 'toolbar=0,menubar=0,location=no,directories=no,scrollbars=no,resizable=no,status=no,width=314,height=400,top=0,left=0');
	return false;
}


function getswf(id,param,w,h,play,loop,bg)
{
 	if (AC_FL_RunContent == 0) {
		alert('Error - script not found');
	} else {
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
			'width', w ,
			'height', h ,
			'src', param,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', play ,
			'loop', loop ,
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', id ,
			'bgcolor', bg,
			'name', id ,
			'menu', 'false',
			'allowScriptAccess','sameDomain',
            'movie', param,
			'salign', ''
			); 
	}

}


/* AJAX */
function setdisplay(str){

	var mySplitResult = str.split(" ");

	for(i = 0; i < mySplitResult.length; i++){
		var row = document.getElementById(mySplitResult[i]);
		if (row.style.display == '') row.style.display = 'none';
		else row.style.display = '';
	}
}


function WEEBO_set_data(xobj){
/*
 var iname = document.getElementsByTagName('input');
 afield = '';
 
 for(i = 0; i<iname.length; i++){
   afield = iname[i].name==fname ? afiled + iname[i].value.';': afield;
 }
 return afield;
}
*/
if(!xobj || xobj.length<1){ obj = document; }else{ obj = document.getElementById(xobj); }

  var getstr = "?";
  for (i=0; i<obj.getElementsByTagName("input").length; i++) {
        if (obj.getElementsByTagName("input")[i].type == "hidden") {
           getstr += obj.getElementsByTagName("input")[i].name + "=" + 
                   obj.getElementsByTagName("input")[i].value + "&";
        }
		if (obj.getElementsByTagName("input")[i].type == "text") {
           getstr += obj.getElementsByTagName("input")[i].name + "=" + 
                   obj.getElementsByTagName("input")[i].value + "&";
        }
        if (obj.getElementsByTagName("input")[i].type == "checkbox") {
           if (obj.getElementsByTagName("input")[i].checked) {
              getstr += obj.getElementsByTagName("input")[i].name + "=" + 
                   obj.getElementsByTagName("input")[i].value + "&";
           } else {
              getstr += obj.getElementsByTagName("input")[i].name + "=&";
           }
        }
        if (obj.getElementsByTagName("input")[i].type == "radio") {
           if (obj.getElementsByTagName("input")[i].checked) {
              getstr += obj.getElementsByTagName("input")[i].name + "=" + 
                   obj.getElementsByTagName("input")[i].value + "&";
           }
     }  
     if (obj.getElementsByTagName("input")[i].tagName == "SELECT") {
        var sel = obj.getElementsByTagName("input")[i];
        getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
     }
     
  }
  return getstr;
}


/* WEEBO XMLHTTPREQUEST object v 1.2 */         
function xmlhttp(addr, obj, cl_obj, cl_obj_type, formid)
{
/*
@addr - php request address
@obj - dom object id
@cl_obj - value dom object id (search field)
@cl_obj_type - behavior type inner or value, hide cl_obj when not set
*/

    var xhttpRequest;
    try {  
         xhttpRequest = new XMLHttpRequest(); /* Firefox, Opera, Konq... */
        } 
        catch(e){ 
        try 
           { 
            xhttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); /* IE MS XML 2 */
           } 
            catch (e) {
            try { 
                  xhttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); /* IE MS XML */
                } 
                  catch (E) { xhttpRequest = false; 
                }
           } 
        }
    // customize str
	var cachebeat=parseInt(Math.random()*999999);
	var my_request = WEEBO_set_data(formid) + '&weebo_no_chache_param=' + cachebeat;

    xhttpRequest.open("POST", addr, true);
	xhttpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xhttpRequest.setRequestHeader("Content-length", my_request.length);
	xhttpRequest.setRequestHeader("Connection", "close");
    xhttpRequest.onreadystatechange= function (){
        processRequest(xhttpRequest, addr, obj, cl_obj, cl_obj_type) 
    };
    xhttpRequest.send(my_request);
}

function processRequest(xhttpRequest, addr, obj, cl_obj, cl_obj_type) 
{
    if(cl_obj_type=='value'){ vl =  document.getElementById(cl_obj).value.length; }
    if (xhttpRequest.readyState == 4){
        if(( xhttpRequest.status >= 200 && xhttpRequest.status < 300 ) || xhttpRequest.status == 304){
            if (typeof obj == 'string'){
                if(cl_obj_type=='value' && vl<1){ document.getElementById(obj).style.display = 'block'; }
                if(obj.length>0){ document.getElementById(obj).innerHTML = xhttpRequest.responseText; }
            }
        }else{
            alert("Chyba adresy " + xhttpRequest.status +" : "+ xhttpRequest.statusText);
        }
		
    }else{
        
		if (typeof addr == 'string' && obj != ''){
             if(obj.length>0){ document.getElementById(obj).innerHTML = '<span class="list_preloader"></span>'; }
        }
    }
	
    if(cl_obj_type=='value' && vl<1 && obj.length>0){ document.getElementById(obj).style.display = 'none'; }
       
}          

function mw_showhide(sid){
	var obj = document.getElementById(sid);
	if(obj){ obj.style.display = obj.style.display == 'block' ? 'none': 'block'; }
}
function mw_changetxt(aid,bid,newtxt,oldtxt){
	var obj = document.getElementById(aid);
	var obj2 = document.getElementById(bid);
	if(obj && obj2){ 
		if( obj2.style.display == 'block') {
			obj2.style.display = 'none';
			obj.innerHTML=newtxt;
			setCookie(bid,'1','1');
		}else{
			obj2.style.display = 'block';
			obj.innerHTML=oldtxt;
			setCookie(bid,'0','1');
		}
	}
	
}

function mw_tzshow(boxa,boxb,from,to){
	var show=getCookie(boxb);
	if(show==1){
		mw_changetxt(boxa,boxb,from,to);
	}
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

  function votenow(o){
   var obj = document.getElementById(o);
   obj.submit();
  }
