//javascript
$(function(){
	$.nyroModalSettings({	
			minWidth: 820,
  			minHeight: 765
		});
});
function trimiteComanda(){
	$("#com").val('trimite_comanda');
	$("#cos_form").submit();
}
function loginClient(){
	$("input[name=login_client]").val(1);
	$("#login_client").submit();
}
function actualizeazaCantitateCos(){
	$("#com").val('actualizare_cantitati');
	$("#cos_form").submit();
}
function stergeDinCos(no_produs){
	$("#com").val('sterge_din_cos');
	$("#no_produs").val(no_produs);
	$("#cos_form").submit();
}
function showSubm(id){
	if ($("#subm_"+id).is(':hidden')){
		$("#subm_"+id).slideDown();
	}else{
		$("#subm_"+id).slideUp();
	}
}

function sendForm(idFormular,tipFormular){
	var date = $('#'+idFormular).serialize();
	$.ajax({
		type: "POST",
		url: PATH.root+'send_'+tipFormular+'/',
		data: date,
		success: function(rasp){
			$("#form").html(rasp);
		}

	});
}

var countInput = 0;
function adauga_inp_file(id,maxInputs){
	var obj=document.getElementById(id);

	var new_input=document.createElement('input');
	var new_txt=document.createElement('span');
	var new_check=document.createElement('input');

	new_input.setAttribute('type','file');
	new_input.setAttribute('name','foto[]');
	new_input.setAttribute('style','width:200px');
	new_input.setAttribute('size','20');

	new_txt.innerHTML = 'principala ';

	new_check.setAttribute('type','radio');
	new_check.setAttribute('style','width:15px;height:15px;');
	new_check.setAttribute('name','principala');
	new_check.setAttribute('value',countInput);

	if (countInput < maxInputs){
		obj.appendChild(new_input);
		obj.appendChild(new_check);
		obj.appendChild(new_txt);

		var new_input=document.createElement('br');
		new_input.setAttribute('style','clear:both');
		obj.appendChild(new_input);
		countInput++;
	}
}

function setFotoPr(id,id_ext,container,tpl,tabel){
	$.ajax({
		type: "POST",
		url: PATH.root+'ajax/ch_foto_pr',
		data: 'id='+id+'&id_ext='+id_ext+'&tabel='+tabel+'&tpl='+tpl+'&url='+escape(window.location.href),
		success: function(rasp){
			$("#"+container).html(rasp);
		}

	});
}


function chImg(cale){
	$("#img_w").attr('src',cale);

}