

function ajaxFunction(id,cnt_type)
{
var url="";
var xmlHttp;

url=url+"zkiajax.php?zki=faj&pcat="+id;
content_id='faj_id';

if (cnt_type=="fajta")
{
	url="zkiajax.php?zki=fajta&pscat="+id+"&pcat="+document.getElementById('termkat_id').value;
	content_id='fajta_id';
}

xmlHttp=getXMLObject();
xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {

	if (cnt_type=="faj")
	{
		
		var inner = '<option value="0">-- - --</option>'; 
		select_innerHTML(document.getElementById("fajta_id"),inner);
		
	}
	
	var inner = xmlHttp.responseText; 
	select_innerHTML(document.getElementById(content_id),inner);

      }
    }
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}

function getXMLObject()
{

try
  {
  // Firefox, Opera 8.0+, Safari
  return xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    return xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      return xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      return false;
      }
    }
  }

}

function select_innerHTML(objeto,innerHTML){
/******
* select_innerHTML - corrige o bug do InnerHTML em selects no IE
* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
* Versao: 2.1 - 04/09/2007
* Autor: Micox - Náiron José C. Guimaraes - micoxjcg@yahoo.com.br
* @objeto(tipo HTMLobject): o select a ser alterado
* @innerHTML(tipo string): o novo valor do innerHTML
*******/
    objeto.innerHTML = ""
    var selTemp = document.createElement("micoxselect")
    var opt;
    selTemp.id="micoxselect1"
    document.body.appendChild(selTemp)
    selTemp = document.getElementById("micoxselect1")
    selTemp.style.display="none"
    if(innerHTML.toLowerCase().indexOf("<option")<0){//se nao é option eu converto
        innerHTML = "<option>" + innerHTML + "</option>"
    }
    innerHTML = innerHTML.toLowerCase().replace(/<option/g,"<span").replace(/<\/option/g,"</span")
    selTemp.innerHTML = innerHTML
      
    
    for(var i=0;i<selTemp.childNodes.length;i++){
  var spantemp = selTemp.childNodes[i];
  
        if(spantemp.tagName){     
            opt = document.createElement("OPTION")
    
   if(document.all){ //IE
    objeto.add(opt)
   }else{
    objeto.appendChild(opt)
   }       
    
   //getting attributes
   for(var j=0; j<spantemp.attributes.length ; j++){
    var attrName = spantemp.attributes[j].nodeName;
    var attrVal = spantemp.attributes[j].nodeValue;
    if(attrVal){
     try{
      opt.setAttribute(attrName,attrVal);
      opt.setAttributeNode(spantemp.attributes[j].cloneNode(true));
     }catch(e){}
    }
   }
   //getting styles
   if(spantemp.style){
    for(var y in spantemp.style){
     try{opt.style[y] = spantemp.style[y];}catch(e){}
    }
   }
   //value and text
   opt.value = spantemp.getAttribute("value")
   opt.text = spantemp.innerHTML
   //IE
   opt.selected = spantemp.getAttribute('selected');
   opt.className = spantemp.className;
  } 
 }    
 document.body.removeChild(selTemp)
 selTemp = null
}

