var xmlHttp
var selname
var currentdepth=0

//spec parameterekhez frissiti a szukitesi opciokat
/*function select_specs(param)
{ 
	var opts = {
	   method: 'post',
       postBody: "spec_param="+param,
       onSuccess: function(t) {
			
//                    document.getElementById("specsgenerated").innerHTML=t.responseText 
//   					new Insertion.Bottom('specsgenerated', t.responseText);//prototype.js
   					document.getElementById('specsgenerated').innerHTML=t.responseText ;
   					
                },
                on404: function(t) {
                        alert('Error 404: location "' + t.statusText + '" was not found.');
                },
                onFailure: function(t) {
                        alert('Error ' + t.status + ' -- ' + t.statusText);
				}
	}
	var url="../action/index/search_specs_generator.php";
	new Ajax.Request(url, opts);
}
*/

function select_category(selector_name,selector_value,webshop_id)
{ 
	if (!getObjfromIdorObj('subsgenerated'))return false;
	selname=selector_name
	var changedDepth=parseInt(String(selector_name).replace("subs",""));

    if(selector_name=="root_category"){
        currentdepth=0;
    }
    else {
        if(changedDepth<currentdepth){
                        
            currentdepth=changedDepth+1;
        }
        else currentdepth++;
    }
	
	var opts = {
	   method: 'post',
                // Send this lovely data
       postBody: "selector_value="+selector_value+"&depth="+currentdepth+"&webshop_id="+webshop_id,
                // Handle successful response
       onSuccess: function(t) {
             document.getElementById("last_category").value="subs"+currentdepth;
             if(selname=="root_category"){
		           	document.getElementById('subsgenerated').innerHTML="";					//t.responseText;	             	
   					new Insertion.Bottom('subsgenerated', t.responseText);//prototype.js
					document.getElementById("before_last_category").value="rcat";
//					alert(t.responseText);
					//deteleChildNodes('root_category');//teljes id kell csak neki, és automatán megtalálja mik vannak utána.....
              }               
              else {
					deteleChildNodes(selector_name);//teljes id kell csak neki, és automatán megtalálja mik vannak utána.....
   					if(currentdepth < parseInt(document.getElementById("search_max_depth").value))
   					{
	   					new Insertion.Bottom('subsgenerated', t.responseText);//prototype.js
		            }
					document.getElementById("before_last_category").value="subs"+(currentdepth-1);		            
//                    alert(t.responseText);
              }
                },
                // Handle 404
                on404: function(t) {
                        alert('Error 404: location "' + t.statusText + '" was not found.');
                },
                // Handle other errors
                onFailure: function(t) {
                        alert('Error ' + t.status + ' -- ' + t.statusText);
	
				}
	}
	//"../action/index/search_category_generator.php"
	new Ajax.Request(getAjaxIndexDir()+"search_category_generator.php", opts);
//    new Ajax.Updater('subsgenerated', url, opts);

}


