window.addEvent('domready', function(e){ set_carrot(); (function(){set_carrot();}).periodical(1500); var cb = $('contact_button'); if(cb){ toggle_contact_form(true); cb.addEvent('click', function(e){ toggle_contact_form(false); }); } init_tooltips(); var title = $('content_container').getElement('div.title .slider'); if(title){ title.set('slide', {duration: 800, transition: Fx.Transitions.Expo.easeOut}); //title.set('fade', {duration: 800, transition: Fx.Transitions.Expo.easeOut}); //title.fade('hide').fade('in'); title.slide('hide').slide('in'); } }); function set_carrot(){ var cur_nav = $('navigation').getElement('.current'); var carrot = $('page_carrot'); if(cur_nav && carrot){ var p = cur_nav.getPosition(); var s = cur_nav.getSize(); //alert(s.x + (p.x/2)); //carrot.setStyle('left', (p.x + (s.x/2))); //constant # is for margin carrot.morph({ 'margin-left': '0px', 'margin-top': '1px', left: (p.x + (s.x/2) - 7) + 'px' }); } } function toggle_contact_form(hide){ var cf = $('contact_area').getElement('.slider'); if(hide == false){ if(cf){ cf.slide('toggle'); $('name').focus(); } } else if(hide == true){ cf.slide('hide'); } } function init_tooltips(){ var tooltips = new Tips('.tooltip', {text:'', className: 'tooltipian'}); tooltips.addEvent('show', function(tip, el){ tip.fade('in'); }); tooltips.addEvent('hide', function(tip, el){ tip.fade('out'); }); } function submit_demo_request(){ var name = $('name'); var email = $('email'); var phone = $('phone'); var organization = $('organization'); var has_error = false; if(!not_empty(name)){ name.addClass('error'); has_error = true; }else{ name.removeClass('error'); } if(!not_empty(email) || !valid_email(email)){ email.addClass('error'); has_error = true; }else{ email.removeClass('error'); } if(!not_empty(phone)){ phone.addClass('error'); has_error = true; }else{ phone.removeClass('error'); } if(!not_empty(organization)){ organization.addClass('error'); has_error = true; }else{ organization.removeClass('error'); } if(!has_error){ var ajax_result = new Request({ url:'http://consciencium.com/remote/demo.php', method: 'post', onComplete: function(response){ if(response == '1'){ $('contact_form').getElement('.container').innerHTML = 'Thank you for requesting a demo. We have received your information and will contact you soon.'; $('contact_form').getElement('.contact_form_bottom').destroy(); return false; }else{ alert('There was an error processing your request. Please refresh this page and try again.'); return false; } } }).send($('contact_form').toQueryString() + random_time_qs()); }else{ return false; } return false; } function not_empty(el){ el.value = el.get('value').replace(/^[ \t]+|[ \t]+$/, ''); el.value = el.get('value').replace(/\s(\s)+/g, ' '); var val = el.get('value'); if(val != '' && val != ' '){ return true; }else{ return false; } } function valid_email(el){ var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if(!regex.test(el.value)){ return false; }else{ return true; } } function random_time_qs(){ var time_qs = "&randtime=" + $time(); return time_qs; }