var CallElement=function(){var currentCallToActionTypeId=null;var currentCallToActionType=null;var currentCallToActionTypeId2=null;var currentCallToActionType2=null;var callerPhone=null;var phoneWithoutCountryCode=null;var callerIsMember=null;var countryISOCode=null;var loginScreenMessage=null;var loginForwardURL=null;var countryDialCode=null;var shouldAddPhone=false;var counter=null;var callId=null;var queryForStatus=true;var warningMessage=null;var warningType=null;var didPolicy=null;var c2cPolicy=null;var callee=null;var jaxBalance=null;var c2cJaxCost=null;var jaxtrOut=0;didUpsellShown=false;var phoneFromServer=null;var isDidCountry=true;var canGetSMSByDID=false;var handleBuyButtonClick=function(){if(currentCallToActionType!=null){var eventObject="{callToActionTypeString: '"+currentCallToActionType+"'}";currentCallToActionType=null;currentCallToActionTypeId=null;recordEvents("CallToActionResponseEvt",eventObject)}document.location.href="overview.jsp"};var handleUpsellBuyButtonClick=function(){if(currentCallToActionType!=null){var eventObject="{callToActionTypeString: '"+currentCallToActionType+"'}";currentCallToActionType=null;currentCallToActionTypeId=null;recordEvents("CallToActionResponseEvt",eventObject)}document.location.href="ssl/purchase_subscription.jsp"};var handleRegisterButtonClick=function(){document.location.href="registration.jsp"};var handleAfterCallEnd=function(){$("#endCallButton").hide();$("#footerText").show();if(isDidCountry&&C2C_START_PAGE=="home"){$("#okButton").html('<span style="font-size: 0.95em;">Get number</span>');$("#okButton").click(function(e){e.preventDefault();tab_reset();$("#tab_connect").find("img").attr("src",cdnURL+"/user/img/home/button_tab_connect_active.png");$("#tab_connect").addClass("active");$("#call_sms").hide();$("#connect").show();$("div.content").block({css:{border:"none",padding:"15px",backgroundColor:"#000","-webkit-border-radius":"10px","-moz-border-radius":"10px",opacity:".5",color:"#fff"}});$.ajax({type:"POST",url:"JaxtrSpeedDial.action",data:{fromStep:2,toStep:3,callee:callee},success:function(html){$("#connect").html(html);$("div.content").unblock()}});$.jaxtrBox.close()})}else{$("#okButton").click(function(){closeBox("c2c")})}if(C2C_START_PAGE=="home"){$("#buyButton").text("New Call");$("#buyButton").click(function(e){e.preventDefault();$.ajax({type:"POST",url:"JaxtrClick2Call.action",data:{forceDontWatchVideo:1},success:function(html){$("#connect").html(html);$("div.content").unblock()}});$.jaxtrBox.close();return false})}else{$("#okButton").removeClass("button");$("#okButton").addClass("button_centered")}jQuery.ajax({type:"POST",url:"Call.action",data:{act:"jaxBalance"},cache:false,success:function(msg){var jsonMsg=eval("("+msg+")");if(!jsonMsg.error){$("#jaxtrBox .jaxtrInfoBoxJaxBalance").show("slow");$("#footerText").html("Credit balance: "+getDisplayC2CBalance(jsonMsg.jaxBalance)+"");if($("#jax_balance_total").length>0){$("#jax_balance_total").text(jsonMsg.jaxBalance+" jax")}if($("#jax_balance_total_number").length>0){$("#jax_balance_total_number").text(jsonMsg.jaxBalance)}var helpBuyDone=false;$("#okButton").show();if(jsonMsg.jaxBalance<1){var msg='Call ended. <br/> <span style="font-size: 12px; font-weight: normal; color: #777777;">You have used all your calling credits. Continue saving on your phone bill by adding more credits to your account today.</span>';$("#call_status_text").html(msg);$("#okButton").hide();$("#buyButton").text("Buy Credit");$("#buyButton").unbind("click");$("#buyButton").removeClass("button");$("#buyButton").addClass("button_centered_buy");$("#buyButton").click(handleUpsellBuyButtonClick);helpBuyDone=true;var eventObject="{callToActionTypeString: 'BUY_JAX_C2C_UPSELL_Y'}";currentCallToActionType="BUY_JAX_C2C_UPSELL_Y";recordEvents("CallToActionEvt",eventObject)}if(helpBuyDone==false){var eventObject="{callToActionTypeString: 'BUY_JAX_C2C_EC'}";currentCallToActionType="BUY_JAX_C2C_EC";recordEvents("CallToActionEvt",eventObject)}if(C2C_START_PAGE=="home"){$("#buyButton").show()}}else{switch(jsonMsg.errorcode){case"NON_MEMBER":break;case"EXCEPTION":$("#footerText").html("Unable to retrieve your balance.");break}}}})};var initializeVoiceMailWarning=function(){$("#help_icon").hide();$("#jaxtr_box_title").html("&nbsp;");$("#call_element_learn_more").click(function(){$.jaxtrBox.loading(true);$.get("Call.action?act=learn_more",function(data){$.jaxtrBox.reveal(data,"")})});$("#learnMoreButtonOne").click(function(){$.jaxtrBox.loading(true);$.get("Call.action?act=call_options&callType="+jaxtrOut,function(data){$.jaxtrBox.reveal(data,"")})});$("input[@name='vm_warning_no_more']").click(function(){var user_id=jQuery.cookie("jaxtr1");if($("input[@name='vm_warning_no_more']").is(":checked")){jQuery.cookie("vm_warning_no_more",user_id+":true")}else{jQuery.cookie("vm_warning_no_more",user_id+":false")}$(this).blur()})};var initializeWarningScreen=function(){$("#message").html(warningMessage);if(warningType=="c2c5mins"){$("#buyButton").show();$("#callButton").show();$("#callButton").html("Continue call");$("#callButton").click(function(){$.jaxtrBox.loading(true);$.ajax({url:"Call.action?act=startCall",cache:false,success:function(data){$.jaxtrBox.reveal(data)}})})}else{if(warningType=="c2c1min"){if(!isDidCountry){$("#callButton").hide();$("#buyButton").removeClass("button");$("#buyButton").addClass("button_centered")}else{$("#callButton").html('<span style="font-size: 0.95em;">Get number</span>');$("#callButton").click(function(e){e.preventDefault();tab_reset();$("#tab_connect").find("img").attr("src",cdnURL+"/user/img/home/button_tab_connect_active.png");$("#tab_connect").addClass("active");$("#call_sms").hide();$("#connect").show();$("div.content").block({css:{border:"none",padding:"15px",backgroundColor:"#000","-webkit-border-radius":"10px","-moz-border-radius":"10px",opacity:".5",color:"#fff"}});$.ajax({type:"POST",url:"JaxtrSpeedDial.action",data:{fromStep:2,toStep:3,callee:callee},success:function(html){$("#connect").html(html);$("div.content").unblock()}});$.jaxtrBox.close()})}$("#buyButton").show()}}$("#help_icon").hide();$("#buyButton").click(handleBuyButtonClick)};var initializeUpsellScreen=function(){$("#close_icon").hide();$("#message").html("This is the upsell screen");$("#buttonOne").show();$("#buttonTwo").show();$("#buttonTwo").click(closeBox);$("#buttonOne").click(handleBuyButtonClick)};var clickEndCall=function(){queryForStatus=false;$("#call_status_img").attr("width","15");$("#call_status_img").attr("height","25");$("#call_status_img").attr("src","img/CallElement/call_icon_inactive.png");$("#call_status_text").html("Call Ended.");jQuery.ajax({type:"POST",url:"callcontrol",cache:false,data:{act:"end_call",tid:callId},success:function(msg){var jsonMsg=eval("("+msg+")");if(!jsonMsg.callOptions.error){$("#call_status_img").attr("width","15");$("#call_status_img").attr("height","25");$("#call_status_img").attr("src","img/CallElement/call_icon_inactive.png");var msg="Call Ended.";if(isDidCountry){msg+='<br/><span style="font-size: 12px; font-weight: normal; color: #777777;">For added savings and convenience, get a local jaxtr number to call this contact from your phone.</span>'}$("#call_status_text").html(msg);handleAfterCallEnd()}else{handleAfterCallEnd()}}})};var updateCallStatus=function(){if(queryForStatus){if(callId!=null||callId!=""||callId!="undefined"){jQuery.ajax({type:"POST",url:"callcontrol",cache:false,data:{act:"get_call_status",tid:callId},success:function(msg){var jsonMsg=eval("("+msg+")");if(!jsonMsg.callOptions.error){switch(jsonMsg.callOptions.callStatus){case"INIT":$("#call_status_img").attr("src","img/CallElement/call_icon_init.gif");$("#call_status_text").html("Now calling...");break;case"CONNECTING_CALLER":$("#call_status_img").attr("src","img/CallElement/call_icon_init.gif");$("#call_status_text").html("Now calling...");break;case"CONNECTING_CALLEE":$("#call_status_img").attr("src","img/CallElement/call_icon_init.gif");$("#call_status_text").html("Now calling...");break;case"ACTIVE":$("#call_status_img").attr("src","img/CallElement/call_icon_active.gif");$("#call_status_img").attr("width","67");$("#call_status_img").attr("height","27");$("#call_status_text").html("Call in progress...");break;case"FINISHED":$("#call_status_img").attr("src","img/CallElement/call_icon_inactive.png");$("#call_status_img").attr("width","15");$("#call_status_img").attr("height","25");var msg="Call ended.";if(isDidCountry){msg+='<br/><span style="font-size: 12px; font-weight: normal; color: #777777;">For added savings and convenience, get a local jaxtr number to call this contact from your phone.</span>'}$("#call_status_text").html(msg);handleAfterCallEnd();break;case"FINISHED_BY_POLICY":$("#call_status_img").attr("src","img/CallElement/call_icon_inactive.png");$("#call_status_img").attr("width","15");$("#call_status_img").attr("height","25");var msg="Call ended.";if(isDidCountry){msg+='<br/><span style="font-size: 12px; font-weight: normal; color: #777777;">For added savings and convenience, get a local jaxtr number to call this contact from your phone.</span>'}$("#call_status_text").html(msg);handleAfterCallEnd();break;case"FAILED":$("#call_status_img").attr("src","img/CallElement/call_icon_inactive.png");$("#call_status_img").attr("width","15");$("#call_status_img").attr("height","25");$("#call_status_text").html("Call failed. Please retry.");break;case"NIL":$("#call_status_img").attr("src","img/CallElement/call_icon_inactive.png");$("#call_status_img").attr("width","15");$("#call_status_img").attr("height","25");var msg="Call ended.";if(isDidCountry){msg+='<br/><span style="font-size: 12px; font-weight: normal; color: #777777;">For added savings and convenience, get a local jaxtr number to call this contact from your phone.</span>'}$("#call_status_text").html(msg);handleAfterCallEnd();return ;break}setTimeout("CallElement.updateStatus()",jsonMsg.callOptions.refreshPeriod)}else{handleC2CErrors(jsonMsg.callOptions.errorCode)}}})}}};var makeC2C=function(){$("#c2cLoading").show();$("#startCall").hide();jQuery.ajax({type:"POST",url:"callcontrol",cache:false,data:{act:"start_call",jaxtrOut:jaxtrOut,cid:callerPhone,cidhide:0,destctx:callee},success:function(msg){$("#loadingDiv").hide();var jsonMsg=eval("("+msg+")");if(!jsonMsg.callOptions.error){c2cPolicy=jsonMsg.callOptions.c2cCallOptionPolicy;var c2Cjax=Math.round((c2cPolicy.rateMicrojaxPerSec/1000000)*60);if(c2cPolicy.allowed&&jsonMsg.callOptions.callId>0){$("#call_status_text").html("Now calling...");$("#endCallButton").removeClass("button");$("#endCallButton").addClass("button_centered");$("#endCallButton").show();$("#endCallButton").click(clickEndCall);$("#c2cLoading").hide();$("#startCall").show();var numericRateC2C="";var xxC2C=(c2Cjax*(0.008));numericRateC2C=xxC2C.toFixed(3);numericRateC2C="$ "+c2cPolicy.callRate+"/min";$("#footerText").html("This call costs: "+numericRateC2C);callId=jsonMsg.callOptions.callId;updateCallStatus()}else{if(c2cPolicy.reasonCode=="BANNED_CALLEE"){$.get("Call.action?act=bannedCallee",function(data){$.jaxtrBox.reveal(data,"")});return }else{if(c2cPolicy.reasonCode=="BAD_CALLEE_ACCOUNT"){$.ajax({url:"Call.action?act=call_options&callType="+jaxtrOut+"&error=The person you are trying to reach is not authorized to receive the call",cache:false,success:function(data){$.jaxtrBox.reveal(data)}})}else{if(c2cPolicy.reasonCode=="BAD_CALLER_ACCOUNT"){$.ajax({url:"Call.action?act=call_options&callType="+jaxtrOut+"&error=You are not authorized to make this call",cache:false,success:function(data){$.jaxtrBox.reveal(data)}})}else{if(c2cPolicy.reasonCode=="CALLER_MUST_BE_MEMBER"){loginScreenMessage="Click to Call is for members only.";loginForwardURL="Call.action?act=startCall";var eventObject="{callToActionTypeString: 'LOGIN_C2C'}";currentCallToActionType="LOGIN_C2C";recordEvents("CallToActionEvt",eventObject);eventObject="{callToActionTypeString: 'REGISTER_C2C'}";currentCallToActionType2="REGISTER_C2C";recordEvents("CallToActionEvt",eventObject);$.ajax({url:"Call.action?act=login",cache:false,success:function(data){$.jaxtrBox.reveal(data)}})}else{if(c2cPolicy.reasonCode=="CALLER_ENDPOINT_OUTSIDE_SVC_AREA"){$.ajax({url:"Call.action?act=call_options&callType="+jaxtrOut+"&error=Jaxtr is not available in your region",cache:false,success:function(data){$.jaxtrBox.reveal(data)}})}else{if(c2cPolicy.reasonCode=="CALLEE_ENDPOINT_OUTSIDE_SVC_AREA"){$.ajax({url:"Call.action?act=call_options&callType="+jaxtrOut+"&error=Jaxtr is not available in your friends region",cache:false,success:function(data){$.jaxtrBox.reveal(data)}})}else{if(c2cPolicy.reasonCode=="INSUFFICIENT_BALANCE"){var msg="You need calling credits to make this call at jaxtr's low rates. Start saving immediately by buying jaxtr credits today.";if(isDidCountry){msg+="<br/>Tip: To save even more, get a local jaxtr number to call this contact."}$.get("Call.action?act=errorLead2Buy&error="+msg,function(data){$.jaxtrBox.reveal(data,"")});return }}}}}}}}}else{handleC2CErrors(jsonMsg.callOptions.errorCode)}}})};var handleMemberOKClick=function(){user_phone_number=$("#phoneNumberText").val();var error=false;if(user_phone_number=="Enter your number here"||user_phone_number==""){$("#phoneNumberSelect option:selected").each(function(){user_phone_number=$(this).val();if(user_phone_number!="temp"){callerPhone=user_phone_number;jQuery.cookie("member_phone_number",user_phone_number)}else{jQuery("#phoneError").html("Please select a phone");error=true}})}else{$("#countryCodeSelect option:selected").each(function(){countryISOCode=$(this).text().split(" ")[0]});shouldAddPhone=true;phoneWithoutCountryCode=user_phone_number;country_code=$("#countryCodeSelect").val();countryISOCode=country_code.split(" ")[0];countryDialCode=$("#dialCode").val();callerPhone=countryDialCode+user_phone_number}if(error){return }if(CallOutUtils.validatePhone(callerPhone)){var call_method=$("input[@name=call_method]:checked").val();if(jaxtrOut==0){call_method="did"}if(call_method=="did"){$.jaxtrBox.loading(true);$.ajax({url:"Call.action?act=showDID",cache:false,success:function(data){$.jaxtrBox.reveal(data);$("#okButton").unbind("keypress");$("#phoneNumberText").unbind("keypress");$("#call_method_c2c").unbind("keypress");$("#call_method_c2c").unbind("keypress")}})}else{if(c2cPolicy.allowed){if(c2cPolicy.allowedDurationSec<300){warningMessage="At your current credit balance, your call will last less than 5 minutes.";warningType="c2c5mins";var eventObject="{callToActionTypeString: 'BUY_JAX_C2C_LESS_THAN_5MINS'}";currentCallToActionType="BUY_JAX_C2C_LESS_THAN_5MINS";recordEvents("CallToActionEvt",eventObject);eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'CALL_LASTS_LESS_THAN_5_MINS'}";recordEvents("ClickToCallRequestEvt",eventObject);$.get("Call.action?act=c2cwarn",function(data){$.jaxtrBox.reveal(data,"")});return }$.jaxtrBox.loading(true);$.ajax({url:"Call.action?act=startCall",cache:false,success:function(data){$.jaxtrBox.reveal(data)}})}else{eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'"+c2cPolicy.reasonCode+"'}";recordEvents("ClickToCallRequestEvt",eventObject);switch(c2cPolicy.reasonCode){case"CALLEE_ENDPOINT_IS_SIB":$.get("Call.action?act=error&error=The number: "+callee+" is invalid. Please retry.",function(data){$.jaxtrBox.reveal(data,"")});break;case"SERVER_FAILURE":jQuery("#phoneError").html("Server failure. Please retry later.");break;case"BAD_CALLEE_ACCOUNT":jQuery("#phoneError").html("The person you are trying to reach is not authorized to receive the call");break;case"BAD_CALLER_ACCOUNT":jQuery("#phoneError").html("You are not authorized to make this call");break;case"CALLER_MUST_BE_MEMBER":loginScreenMessage="Click to Call is for members only.";loginForwardURL="Call.action?act=startCall";var eventObject="{callToActionTypeString: 'LOGIN_C2C'}";currentCallToActionType="LOGIN_C2C";recordEvents("CallToActionEvt",eventObject);eventObject="{callToActionTypeString: 'REGISTER_C2C'}";currentCallToActionType2="REGISTER_C2C";recordEvents("CallToActionEvt",eventObject);$.ajax({url:"Call.action?act=login",cache:false,success:function(data){$.jaxtrBox.reveal(data)}});break;case"CALLER_ENDPOINT_OUTSIDE_SVC_AREA":jQuery("#phoneError").html("We dont have our service in your friends region");break;case"INSUFFICIENT_BALANCE":warningMessage="You need calling credits to make this call at jaxtr's low rates. Start saving immediately by buying jaxtr credits today.";warningType="c2c1min";var eventObject="{callToActionTypeString: 'BUY_JAX_C2C_LESS_THAN_1MIN'}";currentCallToActionType="BUY_JAX_C2C_LESS_THAN_1MIN";recordEvents("CallToActionEvt",eventObject);$.ajax({url:"Call.action?act=c2cwarn",cache:false,success:function(data){$.jaxtrBox.reveal(data)}});break;default:jQuery("#phoneError").html("Unknown error. Please retry");break}}}}else{jQuery("#phoneError").html(CEMessages.INVALID_NUMBER);if(call_method=="did"){var eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'INVALID_NUMBER'}";recordEvents("AssignDidRequestEvt",eventObject)}else{var eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'INVALID_NUMBER'}";recordEvents("ClickToCallRequestEvt",eventObject)}}};var initializeMemberOptions=function(user_phone_number){if($("#phoneNumberSelect").length>0){if(user_phone_number!=null&&user_phone_number!="undefined"){callerPhone=user_phone_number;$("#phoneNumberSelect option").each(function(){if($(this).val()==callerPhone){$(this).attr("selected","selected")}})}else{$("#phoneNumberSelect option:selected").each(function(){user_phone_number=$(this).val();if(user_phone_number!="temp"){callerPhone=$(this).val();jQuery.cookie("member_phone_number",callerPhone)}else{jQuery("#phoneError").html("Please select a phone");return }})}if(callerPhone!=null){jQuery("#optionsLoading").show();jQuery.ajax({type:"POST",url:"callcontrol",cache:false,data:{act:"call_options",jaxtrOut:jaxtrOut,cid:callerPhone,cidhide:0,destctx:callee},success:function(msg){var jsonMsg=eval("("+msg+")");if(!jsonMsg.callOptions.error){didPolicy=jsonMsg.callOptions.didCallOptionPolicy;c2cPolicy=jsonMsg.callOptions.c2cCallOptionPolicy;jaxBalance=jsonMsg.callOptions.jaxBalance;showOptions();$("#okButton").keypress(function(e){if(e.keyCode==13){if(callerIsMember){handleMemberOKClick()}else{handleNonMemberOKClick()}return false}})}else{handleOptionsErrors(jsonMsg.callOptions.errorCode);jQuery("#optionsLoading").hide()}}});jQuery("#okButton").show();$("#okButton").removeClass("button");$("#okButton").addClass("button_centered")}}else{enableNextButton()}};var updateCallCost=function(user_phone_number){if(user_phone_number!=null){jQuery("#optionsLoading").show();jQuery.ajax({type:"POST",url:"callcontrol",cache:false,data:{act:"call_options",jaxtrOut:jaxtrOut,cid:user_phone_number,cidhide:0,destctx:callee},success:function(msg){var jsonMsg=eval("("+msg+")");if(!jsonMsg.callOptions.error){didPolicy=jsonMsg.callOptions.didCallOptionPolicy;c2cPolicy=jsonMsg.callOptions.c2cCallOptionPolicy;var c2Cjax=Math.round((c2cPolicy.rateMicrojaxPerSec/1000000)*60);var displayRate=getDisplayC2CCallRate(c2Cjax);$("#footerText").html("This call costs: "+displayRate)}else{handleOptionsErrors(jsonMsg.callOptions.errorCode);jQuery("#optionsLoading").hide()}}})}};var getDisplayC2CCallRate=function(c2Cjax){var displayC2CCallRate="";var div=this.parent.document.getElementById("currencyValues");var xData=div.innerHTML.split(",");var symbol=xData[0].replace("&amp;","&");var numericRateC2C=((c2Cjax*(0.008))*xData[1]).toFixed(3);displayC2CCallRate=symbol+numericRateC2C+"/min";return displayC2CCallRate};var getDisplayC2CBalance=function(c2Cjax){var displayC2CCallRate="";var div=this.parent.document.getElementById("currencyValues");var xData=div.innerHTML.split(",");var symbol=xData[0].replace("&amp;","&");var numericRateC2C=((c2Cjax*(0.008))*xData[1]).toFixed(2);displayC2CCallRate=symbol+numericRateC2C;return displayC2CCallRate};var showOptions=function(){if(jaxtrOut==0){$("#call_element_controls").html('<div style="font-size: 13px; font-weight: bold; padding: 25px; text-align: center;">Jaxtr will give you a phone number that you call to talk with this member for <span style="color: #F67C1B; font-weight: bold;">Free!</span></div>')}else{$("#call_method_did").keypress(function(e){if(e.keyCode==13){if(callerIsMember){handleMemberOKClick()}else{handleNonMemberOKClick()}return false}});$("#call_method_c2c").keypress(function(e){if(e.keyCode==13){if(callerIsMember){handleMemberOKClick()}else{handleNonMemberOKClick()}return false}});if(didPolicy.domesticDidAvailable){jQuery("#call_method_did").attr("checked","checked")}else{jQuery("#call_method_did_text_hint").text("Jaxtr gives you a number that you call to reach your contact.");jQuery("#info_icon").show()}if(didPolicy.rateMicrojaxPerSec>0){jQuery("#call_method_did_rate").removeClass("rate");jQuery("#call_method_did_rate").text(Math.round((didPolicy.rateMicrojaxPerSec/1000000)*60)+" jax/min")}else{jQuery("#call_method_did_rate").removeClass("rate");jQuery("#call_method_did_rate").addClass("free-rate");jQuery("#call_method_did_rate").text("Free!")}jQuery("#c2c").text("Call me now");if(c2cPolicy.rateMicrojaxPerSec==0){jQuery("#c2cRate").text("-")}else{jQuery("#c2cRate").text(Math.round((c2cPolicy.rateMicrojaxPerSec/1000000)*60)+" jax/min");c2cJaxCost=Math.round((c2cPolicy.rateMicrojaxPerSec/1000000)*60)}}jQuery("#okButton").show();$("#okButton").removeClass("button");$("#okButton").addClass("button_centered");jQuery("#jaxtrBox .jaxtrInfoBoxControls").show("slow");jQuery("#nextButton").hide();jQuery("#optionsLoading").hide();if(callerIsMember){if(jaxBalance!="-1"){jQuery("#footerText").text(jaxBalance+" jax available")}else{jQuery("#footerText").text("Jax currently unavailable")}}var jaxtrCallType="JAXTR_OUT";if(jaxtrOut==0){jaxtrCallType="JAXTR_IN"}var eventObject="{callee: '"+callee+"', jaxtrCallType:'"+jaxtrCallType+"', callElementActionType:'SHOW_OPTIONS'}";recordEvents("CallElementActionEvt",eventObject);$("#okButton").focus()};var rand=function(min,max){var offset=min;var range=(max-min)+1;var randomNumber=Math.floor(Math.random()*range)+offset;return randomNumber};var showDID=function(showUpsell){var rate=null;$("#didLoading").show();$("#showDID").hide();if(didPolicy.allowed&&didPolicy.localPhoneNumber){if(callerIsMember){var jax=Math.round((didPolicy.rateMicrojaxPerSec/1000000)*60);var numericRate="";jQuery.ajax({type:"POST",url:"Call.action",data:{act:"jaxBalance"},cache:false,success:function(msg){var jsonMsg=eval("("+msg+")");if(!jsonMsg.error){if((jsonMsg.jaxBalance>0)&&(jsonMsg.purchaseJaxBalance<1)){var xx=(jax*(0.008));numericRate=xx.toFixed(3);numericRate="($ "+numericRate+"/min)"}if(didPolicy.rateMicrojaxPerSec>0){if(jaxtrOut==0){rate=jax+" jax/min "+numericRate}else{if(CallElement.getCanSendDIDBySMS()){rate=jax+" jax/min "+numericRate+' <div style="padding-top: 30px;"><span id="didBySMS"><a style="color: #23A5FF; text-decoration: none;" href="javascript:CallElement.sendDIDToPhone(\''+didPolicy.localPhoneNumber.displayPhoneNumber+'\');"">Click here</a> <br/> to SMS the number to my phone</span><br/><br/>or<br/><br/></div><div><a style="color: #23A5FF; text-decoration: none;" href="javascript:CallElement.showDIDforMember(\'c2c\');">Click to call me now</a> <br/>(extra '+(c2cJaxCost-jax)+" jax/min) </div>"}else{rate=jax+" jax/min "+numericRate+' <div style="padding-top: 30px;">&nbsp;<div><a style="color: #23A5FF; text-decoration: none;" href="javascript:CallElement.showDIDforMember(\'c2c\');">Click to call me now</a> <br/>(extra '+(c2cJaxCost-jax)+" jax/min) </div>"}}}else{rate="Free!"}if(didPolicy.domesticDidAvailable){$("#headerText").html('<br />Call this number to talk <br/> with your contact <br/><a style="font-weight: normal; font-size: 12px; color: #888888;" href="javascript:CallElement.showSDWhy();">(Why ?)</a>');$("#didNumber").html(didPolicy.localPhoneNumber.domesticDisplayString+' <br/> <div style="font-size: 14px;">'+rate+"</div>");if(jaxtrOut==0){$("#message").html('This call may be directed to jaxtr voicemail <br/> depending on this member\'s settings. <a style="color: #2B9BFD; text-decoration: none;" target="_blank" href="http://support.jaxtr.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=87">Learn more</a>.')}else{}}else{$("#didNumber").html(didPolicy.localPhoneNumber.displayPhoneNumber+' <br/> <span style="font-size: 14px;">'+rate+"</span>");$("#headerText").html("<br/> Call this number to talk <br/> &nbsp; &nbsp; with your contact");if(jaxtrOut==0){$("#message").html('No local jaxtr number in your country is currently available. Your phone provider charges a fee to call this number. <br /> <br /> This call may be directed to jaxtr voicemail <br/> depending on this member\'s settings. <a style="color: #2B9BFD; text-decoration: none;" target="_blank" href="http://support.jaxtr.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=87">Learn more</a>.')}else{$("#message").html("No local jaxtr number in your country is currently available. Your phone provider charges a fee to call this number. ")}}if(callerIsMember){jQuery("#footerText").text("Your jax balance: "+jaxBalance)}else{jQuery("#footerText").text("Sign up to call anyone in the world with jaxtr!")}$("#okButton").text("Close");$("#buyButton").text("Buy jax");$("#okButton").show();$("#buyButton").show();if(showUpsell){setTimeout("CallElement.showDIDUpsell()",30000)}$("#okButton").click(function(){closeBox("did")});if(callerIsMember){$("#buyButton").click(handleBuyButtonClick)}else{$("#buyButton").text("Sign up");$("#buyButton").click(handleRegisterButtonClick)}$("#didLoading").hide();$("#showDID").show()}}})}else{if(didPolicy.domesticDidAvailable){$("#headerText").html('<br />Call this number to talk <br/> with your contact <br/><a style="font-weight: normal; font-size: 12px; color: #888888;" href="javascript:CallElement.showSDWhy();">(Why ?)</a>');$("#didNumber").html(didPolicy.localPhoneNumber.domesticDisplayString+' <br/> <div style="font-size: 14px;">Free!</div>');if(jaxtrOut==0){$("#message").html('This call may be directed to jaxtr voicemail <br/> depending on this member\'s settings. <a style="color: #2B9BFD; text-decoration: none;" target="_blank" href="http://support.jaxtr.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=87">Learn more</a>.')}else{}}else{$("#didNumber").html(didPolicy.localPhoneNumber.displayPhoneNumber+' <br/> <span style="font-size: 14px;">Free!</span>');$("#headerText").html("<br/> Call this number to talk <br/> &nbsp; &nbsp; with your contact");if(jaxtrOut==0){$("#message").html('No local jaxtr number in your country is currently available. Your phone provider charges a fee to call this number. <br /> <br /> This call may be directed to jaxtr voicemail <br/> depending on this member\'s settings. <a style="color: #2B9BFD; text-decoration: none;" target="_blank" href="http://support.jaxtr.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=87">Learn more</a>.')}else{$("#message").html("No local jaxtr number in your country is currently available. Your phone provider charges a fee to call this number. ")}}jQuery("#footerText").text("Sign up to call anyone in the world with jaxtr!");$("#okButton").text("Close");$("#buyButton").text("Buy jax");$("#okButton").show();$("#buyButton").show();if(showUpsell){setTimeout("CallElement.showDIDUpsell()",30000)}$("#okButton").click(function(){closeBox("did")});$("#buyButton").text("Sign up");$("#buyButton").click(handleRegisterButtonClick);$("#didLoading").hide();$("#showDID").show()}}else{if(didPolicy.reasonCode=="FAILED_TO_ASSIGN_DID"){$.get("Call.action?act=errorNoDID&c2cJaxCost="+c2cJaxCost+"&error=No more jaxtr numbers available in your region.",function(data){$.jaxtrBox.reveal(data,"")})}else{if(didPolicy.reasonCode=="CALLEE_ENDPOINT_IS_SIB"){$.get("Call.action?act=error&error=Phone number of "+callee+" is invalid.",function(data){$.jaxtrBox.reveal(data,"")})}else{if(didPolicy.reasonCode=="CALLEE_ENDPOINT_OUTSIDE_SVC_AREA"){$.get("Call.action?act=error&error=Jaxtr is not available in your friends region.",function(data){$.jaxtrBox.reveal(data,"")});return }else{if(didPolicy.reasonCode=="SERVER_FAILURE"){$.get("Call.action?act=error&error=Unable to make a call. Please retry after a few minutes.",function(data){$.jaxtrBox.reveal(data,"")});return }else{if(didPolicy.reasonCode=="CALLER_MUST_BE_MEMBER"){loginScreenMessage="You have already received a complimentary local number. Log in or sign up to get more.";loginForwardURL="Call.action?act=showDID";var eventObject="{callToActionTypeString: 'LOGIN_1DID_LIMIT_REACHED'}";currentCallToActionType="LOGIN_1DID_LIMIT_REACHED";recordEvents("CallToActionEvt",eventObject);eventObject="{callToActionTypeString: 'REGISTER_1DID_LIMIT_REACHED'}";currentCallToActionType2="REGISTER_1DID_LIMIT_REACHED";recordEvents("CallToActionEvt",eventObject);$.ajax({url:"Call.action?act=login",cache:false,success:function(data){$.jaxtrBox.reveal(data)}})}else{if(didPolicy.reasonCode=="CALLER_MUST_BE_PAYING_MEMBER"){$("#headerText").html("You have used all five of <br/> your complimentary local numbers");$("#message").html("<br /> <br /> Add some jax now to get more local numbers.");$("#didNumber").hide();$("#okButton").text("Close");$("#okButton").show();$("#buyButton").show();$("#okButton").click(function(){closeBox("did")});var eventObject="{callToActionTypeString: 'BUY_JAX_5DID_LIMIT_REACHED'}";currentCallToActionType="BUY_JAX_5DID_LIMIT_REACHED";recordEvents("CallToActionEvt",eventObject);if(callerIsMember){jQuery("#footerText").text("Your jax balance: "+jaxBalance)}else{jQuery("#footerText").text("Sign up to call anyone in the world with jaxtr!")}if(showUpsell){setTimeout("CallElement.showDIDUpsell()",10000)}$("#buyButton").click(handleBuyButtonClick);$("#didLoading").hide();$("#showDID").show()}else{if(didPolicy.reasonCode=="BAD_CALLER_ACCOUNT"){$.get("Call.action?act=error&error=You cannot make this call.",function(data){$.jaxtrBox.reveal(data,"")});return }else{if(didPolicy.reasonCode=="INSUFFICIENT_BALANCE"){$.get("Call.action?act=error&error=You do not have sufficient funds to make this call.",function(data){$.jaxtrBox.reveal(data,"")});return }else{if(didPolicy.reasonCode=="BAD_CALLEE_ACCOUNT"){$.get("Call.action?act=error&error=You cannot make this call.",function(data){$.jaxtrBox.reveal(data,"")});return }else{if(didPolicy.reasonCode=="FROZEN_ACCOUNT"){$.get("Call.action?act=error&error=Account is on hold for security review, please contact billing@jaxtr.com.",function(data){$.jaxtrBox.reveal(data,"")});return }else{if(didPolicy.reasonCode=="BANNED_CALLEE"){$.get("Call.action?act=bannedCallee",function(data){$.jaxtrBox.reveal(data,"")});return }else{alert("Please report a bug mentioning this: "+didPolicy.reasonCode)}}}}}}}}}}}}};var handleC2CErrors=function(errorCode){var eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'"+errorCode+"'}";switch(errorCode){case"CALLEE_ENDPOINT_IS_SIB":$.get("Call.action?act=error&error=The number: "+callee+" is invalid. Please retry.",function(data){$.jaxtrBox.reveal(data,"")});break;case"SERVER_FAILURE":$.get("Call.action?act=call_options&callType="+jaxtrOut+"&error="+CEMessages.SERVER_FAILURE,function(data){$.jaxtrBox.reveal(data,"")});recordEvents("ClickToCallRequestEvt",eventObject);break;case"INVALID_NUMBER":$.get("Call.action?act=call_options&callType="+jaxtrOut+"&error="+CEMessages.INVALID_NUMBER,function(data){$.jaxtrBox.reveal(data,"")});recordEvents("ClickToCallRequestEvt",eventObject);break;case"CONTEXT_NULL":$.get("Call.action?act=call_options&callType="+jaxtrOut+"&error="+CEMessages.CONTEXT_NULL,function(data){$.jaxtrBox.reveal(data,"")});recordEvents("ClickToCallRequestEvt",eventObject);break;case"CALLEE_DOES_NOT_EXIST":$.get("Call.action?act=call_options&callType="+jaxtrOut+"&error="+CEMessages.CALLEE_DOES_NOT_EXIST,function(data){$.jaxtrBox.reveal(data,"")});break;case"PHONE_EXISTS":recordEvents("ClickToCallRequestEvt",eventObject);shouldAddPhone=false;loginScreenMessage="Please login to your jaxtr account";loginForwardURL="Call.action?act=startCall";$.get("Call.action?act=login",function(data){$.jaxtrBox.reveal(data,"")});break;case"CALLER_MUST_LOGIN":recordEvents("ClickToCallRequestEvt",eventObject);loginScreenMessage="Please login to your jaxtr account";loginForwardURL="Call.action?act=startCall";$.get("Call.action?act=login",function(data){$.jaxtrBox.reveal(data,"")});break;case"PHONE_NUMBER_FORMAT_ERROR":recordEvents("ClickToCallRequestEvt",eventObject);$.get("Call.action?act=call_options&callType="+jaxtrOut+"&error="+CEMessages.PHONE_NUMBER_FORMAT_ERROR,function(data){$.jaxtrBox.reveal(data,"")});break;case"CALL_MAP_EMPTY":break;case"CANCEL_CALL":recordEvents("ClickToCallRequestEvt",eventObject);closeBox("");break;default:recordEvents("ClickToCallRequestEvt",eventObject);$.get("Call.action?act=call_options&callType="+jaxtrOut+"&error="+CEMessages.RETRY,function(data){$.jaxtrBox.reveal(data,"")});break}};var closeBox=function(action){callerPhone=null;phoneWithoutCountryCode=null;callerIsMember=null;countryISOCode=null;loginScreenMessage=null;loginForwardURL=null;countryDialCode=null;shouldAddPhone=false;counter=null;callId=null;queryForStatus=true;warningMessage=null;warningType=null;didPolicy=null;c2cPolicy=null;currentCallToActionType=null;currentCallToActionType2=null;currentCallToActionTypeId=null;currentCallToActionTypeId2=null;if(action=="did"){CallElement.showDIDUpsell(true)}else{$.jaxtrBox.close()}var jaxtrCallType="JAXTR_OUT";if(jaxtrOut==0){jaxtrCallType="JAXTR_IN"}var eventObject="{callee: '"+callee+"', jaxtrCallType:'"+jaxtrCallType+"', callElementActionType:'CLOSE_CALL_ELEMENT'}";recordEvents("CallElementActionEvt",eventObject)};var handleC2CEndErrors=function(errorCode){switch(errorCode){case"CALL_MAP_EMPTY":alert("something is wrong");break;case"CALL_ID_EMPTY":alert("something is wrong");break;default:break}};var handleOptionsErrors=function(errorCode){switch(errorCode){case"INVALID_NUMBER":$.get("Call.action?act=error&error="+CEMessages.INVALID_NUMBER,function(data){$.jaxtrBox.reveal(data,"")});break;case"CONTEXT_NULL":$.get("Call.action?act=error&error="+CEMessages.CONTEXT_NULL,function(data){$.jaxtrBox.reveal(data,"")});break;case"CALLEE_DOES_NOT_EXIST":$.get("Call.action?act=error&error="+CEMessages.CALLEE_DOES_NOT_EXIST,function(data){$.jaxtrBox.reveal(data,"")});break;case"CALLER_MUST_LOGIN":loginScreenMessage="Please login to your jaxtr account";loginForwardURL="Call.action?act=call_options&callType="+jaxtrOut;$.get("Call.action?act=login",function(data){$.jaxtrBox.reveal(data,"")});break;case"PHONE_NUMBER_FORMAT_ERROR":$.get("Call.action?act=error&error="+CEMessages.INVALID_NUMBER,function(data){$.jaxtrBox.reveal(data,"")});break;case"INVALID_CALLEE_NUMBER":$.get("Call.action?act=error&error="+CEMessages.INVALID_CALLEE_NUMBER,function(data){$.jaxtrBox.reveal(data,"")});break;case"CALLEE_ENDPOINT_OUTSIDE_SVC_AREA":$.get("Call.action?act=error&error="+CEMessages.CALLEE_ENDPOINT_OUTSIDE_SVC_AREA,function(data){$.jaxtrBox.reveal(data,"")});break;case"CALLEE_ENDPOINT_IS_SIB":$.get("Call.action?act=error&error=The number: "+callee+" is invalid. Please retry.",function(data){$.jaxtrBox.reveal(data,"")});break;default:$.get("Call.action?act=error&error="+CEMessages.RETRY,function(data){$.jaxtrBox.reveal(data,"")});break}$("#okButton").click(function(){closeBox("")})};var handleOptionsErrorsForC2C=function(errorCode){switch(errorCode){case"INVALID_NUMBER":$("#error_message").html('<div class="jx_notification_error"><p>'+CEMessages.INVALID_NUMBER+"</p></div>");break;case"CONTEXT_NULL":$("#error_message").html('<div class="jx_notification_error"><p>'+CEMessages.CONTEXT_NULL+"</p></div>");break;case"CALLEE_DOES_NOT_EXIST":$("#error_message").html('<div class="jx_notification_error"><p>'+CEMessages.CALLEE_DOES_NOT_EXIST+"</p></div>");break;case"CALLER_MUST_LOGIN":loginScreenMessage="Please login to your jaxtr account";loginForwardURL="Call.action?act=call_options&callType="+jaxtrOut;$.jaxtrBox.show("Call.action?act=login");break;case"PHONE_NUMBER_FORMAT_ERROR":$("#error_message").html('<div class="jx_notification_error"><p>'+CEMessages.INVALID_NUMBER+"</p></div>");break;case"INVALID_CALLEE_NUMBER":$("#error_message").html('<div class="jx_notification_error"><p>'+CEMessages.INVALID_CALLEE_NUMBER+"</p></div>");break;case"CALLEE_ENDPOINT_OUTSIDE_SVC_AREA":$("#error_message").html('<div class="jx_notification_error"><p>'+CEMessages.CALLEE_ENDPOINT_OUTSIDE_SVC_AREA+"</p></div>");break;case"CALLEE_ENDPOINT_IS_SIB":$("#error_message").html('<div class="jx_notification_error"><p>The number: '+callee+" is invalid. Please retry.</p></div>");$.get("Call.action?act=error&error=The number: "+callee+" is invalid. Please retry.",function(data){$.jaxtrBox.reveal(data,"")});break;default:$("#error_message").html('<div class="jx_notification_error"><p>'+CEMessages.RETRY+"</p></div>");break}};var handleShowDIDErrors=function(errorCode){var eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'"+errorCode+"'}";recordEvents("AssignDidRequestEvt",eventObject);switch(errorCode){case"CALLEE_ENDPOINT_IS_SIB":$.get("Call.action?act=error&error=The number "+callee+" is invalid. Please retry.",function(data){$.jaxtrBox.reveal(data,"")});break;case"INVALID_NUMBER":$.get("Call.action?act=call_options&callType="+jaxtrOut+"&error="+CEMessages.INVALID_NUMBER,function(data){$.jaxtrBox.reveal(data,"")});break;case"CONTEXT_NULL":$.get("Call.action?act=call_options&callType="+jaxtrOut+"&error="+CEMessages.CONTEXT_NULL,function(data){$.jaxtrBox.reveal(data,"")});break;case"CALLEE_DOES_NOT_EXIST":$.get("Call.action?act=call_options&callType="+jaxtrOut+"&error="+CEMessages.CALLEE_DOES_NOT_EXIST,function(data){$.jaxtrBox.reveal(data,"")});break;case"PHONE_EXISTS":shouldAddPhone=false;loginScreenMessage="This phone is already registered with Jaxtr.";loginForwardURL="Call.action?act=showDID";var eventObject="{callToActionTypeString: 'LOGIN_1DID_LIMIT_REACHED'}";currentCallToActionType="LOGIN_1DID_LIMIT_REACHED";recordEvents("CallToActionEvt",eventObject);$.get("Call.action?act=login",function(data){$.jaxtrBox.reveal(data,"")});break;case"CALLER_MUST_LOGIN":loginScreenMessage="";loginForwardURL="Call.action?act=showDID";var eventObject="{callToActionTypeString: 'LOGIN_1DID_LIMIT_REACHED'}";currentCallToActionType="LOGIN_1DID_LIMIT_REACHED";recordEvents("CallToActionEvt",eventObject);$.get("Call.action?act=login",function(data){$.jaxtrBox.reveal(data,"")});break;case"PHONE_NUMBER_FORMAT_ERROR":$.get("Call.action?act=call_options&callType="+jaxtrOut+"&error="+CEMessages.PHONE_NUMBER_FORMAT_ERROR,function(data){$.jaxtrBox.reveal(data,"")});break;default:$.get("Call.action?act=call_options&callType="+jaxtrOut+"&error="+CEMessages.RETRY,function(data){$.jaxtrBox.reveal(data,"")});break}};var handleNonMemberNextClick=function(){jQuery("#phoneError").html("");country_code=null;user_phone_number=null;$("#countryCodeSelect option:selected").each(function(){country_code=$(this).val()});user_phone_number=$("#phoneNumberText").val();countryISOCode=country_code.split(" ")[0];countryDialCode=$("#dialCode").val();phoneWithoutCountryCode=user_phone_number;callerPhone=countryDialCode+user_phone_number;if(CallOutUtils.validatePhone(callerPhone)){jQuery("#optionsLoading").show();jQuery.ajax({type:"POST",url:"callcontrol",cache:false,data:{act:"call_options",jaxtrOut:jaxtrOut,cid:callerPhone,cidhide:0,destctx:callee},success:function(msg){var jsonMsg=eval("("+msg+")");if(!jsonMsg.callOptions.error){didPolicy=jsonMsg.callOptions.didCallOptionPolicy;c2cPolicy=jsonMsg.callOptions.c2cCallOptionPolicy;showOptions()}else{handleOptionsErrors(jsonMsg.callOptions.errorCode);jQuery("#optionsLoading").hide()}}})}else{jQuery("#phoneError").html(CEMessages.INVALID_NUMBER)}};var handleAddPhoneClick=function(){jQuery("#phoneError").html("");var country_code=null;user_phone_number=null;$("#countryCodeSelect option:selected").each(function(){country_code=$(this).val()});user_phone_number=$("#phoneNumberText").val();countryISOCode=country_code.split(" ")[0];countryDialCode=$("#dialCode").val();phoneWithoutCountryCode=user_phone_number;callerPhone=countryDialCode+user_phone_number;var phone_type=$("#phone_type").val();if(CallOutUtils.validatePhone(callerPhone)){if(callerIsMember){jQuery.ajax({type:"POST",url:"AddPhoneUnv.action",cache:false,data:{country:countryISOCode,dialCode:countryDialCode,phoneNumber:phoneWithoutCountryCode,phoneType:phone_type},success:function(msg){$("#loadingDiv").hide();var jsonMsg=eval("("+msg+")");if(!jsonMsg.success&&!jsonMsg.phone_exists_already){handleAddPhoneErrorForC2C(jsonMsg);eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'ADD_PHONE_REQUEST_FAILED'}";recordEvents("ClickToCallRequestEvt",eventObject)}else{jQuery.cookie("member_phone_number",callerPhone);$.jaxtrBox.show("Call.action?act=c2c_select_phone&callType=1")}}})}}else{jQuery("#phoneError").html(CEMessages.INVALID_NUMBER)}};var handleNextClick=function(){jQuery("#phoneError").html("");var country_code=null;user_phone_number=null;$("#countryCodeSelect option:selected").each(function(){country_code=$(this).val()});user_phone_number=$("#phoneNumberText").val();countryISOCode=country_code.split(" ")[0];countryDialCode=$("#dialCode").val();phoneWithoutCountryCode=user_phone_number;callerPhone=countryDialCode+user_phone_number;if(CallOutUtils.validatePhone(callerPhone)){if(isDidCountry&&callerIsMember){jQuery.ajax({type:"POST",url:"AddPhoneUnv.action",cache:false,data:{country:countryISOCode,dialCode:countryDialCode,phoneNumber:phoneWithoutCountryCode},success:function(msg){$("#loadingDiv").hide();var jsonMsg=eval("("+msg+")");if(!jsonMsg.success&&!jsonMsg.phone_exists_already){handleAddPhoneError(jsonMsg);eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'ADD_PHONE_REQUEST_FAILED'}";recordEvents("ClickToCallRequestEvt",eventObject)}else{$.jaxtrBox.show("Call.action?act=call_options&callType=1")}}})}else{jQuery("#optionsLoading").show();jQuery.ajax({type:"POST",url:"callcontrol",cache:false,data:{act:"call_options",jaxtrOut:jaxtrOut,cid:callerPhone,cidhide:0,destctx:callee},success:function(msg){var jsonMsg=eval("("+msg+")");if(!jsonMsg.callOptions.error){didPolicy=jsonMsg.callOptions.didCallOptionPolicy;c2cPolicy=jsonMsg.callOptions.c2cCallOptionPolicy;jaxBalance=jsonMsg.callOptions.jaxBalance;showOptions();$("#phoneNumberText").unbind("keypress")}else{handleOptionsErrors(jsonMsg.callOptions.errorCode);jQuery("#optionsLoading").hide()}}})}}else{jQuery("#phoneError").html(CEMessages.INVALID_NUMBER)}};var processCookieValues=function(user_phone_number,country_code){countryISOCode=country_code.split(" ")[0];countryDialCode=country_code.split(" ")[1];phoneWithoutCountryCode=user_phone_number;callerPhone=countryDialCode+user_phone_number;if(CallOutUtils.validatePhone(callerPhone)){$("#phoneNumberText").val(phoneWithoutCountryCode);$("#countryCodeSelect option").each(function(){if($(this).val()==country_code){$(this).attr("selected","selected")}$("#dialCode").val(countryDialCode)});jQuery("#optionsLoading").show();jQuery.ajax({type:"POST",url:"callcontrol",cache:false,data:{act:"call_options",jaxtrOut:jaxtrOut,cid:callerPhone,cidhide:0,destctx:callee},success:function(msg){var jsonMsg=eval("("+msg+")");if(!jsonMsg.callOptions.error){didPolicy=jsonMsg.callOptions.didCallOptionPolicy;c2cPolicy=jsonMsg.callOptions.c2cCallOptionPolicy;showOptions()}else{handleOptionsErrors(jsonMsg.callOptions.errorCode);jQuery("#optionsLoading").hide();enableNextButton()}}})}};var handleNonMemberOKClick=function(){user_phone_number=$("#phoneNumberText").val();$("#countryCodeSelect option:selected").each(function(){country_code=$(this).val()});countryISOCode=country_code.split(" ")[0];countryDialCode=$("#dialCode").val();phoneWithoutCountryCode=user_phone_number;callerPhone=countryDialCode+user_phone_number;jQuery.cookie("non_member_phone_number",user_phone_number);jQuery.cookie("non_member_country_code",country_code);if(CallOutUtils.validatePhone(callerPhone)){shouldAddPhone=true;var call_method=$("input[@name=call_method]:checked").val();if(jaxtrOut==0){call_method="did"}if(call_method=="did"){$.jaxtrBox.loading(true);$.ajax({url:"Call.action?act=showDID",cache:false,success:function(data){$.jaxtrBox.reveal(data);$("#okButton").unbind("keypress")}})}else{loginScreenMessage="Click to Call is for members only.";loginForwardURL="Call.action?act=startCall";var eventObject="{callToActionTypeString: 'LOGIN_C2C'}";currentCallToActionType="LOGIN_C2C";recordEvents("CallToActionEvt",eventObject);eventObject="{callToActionTypeString: 'REGISTER_C2C'}";currentCallToActionType2="REGISTER_C2C";recordEvents("CallToActionEvt",eventObject);$.ajax({url:"Call.action?act=login",cache:false,success:function(data){$.jaxtrBox.reveal(data)}})}}else{jQuery("#phoneError").html("Invalid phone number");jQuery("#jaxtrBox .jaxtrInfoBoxControls").show("slow")}};var handleAddPhoneError=function(jsonMsg){if(jsonMsg.user_null==true){loginScreenMessage="Please login to your jaxtr account";loginForwardURL="Call.action?act=showDID";$.get("Call.action?act=login",function(data){$.jaxtrBox.reveal(data,"")});return }else{if(jsonMsg.max_phones_reached==true){$.get("Call.action?act=error&error=You can only have 3 numbers associated with your account.",function(data){$.jaxtrBox.reveal(data,"")});return }else{if(jsonMsg.phone_exists_already==true){}}}$.get("Call.action?act=call_options&callType="+jaxtrOut+"&error="+jsonMsg.message,function(data){$.jaxtrBox.reveal(data,"")})};var handleAddPhoneErrorForC2C=function(jsonMsg){if(jsonMsg.user_null==true){loginScreenMessage="Please login to your jaxtr account";loginForwardURL="Call.action?act=c2c_select_phone&callType=1";$.get("Call.action?act=login",function(data){$.jaxtrBox.reveal(data,"")});return }else{if(jsonMsg.max_phones_reached==true){jQuery("#phoneError").html("ERROR: 4001. You can only have 3 numbers associated with your account.");return }else{if(jsonMsg.phone_exists_already==true){$.get("Call.action?act=c2c_select_phone&callType=1",function(data){$.jaxtrBox.reveal(data,"")})}else{if(jsonMsg.invalid_phone==true){jQuery("#phoneError").html("Your phone number is invalid.")}else{if(jsonMsg.phone_banned==true){jQuery("#phoneError").html("ERROR: 4002. Security error, please contact support.")}else{if(jsonMsg.unknown_error==true){jQuery("#phoneError").html("Unknown error. Please try again later.")}else{if(jsonMsg.phone_out_of_service==true){jQuery("#phoneError").html("ERROR: 4003. Jaxtr is not supported in your country yet.")}else{if(jsonMsg.phone_diff_user==true){jQuery("#phoneError").html("ERROR: 4004. Security error, please contact support.")}else{if(jsonMsg.phone_max_accounts_within_month==true){jQuery("#phoneError").html("ERROR: 4005. Security error, please contact support.")}}}}}}}}}$.get("Call.action?act=call_options&callType="+jaxtrOut+"&error="+jsonMsg.message,function(data){$.jaxtrBox.reveal(data,"")})};var getLocalNumber=function(){$("#loadingDiv").show();jQuery.ajax({type:"POST",url:"callcontrol",cache:false,data:{act:"get_local_number",jaxtrOut:jaxtrOut,cid:callerPhone,cidhide:0,destctx:callee},success:function(msg){$("#loadingDiv").hide();var jsonMsg=eval("("+msg+")");if(!jsonMsg.callOptions.error){didPolicy=jsonMsg.callOptions.didCallOptionPolicy;jaxBalance=jsonMsg.callOptions.jaxBalance;showDID(true)}else{handleShowDIDErrors(jsonMsg.callOptions.errorCode)}}})};var processDIDSelection=function(){if(CallOutUtils.validatePhone(callerPhone)){$("#loadingDiv").show();if(callerIsMember&&shouldAddPhone){jQuery.ajax({type:"POST",url:"AddPhoneUnv.action",cache:false,data:{country:countryISOCode,dialCode:countryDialCode,phoneNumber:phoneWithoutCountryCode},success:function(msg){$("#loadingDiv").hide();var jsonMsg=eval("("+msg+")");if(!jsonMsg.success&&!jsonMsg.phone_exists_already){handleAddPhoneError(jsonMsg);eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'ADD_PHONE_REQUEST_FAILED'}";recordEvents("ClickToCallRequestEvt",eventObject)}else{getLocalNumber()}}})}else{getLocalNumber()}}else{$.get("Call.action?act=call_options&callType="+jaxtrOut+"&error=Invalid phone number",function(data){$.jaxtrBox.reveal(data,"")})}};var initializeLogin=function(){$("#message").text(loginScreenMessage);$("#password").keypress(function(e){if(e.keyCode==13){handleLoginClick();return false}});$("#close_icon").show();$("#help_icon").hide();$("#loginButton").click(function(){handleLoginClick()})};var handleLoginClick=function(){var screenName=$("#screenName").val();var password=$("#password").val();if(screenName==""){$("#loginError").text("Enter your screen name");$("#forgotPassword").show();return }if(password==""){$("#loginError").text("Enter your password");$("#forgotPassword").show();return }if(currentCallToActionTypeId!=null){var eventObject="{callToActionTypeString: '"+currentCallToActionType+"'}";currentCallToActionType=null;currentCallToActionTypeId=null;currentCallToActionType2=null;currentCallToActionTypeId2=null;recordEvents("CallToActionResponseEvt",eventObject)}if(currentCallToActionTypeId2!=null){var eventObject="{callToActionTypeString: '"+currentCallToActionType2+"'}";currentCallToActionType2=null;currentCallToActionTypeId2=null;currentCallToActionType=null;currentCallToActionTypeId=null;recordEvents("CallToActionResponseEvt",eventObject)}jQuery.ajax({type:"POST",url:"callcontrol",cache:false,data:{act:"login",wtype:"js-call-element",screenName:screenName,password:password},success:function(msg){var jsonMsg=eval("("+msg+")");if(!jsonMsg.callOptions.error){$("#password").unbind("keypress");callerIsMember=true;$.get(loginForwardURL,function(data){$.jaxtrBox.reveal(data,"")})}else{$("#forgotPassword").show();if(jsonMsg.callOptions.errorCode=="NOT_ALPHA_USER"){$.get("Call.action?act=notAlphaUser",function(data){$.jaxtrBox.reveal(data,"")});return }else{if(jsonMsg.callOptions.errorCode=="INVALID_NAME_PASSWORD"){$("#loginError").text("Please check your screen name / password")}else{$("#loginError").text("Unknown error, please retry")}}}}})};var enableNextButton=function(){$("#nextButton").show();$("#phoneNumberText").keypress(function(e){if(e.keyCode==13){handleNextClick();return false}});$("#phoneNumberText").focus();$("#nextButton").click(handleNextClick);$("#nextButton").removeClass("button");$("#nextButton").addClass("button_centered")};return{init:function(callee2,jaxtrOut2){callee=callee2;jaxtrOut=jaxtrOut2},setJaxtrOut:function(jaxtrOut2){jaxtrOut=jaxtrOut2},setCallee:function(callee2){callee=callee2},setPhoneFromServer:function(pNumber){phoneFromServer=pNumber},setIsDIDCountry:function(didCountry){isDidCountry=didCountry},setLoginForwardUrl:function(url){loginForwardURL=url},setLoginScreenMessage:function(msg){loginScreenMessage=msg},makeACallNonMember:function(){didUpsellShown=false;var displayCalleeString=CallOutUtils.ellipsis(callee,17);$("#jaxtr_box_title").html("Call to: "+displayCalleeString);$("#help_icon").show();$("#help_icon").click(function(){$.jaxtrBox.loading(true);$.get("Call.action?act=help",function(data){$.jaxtrBox.reveal(data,"")})});$("#close_icon").show();$("#close_icon").click(closeBox);callerIsMember=false;shouldAddPhone=false;callerPhone=null;$("input:text").hint();$("#tempNumber").show();$("#phoneNumberText").focus();var user_phone_number=jQuery.cookie("non_member_phone_number");var country_code=jQuery.cookie("non_member_country_code");if(user_phone_number!=null&&country_code!=null&&country_code!="undefined"&&user_phone_number!="undefined"){processCookieValues(user_phone_number,country_code)}else{enableNextButton()}$("#okButton").click(handleNonMemberOKClick)},startCall:function(){$("#help_icon").hide();callId=null;queryForStatus=true;if(CallOutUtils.validatePhone(callerPhone)){if(callerIsMember&&shouldAddPhone){jQuery.ajax({type:"POST",url:"AddPhoneUnv.action",cache:false,data:{country:countryISOCode,dialCode:countryDialCode,phoneNumber:phoneWithoutCountryCode},success:function(msg){$("#loadingDiv").hide();var jsonMsg=eval("("+msg+")");if(!jsonMsg.success&&!jsonMsg.phone_exists_already){eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'ADD_PHONE_REQUEST_FAILED'}";recordEvents("ClickToCallRequestEvt",eventObject);handleAddPhoneError(jsonMsg)}else{makeC2C()}}})}else{if(callerIsMember){makeC2C()}else{if(!callerIsMember){loginScreenMessage="Click to Call is for members only.";loginForwardURL="Call.action?act=startCall";$.get("Call.action?act=login",function(data){$.jaxtrBox.reveal(data,"")})}}}}else{alert("Invalid number")}},updateStatus:function(){updateCallStatus()},endCall:function(){clickEndCall()},showDID:function(){$("#help_icon").hide();processDIDSelection()},getC2cJaxCost:function(){return c2cJaxCost},initLoginScreen:function(){initializeLogin()},initVoiceMailWarning:function(){initializeVoiceMailWarning()},initWarningScreen:function(){initializeWarningScreen()},initUpsellScreen:function(){initializeUpsellScreen()},initErrorScreen:function(){$("#close_icon").hide();$("#help_icon").hide();$("#buttonOne").click(function(){closeBox("")})},initVerifyPhoneScreen:function(){$("#help_icon").hide();$("#help_back_button").click(function(e){$.get("Call.action?act=call_options&callType="+jaxtrOut,function(data){$.jaxtrBox.reveal(data,"")})})},showSDWhy:function(){$.jaxtrBox.loading(true);$.get("Call.action?act=didHelp",function(data){$.jaxtrBox.reveal(data,"")})},sendDIDToPhone:function(did){jQuery.post("SendDIDBySMS.action",{did:did,callee:callee},function(data){if(data.success!=true){$("#didBySMS").html('<span style="color: red; font-size: 12px; ">Unable to send.</span>')}else{$("#didBySMS").html('<span style="color: green; font-size: 12px; ">Number has been sent to your phone.</span>')}},"json")},setCanSendDIDBySMS:function(canSend){canGetSMSByDID=canSend},getCanSendDIDBySMS:function(){return canGetSMSByDID},showDIDUpsell:function(shouldCloseBox){if(!didUpsellShown){didUpsellShown=true;$("#close_icon").hide();if($.jaxtrBox.isOpen){$.ajax({url:"HelpBuy.action",cache:false,success:function(data){if(data.length>0){$.jaxtrBox.reveal(data)}else{if(shouldCloseBox){$.jaxtrBox.close()}}}})}}else{if(shouldCloseBox){$.jaxtrBox.close()}}},setCountryPhoneCode:function(valu){if(valu=="other"){$.get("Call.action?act=verifyPhone",function(data){$.jaxtrBox.reveal(data,"")})}else{var dialCode=valu.split(" ");$("#dialCode").attr("disabled","false");$("#dialCode").val(dialCode[1]);$("#dialCode").attr("disabled","true")}},startC2CCall:function(){var call_method="c2c";didUpsellShown=false;var displayCalleeString=CallOutUtils.ellipsis(callee,17);$("#jaxtr_box_title").html("Call to: "+displayCalleeString);$("#help_icon").hide();$("#close_icon").show();$("#close_icon").click(closeBox);shouldAddPhone=false;callerIsMember=true;$("input:text").hint();if(callerPhone==null){var user_phone_number=phoneFromServer;callerPhone=user_phone_number;jQuery.cookie("member_phone_number",callerPhone)}jQuery.ajax({type:"POST",url:"callcontrol",cache:false,data:{act:"call_options",jaxtrOut:jaxtrOut,cid:callerPhone,cidhide:0,destctx:callee},success:function(msg){var jsonMsg=eval("("+msg+")");if(!jsonMsg.callOptions.error){didPolicy=jsonMsg.callOptions.didCallOptionPolicy;c2cPolicy=jsonMsg.callOptions.c2cCallOptionPolicy;c2cJaxCost=Math.round((c2cPolicy.rateMicrojaxPerSec/1000000)*60);jaxBalance=jsonMsg.callOptions.jaxBalance;if(CallOutUtils.validatePhone(callerPhone)){if(jaxtrOut==0){call_method="did"}if(call_method=="did"){$.ajax({url:"Call.action?act=showDID",cache:false,success:function(data){CallElement.showDID();$("#okButton").unbind("keypress");$("#phoneNumberText").unbind("keypress");$("#call_method_c2c").unbind("keypress");$("#call_method_c2c").unbind("keypress")}})}else{if(c2cPolicy.allowed){if(c2cPolicy.allowedDurationSec<300){warningMessage="At your current credit balance, your call will last less than 5 minutes.";warningType="c2c5mins";var eventObject="{callToActionTypeString: 'BUY_JAX_C2C_LESS_THAN_5MINS'}";currentCallToActionType="BUY_JAX_C2C_LESS_THAN_5MINS";recordEvents("CallToActionEvt",eventObject);eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'CALL_LASTS_LESS_THAN_5_MINS'}";recordEvents("ClickToCallRequestEvt",eventObject);$.jaxtrBox.show("Call.action?act=c2cwarn");return }$.jaxtrBox.loading(true);$.jaxtrBox.show("Call.action?act=startCall")}else{eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'"+c2cPolicy.reasonCode+"'}";recordEvents("ClickToCallRequestEvt",eventObject);switch(c2cPolicy.reasonCode){case"CALLEE_ENDPOINT_IS_SIB":$("#error_message").html('<div class="jx_notification_error"><p>The number: '+callee+" is invalid. Please retry.</p></div>");break;case"SERVER_FAILURE":$("#error_message").html('<div class="jx_notification_error"><p>Server failure. Please retry later.</p></div>');break;case"BAD_CALLEE_ACCOUNT":$("#error_message").html('<div class="jx_notification_error"><p>The person you are trying to reach is not authorized to receive the call.</p></div>');break;case"BAD_CALLER_ACCOUNT":$("#error_message").html('<div class="jx_notification_error"><p>You are not authorized to make this call.</p></div>');break;case"CALLER_MUST_BE_MEMBER":$("#error_message").html('<div class="jx_notification_error"><p>Please <a href="http://www.jaxtr.com/user/login.jsp">login</a> and try again.</p></div>');break;case"CALLER_ENDPOINT_OUTSIDE_SVC_AREA":$("#error_message").html('<div class="jx_notification_error"><p>Jaxtr does not provide its service in your contacts region.</p></div>');break;case"INSUFFICIENT_BALANCE":var msg="You need calling credits to make this call at jaxtr's low rates. Start saving immediately by buying jaxtr credits today.";if(isDidCountry){msg+='<br/><span style="font-size: 0.8em; font-weight: normal; color: #777777;">Tip: To save even more, get a local jaxtr number to call this contact.</span>'}warningMessage=msg;warningType="c2c1min";var eventObject="{callToActionTypeString: 'BUY_JAX_C2C_LESS_THAN_1MIN'}";currentCallToActionType="BUY_JAX_C2C_LESS_THAN_1MIN";recordEvents("CallToActionEvt",eventObject);$.jaxtrBox.show("Call.action?act=c2cwarn");break;default:$("#error_message").html('<div class="jx_notification_error"><p>Unknown error. Please retry.</p></div>');break}}}}else{$("#error_message").html('<div class="jx_notification_error"><p>'+CEMessages.INVALID_NUMBER+"</p></div>");if(call_method=="did"){var eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'INVALID_NUMBER'}";recordEvents("AssignDidRequestEvt",eventObject)}else{var eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'INVALID_NUMBER'}";recordEvents("ClickToCallRequestEvt",eventObject)}}}else{handleOptionsErrorsForC2C(jsonMsg.callOptions.errorCode)}}})},showDIDforMember:function(call_method){didUpsellShown=false;var displayCalleeString=CallOutUtils.ellipsis(callee,17);$("#jaxtr_box_title").html("Call to: "+displayCalleeString);$("#help_icon").show();$("#help_icon").click(function(){$.jaxtrBox.loading(true);$.get("Call.action?act=help",function(data){$.jaxtrBox.reveal(data,"")})});$("#close_icon").show();$("#close_icon").click(closeBox);shouldAddPhone=false;callerIsMember=true;$("input:text").hint();if(callerPhone==null){var user_phone_number=null;user_phone_number=phoneFromServer;callerPhone=user_phone_number;jQuery.cookie("member_phone_number",callerPhone)}jQuery.ajax({type:"POST",url:"callcontrol",cache:false,data:{act:"call_options",jaxtrOut:jaxtrOut,cid:callerPhone,cidhide:0,destctx:callee},success:function(msg){var jsonMsg=eval("("+msg+")");if(!jsonMsg.callOptions.error){didPolicy=jsonMsg.callOptions.didCallOptionPolicy;c2cPolicy=jsonMsg.callOptions.c2cCallOptionPolicy;c2cJaxCost=Math.round((c2cPolicy.rateMicrojaxPerSec/1000000)*60);jaxBalance=jsonMsg.callOptions.jaxBalance;if(CallOutUtils.validatePhone(callerPhone)){if(jaxtrOut==0){call_method="did"}if(call_method=="did"){$.ajax({url:"Call.action?act=showDID",cache:false,success:function(data){CallElement.showDID();$("#okButton").unbind("keypress");$("#phoneNumberText").unbind("keypress");$("#call_method_c2c").unbind("keypress");$("#call_method_c2c").unbind("keypress")}})}else{if(c2cPolicy.allowed){if(c2cPolicy.allowedDurationSec<300){warningMessage="With your current jax balance, your call will last less than five minutes";warningType="c2c5mins";var eventObject="{callToActionTypeString: 'BUY_JAX_C2C_LESS_THAN_5MINS'}";currentCallToActionType="BUY_JAX_C2C_LESS_THAN_5MINS";recordEvents("CallToActionEvt",eventObject);eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'CALL_LASTS_LESS_THAN_5_MINS'}";recordEvents("ClickToCallRequestEvt",eventObject);$.get("Call.action?act=c2cwarn",function(data){$.jaxtrBox.reveal(data,"")});return }$.jaxtrBox.loading(true);$.ajax({url:"Call.action?act=startCall",cache:false,success:function(data){$.jaxtrBox.reveal(data)}})}else{eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'"+c2cPolicy.reasonCode+"'}";recordEvents("ClickToCallRequestEvt",eventObject);switch(c2cPolicy.reasonCode){case"CALLEE_ENDPOINT_IS_SIB":$.get("Call.action?act=error&error=The number: "+callee+" is invalid. Please retry.",function(data){$.jaxtrBox.reveal(data,"")});break;case"SERVER_FAILURE":jQuery("#phoneError").html("Server failure. Please retry later.");break;case"BAD_CALLEE_ACCOUNT":jQuery("#phoneError").html("The person you are trying to reach is not authorized to receive the call");break;case"BAD_CALLER_ACCOUNT":jQuery("#phoneError").html("You are not authorized to make this call");break;case"CALLER_MUST_BE_MEMBER":loginScreenMessage="Click to Call is for members only.";loginForwardURL="Call.action?act=startCall";var eventObject="{callToActionTypeString: 'LOGIN_C2C'}";currentCallToActionType="LOGIN_C2C";recordEvents("CallToActionEvt",eventObject);eventObject="{callToActionTypeString: 'REGISTER_C2C'}";currentCallToActionType2="REGISTER_C2C";recordEvents("CallToActionEvt",eventObject);$.ajax({url:"Call.action?act=login",cache:false,success:function(data){$.jaxtrBox.reveal(data)}});break;case"CALLER_ENDPOINT_OUTSIDE_SVC_AREA":jQuery("#phoneError").html("We dont have our service in your friends region");break;case"INSUFFICIENT_BALANCE":warningMessage="You need calling credits to make this call at jaxtr's low rates. Start saving immediately by buying jaxtr credits today.";warningType="c2c1min";var eventObject="{callToActionTypeString: 'BUY_JAX_C2C_LESS_THAN_1MIN'}";currentCallToActionType="BUY_JAX_C2C_LESS_THAN_1MIN";recordEvents("CallToActionEvt",eventObject);$.ajax({url:"Call.action?act=c2cwarn",cache:false,success:function(data){$.jaxtrBox.reveal(data)}});break;default:jQuery("#phoneError").html("Unknown error. Please retry");break}}}}else{jQuery("#phoneError").html(CEMessages.INVALID_NUMBER);if(call_method=="did"){var eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'INVALID_NUMBER'}";recordEvents("AssignDidRequestEvt",eventObject)}else{var eventObject="{callerPhoneNumber: '"+callerPhone+"', callContextType:'"+jaxtrOut+"', callContext:'"+callee+"', c2cReasonCode:'INVALID_NUMBER'}";recordEvents("ClickToCallRequestEvt",eventObject)}}}else{handleOptionsErrors(jsonMsg.callOptions.errorCode);jQuery("#optionsLoading").hide()}}})},initC2cSelectPhone:function(){var displayCalleeString=CallOutUtils.ellipsis(callee,17);$("#help_icon").hide();$("#close_icon").show();$("#close_icon").click(closeBox);shouldAddPhone=false;callerIsMember=true;callerPhone=null;$("input:text").hint();if(CALL_FROM_SCREEN==true){var jaxtrCallType="JAXTR_OUT";var eventObject="{callee: '"+callee+"', jaxtrCallType:'"+jaxtrCallType+"', callElementActionType:'ADD_UNV_PHONE_SCREEN'}";recordEvents("CallElementActionEvt",eventObject)}var user_phone_number=null;var prev_phone_number=jQuery.cookie("member_phone_number");if(prev_phone_number==null||prev_phone_number=="undefined"){user_phone_number=phoneFromServer;prev_phone_number=phoneFromServer}if($("#phoneNumberSelect").length>0){if(prev_phone_number!=null&&prev_phone_number!="undefined"){$("#phoneNumberSelect option").each(function(){if($(this).val()==prev_phone_number){$(this).attr("selected","selected");user_phone_number=prev_phone_number}})}}if(user_phone_number==null){user_phone_number=phoneFromServer}callerPhone=user_phone_number;$("#phoneNumberSelect").change(function(){$("#phoneNumberSelect option:selected").each(function(){if($(this).val()=="temp"){$("#tempNumber").show("slow");$("input:text").hint();$("#phoneNumberText").focus();$("#phoneNumberText").keypress(function(e){if(e.keyCode==13){handleAddPhoneClick();return false}});$("#callButton").hide();$("#addPhoneButton").show();$("#addPhoneButton").click(handleAddPhoneClick)}else{callerPhone=$(this).val();jQuery.cookie("member_phone_number",callerPhone);updateCallCost(callerPhone);$("#callButton").show();$("#addPhoneButton").hide();$("#addPhoneButton").unbind("click");$("#phoneNumberText").val("");$("#tempNumber").hide("slow")}})});if(user_phone_number!=""){updateCallCost(user_phone_number)}$("#callButton").click(function(){CallElement.startC2CCall()})},makeACallMember:function(){didUpsellShown=false;var displayCalleeString=CallOutUtils.ellipsis(callee,17);$("#jaxtr_box_title").html("Call to: "+displayCalleeString);$("#help_icon").show();$("#help_icon").click(function(){$.jaxtrBox.loading(true);$.get("Call.action?act=help",function(data){$.jaxtrBox.reveal(data,"")})});$("#close_icon").show();$("#close_icon").click(closeBox);shouldAddPhone=false;callerIsMember=true;callerPhone=null;$("input:text").hint();if(CALL_FROM_SCREEN==true){var jaxtrCallType="JAXTR_OUT";if(jaxtrOut==0){jaxtrCallType="JAXTR_IN"}var eventObject="{callee: '"+callee+"', jaxtrCallType:'"+jaxtrCallType+"', callElementActionType:'ADD_UNV_PHONE_SCREEN'}";recordEvents("CallElementActionEvt",eventObject)}$("#phoneNumberSelect").change(function(){$("#phoneNumberSelect option:selected").each(function(){if($(this).val()=="temp"){$("#tempNumber").show("slow");$("input:text").hint();$("#phoneNumberText").focus();$("#phoneNumberText").keypress(function(e){if(e.keyCode==13){handleMemberOKClick();return false}})}else{$("#phoneNumberText").val("");$("#tempNumber").hide("slow")}})});var user_phone_number=jQuery.cookie("member_phone_number");initializeMemberOptions(user_phone_number);$("#okButton").click(handleMemberOKClick)}}}();