
function get_phonelist(type_get){
	var brand_id = document.forms['filform'].elements['ubrand'].value;
	var region = document.getElementById('phone');
	while(region.length > 0) {
		region.remove(region.length - 1);
	}
	var e=document.createElement('option');
	e.text='ждите, получаем модели';
	e.value='0';
	try { 
		region.add(e,null);
	} catch(ex) { 
		region.add(e);
	}
	var req = new JsHttpRequest();
    // Code automatically called on load finishing.
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
						while(region.length > 0) {
				region.remove(region.length - 1);
			}
			var e=document.createElement('option');
			e.text="Выберите модель";
			e.value=0;
			e.label="Выберите модель";
				try { 
					region.add(e,null);
				} catch(ex) { 
					region.add(e);
				}
			for(i=0;i<req.responseJS.cnt;i++){
				var e=document.createElement('option');
				e.text=req.responseJS.opname[i];
				e.value=req.responseJS.opid[i];
				e.label=req.responseJS.opname[i];
				try { 
					region.add(e,null);
				} catch(ex) { 
					region.add(e);
				}

			}
        }
    }
    // Prepare request object (automatically choose GET or POST).
    req.open(null, "/sitelama/modules/getphonesaj.php?id="+brand_id+"&ph="+type_get, true);
    // Send data to backend.
    req.send( { q: 1 } );
}
function redir2contentlist(){
var brand_id = document.forms['filform'].elements['ubrand'].options[document.forms['filform'].elements['ubrand'].selectedIndex].value; 
var brand_name = document.forms['filform'].elements['ubrand'].options[document.forms['filform'].elements['ubrand'].selectedIndex].label; 
var model = document.forms['filform'].elements['phone'].options[document.forms['filform'].elements['phone'].selectedIndex].label; 
var phone_id = document.forms['filform'].elements['phone'].value;
	 //document.location.href = httpPBase+'/all'+cont_m_type+'s/'+ 
	//document.location.href = httpPBase+'/all'+cont_m_type+'s/'+
	// brand_id + '-' +
	// phone_id + '/'+brand_name + '-' + model + '/';
	//themes/0-0-1-1/
	document.location.href = httpPBase+'/'+cont_m_type+'s/'+brand_name + '-' + model + '/';

}
function telSubmitAlt(page, fromOnChange){
	if (document.getElementById('navPhone')){
		var search=trim(escape(document.getElementById('navSearch').value)).toLowerCase();
		if (!fromOnChange && (page=='wallpapers' || page=='themes') && document.getElementById('navCat').value ==0 && search=='') {
			alert('Выберите категорию поиска!');	
		}else{
			var phone=document.getElementById('navPhone');
			var phone_name=makeURLString(phone.options[phone.options.selectedIndex].text);
			phone=phone.options[phone.options.selectedIndex].value;
			if (fromOnChange){
				var navString='';
			}else{
				var category=document.getElementById('navCat').value;
				var order=document.getElementById('navOrder').options.selectedIndex;	
				if (search!='') search='-'+search;
				var navString=category+'-'+order+'-1'+search+'/';
			}
			window.location='/'+page+'/'+phone+'/'+phone_name+'-'+page+'/'+navString;
		}
	}else{
		var category=document.getElementById('navCat').value;
		var order=document.getElementById('navOrder').value;
		var search=escape(document.getElementById('navSearch').value);
		if (search!='') search='?q='+search;
		var navString=search;
		if (document.getElementById('full_phone_name')) {
			var full_phone_name= document.getElementById('full_phone_name').value;
		}
	
		if (full_phone_name) {
			window.location='/'+page+'/'+full_phone_name+'/'+category+'-'+order+'-1/'+navString;
		} else {
			window.location='/'+page+'/'+category+'-'+order+'-1/'+navString;
		}
	}
}


function approve_item(idd){
    JsHttpRequest.query(
    	httpPBase+'/ajax_conmoder.php?act=appr&itt='+idd, // backend
        {
            // pass a text value 
            'idd': idd
        },
        // Function is called when an answer arrives. 
        function(jsresult, txthtml) {
        	document.getElementById('hid'+idd).innerHTML = jsresult['str'];
        },
        false  // do not disable caching
    );
}
function disapprove_item(idd){		
    JsHttpRequest.query(
    	httpPBase+'/ajax_conmoder.php?act=disappr&itt='+idd, // backend
        {
            // pass a text value 
            'idd': idd
        },
        // Function is called when an answer arrives. 
        function(jsresult, txthtml) {
        	document.getElementById('hid'+idd).innerHTML = jsresult['str'];
        },
        false  // do not disable caching
    );
}
function kill_item(idd){
	if(confirm('Вы в самом деле решили удалить?')){
	    JsHttpRequest.query(
	    	httpPBase+'/ajax_conmoder.php?act=kill&itt='+idd, // backend
	        {
	            // pass a text value 
	            'idd': idd
	        },
	        // Function is called when an answer arrives. 
	        function(jsresult, txthtml) {
	        	document.getElementById('hid'+idd).innerHTML = jsresult['str'];
	        },
	        false  // do not disable caching
	    );
	}
}
