window.addEvent ('domready', function () {
	if ($('contactar')) $('contactar').addEvent ('click', (function (e) {
		e.stop();
		if (!$('divAjax')) {
			oDiv = new Element ('div', {
				'id': 'divAjax',
				'html': '<div style="color: #4C79E4; font-size: 13px; padding-left: 78px;text-align:left">Teléfono de la academia o escuela:</'+'div>'
					+'<div style="font-size: 18px;text-transform:uppercase;padding: 12px 0 2px 78px;text-align:left">'+ $('nacad').get ('text') +'</'+'div>'
					+'<br/>indique que lo ha encontrado en'
					+'<br/><img src="img/popup_academias.gif" alt="academias.com" width="159" height="30" style="background:#fff;padding:6px 21px;" />'
					+'<br/>para recibir un trato preferente'
					+'<div id="stlf">espere, por favor</'+'div>',
				'events': { 'click': function () { this.setStyle ('display', 'none'); } }
			});
			oDiv.inject ('contactar', 'after');

			rq = new Request ({'url': 'publicidad.popup.ajax.php', 'method': 'get', 'onSuccess': function (tx,xh) {
				$('stlf').set ('text', tx ? tx : 'no consta');
			}}).send ('a='+ $('dat_id').get ('value'));
		} else {
			$('divAjax').setStyle ('display', 'block');
		}
		return false;
	}));
	$('dat_cp').addEvent ('keydown', function (e) {
		if ((e.code >= 48 && e.code <= 57)
			|| (e.code >= 96 && e.code <= 105)
			|| e.key == 'enter' || e.key == 'left' || e.key == 'right'
			|| e.key == 'backspace' || e.key == 'delete' || e.key == 'tab'
		) return true;
		e.stop ();
	});
	$('imprimir').addEvent ('click', (function (e) { e.stop(); window.print (); return false; }));
	$('condicionesyaviso').addEvents ({
		'mouseenter': function (e) { $(this).setStyle ('cursor', (window.ie ? 'hand' : 'pointer')); },
		'mouseleave': function (e) { $(this).setStyle ('cursor', 'default'); },
		'click': function (e) {
			$('condiciones').setStyles ({ 'display': 'block', 'left': ($('contenedor').offsetLeft + 200)+'px' });
		}
	});
	$('condiciones').addEvents ({
		'mouseenter': function (e) { $(this).setStyle ('cursor', (window.ie ? 'hand' : 'pointer')); },
		'mouseleave': function (e) { $(this).setStyle ('cursor', 'default'); },
		'click': function (e) { $(this).setStyle ('display', 'none'); }
	});
	if ($('situacion')) $('situacion').addEvent ('click', function (e) {
		e.stop();
		var mapa = window.open (this.href, 'popupmapa', 'location=no,menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=730,height=590');
	});
	if ($('streetview')) $('streetview').addEvent ('click', function (e) {
		e.stop();
		var mapa = window.open (this.href, 'popupstreetview', 'location=no,menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=730,height=590');
	});
	window.focus();
});
window.addEvent ('load', function () {
	if (!$('ufoytreal')) return false;
	ytId = $('ufoytreal').hash.substr (1);
	if (ytId) {
		$('ufoyt').set ('html', '<iframe src="video.popup.php?v='+ ytId +'&w=210&h=178" width="210" height="178" scrolling="no" border="0" frameborder="0" />');
		if ($('ufoytreal')) $('ufoytreal').addEvent ('click', (function (e) {
			e.stop();
			$('ufoyt').getElement ('iframe').contentDocument.getElementById ('ytembvid').stopVideo();
			if ($('divYT')) $('divYT').remove ();
			oDiv = new Element ('div', { 'id': 'divYT' }).adopt (
				new Element ('img', { 'id': 'divYTClose', 'src': 'img/frmno.gif', 'alt': 'cerrar', 'width': 13, 'height': 13,
					'events': { 'click': function () { this.getParent ().destroy (); } }
				}),
				new Element ('iframe', { 'border': 0, 'frameborder': 0, 'scrolling': 'no', 'width': '425', 'height': '366', 'src': 'video.popup.php?v='+ ytId +'&w=425&h=366' })
			);
			oDiv.inject ('contactar', 'after');
			return false;
		}));
	} else {
		if ($('ufoytreal')) $('ufoytreal').addEvent ('click', (function (e) { e.stop(); return false; }));
	}
});
