function admin_change_cc(ord,id,cc){
n=prompt(lang['new_cc'],cc);

if(n)location.href="admin.php?mode=order&id="+ord+"&change_cc="+n+"&order_item="+id;

}

function admin_catalog_main(c,add){

ind=c.options[c.selectedIndex].value;
url="ajax_req.php?catalog_main="+ind;

dd = document.getElementById('sub_catalog'+add);
dd.innerHTML=loading_small;

loadData(get_req(),url,'sub_catalog'+add);

}

function item_change_cat(item){

cat_s=document.getElementById('sub_cat');
//alert(cat_s);
cat =cat_s.options[cat_s.selectedIndex].value; 


dd = document.getElementById('catalog_button');
dd.innerHTML=loading_small;
url="ajax_req.php?change_item_cat="+item+"&cat="+cat;
loadData(get_req(),url,"catalog_button");

}


function admin_main_cat(s,id){


url = "ajax_admin.php?main_cat="+s.options[s.selectedIndex].value+"&id="+id;


//alert(url);
document.getElementById(id+"sub_cat").innerHTML=loading_small;

loadData(get_req(),url,id+'sub_cat');

}

function admin_sub_cat(s,id){


url = "ajax_admin.php?sub_cat="+s.options[s.selectedIndex].value+"&id="+id;

//alert(url);

document.getElementById(id+"items").innerHTML=loading_small;

loadData(get_req(),url,id+'items');

}

function admin_items(s,id){

if(id=='items_cont')document.getElementById("r_").style.display="block";


url = "ajax_admin.php?item="+s.options[s.selectedIndex].value+"&id="+id;
if(id=='items_cont')url+="&type=select";
if(id=='items_select')url+="&type=list";
//alert(url);

d=document.getElementById(id);

if(d){
d.innerHTML=loading;

loadData(get_req(),url,id);
}
}

function admin_add_compare(id){

item= document.getElementById("sel_item").value;

//alert(item);


url = "ajax_admin.php?add_compare="+id+"&item="+item;

get_content(url,"items_cont");
}

function admin_del_compare(id){

item= document.getElementById("sel_item").value;

//alert(item);


url = "ajax_admin.php?del_compare="+id+"&item="+item;

get_content(url,"items_cont");
}

function admin_set_order_status(t,id){


		
	// alert(t.selectedIndex);

	st = t.options[t.selectedIndex].value;
	stat = prompt(lang['new_status']+" \""+lang['s'+st]+"\"","");	
	
	// alert(st+"\n"+id);

	document.getElementById("div_status_"+id).innerHTML=loading_small;

	url="ajax_req.php?set_status="+st+"&id="+id;
	data = "status="+stat
	postData(get_req(),url,"div_status_"+id,data);
	

}

function admin_del_need(id){

if(!confirm('Delete?'))return;
tr=document.getElementById("tr_"+id);
tr.parentNode.removeChild(tr);

url="ajax_req.php?del_need="+id;
send_req(get_req(),url);

}


function admin_add_item(id){

sel=document.getElementById(id+'items_select');
if(!sel){alert('Select item');return;}
item = sel.options[sel.selectedIndex].value;
if(!item||item==-1){alert('Select item');return;}

cc=document.getElementById(id+'order_cc').value;
if(!cc)cc=1;

url="admin.php?mode=order&id="+id.substring(0,id.length-1)+"&add_item="+item+"&cc="+cc;
//alert(url);
location.href=url;

}


