///////////////////////////////////////////////////////////
function change_amount_main(amount){
	main_price=parseInt(document.getElementById('prod_all_sodi').value,10);
	new_main_price=main_price*parseInt(amount,10);
	document.getElementById('prod_all').value=new_main_price;
	
	change_comon_price();
}
/////////////////////////////////////////////////////////////
function show_selected_item(val,id_price,id_sub,amount_id){
	val_arr=val.split(",");
	
	realy_amount=parseInt(document.getElementById(amount_id).value,10);
	
	document.getElementById(id_price).value=realy_amount * parseInt(val_arr[1],10);
	document.getElementById(id_sub).value=val_arr[0];
	
	if(val_arr[1]==0){
		document.getElementById(id_sub).checked=false;
		document.getElementById(amount_id).disabled=true;
		document.getElementById(id_sub).disabled=true;
	}else{
		document.getElementById(id_sub).checked=true;
		document.getElementById(amount_id).disabled=false;
		document.getElementById(id_sub).disabled=false;
	}
	
	change_comon_price();
}
////////////////////////////////////////////////////////////////////
function change_amount_add(amn,id_item,id_price){
	price=document.getElementById(id_item).value
	prise_arr=price.split(",");
	price_source=parseInt(prise_arr[1],10);
	
	new_add_price=price_source*parseInt(amn,10);
	document.getElementById(id_price).value=new_add_price;
	
	change_comon_price();
}
////////////////////////////////////////////////////////////
function change_comon_price(){
	count_add_itm=parseInt(document.getElementById('amount_add_items').value,10);
	prod_amount=parseInt(document.getElementById('itm_prod_amount').value,10);
	
	prev_price=parseInt(document.getElementById('prod_all_sodi').value,10)*prod_amount;
	
	
	for(i=0;i<count_add_itm;i++){
		add_price=document.getElementById('itm_prod_add_price_' + i).value;
		prev_price+=parseInt(add_price,10);
	}
	document.getElementById('prod_all').value=prev_price;
}
///////////////////////////////////////////////////////
arrDelPrc=new Array();
price_global=0;
price_delivery=0;
delivery=new Array('0');
////////////////////////////////////////////////////
function change_order(price_cur,delivery_fee_id,chk){
  price_global=parseInt(document.getElementById("glob_price").value,10);
  price_common=parseInt(document.getElementById(price_cur).value,10);
  delivery_fee=parseInt(document.getElementById(delivery_fee_id).value,10);
                                                                                            
  if(document.getElementById(chk).checked==true){
       price_global+=price_common;
       document.getElementById("glob_price").value=price_global;
                                                                                                
			if(delivery_fee>parseInt(document.getElementById("global_deliv").value,10)){
                   document.getElementById("global_deliv").value=delivery_fee;
                   price_delivery=delivery_fee;
				   delivery.unshift(delivery_fee);
			}else{
				delivery.unshift(delivery_fee);
			}	
	}else{
			price_global-=price_common;
			document.getElementById("glob_price").value=price_global;
			delivery.shift();
			document.getElementById("global_deliv").value=delivery[0];
			price_delivery=delivery[0];
	}
}
///////////////////////////////////////////////////
////////////////////////////////////////////////////
function togle_delivery(){
	if(document.getElementById("choose_delivery").checked==true){
			document.getElementById("global_deliv").value='0';
	}else{
			document.getElementById("global_deliv").value=price_delivery;
	}
}
////////////////////////////////////////////////////

