function valor_campo (campo, tipo) {
	switch (tipo) {
		case 1:
			value = $('input[name="'+campo+'"]').attr('value');
			break;
		case 2:
			value = $('[name="'+campo+'"]:checked').attr('value');
			break;
		case 3:
			value = $('select[name="'+campo+'"] option:selected').attr('value');
			break;
		case 4:
			value = $('input[name="'+campo+'"]').attr('checked');
			if (value) {
				value = $('input[name="'+campo+'"]').attr('value');
			}
			else {
				value = "";
			}
			break;
		default:
			break;
	}
	if (value == undefined) {
		value = "";
	}
	return value;
}

function open_pop_up (nom_pop_up) {
	$(nom_pop_up).hide();
	w = $(window).width()/2 - $(nom_pop_up).width()/2;
	h = $(window).height()/2 - $(nom_pop_up).height()/2;
	$(nom_pop_up).css("left",w + "px");
	$(nom_pop_up).css("top",h + "px");
	$(nom_pop_up).show('slow');
}

function recorrer_botones (tablas) {
	name = "";
	jQuery.each (tablas, function () {
		$(""+this+"").each(function () {
			if ($(this).attr('checked')) {
				name = name + $(this).attr('tabla');
			}
		});
	});
	return name;
}

function act_lista_confs_arts () {
	lista = '';
	precio = 0;
	lista += '<tr><th align="right">Cant.</th><th align="left">Ref.</th><th align="left">Nombre</th><th align="right">PVP</th><th align="right"/></tr>';
	$(".grupo_arts input").each(function () {
		if ($(this).attr("checked")) {
			if ($(this).attr('cant') > 0) {
				lista += '<tr>' + $(this).parent ().parent ().html() + '</tr>';
			}
			precio += $(this).attr('precio') * $(this).attr('cant');
		}
	});
	lista += '<tr><td colspan="3" align="left"><font class="title">Total:</font></td><td align="right" nowrap><font class="title">' + precio.toFixed (2) + " €</font></td></tr>";
	$('#list_arts').html (lista);
	$('#list_arts').find ('input').parent ().remove();
}
function diff_precios_confs_arts () {
	$('.dif_precio').text ('');
	$('.grupo_arts').each (function () {
		var prec_comp = 0;
		$(this).find ('input').each(function () {
			if ($(this).attr('checked')) {
				prec_comp = $(this).attr('precio') * $(this).attr('cant');
			}
		});
		prec_comp = prec_comp.toFixed (2);
		$(this).find ('input[type="radio"]').each (function () {
			var prec = $(this).attr ('cant') * $(this).attr ('precio');
			if (isNaN (prec)) prec = 0;
			prec = prec.toFixed (2);
			if (prec_comp != prec) {
				var diff = (prec - prec_comp).toFixed (2);
				if (diff > 0) {
					diff = '+' + diff;
				}
				$(this).parent ().parent ().children ('.dif_precio').first ().text (' ('+diff+')');
			}
		});
	});
}
function cerrar_conf_grupos_arts (target) {
	$(target).find ('.linea_grupo_conf').hide ();
	$(target).find ('[checked="true"]').parent ().parent ().show ();
}
function abrir_conf_grupos_arts (target) {
	$(target).find ('.linea_grupo_conf').show ();
}
function mostrar_foto_confs (ref) {
	$('#descr_conf_pers img').hide ();
	$('#descr_conf_pers img[src*="' + ref + '."]').show ();
}

