$(document).ready(function(){ clearForms(); changeQuestion(); $('#leaving_site_popup').hide(); $('.external_link').click(function() { var link = $(this).attr('href'); $('#leaving_site_popup').modal(); $('#simplemodal-container').addClass('leaving_popup'); $('#simplemodal-container, .simplemodal-wrap').css({'height': '142px', 'z-index': '4000', 'width': '800px'}); $('.leave_site_go').click(function() { window.open(link, "mywindow"); return false; }); $('.close_leaving_popup').click(function() { $.modal.close(); return false; }) return false; }); $('.page2 .submit').click(function() { }); /* var wrapper_left_offset = $('#wrapper').offset().left - '10'; $('#importantSafetyCallout').css({'left': wrapper_left_offset + 'px'}); $(window).resize(function() { var wrapper_left_offset = $('#wrapper').offset().left - '10'; $('#importantSafetyCallout').css({'left': wrapper_left_offset + 'px'}); }); */ /* $("#panes div a").click(function() { var pane_link = $("#panes div a").attr('href'); window.scroll(0,1); window.location.href = pane_link; }); */ }); function clearForms() { var i; for (i = 0; (i < document.forms.length); i++) { document.forms[i].reset(); } } function changeQuestion(number) { $("input[name='question3']").removeAttr('checked'); $("input[name='question4']").removeAttr('checked'); $("input[name='question5']").removeAttr('checked'); $("input[name='question6']").removeAttr('checked'); $("input[name='question11']").removeAttr('checked'); $("input[name='question12a']").removeAttr('checked'); $("input[name='question12b']").removeAttr('checked'); $("input[name='question12c']").removeAttr('checked'); $("input[name='question12d']").removeAttr('checked'); $("input[name='question12e']").removeAttr('checked'); $("input[name='question13']").removeAttr('checked'); $("input[name='question14']").removeAttr('checked'); $("input[name='question15']").removeAttr('checked'); $("input[name='contactmethod']").removeAttr('checked'); $("input[name='question16']").removeAttr('checked'); switch(number) { case "1": $("input[name='question2']").removeAttr('checked'); $("input[name='question7']").removeAttr('checked'); $("input[name='question8']").removeAttr('checked'); $("input[name='question9']").removeAttr('checked'); $("input[name='question10']").removeAttr('checked'); break; case "2a": $("input[name='question7']").removeAttr('checked'); $("input[name='question8']").removeAttr('checked'); $("input[name='question9']").removeAttr('checked'); $("input[name='question10']").removeAttr('checked'); break; case "2b": $("input[name='question2']").removeAttr('checked'); $("input[name='question8']").removeAttr('checked'); $("input[name='question9']").removeAttr('checked'); $("input[name='question10']").removeAttr('checked'); break; case "5b": $("input[name='question2']").removeAttr('checked'); break; default: $("input[name='question1']").removeAttr('checked'); $("input[name='question2']").removeAttr('checked'); $("input[name='question7']").removeAttr('checked'); $("input[name='question8']").removeAttr('checked'); $("input[name='question9']").removeAttr('checked'); $("input[name='question10']").removeAttr('checked'); break; } } //show and hide a particular question (optional: clear old selection) function toggleQ(target,oldTarget,clear,strict){ if (oldTarget) { if (clear) { $('.'+oldTarget+' .question').hide(); } $('.'+oldTarget).hide(); $('.END').hide(); } $('.'+target).show(); } function nextPage(id, num) { var birth_year_error = $("label[for='yyyy']").text(); var birth_year_error2 = $("label[for='yyyy2']").text(); var $defaultmessage = $("label[for='mm']").text(); var $defaultmessage2 = $("label[for='mm2']").text(); var valid = $("#"+id+"form").valid(); if(valid) { $('#'+id+'_div .page'+(num-1)).hide(); $('#'+id+'_div .page'+num).fadeIn(); if (id == 'signup' && num == 2) { $('.signup_div_title').text('Step 2 of 3: Sign up for the latest news about PRADAXA.'); } if (id == 'signup' && num == 3) { $('.signup_div_title').text('Step 3 of 3: Sign up for the latest news about PRADAXA.'); } if (id == 'enroll' && num == 2) { $('.enroll_div_title').html('Step 2 of 3: Join The New Housecall support program by PRADAXA.'); } if (id == 'enroll' && num == 3) { $('#enroll_div h3').css({'width': '105%'}); $('.enroll_div_title').html('Step 3 of 3: Join The New Housecall support program by PRADAXA.'); } if (num > 1) { $('.sign_up_hide').hide(); } } if(!valid) { if (id == 'enroll' && $("label[for='mm2']").length > 0) { $("label[for='mm2']").text($defaultmessage2); } if (id == 'enroll' && $("label[for='mm2']").text() == '') { $("label[for='mm2']").text(birth_year_error2); } if (id == 'signup' && $("label[for='mm']").length > 0) { $("label[for='mm']").text($defaultmessage); } if (id == 'signup' && $("label[for='mm']").text() == '') { $("label[for='mm']").text(birth_year_error); } } } function toggleQ(target,oldTarget,clear,strict){ if (oldTarget) { if (clear) { $('.'+oldTarget+' .question').hide(); } $('.'+oldTarget).hide(); $('.END').hide(); } $('.'+target).show(); } function validDate(id,currentNumber){ if (currentNumber == "") { return; } newNumber = parseInt(currentNumber,10); if (isNaN(newNumber)) { return; } if (newNumber<10){ newNumber=('0'+newNumber); } document.getElementById(id).value = newNumber; } function clearForms() { var i; for (i = 0; (i < document.forms.length); i++) { document.forms[i].reset(); } } function process_signup() { var valid = check_contact("signupform"); if (valid == true) { $('#signupform').submit(); closeModal('signup'); } else { return; } } function process_enroll() { var valid = check_contact("enrollform"); if (valid == true) { $('#enrollform').submit(); closeModal('enroll'); } else { return; } } function process_unsubscribe() { var valid = check_contact("unsubscribeform"); if (valid == true) { // window.location.href="http://pradaxa21-staging.iinteractive.com/unsubscribe-confirmation.jsp"; _gaq.push(['_trackEvent', 'unsubscribe', 'completed', 'unsubscribe.jsp completion']); $('#unsubscribeform').submit(); } else { return; } } function process_reminder_unsubscribe() { var valid = check_contact("reminder_unsubscribe_form"); if (valid == true) { // window.location.href="http://pradaxa21-staging.iinteractive.com/reminders-unsubscribe-confirmation.jsp"; _gaq.push(['_trackEvent', 'reminders unsubscribe', 'completed', 'reminders-unsubscribe.jsp completion']); $('#reminder_unsubscribe_form').submit(); } else { return; } } function check_contact(formName) { var success = $("#"+formName).valid(); return success; } function external_link(destination) { $("#leaving_message").modal({overlayCss: {backgroundColor:"#000000"}}); $("#leaving_message").css("display","block"); $("#leaving_message").append("