/*
Frontend de Papelandia - http://www.papelandia.com.ve/
Diseño: T.S.U. Roselba Gómez <roselba@actimedia.com.ve>
Programación: Ing. Miguel Palazzo <miguel@actimedia.com.ve>
Fecha de Creación: 14/11/2007
Fecha de Actualización: 03/03/2008
*/

<!--//
// Auto-Inserción de función para inicialización y envío del formulario
window.addEvent('domready', function() {
	var f = document.getElementById($$('form[id!="formaAcceso"]').getProperty('id'));
	if (f != null) {
		f.reset();
		f.addEvent('submit', function(e) {
			new Event(e).stop();
			var log = $('resultado').empty().addClass('carga');
			this.effect('opacity', {duration: 1500, transition: Fx.Transitions.Back.easeOut}).start(1, 0);
			this.send({
				update: log,
				evalScripts: true,
				onComplete: function() {
					log.removeClass('carga');
				}
			});
		});
	}
	if ($('misma_direccion') != null) {
		$('misma_direccion').addEvent('click', function(e) {
			var valor = (this.getValue() == 1 ? true : false);
			$$('input[name^="envio"]').each(function(el) {
				el.value = '';
				el.disabled = valor;
			});
			$$('select[name^="envio"]').each(function(el) {
				el.selectedIndex = -1;
				el.disabled = valor;
			});
			$$('textarea[name^="envio"]').each(function(el) {
				el.value = '';
				el.disabled = valor;
			});
		});
	}
});

// Función para limpieza de formulario
function limpiarForma() {
	var f = document.getElementById($$('form[id!="formaAcceso"]').getProperty('id'));
	f.reset();
	f.elements[0].focus();
}

// Función para reintentar envío de formulario
function reintentarForma() {
	$('resultado').empty();
	var f = document.getElementById($$('form[id!="formaAcceso"]').getProperty('id'));
	f.effect('opacity', {duration: 1500, transition: Fx.Transitions.Back.easeOut}).start(0, 1);
}

// Función para contar y delimitar cantidad de caracteres permitidos en un textarea
function contarChars(obj,maxlong,contador) {
	if (obj.length > maxlong)
		obj = obj.substring(0,maxlong);
	else
		document.getElementById(contador).innerHTML = maxlong - obj.length;
}
//-->