function corner_fix() {
	$('bl1').style.bottom = '1px'; $('br1').style.bottom = '1px'; $('bl2').style.bottom = '1px'; $('br2').style.bottom = '1px'
	bottom = (document.all) ? '-1px' : '0'
	setTimeout("$('bl1').style.bottom = bottom; $('br1').style.bottom = bottom; $('bl2').style.bottom = bottom; $('br2').style.bottom = bottom", 500)
}

function fix_search() {
// NOOP
//	mid_col = $('middle-col')
//	left_col = $('left-col')
//	left_col.clientHeight = mid_col.clientHeight
}


function homeChangeProfession(sel) {
	loc = location.host.replace(/(www|local)\.info(\w+)\.com/, "http://$1.info"+sel[sel.selectedIndex].value+".com/")
}

var Constants = { }
Constants.IVA = 0.16

var Signup = { }
Signup.professions = [ ]
Signup.specialities = [ ]

Signup.updateCounter = function(ele) {
	var max = 150
	if (ele.value.length > max)
		ele.value = ele.value.substr(0, max)
	$('activity_counter').innerHTML = "Quedan "+(max - ele.value.length)+" carácteres"
}

Signup.addProfesssion = function() {
	var container = document.getElementById('profession_list_container')
	var signuphash = document.getElementById('signuphash')
	var category = $F('select_profession')
	new Ajax.Updater('profession_list_container', "_ajax_signup_profession.php?id="+category+"&hash="+signuphash.value+"&period="+Signup.get_period(), {onComplete: function() {corner_fix();}, insertion: Insertion.Bottom, evalScripts: true })
	Signup.professions.push($('select_profession')[$('select_profession').selectedIndex].text)
	Signup.updateProfessions()
	Element.remove($('select_profession')[$('select_profession').selectedIndex])
	setTimeout("Signup.update_subtotals()", 500)
}

Signup.addProfesssion2 = function() {
	var container = document.getElementById('profession_list_container')
	var category = $F('select_profession')
	new Ajax.Updater('profession_list_container', "/_ajax_signup_profession.php?id="+category+"&hash=&period="+Signup.get_period(), {onComplete: function() {corner_fix();}, insertion: Insertion.Bottom, evalScripts: true })
	Signup.professions.push($('select_profession')[$('select_profession').selectedIndex].text)
	Signup.updateProfessions()
	Element.remove($('select_profession')[$('select_profession').selectedIndex])
	setTimeout("Signup.update_subtotals()", 500)
}

Signup.addProfesssionRenew = function(profession) {
	var container = document.getElementById('profession_list_container')
	new Ajax.Updater('profession_list_container', "/_ajax_renew_profession.php?id="+profession+"&hash=&period="+Signup.get_period(), {onComplete: function() {corner_fix();}, insertion: Insertion.Bottom, evalScripts: true })
	Signup.professions.push($('select_profession')[$('select_profession').selectedIndex].text)
	Signup.updateProfessions()
	Element.remove($('select_profession')[$('select_profession').selectedIndex])
	setTimeout("Signup.update_subtotals()", 500)
}

Signup.removeProfession = function(link, options) {
	Element.remove(link.parentNode)
	$('select_profession').options[$('select_profession').length] = new Option(options.name, options.id)
	setTimeout("Signup.update_subtotals()", 500)
	if (-1 != (index = Signup.professions.indexOf(options.name)))
		Signup.professions.splice(index, 1)
	Signup.updateProfessions()
}
Signup.updateProfessions = function() {
	if ($('preview_other_professions')) $('preview_other_professions').innerHTML = Signup.professions.join(", ")	
}


Signup.update_line_costs = function(multiplier, speciality_cost) {
	lines = document.getElementsByClassName('line_total')
	lines.each(function(line, index) {
		matches = line.id.match(/line_total_(\d+)/)
		line_id = matches[1]
		Signup.calculate_line_cost(multiplier.form["profession["+line_id+"][specialities][]"][0], line_id, speciality_cost)
	})
	Signup.update_subtotals()
}

Signup.get_period = function(myForm) {
	var period = 1
	if (!myForm) myForm = document.forms['signup5']
	if (!myForm) return period
	if (myForm['signup[payment_billing_period]'].type == 'hidden') {
		period = $F(myForm['signup[payment_billing_period]'])
	} else if (period_radios = myForm['signup[payment_billing_period]']) {
		for (i = 0; i < period_radios.length; i++) {
			if (period_radios[i].checked) period = period_radios[i].value
		}
	}
	return period
}

Signup.updateSpecialities = function(chk, id, speciality_cost) {
	Signup.calculate_line_cost(chk, id, speciality_cost)
	if (chk.checked)
		Signup.specialities[chk.value] = $('speciality_text_'+chk.value).innerHTML
	else
		Signup.specialities.splice(chk.value, 1)
	if ($('preview_specialities')) $('preview_specialities').innerHTML = Signup.specialities.compact().join(", ")	
}

Signup.calculate_line_cost = function(chk, id, speciality_cost) {
	if (signup_years == 2 || signup_years == 3) {
		var base_cost = eval('profession_base_cost_years_'+id)
	} else {
		var base_cost = eval('profession_base_cost_'+id)
	}
	chks = chk.form[chk.name]
	var period = Signup.get_period(chk.form)
	var rate = chk.form['multiplier['+period+']'].value
	var rate2 = chk.form['multiplier2['+period+']'].value
	var line_discount = Math.min(period, promotion)
	var discount_rate = (line_discount == 0) ? 0 : chk.form['multiplier['+line_discount+']'].value
	
	var qty = 0;
	for (i = 0; i < chks.length; i++) {
		qty += (chks[i].checked) ? 1 : 0
	}
	$('base_cost_'+id).innerHTML = (base_cost * rate).to_currency()
	$('line_qty_'+id).innerHTML = qty + ' especialidad' + ((qty == 1) ? '' : 'es')
	price = (qty > 2) ? (qty-2) * (1 == launch_period ? 0 : speciality_cost) : 0
	$('line_price_'+id).innerHTML = (price * rate2).to_currency()
	$('line_total_'+id).innerHTML = ((price * rate2) + (base_cost * rate)).to_currency()
	$('line_total_w_discount_'+id).innerHTML = ((price * rate2) + Math.max(0, ((base_cost * rate) - (base_cost * discount_rate)))).to_currency()
	Signup.update_subtotals()
}

Signup.update_line_total = function(multiplier, id) {
	var period = multiplier.value
	var rate = multiplier.form['multiplier['+period+']'].value
	price = parseFloat($('line_price_'+id).innerHTML)
	$('line_total_'+id).innerHTML = ((price + 95) * rate).to_currency()
}

Signup.update_subtotals = function() {
	if ($('subtotal')) {
		var sub = $('subtotal');
		var iva = $('total_iva');
		var grand_total = $('grand_total');
		//var payment_method1 = $('paymeth1');
		var payment_method2 = $('paymeth2');
		var payment_method3 = $('paymeth3');
		var payment_method4 = $('paymeth4');	
		
		lines = document.getElementsByClassName('line_total_w_discount')
		total = lines.inject(0, function(memo, line, index) {
			return memo + parseInt(line.innerHTML)
		})
		sub.innerHTML = total.to_currency()
		if (iva) iva.innerHTML = (total * Constants.IVA).to_currency()
		if (grand_total) grand_total.innerHTML = (total * (1 + Constants.IVA)).to_currency()
		
		//show hide payment method
		//if (payment_method1 && payment_method2 && payment_method3 && payment_method4) {
		if (payment_method2 && payment_method3 && payment_method4) {
			if (total == 0) {
		    //payment_method1.disabled = true;
			payment_method2.disabled = true;
			payment_method3.disabled = true;	
			payment_method4.checked = true;
			monto_cero = true;
			}
			else {
		    //payment_method1.disabled = false;
			payment_method2.disabled = false;
			payment_method3.disabled = false;	
			payment_method4.checked = false;
			monto_cero = false;
			}	
		}		
	}
}

Signup.updatePreview = function(field) {
	var value = ''
	if (field.selectedIndex)
		value = field[field.selectedIndex].text
	else
		value = field.value
	var matches = field.name.match(/signup\[(.*)\]/)
	var field_name = matches[1]
	if (field_name == 'town_name' || field_name == 'town_id')
		field_name = 'town'
	$('preview_'+field_name).innerHTML = value
	if ('address' == field_name || 'name' == field_name || 'phone' == field_name || 'town' == field_name || 'postcode' == field_name)
		$('preview_'+field_name+'_2').innerHTML = value
}

Signup.toggleOtherTown = function(field) {
	if (field[field.selectedIndex].value == "other_town") {
		Element.show($("other_town"))
		return false
	} else {
		Element.hide($("other_town"))
		return true
	}
}

function to_currency(funky_number) {
	var str = (Math.round((funky_number) * 100) / 100).toString()
	if (index = str.indexOf('.')) {
		return (index == (str.length - 2)) ? str+"0" : str
	} else {
		return str + ".00"
	}
}
Number.prototype.to_currency = function() {
	var val = this.valueOf()
	var str = (Math.round((val) * 100) / 100).toString()
	if (str == '0') {
		return '0.00'
	} else if (-1 != (index = str.indexOf('.'))) {
		return (index == (str.length - 2)) ? str+"0" : str
	} else {
		return str + ".00"
	}
}

Signup.val_step_1a = function(f) {
	val = new Validator({})
	val.val_length(f['signup[name]'], 1, 128, "Nombre no puede estar vacío")
	val.val_cif_nif_nie(f['signup[cif]'], "NIF/CIF tiene que ser un código válido")
	val.val_phone(f['signup[phone]'], "Teléfono tiene que tener 9 dígitos")
	val.val_email(f['signup[email]'], "E-mail tiene que ser una dirección válida")
	val.val_length(f['signup[address]'], 1, 255, "Dirección no puede estar vacío")
	val.val_not_selected(f['signup[province_id]'], 0, "Hay que seleccionar una provincia")
	val.val_not_selected(f['signup[town_id]'], 0, "Hay que seleccionar una población")
	val.val_format(f['signup[postcode]'], /^\d{5}$/, "El código postal tiene que ser en el formato 01234")
	val.val_length(f['signup[short_description]'], 1, null, "Breve descripción de la actividad no puede estar vacía")

	if (valid = val.validate()) {
		if (f['logo'].value || f['photo_1'].value || f['photo_2'].value || f['photo_3'].value) {
			Element.hide('submit_image')
			Element.show('loading_message')
			setTimeout("$('spinner').src= '/images/spinner.gif'", 200)
		}
	}
	return valid
}

Signup.val_step_1b = function(f) {
	val = new Validator({})
	var professions = (f['signup[professions][]'].length) ? f['signup[professions][]'] : [f['signup[professions][]']]
	var checkbox_arrs = []
	for (i = 0; i < professions.length; i++) {
		checkbox_arrs.push(f['profession['+professions[i].value+'][specialities][]'])
	}
	val.val_at_least_one_checked_multiple(checkbox_arrs, "Hay que seleccionar por lo menos una especialidad para cada titulación")
	valid = val.validate()
	return valid
}

Signup.val_step_1 = function(f) {
	val = new Validator({})
	val.val_length(f['signup[name]'], 1, 128, "Nombre no puede estar vacío")
	val.val_cif_nif_nie(f['signup[cif]'], "NIF/CIF tiene que ser un código válido")
	val.val_phone(f['signup[phone]'], "Teléfono tiene que tener 9 dígitos")
	val.val_email(f['signup[email]'], "E-mail tiene que ser una dirección válida")
	val.val_length(f['signup[address]'], 1, 255, "Dirección no puede estar vacío")
	val.val_not_selected(f['signup[province_id]'], 0, "Hay que seleccionar una provincia")
	val.val_not_selected(f['signup[town_id]'], 0, "Hay que seleccionar una población")
	val.val_format(f['signup[postcode]'], /^\d{5}$/, "El código postal tiene que ser en el formato 01234")
	val.val_length(f['signup[short_description]'], 1, null, "Breve descripción de la actividad no puede estar vacía")
	var professions = (f['signup[professions][]'].length) ? f['signup[professions][]'] : [f['signup[professions][]']]
	var checkbox_arrs = []
	for (i = 0; i < professions.length; i++) {
		checkbox_arrs.push(f['profession['+professions[i].value+'][specialities][]'])
	}
	val.val_at_least_one_checked_multiple(checkbox_arrs, "Hay que seleccionar por lo menos una especialidad para cada titulación")
	if (valid = val.validate()) {
		if (f['logo'].value || f['photo_1'].value || f['photo_2'].value || f['photo_3'].value) {
			Element.hide('submit_image')
			Element.show('loading_message')
			setTimeout("$('spinner').src= '/images/spinner.gif'", 200)
		}
	}
	return valid
}

Signup.val_step_pro = function(f) {
	val = new Validator({})
	val.val_length(f['signupprofessional[first_name]'], 1, 32, "Nombre no puede estar vacío")
	val.val_length(f['signupprofessional[last_name_1]'], 1, 32, "Apellido 1 no puede estar vacío")
//	val.val_length(f['signupprofessional[nif]'], 1, 32, "NIF/pasaporte no puede estar vacío")
	val.val_email(f['signupprofessional[email]'], "E-mail tiene que ser una dirección válida")
	if (valid = val.validate()) {
		Element.hide('submit_image')
		Element.show('loading_message')
		setTimeout("$('spinner').src= '/images/spinner.gif'", 200)
	}
	return valid
}

Signup.val_step_4 = function(f) {
	val = new Validator({})
	val.val_email(f['signup[master_email]'], "E-mail tiene que ser una dirección válida")
	if (val.val_format(f['signup[master_password]'], /^[^\s]{6,20}$/, "La contraseña tiene que ser 6 a 20 carácteres de longitud y sin espacios"))
		val.val_equal(f['signup[master_password]'], f['signup[master_password_check]'], "Las contraseñas no coinciden")
	val.val_length(f['signup[master_first_name]'], 1, 32, "Nombre no puede estar vacío")
	val.val_length(f['signup[master_last_name_1]'], 1, 32, "Apellido 1 no puede estar vacío")
	val.val_cif_nif_nie(f['signup[master_nif]'], "NIF/pasaporte tiene que ser un código válido")
	val.val_phone(f['signup[master_phone]'], "Teléfono tiene que tener 9 dígitos")
	return val.validate()
}

Signup.val_step_5 = function(f) {
	val = new Validator({})
	
	var in_launch_period = (f['signup[launch_period]'].value == 1)
	// Contact details
	val.val_length(f['signup[payment_fao]'], 1, 64, "Persona a quién dirigir la factura no puede estar vacía")
	val.val_length(f['signup[payment_phone]'], 1, 32, "Teléfono no puede estar vacío")
	val.val_length(f['signup[payment_name]'], 1, 64, "Razón social no puede estar vacía")
	val.val_length(f['signup[payment_cif]'], 1, 32, "CIF/NIF no puede estar vacío")
	val.val_length(f['signup[payment_address]'], 1, 255, "Dirección no puede estar vacía")
	val.val_format(f['signup[payment_postcode]'], /^\d{5}$/, "El código postal tiene que ser en el formato 01234")
	val.val_length(f['signup[payment_town]'], 1, 32, "Población no puede estar vacía")
	val.val_length(f['signup[payment_province]'], 1, 32, "Provincia no puede estar vacía")
	
	// Billing
	if (!in_launch_period)
		val.val_at_least_one_checked(f['signup[payment_billing_period]'], "Hay que seleccionar un periodo de inscripción")
	var professions = (f['signup[professions][]'].length) ? f['signup[professions][]'] : [f['signup[professions][]']]
	var checkbox_arrs = []
	for (i = 0; i < professions.length; i++) {
		checkbox_arrs.push(f['profession['+professions[i].value+'][specialities][]'])
	}
	val.val_at_least_one_checked_multiple(checkbox_arrs, "Hay que seleccionar por lo menos una especialidad para cada titulación");
	// Payment
	if (!in_launch_period && !monto_cero) {
		if (val.val_at_least_one_checked(f['signup[payment_method]'], "Hay que seleccionar un método de pago")) {
			payment_method = radio_value(f['signup[payment_method]'])
			if (1 == payment_method) {
				val.val_length(f['signup[db_name]'], 1, 32, "Titular de la cuenta no puede estar vacío")
				if (val.val_format(f['signup[db_number_1]'], /\d{4}/, "Entidad tiene que ser 4 dígitos") &&
						val.val_format(f['signup[db_number_2]'], /\d{4}/, "Oficina tiene que ser 4 dígitos") &&
						val.val_format(f['signup[db_number_3]'], /\d{2}/, "Control tiene que ser 2 dígitos") &&
						val.val_format(f['signup[db_number_4]'], /\d{10}/, "Número de cuenta tiene que ser 8 dígitos")) {
					val.val_cuenta_corriente(f['signup[db_number_1]'], f['signup[db_number_2]'], f['signup[db_number_3]'], f['signup[db_number_4]'], "El número de cuenta corriente no está válido")
				}
			} else if (2 == payment_method) {
				val.reset( [f['signup[db_name]'], f['signup[db_number_1]'], f['signup[db_number_2]'], f['signup[db_number_3]'], f['signup[db_number_4]']])
			} else if (3 == payment_method) {
				// Do nothing
			}
		}
	}
	// T+C's
	val.val_checked(f['signup[accept_conditions]'], "Hay que aceptar las condiciones")
	return val.validate()
}

var Contact = { }
Contact.validate = function(f) {
	val = new Validator({})
	val.val_length(f['enquiry[name]'], 1, 128, "'Nombre' no puede estar vacío")
	val.val_email(f['enquiry[email]'], "'E-mail' tiene que ser una dirección válida")
	val.val_length(f['enquiry[message]'], 1, null, "'Comentarios' no puede estar vacío")
	return val.validate()
}

var Recommend = { }
Recommend.validate = function(f) {
	val = new Validator({})
	val.val_email(f['recommend[email]'], "'E-mail' tiene que ser una dirección válida")
	val.val_length(f['recommend[name]'], 1, 128, "'Nombre' no puede estar vacío")
	val.val_length(f['recommend[message]'], 1, null, "'Mensaje' no puede estar vacío")
	val.val_equal(f['contact[suma]'],f['contact[suma_result]'],"'Suma Incorrecta'")	
	return val.validate()
}

var Company = { showing: null }
Company.show_pictures = function(id, type) {
	if (Company.showing == type) {
		Element.hide('ajax_container_'+id)
		Company.showing = null
	} else {
		new Ajax.Updater('ajax_container_'+id, "/_ajax_company_"+type+".php?id="+id, { onComplete: function() { Element.show('ajax_container_'+id) } })
		Company.showing = type
	}
}

var Public = { }
Public.val_company_contact = function(f) {
	val = new Validator({})
	val.val_length(f['contact[name]'], 1, null, "'Nombre' no puede estar vacío")
	val.val_email(f['contact[email]'], "'E-mail' tiene que ser una dirección válida")
	val.val_length(f['contact[message]'], 1, null, "'Consulta' no puede estar vacío")
	val.val_equal(f['contact[suma]'],f['contact[suma_result]'],null,"'Suma Incorrecta'")
	return val.validate()	
}
Public.val_company_contact = function(f) {
	val = new Validator({})
	val.val_length(f['contact[name]'], 1, null, "'Nombre' no puede estar vacío")
	val.val_email(f['contact[email]'], "'E-mail' tiene que ser una dirección válida")
	val.val_length(f['contact[message]'], 1, null, "'Consulta' no puede estar vacío")
	val.val_equal(f['contact[suma]'],f['contact[suma_result]'],"'Suma Incorrecta'")
	return val.validate()	
}


var Search = { }
Search.first_selected = null
Search.validate = function(f) {
	val = new Validator({})
	val.val_not_selected(f['speciality_id'], 0, "Hay que seleccionar una especialidad")
	val.val_not_selected(f['province_id'], 0, "Hay que seleccionar una provincia")
	val.val_not_selected(f['town_id'], 0, "Hay que seleccionar una población")
	return val.validate()
}
Search.Params = ['speciality', 'province', 'town']
Search.handle = function(type) {
	if (0 == $F('sel_'+type+'_id'))
		return
	this.first_selected = this.first_selected || type
	var opts = { type: type, first_selected: this.first_selected }
	Search.Params.each(function(p) { $('sel_'+p+'_id').disabled = true; opts[p+"_id"] = $F('sel_'+p+'_id') })
	
	new Ajax.Request("_ajax_search_handler.php", { method: 'post', parameters: $H(opts).toQueryString(), onComplete: function(ajax) {
		Search.generateOptions(eval(ajax.responseText))
		if ($('sel_province_id').selectedIndex == 0)
			$('sel_town_id').disabled = true
	}})
}

Search.generateOptions = function(opts) {
	Search.Params.each(function(type) {
		var sel = $('sel_'+type+'_id')
		sel.disabled = false
		if (null != opts[type]) {
			sel.length = 0 // remove all child elements
			sel.options[0] = new Option("Seleccionar...", 0) // add default option
			opts[type].each(function(opt) {
				sel.options[sel.options.length] = new Option(opt.text, opt.value, opt.selected, opt.selected)
			})
		}
	})
}


function activex_check() {
	if(Try.these(
      function() {return new ActiveXObject('Msxml2.XMLHTTP')},
      function() {return new ActiveXObject('Microsoft.XMLHTTP')},
      function() {return new XMLHttpRequest()}
  )) {
		return true
	} else {
		alert("Tienes deshabilitada una funcionalidad (ActiveX) que esta página requiere para funcionar correctamente.\n\nRecomendamos que lo actives desde la pestaña de Seguridad en la ventana Opciones de Internet del menú Herramientas de Internet Explorer.")
		return false
	}
}

function jump_page() {
	if (hash = window.location.hash) {
		matches = hash.match(/#page-(\d+)/)
		page = matches[1]
		$("middle-col").innerHTML = ""
		new Ajax.Updater("middle-col", "_ajax_search_results.php"+ window.location.search +"&page="+page) 
	}
}

Signup.newUpdateSpecialities = function(chk, id, speciality_cost) {
	Signup.newCalculate_line_cost(chk, id, speciality_cost)
	if (chk.checked)
		Signup.specialities[chk.value] = $('speciality_text_'+chk.value).innerHTML
	else
		Signup.specialities.splice(chk.value, 1)
	if ($('preview_specialities')) $('preview_specialities').innerHTML = Signup.specialities.compact().join(", ")	
}

Signup.newCalculate_line_cost = function(chk, id, speciality_cost) {
	if (signup_years == 2 || signup_years == 3) {
		var base_cost = eval('profession_base_cost_years_'+id)
	} else {
		var base_cost = eval('profession_base_cost_'+id)
	}
	chks = chk.form[chk.name]
	var period = Signup.get_period(chk.form)
	var rate = chk.form['multiplier['+period+']'].value
	var rate2 = chk.form['multiplier2['+period+']'].value
	var line_discount = Math.min(period, promotion)
	var discount_rate = (line_discount == 0) ? 0 : chk.form['multiplier['+line_discount+']'].value
	
	var qty = 0;
	for (i = 0; i < chks.length; i++) {
		qty += (chks[i].checked) ? 1 : 0
	}
	$('base_cost_'+id).innerHTML = (base_cost * rate).to_currency()
	$('line_qty_'+id).innerHTML = qty + ' especialidad' + ((qty == 1) ? '' : 'es')
	price = (qty > 2) ? (qty-2) * (1 == launch_period ? 0 : speciality_cost) : 0
	$('line_price_'+id).innerHTML = (price * rate2).to_currency()
	$('line_total_'+id).innerHTML = ((price * rate2) + (base_cost * rate)).to_currency()

	var prominent = parseFloat($('line_price_prominent_'+id).innerHTML)
	var active = parseFloat($('line_price_active_'+id).innerHTML)

	$('line_total_w_discount_'+id).innerHTML = ((price * rate2) + Math.max(0, ((base_cost * rate) - (base_cost * discount_rate)))+ prominent + active).to_currency()
	Signup.update_subtotals()
}

Signup.testupdate_line_costs = function(multiplier, speciality_cost) {
	lines = document.getElementsByClassName('line_total')
	lines.each(function(line, index) {
		matches = line.id.match(/line_total_(\d+)/)
		line_id = matches[1]
		Signup.newCalculate_line_cost(multiplier.form["profession["+line_id+"][specialities][]"][0], line_id, speciality_cost)
	})

	var prom_price = multiplier.form['precio_pro'].value
	var acti_price = multiplier.form['precio_act'].value

	actives = document.getElementsByClassName('active_total')
	actives.each(function(active, index) {
		matches = active.id.match(/line_price_active_(\d+)/)
		line_id = matches[1]
		Signup.updateExtra(multiplier.form["profession["+line_id+"][specialities][]"][0], line_id, prom_price, acti_price)
	})
	Signup.update_subtotals()
}

Signup.calculate_extra_costs = function(multiplier, speciality_cost) {
	chks = chk.form[chk.name]
	var period = Signup.get_period(chk.form)
	var rate = chk.form['multiplier['+period+']'].value
	var rate2 = chk.form['multiplier2['+period+']'].value
	var line_discount = Math.min(period, promotion)
	var discount_rate = (line_discount == 0) ? 0 : chk.form['multiplier['+line_discount+']'].value
	
	var qty = 0;
	for (i = 0; i < chks.length; i++) {
		qty += (chks[i].checked) ? 1 : 0
	}
	$('base_cost_'+id).innerHTML = (base_cost * rate).to_currency()
	$('line_qty_'+id).innerHTML = qty + ' especialidad' + ((qty == 1) ? '' : 'es')
	price = (qty > 2) ? (qty-2) * (1 == launch_period ? 0 : speciality_cost) : 0
	$('line_price_'+id).innerHTML = (price * rate2).to_currency()
	$('line_total_'+id).innerHTML = ((price * rate2) + (base_cost * rate)).to_currency()

	var prominent = parseFloat($('line_price_prominent_'+id).innerHTML)
	var active = parseFloat($('line_price_active_'+id).innerHTML)

	$('line_total_w_discount_'+id).innerHTML = ((price * rate2) + Math.max(0, ((base_cost * rate) - (base_cost * discount_rate)))+ prominent + active).to_currency()
	Signup.update_subtotals()
}

Signup.updateExtra = function(chk, id, cost_p, cost_a) {
	chks = chk.form['profession['+id+'][specialities][]']
	
	var qty = 0;
	var qty_a = 0;
	var qty_p = 0;
	var period = Signup.get_period(chk.form)

	for (i = 0; i < chks.length; i++) {
		if (chks[i].checked)
		{
			prominent = chk.form['destacado['+id+'][specialities]['+chks[i].value+']']
			active = chk.form['activo['+id+'][specialities]['+chks[i].value+']']

			qty_p += (prominent.checked) ? 1 : 0
			qty_a += (active.checked) ? 1 : 0
		}
	}
	
	$('line_price_prominent_'+id).innerHTML = (cost_p * qty_p * period).to_currency()
	$('line_price_active_'+id).innerHTML = (cost_a * qty_a * period).to_currency() 

	var price = parseFloat($('line_price_'+id).innerHTML)
	var prominent = parseFloat($('line_price_prominent_'+id).innerHTML)
	var active = parseFloat($('line_price_active_'+id).innerHTML)
	
	$('line_total_w_discount_'+id).innerHTML = (price + prominent + active).to_currency()
	$('line_total_'+id).innerHTML = (price + prominent + active).to_currency()
	Signup.update_subtotals()
}