function setCatalog(_action,value,type) {
    // Create new JsHttpRequest object.
    var req = new JsHttpRequest();
    // Code automatically called on load finishing.
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
        	
            // Write result to pae element ($_RESULT become responseJS). 
            if(req.responseJS.setcatalog == 'ok') {
            	//
            	if(_action=='setOutOnPage') window.location.reload();
            	if(_action=='setSortBy') window.location.reload();
            }
            // Write debug information too (output become responseText).
            if(req.responseText){
	           alert(req.responseText);
	           //document.getElementById('addmess').innerHTML = req.responseText;
            }    
        }
    }    
    if((_action=='setOutOnPage') || (_action=='setSortBy')) document.getElementById('setoptpreloader').style.visibility = 'visible';
    // Prepare request object (automatically choose GET or POST).
    req.open(null, '/shop/action/catalog_loader.php', true);
    // Send whole form data to backend.
    if(type == 'item') req.send( { '_action': _action, 'item': value} );
    if(type == 'form') req.send( { 'form': value } );
}
