/**
* @author sudumalp
*/
var HOST_WITH_SSL;
var HOST_WITHOUT_SSL;
var SIGN_UP_PAGETYPE='sign_up_page_type';
var SIGN_UP_ORIGIN='SignupOrigin';
var DEFAULT_ORIGIN='undefined';
var COMPANY_NAME='company_name';
var LANDING_PAGE = 'landc';
var REGISTER_PAGE = 'regc';
var USER_REG = 'user_reg';
var LOGO_CONFIRMATION = 'logo_c';
var POPUP_ONBOARDING_STEP1_STARTED= 'Pop Up 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"];
var imageUploaderData;
//CAUTION : We have other copy this map @ OAuthcallback.jsp as well, please keep it Sync
var signUpPageTypeMap=['Home Page','Mobile Homepage','Company Profile Page','CP - Overview Page','CP - Competitors Page','CP - Funding and Acquisitions Page','CP - Info','CP - Acquisition Page','CP - News and Events Page','CP - Polls page','Poll Page','iFrame Page','CIR Example Page','Funding List','Acquisition List','Leadership List','External Referral','Browse Company Page','Marketing Page','Special Reports Page','Daily Funding List','Daily Acquisition List','Daily Leadership List', 'Signup Page','CP - Portfolio Page','CP - CA Page'];
function initializeUrls(appUrl) {
HOST_WITH_SSL = appUrl + "/";
HOST_WITHOUT_SSL = HOST_WITH_SSL;
}
function showLoginPopUpInPolls(origin) {
var targetURL = getCompetitorSectionUrl(companyId, companyName);
showLoginPopup(origin, targetURL, false);
setTimeout(function() {
$("#TB_load").remove();
}, 1);
}
function showLoginPopup(popupOrigin,targetURL,follow) {
if(popupOrigin!=''&&popupOrigin!=null) {
setCookie(SIGN_UP_ORIGIN, popupOrigin, 120);
}else{
setCookie(SIGN_UP_ORIGIN, DEFAULT_ORIGIN, 120);
}
setPageTypeCookie(popupOrigin)
resetForm($("#registerForm"));
resetForm($("#simpleRegisterForm"));
if (targetURL==null || targetURL=="") {
targetURL=window.location.href;
if(follow !=undefined && follow){
targetURL=targetURL+"/follow"
}
}
document.getElementById("targetURL").value = targetURL;
$("#pageless-onboarding-popup").show();
}
function animateInactiveBar() {
// alert("clicked");
$("#inactivebar").addClass("animate").delay(1000).queue(function(next){
$(this).removeClass("animate");
next();
});
}
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);
}
return validOrNot;
}, jQuery.format("Please fill at least {0} of these fields."));
/* Login Link - Click event */
$("#signInLink").click(function(){
setCookie(SIGN_UP_ORIGIN,'Login Popup',120);
setPageTypeCookie('Company Profile Page')
tb_show('', '#TB_inline?height=285&width=480&inlineId=signInFormDiv');
signInForm.resetForm();
resetPasswordRequestValidator.resetForm();
resetForm($('#signInForm'));
$("#signupFormDivContainer").hide();
$("#signInFormResponseDivContainer").hide();
$('#signInFormDivContainer').show();
$('#loginError').hide();
setTimeout(function() {
$("#emailSignIn").focus();
}, 500);
});
$(".login-close-popup").click(function(){
resetForm($('#signInForm'));
$("#signInFormDiv").removeClass("showLogin");
$("#pageless-onboarding-popup").show();
});
$("#reqList").click(function() {
resetForm($('#requestListByUrlForm'));
$("#requestListUrlTextBox").removeClass("error");
});
$("#signInLinkPopup").click(function() {
signInForm.resetForm();
resetForm($('#signInForm'));
$("#signInFormResponseDivContainer").hide();
$('#signInFormDivContainer').show();
$('#loginError').hide();
});
/* 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;
});
$("#cp-signup").click(function() {
setCookie(SIGN_UP_ORIGIN,'Profile Sign Up Button',120);
setPageTypeCookie('Company Profile Page')
resetForm($("#registerForm"));
resetForm($("#simpleRegisterForm"));
tb_init();
//tb_show('REGISTER FOR FULL ACCESS',
//'#TB_inline?height=295&width=275&inlineId=signup_companyProfile');
tb_show('REGISTER FOR FREE','#TB_inline?height=255&width=500&inlineId=simple_signup_companyProfile');
$("#cp_signup .signup_box").hide();
$('#cp_signup .registration_box').show();
});
$("#cp_signinLink").click(function() {
signInForm.resetForm();
resetPasswordRequestValidator.resetForm();
resetForm($('#signInForm'));
$("#signupFormDivContainer").hide();
$("#resetPasswordRequestSuccessDiv").hide();
$('#resetPasswordRequestDivContainer').hide();
$('#signInFormDivContainer').show();
$('#loginError').hide();
tb_remove();
setTimeout(function() {
tb_show("", "#TB_inline?height=285&width=480&inlineId=signInFormDiv");
$("#emailSignIn").focus();
}, 500);
return false;
});
$("#cp_signup .already").click(function() {
signInForm.resetForm();
resetPasswordRequestValidator.resetForm();
resetForm($('#signInForm'));
$("#signupFormDivContainer").hide();
$("#resetPasswordRequestSuccessDiv").hide();
$('#resetPasswordRequestDivContainer').hide();
$('#signInFormDivContainer').show();
$('#loginError').hide();
tb_remove();
setTimeout(function() {
tb_show("", "#TB_inline?height=445&width=470&inlineId=signInFormDiv");
$("#emailSignIn").focus();
}, 500);
return false;
});
/* Sign up Link inside login popup - Click event */
$("#sign_up").click(function() {
signupFormValidator.resetForm();
resetForm($("#signupForm"));
$("#signupError").hide();
$("#signupFormDivContainer").show();
$('#signInFormDivContainer').hide();
tb_show("Sign up to Create an Account", "#TB_inline?height=345&width=505&inlineId=signupFormDiv");
return false;
});
/* Add Company Link - Click event */
$("#addCompanyLink").click(function() {
resetForm($("#addCompanyForm"));
$("#addCompanySucccessMessageDiv").hide();
$("#addCompanyErrorMessagesDiv").html("");
$("#companylogopicture").val("");
$(".imgMainPreview").attr('src', CDNImgPATH+'/images/empty_logo.png');
$("#addCompanyFormErrorMessagesDiv p").html('');
$("#addCompanyFormErrorMessagesDiv").hide();
});
/* 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() {
try{
mixpanel.cookie.clear();
}catch(e){
}
location.href = HOST_WITHOUT_SSL+"j_spring_security_logout";
});
$("#sign_out").click(logout);
/* 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 section js */
$('#cp_signup .email-signup-link').click(function() {
$('#cp_signup .signup_box').hide();
$('#cp_signup .registration_box').show();
$('#TB_ajaxContent').animate({
height:"+=50"
},300);
});
$('#cp_signup .signup_social a').click(function() {
registerFormValidator.resetForm();
resetForm($("#registerForm"));
$('#cp_signup .registration_box').hide();
$('#cp_signup .social_box').show();
$('#TB_ajaxContent').animate({
height:"-=50"
},300);
});
$("#referralLink").click(function() {
$("html").css({'overflow':'hidden'});
$("body")
.append(
"
");
$("#referralPopup").show();
$(".socialmedia").show();
$("#emailForm").hide();
$('#referralPopup .popup_arrow').show();
trackMixpanelEvent("Clicked Referral Button");
});
$("#referralLink1").click(function() {
$("html").css({'overflow':'hidden'});
$("body")
.append(
"");
$("#referralPopup").show();
$(".socialmedia").show();
$("#emailForm").hide();
$('#referralPopup .popup_arrow').show();
trackMixpanelEvent("Clicked Referral Button");
});
$("#overlay_body").live("click", function() {
$("#overlay_body").remove();
$("#referralPopup").hide();
$("html").css({'overflow':'auto'});
});
$("#referCloseButton").click(function() {
$("#overlay_body").remove();
$("#referralPopup").hide();
$("html").css({'overflow':'auto'});
});
$("#openEmailForm").click(function() {
emailReferralForm.resetForm();
resetForm($("#emailreferralform"));
$(".socialmedia").hide();
$("#emailForm").show();
});
$("#referralEmailConfirmationOk").click(function() {
$("#overlay_body").remove();
$("#referralPopup").hide();
$("html").css({'overflow':'auto'});
});
$(".socialicons a.linkedin").click(function() {
trackMixpanelEvent("Social Referral Link",{ "Channel Used": "LinkedIn"});
});
/*$(".socialicons a.twitter").click(function() {
mixpanel.track("Social Referral Link",{ "Channel Used": "Twitter"});
});*/
$(".socialicons a.facebook").click(function() {
trackMixpanelEvent("Social Referral Link",{ "Channel Used": "Facebook"});
});
$('.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");
});
$.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 targetURL = $("input#targetURL").val();
if(targetURL == "" || targetURL == 'null')
{
targetURL = HOST_WITH_SSL;
}
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
window.location.assign(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;
}
});
//for simple success form
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 targetURL = $("input#targetURL").val();
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 = "";
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;
}
});
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
window.location.reload();
} 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;
}
});
/*Simple Register Form*/
var registerFormValidator = $("#simpleRegisterForm")
.validate(processFormValidate("input#simpleEmail", '#simpleSignUpSubmit', "#simpleRegisterError", "#simpleRegisterForm"));
$("#close_simple_signup_box").click(
function() {
$("#simple_signup_box").hide();
}
);
var curtainRegisterFormValidator = $("#curtainRegisterForm")
.validate(processFormValidate("input#curtainEmail", '#curtainRegisterSubmit', "#curtainRegisterError", "#curtainRegisterForm"));
$("#curtainRegisterForm").click(function(){
setPageTypeCookie();
var popupOrigin = getUrlParameter('Origin');
if(popupOrigin!=''&&popupOrigin!=null) {
setCookie(SIGN_UP_ORIGIN, popupOrigin, 120);
} else {
setCookie(SIGN_UP_ORIGIN,'Profile Page #11 - plain pop-up', 120);
}
});
var curtainPollRegisterFormValidator = $("#curtainPollRegisterForm")
.validate(processFormValidate("input#curtainPollEmail", '#curtainPollRegisterSubmit', "#curtainPollRegisterError", "#curtainPollRegisterForm"));
$("#curtainPollRegisterForm").click(function(){
setPageTypeCookie();
setCookie(SIGN_UP_ORIGIN,'Poll Page 5Y - Medium style pop-up', 120);
});
var curtainProfileRegisterFormValidator = $("#curtainProfileRegisterForm")
.validate(processFormValidate("input#curtainProfileEmail", '#curtainProfileRegisterSubmit', "#curtainProfileRegisterError", "#curtainProfileRegisterForm"));
$("#curtainProfileRegisterForm").click(function(){
setPageTypeCookie();
setCookie(SIGN_UP_ORIGIN,'Profile Page - Social', 120);
});
/*cir Signup Register Form*/
var cirSimpleRegisterFormValidator = $("#cirSimpleSignupRegisterForm")
.validate(processFormValidate("input#simpleSignupEmail", '#simpleSignUpRegisterSubmit', "#simpleSignupRegisterError", "#cirSimpleSignupRegisterForm"));
var reportsWebSimpleSignupFormValidator = $("#reportsWebSimpleSignupForm").validate(processFormValidate("input#simpleSignupEmail", '#simpleSignUpRegisterSubmit', "#simpleSignupRegisterError", "#reportsWebSimpleSignupForm"));
$("#cirSimpleSignupRegisterForm").click(function(){
setPageTypeCookie();
setCookie(SIGN_UP_ORIGIN,'Profile Sign Up Button', 120);
});
$("#reportsWebSimpleSignupForm").click(function(){
setPageTypeCookie();
setCookie(SIGN_UP_ORIGIN,'Profile Sign Up Button', 120);
});
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 emailValue = $(inputBoxDom).val();
var dataString = "email="+emailValue;
$(submitButtonDom).attr("disabled", true);
var url = HOST_WITH_SSL + "addSimpleVisitor.htm?";
var targetURL = window.location.href;
dataString = dataString + "&targetURL=" + targetURL;
if(window.companyId && companyId != null) {
dataString = dataString + "&employerId=" + companyId;
}
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;
}
$('input#business-email').keyup(function(e) {
if(e.which == 13 || e.keyCode == 13 || e.which == 9 || e.keyCode == 9) {
validateBusinessEmail("#form-signup-getBusinessEmail", "input#business-email", '#business-email-submit', "#form-error-message");
}else{
emailGet = $("input#business-email").val();
var emailValidateResult = validateEmail(emailGet);
if(emailValidateResult){
validateBusinessEmail("#form-signup-getBusinessEmail", "input#business-email", '#business-email-submit', "#form-error-message");
}else{
disableSumbitButton("#business-email-submit");
}
}
});
//Signup.jsp Server side ERROR Handling
$("#form-signup-getBusinessEmail").ready(function(){
var errorCheck = $("#hiddenFieldForSignupCheck").val();
if(errorCheck == 'true'){
var errorMessage = $("#hiddenFieldErrorForSignup").val();
showErrorMeg("#form-error-message", errorMessage);
hideErrorMeg("#form-error-message", "#form-signup-getBusinessEmail");
}
});
$('input#business-email').focusout(function(){
var getBusinessEmail = $('input#business-email').val();
validateBusinessEmail("#form-signup-getBusinessEmail", "input#business-email", '#business-email-submit', "#form-error-message");
});
$("#business-email-submit").click(function(){
setPageTypeCookie('Signup Page');
var errorMeg = "#form-error-message";
var submitId = "#business-email-submit";
var inputId = "input#business-email";
var formID = "#form-signup-getBusinessEmail";
var emailValue = $(inputId).val();
var dataString = "email="+emailValue;
url = HOST_WITH_SSL + "emailSignup.htm?";
if(validateDomain(emailValue)){
processSignupFlowForBusinessEmail(formID, dataString, inputId, submitId, errorMeg, undefined, trackMixpanelLoginEvent, trackMixpanelEvent, url);
} else {
$("#domain_error_message").show();
$(submitId).removeAttr('disabled');
$(submitId).addClass("active");
}
return false;
});
//Customized function
function validateBusinessEmail(formID, inputId, submitId, errorMeg){
emailGet = $(inputId).val();
if(emailGet == '' || emailGet == null || emailGet == undefined){
return false;
}else{
var emailValidateResult = validateEmail(emailGet);
if(emailValidateResult){
$(submitId).removeAttr('disabled');
$(submitId).addClass("active");
}else{
disableSumbitButton(submitId);
var text = 'Please enter a valid email address';
showErrorMeg(errorMeg, text);
hideErrorMeg(errorMeg, formID);
}
}
}
function processSignupFlowForBusinessEmail(formID, dataString, inputBoxDom, submitButtonDom, ErrorBoxDom,showLoginPopup,trackMixpanelLoginEvent,trackMixpanelEvent, url) {
$.ajax({
type : "POST",
url : url,
data : dataString,
success : function(data, textStatus, jQXHr) {
var response = $.parseJSON(data);
if (response.result == SUCCESS_STRING) {
// Fixing Mixpanel Origin. If origin is not available, then user is registering through signup.htm page
var signUpOrigin=getCookie(SIGN_UP_ORIGIN)
if (signUpOrigin == undefined || signUpOrigin.trim().length == 0) {
// this method is called only for signup.htm, check this is used elsewhere.
setCookie(SIGN_UP_ORIGIN,'External Signup Link',120);
}
var targetURL = $("input#targetURL").val();
if(targetURL == "" || targetURL == 'null')
{
targetURL = HOST_WITHOUT_SSL+"home.htm";
}
trackMixpanelLoginEvent(response,getCallBckFn(targetURL));
} else {
if (ErrorBoxDom != undefined && ErrorBoxDom != "") {
var text = response.message;
showErrorMeg(ErrorBoxDom, text);
hideErrorMeg(ErrorBoxDom, formID);
}
if (submitButtonDom != undefined
&& submitButtonDom != "") {
$(submitButtonDom).attr("disabled", false);
}
}
},
error : function(data, textStatus, jQXhr) {
if ((submitButtonDom != undefined && submitButtonDom != "")
|| (ErrorBoxDom != undefined && ErrorBoxDom != "")) {
$(ErrorBoxDom).html = data;
$(submitButtonDom).attr("disabled", false);
}
}
});
}
function showErrorMeg(errorMeg, text){
$(errorMeg).prevAll('.form_error_message').remove();
var html = '';
html += '';
html += '';
html += '';
html += text;
html += '';
$(errorMeg).before($(html).fadeIn(400));
}
function hideErrorMeg(errorMeg, formID){
setTimeout(function(){
$(errorMeg).prevAll('.form_error_message').fadeOut(400);
setTimeout(function(){
$(errorMeg).closest(formID).find('.form_error_message').remove();
},500);
}, 3000);
}
function disableSumbitButton(submitId){
$(submitId).attr('disabled', 'disabled');
$(submitId).removeClass("active");
}
/* Referral Form submission */
var emailReferralForm = $("#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');
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() {
var message = $("#message").val();
message = message.replace(/\n\r?/g, '
');
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+ "&message="+message;
var url = HOST_WITH_SSL+"emailreferral.htm?";
$("#referralPopupContainer").append("");
$
.ajax({
type : "POST",
url : url,
data : dataString,
success : function(data, textStatus,
jQXHr) {
var response = $.parseJSON(data);
if (response.result == SUCCESS_STRING) {
$('#emailForm').hide();
$('.popup_overlay').remove();
$('#referralEmailConfirmationDiv').show();
$('#referralPopup .popup_arrow').hide();
$('#referralEmailConfirmationSuccessDiv').html(response.message);
var count=response.count;
trackMixpanelEvent("Email Referral Link",{"Number of referral recipients": count+""});
} else {
$('#emailForm').hide();
$('.popup_overlay').remove();
$('#referralPopup .popup_arrow').hide();
$('#referralEmailConfirmationDiv').show();
$('#referralEmailConfirmationErrorDiv').html(response.message);
}
},
error : function(data, textStatus,
jQXhr) {
$('#emailForm').hide();
$('.popup_overlay').remove();
$('#referralPopup .popup_arrow').hide();
$('#referralEmailConfirmationDiv').show();
$('#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();
}
});
});
/* Sign up form */
var signupFormValidator = $("#signupForm")
.validate(
{
rules : {
name : {
required : true
},
email : {
required : true,
emailValidation : true
},
password : {
required : true,
minlength : 6
},
confirmPassword : {
equalTo : "#password"
}
},
messages : {
name : {
required : "Please enter your name"
},
email : {
required : "Please enter a valid email address",
emailValidation : "Please enter a valid email address"
},
password : {
required : "Please enter a password",
minlength : "Your password must be at least 6 characters"
},
confirmPassword : {
equalTo : "Passwords did 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() - 260);
error.css('top', $(element).position().top + $(element).height() - 55);
}
},
submitHandler : function() {
var name = $("input#name").val();
var emailValue = $("input#email").val();
var password = $("input#password").val();
var profileName = $("#profileName").val();
var companyEmail = "0";
var selected = $("#signupForm input[type='radio'][name='companyEmail']:checked");
if (selected.length > 0){
if(selected.val() == "Yes")
companyEmail = "1"
}
var industry = $("input#industry").val();
var role = $("input#role").val();
var dataString = "name="+name + "&email=" + emailValue
+ "&password=" + password+"&profileName="+profileName+"&industry="+industry+"&role="+role+"&companyEmail="+companyEmail;
$('#signup').attr("disabled", true);
var url = HOST_WITH_SSL+"addVisitor.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) {
$("span#emailContent").html(emailValue);
$('#signupFormDiv').hide();
$('#signup').attr("disabled",
false);
$("#signupFormDivContainer")
.hide();
$(".popup_overlay").remove();
tb_show("Confirmation",
"#TB_inline?height=130&width=470&inlineId=confirmationDiv");
$('#confirmationDivContainer')
.show();
} else {
$("#signupError p").html(response.message);
$('#signupError').show();
$(".popup_overlay").remove();
$('#signup').attr("disabled",
false);
}
},
error : function(data, textStatus,
jQXhr) {
$("#signupError p").html = data;
$(".popup_overlay").remove();
$('#signup').attr("disabled", false);
}
});
return false;
}
});
/* Sign up form in by reports page */
var buyReportSignupFormValidator = $("#signupFormBuyReports")
.validate(
{
rules : {
buy_name : {
required : true
},
buy_email : {
required : true,
email : true
},
buy_password : {
required : true,
minlength : 6
},
buy_confirmPassword : {
equalTo : "#buy_password"
}
},
messages : {
buy_name : {
required : "Please enter your name"
},
buy_email : {
required : "Please enter a valid email address",
email : "Please enter a valid email address"
},
buy_password : {
required : "Please enter a password",
minlength : "Your password must be at least 6 characters"
},
buy_confirmPassword : {
equalTo : "Passwords did 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") == "buy_fname") || ($(element).attr("id") == "buy_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() - 260);
error.css('top', $(element).position().top + $(element).height() - 55);
}
},
submitHandler : function() {
var name = $("input#buy_name").val();
var buy_emailValue = $("input#buy_email").val();
var buy_password = $("input#buy_password").val();
var dataString = "name="+name + "&email=" + buy_emailValue
+ "&password=" + buy_password;
$('#buy_submit').attr("disabled", true);
var url = HOST_WITH_SSL+"addVisitor.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) {
$("span#emailContent").html(buy_emailValue);
$('#signupFormDivInBuyReports').hide();
$("#signupFormDivInBuyReportsContainer")
.hide();
$(".popup_overlay").remove();
tb_show("Confirmation",
"#TB_inline?height=130&width=470&inlineId=confirmationDiv");
$('#confirmationDivContainer')
.show();
$('#buy_submit').attr("disabled", false);
} else {
$(".popup_overlay").remove();
$("#buy_signUpErrorMessagesDiv p").html(response.message);
$("#buy_signUpErrorMessagesDiv").show();
$('#buy_submit').attr("disabled", false);
}
},
error : function(data, textStatus,
jQXhr) {
$("#buy_signUpErrorMessagesDiv p").html = data;
$(".popup_overlay").remove();
$('#buy_submit').attr("disabled", false);
}
});
return false;
}
});
$(".signup_buyreport").live('click', function() {
buyReportSignupFormValidator.resetForm();
resetForm($('#signupFormBuyReports'));
$("#buy_signUpErrorMessagesDiv").hide();
$("#loginError").hide();
tb_remove();
});
$("#signupCancel").click(function() {
signupFormValidator.resetForm();
resetForm($('#signupForm'));
tb_remove();
});
$(".have_account").live('click', 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();
signupFormValidator.resetForm();
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 = getUrlParameter('targetURL');
if(targetURL == null || targetURL == undefined) {
targetURL = window.location.href;
}
if(window.currentPage == 'errorPage') {
targetURL=undefined;
}
var 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();
trackSignInRequest(response.memberId,emailValue,'SingIn Form',false)
} 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) {
if(window.currentPage == "errorPage") {
if(targetURL == undefined) {
targetURL = HOST_WITHOUT_SSL+"home.htm";
}
}
trackSignInRequest(response.memberId,emailValue,'SingIn Form',true,targetURL)
} else {
showSignInErrorMsg(response.message);
$("#signInForm input").removeClass("valid");
}
},
error : function(data, textStatus, jqXHr) {
showSignInErrorMsg(data);
}
});
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=registerThanksDivSocial&modal=true");
}, 500);
$("#profilename1").val(OauthResponse.screenName);
var userIdProp={};
userIdProp['UserId']=OauthResponse.memberId;
trackMixpanelEvent('Simplified Signup Step 2 Viewed',userIdProp)
}
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() - 230);
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 did 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'));
$("#resetPasswordForm").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
},
companyShortName : {
required : true,
unicodeValidation : true
},
companyURL : {
required : true,
onkeyup : false
}
},
messages : {
companyName : {
required : "Please enter a company name"
},
companyURL : {
required : "Please enter valid URL",
validateURL : "Please enter a valid URL"
},
companyShortName : {
required : "Please select a valid company short name"
}
},
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 companylogopicture = $("#companylogopicture").val();
var companyLogoFounded = $("#companyLogoFounded:checked").val();
if(companylogopicture == "" && companyLogoFounded == undefined ) {
$("#addCompanyFormErrorMessagesDiv p").html('Please upload company logo image');
$("#addCompanyFormErrorMessagesDiv").show();
$("#addCompanyFormErrorMessagesDiv .error").show();
return;
}
var logoWidth = $("#companyLogoWidth").val();
var logoHeight = $("#companyLogoHeight").val();
var companyName = $("#companyName").val();
companyName = escape(companyName);
var companyURL = $("#companyURL").val();
var country = $("#country").val();
var priority = $("#priority").val();
var companyShortName = $("#companyShortName").val();
var imagePayload = {};
imagePayload.imageData = imageUploaderData;
imagePayload.websiteScreenshotCrop = false;
imagePayload.imageId = "logo/"+getSEOFriendlyCompanyName(companyShortName);
imagePayload.formType = "LOGO";
imagePayload.imageDimensionType = "COMPANY_LOGO";
var url = HOST_WITHOUT_SSL+"saveImageData.htm";
$("#TB_window").append("");
$.ajax({
type : "POST",
url : url,
dataType: "json",
contentType: "application/json; charset=utf-8",
data : JSON.stringify(imagePayload),
success : function(data, textStatus, jqXhr) {
var dataString = "companyName=" + companyName
+ "&companyURL=" + companyURL + "&country="
+ country + "&priority=" + priority + "&companyShortName="
+ companyShortName+ "&companylogopicture=" + data.awsUrl+"&companyLogoWidth=" +data.imageWidth+"&companyLogoHeight=" +data.imageHeight;
var url = HOST_WITHOUT_SSL+"admin/addCompany.htm?";
$.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);
}
});
},
error : function(data, textStatus, jqXHr) {
errorMessage('Error !!! Status =' + data);
}
});
return false;
}
});
});
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();
$(".validate").live('mouseenter', function() {
$(this).prev(".form_error_message, .form_error_message_right").css('visibility', 'visible');
});
$(".validate").live('mouseleave', function() {
$(this).prev(".form_error_message, .form_error_message_right").css('visibility', 'hidden');
});
$("#signupForm input#password").focus(function() {
$("#signupForm input#confirmPassword").val('');
});
$("#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','');
}
$(document).ready(function() {
$('#resendEmail').live("click",
function() {
var url = HOST_WITHOUT_SSL+"resendEmail.htm";
$('#resendEmail').attr("disabled", true);
$("#resendEmail").append("");
$.ajax({
type : "POST",
url : url,
data : "url="+url,
success : function(data, textStatus, jQXHr) {
var response = $.parseJSON(data);
$(".popup_overlay").remove();
if (response.result == SUCCESS_STRING) {
$('#resendEmail').attr("disabled", false);
$('#resendEmailActivation').html("Roger that! A confirmation email has been resent to "+response.email+".
");
}
},
error : function(data, textStatus, jQXhr) {
$('#resendEmailActivation').html("Please try again later..
");
}
});
});
});
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, getCurrentPage(), 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())
window.location.reload();
}else if(status == OAUTH_STATUS_EMAIL_REQD){
var targetURL=window.location.href;
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);
if(window.companyId != undefined){
setCookie('i_c', window.companyId, 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) {
setCookie(USER_REG, 0, 300);
if(response.employerURL != undefined){
setCookie(LOGO_CONFIRMATION, 0, 300);
trackMixpanelLoginEvent(response,getCallBckFn(window.location.href+"?onBoardingComplete=true"));
} else {
$("#pagelessOnboardingRegistrationPopup").hide();
$("#registrationFlowSteps").show();
$("#userEmail").val(response.userEmail);
var property={};
property['User role']=response.userRole;
property['UserId']=response.memberId;
trackMixpanelLoginEvent(response,function(){
trackMixpanelEvent(POPUP_ONBOARDING_STEP1_STARTED,property)
});
}
} else if(status == OAUTH_STATUS_EMAIL_REQD){
var targetURL=window.location.href;
window.location.replace(HOST_WITH_SSL + 'signup.htm?targetURL=' + targetURL);
} else if(status == OAUTH_STATUS_USER_LOGGED_IN){
trackMixpanelLoginEvent(response,getCallBckFn())
window.location.reload();
} 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();
$("#dynamic_text_forSocialLogin").html("TWITTER");
}
},
error : function(data, textStatus, jQXHr) {
alert(textStatus);
}
});
return false;
});
function initSocialSignupData(){
if(window.companyId!=undefined)
setCookie("c_id",window.companyId,480);
}
$(".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);
initSocialSignupData();
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);
initSocialSignupData();
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);
initSocialSignupData();
social_connect.exec();
$("#dynamic_text_forSocialLogin").html("FACEBOOK");
}
},
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);
initSocialSignupData();
social_connect.exec();
}
},
error : function(data, textStatus, jQXHr) {
alert(textStatus);
}
});
return false;
});
});
$(window).bind("load", function() {
var isShowSignup = getUrlParameter('showSignUp');
var checkEmail = getUrlParameter('Email');
if (checkEmail != undefined && checkEmail != ""){
setPageTypeCookie('Email URL Signup');
if (validateEmail(checkEmail)) {
setCookie(SIGN_UP_ORIGIN,'Email URL Signup',120);
var dataString = "email=" + checkEmail;
var url = HOST_WITH_SSL + "addSimpleVisitor.htm?";
if(window.companyId && companyId != null) {
dataString = dataString + "&employerId=" + companyId;
}
processSignupFlow(dataString, undefined, undefined,
undefined, showLoginPopup,trackMixpanelLoginEvent,trackMixpanelEvent, url);
}
else {
showLoginPopup('External Referral');
$("#simpleRegisterError").show();
$("#simpleRegisterError").html(
"Please enter valid email address");
}
}else if(isShowSignup!=undefined && isShowSignup=="true"){
var signupOrigin = getUrlParameter('Origin');
setPageTypeCookie('External Referral');
if(signupOrigin!=undefined&&signupOrigin!='') {
showLoginPopup(signupOrigin);
}
else {
showLoginPopup('External Referral');
}
}
// To set landing page of the user
if(getCookie(LANDING_PAGE) == null){
setCookie(LANDING_PAGE, getCurrentPage(), 604800); // Expiry time for 7 days
}
});
function getCurrentPage() {
var landingPage = currentPage;
if (window.companyId != undefined) {
if (landingPage == 'seoCompanyProfile') {
landingPage = document.getElementById("originPage").value;
landingPage = landingPage.replaceAll(" ", "");
}
landingPage = landingPage + "_" + window.companyId;
}
return landingPage;
}
function validateEmail(email) {
return /^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/i
.test(email);
}
function getSignUpPageType() {
var signUpPageType = signUpPageTypeMap[getCookie(SIGN_UP_PAGETYPE)];
return signUpPageType;
}
function trackMixpanelLoginEvent(response,callBckFun){
var event=response.event
var memberId=response.memberId
var mode=response.mode
var memberRole=response.userRole
var emailId=response.userEmail
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 employerId =response.employerId
var signUpPageType = signUpPageTypeMap[getCookie(SIGN_UP_PAGETYPE)]
property['Page Type'] = signUpPageType
property['Visitor Id'] = response.visitor_id;
property['Email'] = emailId
if(response.Type) {
property['Type'] = response.Type;
}
property['Employer Detected'] = (employerDeduction!=undefined)?true:false
mixpanel.people.set('$last_seen',new Date());
mixpanel.people.set('employer_id',''+employerId);
mixpanel.people.set_once('$email',emailId);
mixpanel.people.set_once('$name',screenName);
mixpanel.people.set_once('$SignUpDate', new Date());
mixpanel.people.set_once('registration_source', response.registration_source);
}
setUtmParams();
//clear Cookies
deleteCookie(SIGN_UP_PAGETYPE);
deleteCookie(SIGN_UP_ORIGIN);
deleteCookie(OAUTH_STATUS_COOKIE);
deleteCookie(OAUTH_RESPONSE);
deleteCookie(LANDING_PAGE);
// initiate 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 setPageTypeCookie(popupOrigin){
var pageType;
try {
pageType=document.getElementById("originPage").value;
} catch(e) {
//Page with no origin type, Say, IFrame page
pageType=popupOrigin;
}
if (pageType != null) {
setCookie(SIGN_UP_PAGETYPE,signUpPageTypeMap.indexOf(pageType), 120);
}
}
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,showLoginPopup,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) {
var targetURL = $("input#targetURL").val();
if(targetURL == "" || targetURL == 'null')
{
targetURL = HOST_WITHOUT_SSL+"home.htm";
}
trackMixpanelLoginEvent(response,getCallBckFn(targetURL));
} else {
if (ErrorBoxDom != undefined && ErrorBoxDom != "") {
$(ErrorBoxDom).html(response.message);
$(ErrorBoxDom).show();
}else {
showLoginPopup('External Referral');
$("#simpleRegisterError").html(response.message);
$("#simpleRegisterError").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;
$(submitButtonDom).attr("disabled", false);
}
$(".popup_overlay").remove();
}
});
}
function getUrlParameter(sParam)
{
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++)
{
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam)
{
return sParameterName[1];
}
}
}
function generatePopupTitle(){
var html = '';
html += '';
html += 'WELCOME TO OWLER! ';
html += 'WHAT CAN YOU EXPECT NEXT?';
html += '
';
return html;
}
function showWelcomePopup(){
var widthCalculate = $(window).width() - 20;
tb_show('', "#TB_inline?height=495&width=650&inlineId=welcome-popup");
var getTheDOM = generatePopupTitle();
$("#TB_ajaxWindowTitle").html(generatePopupTitle);
$("#TB_ajaxWindowTitle").css("height","inherit");
$("#TB_ajaxContent").css("float","left");
$("#TB_ajaxContent").css("padding-top","5px");
}
//function showWelcomePopup(){
// var widthCalculate = $(window).width() - 20;
// tb_show('', "#TB_inline?height=200&inlineId=welcome-popup");
// var getTheDOM = generatePopupTitle();
// $("#TB_ajaxWindowTitle").html(generatePopupTitle);
// $("#TB_ajaxWindowTitle").css("height","inherit");
// if(widthCalculate <= 550 ){
// var TB_WIDTH = widthCalculate;
// }else{
// var TB_WIDTH = 550;
// }
// var dynamicHeight = $(".welcome-popup-innercontainer").height();
// TB_HEIGHT = dynamicHeight + 60; // set the new width and height dimensions here..
// $("#TB_window").animate({
// marginLeft: '-' + parseInt((TB_WIDTH / 2), 10) + 'px',
// width: TB_WIDTH + 'px',
// height: TB_HEIGHT + 'px',
// marginTop: '-' + parseInt((TB_HEIGHT / 2), 10) + 'px'
// });
//
// $("#TB_ajaxContent").css({
// width: TB_WIDTH + 'px',
// height: dynamicHeight + 'px',
// });
// $("#TB_ajaxContent").css("float","left");
// $("#TB_ajaxContent").css("padding-top","25px");
// $("#TB_ajaxContent").css("overflow-y","scroll");
//}
//@see https://infoarmy.jira.com/wiki/display/MKT/Timezone+conversions+for+snapshot
// Method returns the gmt timezone offset without the daylight savings
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){
return function(){
if(targetURL){
window.location.assign(targetURL);
} else {
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)
}
};
//Tracking user's session time in Mixpanel - Duration is from entering the website to closing the window/tab
$(document).ready(function() {
var timerId = setTimeout(function() {
if(mixpanel != undefined) {
mixpanel.time_event("Time on Site");
}
}, 20000);
$(window).on('beforeunload', function(){
trackMixpanelEvent('Time on Site');
});
});
function logout(targetURL,register){
try{
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');
}catch(e){
}
var signOutProperty={};
var timeStamp = new Date().toUTCString();
signOutProperty['UserId']=userId;
signOutProperty['Timestamp']=timeStamp;
trackMixpanelEvent('User Sign Out',signOutProperty,function(){
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;
}
});
}