/** * @author sudumalp */ var HOST_WITH_SSL; var HOST_WITHOUT_SSL; var SIGN_UP_ORIGIN = 'SignupOrigin'; var SIGN_UP_PAGETYPE = 'sign_up_page_type'; var LANDING_PAGE = 'landc'; var REGISTER_PAGE = 'regc'; var CITY_PAGE = 'cityPage'; var USER_REG = 'user_reg'; var LOGO_CONFIRMATION = 'logo_c'; var HP_ONBOARDING_STEP1_STARTED = 'HP Onboarding V4 Step 1 Started' var localStorageKeysArray = ["ngStorage-ownership","ngStorage-country","ngStorage-state","ngStorage-industry","ngStorage-industryCode", "ngStorage-sector","ngStorage-employeemin","ngStorage-employeemax","ngStorage-revenuemin","ngStorage-revenuemax", "ngStorage-fundingmin","ngStorage-fundingmax","ngStorage-agemin","ngStorage-agemax","ngStorage-zipcodes"]; setCookie(SIGN_UP_PAGETYPE, 0, 120) function initializeUrls(appUrl) { HOST_WITH_SSL = appUrl + "/"; HOST_WITHOUT_SSL = HOST_WITH_SSL; } function getTargetURL() { var targetURL = $( "input#targetURL") .val(); var hashParam = window.location.hash .substr(1); if (targetURL == "" || targetURL == 'null') { targetURL = HOST_WITHOUT_SSL + "home.htm"; } if (hashParam != undefined && targetURL != undefined && hashParam != "") { targetURL = targetURL + "#" + hashParam; } return targetURL; } function closeSignInLink(){ resetForm($('#signInForm')); $(".showLogin #signInFormResponseDivContainer .button_submit").attr("onclick","tb_remove()"); $("#signInFormResponseDivContainer").hide(); $("#signInFormDiv").removeClass("showLogin"); $("#pageless-onboarding-popup").show(); } var urlPrefixRegExPattern = new RegExp("(http|ftp|https):\/\/"); $(function() { var SUCCESS_STRING = "1"; var AUTO_LOGIN_SUCCESS_STRING = "5"; /* URL Validation in server */ $.validator.addMethod("validateURLInServer", function(value, element) { var isSuccess = false; var responseRecevied = false; $.ajax({ type : "POST", url : HOST_WITHOUT_SSL + "validateURL.htm?", data : "url=" + value, async : false, success : function(data, textStatus, jQXHr) { responseRecevied = true; var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { isSuccess = true; } else { } }, error : function(msg) { responseRecevied = true; isSuccess = false; } }); return isSuccess; }, "Please enter a valid URL"); /* URL - validation */ $.validator .addMethod( "validateURL", function(value, element) { return this.optional(element) || /^((https?|ftp):\/\/){0,1}(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i .test(value); }, "Please enter a valid URL"); /* Email - validation */ $.validator .addMethod( "emailValidation", function(value, element) { return this.optional(element) || validateEmail(value); }, "Please enter a valid email address"); /* Only UTF-8 characters except the ASCII - validation */ $.validator.addMethod("unicodeValidation", function(value, element) { return this.optional(element) || /^[\x00-\x7F]+$/i.test(value); }, "Please enter without any junk characters"); /* Numeric - validation */ $.validator.addMethod("numberValidation", function(value, element) { return this.optional(element) || /^[0-9!@#$%^&*()_]{1,16}$/i.test(value); }, "Please enter only numbers"); /* Numeric - validation with two decimal place values */ $.validator.addMethod("paymentValidation", function(value, element) { return this.optional(element) || /^[0-9]+(\.[0-9]{1,2})?$/i.test(value); }, "Please enter only numbers"); /* ccv no - validation */ $.validator .addMethod( "ccvValidation", function(value, element) { return this.optional(element) || /^[0-9]{3,4}$/i.test(value); }, "Please enter 4 digits number for AMEX card and 3 digits number for all other cards"); /* Not Equal - validation */ $.validator.addMethod("notEqual", function(value, element, param) { return this.optional(element) || value != $(param).val(); }, "This has to be different..."); /* Only Alphabets with space and dot allowed - validation */ $.validator.addMethod("onlyAlpabets", function(value, element) { return this.optional(element) || /^[a-zA-Z\s\.]+$/i.test(value); }, "Please enter only alphabets"); /* * Only Alphabets and Numbers without space and special characters - * validation */ $.validator.addMethod("alpaNumericNoSpace", function(value, element) { return this.optional(element) || /^[0-9a-zA-Z]+$/i.test(value); }, "Please enter only alpha numeric values without space"); $.validator.addMethod("require_from_group", function(value, element, options) { // var selector = options[1]; // var validOrNot = $(selector, element.form).filter(function() { // return $(this).val(); // }).length >= options[0]; var numberRequired = options[0], selector = options[1], $fields = $( selector, element.form), validOrNot = $fields .filter(function() { return $(this).val(); }).length >= numberRequired, validator = this; if (!$(element).data('being_validated')) { $fields.data('being_validated', true).each(function() { validator.valid(this); }).data('being_validated', false); } // if(!$(element).data('being_validated')) { // var fields = $(selector, element.form); // fields.data('being_validated', true); // fields.valid(); // fields.data('being_validated', false); // } // if(validOrNot){ // $("#form_error").hide(); // }else{ // $("#form_error").show(); // } return validOrNot; }, jQuery.format("Please fill at least {0} of these fields.")); /* Login Link - Click event */ /*************** Home Page LinkedIn click ****************************8*/ $("#linkedInLink").click(function(){ setPageTypeCookie(); var popupOrigin = getUrlParameter('Origin'); if(popupOrigin!=''&&popupOrigin!=null) { setCookie(SIGN_UP_ORIGIN, popupOrigin, 120); } else { setCookie(SIGN_UP_ORIGIN,'Home Page', 120); } }); $("#signInLink") .click( function() { setCookie(SIGN_UP_ORIGIN, 'Login Popup', 120); setPageTypeCookie('Home Page') tb_show('', '#TB_inline?height=305&width=470&inlineId=signInFormDiv'); signInForm.resetForm(); resetForm($('#signInForm')); var emailAddress = document .getElementById("emailAddressFromCookie").value; if (emailAddress != '') { $('#emailSignIn').val(emailAddress); $('#rememberMyEmailAddress').attr('checked', true); } $("#signupFormDivContainer").hide(); $("#signInFormResponseDivContainer").hide(); $('#signInFormDivContainer').show(); $('#loginError').hide(); setTimeout(function() { $("#emailSignIn").focus(); }, 500); }); $("#registerList").click(function() { $('#signInFormDivContainer').hide(); $("#registerListFormDivContainer").show(); return false; }); $("#signInLinkFromSignup") .click( function() { $("#signupFormDivContainer").hide(); $("#signInFormDivContainer").show(); tb_show("Login", "#TB_inline?height=445&width=490&inlineId=signInFormDiv"); }); $(".login-close-popup").click(function(){ resetForm($('#signInForm')); $("#signInFormDiv").removeClass("showLogin"); $("#pageless-onboarding-popup").show(); }); /* Forgot Password Link - Click event */ $("#forgotPasswordLink") .click( function() { resetPasswordRequestValidator.resetForm(); $("#resetPasswordRequestSuccessDiv").hide(); $("#resetPasswordError").hide(); $('#signInFormDivContainer').hide(); $('#resetPasswordRequestDivContainer').show(); $("#resetPasswordRequestErrorDiv").hide(); $("#resetPasswordRequestSuccessDiv").hide(); $("#resetPasswordRequestSuccessDiv").html(""); $("#resetPasswordRequestEmailSignIn").val(""); $("#resetPasswordTable").show(); $('#resetPasswordRequestEmailSignIn').removeClass( 'error'); tb_remove(); setTimeout( function() { tb_show("Forgot Password", "#TB_inline?height=210&width=480&inlineId=resetPasswordRequestDiv"); }, 500); return false; }); $("#mobile_forgotPasswordLink") .click( function() { $('#resetPasswordRequestDivContainer').show(); $("#resetPasswordRequestErrorDiv").hide(); $("#resetPasswordRequestSuccessDiv").hide(); $("#resetPasswordRequestSuccessDiv").html(""); $("#resetPasswordRequestEmailSignIn").val(""); $("#resetPasswordTable").show(); $('#resetPasswordRequestEmailSignIn').removeClass( 'error'); tb_remove(); setTimeout( function() { tb_show("Forgot Password", "#TB_inline?height=210&width=480&inlineId=resetPasswordRequestDiv"); }, 500); return false; }); $(".close-popup").click(function() { tb_remove(); }); /* Sign up Link inside register list popup - Click event */ $("#sign_up") .click( function() { resetForm($("#signupForm")); $("#signupError").hide(); $("#signupFormDivContainer").show(); $('#registerListFormDivContainer').hide(); tb_show("Sign up to Create an Account", "#TB_inline?height=345&width=505&inlineId=signupFormDiv"); return false; }); /* Register list Link inside login/sign-in popup - Click event */ $("#registerList") .click( function() { $('#signInFormDivContainer').hide(); $("#registerListFormDivContainer").show(); tb_show("Register to Create an Account", "#TB_inline?height=460&width=460&inlineId=registerListFormDiv"); return false; }); /* Add Company Link - Click event */ $("#addCompanyLink").click(function() { resetForm($("#addCompanyForm")); $("#addCompanySucccessMessageDiv").hide(); $("#addCompanyError MessagesDiv").html(""); }); /* Add Company Cancel Button - Click event */ $("#addCompanyCancel").click(function() { resetForm($("#addCompanyForm")); tb_remove(); }); /* Send Button clicked - Click event */ $("#referralEmailConfirmationOk").click(function() { $("#referralEmailConfirmationDiv").hide(); tb_remove(); }); /* Add User Link - Click event */ $("#addUserLink").click(function() { $('#signInFormDivContainer').validate().resetForm(); $('#resetPasswordRequestDivContainer').hide(); $('#signInFormDivContainer').show(); $("#email").val(""); $("#password").val(""); $("#signInErrorMessagesDiv").hide(); $("#signInErrorMessagesDiv").html(""); }); /* Sign out Link - Click event */ $("#signOutLink").click(function() { signout(); }); $("#sign_out").click(function(){ signout(); }); // This is for liferay marketing pages $("#signout").click(function(){ signout(); }); /* Resend Confirmation Button - Click event */ $("#resendCloseButton").click(function() { $("#resendConfirmationDiv").hide(); }); /* Confirmation Button - Click event */ $("#confirmationOk").click(function() { $("#confirmationDiv").hide(); tb_remove(); }); /* Sign in link - Click event */ $(".login_link a").click(function() { $('#signInFormDivContainer').show(); $('#resetPasswordRequestDivContainer').hide(); }); /* Referral Researcher Link - Click event */ $("#referralResearcherLink").click(function() { resetForm($("#recruitResearcher")); $(".alert_success").hide(); }); $('.pg4 .email-signup-link').click(function() { $('.pg4 .signup_box').hide(); $('.pg4 .registeration_box').show(); setCookie(SIGN_UP_ORIGIN, 'Home Page Registration Box', 120) }); $('.pg4 .signup_social a').click(function() { setCookie(SIGN_UP_ORIGIN, 'Home Page Registration Box', 120) registerFormFiveValidator.resetForm(); resetForm($("#registerForm5")); $('.pg4 .registeration_box').hide(); $('.pg4 .signup_box').show(); }); /* Referral Form submission */ $("#emailreferralform") .validate( { rules : { referralemail1 : { require_from_group : [ 1, ".referralemailgroup" ], emailValidation : true }, referralemail2 : { require_from_group : [ 1, ".referralemailgroup" ], emailValidation : true }, referralemail3 : { require_from_group : [ 1, ".referralemailgroup" ], emailValidation : true }, referralemail4 : { require_from_group : [ 1, ".referralemailgroup" ], emailValidation : true }, referralemail5 : { require_from_group : [ 1, ".referralemailgroup" ], emailValidation : true }, }, messages : { referralemail1 : { emailValidation : "Please enter a valid email address" }, referralemail2 : { emailValidation : "Please enter a valid email address" }, referralemail3 : { emailValidation : "Please enter a valid email address" }, referralemail4 : { emailValidation : "Please enter a valid email address" }, referralemail5 : { emailValidation : "Please enter a valid email address" } }, errorElement : "span", wrapper : "span", // a wrapper around the error // message errorPlacement : function(error, element) { element.before(error); error.addClass('form_error_message_right'); error.append(""); offset = element.offset(); error.css('left', $(element).position().left + $(element).width() + 10); error.css('top', $(element).position().top + $(element).height() - 20); }, submitHandler : function() { var referralemail1 = $("#referralemail1").val(); var referralemail2 = $("#referralemail2").val(); var referralemail3 = $("#referralemail3").val(); var referralemail4 = $("#referralemail4").val(); var referralemail5 = $("#referralemail5").val(); var dataString = "referralemail1=" + referralemail1 + "&referralemail2=" + referralemail2 + "&referralemail3=" + referralemail3 + "&referralemail4=" + referralemail4 + "&referralemail5=" + referralemail5; var url = HOST_WITH_SSL + "emailreferral.htm?"; $("#TB_window") .append( ""); $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jQXHr) { var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { $('#recruitResearcher').hide(); $(".popup_overlay").remove(); $( '#referralEmailConfirmationSuccessDiv') .html(response.message); tb_show("Confirmation", "#TB_inline?height=130&width=470&inlineId=referralEmailConfirmationDiv"); } else { $('#recruitResearcher').hide(); $(".popup_overlay").remove(); tb_show("Confirmation", "#TB_inline?height=130&width=470&inlineId=referralEmailConfirmationDiv"); $( '#referralEmailConfirmationErrorDiv') .html(response.message); } }, error : function(data, textStatus, jQXhr) { $('#recruitResearcher').hide(); $(".popup_overlay").remove(); tb_show("Confirmation", "#TB_inline?height=130&width=470&inlineId=referralEmailConfirmationDiv"); $('#referralEmailConfirmationErrorDiv').html = data; } }); return false; } }); /* Resend email notification */ $("#resend") .click( function() { var email = $("span#emailContent").html(); var url = HOST_WITHOUT_SSL + "resend.htm?"; $('#resend').attr("disabled", true); $("#TB_window") .append( ""); var dataString = "email=" + email; $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jQXHr) { var response = $.parseJSON(data); if (response.result = SUCCESS_STRING) { $("span#emailContent").html(email); $(".popup_overlay").remove(); $('#resend') .attr("disabled", false); } else { $(".popup_overlay").remove(); $("#confirmationErrorDiv p").html = response.message; $('#resend') .attr("disabled", false); } }, error : function(data, textStatus, jQXhr) { $("#confirmationErrorDiv p").html = data; $(".popup_overlay").remove(); } }); }); /* Register form in homepage */ var registerFormValidator = $("#registerForm") .validate( { rules : { email : { required : true, emailValidation : true }, password : { required : true, minlength : 6 }, confirmPassword : { equalTo : "#password" } }, messages : { email : { required : "Please enter a valid email address", emailValidation : "Please enter a valid email address" }, password : { required : "Please enter a password", minlength : "Password must be at least 6 characters" }, confirmPassword : { equalTo : "Passwords do not match" } }, errorElement : "span", wrapper : "span", // a wrapper around the error // message errorPlacement : function(error, element) { element.before(error); error.addClass('form_error_message'); error.append(""); offset = element.offset(); if (($(element).attr("id") == "fname") || ($(element).attr("id") == "lname")) { error.css('left', $(element).position().left + $(element).width() - 260 + 100); error.css('top', $(element).position().top + $(element).height() - 55); } else { error.css('left', $(element).position().left + $(element).width() - 210); error.css('top', $(element).position().top + $(element).height() - 55); } }, submitHandler : function() { var emailValue = $("input#email").val(); var password = $("input#password").val(); var dataString = "email=" + emailValue + "&password=" + password; $('#register').attr("disabled", true); var url = HOST_WITH_SSL + "addVisitor.htm?"; $("#registerForm") .append( ""); $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jQXHr) { var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { trackMixpanelLoginEvent(response,getCallBckFn()); $('#register').attr("disabled", false); tb_remove(); setTimeout( function() { tb_show( "", "#TB_inline?height=280&width=520&inlineId=registerThanksDiv&modal=true"); }, 500); $("#profilename").val( response.screenName); $('#confirmationDivContainer') .show(); } else { $("#registerError").html( response.message); $('#registerError').show(); $(".popup_overlay").remove(); $('#register').attr("disabled", false); } }, error : function(data, textStatus, jQXhr) { $("#registerError").html = data; $(".popup_overlay").remove(); $('#register').attr("disabled", false); } }); return false; } }); var registerFormTwoValidator = $("#registerForm1") .validate( { rules : { email : { required : true, emailValidation : true }, password : { required : true, minlength : 6 }, confirmPassword : { equalTo : "#password1" } }, messages : { email : { required : "Please enter a valid email address", emailValidation : "Please enter a valid email address" }, password : { required : "Please enter a password", minlength : "Password must be at least 6 characters" }, confirmPassword : { equalTo : "Passwords do not match" } }, errorElement : "span", wrapper : "span", // a wrapper around the error // message errorPlacement : function(error, element) { element.before(error); error.addClass('form_error_message'); error.append(""); offset = element.offset(); if (($(element).attr("id") == "fname") || ($(element).attr("id") == "lname")) { error.css('left', $(element).position().left + $(element).width() - 260 + 100); error.css('top', $(element).position().top + $(element).height() - 55); } else { error.css('left', $(element).position().left + $(element).width() - 210); error.css('top', $(element).position().top + $(element).height() - 55); } }, submitHandler : function() { var emailValue = $("input#email1").val(); var password = $("input#password1").val(); var dataString = "email=" + emailValue + "&password=" + password; $('#register1').attr("disabled", true); var url = HOST_WITH_SSL + "addVisitor.htm?"; $("#registerForm1") .append( ""); $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jQXHr) { var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { trackMixpanelLoginEvent(response,getCallBckFn()); $('#register1').attr( "disabled", false); tb_remove(); setTimeout( function() { tb_show( "", "#TB_inline?height=280&width=520&inlineId=registerThanksDiv&modal=true"); }, 500); $("#profilename").val( response.screenName); $('#confirmationDivContainer') .show(); } else { $("#registerError1").html( response.message); $('#registerError1').show(); $(".popup_overlay").remove(); $('#register1').attr( "disabled", false); } }, error : function(data, textStatus, jQXhr) { $("#registerError1").html = data; $(".popup_overlay").remove(); $('#register1').attr("disabled", false); } }); return false; } }); var registerFormTwoValidator = $("#registerForm2") .validate( { rules : { email : { required : true, emailValidation : true }, password : { required : true, minlength : 6 }, confirmPassword : { equalTo : "#password2" } }, messages : { email : { required : "Please enter a valid email address", emailValidation : "Please enter a valid email address" }, password : { required : "Please enter a password", minlength : "Password must be at least 6 characters" }, confirmPassword : { equalTo : "Passwords do not match" } }, errorElement : "span", wrapper : "span", // a wrapper around the error // message errorPlacement : function(error, element) { element.before(error); error.addClass('form_error_message'); error.append(""); offset = element.offset(); if (($(element).attr("id") == "fname") || ($(element).attr("id") == "lname")) { error.css('left', $(element).position().left + $(element).width() - 260 + 100); error.css('top', $(element).position().top + $(element).height() - 55); } else { error.css('left', $(element).position().left + $(element).width() - 210); error.css('top', $(element).position().top + $(element).height() - 55); } }, submitHandler : function() { var emailValue = $("input#email2").val(); var password = $("input#password2").val(); var dataString = "email=" + emailValue + "&password=" + password; $('#register2').attr("disabled", true); var url = HOST_WITH_SSL + "addVisitor.htm?"; $("#registerForm2") .append( ""); $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jQXHr) { trackMixpanelLoginEvent(response,getCallBckFn()); var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { $('#register2').attr( "disabled", false); tb_remove(); setTimeout( function() { tb_show( "", "#TB_inline?height=280&width=520&inlineId=registerThanksDiv&modal=true"); }, 500); $("#profilename").val( response.screenName); $('#confirmationDivContainer') .show(); } else { $("#registerError2").html( response.message); $('#registerError2').show(); $(".popup_overlay").remove(); $('#register2').attr( "disabled", false); } }, error : function(data, textStatus, jQXhr) { $("#registerError2").html = data; $(".popup_overlay").remove(); $('#register2').attr("disabled", false); } }); return false; } }); var registerFormThreeValidator = $("#registerForm3") .validate( { rules : { email : { required : true, emailValidation : true }, password : { required : true, minlength : 6 }, confirmPassword : { equalTo : "#password3" } }, messages : { email : { required : "Please enter a valid email address", emailValidation : "Please enter a valid email address" }, password : { required : "Please enter a password", minlength : "Password must be at least 6 characters" }, confirmPassword : { equalTo : "Passwords do not match" } }, errorElement : "span", wrapper : "span", // a wrapper around the error // message errorPlacement : function(error, element) { element.before(error); error.addClass('form_error_message'); error.append(""); offset = element.offset(); if (($(element).attr("id") == "fname") || ($(element).attr("id") == "lname")) { error.css('left', $(element).position().left + $(element).width() - 260 + 100); error.css('top', $(element).position().top + $(element).height() - 55); } else { error.css('left', $(element).position().left + $(element).width() - 210); error.css('top', $(element).position().top + $(element).height() - 55); } }, submitHandler : function() { var emailValue = $("input#email3").val(); var password = $("input#password3").val(); var dataString = "email=" + emailValue + "&password=" + password; $('#register3').attr("disabled", true); var url = HOST_WITH_SSL + "addVisitor.htm?"; $("#registerForm3") .append( ""); $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jQXHr) { var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { trackMixpanelLoginEvent(response,getCallBckFn()); $('#register3').attr( "disabled", false); tb_remove(); setTimeout( function() { tb_show( "", "#TB_inline?height=280&width=520&inlineId=registerThanksDiv&modal=true"); }, 500); $("#profilename").val( response.screenName); $('#confirmationDivContainer') .show(); } else { $("#registerError3").html( response.message); $('#registerError3').show(); $(".popup_overlay").remove(); $('#register3').attr( "disabled", false); } }, error : function(data, textStatus, jQXhr) { $("#registerError3").html = data; $(".popup_overlay").remove(); $('#register3').attr("disabled", false); } }); return false; } }); var registerFormFourValidator = $("#registerForm4") .validate( { rules : { email : { required : true, emailValidation : true }, password : { required : true, minlength : 6 }, confirmPassword : { equalTo : "#password4" } }, messages : { email : { required : "Please enter a valid email address", emailValidation : "Please enter a valid email address" }, password : { required : "Please enter a password", minlength : "Password must be at least 6 characters" }, confirmPassword : { equalTo : "Passwords do not match" } }, errorElement : "span", wrapper : "span", // a wrapper around the error // message errorPlacement : function(error, element) { element.before(error); error.addClass('form_error_message'); error.append(""); offset = element.offset(); if (($(element).attr("id") == "fname") || ($(element).attr("id") == "lname")) { error.css('left', $(element).position().left + $(element).width() - 260 + 100); error.css('top', $(element).position().top + $(element).height() - 55); } else { error.css('left', $(element).position().left + $(element).width() - 210); error.css('top', $(element).position().top + $(element).height() - 55); } }, submitHandler : function() { var emailValue = $("input#email4").val(); var password = $("input#password4").val(); var dataString = "email=" + emailValue + "&password=" + password; $('#register4').attr("disabled", true); var url = HOST_WITH_SSL + "addVisitor.htm?"; $("#registerForm4") .append( ""); $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jQXHr) { var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { trackMixpanelLoginEvent(response,getCallBckFn()); $('#register4').attr( "disabled", false); tb_remove(); setTimeout( function() { tb_show( "", "#TB_inline?height=280&width=520&inlineId=registerThanksDiv&modal=true"); }, 500); $("#profilename").val( response.screenName); $('#confirmationDivContainer') .show(); trackSignupStep2Event(response.member_id) } else { $("#registerError4").html( response.message); $('#registerError4').show(); $(".popup_overlay").remove(); $('#register4').attr( "disabled", false); } }, error : function(data, textStatus, jQXhr) { $("#registerError4").html = data; $(".popup_overlay").remove(); $('#register4').attr("disabled", false); } }); return false; } }); var registerFormFiveValidator = $("#registerForm5") .validate( { rules : { email : { required : true, emailValidation : true }, password : { required : true, minlength : 6 }, confirmPassword : { equalTo : "#password5" } }, messages : { email : { required : "Please enter a valid email address", emailValidation : "Please enter a valid email address" }, password : { required : "Please enter a password", minlength : "Password must be at least 6 characters" }, confirmPassword : { equalTo : "Passwords do not match" } }, errorElement : "span", wrapper : "span", // a wrapper around the error // message errorPlacement : function(error, element) { element.before(error); error.addClass('form_error_message'); error.append(""); offset = element.offset(); if (($(element).attr("id") == "fname") || ($(element).attr("id") == "lname")) { error.css('left', $(element).position().left + $(element).width() - 260 + 100); error.css('top', $(element).position().top + $(element).height() - 55); } else { error.css('left', $(element).position().left + $(element).width() - 210); error.css('top', $(element).position().top + $(element).height() - 55); } }, submitHandler : function() { setCookie(SIGN_UP_ORIGIN, 'Home Page Registration Box', 120) var emailValue = $("input#email5").val(); var password = $("input#password5").val(); var dataString = "email=" + emailValue + "&password=" + password; $('#register5').attr("disabled", true); var url = HOST_WITH_SSL + "addVisitor.htm?"; $("#registerForm5") .append( ""); $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jQXHr) { var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { trackMixpanelLoginEvent(response,getCallBckFn()); $('#register5').attr( "disabled", false); tb_remove(); setTimeout( function() { tb_show( "", "#TB_inline?height=280&width=520&inlineId=registerThanksDiv&modal=true"); }, 500); $("#profilename").val( response.screenName); $('#confirmationDivContainer') .show(); trackSignupStep2Event(response.member_id) } else { $("#registerError5").html( response.message); $('#registerError5').show(); $(".popup_overlay").remove(); $('#register5').attr( "disabled", false); } }, error : function(data, textStatus, jQXhr) { $("#registerError5").html = data; $(".popup_overlay").remove(); $('#register5').attr("disabled", false); } }); return false; } }); $.validator .addMethod( "profileNameExists", function(value, element) { var isProfileNameNotExists = true; var result = this.optional(element) || /^[0-9a-zA-Z]+$/i.test(value); if (result == false) { $.validator.messages.profileNameExists = 'No special characters allowed'; return result; } $('#profilename').attr('readonly', true); $('#profilename1').attr('readonly', true); $ .ajax({ type : "POST", url : HOST_WITH_SSL + "/profileNameExists.htm?", data : "profilename=" + value, async : false, success : function(data, textStatus, jQXHr) { responseRecevied = true; var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { $('#profilename').attr('readonly', false); $('#profilename1').attr('readonly', false); isProfileNameNotExists = true; } else { $('#profilename').attr('readonly', false); $('#profilename1').attr('readonly', false); isProfileNameNotExists = false; $.validator.messages.profileNameExists = response.message; } }, error : function(msg) { responseRecevied = true; isProfileNameNotExists = false; $('span.available').remove(); $('span.notavailable').remove(); } }); return isProfileNameNotExists; }, "profile name already exists..."); var regSuccessFormValidator = $("#regSuccessForm") .validate( { rules : { profilename : { required : true, minlength : 4, profileNameExists : true } }, messages : { profilename : { required : "Please enter your public profile name", minlength : "Must consist of 4 characters and no spaces" } }, errorElement : "span", wrapper : "span", // a wrapper around the error // message errorPlacement : function(error, element) { element.before(error); error.addClass('form_error_message'); error.append(""); offset = element.offset(); if (($(element).attr("id") == "fname") || ($(element).attr("id") == "lname")) { error.css('left', $(element).position().left + $(element).width() - 260 + 100); error.css('top', $(element).position().top + $(element).height() - 55); } else { error.css('left', $(element).position().left + $(element).width() - 155); error.css('top', $(element).position().top + $(element).height() - 55); } }, submitHandler : function() { var time_Zone_Offset = new Date().getGmtOffset(); var firstName = ""; var lastName = ""; var profileName = $("input#profilename").val(); var profilePicture = ""; var dataString = "firstname=" + firstName + "&lastname=" + lastName + "&profilename=" + profileName + "&profilepicture=" + profilePicture+'&timeZone='+time_Zone_Offset $('#continueRegisterThanks').prop('disabled', true); var url = HOST_WITH_SSL + "/updatePublicProfile.htm?"; $("#TB_window") .append( ""); $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jQXHr) { var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { $("#registerThanksDiv").hide(); tb_remove(); // Now go inside application var targetURL = $( "input#targetURL") .val(); var hashParam = window.location.hash .substr(1); if (targetURL == "" || targetURL == 'null') { targetURL = HOST_WITHOUT_SSL + "home.htm"; } if (hashParam != undefined && targetURL != undefined && hashParam != "") { targetURL = targetURL + "#" + hashParam; } window.location.href = targetURL; } else { $("#regSuccessFormErrorDiv p") .html(response.message); $('#regSuccessFormErrorDiv') .show(); $(".popup_overlay").remove(); $('#continueRegisterThanks') .attr("disabled", false); } }, error : function(data, textStatus, jQXhr) { $("#regSuccessFormErrorDiv p").html = data; $(".popup_overlay").remove(); $('#continueRegisterThanks').attr( "disabled", false); } }); return false; } }); var regSocialSuccessFormValidator = $("#regSocialSuccessForm") .validate( { rules : { profilename1 : { required : true, minlength : 4, profileNameExists : true } }, messages : { profilename1 : { required : "Please enter your public profile name", minlength : "Must consist of 4 characters and no spaces" } }, errorElement : "span", wrapper : "span", // a wrapper around the error // message errorPlacement : function(error, element) { element.before(error); error.addClass('form_error_message'); error.append(""); offset = element.offset(); if (($(element).attr("id") == "fname") || ($(element).attr("id") == "lname")) { error.css('left', $(element).position().left + $(element).width() - 260 + 100); error.css('top', $(element).position().top + $(element).height() - 55); } else { error.css('left', $(element).position().left + $(element).width() - 155); error.css('top', $(element).position().top + $(element).height() - 55); } }, submitHandler : function() { var time_Zone_Offset = new Date().getGmtOffset(); var firstName = ""; var lastName = ""; var profileName = $("input#profilename1").val(); var profilePicture = ""; var dataString = "firstname=" + firstName + "&lastname=" + lastName + "&profilename=" + profileName + "&profilepicture=" + profilePicture+'&timeZone='+time_Zone_Offset $('#continueRegisterThanks').prop('disabled', true); var url = HOST_WITH_SSL + "/updatePublicProfile.htm?"; $("#TB_window") .append( ""); $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jQXHr) { var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { $("#registerThanksDivSocial") .hide(); tb_remove(); // Now go inside application var targetURL = $( "input#targetURL") .val(); var hashParam = window.location.hash .substr(1); if (targetURL == "" || targetURL == 'null') { targetURL = HOST_WITHOUT_SSL + "home.htm"; } if (hashParam != undefined && targetURL != undefined && hashParam != "") { targetURL = targetURL + "#" + hashParam; } window.location .assign(targetURL); } else { $( "#regSocialSuccessFormErrorDiv p") .html(response.message); $( '#regSocialSuccessFormErrorDiv') .show(); $(".popup_overlay").remove(); $( '#continueSocialRegisterThanks') .attr("disabled", false); } }, error : function(data, textStatus, jQXhr) { $("#regSocialSuccessFormErrorDiv p").html = data; $(".popup_overlay").remove(); $('#continueSocialRegisterThanks') .attr("disabled", false); } }); return false; } }); $("#webSignupLink").click(function() { showRegistrationPopUp('Home Page Top Image'); }); function showRegistrationPopUp(origin) { tb_show('', '#TB_inline?height=180&width=475&inlineId=signupFormDiv'); resetForm($('#signupForm')); $('#signupErrorMessagesDiv').html(""); $('#signupError').hide(); $('#signupFormDivContainer').show(); $('#signupErrorMessagesDiv').hide(); $('#signupErrorMessagesDiv').html(""); $('.label-hide').show(); setCookie(SIGN_UP_ORIGIN, origin, 120); } $("#mobileSignupLink").click(function() { window.location.href = "mobileSignUp.htm"; }); $("#signupLink2").click(function() { showRegistrationPopUp('Banner Images') }); $("#webSignupLink1").click(function() { showRegistrationPopUp('Signup Button') }); $("#mobileSignupLink1").click(function() { window.location.href = "mobileSignUp.htm" }); $("#registerLink").click(function() { tb_remove(); $("#registerListFormDivContainer").show(); }); $(document) .on( 'click', '.have_account', function() { tb_init(); signInForm.resetForm(); document.getElementById("targetUrl").value = "browsecompanyprofiles.htm"; $("#signInFormDivContainer").show(); tb_show("Login", "#TB_inline?height=275&width=405&inlineId=signInFormDiv"); $('#signupFormDivInBuyReportsContainer').hide(); $("#resetPasswordRequestDivContainer").hide(); setTimeout(function() { $("#buy_email").focus(); }, 200); }); function showSignupForm() { $('#signupFormDivContainer').show(); resetForm($('#signupForm')); $('#confirmationDivContainer').hide(); $('#signupErrorMessagesDiv').html(""); $('#signupError').hide(); $('#signupFormDivContainer').show(); $('#signupErrorMessagesDiv').hide(); $('#signupErrorMessagesDiv').html(""); $('.label-hide').show(); } $("#signuplink1").click(function() { showSignupForm(); }); $("#signuplink2").click(function() { showSignupForm(); }); /* Sign in Form */ var showSignInErrorMsg = function(data){ $(".domain_error_message").remove(); $('#emailSignIn').after("
"); $(".domain_error_message span.error").html(data); $(".domain_error_message").show(); $(".popup_overlay").remove(); } var signInForm = $("#signInForm") .validate( { rules : { emailSignIn : { required : true, emailValidation : true } }, messages : { emailSignIn : { required : "Please enter a valid email address", emailValidation : "Please enter a valid email address" } }, errorElement : "span", wrapper : "div", // a wrapper around the error // message errorPlacement : function(error, element) { $(".domain_error_message").remove(); $('#emailSignIn').after(error); error.addClass('domain_error_message'); error.prepend(""); offset = element.offset(); }, submitHandler : function(form) { var emailValue = $("input#emailSignIn").val(); var targetURL = window.location.href; var pageType =$('#pageType').val(); if(pageType != undefined && pageType == CITY_PAGE) { var landingPageUrl=$('#landingPageUrl').val(); targetURL=landingPageUrl; } var dataString; if(window.currentPage =='index'){ dataString= "email=" + emailValue; }else { dataString= "email=" + emailValue+"&targetURL="+ targetURL; } var url = HOST_WITH_SSL + "requestSignInLink.htm?"; $("#TB_window") .append( ""); $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jqXhr) { var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { $(".popup_overlay").remove(); $("#signInFormDivContainer").hide(); $("#signInFormResponseDivContainer").show(); var pageTypeProp={}; var pageType=document.getElementById("originPage") var timeStamp = new Date().toUTCString(); if( pageType!= undefined &&pageType != null){ pageTypeProp['Page Type']=pageType.value }else{ pageTypeProp['Page Type']=window.currentPage } pageTypeProp['UserId']=response.memberId; pageTypeProp['Timestamp']= timeStamp; pageTypeProp['Email Id']= $("input#emailSignIn").val(); trackMixpanelEvent('User sign in request',pageTypeProp) } else if (response.result == '3') { showSignInErrorMsg("Your account has been locked. Please contact support@owler.com if you feel this has been in error"); $("#signInForm input").removeClass("valid"); } else if(response.result == AUTO_LOGIN_SUCCESS_STRING) { trackSignInRequest(response.memberId,emailValue,'User sign in request',true, undefined) } else { showSignInErrorMsg(response.message); $("#signInForm input").removeClass("valid"); } }, error : function(data, textStatus, jqXHr) { showSignInErrorMsg(data); } }); return false; } }); /* Sign in Form */ var mobileSignInForm = $("#mobileSignInForm") .validate( { rules : { emailSignIn : { required : true, emailValidation : true }, passwordSignIn : { required : true, minlength : 6 } }, messages : { emailSignIn : { required : "Please enter a valid email address", emailValidation : "Please enter a valid email address" }, passwordSignIn : { required : "Please enter a password", minlength : "Password minimum of 6 characters" } }, errorElement : "span", wrapper : "span", // a wrapper around the error // message errorPlacement : function(error, element) { element.before(error); error.addClass('form_error_message'); error.append(""); offset = element.offset(); error.css('left', $(element).position().left + $(element).width() - 200); error.css('top', $(element).position().top + $(element).height() - 50); }, submitHandler : function(form) { var emailValue = $("input#emailSignIn").val(); var targetURL = $("input#targetURL").val(); if (targetURL == "" || targetURL == 'null') { targetURL = HOST_WITHOUT_SSL + "home.htm"; } var rememberMyEmailAddress = $( "input#rememberMyEmailAddress").attr( 'checked') ? 1 : 0; var password = $("input#passwordSignIn").val(); var dataString = "j_username=" + emailValue + "&j_password=" + password + "&login=1&rememberMyEmailAddress=" + rememberMyEmailAddress; var url = HOST_WITH_SSL + "j_spring_security_check?"; $("#mobile_wrapper") .append( ""); $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jqXhr) { var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { location.href = targetURL; } else if (response.result == '3') { $("#loginError p") .html( "Your account has been locked. Please contact support@owler.com if you feel this has been in error"); $('#loginError').show(); $(".popup_overlay").remove(); $("#passwordSignIn").val(''); $("#emailSignIn").val(''); $("#signInForm input") .removeClass("valid"); } else { $("#loginError p").html( response.message); $('#loginError').show(); $(".popup_overlay").remove(); $("#passwordSignIn").val(''); $("#signInForm input") .removeClass("valid"); } }, error : function(data, textStatus, jqXHr) { $("#loginError p").html = data; $(".popup_overlay").remove(); } }); return false; } }); var twitterRegForm = $("#twitterEmailForm") .validate( { rules : { twitterRegEmail : { required : true, emailValidation : true } }, messages : { twitterRegEmail : { required : "Please enter a valid email address", emailValidation : "Please enter a valid email address" } }, errorElement : "span", wrapper : "span", // a wrapper around the error // message errorPlacement : function(error, element) { element.before(error); error.addClass('form_error_message'); offset = element.offset(); error.css('left', $(element).position().left + $(element).width() - 200); error.css('top', $(element).position().top + $(element).height() + -45); }, submitHandler : function(form) { var emailValue = $("input#twitterRegEmail").val(); var dataString = "email=" + emailValue; var url = HOST_WITH_SSL + "socialEmailRegistration.htm"; $("#TB_window") .append( ""); $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jqXhr) { var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { var OauthResponseJson = $.parseJSON(getCookie(OAUTH_RESPONSE)) var OauthResponse = $.parseJSON(OauthResponseJson) trackMixpanelLoginEvent(OauthResponse,getCallBckFn()); $(".popup_overlay").remove(); tb_remove(); setTimeout( function() { tb_show( "", "#TB_inline?height=280&width=520&inlineId=registerThanksDiv&modal=true"); }, 500); $("#profilename").val( OauthResponse.screenName); trackSignupStep2Event(OauthResponse.memberId) } else { $("#twitterRegError p").html( response.message); $('#twitterRegError').show(); $(".popup_overlay").remove(); $("#twitterEmailForm input") .removeClass("valid"); } }, error : function(data, textStatus, jqXHr) { $("#twitterRegError p").html = data; $(".popup_overlay").remove(); } }); return false; } }); var errorLoginForm = $("#errorSignIn") .validate( { rules : { error_emailSignin : { required : true }, error_passwordSignin : { required : true, minlength : 6 } }, messages : { error_emailSignin : { required : "Please enter a valid email address" }, error_passwordSignin : { required : "Please enter a password", minlength : "Your password must be at least 6 characters" } }, errorElement : "span", wrapper : "span", // a wrapper around the error // message errorPlacement : function(error, element) { element.before(error); error.addClass('form_error_message'); error.append(""); offset = element.offset(); error.css('left', $(element).position().left + $(element).width() - 260); error.css('top', $(element).position().top + $(element).height() - 55); }, submitHandler : function(form) { var error_mailValue = $("input#error_emailSignin") .val(); var error_targetURl = $("input#error_targetURl") .val(); if (error_targetURl == "" || error_targetURl == 'null') { error_targetURl = HOST_WITHOUT_SSL + "home.htm"; } var rememberMyEmailAddress = $( "input#error_rememberMyEmailAddress").attr( 'checked') ? 1 : 0; var error_loginPassword = $( "input#error_passwordSignin").val(); var dataString = "j_username=" + error_mailValue + "&j_password=" + error_loginPassword + "&rememberMyEmailAddress=" + rememberMyEmailAddress; var url = HOST_WITH_SSL + "j_spring_security_check?"; $("#errorSignInContainer") .append( ""); $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jqXhr) { var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { location.href = error_targetURl; $(".popup_overlay").remove(); } else if (response.result == '3') { $("#error_page_messages p") .html( "Your account has been locked. Please contact support@owler.com if you feel this has been in error."); $("#error_page_messages") .show(); $("#error_page_messages .error") .show(); $(".popup_overlay").remove(); $("#error_emailSignin").val(""); $("#error_passwordSignin").val( ""); $(".alert").hide(); } else { $("#error_page_messages p") .html(response.message); $("#error_page_messages") .show(); $("#error_page_messages .error") .show(); $(".popup_overlay").remove(); $("#error_passwordSignin").val( ""); $(".alert").hide(); } }, error : function(data, textStatus, jqXHr) { $("#error_page_messages p").html = data; } }); return false; } }); var resetPasswordRequestValidator = $("#resetPasswordRequestForm") .validate( { rules : { resetPasswordRequestEmailSignIn : { required : true, emailValidation : true } }, messages : { resetPasswordRequestEmailSignIn : { required : "Please enter a valid email address", emailValidation : "Please enter a valid email address" } }, errorElement : "span", wrapper : "span", // a wrapper around the error // message errorPlacement : function(error, element) { element.before(error); error.addClass('form_error_message'); error.append(""); offset = element.offset(); error.css('left', $(element).position().left + $(element).width() - 180); error.css('top', $(element).position().top + $(element).height() - 55); }, submitHandler : function(form) { var forgotEmailValue = $( "input#resetPasswordRequestEmailSignIn") .val(); var dataString = "email=" + forgotEmailValue; var url = HOST_WITH_SSL + "sendResetPassswordNotify.htm?"; $("#TB_window") .append( ""); $.ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jqXhr) { var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { $("#resetPasswordRequestSuccessDiv") .html(response.message); $("#resetPasswordRequestDivContainer") .hide(); $("#resetPasswordRequestSuccessDiv") .show(); $(".popup_overlay").remove(); } else { $("#resetPasswordError p").html( response.message); $("#resetPasswordError").show(); $("span.error").show(); $(".popup_overlay").remove(); } }, error : function(data, textStatus, jqXHr) { $("#resetPasswordError p").html = data; $(".popup_overlay").remove(); } }); return false; } }); $("#resetPasswordForm") .validate( { rules : { resetPassword : { required : true, minlength : 6 }, confirmResetPassword : { equalTo : "#resetPassword" } }, messages : { resetPassword : { required : "Please enter a password", minlength : "Your password must be at least 6 characters" }, confirmResetPassword : { equalTo : "Passwords do not match" } }, errorElement : "span", wrapper : "span", // a wrapper around the error // message errorPlacement : function(error, element) { element.before(error); error.addClass('form_error_message_right'); error.append(""); offset = element.offset(); error.css('left', $(element).position().left + $(element).width() + 10); error.css('top', $(element).position().top + $(element).height() - 20); }, submitHandler : function(form) { var email = $("#resetpasswordemail").val(); var password = $("input#resetPassword").val(); var url = HOST_WITH_SSL + "resetPassword.htm?"; var dataString = "email=" + email + "&password=" + password; $.ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jQXHr) { var response = $.parseJSON(data); // passes the response to this function ajaxResponseHandler(response); resetForm($('#resetPasswordForm')); $(".formbox").hide(); $(".button_continueinfoarmy") .fadeIn("slow"); }, error : function(data, textStatus, jQXhr) { errorMessage('Error !!! Status =' + data); } }); return false; } }); $('#companyURL').bind('keyup', function() { return false; }); var addCompanyFormValidator = $("#addCompanyForm") .validate( { rules : { companyName : { required : true, unicodeValidation : true }, costType : { required : true }, companyURL : { required : true, onkeyup : false, validateURL : true } }, messages : { companyName : { required : "Please enter a company name" }, companyURL : { required : "Please enter valid URL", validateURL : "Please enter a valid URL" }, costType : { required : "Please select a cost value" } }, errorElement : "span", wrapper : "span", // a wrapper around the error // message errorPlacement : function(error, element) { element.before(error); error.addClass('form_error_message'); error.append(""); offset = element.offset(); error.css('left', $(element).position().left + $(element).width() - 260); error.css('top', $(element).position().top + $(element).height() - 55); }, submitHandler : function(form) { var companyName = $("#companyName").val(); companyName = escape(companyName); var companyURL = $("#companyURL").val(); var country = $("#country").val(); var priority = $("#priority").val(); var costType = $("#costType").val(); var dataString = "companyName=" + companyName + "&companyURL=" + companyURL + "&country=" + country + "&priority=" + priority + "&costType=" + costType; var url = HOST_WITHOUT_SSL + "admin/addCompany.htm?"; $("#TB_window") .append( ""); $ .ajax({ type : "POST", url : url, contentType : "application/x-www-form-urlencoded; charset=UTF-8", data : dataString, success : function(data, textStatus, jqXhr) { var response = $.parseJSON(data); tb_remove(); ajaxResponseHandler(response); }, error : function(data, textStatus, jqXHr) { errorMessage('Error !!! Status =' + data); } }); return false; } }); /*cir Sample Report Register Form*/ var simpleRegisterFormValidator = $("#sampleCirForm") .validate(processFormValidate("input#sampleCirEmail", '#sampleCirRegister', "#sampleCirError", "#sampleCirForm")); // Simple sign up Form Validator var simpleSignUpFormValidator = $("#signupForm") .validate(processFormValidate("input#email", '#signup', "#signupError", "#signupForm")); var seoSignUpFormValidator = $("#seoCitySignUpForm") .validate(processFormValidateSEOLandingPage("input#seoEmail",'#seoSignUp',"#seoSignUpError","#seoCitySignUpForm")); $("#seoCitySignUpForm").click(function(){ setCookie(SIGN_UP_ORIGIN,'SEO CITY PAGE'); setCookie(SIGN_UP_PAGETYPE,'SEO CITY PAGE',120); }); $("#sampleCirForm").click(function(){ setCookie(SIGN_UP_ORIGIN,'CIR Request', 120); setCookie(SIGN_UP_PAGETYPE, 0, 120); }); $("#conversionForm").click(function(){ setCookie(SIGN_UP_ORIGIN,'Company Search Registration Bar', 120); setCookie(SIGN_UP_PAGETYPE, 0, 120); }); var simpleRegSuccessFormValidator = $("#simpleRegSuccessForm") .validate( { rules : { simpleProfilename : { required : true, minlength : 4, profileNameExists : true }, randomPassword:{ minlength : 6 } }, messages : { profilename : { required : "Please enter your public profile name", minlength : "Profile Name must consist of 4 characters and no spaces" }, randomPassword : { minlength : "Password must consist of 6 characters" } }, errorElement: "span", wrapper: "span", // a wrapper around the error message errorPlacement: function(error, element) { element.before(error); error.addClass('form_error_message'); error.append(""); offset = element.offset(); if (($(element).attr("id") == "fname") || ($(element).attr("id") == "lname")) { error.css('left', $(element).position().left + $(element).width() - 350); error.css('top', $(element).position().top + $(element).height() - 55); } else { error.css('left', $(element).position().left + $(element).width() - 270); error.css('top', $(element).position().top + $(element).height() - 50); error.css('text-align', "left"); } }, submitHandler : function() { var time_Zone_Offset = new Date().getGmtOffset(); var firstName = ""; var lastName = ""; var profileName = $("input#simpleProfilename").val(); var password = $("input#randomPassword").val(); var oldPassword = $("#oldPassword").text(); var profilePicture = ""; var targetURL = $("input#targetURL").val(); if(targetURL == "" || targetURL == 'null') { targetURL = HOST_WITH_SSL; } var dataString = "firstname=" + firstName + "&lastname=" + lastName+ "&profilename=" + profileName+ "&profilepicture=" + profilePicture+"&password="+password+"&oldPassword="+oldPassword+'&timeZone='+time_Zone_Offset $('#simpleContinueRegisterThanks').prop('disabled', true); var url = HOST_WITH_SSL+"/updateprofilePassword.htm?"; $("#TB_window").append(""); $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jQXHr) { var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { $("#simpleRegisterThanksDiv").hide(); tb_remove(); //Now go inside application window.location.assign(targetURL); } else { $("#simpleRegSuccessFormErrorDiv p").html(response.message); $('#simpleRegSuccessFormErrorDiv').show(); $(".popup_overlay").remove(); $('#simpleContinueRegisterThanks').attr("disabled", false); } }, error : function(data, textStatus, jQXhr) { $("#simpleRegSuccessFormErrorDiv p").html = data; $(".popup_overlay").remove(); $('#simpleContinueRegisterThanks').attr("disabled", false); } }); return false; } }); function processFormValidate(inputBoxDom, submitButtonDom, ErrorBoxDom, formId){ var validate = { rules : { email : { required : true, emailValidation : true } }, messages : { email : { required : "Please enter a valid email address", emailValidation : "Please enter a valid email address" } }, errorElement: "span", wrapper: "span", // a wrapper around the error message errorPlacement: function(error, element) { element.before(error); error.addClass('form_error_message'); error.append(""); offset = element.offset(); if (($(element).attr("id") == "fname") || ($(element).attr("id") == "lname")) { error.css('left', $(element).position().left + $(element).width() - 260 + 100); error.css('top', $(element).position().top + $(element).height() - 55+20); } else { error.css('left', $(element).position().left + $(element).width() - 210); error.css('top', $(element).position().top + $(element).height() - 55); } }, submitHandler : function() { var timeZone = new Date().getGmtOffset(); var emailValue = $(inputBoxDom).val(); var dataString = "email=" + emailValue + "&timeZone=" + timeZone; $(submitButtonDom).attr("disabled", true); var url = HOST_WITH_SSL + "addSimpleVisitor.htm?"; $("#bg_conversion_banner1").append(""); $(ErrorBoxDom).hide(); var companyName = $("input#searchTextBox").val(); if (employerId != undefined && employerId != null) { var targetURL = getCompetitorSectionUrl(employerId, companyName); $("input#targetURL").val(targetURL); } if(validateDomain(emailValue)){ processSignupFlow(dataString, inputBoxDom, submitButtonDom, ErrorBoxDom, undefined, trackMixpanelLoginEvent, trackMixpanelEvent, url); } else { if(formId != undefined){ $(formId+" #domain_error_message").show(); } else { $("#domain_error_message").show(); } $(submitButtonDom).attr("disabled", false); $(".popup_overlay").remove(); } return false; } }; return validate; } function processFormValidateSEOLandingPage(inputBoxDom, submitButtonDom, ErrorBoxDom, formId){ $(inputBoxDom).focus(function(){ $(ErrorBoxDom).hide(); }); var validate = { rules : { email : { required : true, emailValidation : true } }, messages : { email : { required : "Please enter a valid email address", emailValidation : "Please enter a valid email address" } }, errorElement: "span", wrapper: "span", // a wrapper around the error message errorPlacement: function(error, element) { element.after(error); error.addClass('domain_error_message'); error.prepend(""); offset = element.offset(); if (($(element).attr("id") == "fname") || ($(element).attr("id") == "lname")) { error.css('left', $(element).position().left + $(element).width() - 260 + 100); error.css('top', $(element).position().top + $(element).height() - 55+20); } else { error.css('left', $(element).position().left + $(element).width() - 210); error.css('top', $(element).position().top + $(element).height() - 55); } }, submitHandler : function() { var emailValue = $(inputBoxDom).val(); var dataString = "email=" + emailValue; if(employerId !=undefined && employerId != null){ dataString = dataString + "&employerId=" + employerId; } $(submitButtonDom).attr("disabled", true); var url = HOST_WITH_SSL + "addSimpleVisitor.htm?"; $("#home_banner").append(""); $(ErrorBoxDom).hide(); var companyName = $("input#searchTextBox").val(); if (employerId != undefined && employerId != null) { var targetURL = getCompetitorSectionUrl(employerId, companyName); $("input#targetURL").val(targetURL); } if(validateDomain(emailValue)){ processSignupFlow(dataString, inputBoxDom, submitButtonDom, ErrorBoxDom, undefined, trackMixpanelLoginEvent, trackMixpanelEvent, url); } else { if(formId != undefined){ $(formId+" #domain_error_message").show(); } else { $("#domain_error_message").show(); } $(submitButtonDom).attr("disabled", false); } return false; } }; return validate; } }); function companyTabClicked(tabDiv, urlString) { $.ajax({ type : "POST", url : urlString, success : function(data, textStatus, jqXhr) { $("#" + tabDiv).html(data); }, error : function(data, textStatus, jqXHr) { $("#error").html(data); } }); } function headerClicked(colName) { var searchTerm = $("#search").val(); var sortType = $("#sortOrder").val(); var dataString = "searchTerm=" + searchTerm + "&sortParam=" + colName + "&sortOrder=" + sortType; var url = HOST_WITHOUT_SSL + "search.htm?"; $.ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jqXhr) { $("#main_container").html(data); }, error : function(data, textStatus, jqXHr) { $("#mainContainerError").html(data); } }); } /* Form Reset function */ function resetForm($form) { $form.find('input:text, input:password, input:file, select').val(''); $form.find('input:text, input:password, input:file, select').removeClass( "error").removeClass("valid").removeClass( 'form_error_message_right').removeClass('form_error_message'); $form.find('input:radio, input:checkbox').removeAttr('checked').removeAttr( 'selected'); $form.find('.domain_error_message').hide(); } function populateState() { var c = $("#countryi").val(); var selectOptions = ""; $.getJSON(HOST_WITHOUT_SSL + 'populateState.htm?country=' + c, function( data) { $.each(data, function(i, item) { selectOptions += " "; }); $("#statei").html(selectOptions); }); } /* Placeholder on sumbit empty's the default values */ $('[placeholder]').focus(function() { var input = $(this); if (input.val() == input.attr('placeholder')) { input.val(''); input.removeClass('placeholder'); } }).blur(function() { var input = $(this); if (input.val() == '' || input.val() == input.attr('placeholder')) { input.addClass('placeholder'); input.val(input.attr('placeholder')); } }).blur(); $(document).on( 'mouseenter', '.validate', function() { $(this).prev(".form_error_message, .form_error_message_right").css( 'visibility', 'visible'); }); $(document).on( 'mouseleave', '.validate', function() { $(this).prev(".form_error_message, .form_error_message_right").css( 'visibility', 'hidden'); }); $("#signupFormBuyReports input#buy_password").focus(function() { $("#signupFormBuyReports input#buy_confirmPassword").val(''); }); /* Ajax response handler for messages in all pages */ function ajaxResponseHandler(response) { if (response.result == 1) { successMessage(response.message); } else if (response.result == 0) { errorMessage(response.message); } else if (response.result == 2) { informationMessage(response.message); } } function removeResponseMessages() { $("#message_container").find('div').hide(); $("#message_container .alert").hide(); $("#message_container .success").hide(); $(".info_alert").hide(); $(".popup_overlay").remove(); } function errorMessage(message) { $("#other_message_container").find('div').hide(); $("#message_container").find('div').hide(); $("#message_container .alert").fadeIn("slow"); $("#message_container .alert p").html(message); $(".popup_overlay").remove(); } function successMessage(message) { $("#other_message_container").find('div').hide(); $("#message_container").find('div').hide(); $("#message_container .success").fadeIn("slow"); $("#message_container .success p").html(message); } function informationMessage(message) { $("#other_message_container").find('div').hide(); $("#message_container").find('div').hide(); $("#message_container .info_alert").fadeIn("slow"); $("#message_container .info_alert p").html(message); } /* Image Util for relative resize of the image */ function getScalingFactor(destWidth, destHeight, imageWidth, imageHeight, scaleUp) { var scalingFactor = 1; if (destWidth <= 0 || destHeight <= 0 || imageWidth <= 0 || imageHeight <= 0) { return -1; } var widthScalingFactor = destWidth / imageWidth; var heightScalingFactor = destHeight / imageHeight; if (widthScalingFactor < 1 && heightScalingFactor < 1) { scalingFactor = (widthScalingFactor < heightScalingFactor) ? widthScalingFactor : heightScalingFactor; } else if (widthScalingFactor < 1) { scalingFactor = widthScalingFactor; } else if (heightScalingFactor < 1) { scalingFactor = heightScalingFactor; } else if (widthScalingFactor > 1 && heightScalingFactor > 1 && scaleUp == true) { scalingFactor = (widthScalingFactor < heightScalingFactor) ? widthScalingFactor : heightScalingFactor; } return scalingFactor; } function resizeImage(loadedImage, image, scaleUp) { image = $('#' + image.id); var imageWidth = loadedImage.width; var imageHeight = loadedImage.height; var scalingFactor = getScalingFactor(image.attr('maxwidth'), image .attr('maxheight'), imageWidth, imageHeight, scaleUp); if (scalingFactor != -1 && scalingFactor != 1) { var calWidth = Math.round(imageWidth * scalingFactor); var calHeight = Math.round(imageHeight * scalingFactor); if (calHeight == (image.attr('maxheight') - 1)) { calHeight = calHeight + 1; } if (calWidth == (image.attr('maxwidth') - 1)) { calWidth = calWidth + 1; } image.css('width', calWidth); image.css('height', calHeight); } image.css('display', ''); } /** * @param destImage * is image element that needs to be resized, mandatory max width and * max height setted in width and height attributes */ function preloadImage(destImage) { var resize = destImage.getAttribute('resize'); if (resize === 'true') { destImage.style.display = 'none'; var loadedimage = $('').attr('src', destImage.src); resizeImage(loadedimage[0], destImage, true); } } /* Image Util for relative resize of the image */ function getScalingFactor(destWidth, destHeight, imageWidth, imageHeight, scaleUp) { var scalingFactor = 1; if (destWidth <= 0 || destHeight <= 0 || imageWidth <= 0 || imageHeight <= 0) { return -1; } var widthScalingFactor = destWidth / imageWidth; var heightScalingFactor = destHeight / imageHeight; if (widthScalingFactor < 1 && heightScalingFactor < 1) { scalingFactor = (widthScalingFactor < heightScalingFactor) ? widthScalingFactor : heightScalingFactor; } else if (widthScalingFactor < 1) { scalingFactor = widthScalingFactor; } else if (heightScalingFactor < 1) { scalingFactor = heightScalingFactor; } else if (widthScalingFactor > 1 && heightScalingFactor > 1 && scaleUp == true) { scalingFactor = (widthScalingFactor < heightScalingFactor) ? widthScalingFactor : heightScalingFactor; } return scalingFactor; } function resizeImage(loadedImage, image, scaleUp) { image = $('#' + image.id); var imageWidth = loadedImage.width; var imageHeight = loadedImage.height; var scalingFactor = getScalingFactor(image.attr('maxwidth'), image .attr('maxheight'), imageWidth, imageHeight, scaleUp); if (scalingFactor != -1 && scalingFactor != 1) { var calWidth = Math.round(imageWidth * scalingFactor); var calHeight = Math.round(imageHeight * scalingFactor); if (calHeight == (image.attr('maxheight') - 1)) { calHeight = calHeight + 1; } if (calWidth == (image.attr('maxwidth') - 1)) { calWidth = calWidth + 1; } image.css('width', calWidth); image.css('height', calHeight); } image.css('display', ''); } /* Hiding the label for relevent input field keydown in signup form */ $(document).ready(function() { $(function() { $('#signupForm .input_field').focus(function() { $('label.label-hide[for="' + $(this)[0].id + '"]').hide(); window.setInterval(timeout, 1000); }).blur(function() { if ($(this).val() == '') $('label.label-hide[for="' + $(this)[0].id + '"]').show(); }); }); function timeout() { // if ($("#password").val().length > 0) // $('label.label-hide[for="password"]').hide(); } function timeout1() { // if ($("#password1").val().length > 0) // $('label.label-hide[for="password1"]').hide(); } function timeout2() { // if ($("#password2").val().length > 0) // $('label.label-hide[for="password2"]').hide(); } function timeout3() { // if ($("#password3").val().length > 0) // $('label.label-hide[for="password3"]').hide(); } function timeout4() { // if ($("#password4").val().length > 0) // $('label.label-hide[for="password4"]').hide(); } function timeout5() { // if ($("#password5").val().length > 0) // $('label.label-hide[for="password5"]').hide(); } $(function() { $('#mobileSignInForm .input_field').focus(function() { $('label.label-hide[for="' + $(this)[0].id + '"]').hide(); window.setInterval(timeout, 1000); }).blur(function() { if ($("#password").val().length > 0) $('label.label-hide[for="password"]').hide(); if ($(this).val() == '') $('label.label-hide[for="' + $(this)[0].id + '"]').show(); }); }); $(function() { $('#registerForm .input_field').focus(function() { $('label.label-hide[for="' + $(this)[0].id + '"]').hide(); window.setInterval(timeout, 1000); }).blur(function() { if ($("#password").val().length > 0) $('label.label-hide[for="password"]').hide(); if ($(this).val() == '') $('label.label-hide[for="' + $(this)[0].id + '"]').show(); }); }); $(function() { $('#registerForm1 .input_field').focus(function() { $('label.label-hide[for="' + $(this)[0].id + '"]').hide(); window.setInterval(timeout1, 1000); }).blur(function() { if ($("#password1").val().length > 0) $('label.label-hide[for="password1"]').hide(); if ($(this).val() == '') $('label.label-hide[for="' + $(this)[0].id + '"]').show(); }); }); $(function() { $('#registerForm2 .input_field').focus(function() { $('label.label-hide[for="' + $(this)[0].id + '"]').hide(); window.setInterval(timeout2, 1000); }).blur(function() { if ($("#password2").val().length > 0) $('label.label-hide[for="password2"]').hide(); if ($(this).val() == '') $('label.label-hide[for="' + $(this)[0].id + '"]').show(); }); }); $(function() { $('#registerForm3 .input_field').focus(function() { $('label.label-hide[for="' + $(this)[0].id + '"]').hide(); window.setInterval(timeout3, 1000); }).blur(function() { if ($("#password3").val().length > 0) $('label.label-hide[for="password3"]').hide(); if ($(this).val() == '') $('label.label-hide[for="' + $(this)[0].id + '"]').show(); }); }); $(function() { $('#registerForm4 .input_field').focus(function() { $('label.label-hide[for="' + $(this)[0].id + '"]').hide(); window.setInterval(timeout4, 1000); }).blur(function() { if ($("#password4").val().length > 0) $('label.label-hide[for="password4"]').hide(); if ($(this).val() == '') $('label.label-hide[for="' + $(this)[0].id + '"]').show(); }); }); $(function() { $('#registerForm5 .input_field').focus(function() { $('label.label-hide[for="' + $(this)[0].id + '"]').hide(); window.setInterval(timeout5, 1000); }).blur(function() { if ($("#password5").val().length > 0) $('label.label-hide[for="password5"]').hide(); if ($(this).val() == '') $('label.label-hide[for="' + $(this)[0].id + '"]').show(); }); }); function timeout() { // if ($("#password").val().length > 0) // $('label.label-hide[for="password"]').hide(); } function timeout2() { // if ($("#password2").val().length > 0) // $('label.label-hide[for="password2"]').hide(); } $('.menu-icon').click(function(){ var isMenuOpened = $('.menu-icon').hasClass('submenu-link-active'); var isAdminMenuOpened = $('.admin-menu-icon').hasClass('submenu-link-active'); if(isMenuOpened){ $("#header-overlay").toggleClass("hide-overlay"); $("#search-overlay").toggleClass("hide-overlay"); $(this).toggleClass('submenu-link-active'); $(".search-box").removeAttr("disabled"); } else { if(!isAdminMenuOpened){ $("#header-overlay").toggleClass("hide-overlay"); $("#search-overlay").toggleClass("hide-overlay"); $(this).toggleClass('submenu-link-active'); $(".search-box").attr("disabled","true"); } else { $('.admin-menu-icon').toggleClass('submenu-link-active'); $(this).toggleClass('submenu-link-active'); } } }); $('.admin-menu-icon').click(function(){ var isMenuOpened = $('.menu-icon').hasClass('submenu-link-active'); var isAdminMenuOpened = $('.admin-menu-icon').hasClass('submenu-link-active'); if(isAdminMenuOpened){ $("#header-overlay").toggleClass("hide-overlay"); $("#search-overlay").toggleClass("hide-overlay"); $(this).toggleClass('submenu-link-active'); $(".search-box").removeAttr("disabled"); } else { if(!isMenuOpened){ $("#header-overlay").toggleClass("hide-overlay"); $("#search-overlay").toggleClass("hide-overlay"); $(this).toggleClass('submenu-link-active'); $(".search-box").attr("disabled","true"); } else { $('.menu-icon').toggleClass('submenu-link-active'); $(this).toggleClass('submenu-link-active'); } } }); /*var mypos = $(window).scrollTop(); var up = false; var newscroll; var header = $("#header"); $(window).scroll(function() { newscroll = $(window).scrollTop(); if(newscroll == 0){ header.removeClass("desktop-only"); header.css("position","relative"); } else { if (newscroll > mypos && !up) { header.removeClass("desktop-only"); header.css("position","relative"); up = !up; } else if(newscroll < mypos && up) { header.addClass("desktop-only"); header.css("position","fixed"); up = !up; } } mypos = newscroll; });*/ $('.handle-overlay').click(function(){ $(".handle-overlay").removeClass("hide-overlay"); $(".submenu-link").removeClass('submenu-link-active'); $(".search-box").removeAttr("disabled"); }); }); $(window).bind("load", function() { // To set landing page of the user if(getCookie(LANDING_PAGE) == null){ setCookie(LANDING_PAGE, currentPage, 604800); // Expiry time for 7 days } }); var oauth_window; var OAUTH_STATUS_USER_REGISTERED = "2"; var OAUTH_STATUS_EMAIL_REQD = "3"; var OAUTH_STATUS_COOKIE = 'oauth_status'; var OAUTH_RESPONSE = 'oauth_response'; var OAUTH_STATUS_ACCOUNT_BLOCKED = "4"; var OAUTH_STATUS_USER_LOGGED_IN = "5"; function PopupOAuthWindowCenter(pageURL, title, w, h) { if (oauth_window) { oauth_window.close(); } var left = (screen.width / 2) - (w / 2); var top = (screen.height / 2) - (h / 2); oauth_window = window .open( pageURL, title, 'toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no,width=' + w + ',height=' + h + ',top=' + top + ',left=' + left); oauth_window.focus(); setCookie(REGISTER_PAGE, currentPage, 480); } var TwitterConnect = (function() { function TwitterConnect(url, width, height) { this.url = url; this.width = width; this.height = height; } TwitterConnect.prototype.exec = function() { var self = this; PopupOAuthWindowCenter(this.url, 'OAuth', this.width, this.height); this.interval = window.setInterval((function() { if (oauth_window.closed) { window.clearInterval(self.interval); var responseStr = $.parseJSON(getCookie(OAUTH_RESPONSE)) var response = $.parseJSON(responseStr) var status = getCookie(OAUTH_STATUS_COOKIE); if(status == OAUTH_STATUS_USER_LOGGED_IN){ trackMixpanelLoginEvent(response,getCallBckFn()) } else if(status == OAUTH_STATUS_EMAIL_REQD){ var targetURL = getTargetURL(); window.location.replace(HOST_WITH_SSL + 'signup.htm?targetURL=' + targetURL); }else if(status == OAUTH_STATUS_ACCOUNT_BLOCKED){ tb_remove(); tb_show("Account Blocked", "#TB_inline?height=100&width=360&inlineId=accountBlockedDiv"); } } }), 1000); }; return TwitterConnect; })(); var SocialConnect = (function() { function SocialConnect(url, width, height) { this.url = url; this.width = width; this.height = height; } SocialConnect.prototype.exec = function() { setCookie('t_z', new Date().getGmtOffset(), 300); var self = this; PopupOAuthWindowCenter(this.url, 'OAuth', this.width, this.height); this.interval = window.setInterval((function() { if (oauth_window.closed) { window.clearInterval(self.interval); var responseStr = $.parseJSON(getCookie(OAUTH_RESPONSE)) var response = $.parseJSON(responseStr) var status = getCookie(OAUTH_STATUS_COOKIE) if(status == OAUTH_STATUS_USER_REGISTERED) { if(response.employerURL != undefined){ setCookie(LOGO_CONFIRMATION, 0, 300); trackMixpanelLoginEvent(response,getSignUpCallBckFn(response.employerURL+"?onBoardingComplete=true")); } else { $("#conversionForm").hide(); $("#linkedInLink").hide(); $(".signUpLink").hide(); $("#registrationFlowSteps").show(); $("#userEmail").val(response.userEmail); var property={}; property['User role']=response.userRole; property['UserId']=response.memberId; trackMixpanelLoginEvent(response,function(){ trackMixpanelEvent(HP_ONBOARDING_STEP1_STARTED,property) }); } setCookie(USER_REG, 0, 300); } else if(status == OAUTH_STATUS_USER_LOGGED_IN){ trackMixpanelLoginEvent(response,getCallBckFn()); } else if(status == OAUTH_STATUS_EMAIL_REQD) { var targetURL = getTargetURL(); window.location.replace(HOST_WITH_SSL + 'signup.htm?targetURL=' + targetURL); } else if(status == OAUTH_STATUS_ACCOUNT_BLOCKED){ tb_remove(); tb_show("Account Blocked", "#TB_inline?height=100&width=360&inlineId=accountBlockedDiv"); } } }), 1000); }; return SocialConnect; })(); $(function() { $(".twitter-login-connect").click( function() { var dataString = "login"; $.ajax({ url : HOST_WITHOUT_SSL + "twitterlogin.htm?", async : false, data : "url=" + dataString, success : function(data, textStatus, jQXHr) { tb_remove(); var response = $.parseJSON(data); var authUrl = response.authorizationUrl; if (authUrl) { var twitter_connect = new TwitterConnect(authUrl, 900, 600); twitter_connect.exec(); } }, error : function(data, textStatus, jQXHr) { alert(textStatus); } }); return false; }); $(".twitter-register-connect").click( function() { var dataString = "register"; $.ajax({ url : HOST_WITHOUT_SSL + "twitterlogin.htm?", async : false, data : "url=" + dataString, success : function(data, textStatus, jQXHr) { tb_remove(); var response = $.parseJSON(data); var authUrl = response.authorizationUrl; if (authUrl) { var twitter_connect = new TwitterConnect(authUrl, 900, 600); twitter_connect.exec(); } }, error : function(data, textStatus, jQXHr) { alert(textStatus); } }); return false; }); $(".google-connect").click(function() { $.ajax({ url : HOST_WITHOUT_SSL + "googlelogin.htm", async : false, success : function(data, textStatus, jQXHr) { tb_remove(); var authUrl = data; if (authUrl) { var social_connect = new SocialConnect(authUrl, 900, 600); social_connect.exec(); } }, error : function(data, textStatus, jQXHr) { alert(textStatus); } }); return false; }); $(".facebook-connect").click(function() { $.ajax({ url : HOST_WITHOUT_SSL + "facebooklogin.htm", async : false, success : function(data, textStatus, jQXHr) { tb_remove(); // var response = $.parseJSON(data); var authUrl = data; if (authUrl) { var social_connect = new SocialConnect(authUrl, 900, 600); social_connect.exec(); } }, error : function(data, textStatus, jQXHr) { alert(textStatus); } }); return false; }); $(".linkedin-connect").click(function() { $.ajax({ url : HOST_WITHOUT_SSL + "linkedinlogin.htm", async : false, success : function(data, textStatus, jQXHr) { tb_remove(); var response = $.parseJSON(data); var authUrl = response.authorizationUrl; if (authUrl) { var social_connect = new SocialConnect(authUrl, 900, 600); social_connect.exec(); } }, error : function(data, textStatus, jQXHr) { alert(textStatus); } }); return false; }); }); $("#sign_out").click(function(){ var signOutProperty={}; var timeStamp = new Date().toUTCString(); signOutProperty['UserId']=userId; signOutProperty['Timestamp']=timeStamp; trackMixpanelEvent('User Sign Out',signOutProperty,function(){ location.href = HOST_WITHOUT_SSL+"j_spring_security_logout"; }); }); function getCookie(c_name) { var c_value = document.cookie; var c_start = c_value.indexOf(" " + c_name + "="); if (c_start == -1) { c_start = c_value.indexOf(c_name + "="); } if (c_start == -1) { c_value = null; } else { c_start = c_value.indexOf("=", c_start) + 1; var c_end = c_value.indexOf(";", c_start); if (c_end == -1) { c_end = c_value.length; } c_value = unescape(c_value.substring(c_start, c_end)); } return c_value; } function trackMixpanelLoginEvent(response,callBckFun){ var event=response.event var memberId=response.memberId var mode=response.mode var memberRole=response.userRole var screenName=response.screenName var property={}; property['Mode']=mode+''; mixpanel.identify(memberId); if(event=='Sign in'){ mixpanel.people.set({'$last_seen':new Date()}); }else{ var employerDeduction=response.employerURL var emailId=response.userEmail var pageType=getCookie(SIGN_UP_PAGETYPE) if(pageType != undefined && pageType != null){ property['Page Type'] = pageType; } else if(window.currentPage == 'eventsPage'){ property['Page Type'] = 'Events Page' } else if(pageType == undefined || pageType == null){ property['Page Type'] = 'Home Page' } property['Employer Detected'] = (employerDeduction!=undefined)?true:false property['Email'] = emailId mixpanel.people.set('$last_seen',new Date()); mixpanel.people.set_once('$SignUpDate', new Date()); mixpanel.people.set_once('$email',emailId); mixpanel.people.set_once('$name',screenName); } setUtmParams(); //clear Cookies deleteCookie(SIGN_UP_PAGETYPE); deleteCookie(SIGN_UP_ORIGIN); deleteCookie(OAUTH_STATUS_COOKIE); deleteCookie(OAUTH_RESPONSE); // initate Mixpanel calls mixpanel.register({'User role':memberRole+'','UserId':memberId+''}); trackMixpanelEvent(event+'',property,function(response) { if (response && response['status'] == 0) { var dataString= 'payLoadString={error:'+response['error']+', event:'+event+', email:'+emailId+', memberId'+memberId+'}'; $.ajax({ url: HOST_WITH_SSL + "reportMixpanelFailure.htm?", type: "POST", data: dataString }); } }); var activeUserProperty={}; activeUserProperty['Platform']='Web'; trackMixpanelEvent('Overall Active User',activeUserProperty,function(){ if(callBckFun!=undefined){ callBckFun() } }); } function showCommonSignupForm(mobile) { if (mobile == true) { window.location.href = "mobileSignUp.htm"; } else { tb_show('', '#TB_inline?height=475&width=475&inlineId=signupFormDiv'); $('#signupFormDivContainer').show(); $('#signupErrorMessagesDiv').hide(); $('#signupErrorMessagesDiv').html(""); resetForm($('#signupForm')); $('#signupErrorMessagesDiv').html(""); $('#signupError').hide(); $('#signupFormDivContainer').show(); $('#signupErrorMessagesDiv').hide(); $('#signupErrorMessagesDiv').html(""); $('.label-hide').show(); } } function setCookie(cname, cvalue, exsecs) { var d = new Date(); d.setTime(d.getTime() + (exsecs * 1000)); var expires = "expires=" + d.toGMTString(); document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/"; } function setPageTypeCookie() { var pageType; var temp = document.getElementById("originPage"); if( temp && temp.value ) { pageType = document.getElementById("originPage").value; } if (pageType == 'Home Page') { setCookie(SIGN_UP_PAGETYPE, 'Home Page', 120); // Home Page } else if(pageType != undefined){ setCookie(SIGN_UP_PAGETYPE, pageType, 120); } else { setCookie(SIGN_UP_PAGETYPE, 16, 120); // Static pages } } function hideErrorMsg(){ $(".domain_error_message").hide(); } function validateDomain(emailValue) { var email = emailValue; var domain = email.replace(/.*@/, "").toLowerCase(); for (var i = 0; i < listOfBlackListedDomains.length; i++) { if (listOfBlackListedDomains[i] == domain) { return false; } } return true; } function processSignupFlow(dataString, inputBoxDom, submitButtonDom, ErrorBoxDom, showRegistrationPopUp,trackMixpanelLoginEvent,trackMixpanelEvent, url) { $("#TB_window").append( ""); $ .ajax({ type : "POST", url : url, data : dataString, success : function(data, textStatus, jQXHr) { var response = $.parseJSON(data); if (response.result == SUCCESS_STRING) { $(".popup_overlay").remove(); if(response.employerURL != undefined){ trackMixpanelLoginEvent(response,getSignUpCallBckFn(response.employerURL)); } else { $("#linkedInLink").hide(); $(".signUpLink").hide(); $("#conversionForm").hide(); $("#registration-flow-employer").show(); $("#userEmail").val(response.userEmail); trackMixpanelLoginEvent(response,getSignUpCallBckFn()); } setCookie(USER_REG, 0, 300); } else { if (ErrorBoxDom != undefined && ErrorBoxDom != "") { $(ErrorBoxDom).html(response.message); $(ErrorBoxDom).show(); } else { showRegistrationPopUp('External referral'); $("#signupError").show(); $("#signupError p").html( "Please enter valid email address"); $("#signupError").html(response.message); $("#signupError").show(); } $(".popup_overlay").remove(); if (submitButtonDom != undefined && submitButtonDom != "") { $(submitButtonDom).attr("disabled", false); } } }, error : function(data, textStatus, jQXhr) { if ((submitButtonDom != undefined && submitButtonDom != "") || (ErrorBoxDom != undefined && ErrorBoxDom != "")) { $(ErrorBoxDom).html = data; $(ErrorBoxDom).show(); $(submitButtonDom).attr("disabled", false); } $(".popup_overlay").remove(); } }); } function validateEmail(email) { return /^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/i .test(email); } function trackSignupStep2Event(userid) { var userIdProp = {}; userIdProp['UserId'] = userid; trackMixpanelEvent('Homepage Signup Step 2 Viewed', userIdProp); } // Method returns the gmt timezone offset without the daylight savings // @see https://infoarmy.jira.com/wiki/display/MKT/Timezone+conversions+for+snapshot Date.prototype.getGmtOffset = function() { var jan = new Date(this.getFullYear(), 0, 1) var jul = new Date(this.getFullYear(), 6, 1) var stdOffSet=Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()) return (stdOffSet/60)*(-1) } function getCallBckFn(targetURL){ if(targetURL!=undefined){ return function() { window.location.assign(targetURL); } }else { return function() { window.location.reload(); } } } function getSignUpCallBckFn(targetURL){ return function(){ if(targetURL){ window.location.assign(targetURL); } } } // URL Param manipulation, exclusively for Mixpanel Last Touch UTM operations function getQueryParam(url, param) { // Expects a raw URL param = param.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + param + "=([^&#]*)", regex = new RegExp( regexS ), results = regex.exec(url); if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) { return ''; } else { return decodeURIComponent(results[1]).replace(/\+/g, ' '); } }; function setUtmParams() { var campaign_keywords = ['utm_source','utm_medium','utm_campaign','utm_content','utm_term'] , kw = '' , params = {} , first_params = {}; var index; for (index = 0; index < campaign_keywords.length; ++index) { kw = getQueryParam(document.URL, campaign_keywords[index]); if (kw.length) { params[campaign_keywords[index] + ' [last touch]'] = kw; first_params[campaign_keywords[index] + ' [first touch]'] = kw; } } mixpanel.register(params); } function trackSignInRequest(member_id,email,origin, reload, targetURL){ var props={}; var pageType=document.getElementById("originPage") var timeStamp = new Date().toUTCString(); if( pageType!= undefined &&pageType != null){ props['Page Type']=pageType.value }else{ props['Page Type']=window.currentPage } props['Email Id']= email; props['UserId']=member_id; props['Timestamp']= timeStamp; props['Origin']= origin; if(reload == true) { trackMixpanelEvent('User sign in request',props, getCallBckFn(targetURL)) } else { trackMixpanelEvent('User sign in request',props) } }; //Common signout function function signout(targetURL,register){ mixpanel.cookie.clear(); // clear advanced search persisted attributes in local storage for (var key in localStorageKeysArray ) { localStorage.removeItem(localStorageKeysArray [key]); } localStorage.removeItem('ngStorage-owler_advSearchObject'); if(targetURL == undefined || register == undefined){ location.href = HOST_WITHOUT_SSL+"j_spring_security_logout"; }else{ location.href = HOST_WITHOUT_SSL+"j_spring_security_logout?targetURL="+targetURL+"®ister="+register; } } function logout(targetURL,register){ signout(targetURL,register); } function getUrlParameter(parameterKey) { var urlParametersString = window.location.search.substring(1); if (urlParametersString != "") { var urlParametersList = urlParametersString.split('&'); for (var i = 0; i < urlParametersList.length; i++) { var urlParameterKeyValue = urlParametersList[i].split('='); if (urlParameterKeyValue[0] == parameterKey) { return urlParameterKeyValue[1]; } } } } /*Jquery toggling for Search icon in mobile Header*/ $(document).ready(function() { $(document).on('click touchstart', function (event){ var $trigger = $("#search-holder"); var $trigger1 = $("#header-search-icon"); if($trigger.find(event.target).length > 0 || $trigger1[0] === event.target || $trigger1[0] === event.target.parentElement){ $("#search-holder").addClass('width-transition'); } else { $("#search-holder").removeClass('width-transition'); } }); });