function getId(id) {
	return document.getElementById(id);
}

function muestraFormulario(idtabla) {
	if (getId('idpro').value < 1) {
		alert('Primero debe cargar una pieza para poder completar el formulario.');
		return false;
	}
	
	for (i = 2; i < 13; i++) {
		if ('table' + i != idtabla) {
			document.getElementById('table' + i).style.display = 'none';
		}
	}
	
	if (getId(idtabla).style.display == 'none') {
		getId(idtabla).style.display = 'block';
	}
	else {
		getId(idtabla).style.display = 'none';
	}
}

function siguienteFormulario(idtabla) {
	setTimeout("muestraFormulario('" + idtabla + "');", 750);
}

function nadaFunction(sd) {
}

function muestraTabla(idtabla) {
	if (getId(idtabla).style.display == 'none') {
		getId(idtabla).style.display = 'block';
	}
	else {
		getId(idtabla).style.display = 'none';
	}
}

function validarAnunciante() {
	if (getId('anunciante_nombre').value == '') {
		alert('Debe ingresar el nombre del anunciante.');
		getId('anunciante_nombre').focus();
		return false;
	}
	if (getId('anunciante_cargo').value == '') {
		alert('Debe ingresar el cargo del anunciante.');
		getId('anunciante_cargo').focus();
		return false;
	}
	if (getId('anunciante_empresa').value == '') {
		alert('Debe ingresar la empresa anunciante.');
		getId('anunciante_empresa').focus();
		return false;
	}
	if (getId('anunciante_pais').value == '') {
		alert('Debe ingresar el país de la empresa anunciante.');
		getId('anunciante_pais').focus();
		return false;
	}
	if (getId('anunciante_provincia').value == '') {
		alert('Debe ingresar la provincia.');
		getId('anunciante_provincia').focus();
		return false;
	}
	if (getId('anunciante_direccion').value == '') {
		alert('Debe ingresar la dirección.');
		getId('anunciante_direccion').focus();
		return false;
	}
	if (getId('anunciante_codpostal').value == '') {
		alert('Debe ingresar el código postal.');
		getId('anunciante_codpostal').focus();
		return false;
	}
	if (getId('anunciante_telefono').value == '') {
		alert('Debe ingresar el teléfono de contacto.');
		getId('anunciante_telefono').focus();
		return false;
	}
	if (getId('anunciante_email').value == '') {
		alert('Debe ingresar el e-mail de contacto.');
		getId('anunciante_email').focus();
		return false;
	}
	aj1.post('aj_gc.php?s=form2', 'anunciante_nombre=' + getId('anunciante_nombre').value + '&anunciante_cargo=' + getId('anunciante_cargo').value + '&anunciante_nombre2=' + getId('anunciante_nombre2').value + '&anunciante_cargo2=' + getId('anunciante_cargo2').value + '&anunciante_empresa=' + getId('anunciante_empresa').value + '&anunciante_pais=' + getId('anunciante_pais').value + '&anunciante_provincia=' + getId('anunciante_provincia').value + '&anunciante_direccion=' + getId('anunciante_direccion').value + '&anunciante_codpostal=' + getId('anunciante_codpostal').value + '&anunciante_telefono=' + getId('anunciante_telefono').value + '&anunciante_email=' + getId('anunciante_email').value + '&id=' + getId('idpro').value, 'aj_form2');
	siguienteFormulario('table3');
}

function validarExhibicion() {
	if (getId('espacio_watts').value == '') {
		alert('Debe ingresar el consumo de la pieza.');
		getId('espacio_watts').focus();
		return false;
	}
	if (getId('espacio_ancho').value == '') {
		alert('Debe ingresar el ancho de la pieza.');
		getId('espacio_ancho').focus();
		return false;
	}
	if (getId('espacio_profundidad').value == '') {
		alert('Debe ingresar la profundidad de la pieza.');
		getId('espacio_profundidad').focus();
		return false;
	}
	if (getId('espacio_alto').value == '') {
		alert('Debe ingresar el alto de la pieza.');
		getId('espacio_alto').focus();
		return false;
	}
	if (getId('espacio_emplazamiento').value == '') {
		alert('Debe seleccionar el tipo de emplazamiento de la pieza.');
		return false;
	}
	aj1.post('aj_gc.php?s=form7', 'espacio_watts=' + getId('espacio_watts').value + '&espacio_ancho=' + getId('espacio_ancho').value + '&espacio_profundidad=' + getId('espacio_profundidad').value + '&espacio_alto=' + getId('espacio_alto').value + '&espacio_superficie=' + getId('espacio_superficie').value + '&espacio_emplazamiento=' + getId('espacio_emplazamiento').value + '&id=' + getId('idpro').value, 'aj_form7');
	siguienteFormulario('table8');
}

function calcularSuperficie() {
	getId('espacio_superficie').value = (getId('espacio_ancho').value * getId('espacio_profundidad').value);
}

function procesarHisto3() {
	var cant_checks = 0;
	cadena = 'histo3_presupuesto=' + getId('histo3_presupuesto').value + '&histo3_promocion=';
	if (getId('histo3_0').checked == true) {
		cadena += getId('histo3_0').value + '*'
		cant_checks++;
	}
	if (getId('histo3_1').checked == true) {
		cadena += getId('histo3_1').value + '*'
		cant_checks++;
	}
	if (getId('histo3_2').checked == true) {
		cadena += getId('histo3_2').value + '*'
		cant_checks++;
	}
	if (getId('histo3_3').checked == true) {
		cadena += getId('histo3_3').value + '*'
		cant_checks++;
	}
	if (getId('histo3_4').checked == true) {
		cadena += getId('histo3_4').value + '*'
		cant_checks++;
	}
	if (getId('histo3_5').checked == true) {
		cadena += getId('histo3_5').value + '*'
		cant_checks++;
	}
	if (getId('histo3_6').checked == true) {
		cadena += getId('histo3_6').value + '*'
		cant_checks++;
	}
	if (getId('histo3_7').checked == true) {
		cadena += getId('histo3_7').value + '*'
		cant_checks++;
	}
	if (getId('histo3_8').checked == true) {
		cadena += getId('histo3_8').value
		cant_checks++;
	}
	cadena += '&id=' + getId('idpro').value;
	if (cant_checks > 1) {
		aj1.post('aj_gc.php?s=form10', cadena, 'aj_form10');
		siguienteFormulario('table11');
	}
	else {
		alert('Debe seleccionar al menos dos técnicas de promoción.');
		return false;
	}
}

function maxCaracteres(event, box, maxCar){
	
	var tecla = event.which; //BACKSPACE = event.which => 8
	
	if(box.value.length >= maxCar && tecla != 8){
		
		alert('Máx. 300 caracteres (espacios incluidos)');
		return false;
	}
}

/** Botones Limpiar **/

function clear_informacion_anunciante(){
	
	document.getElementById('anunciante_nombre').value    = '';
	document.getElementById('anunciante_cargo').value     = '';
	document.getElementById('anunciante_nombre2').value   = '';
	document.getElementById('anunciante_cargo2').value    = '';
	document.getElementById('anunciante_empresa').value   = '';
	document.getElementById('anunciante_pais').value      = '';
	document.getElementById('anunciante_provincia').value = '';
	document.getElementById('anunciante_direccion').value = '';
	document.getElementById('anunciante_codpostal').value = '';
	document.getElementById('anunciante_telefono').value  = '';
	document.getElementById('anunciante_email').value     = '';
	return false;
}

function clear_informacion_diseniador_grafico(){
	
	document.getElementById('disgrafico_nombre').value    = '';
	document.getElementById('disgrafico_cargo').value     = '';
	document.getElementById('disgrafico_empresa').value   = '';
	document.getElementById('disgrafico_pais').value      = '';
	document.getElementById('disgrafico_provincia').value = '';
	document.getElementById('disgrafico_direccion').value = '';
	document.getElementById('disgrafico_codpostal').value = '';
	document.getElementById('disgrafico_telefono').value  = '';
	document.getElementById('disgrafico_email').value     = '';
	return false;
}

function clear_informacion_diseniador_industrial(){
	
	document.getElementById('disindustrial_nombre').value    = '';
	document.getElementById('disindustrial_cargo').value     = '';
	document.getElementById('disindustrial_empresa').value   = '';
	document.getElementById('disindustrial_pais').value      = '';
	document.getElementById('disindustrial_provincia').value = '';
	document.getElementById('disindustrial_direccion').value = '';
	document.getElementById('disindustrial_codpostal').value = '';
	document.getElementById('disindustrial_telefono').value  = '';
	document.getElementById('disindustrial_email').value     = '';
	return false;
}

function clear_estudio_disenio(){

	document.getElementById('estudio_nombre').value    = '';
	document.getElementById('estudio_cargo').value     = '';
	document.getElementById('estudio_empresa').value   = '';
	document.getElementById('estudio_pais').value      = '';
	document.getElementById('estudio_provincia').value = '';
	document.getElementById('estudio_direccion').value = '';
	document.getElementById('estudio_codpostal').value = '';
	document.getElementById('estudio_telefono').value  = '';
	document.getElementById('estudio_email').value     = '';
	return false;
}

function clear_agencia(){

	document.getElementById('agencia_nombre').value    = '';
	document.getElementById('agencia_cargo').value     = '';
	document.getElementById('agencia_empresa').value   = '';
	document.getElementById('agencia_pais').value      = '';
	document.getElementById('agencia_provincia').value = '';
	document.getElementById('agencia_direccion').value = '';
	document.getElementById('agencia_codpostal').value = '';
	document.getElementById('agencia_telefono').value  = '';
	document.getElementById('agencia_email').value     = '';
	return false;
}

function clear_espacio_exhibicion(){
	
	document.form7.espacio_watts1[1].checked = true;
	document.form7.radiobutton[0].checked    = false;
	document.form7.radiobutton[1].checked    = false;
	document.form7.radiobutton[2].checked    = false;
	document.form7.radiobutton[3].checked    = false;

	document.getElementById('espacio_watts').value       = '';
	document.getElementById('espacio_ancho').value       = '';
	document.getElementById('espacio_profundidad').value = '';
	document.getElementById('espacio_alto').value        = '';
	document.getElementById('espacio_superficie').value  = '';
	return false;
}

function clear_formulario_1(){

	document.getElementById('histo1_lapso1').value   = 0;
	document.getElementById('histo1_lapso2').value   = 0;
	document.getElementById('histo1_lapso3').value   = 0;
	document.getElementById('histo1_engrega1').value = 0;
	document.getElementById('histo1_engrega2').value = 0;
	document.getElementById('histo1_engrega3').value = 0;
	document.getElementById('histo1_precio').value   = 0;
	document.getElementById('histo1_cantidad').value = '';
	document.getElementById('histo1_text1').value 	 = '';
	document.getElementById('histo1_text2').value 	 = '';
	document.getElementById('histo1_text3').value 	 = '';
	document.getElementById('histo1_text4').value 	 = '';
	return false;
}

function clear_formulario_2(){

	document.getElementById('histo2_text1').value = '';
	document.getElementById('histo2_text2').value = '';
	document.getElementById('histo2_text3').value = '';
	document.getElementById('histo2_text4').value = '';
	return false;
}

function clear_formulario_3(){

	document.form10.histo3_promocionxx[0].checked = false;
	document.form10.histo3_promocionxx[1].checked = false;
	document.form10.histo3_promocionxx[2].checked = false;
	document.form10.histo3_promocionxx[3].checked = false;
	document.form10.histo3_promocionxx[4].checked = false;
	document.form10.histo3_promocionxx[5].checked = false;
	document.form10.histo3_promocionxx[6].checked = false;
	document.form10.histo3_promocionxx[7].checked = false;
	document.form10.histo3_promocionxx[8].checked = false;
	return false;
}

function clear_ficha(){
	
	document.getElementById('ficha_nombre').value 	  = '';
	document.getElementById('ficha_empresa').value 	  = '';
	document.getElementById('ficha_objetivos').value  = '';
	document.getElementById('ficha_materiales').value = '';
	return false;
}

function clear_comite_admision(){
	
	document.getElementById('comite_observaciones').value = '';
	document.getElementById('comite_participantes').value = '';
	return false;
}

/** Fin Botones Limpiar **/
