function checkDWLPopup() { console.log('errcheck'); var err=0; if(document.getElementById('dwl-name').value == '') {$('dwl-name').addClass('formerror'); err=1;} else $('dwl-name').removeClass('formerror'); if(document.getElementById('dwl-surname').value == '') {$('dwl-surname').addClass('formerror'); err=1;} else $('dwl-surname').removeClass('formerror'); if(document.getElementById('dwl-jobtitle').value == '') {$('dwl-jobtitle').addClass('formerror'); err=1;} else $('dwl-jobtitle').removeClass('formerror'); if(document.getElementById('dwl-company').value == '') {$('dwl-company').addClass('formerror'); err=1;} else $('dwl-company').removeClass('formerror'); if(document.getElementById('dwl-country').value == '') {$('dwl-country').addClass('formerror'); err=1;} else $('dwl-country').removeClass('formerror'); filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; if (!filter.test(document.getElementById('dwl-email').value)) {$('dwl-email').addClass('formerror'); err=1;} else $('dwl-email').removeClass('formerror'); if(err!=0) return false; console.log(shareurl); setTimeout('self.location="'+shareurl+'"',2500); } var OPEN_POPUP_SPEED = 400; var DownloadPopup = new Class({ Implements: [Events], Binds: ['close', 'submitClicked', 'onScroll'], initialize: function(__name,__modc) { this.name = __name; this.modc = __modc; this.setup(); }, containerDiv : 0, formDiv : 0, isOpen : false, setup: function() { this.containerDiv = new Element('div'); this.containerDiv.addClass('lightbox'); this.createHtml(); if (!SUPPORT_OPACITY) { this.containerDiv.setStyle('opacity', 0); this.formDiv.setStyle('opacity', 0); this.formDiv.setAnimationProperties(['opacity'], [OPEN_POPUP_SPEED], [''], [0]); } this.containerDiv.setAnimationProperties(['opacity'], [OPEN_POPUP_SPEED], [''], [0]); if (!SUPPORT_POSITION_FIXED) { window.addEvent('scroll', this.onScroll); } this.open(); this.resize(window.getSize().x, window.getSize().y); // $('submitDownloadForm').addEvent('click', this.submitClicked); }, onScroll: function(e) { var scrolled = window.getScroll().y, windowHeight = window.getSize().y, formHeight = this.formDiv.getSize().y, diff = windowHeight - formHeight, toTop = Math.round( scrolled + +(diff * .5) ); this.formDiv.setStyle('margin-top', toTop + 'px'); }, createHtml: function() { var bgDiv = new Element('div'); bgDiv.addClass('bg'); bgDiv.inject(this.containerDiv); bgDiv.addEvent('click', this.close); this.formDiv = new Element('div'); this.formDiv.addClass('contact-form-holder'); this.formDiv.inject(this.containerDiv); this.formDiv.set('html', this.getFormHtml()); this.formDiv.getElements('.close-popup-btn').addEvent('click', this.close); }, getFormHtml: function() { var html = '

Download

' + '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
Cancel
' + '' + ''; return html; }, submitClicked: function() { console.log('check'); var err=0; if(document.getElementById('dwl-name').value == '') {$('dwl-name').addClass('formerror'); err=1;} else $('dwl-name').removeClass('formerror'); if(document.getElementById('dwl-surname').value == '') {$('dwl-surname').addClass('formerror'); err=1;} else $('dwl-surname').removeClass('formerror'); if(document.getElementById('dwl-jobtitle').value == '') {$('dwl-jobtitle').addClass('formerror'); err=1;} else $('dwl-jobtitle').removeClass('formerror'); if(document.getElementById('dwl-company').value == '') {$('dwl-company').addClass('formerror'); err=1;} else $('dwl-company').removeClass('formerror'); if(document.getElementById('dwl-country').value == '') {$('dwl-country').addClass('formerror'); err=1;} else $('dwl-country').removeClass('formerror'); filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; if (!filter.test(document.getElementById('dwl-email').value)) {$('dwl-email').addClass('formerror'); err=1;} else $('dwl-email').removeClass('formerror'); if(err!=0) return false; // javascript:_gaq.push([\'_trackEvent\',\'form_contacto-global\',\'descargar\',\'ok\']); this.close(); // setTimeout('self.location="'+shareurl+'";',500); // DownloadPopup.showThankyouMsg(); //return true; //if (this.validateForm()) return true; //else return false; }, showThankyouMsg: function() { this.open(); $('lb-form-holder').setStyle('display', 'none'); $('lb-fail-holder').setStyle('display', 'none'); $('lb-thanks-holder').setStyle('display', 'block'); }, showFailedMsg: function() { this.open(); $('lb-form-holder').setStyle('display', 'none'); $('lb-thanks-holder').setStyle('display', 'none'); $('lb-fail-holder').setStyle('display', 'block'); }, open: function() { if (!this.isOpen) { this.isOpen = true; this.containerDiv.inject($$('body')[0]); var t = this; setTimeout(function() { //if (!SUPPORT_POSITION_FIXED) t.onScroll(); //will be called in resize() instead t.containerDiv.animateStyle('opacity', 1); if (!SUPPORT_OPACITY) t.formDiv.animateStyle('opacity', 1); }, 5); } }, close: function() { if (this.isOpen) { this.isOpen = false; this.containerDiv.animateStyle('opacity', 0); if (!SUPPORT_OPACITY) this.formDiv.animateStyle('opacity', 0); var t = this; setTimeout(function() { t.containerDiv.dispose(); t.fireEvent('popupClosed'); }, OPEN_POPUP_SPEED); } }, /* resize: function(w, h) { if (!SUPPORT_POSITION_FIXED) { var fullPageHeight = $$('.main')[0].getSize().y + $$('.main')[0].getPosition().y; this.containerDiv.setStyle('height', fullPageHeight + 'px'); this.onScroll(); } else { var toTop = Math.round( (h * .5) - (this.formDiv.getSize().y * .5) ); this.formDiv.setStyle('margin-top', toTop + 'px'); } } */ resize: function(w, h) { if (!SUPPORT_POSITION_FIXED) { var fullPageHeight = $$('.main')[0].getSize().y + $$('.main')[0].getPosition().y; this.containerDiv.setStyle('height', fullPageHeight + 'px'); this.onScroll(); } else { var toTop = Math.round( (h * .5) - (this.formDiv.getSize().y * .5) ); this.formDiv.setStyle('margin-top', toTop + 'px'); var isMobile = false; //initiate as false if( $('#show-menu').css('display')=='none') { is_mobile = true; } if (is_mobile == true) { var fullPageHeight = $$('.main')[0].getSize().y + $$('.main')[0].getPosition().y; this.containerDiv.setStyle('height', fullPageHeight + 'px'); this.onScroll(); } } } });