function formPedido(id, txt, min){
	document.getElementById('formpedido').style.top = '30%';
	//document.getElementById('formpedido').style.top = (y - 200)+'px';
	document.getElementById('producto').value = txt;
	document.getElementById('cantidad').value = '';
	document.getElementById('observaciones').value = '';
	document.getElementById('id_producto').value = id;
	document.getElementById('mini').value = min;
	if (min != ''){
		document.getElementById('minimo').innerHTML = '(Minimo '+min+')';
	} else {
		document.getElementById('minimo').innerHTML = '';
	}
	
	document.getElementById('formpedido').style.display = '';
	$('#minimo').sifr({path: 'others/swf/', font: 'helve57-cond'});
}

function ocultarPop(){
	document.getElementById('formpedido').style.display = 'none';
}

function enviar(){
	var min = document.getElementById('mini').value;
	var cant = document.getElementById('cantidad').value;
	if (cant == ''){
		alert('Por favor, ingrese una cantidad mayor a cero.');
		document.getElementById('cantidad').focus();
	} else {
		if (min != '' && parseInt(cant) < parseInt(min)){
			alert('No se puede realizar un pedido por debajo del mínimo.');
			document.getElementById('cantidad').focus();
		} else {
			if (isNaN(cant)){
				alert('Por favor, ingrese una cantidad válida.');
				document.getElementById('cantidad').focus();
			} else {
				document.getElementById('form_producto').submit();
			}
		}
	}
}


function formConsulta(id, txt){
	document.getElementById('formconsulta').style.top = '30%';
	//document.getElementById('formpedido').style.top = (y - 200)+'px';
	document.getElementById('producto2').value = txt;
	document.getElementById('asunto').value = '';
	document.getElementById('consulta').value = '';
	document.getElementById('id_producto2').value = id;
	
	document.getElementById('formconsulta').style.display = '';

	$('#titulo_label2').sifr({path: 'others/swf/', font: 'helve57-cond'});
	$('#producto_label2').sifr({path: 'others/swf/', font: 'helve57-cond'});
	$('#asunto_label2').sifr({path: 'others/swf/', font: 'helve57-cond'});
	$('#consulta_label2').sifr({path: 'others/swf/', font: 'helve57-cond'});
}

function ocultarPop2(id){
	document.getElementById(id).style.display = 'none';
}

function enviar2(){
	document.getElementById('form_consulta').submit();
}



function cambiarFoto(id,j){
	ocultartodo(id);
	document.getElementById('img_'+id+'_'+j).style.display = '';
}

function ocultartodo(id){
	var i;
	tags = document.getElementsByTagName('div');
	for (i = 0; i < tags.length; i++){
		if (tags[i].id && tags[i].id.indexOf('img_'+id+'_') >= 0){
			tags[i].style.display = 'none';
		}
	}
}

function verFotoGrande(foto){
	document.getElementById('divFotoGrande').style.top = '30%';
	document.getElementById('fotoGrande').src = foto;
	document.getElementById('divFotoGrande').style.display = '';
}
